Closed thearyadev closed 3 months ago
You can now use container queries
in SimpleGrid component. With container queries, grid columns and spacing
will be adjusted based on the container width, not the viewport width.
Example of using container queries. To see how the grid changes, resize the root element
of the demo with the resize handle located at the bottom right corner of the demo:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { SimpleGrid } from '@ mantine/core';
function Demo() { return ( // Wrapper div is added for demonstration purposes only, // it is not required in real projects <div style={{ resize: 'horizontal', overflow: 'hidden', maxWidth: '100%' }}> <SimpleGrid type="container" cols={{ base: 1, '300px': 2, '500px': 5 }} spacing={{ base: 10, '300px': 'xl' }} > <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> </SimpleGrid> </div> ); }">
import { SimpleGrid } from '@ mantine/core';function Demo() { return ( // Wrapper div is added for demonstration purposes only, // it is not required in real projects <div style={{ resize: 'horizontal', overflow: 'hidden', maxWidth: '100%' }}> <SimpleGrid type="container" cols={{ base: 1, '300px': 2, '500px': 5 }} spacing={{ base: 10, '300px': 'xl' }} > <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> </SimpleGrid> </div> ); }
New Checkbox.Indicator and Radio.Indicator
components look exactly the same as Checkbox
and Radio
components, but they do not
have any semantic meaning, they are just visual representations of checkbox and radio states.
Checkbox.Indicator
component:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { Checkbox, Group } from '@ mantine/core';
function Demo() { return ( <Group> <Checkbox.Indicator /> <Checkbox.Indicator checked /> <Checkbox.Indicator indeterminate /> <Checkbox.Indicator disabled /> <Checkbox.Indicator disabled checked /> <Checkbox.Indicator disabled indeterminate /> </Group> ); }">
import { Checkbox, Group } from '@ mantine/core';function Demo() { return ( <Group> <Checkbox.Indicator /> <Checkbox.Indicator checked /> <Checkbox.Indicator indeterminate /> <Checkbox.Indicator disabled /> <Checkbox.Indicator disabled checked /> <Checkbox.Indicator disabled indeterminate /> </Group> ); }
Radio.Indicator
component:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { Group, Radio } from '@ mantine/core';
function Demo() { return ( <Group> <Radio.Indicator /> <Radio.Indicator checked /> <Radio.Indicator disabled /> <Radio.Indicator disabled checked /> </Group> ); }">
import { Group, Radio } from '@ mantine/core';function Demo() { return ( <Group> <Radio.Indicator /> <Radio.Indicator checked /> <Radio.Indicator disabled /> <Radio.Indicator disabled checked /> </Group> ); }
New Checkbox.Card and Radio.Card
components can be used as replacements for Checkbox
and Radio
to build custom cards/buttons/etc.
that work as checkboxes and radios. Components are accessible by default and support the same
keyboard interactions as input[type="checkbox"]
and input[type="radio"]
.
Checkbox.Card
component:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { useState } from 'react'; import { Checkbox, Group, Text } from '@ mantine/core'; import classes from './Demo.module.css';
function Demo() { const [checked, setChecked] = useState(false);
return ( <Checkbox.Card className={classes.root} radius="md" checked={checked} onClick={() => setChecked((c) => !c)} > <Group wrap="nowrap" align="flex-start"> <Checkbox.Indicator /> <div> <Text className={classes.label}>@ mantine/core</Text> <Text className={classes.description}> Core components library: inputs, buttons, overlays, etc. </Text> </div> </Group> </Checkbox.Card> ); }">
import { useState } from 'react'; import { Checkbox, Group, Text } from '@ mantine/core'; import classes from './Demo.module.css';function Demo() { const [checked, setChecked] = useState(false);
return ( <Checkbox.Card className={classes.root} radius="md" checked={checked} onClick={() => setChecked((c) => !c)} > <Group wrap="nowrap" align="flex-start"> <Checkbox.Indicator /> <div> <Text className={classes.label}>@ mantine/core</Text> <Text className={classes.description}> Core components library: inputs, buttons, overlays, etc. </Text> </div> </Group> </Checkbox.Card> ); }
Checkbox.Card
component with Checkbox.Group
:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { useState } from 'react'; import { Checkbox, Group, Stack, Text } from '@ mantine/core'; import classes from './Demo.module.css';
const data = [ { name: '@ mantine/core', description: 'Core components library: inputs, buttons, overlays, etc.', }, { name: '@ mantine/hooks', description: 'Collection of reusable hooks for React applications.' }, { name: '@ mantine/notifications', description: 'Notifications system' }, ];
function Demo() { const [value, setValue] = useState<string[]>([]);
const cards = data.map((item) => ( <Checkbox.Card className={classes.root} radius="md" value={item.name} key={item.name}> <Group wrap="nowrap" align="flex-start"> <Checkbox.Indicator /> <div> <Text className={classes.label}>{item.name}</Text> <Text className={classes.description}>{item.description}</Text> </div> </Group> </Checkbox.Card> ));
return ( <> <Checkbox.Group value={value} onChange={setValue} label="Pick packages to install" description="Choose all packages that you will need in your application" > <Stack pt="md" gap="xs"> {cards} </Stack> </Checkbox.Group>
<Text fz="xs" mt="md">
CurrentValue: {value.join(', ') || '–'}
</Text>
</>
); }">
import { useState } from 'react'; import { Checkbox, Group, Stack, Text } from '@ mantine/core'; import classes from './Demo.module.css';const data = [ { name: '@ mantine/core', description: 'Core components library: inputs, buttons, overlays, etc.', }, { name: '@ mantine/hooks', description: 'Collection of reusable hooks for React applications.' }, { name: '@ mantine/notifications', description: 'Notifications system' }, ];
function Demo() { const [value, setValue] = useState<string[]>([]);
const cards = data.map((item) => ( <Checkbox.Card className={classes.root} radius="md" value={item.name} key={item.name}> <Group wrap="nowrap" align="flex-start"> <Checkbox.Indicator /> <div> <Text className={classes.label}>{item.name}</Text> <Text className={classes.description}>{item.description}</Text> </div> </Group> </Checkbox.Card> ));
return ( <> <Checkbox.Group value={value} onChange={setValue} label="Pick packages to install" description="Choose all packages that you will need in your application" > <Stack pt="md" gap="xs"> {cards} </Stack> </Checkbox.Group>
<span class="pl-c1"><</span><span class="pl-smi">Text</span> <span class="pl-c1">fz</span><span class="pl-c1">=</span><span class="pl-s">"xs"</span> <span class="pl-c1">mt</span><span class="pl-c1">=</span><span class="pl-s">"md"</span><span class="pl-c1">></span> CurrentValue: <span class="pl-kos">{</span><span class="pl-s1">value</span><span class="pl-kos">.</span><span class="pl-en">join</span><span class="pl-kos">(</span><span class="pl-s">', '</span><span class="pl-kos">)</span> <span class="pl-c1">||</span> <span class="pl-s">'–'</span><span class="pl-kos">}</span> <span class="pl-c1"><</span><span class="pl-c1">/</span><span class="pl-smi">Text</span><span class="pl-c1">></span> <span class="pl-c1"><</span><span class="pl-c1">/</span><span class="pl-c1">></span>
); }
Radio.Card
component:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { useState } from 'react'; import { Group, Radio, Text } from '@ mantine/core'; import classes from './Demo.module.css';
function Demo() { const [checked, setChecked] = useState(false);
return ( <Radio.Card className={classes.root} radius="md" checked={checked} onClick={() => setChecked((c) => !c)} > <Group wrap="nowrap" align="flex-start"> <Radio.Indicator /> <div> <Text className={classes.label}>@ mantine/core</Text> <Text className={classes.description}> Core components library: inputs, buttons, overlays, etc. </Text> </div> </Group> </Radio.Card> ); }">
import { useState } from 'react'; import { Group, Radio, Text } from '@ mantine/core'; import classes from './Demo.module.css';function Demo() { const [checked, setChecked] = useState(false);
return ( <Radio.Card className={classes.root} radius="md" checked={checked} onClick={() => setChecked((c) => !c)} > <Group wrap="nowrap" align="flex-start"> <Radio.Indicator /> <div> <Text className={classes.label}>@ mantine/core</Text> <Text className={classes.description}> Core components library: inputs, buttons, overlays, etc. </Text> </div> </Group> </Radio.Card> ); }
Radio.Card
component with Radio.Group
:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { useState } from 'react'; import { Group, Radio, Stack, Text } from '@ mantine/core'; import classes from './Demo.module.css';
const data = [ { name: '@ mantine/core', description: 'Core components library: inputs, buttons, overlays, etc.', }, { name: '@ mantine/hooks', description: 'Collection of reusable hooks for React applications.' }, { name: '@ mantine/notifications', description: 'Notifications system' }, ];
function Demo() { const [value, setValue] = useState<string | null>(null);
const cards = data.map((item) => ( <Radio.Card className={classes.root} radius="md" value={item.name} key={item.name}> <Group wrap="nowrap" align="flex-start"> <Radio.Indicator /> <div> <Text className={classes.label}>{item.name}</Text> <Text className={classes.description}>{item.description}</Text> </div> </Group> </Radio.Card> ));
return ( <> <Radio.Group value={value} onChange={setValue} label="Pick one package to install" description="Choose a package that you will need in your application" > <Stack pt="md" gap="xs"> {cards} </Stack> </Radio.Group>
<Text fz="xs" mt="md">
CurrentValue: {value || '–'}
</Text>
</>
); }">
import { useState } from 'react'; import { Group, Radio, Stack, Text } from '@ mantine/core'; import classes from './Demo.module.css';const data = [ { name: '@ mantine/core', description: 'Core components library: inputs, buttons, overlays, etc.', }, { name: '@ mantine/hooks', description: 'Collection of reusable hooks for React applications.' }, { name: '@ mantine/notifications', description: 'Notifications system' }, ];
function Demo() { const [value, setValue] = useState<string | null>(null);
const cards = data.map((item) => ( <Radio.Card className={classes.root} radius=<sp...
vercel[bot] commented 4 months agoThe latest updates on your projects. Learn more about Vercel for Git ↗︎
Name Status Preview Comments Updated (UTC) top500-aggregator ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 22, 2024 6:51am
This PR was automatically created by Snyk using the credentials of a real user.
![snyk-top-banner](https://github.com/andygongea/OWASP-Benchmark/assets/818805/c518c423-16fe-447e-b67f-ad5a49b5d123)
Snyk has created this PR to upgrade @mantine/core from 7.9.1 to 7.10.1.
:information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.- The recommended version is **3 versions** ahead of your current version. - The recommended version was released on **23 days ago**.
Release notes
Package name: @mantine/core
What's Changed
[@ mantine/charts]
BarChart: Add waterfall type (#6231)[@ mantine/form]
Fixform.setFieldError
called insideform.onSubmit
not working correctly in some cases (#6101)[@ mantine/core]
SegmentedControl: Fix false error reported by React 18.3+ for incorrect key prop usage[@ mantine/hooks]
use-fetch: Fix incorrect error handling (#6278)[@ mantine/core]
Fixbd
style prop not being applied in some components (#6282)[@ mantine/core]
NumberInput: Fix incorrect leading zeros handling (#6232)[@ mantine/core]
NumberInput: Fix incorrect logic while editing decimal values (#6232)[@ mantine/core]
ScrollArea: Fix scrollbar flickering on reveal with hover and scroll types (#6218)[@ mantine/hooks]
Update use-throttled-* hooks to emit updates on trailing edges (#6257)[@ mantine/core]
Input: AddinputSize
prop to setsize
html attribute on the input elementNew Contributors
Full Changelog: 7.10.0...7.10.1
View changelog with demos on mantine.dev website
Tree component
New Tree component:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { IconFolder, IconFolderOpen } from '@ tabler/icons-react'; import { Group, RenderTreeNodePayload, Tree } from '@ mantine/core'; import { CssIcon, NpmIcon, TypeScriptCircleIcon } from '@ mantinex/dev-icons'; import { data, dataCode } from './data'; import classes from './Demo.module.css';
interface FileIconProps { name: string; isFolder: boolean; expanded: boolean; }
function FileIcon({ name, isFolder, expanded }: FileIconProps) { if (name.endsWith('package.json')) { return <NpmIcon size={14} />; }
if (name.endsWith('.ts') || name.endsWith('.tsx') || name.endsWith('tsconfig.json')) { return <TypeScriptCircleIcon size={14} />; }
if (name.endsWith('.css')) { return <CssIcon size={14} />; }
if (isFolder) { return expanded ? ( <IconFolderOpen color="var(--mantine-color-yellow-9)" size={14} stroke={2.5} /> ) : ( <IconFolder color="var(--mantine-color-yellow-9)" size={14} stroke={2.5} /> ); }
return null; }
function Leaf({ node, expanded, hasChildren, elementProps }: RenderTreeNodePayload) { return ( <Group gap={5} {...elementProps}> <FileIcon name={node.value} isFolder={hasChildren} expanded={expanded} /> <span>{node.label}</span> </Group> ); }
function Demo() { return ( <Tree classNames={classes} selectOnClick clearSelectionOnOutsideClick data={data} renderNode={(payload) => <Leaf {...payload} />} /> ); }">
form.getInputNode
New
form.getInputNode(path)
handler returns input DOM node for the given field path.Form example, it can be used to focus input on form submit if there is an error:
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { Button, Group, TextInput } from '@ mantine/core'; import { isEmail, isNotEmpty, useForm } from '@ mantine/form';
function Demo() { const form = useForm({ mode: 'uncontrolled', initialValues: { name: '', email: '', },
});
return ( <form onSubmit={form.onSubmit( (values) => console.log(values), (errors) => { const firstErrorPath = Object.keys(errors)[0]; form.getInputNode(firstErrorPath)?.focus(); } )} > <TextInput withAsterisk label="Your name" placeholder="Your name" key={form.key('name')} {...form.getInputProps('name')} />
); }">