@mantine/core 9.1.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Autocomplete/Autocomplete.cjs +5 -1
- package/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/cjs/components/Card/Card.cjs +1 -1
- package/cjs/components/Card/Card.cjs.map +1 -1
- package/cjs/components/Checkbox/Checkbox.cjs +4 -1
- package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/cjs/components/ColorInput/ColorInput.cjs +5 -1
- package/cjs/components/ColorInput/ColorInput.cjs.map +1 -1
- package/cjs/components/Combobox/ComboboxClearButton/ComboboxClearButton.cjs +1 -1
- package/cjs/components/Combobox/ComboboxClearButton/ComboboxClearButton.cjs.map +1 -1
- package/cjs/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.cjs +1 -0
- package/cjs/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.cjs.map +1 -1
- package/cjs/components/Combobox/ComboboxSearch/ComboboxSearch.cjs +2 -1
- package/cjs/components/Combobox/ComboboxSearch/ComboboxSearch.cjs.map +1 -1
- package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.cjs +1 -0
- package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.cjs.map +1 -1
- package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.cjs +18 -12
- package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.cjs.map +1 -1
- package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs +17 -0
- package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs.map +1 -0
- package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs +170 -0
- package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs.map +1 -0
- package/cjs/components/FileInput/FileInput.cjs +5 -1
- package/cjs/components/FileInput/FileInput.cjs.map +1 -1
- package/cjs/components/Highlight/highlighter/highlighter.cjs +3 -3
- package/cjs/components/Highlight/highlighter/highlighter.cjs.map +1 -1
- package/cjs/components/Input/use-input-props.cjs +5 -1
- package/cjs/components/Input/use-input-props.cjs.map +1 -1
- package/cjs/components/JsonInput/JsonInput.cjs +5 -2
- package/cjs/components/JsonInput/JsonInput.cjs.map +1 -1
- package/cjs/components/MaskInput/MaskInput.cjs +5 -1
- package/cjs/components/MaskInput/MaskInput.cjs.map +1 -1
- package/cjs/components/MaskInput/use-mask-input-props.cjs +3 -2
- package/cjs/components/MaskInput/use-mask-input-props.cjs.map +1 -1
- package/cjs/components/MultiSelect/MultiSelect.cjs +19 -3
- package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/cjs/components/NativeSelect/NativeSelect.cjs +5 -1
- package/cjs/components/NativeSelect/NativeSelect.cjs.map +1 -1
- package/cjs/components/NumberInput/NumberInput.cjs +5 -1
- package/cjs/components/NumberInput/NumberInput.cjs.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs +6 -2
- package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/cjs/components/Pill/Pill.module.cjs.map +1 -1
- package/cjs/components/PillsInput/PillsInput.cjs +5 -1
- package/cjs/components/PillsInput/PillsInput.cjs.map +1 -1
- package/cjs/components/PinInput/PinInput.cjs +1 -1
- package/cjs/components/PinInput/PinInput.cjs.map +1 -1
- package/cjs/components/Popover/Popover.context.cjs.map +1 -1
- package/cjs/components/Popover/PopoverDropdown/PopoverDropdown.cjs +1 -1
- package/cjs/components/Popover/PopoverDropdown/PopoverDropdown.cjs.map +1 -1
- package/cjs/components/Radio/Radio.module.cjs.map +1 -1
- package/cjs/components/RollingNumber/DigitColumn.cjs +46 -0
- package/cjs/components/RollingNumber/DigitColumn.cjs.map +1 -0
- package/cjs/components/RollingNumber/RollingNumber.cjs +102 -0
- package/cjs/components/RollingNumber/RollingNumber.cjs.map +1 -0
- package/cjs/components/RollingNumber/RollingNumber.module.cjs +13 -0
- package/cjs/components/RollingNumber/RollingNumber.module.cjs.map +1 -0
- package/cjs/components/RollingNumber/build-value.cjs +22 -0
- package/cjs/components/RollingNumber/build-value.cjs.map +1 -0
- package/cjs/components/RollingNumber/get-digit-parts.cjs +40 -0
- package/cjs/components/RollingNumber/get-digit-parts.cjs.map +1 -0
- package/cjs/components/RollingNumber/get-render-slots.cjs +78 -0
- package/cjs/components/RollingNumber/get-render-slots.cjs.map +1 -0
- package/cjs/components/ScrollArea/ScrollArea.cjs +24 -10
- package/cjs/components/ScrollArea/ScrollArea.cjs.map +1 -1
- package/cjs/components/Select/Select.cjs +5 -1
- package/cjs/components/Select/Select.cjs.map +1 -1
- package/cjs/components/TagsInput/TagsInput.cjs +19 -4
- package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
- package/cjs/components/TextInput/TextInput.cjs +5 -1
- package/cjs/components/TextInput/TextInput.cjs.map +1 -1
- package/cjs/components/Textarea/Textarea.cjs +5 -2
- package/cjs/components/Textarea/Textarea.cjs.map +1 -1
- package/cjs/components/Tree/FlatTreeNode.cjs +2 -1
- package/cjs/components/Tree/FlatTreeNode.cjs.map +1 -1
- package/cjs/components/Tree/Tree.cjs +3 -1
- package/cjs/components/Tree/Tree.cjs.map +1 -1
- package/cjs/components/Tree/TreeNode.cjs +10 -5
- package/cjs/components/Tree/TreeNode.cjs.map +1 -1
- package/cjs/components/Tree/is-node-checked/is-node-checked.cjs +1 -0
- package/cjs/components/Tree/is-node-indeterminate/is-node-indeterminate.cjs +1 -0
- package/cjs/components/Tree/use-tree-node-drag-drop.cjs +46 -15
- package/cjs/components/Tree/use-tree-node-drag-drop.cjs.map +1 -1
- package/cjs/components/TreeSelect/TreeSelect.cjs +601 -0
- package/cjs/components/TreeSelect/TreeSelect.cjs.map +1 -0
- package/cjs/components/TreeSelect/TreeSelect.module.cjs +16 -0
- package/cjs/components/TreeSelect/TreeSelect.module.cjs.map +1 -0
- package/cjs/components/TreeSelect/TreeSelectOption.cjs +95 -0
- package/cjs/components/TreeSelect/TreeSelectOption.cjs.map +1 -0
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs +34 -0
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs.map +1 -0
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs +30 -0
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs.map +1 -0
- package/cjs/core/MantineProvider/use-props/use-props.cjs +10 -2
- package/cjs/core/MantineProvider/use-props/use-props.cjs.map +1 -1
- package/cjs/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.cjs +2 -2
- package/cjs/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.cjs.map +1 -1
- package/cjs/index.cjs +8 -0
- package/esm/components/Autocomplete/Autocomplete.mjs +5 -1
- package/esm/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/esm/components/Card/Card.mjs +1 -1
- package/esm/components/Card/Card.mjs.map +1 -1
- package/esm/components/Checkbox/Checkbox.mjs +4 -1
- package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
- package/esm/components/ColorInput/ColorInput.mjs +5 -1
- package/esm/components/ColorInput/ColorInput.mjs.map +1 -1
- package/esm/components/Combobox/ComboboxClearButton/ComboboxClearButton.mjs +1 -1
- package/esm/components/Combobox/ComboboxClearButton/ComboboxClearButton.mjs.map +1 -1
- package/esm/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.mjs +1 -0
- package/esm/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.mjs.map +1 -1
- package/esm/components/Combobox/ComboboxSearch/ComboboxSearch.mjs +2 -1
- package/esm/components/Combobox/ComboboxSearch/ComboboxSearch.mjs.map +1 -1
- package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.mjs +1 -0
- package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.mjs.map +1 -1
- package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.mjs +18 -12
- package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.mjs.map +1 -1
- package/esm/components/Combobox/use-pills-reorder/move-pill.mjs +17 -0
- package/esm/components/Combobox/use-pills-reorder/move-pill.mjs.map +1 -0
- package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs +169 -0
- package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs.map +1 -0
- package/esm/components/FileInput/FileInput.mjs +5 -1
- package/esm/components/FileInput/FileInput.mjs.map +1 -1
- package/esm/components/Highlight/highlighter/highlighter.mjs +3 -3
- package/esm/components/Highlight/highlighter/highlighter.mjs.map +1 -1
- package/esm/components/Input/use-input-props.mjs +5 -1
- package/esm/components/Input/use-input-props.mjs.map +1 -1
- package/esm/components/JsonInput/JsonInput.mjs +5 -2
- package/esm/components/JsonInput/JsonInput.mjs.map +1 -1
- package/esm/components/MaskInput/MaskInput.mjs +5 -1
- package/esm/components/MaskInput/MaskInput.mjs.map +1 -1
- package/esm/components/MaskInput/use-mask-input-props.mjs +4 -3
- package/esm/components/MaskInput/use-mask-input-props.mjs.map +1 -1
- package/esm/components/MultiSelect/MultiSelect.mjs +19 -3
- package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
- package/esm/components/NativeSelect/NativeSelect.mjs +5 -1
- package/esm/components/NativeSelect/NativeSelect.mjs.map +1 -1
- package/esm/components/NumberInput/NumberInput.mjs +5 -1
- package/esm/components/NumberInput/NumberInput.mjs.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.mjs +6 -2
- package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
- package/esm/components/Pill/Pill.module.mjs.map +1 -1
- package/esm/components/PillsInput/PillsInput.mjs +5 -1
- package/esm/components/PillsInput/PillsInput.mjs.map +1 -1
- package/esm/components/PinInput/PinInput.mjs +1 -1
- package/esm/components/PinInput/PinInput.mjs.map +1 -1
- package/esm/components/Popover/Popover.context.mjs.map +1 -1
- package/esm/components/Popover/PopoverDropdown/PopoverDropdown.mjs +1 -1
- package/esm/components/Popover/PopoverDropdown/PopoverDropdown.mjs.map +1 -1
- package/esm/components/Radio/Radio.module.mjs.map +1 -1
- package/esm/components/RollingNumber/DigitColumn.mjs +45 -0
- package/esm/components/RollingNumber/DigitColumn.mjs.map +1 -0
- package/esm/components/RollingNumber/RollingNumber.mjs +101 -0
- package/esm/components/RollingNumber/RollingNumber.mjs.map +1 -0
- package/esm/components/RollingNumber/RollingNumber.module.mjs +13 -0
- package/esm/components/RollingNumber/RollingNumber.module.mjs.map +1 -0
- package/esm/components/RollingNumber/build-value.mjs +22 -0
- package/esm/components/RollingNumber/build-value.mjs.map +1 -0
- package/esm/components/RollingNumber/get-digit-parts.mjs +40 -0
- package/esm/components/RollingNumber/get-digit-parts.mjs.map +1 -0
- package/esm/components/RollingNumber/get-render-slots.mjs +78 -0
- package/esm/components/RollingNumber/get-render-slots.mjs.map +1 -0
- package/esm/components/ScrollArea/ScrollArea.mjs +25 -11
- package/esm/components/ScrollArea/ScrollArea.mjs.map +1 -1
- package/esm/components/Select/Select.mjs +5 -1
- package/esm/components/Select/Select.mjs.map +1 -1
- package/esm/components/TagsInput/TagsInput.mjs +19 -4
- package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
- package/esm/components/TextInput/TextInput.mjs +5 -1
- package/esm/components/TextInput/TextInput.mjs.map +1 -1
- package/esm/components/Textarea/Textarea.mjs +5 -2
- package/esm/components/Textarea/Textarea.mjs.map +1 -1
- package/esm/components/Tree/FlatTreeNode.mjs +2 -1
- package/esm/components/Tree/FlatTreeNode.mjs.map +1 -1
- package/esm/components/Tree/Tree.mjs +3 -1
- package/esm/components/Tree/Tree.mjs.map +1 -1
- package/esm/components/Tree/TreeNode.mjs +10 -5
- package/esm/components/Tree/TreeNode.mjs.map +1 -1
- package/esm/components/Tree/is-node-checked/is-node-checked.mjs +1 -1
- package/esm/components/Tree/is-node-indeterminate/is-node-indeterminate.mjs +1 -1
- package/esm/components/Tree/use-tree-node-drag-drop.mjs +45 -15
- package/esm/components/Tree/use-tree-node-drag-drop.mjs.map +1 -1
- package/esm/components/TreeSelect/TreeSelect.mjs +600 -0
- package/esm/components/TreeSelect/TreeSelect.mjs.map +1 -0
- package/esm/components/TreeSelect/TreeSelect.module.mjs +16 -0
- package/esm/components/TreeSelect/TreeSelect.module.mjs.map +1 -0
- package/esm/components/TreeSelect/TreeSelectOption.mjs +94 -0
- package/esm/components/TreeSelect/TreeSelectOption.mjs.map +1 -0
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs +34 -0
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs.map +1 -0
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs +29 -0
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs.map +1 -0
- package/esm/core/MantineProvider/use-props/use-props.mjs +10 -2
- package/esm/core/MantineProvider/use-props/use-props.mjs.map +1 -1
- package/esm/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.mjs +2 -2
- package/esm/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.mjs.map +1 -1
- package/esm/index.mjs +5 -1
- package/lib/components/Combobox/Combobox.types.d.ts +3 -0
- package/lib/components/Combobox/ComboboxClearButton/ComboboxClearButton.d.ts +1 -1
- package/lib/components/Combobox/index.d.ts +2 -0
- package/lib/components/Combobox/use-combobox-target-props/use-combobox-target-props.d.ts +3 -1
- package/lib/components/Combobox/use-pills-reorder/move-pill.d.ts +2 -0
- package/lib/components/Combobox/use-pills-reorder/use-pills-reorder.d.ts +26 -0
- package/lib/components/MaskInput/MaskInput.d.ts +2 -0
- package/lib/components/MultiSelect/MultiSelect.d.ts +3 -1
- package/lib/components/Popover/Popover.context.d.ts +1 -1
- package/lib/components/RollingNumber/DigitColumn.d.ts +11 -0
- package/lib/components/RollingNumber/RollingNumber.d.ts +41 -0
- package/lib/components/RollingNumber/build-value.d.ts +10 -0
- package/lib/components/RollingNumber/get-digit-parts.d.ts +12 -0
- package/lib/components/RollingNumber/get-render-slots.d.ts +35 -0
- package/lib/components/RollingNumber/index.d.ts +9 -0
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/TagsInput/TagsInput.d.ts +2 -0
- package/lib/components/Tree/Tree.d.ts +10 -0
- package/lib/components/Tree/TreeNode.d.ts +4 -1
- package/lib/components/Tree/index.d.ts +1 -0
- package/lib/components/Tree/use-tree-node-drag-drop.d.ts +19 -7
- package/lib/components/TreeSelect/TreeSelect.d.ts +124 -0
- package/lib/components/TreeSelect/TreeSelectOption.d.ts +36 -0
- package/lib/components/TreeSelect/flatten-tree-select-data.d.ts +12 -0
- package/lib/components/TreeSelect/get-checked-values-by-strategy.d.ts +4 -0
- package/lib/components/TreeSelect/index.d.ts +13 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/core/MantineProvider/use-props/use-props.d.ts +1 -1
- package/lib/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.d.ts +2 -2
- package/package.json +2 -2
- package/styles/Pill.css +35 -0
- package/styles/Pill.layer.css +35 -0
- package/styles/Radio.css +3 -2
- package/styles/Radio.layer.css +3 -2
- package/styles/RollingNumber.css +60 -0
- package/styles/RollingNumber.layer.css +61 -0
- package/styles/TreeSelect.css +113 -0
- package/styles/TreeSelect.layer.css +114 -0
- package/styles.css +213 -2
- package/styles.layer.css +213 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region packages/@mantine/core/src/components/Highlight/highlighter/highlighter.ts
|
|
3
3
|
function escapeRegex(value) {
|
|
4
|
-
return value.replace(/[
|
|
4
|
+
return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
5
5
|
}
|
|
6
6
|
function highlighter(value, _highlight, options = {}) {
|
|
7
7
|
if (_highlight == null) return [{
|
|
@@ -14,8 +14,8 @@ function highlighter(value, _highlight, options = {}) {
|
|
|
14
14
|
highlighted: false
|
|
15
15
|
}];
|
|
16
16
|
const matcher = typeof highlight === "string" ? highlight.trim() : highlight.filter((part) => part.trim().length !== 0).map((part) => part.trim()).sort((a, b) => b.length - a.length).join("|");
|
|
17
|
-
const pattern = options.wholeWord ?
|
|
18
|
-
const re = new RegExp(pattern, "gi");
|
|
17
|
+
const pattern = options.wholeWord ? `(?<![\\p{L}\\p{N}_])(${matcher})(?![\\p{L}\\p{N}_])` : `(${matcher})`;
|
|
18
|
+
const re = new RegExp(pattern, options.wholeWord ? "giu" : "gi");
|
|
19
19
|
return value.split(re).map((part, index) => ({
|
|
20
20
|
chunk: part,
|
|
21
21
|
highlighted: index % 2 === 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlighter.mjs","names":[],"sources":["../../../../src/components/Highlight/highlighter/highlighter.ts"],"sourcesContent":["function escapeRegex(value: string) {\n return value.replace(/[
|
|
1
|
+
{"version":3,"file":"highlighter.mjs","names":[],"sources":["../../../../src/components/Highlight/highlighter/highlighter.ts"],"sourcesContent":["function escapeRegex(value: string) {\n return value.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n}\n\nexport interface HighlightChunk {\n chunk: string;\n highlighted: boolean;\n color?: string;\n}\n\nexport interface HighlighterOptions {\n wholeWord?: boolean;\n}\n\nexport function highlighter(\n value: string,\n _highlight: string | string[],\n options: HighlighterOptions = {}\n): HighlightChunk[] {\n if (_highlight == null) {\n return [{ chunk: value, highlighted: false }];\n }\n\n const highlight = Array.isArray(_highlight)\n ? _highlight.map(escapeRegex)\n : escapeRegex(_highlight);\n\n const shouldHighlight = Array.isArray(highlight)\n ? highlight.filter((part) => part.trim().length > 0).length > 0\n : highlight.trim() !== '';\n\n if (!shouldHighlight) {\n return [{ chunk: value, highlighted: false }];\n }\n\n const matcher =\n typeof highlight === 'string'\n ? highlight.trim()\n : highlight\n .filter((part) => part.trim().length !== 0)\n .map((part) => part.trim())\n .sort((a, b) => b.length - a.length)\n .join('|');\n\n const pattern = options.wholeWord\n ? `(?<![\\\\p{L}\\\\p{N}_])(${matcher})(?![\\\\p{L}\\\\p{N}_])`\n : `(${matcher})`;\n const re = new RegExp(pattern, options.wholeWord ? 'giu' : 'gi');\n const chunks = value\n .split(re)\n .map((part, index) => ({ chunk: part, highlighted: index % 2 === 1 }))\n .filter(({ chunk }) => chunk);\n\n return chunks;\n}\n"],"mappings":";;AAAA,SAAS,YAAY,OAAe;AAClC,QAAO,MAAM,QAAQ,uBAAuB,OAAO;;AAarD,SAAgB,YACd,OACA,YACA,UAA8B,EAAE,EACd;AAClB,KAAI,cAAc,KAChB,QAAO,CAAC;EAAE,OAAO;EAAO,aAAa;EAAO,CAAC;CAG/C,MAAM,YAAY,MAAM,QAAQ,WAAW,GACvC,WAAW,IAAI,YAAY,GAC3B,YAAY,WAAW;AAM3B,KAAI,EAJoB,MAAM,QAAQ,UAAU,GAC5C,UAAU,QAAQ,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC,SAAS,IAC5D,UAAU,MAAM,KAAK,IAGvB,QAAO,CAAC;EAAE,OAAO;EAAO,aAAa;EAAO,CAAC;CAG/C,MAAM,UACJ,OAAO,cAAc,WACjB,UAAU,MAAM,GAChB,UACG,QAAQ,SAAS,KAAK,MAAM,CAAC,WAAW,EAAE,CAC1C,KAAK,SAAS,KAAK,MAAM,CAAC,CAC1B,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO,CACnC,KAAK,IAAI;CAElB,MAAM,UAAU,QAAQ,YACpB,wBAAwB,QAAQ,wBAChC,IAAI,QAAQ;CAChB,MAAM,KAAK,IAAI,OAAO,SAAS,QAAQ,YAAY,QAAQ,KAAK;AAMhE,QALe,MACZ,MAAM,GAAG,CACT,KAAK,MAAM,WAAW;EAAE,OAAO;EAAM,aAAa,QAAQ,MAAM;EAAG,EAAE,CACrE,QAAQ,EAAE,YAAY,MAAM"}
|
|
@@ -3,7 +3,11 @@ import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs";
|
|
|
3
3
|
import { extractStyleProps } from "../../core/Box/style-props/extract-style-props/extract-style-props.mjs";
|
|
4
4
|
//#region packages/@mantine/core/src/components/Input/use-input-props.ts
|
|
5
5
|
function useInputProps(component, defaultProps, _props) {
|
|
6
|
-
const props = useProps(
|
|
6
|
+
const props = useProps([
|
|
7
|
+
"Input",
|
|
8
|
+
"InputWrapper",
|
|
9
|
+
component
|
|
10
|
+
], defaultProps, _props);
|
|
7
11
|
const { label, description, error, required, classNames, styles, className, unstyled, __staticSelector, __stylesApiProps, errorProps, labelProps, descriptionProps, wrapperProps: _wrapperProps, id, size, style, inputContainer, inputWrapperOrder, withAsterisk, variant, vars, mod, attributes, ...others } = props;
|
|
8
12
|
const { styleProps, rest } = extractStyleProps(others);
|
|
9
13
|
const wrapperProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-input-props.mjs","names":[],"sources":["../../../src/components/Input/use-input-props.ts"],"sourcesContent":["import { BoxProps, extractStyleProps, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps } from './Input';\n\ninterface BaseProps\n extends __BaseInputProps, BoxProps, StylesApiProps<{ props: any; stylesNames: string }> {\n __staticSelector?: string;\n __stylesApiProps?: Record<string, any>;\n id?: string;\n}\n\nexport function useInputProps<T extends BaseProps, U extends Partial<T> | null>(\n component: string,\n defaultProps: U,\n _props: T\n) {\n const props = useProps<T, U>(component, defaultProps, _props);\n const {\n label,\n description,\n error,\n required,\n classNames,\n styles,\n className,\n unstyled,\n __staticSelector,\n __stylesApiProps,\n errorProps,\n labelProps,\n descriptionProps,\n wrapperProps: _wrapperProps,\n id,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n vars,\n mod,\n attributes,\n ...others\n } = props;\n\n const { styleProps, rest } = extractStyleProps(others);\n\n const wrapperProps = {\n label,\n description,\n error,\n required,\n classNames,\n className,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n errorProps,\n labelProps,\n descriptionProps,\n unstyled,\n styles,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n id,\n mod,\n attributes,\n ..._wrapperProps,\n };\n\n return {\n ...rest,\n classNames,\n styles,\n unstyled,\n wrapperProps: { ...wrapperProps, ...styleProps } as typeof wrapperProps & BoxProps,\n inputProps: {\n required,\n classNames,\n styles,\n unstyled,\n size,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n error,\n variant,\n id,\n attributes,\n },\n };\n}\n"],"mappings":";;;;AAUA,SAAgB,cACd,WACA,cACA,QACA;CACA,MAAM,QAAQ,SAAe,
|
|
1
|
+
{"version":3,"file":"use-input-props.mjs","names":[],"sources":["../../../src/components/Input/use-input-props.ts"],"sourcesContent":["import { BoxProps, extractStyleProps, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps } from './Input';\n\ninterface BaseProps\n extends __BaseInputProps, BoxProps, StylesApiProps<{ props: any; stylesNames: string }> {\n __staticSelector?: string;\n __stylesApiProps?: Record<string, any>;\n id?: string;\n}\n\nexport function useInputProps<T extends BaseProps, U extends Partial<T> | null>(\n component: string,\n defaultProps: U,\n _props: T\n) {\n const props = useProps<T, U>(['Input', 'InputWrapper', component], defaultProps, _props);\n const {\n label,\n description,\n error,\n required,\n classNames,\n styles,\n className,\n unstyled,\n __staticSelector,\n __stylesApiProps,\n errorProps,\n labelProps,\n descriptionProps,\n wrapperProps: _wrapperProps,\n id,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n vars,\n mod,\n attributes,\n ...others\n } = props;\n\n const { styleProps, rest } = extractStyleProps(others);\n\n const wrapperProps = {\n label,\n description,\n error,\n required,\n classNames,\n className,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n errorProps,\n labelProps,\n descriptionProps,\n unstyled,\n styles,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n id,\n mod,\n attributes,\n ..._wrapperProps,\n };\n\n return {\n ...rest,\n classNames,\n styles,\n unstyled,\n wrapperProps: { ...wrapperProps, ...styleProps } as typeof wrapperProps & BoxProps,\n inputProps: {\n required,\n classNames,\n styles,\n unstyled,\n size,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n error,\n variant,\n id,\n attributes,\n },\n };\n}\n"],"mappings":";;;;AAUA,SAAgB,cACd,WACA,cACA,QACA;CACA,MAAM,QAAQ,SAAe;EAAC;EAAS;EAAgB;EAAU,EAAE,cAAc,OAAO;CACxF,MAAM,EACJ,OACA,aACA,OACA,UACA,YACA,QACA,WACA,UACA,kBACA,kBACA,YACA,YACA,kBACA,cAAc,eACd,IACA,MACA,OACA,gBACA,mBACA,cACA,SACA,MACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,EAAE,YAAY,SAAS,kBAAkB,OAAO;CAEtD,MAAM,eAAe;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAkB,oBAAoB;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;EACJ;AAED,QAAO;EACL,GAAG;EACH;EACA;EACA;EACA,cAAc;GAAE,GAAG;GAAc,GAAG;GAAY;EAChD,YAAY;GACV;GACA;GACA;GACA;GACA;GACA;GACA,kBAAkB,oBAAoB;GACtC;GACA;GACA;GACA;GACD;EACF"}
|
|
@@ -11,11 +11,14 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
const defaultProps = {
|
|
12
12
|
serialize: JSON.stringify,
|
|
13
13
|
deserialize: JSON.parse,
|
|
14
|
-
size: "sm",
|
|
15
14
|
indentSpaces: 2
|
|
16
15
|
};
|
|
17
16
|
const JsonInput = factory((props) => {
|
|
18
|
-
const { value, defaultValue, onChange, formatOnBlur, validationError, serialize, deserialize, onFocus, onBlur, readOnly, error, indentSpaces, ...others } = useProps(
|
|
17
|
+
const { value, defaultValue, onChange, formatOnBlur, validationError, serialize, deserialize, onFocus, onBlur, readOnly, error, indentSpaces, ...others } = useProps([
|
|
18
|
+
"Input",
|
|
19
|
+
"InputWrapper",
|
|
20
|
+
"JsonInput"
|
|
21
|
+
], defaultProps, props);
|
|
19
22
|
const [_value, setValue] = useUncontrolled({
|
|
20
23
|
value,
|
|
21
24
|
defaultValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonInput.mjs","names":[],"sources":["../../../src/components/JsonInput/JsonInput.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useUncontrolled } from '@mantine/hooks';\nimport { factory, Factory, useProps } from '../../core';\nimport { __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Textarea, TextareaProps } from '../Textarea';\nimport { validateJson } from './validate-json/validate-json';\n\nexport interface JsonInputProps extends Omit<TextareaProps, 'onChange'> {\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Determines whether the value should be formatted on blur @default false */\n formatOnBlur?: boolean;\n\n /** Error message shown when the input value is invalid JSON (checked on blur). If not provided, a generic error state is shown. Takes precedence over the `error` prop when validation fails. */\n validationError?: React.ReactNode;\n\n /** Function to serialize value into a string for formatting. Called with (value, null, 2) where 2 is the indentation level. @default JSON.stringify */\n serialize?: typeof JSON.stringify;\n\n /** Function to deserialize string value for formatting and validation. Must throw an error if the string is invalid JSON. @default JSON.parse */\n deserialize?: typeof JSON.parse;\n\n /** Number of spaces to use as white space for formatting. Passed as the third argument to `serialize` function. @default 2 */\n indentSpaces?: number;\n}\n\nexport type JsonInputFactory = Factory<{\n props: JsonInputProps;\n ref: HTMLTextAreaElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {\n serialize: JSON.stringify,\n deserialize: JSON.parse,\n
|
|
1
|
+
{"version":3,"file":"JsonInput.mjs","names":[],"sources":["../../../src/components/JsonInput/JsonInput.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useUncontrolled } from '@mantine/hooks';\nimport { factory, Factory, useProps } from '../../core';\nimport { __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Textarea, TextareaProps } from '../Textarea';\nimport { validateJson } from './validate-json/validate-json';\n\nexport interface JsonInputProps extends Omit<TextareaProps, 'onChange'> {\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Determines whether the value should be formatted on blur @default false */\n formatOnBlur?: boolean;\n\n /** Error message shown when the input value is invalid JSON (checked on blur). If not provided, a generic error state is shown. Takes precedence over the `error` prop when validation fails. */\n validationError?: React.ReactNode;\n\n /** Function to serialize value into a string for formatting. Called with (value, null, 2) where 2 is the indentation level. @default JSON.stringify */\n serialize?: typeof JSON.stringify;\n\n /** Function to deserialize string value for formatting and validation. Must throw an error if the string is invalid JSON. @default JSON.parse */\n deserialize?: typeof JSON.parse;\n\n /** Number of spaces to use as white space for formatting. Passed as the third argument to `serialize` function. @default 2 */\n indentSpaces?: number;\n}\n\nexport type JsonInputFactory = Factory<{\n props: JsonInputProps;\n ref: HTMLTextAreaElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {\n serialize: JSON.stringify,\n deserialize: JSON.parse,\n indentSpaces: 2,\n} satisfies Partial<JsonInputProps>;\n\nexport const JsonInput = factory<JsonInputFactory>((props) => {\n const {\n value,\n defaultValue,\n onChange,\n formatOnBlur,\n validationError,\n serialize,\n deserialize,\n onFocus,\n onBlur,\n readOnly,\n error,\n indentSpaces,\n ...others\n } = useProps(['Input', 'InputWrapper', 'JsonInput'], defaultProps, props);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\n\n const [valid, setValid] = useState(validateJson(_value, deserialize));\n\n const handleFocus = (event: React.FocusEvent<HTMLTextAreaElement>) => {\n onFocus?.(event);\n setValid(true);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLTextAreaElement>) => {\n onBlur?.(event);\n const isValid = validateJson(event.currentTarget.value, deserialize);\n formatOnBlur &&\n !readOnly &&\n isValid &&\n event.currentTarget.value.trim() !== '' &&\n setValue(serialize(deserialize(event.currentTarget.value), null, indentSpaces));\n setValid(isValid);\n };\n\n return (\n <Textarea\n value={_value}\n onChange={(event) => setValue(event.currentTarget.value)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n readOnly={readOnly}\n {...others}\n autoComplete=\"off\"\n __staticSelector=\"JsonInput\"\n error={valid ? error : validationError || true}\n data-monospace\n />\n );\n});\n\nJsonInput.classes = InputBase.classes;\nJsonInput.displayName = '@mantine/core/JsonInput';\n\nexport namespace JsonInput {\n export type Props = JsonInputProps;\n export type Factory = JsonInputFactory;\n}\n"],"mappings":";;;;;;;;;;AAwCA,MAAM,eAAe;CACnB,WAAW,KAAK;CAChB,aAAa,KAAK;CAClB,cAAc;CACf;AAED,MAAa,YAAY,SAA2B,UAAU;CAC5D,MAAM,EACJ,OACA,cACA,UACA,cACA,iBACA,WACA,aACA,SACA,QACA,UACA,OACA,cACA,GAAG,WACD,SAAS;EAAC;EAAS;EAAgB;EAAY,EAAE,cAAc,MAAM;CAEzE,MAAM,CAAC,QAAQ,YAAY,gBAAgB;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,CAAC,OAAO,YAAY,SAAS,aAAa,QAAQ,YAAY,CAAC;CAErE,MAAM,eAAe,UAAiD;AACpE,YAAU,MAAM;AAChB,WAAS,KAAK;;CAGhB,MAAM,cAAc,UAAiD;AACnE,WAAS,MAAM;EACf,MAAM,UAAU,aAAa,MAAM,cAAc,OAAO,YAAY;AACpE,kBACE,CAAC,YACD,WACA,MAAM,cAAc,MAAM,MAAM,KAAK,MACrC,SAAS,UAAU,YAAY,MAAM,cAAc,MAAM,EAAE,MAAM,aAAa,CAAC;AACjF,WAAS,QAAQ;;AAGnB,QACE,oBAAC,UAAD;EACE,OAAO;EACP,WAAW,UAAU,SAAS,MAAM,cAAc,MAAM;EACxD,SAAS;EACT,QAAQ;EACE;EACV,GAAI;EACJ,cAAa;EACb,kBAAiB;EACjB,OAAO,QAAQ,QAAQ,mBAAmB;EAC1C,kBAAA;EACA,CAAA;EAEJ;AAEF,UAAU,UAAU,UAAU;AAC9B,UAAU,cAAc"}
|
|
@@ -7,7 +7,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
//#region packages/@mantine/core/src/components/MaskInput/MaskInput.tsx
|
|
8
8
|
const defaultProps = {};
|
|
9
9
|
const MaskInput = factory((props) => {
|
|
10
|
-
const { maskRef, elementProps } = useMaskInputProps(useProps(
|
|
10
|
+
const { maskRef, elementProps } = useMaskInputProps(useProps([
|
|
11
|
+
"Input",
|
|
12
|
+
"InputWrapper",
|
|
13
|
+
"MaskInput"
|
|
14
|
+
], defaultProps, props));
|
|
11
15
|
return /* @__PURE__ */ jsx(InputBase, {
|
|
12
16
|
component: "input",
|
|
13
17
|
ref: maskRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaskInput.mjs","names":[],"sources":["../../../src/components/MaskInput/MaskInput.tsx"],"sourcesContent":["import { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { useMaskInputProps } from './use-mask-input-props';\n\nexport interface MaskInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<MaskInputFactory>,\n ElementProps<'input', 'size'> {\n /** Mask pattern string or array of string literals and RegExp objects */\n mask: string | Array<string | RegExp>;\n\n /** Override or extend the default token map */\n tokens?: Record<string, RegExp>;\n\n /** Called before masking on each keystroke, can return overrides for mask options */\n modify?: (\n value: string\n ) => Partial<Pick<MaskInputProps, 'mask' | 'tokens' | 'slotChar' | 'separate'>> | undefined;\n\n /** When true, raw and display values are decoupled */\n separate?: boolean;\n\n /** Character displayed in unfilled slots, `\"_\"` by default */\n slotChar?: string | null;\n\n /** Show mask pattern even when field is empty and unfocused */\n alwaysShowMask?: boolean;\n\n /** Show mask placeholder on focus, `true` by default */\n showMaskOnFocus?: boolean;\n\n /** Transform each character before validation and insertion */\n transform?: (char: string) => string;\n\n /** Clear value on blur when mask is incomplete, `false` by default */\n autoClear?: boolean;\n\n /** Called on every change with raw and masked values */\n onChangeRaw?: (rawValue: string, maskedValue: string) => void;\n\n /** Called when all required mask slots are filled */\n onComplete?: (maskedValue: string, rawValue: string) => void;\n\n /** Escape hatch for advanced cursor/value manipulation */\n beforeMaskedStateChange?: (states: {\n previousState: { value: string; selection: { start: number; end: number } | null };\n currentState: { value: string; selection: { start: number; end: number } | null };\n nextState: { value: string; selection: { start: number; end: number } | null };\n }) => { value: string; selection: { start: number; end: number } | null };\n}\n\nexport type MaskInputFactory = Factory<{\n props: MaskInputProps;\n variant: InputVariant;\n ref: HTMLInputElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {} satisfies Partial<MaskInputProps>;\n\nexport const MaskInput = factory<MaskInputFactory>((props) => {\n const _props = useProps('MaskInput', defaultProps, props);\n const { maskRef, elementProps } = useMaskInputProps(_props);\n\n return (\n <InputBase\n component=\"input\"\n ref={maskRef}\n {...(elementProps as any)}\n __staticSelector=\"MaskInput\"\n />\n );\n});\n\nMaskInput.classes = InputBase.classes;\nMaskInput.displayName = '@mantine/core/MaskInput';\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"MaskInput.mjs","names":[],"sources":["../../../src/components/MaskInput/MaskInput.tsx"],"sourcesContent":["import { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { useMaskInputProps } from './use-mask-input-props';\n\nexport interface MaskInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<MaskInputFactory>,\n ElementProps<'input', 'size'> {\n /** Mask pattern string or array of string literals and RegExp objects */\n mask: string | Array<string | RegExp>;\n\n /** Override or extend the default token map */\n tokens?: Record<string, RegExp>;\n\n /** Called before masking on each keystroke, can return overrides for mask options */\n modify?: (\n value: string\n ) => Partial<Pick<MaskInputProps, 'mask' | 'tokens' | 'slotChar' | 'separate'>> | undefined;\n\n /** When true, raw and display values are decoupled */\n separate?: boolean;\n\n /** Character displayed in unfilled slots, `\"_\"` by default */\n slotChar?: string | null;\n\n /** Show mask pattern even when field is empty and unfocused */\n alwaysShowMask?: boolean;\n\n /** Show mask placeholder on focus, `true` by default */\n showMaskOnFocus?: boolean;\n\n /** Transform each character before validation and insertion */\n transform?: (char: string) => string;\n\n /** Clear value on blur when mask is incomplete, `false` by default */\n autoClear?: boolean;\n\n /** Called on every change with raw and masked values */\n onChangeRaw?: (rawValue: string, maskedValue: string) => void;\n\n /** Called when all required mask slots are filled */\n onComplete?: (maskedValue: string, rawValue: string) => void;\n\n /** Escape hatch for advanced cursor/value manipulation */\n beforeMaskedStateChange?: (states: {\n previousState: { value: string; selection: { start: number; end: number } | null };\n currentState: { value: string; selection: { start: number; end: number } | null };\n nextState: { value: string; selection: { start: number; end: number } | null };\n }) => { value: string; selection: { start: number; end: number } | null };\n\n /** Assigns a function that clears the input value to the given ref */\n resetRef?: React.RefObject<(() => void) | null>;\n}\n\nexport type MaskInputFactory = Factory<{\n props: MaskInputProps;\n variant: InputVariant;\n ref: HTMLInputElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {} satisfies Partial<MaskInputProps>;\n\nexport const MaskInput = factory<MaskInputFactory>((props) => {\n const _props = useProps(['Input', 'InputWrapper', 'MaskInput'], defaultProps, props);\n const { maskRef, elementProps } = useMaskInputProps(_props);\n\n return (\n <InputBase\n component=\"input\"\n ref={maskRef}\n {...(elementProps as any)}\n __staticSelector=\"MaskInput\"\n />\n );\n});\n\nMaskInput.classes = InputBase.classes;\nMaskInput.displayName = '@mantine/core/MaskInput';\n"],"mappings":";;;;;;;AAgEA,MAAM,eAAe,EAAE;AAEvB,MAAa,YAAY,SAA2B,UAAU;CAE5D,MAAM,EAAE,SAAS,iBAAiB,kBADnB,SAAS;EAAC;EAAS;EAAgB;EAAY,EAAE,cAAc,MAAM,CACzB;AAE3D,QACE,oBAAC,WAAD;EACE,WAAU;EACV,KAAK;EACL,GAAK;EACL,kBAAiB;EACjB,CAAA;EAEJ;AAEF,UAAU,UAAU,UAAU;AAC9B,UAAU,cAAc"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMask, useMergedRef } from "@mantine/hooks";
|
|
2
|
+
import { assignRef, useMask, useMergedRef } from "@mantine/hooks";
|
|
3
3
|
//#region packages/@mantine/core/src/components/MaskInput/use-mask-input-props.ts
|
|
4
4
|
function useMaskInputProps(props) {
|
|
5
|
-
const { mask, tokens, modify, separate, slotChar, alwaysShowMask, showMaskOnFocus, transform, autoClear, onChangeRaw, onComplete, beforeMaskedStateChange, ref, ...elementProps } = props;
|
|
6
|
-
const { ref: maskCallbackRef } = useMask({
|
|
5
|
+
const { mask, tokens, modify, separate, slotChar, alwaysShowMask, showMaskOnFocus, transform, autoClear, onChangeRaw, onComplete, beforeMaskedStateChange, resetRef, ref, ...elementProps } = props;
|
|
6
|
+
const { ref: maskCallbackRef, reset } = useMask({
|
|
7
7
|
mask,
|
|
8
8
|
tokens,
|
|
9
9
|
modify,
|
|
@@ -17,6 +17,7 @@ function useMaskInputProps(props) {
|
|
|
17
17
|
onComplete,
|
|
18
18
|
beforeMaskedStateChange
|
|
19
19
|
});
|
|
20
|
+
assignRef(resetRef, reset);
|
|
20
21
|
return {
|
|
21
22
|
maskRef: useMergedRef(ref, maskCallbackRef),
|
|
22
23
|
elementProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mask-input-props.mjs","names":[],"sources":["../../../src/components/MaskInput/use-mask-input-props.ts"],"sourcesContent":["import { useMask, useMergedRef } from '@mantine/hooks';\nimport type { MaskInputProps } from './MaskInput';\n\nexport function useMaskInputProps(props: MaskInputProps & { ref?: React.Ref<HTMLInputElement> }) {\n const {\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n ref,\n ...elementProps\n } = props;\n\n const { ref: maskCallbackRef } = useMask({\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n });\n\n const maskRef = useMergedRef(ref, maskCallbackRef);\n\n return { maskRef, elementProps };\n}\n"],"mappings":";;;AAGA,SAAgB,kBAAkB,OAA+D;CAC/F,MAAM,EACJ,MACA,QACA,QACA,UACA,UACA,gBACA,iBACA,WACA,WACA,aACA,YACA,yBACA,KACA,GAAG,iBACD;CAEJ,MAAM,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"use-mask-input-props.mjs","names":[],"sources":["../../../src/components/MaskInput/use-mask-input-props.ts"],"sourcesContent":["import { assignRef, useMask, useMergedRef } from '@mantine/hooks';\nimport type { MaskInputProps } from './MaskInput';\n\nexport function useMaskInputProps(props: MaskInputProps & { ref?: React.Ref<HTMLInputElement> }) {\n const {\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n resetRef,\n ref,\n ...elementProps\n } = props;\n\n const { ref: maskCallbackRef, reset } = useMask({\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n });\n\n assignRef(resetRef, reset);\n\n const maskRef = useMergedRef(ref, maskCallbackRef);\n\n return { maskRef, elementProps };\n}\n"],"mappings":";;;AAGA,SAAgB,kBAAkB,OAA+D;CAC/F,MAAM,EACJ,MACA,QACA,QACA,UACA,UACA,gBACA,iBACA,WACA,WACA,aACA,YACA,yBACA,UACA,KACA,GAAG,iBACD;CAEJ,MAAM,EAAE,KAAK,iBAAiB,UAAU,QAAQ;EAC9C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,WAAU,UAAU,MAAM;AAI1B,QAAO;EAAE,SAFO,aAAa,KAAK,gBAAgB;EAEhC;EAAc"}
|
|
@@ -10,6 +10,7 @@ import { getOptionsLockup } from "../Combobox/get-options-lockup/get-options-loc
|
|
|
10
10
|
import { useCombobox } from "../Combobox/use-combobox/use-combobox.mjs";
|
|
11
11
|
import { Combobox } from "../Combobox/Combobox.mjs";
|
|
12
12
|
import { OptionsDropdown } from "../Combobox/OptionsDropdown/OptionsDropdown.mjs";
|
|
13
|
+
import { usePillsReorder } from "../Combobox/use-pills-reorder/use-pills-reorder.mjs";
|
|
13
14
|
import { Pill } from "../Pill/Pill.mjs";
|
|
14
15
|
import { PillsInput } from "../PillsInput/PillsInput.mjs";
|
|
15
16
|
import { filterPickedValues } from "./filter-picked-values.mjs";
|
|
@@ -34,8 +35,12 @@ const defaultProps = {
|
|
|
34
35
|
size: "sm"
|
|
35
36
|
};
|
|
36
37
|
const MultiSelect = genericFactory((_props) => {
|
|
37
|
-
const props = useProps(
|
|
38
|
-
|
|
38
|
+
const props = useProps([
|
|
39
|
+
"Input",
|
|
40
|
+
"InputWrapper",
|
|
41
|
+
"MultiSelect"
|
|
42
|
+
], defaultProps, _props);
|
|
43
|
+
const { classNames, className, style, styles, unstyled, vars, size, value, defaultValue, onChange, onKeyDown, variant, data, dropdownOpened, defaultDropdownOpened, onDropdownOpen, onDropdownClose, selectFirstOptionOnChange, selectFirstOptionOnDropdownOpen, onOptionSubmit, comboboxProps, filter, limit, withScrollArea, maxDropdownHeight, searchValue, defaultSearchValue, onSearchChange, readOnly, disabled, onFocus, onBlur, radius, rightSection, rightSectionWidth, rightSectionPointerEvents, rightSectionProps, leftSection, leftSectionWidth, leftSectionPointerEvents, leftSectionProps, inputContainer, inputWrapperOrder, withAsterisk, labelProps, descriptionProps, errorProps, wrapperProps, description, label, error, maxValues, searchable, nothingFoundMessage, withCheckIcon, withAlignedLabels, checkIconPosition, hidePickedOptions, withErrorStyles, name, form, id, clearable, clearSectionMode, clearButtonProps, hiddenInputProps, placeholder, hiddenInputValuesDivider, required, mod, renderOption, renderPill, onRemove, onClear, onMaxValues, scrollAreaProps, chevronColor, attributes, clearSearchOnChange, openOnFocus, loading, loadingPosition, withPillsReorder, ...others } = props;
|
|
39
44
|
const _id = useId$1(id);
|
|
40
45
|
const parsedData = getParsedComboboxData(data);
|
|
41
46
|
const optionsLockup = getOptionsLockup(parsedData);
|
|
@@ -59,6 +64,11 @@ const MultiSelect = genericFactory((_props) => {
|
|
|
59
64
|
finalValue: [],
|
|
60
65
|
onChange
|
|
61
66
|
});
|
|
67
|
+
const { getPillProps, getListProps, handleInputKeyDown } = usePillsReorder({
|
|
68
|
+
value: _value,
|
|
69
|
+
onChange: setValue,
|
|
70
|
+
enabled: withPillsReorder && !disabled && !readOnly
|
|
71
|
+
});
|
|
62
72
|
const [_searchValue, setSearchValue] = useUncontrolled({
|
|
63
73
|
value: searchValue,
|
|
64
74
|
defaultValue: defaultSearchValue,
|
|
@@ -85,6 +95,7 @@ const MultiSelect = genericFactory((_props) => {
|
|
|
85
95
|
});
|
|
86
96
|
const handleInputKeydown = (event) => {
|
|
87
97
|
onKeyDown?.(event);
|
|
98
|
+
if (event.defaultPrevented) return;
|
|
88
99
|
if (event.key === " " && !searchable) {
|
|
89
100
|
event.preventDefault();
|
|
90
101
|
combobox.toggleDropdown();
|
|
@@ -93,9 +104,11 @@ const MultiSelect = genericFactory((_props) => {
|
|
|
93
104
|
onRemove?.(_value[_value.length - 1]);
|
|
94
105
|
setValue(_value.slice(0, _value.length - 1));
|
|
95
106
|
}
|
|
107
|
+
handleInputKeyDown(event);
|
|
96
108
|
};
|
|
97
109
|
const values = _value.map((item, index) => {
|
|
98
110
|
const optionData = optionsLockup[`${item}`] || retainedSelectedOptions.current[`${item}`];
|
|
111
|
+
const reorderProps = getPillProps(index);
|
|
99
112
|
if (renderPill) return /* @__PURE__ */ jsx(Fragment, { children: renderPill({
|
|
100
113
|
option: optionData,
|
|
101
114
|
value: item,
|
|
@@ -103,7 +116,8 @@ const MultiSelect = genericFactory((_props) => {
|
|
|
103
116
|
setValue(_value.filter((i) => item !== i));
|
|
104
117
|
onRemove?.(item);
|
|
105
118
|
},
|
|
106
|
-
disabled
|
|
119
|
+
disabled,
|
|
120
|
+
reorderProps
|
|
107
121
|
}) }, `${item}-${index}`);
|
|
108
122
|
return /* @__PURE__ */ jsx(Pill, {
|
|
109
123
|
withRemoveButton: !readOnly && !optionsLockup[`${item}`]?.disabled,
|
|
@@ -114,6 +128,7 @@ const MultiSelect = genericFactory((_props) => {
|
|
|
114
128
|
unstyled,
|
|
115
129
|
disabled,
|
|
116
130
|
...getStyles("pill"),
|
|
131
|
+
...reorderProps,
|
|
117
132
|
children: optionData?.label || item
|
|
118
133
|
}, `${item}-${index}`);
|
|
119
134
|
});
|
|
@@ -218,6 +233,7 @@ const MultiSelect = genericFactory((_props) => {
|
|
|
218
233
|
disabled,
|
|
219
234
|
unstyled,
|
|
220
235
|
...getStyles("pillsList", { style: pillsListStyle }),
|
|
236
|
+
...getListProps(),
|
|
221
237
|
children: [values, /* @__PURE__ */ jsx(Combobox.EventsTarget, {
|
|
222
238
|
autoComplete,
|
|
223
239
|
withExpandedAttribute: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.mjs","names":["useId"],"sources":["../../../src/components/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n genericFactory,\n MantineColor,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n Combobox,\n ComboboxItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n ComboboxRenderPillInput,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Pill } from '../Pill';\nimport { PillsInput } from '../PillsInput';\nimport { ScrollAreaProps } from '../ScrollArea';\nimport { filterPickedValues } from './filter-picked-values';\n\nconst clearSectionOffset: Record<string, number> = {\n xs: 41,\n sm: 50,\n md: 60,\n lg: 72,\n xl: 89,\n};\n\nexport type MultiSelectStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport interface MultiSelectProps<Value extends Primitive = string>\n extends\n BoxProps,\n __BaseInputProps,\n ComboboxLikeProps<Value>,\n StylesApiProps<MultiSelectFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Controlled component value */\n value?: Value[];\n\n /** Uncontrolled component default value */\n defaultValue?: Value[];\n\n /** Called when value changes */\n onChange?: (value: Value[]) => void;\n\n /** Called with `value` of the removed item */\n onRemove?: (value: Value) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Called when user attemps to select more values than allowed */\n onMaxValues?: () => void;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Maximum number of values, no limit if not set */\n maxValues?: number;\n\n /** Allows searching through options by user input @default false */\n searchable?: boolean;\n\n /** Message displayed when no options match the search query (when searchable is enabled) or when the data array is empty. If not set, the dropdown will be hidden instead. */\n nothingFoundMessage?: React.ReactNode;\n\n /** If set, the check icon is displayed near the selected option label @default true */\n withCheckIcon?: boolean;\n\n /** If set, unchecked labels are aligned with checked ones @default false */\n withAlignedLabels?: boolean;\n\n /** Position of the checkmark icon shown next to selected options in the dropdown @default 'left' */\n checkIconPosition?: 'left' | 'right';\n\n /** When enabled, selected options are hidden from the dropdown list @default false */\n hidePickedOptions?: boolean;\n\n /** When enabled, displays a clear button to remove all selected values (hidden when component is empty, disabled, or read-only) @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Divider used to separate values in the hidden input `value` attribute @default ',' */\n hiddenInputValuesDivider?: string;\n\n /** A function to render content of the option, replaces the default content of the option */\n renderOption?: (item: ComboboxLikeRenderOptionInput<ComboboxItem>) => React.ReactNode;\n\n /** A function to render content of the pill */\n renderPill?: (props: ComboboxRenderPillInput<Value>) => React.ReactNode;\n\n /** Props passed down to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls color of the default chevron */\n chevronColor?: MantineColor;\n\n /** Clear search value when item is selected @default true */\n clearSearchOnChange?: boolean;\n\n /** Controls whether dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n}\n\nexport type MultiSelectFactory = Factory<{\n props: MultiSelectProps;\n ref: HTMLInputElement;\n stylesNames: MultiSelectStylesNames;\n signature: <Value extends Primitive = string>(\n props: MultiSelectProps<Value>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n maxValues: Infinity,\n withCheckIcon: true,\n checkIconPosition: 'left',\n hiddenInputValuesDivider: ',',\n clearSearchOnChange: true,\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<MultiSelectProps>;\n\nexport const MultiSelect = genericFactory<MultiSelectFactory>((_props) => {\n const props = useProps('MultiSelect', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n value,\n defaultValue,\n onChange,\n onKeyDown,\n variant,\n data,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n readOnly,\n disabled,\n onFocus,\n onBlur,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n labelProps,\n descriptionProps,\n errorProps,\n wrapperProps,\n description,\n label,\n error,\n maxValues,\n searchable,\n nothingFoundMessage,\n withCheckIcon,\n withAlignedLabels,\n checkIconPosition,\n hidePickedOptions,\n withErrorStyles,\n name,\n form,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n placeholder,\n hiddenInputValuesDivider,\n required,\n mod,\n renderOption,\n renderPill,\n onRemove,\n onClear,\n onMaxValues,\n scrollAreaProps,\n chevronColor,\n attributes,\n clearSearchOnChange,\n openOnFocus,\n loading,\n loadingPosition,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n const retainedSelectedOptions = useRef<Record<string, ComboboxItem<Primitive>>>({});\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n if (selectFirstOptionOnDropdownOpen) {\n combobox.selectFirstOption();\n }\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: [],\n onChange,\n });\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: '',\n onChange: onSearchChange,\n });\n\n const handleSearchChange = (value: string) => {\n setSearchValue(value);\n combobox.resetSelectedOption();\n };\n\n const getStyles = useStyles<MultiSelectFactory>({\n name: 'MultiSelect',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<MultiSelectFactory>({\n props,\n styles,\n classNames,\n });\n\n const handleInputKeydown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.key === ' ' && !searchable) {\n event.preventDefault();\n combobox.toggleDropdown();\n }\n\n if (event.key === 'Backspace' && _searchValue.length === 0 && _value.length > 0) {\n onRemove?.(_value[_value.length - 1]);\n setValue(_value.slice(0, _value.length - 1));\n }\n };\n\n const values = _value.map((item, index) => {\n const optionData = optionsLockup[`${item}`] || retainedSelectedOptions.current[`${item}`];\n\n if (renderPill) {\n return (\n <Fragment key={`${item}-${index}`}>\n {renderPill({\n option: optionData,\n value: item,\n onRemove: () => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n },\n disabled,\n })}\n </Fragment>\n );\n }\n\n return (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly && !optionsLockup[`${item}`]?.disabled}\n onRemove={() => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n }}\n unstyled={unstyled}\n disabled={disabled}\n {...getStyles('pill')}\n >\n {optionData?.label || item}\n </Pill>\n );\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _searchValue]);\n\n useEffect(() => {\n _value.forEach((val) => {\n if (`${val}` in optionsLockup) {\n retainedSelectedOptions.current[`${val}`] = optionsLockup[`${val}`];\n }\n });\n }, [optionsLockup, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n setValue([]);\n handleSearchChange('');\n }}\n />\n );\n\n const filteredData = filterPickedValues({ data: parsedData, value: _value });\n const _clearable = clearable && _value.length > 0 && !disabled && !readOnly;\n const pillsListStyle = _clearable\n ? { paddingInlineEnd: clearSectionOffset[size] ?? clearSectionOffset.sm }\n : undefined;\n\n return (\n <>\n <Combobox\n store={combobox}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n readOnly={readOnly}\n __staticSelector=\"MultiSelect\"\n attributes={attributes}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val as any);\n if (clearSearchOnChange) {\n handleSearchChange('');\n }\n combobox.updateSelectedOptionIndex('selected');\n\n if (_value.includes(optionsLockup[`${val}`].value as any)) {\n setValue(_value.filter((v) => v !== optionsLockup[`${val}`].value));\n onRemove?.(optionsLockup[`${val}`].value as any);\n } else if (_value.length < maxValues) {\n setValue([..._value, optionsLockup[`${val}`].value] as any);\n } else {\n onMaxValues?.();\n }\n }}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"MultiSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n className={className}\n style={style}\n variant={variant}\n disabled={disabled}\n radius={radius}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n loading={loading}\n loadingPosition={loadingPosition}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n error={error}\n withErrorStyles={withErrorStyles}\n __stylesApiProps={{\n ...props,\n rightSectionPointerEvents: rightSectionPointerEvents || 'none',\n multiline: true,\n }}\n pointer={!searchable}\n onClick={() => (searchable ? combobox.openDropdown() : combobox.toggleDropdown())}\n data-expanded={combobox.dropdownOpened || undefined}\n id={_id}\n required={required}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group\n attributes={attributes}\n disabled={disabled}\n unstyled={unstyled}\n {...getStyles('pillsList', { style: pillsListStyle })}\n >\n {values}\n <Combobox.EventsTarget autoComplete={autoComplete} withExpandedAttribute>\n <PillsInput.Field\n {...rest}\n id={_id}\n placeholder={placeholder}\n type={!searchable && !placeholder ? 'hidden' : 'visible'}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onFocus={(event) => {\n onFocus?.(event);\n openOnFocus && searchable && combobox.openDropdown();\n }}\n onBlur={(event) => {\n onBlur?.(event);\n combobox.closeDropdown();\n handleSearchChange('');\n }}\n onKeyDown={handleInputKeydown}\n value={_searchValue}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n searchable && combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n disabled={disabled}\n readOnly={readOnly || !searchable}\n pointer={!searchable}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n\n <OptionsDropdown\n data={hidePickedOptions ? filteredData : parsedData}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_searchValue}\n limit={limit}\n hiddenWhenEmpty={!nothingFoundMessage}\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n filterOptions={searchable}\n value={_value}\n checkIconPosition={checkIconPosition}\n withCheckIcon={withCheckIcon}\n withAlignedLabels={withAlignedLabels}\n nothingFoundMessage={nothingFoundMessage}\n unstyled={unstyled}\n labelId={label ? `${_id}-label` : undefined}\n aria-label={label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n <Combobox.HiddenInput\n name={name}\n valuesDivider={hiddenInputValuesDivider}\n value={_value}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nMultiSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nMultiSelect.displayName = '@mantine/core/MultiSelect';\n\nexport namespace MultiSelect {\n export type Props<Value extends Primitive = string> = MultiSelectProps<Value>;\n export type StylesNames = MultiSelectStylesNames;\n export type Factory = MultiSelectFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,qBAA6C;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AA2GD,MAAM,eAAe;CACnB,WAAW;CACX,eAAe;CACf,mBAAmB;CACnB,0BAA0B;CAC1B,qBAAqB;CACrB,aAAa;CACb,MAAM;CACP;AAED,MAAa,cAAc,gBAAoC,WAAW;CACxE,MAAM,QAAQ,SAAS,eAAe,cAAc,OAAO;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,OACA,cACA,UACA,WACA,SACA,MACA,gBACA,uBACA,gBACA,iBACA,2BACA,iCACA,gBACA,eACA,QACA,OACA,gBACA,mBACA,aACA,oBACA,gBACA,UACA,UACA,SACA,QACA,QACA,cACA,mBACA,2BACA,mBACA,aACA,kBACA,0BACA,kBACA,gBACA,mBACA,cACA,YACA,kBACA,YACA,cACA,aACA,OACA,OACA,WACA,YACA,qBACA,eACA,mBACA,mBACA,mBACA,iBACA,MACA,MACA,IACA,WACA,kBACA,kBACA,kBACA,aACA,0BACA,UACA,KACA,cACA,YACA,UACA,SACA,aACA,iBACA,cACA,YACA,qBACA,aACA,SACA,iBACA,GAAG,WACD;CAEJ,MAAM,MAAMA,QAAM,GAAG;CACrB,MAAM,aAAa,sBAAsB,KAAK;CAC9C,MAAM,gBAAgB,iBAAiB,WAAW;CAClD,MAAM,0BAA0B,OAAgD,EAAE,CAAC;CAEnF,MAAM,WAAW,YAAY;EAC3B,QAAQ;EACR,eAAe;EACf,sBAAsB;AACpB,qBAAkB;AAClB,OAAI,gCACF,UAAS,mBAAmB;;EAGhC,uBAAuB;AACrB,sBAA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,eAAe;GACzC,QAAQ,YAAY;GACZ;GACR,QAAQ;GACD;GACP,iBAAiB,CAAC;GACF;GACG;GACnB,eAAe;GACf,OAAO;GACY;GACJ;GACI;GACE;GACX;GACV,SAAS,QAAQ,GAAG,IAAI,UAAU,KAAA;GAClC,cAAY,QAAQ,KAAA,IAAY,OAAO;GACzB;GACG;GACjB,CAAA,CACO;KACX,oBAAC,SAAS,aAAV;EACQ;EACN,eAAe;EACf,OAAO;EACD;EACI;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,YAAY,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AACnE,YAAY,cAAc"}
|
|
1
|
+
{"version":3,"file":"MultiSelect.mjs","names":["useId"],"sources":["../../../src/components/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n genericFactory,\n MantineColor,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n Combobox,\n ComboboxItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n ComboboxRenderPillInput,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n usePillsReorder,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Pill } from '../Pill';\nimport { PillsInput } from '../PillsInput';\nimport { ScrollAreaProps } from '../ScrollArea';\nimport { filterPickedValues } from './filter-picked-values';\n\nconst clearSectionOffset: Record<string, number> = {\n xs: 41,\n sm: 50,\n md: 60,\n lg: 72,\n xl: 89,\n};\n\nexport type MultiSelectStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport interface MultiSelectProps<Value extends Primitive = string>\n extends\n BoxProps,\n __BaseInputProps,\n ComboboxLikeProps<Value>,\n StylesApiProps<MultiSelectFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Controlled component value */\n value?: Value[];\n\n /** Uncontrolled component default value */\n defaultValue?: Value[];\n\n /** Called when value changes */\n onChange?: (value: Value[]) => void;\n\n /** Called with `value` of the removed item */\n onRemove?: (value: Value) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Called when user attemps to select more values than allowed */\n onMaxValues?: () => void;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Maximum number of values, no limit if not set */\n maxValues?: number;\n\n /** Allows searching through options by user input @default false */\n searchable?: boolean;\n\n /** Message displayed when no options match the search query (when searchable is enabled) or when the data array is empty. If not set, the dropdown will be hidden instead. */\n nothingFoundMessage?: React.ReactNode;\n\n /** If set, the check icon is displayed near the selected option label @default true */\n withCheckIcon?: boolean;\n\n /** If set, unchecked labels are aligned with checked ones @default false */\n withAlignedLabels?: boolean;\n\n /** Position of the checkmark icon shown next to selected options in the dropdown @default 'left' */\n checkIconPosition?: 'left' | 'right';\n\n /** When enabled, selected options are hidden from the dropdown list @default false */\n hidePickedOptions?: boolean;\n\n /** When enabled, displays a clear button to remove all selected values (hidden when component is empty, disabled, or read-only) @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Divider used to separate values in the hidden input `value` attribute @default ',' */\n hiddenInputValuesDivider?: string;\n\n /** A function to render content of the option, replaces the default content of the option */\n renderOption?: (item: ComboboxLikeRenderOptionInput<ComboboxItem<Value>>) => React.ReactNode;\n\n /** A function to render content of the pill */\n renderPill?: (props: ComboboxRenderPillInput<Value>) => React.ReactNode;\n\n /** Props passed down to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls color of the default chevron */\n chevronColor?: MantineColor;\n\n /** Clear search value when item is selected @default true */\n clearSearchOnChange?: boolean;\n\n /** Controls whether dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n\n /** If set, selected values can be reordered by dragging pills. Disabled when `disabled` or `readOnly` is set. @default false */\n withPillsReorder?: boolean;\n}\n\nexport type MultiSelectFactory = Factory<{\n props: MultiSelectProps;\n ref: HTMLInputElement;\n stylesNames: MultiSelectStylesNames;\n signature: <Value extends Primitive = string>(\n props: MultiSelectProps<Value>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n maxValues: Infinity,\n withCheckIcon: true,\n checkIconPosition: 'left',\n hiddenInputValuesDivider: ',',\n clearSearchOnChange: true,\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<MultiSelectProps>;\n\nexport const MultiSelect = genericFactory<MultiSelectFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'MultiSelect'], defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n value,\n defaultValue,\n onChange,\n onKeyDown,\n variant,\n data,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n readOnly,\n disabled,\n onFocus,\n onBlur,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n labelProps,\n descriptionProps,\n errorProps,\n wrapperProps,\n description,\n label,\n error,\n maxValues,\n searchable,\n nothingFoundMessage,\n withCheckIcon,\n withAlignedLabels,\n checkIconPosition,\n hidePickedOptions,\n withErrorStyles,\n name,\n form,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n placeholder,\n hiddenInputValuesDivider,\n required,\n mod,\n renderOption,\n renderPill,\n onRemove,\n onClear,\n onMaxValues,\n scrollAreaProps,\n chevronColor,\n attributes,\n clearSearchOnChange,\n openOnFocus,\n loading,\n loadingPosition,\n withPillsReorder,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n const retainedSelectedOptions = useRef<Record<string, ComboboxItem<Primitive>>>({});\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n if (selectFirstOptionOnDropdownOpen) {\n combobox.selectFirstOption();\n }\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: [],\n onChange,\n });\n\n const { getPillProps, getListProps, handleInputKeyDown } = usePillsReorder({\n value: _value,\n onChange: setValue,\n enabled: withPillsReorder && !disabled && !readOnly,\n });\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: '',\n onChange: onSearchChange,\n });\n\n const handleSearchChange = (value: string) => {\n setSearchValue(value);\n combobox.resetSelectedOption();\n };\n\n const getStyles = useStyles<MultiSelectFactory>({\n name: 'MultiSelect',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<MultiSelectFactory>({\n props,\n styles,\n classNames,\n });\n\n const handleInputKeydown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === ' ' && !searchable) {\n event.preventDefault();\n combobox.toggleDropdown();\n }\n\n if (event.key === 'Backspace' && _searchValue.length === 0 && _value.length > 0) {\n onRemove?.(_value[_value.length - 1]);\n setValue(_value.slice(0, _value.length - 1));\n }\n\n handleInputKeyDown(event);\n };\n\n const values = _value.map((item, index) => {\n const optionData = optionsLockup[`${item}`] || retainedSelectedOptions.current[`${item}`];\n const reorderProps = getPillProps(index);\n\n if (renderPill) {\n return (\n <Fragment key={`${item}-${index}`}>\n {renderPill({\n option: optionData,\n value: item,\n onRemove: () => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n },\n disabled,\n reorderProps,\n })}\n </Fragment>\n );\n }\n\n return (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly && !optionsLockup[`${item}`]?.disabled}\n onRemove={() => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n }}\n unstyled={unstyled}\n disabled={disabled}\n {...getStyles('pill')}\n {...reorderProps}\n >\n {optionData?.label || item}\n </Pill>\n );\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _searchValue]);\n\n useEffect(() => {\n _value.forEach((val) => {\n if (`${val}` in optionsLockup) {\n retainedSelectedOptions.current[`${val}`] = optionsLockup[`${val}`];\n }\n });\n }, [optionsLockup, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n setValue([]);\n handleSearchChange('');\n }}\n />\n );\n\n const filteredData = filterPickedValues({ data: parsedData, value: _value });\n const _clearable = clearable && _value.length > 0 && !disabled && !readOnly;\n const pillsListStyle = _clearable\n ? { paddingInlineEnd: clearSectionOffset[size] ?? clearSectionOffset.sm }\n : undefined;\n\n return (\n <>\n <Combobox\n store={combobox}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n readOnly={readOnly}\n __staticSelector=\"MultiSelect\"\n attributes={attributes}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val as any);\n if (clearSearchOnChange) {\n handleSearchChange('');\n }\n combobox.updateSelectedOptionIndex('selected');\n\n if (_value.includes(optionsLockup[`${val}`].value as any)) {\n setValue(_value.filter((v) => v !== optionsLockup[`${val}`].value));\n onRemove?.(optionsLockup[`${val}`].value as any);\n } else if (_value.length < maxValues) {\n setValue([..._value, optionsLockup[`${val}`].value] as any);\n } else {\n onMaxValues?.();\n }\n }}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"MultiSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n className={className}\n style={style}\n variant={variant}\n disabled={disabled}\n radius={radius}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n loading={loading}\n loadingPosition={loadingPosition}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n error={error}\n withErrorStyles={withErrorStyles}\n __stylesApiProps={{\n ...props,\n rightSectionPointerEvents: rightSectionPointerEvents || 'none',\n multiline: true,\n }}\n pointer={!searchable}\n onClick={() => (searchable ? combobox.openDropdown() : combobox.toggleDropdown())}\n data-expanded={combobox.dropdownOpened || undefined}\n id={_id}\n required={required}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group\n attributes={attributes}\n disabled={disabled}\n unstyled={unstyled}\n {...getStyles('pillsList', { style: pillsListStyle })}\n {...getListProps()}\n >\n {values}\n <Combobox.EventsTarget autoComplete={autoComplete} withExpandedAttribute>\n <PillsInput.Field\n {...rest}\n id={_id}\n placeholder={placeholder}\n type={!searchable && !placeholder ? 'hidden' : 'visible'}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onFocus={(event) => {\n onFocus?.(event);\n openOnFocus && searchable && combobox.openDropdown();\n }}\n onBlur={(event) => {\n onBlur?.(event);\n combobox.closeDropdown();\n handleSearchChange('');\n }}\n onKeyDown={handleInputKeydown}\n value={_searchValue}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n searchable && combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n disabled={disabled}\n readOnly={readOnly || !searchable}\n pointer={!searchable}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n\n <OptionsDropdown\n data={hidePickedOptions ? filteredData : parsedData}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_searchValue}\n limit={limit}\n hiddenWhenEmpty={!nothingFoundMessage}\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n filterOptions={searchable}\n value={_value}\n checkIconPosition={checkIconPosition}\n withCheckIcon={withCheckIcon}\n withAlignedLabels={withAlignedLabels}\n nothingFoundMessage={nothingFoundMessage}\n unstyled={unstyled}\n labelId={label ? `${_id}-label` : undefined}\n aria-label={label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n <Combobox.HiddenInput\n name={name}\n valuesDivider={hiddenInputValuesDivider}\n value={_value}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nMultiSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nMultiSelect.displayName = '@mantine/core/MultiSelect';\n\nexport namespace MultiSelect {\n export type Props<Value extends Primitive = string> = MultiSelectProps<Value>;\n export type StylesNames = MultiSelectStylesNames;\n export type Factory = MultiSelectFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,qBAA6C;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AA8GD,MAAM,eAAe;CACnB,WAAW;CACX,eAAe;CACf,mBAAmB;CACnB,0BAA0B;CAC1B,qBAAqB;CACrB,aAAa;CACb,MAAM;CACP;AAED,MAAa,cAAc,gBAAoC,WAAW;CACxE,MAAM,QAAQ,SAAS;EAAC;EAAS;EAAgB;EAAc,EAAE,cAAc,OAAO;CACtF,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,OACA,cACA,UACA,WACA,SACA,MACA,gBACA,uBACA,gBACA,iBACA,2BACA,iCACA,gBACA,eACA,QACA,OACA,gBACA,mBACA,aACA,oBACA,gBACA,UACA,UACA,SACA,QACA,QACA,cACA,mBACA,2BACA,mBACA,aACA,kBACA,0BACA,kBACA,gBACA,mBACA,cACA,YACA,kBACA,YACA,cACA,aACA,OACA,OACA,WACA,YACA,qBACA,eACA,mBACA,mBACA,mBACA,iBACA,MACA,MACA,IACA,WACA,kBACA,kBACA,kBACA,aACA,0BACA,UACA,KACA,cACA,YACA,UACA,SACA,aACA,iBACA,cACA,YACA,qBACA,aACA,SACA,iBACA,kBACA,GAAG,WACD;CAEJ,MAAM,MAAMA,QAAM,GAAG;CACrB,MAAM,aAAa,sBAAsB,KAAK;CAC9C,MAAM,gBAAgB,iBAAiB,WAAW;CAClD,MAAM,0BAA0B,OAAgD,EAAE,CAAC;CAEnF,MAAM,WAAW,YAAY;EAC3B,QAAQ;EACR,eAAe;EACf,sBAAsB;AACpB,qBAAkB;AAClB,OAAI,gCACF,UAAS,mBAAmB;;EAGhC,uBA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MACP,WAAW,UAAU;AACnB,0BAAmB,MAAM,cAAc,MAAM;AAC7C,qBAAc,SAAS,cAAc;AACrC,oCAA6B,SAAS,mBAAmB;;MAEjD;MACV,UAAU,YAAY,CAAC;MACvB,SAAS,CAAC;MACV,CAAA;KACoB,CAAA,CACb;;GACF,CAAA,EACW,CAAA,EAE1B,oBAAC,iBAAD;GACE,MAAM,oBAAoB,eAAe;GACzC,QAAQ,YAAY;GACZ;GACR,QAAQ;GACD;GACP,iBAAiB,CAAC;GACF;GACG;GACnB,eAAe;GACf,OAAO;GACY;GACJ;GACI;GACE;GACX;GACV,SAAS,QAAQ,GAAG,IAAI,UAAU,KAAA;GAClC,cAAY,QAAQ,KAAA,IAAY,OAAO;GACzB;GACG;GACjB,CAAA,CACO;KACX,oBAAC,SAAS,aAAV;EACQ;EACN,eAAe;EACf,OAAO;EACD;EACI;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,YAAY,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AACnE,YAAY,cAAc"}
|
|
@@ -12,7 +12,11 @@ const defaultProps = {
|
|
|
12
12
|
rightSectionPointerEvents: "none"
|
|
13
13
|
};
|
|
14
14
|
const NativeSelect = factory((props) => {
|
|
15
|
-
const { data, children, size, error, rightSection, unstyled, ...others } = useProps(
|
|
15
|
+
const { data, children, size, error, rightSection, unstyled, ...others } = useProps([
|
|
16
|
+
"Input",
|
|
17
|
+
"InputWrapper",
|
|
18
|
+
"NativeSelect"
|
|
19
|
+
], defaultProps, props);
|
|
16
20
|
const options = getParsedComboboxData(data).map((item, index) => /* @__PURE__ */ jsx(NativeSelectOption, { data: item }, index));
|
|
17
21
|
return /* @__PURE__ */ jsx(InputBase, {
|
|
18
22
|
component: "select",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeSelect.mjs","names":[],"sources":["../../../src/components/NativeSelect/NativeSelect.tsx"],"sourcesContent":["import { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { ComboboxChevron, ComboboxData, getParsedComboboxData } from '../Combobox';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { NativeSelectOption } from './NativeSelectOption';\n\nexport interface NativeSelectProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<NativeSelectFactory>,\n ElementProps<'select', 'size'> {\n /**\n * Data used to render options. Accepts strings, objects with label/value,\n * or grouped options. If `children` prop is provided, `data` will be ignored.\n */\n data?: ComboboxData;\n}\n\nexport type NativeSelectFactory = Factory<{\n props: NativeSelectProps;\n ref: HTMLSelectElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n rightSectionPointerEvents: 'none',\n} satisfies Partial<NativeSelectProps>;\n\nexport const NativeSelect = factory<NativeSelectFactory>((props) => {\n const { data, children, size, error, rightSection, unstyled, ...others } = useProps(\n 'NativeSelect',\n defaultProps,\n props\n );\n\n const options = getParsedComboboxData<string>(data).map((item, index) => (\n <NativeSelectOption key={index} data={item} />\n ));\n\n return (\n <InputBase\n component=\"select\"\n {...others}\n __staticSelector=\"NativeSelect\"\n size={size}\n pointer\n error={error}\n unstyled={unstyled}\n rightSection={\n rightSection || <ComboboxChevron size={size} error={error} unstyled={unstyled} />\n }\n >\n {children || options}\n </InputBase>\n );\n});\n\nNativeSelect.classes = InputBase.classes;\nNativeSelect.displayName = '@mantine/core/NativeSelect';\n\nexport namespace NativeSelect {\n export type Props = NativeSelectProps;\n export type Factory = NativeSelectFactory;\n export type StylesNames = __InputStylesNames;\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,eAAe;CACnB,MAAM;CACN,2BAA2B;CAC5B;AAED,MAAa,eAAe,SAA8B,UAAU;CAClE,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,cAAc,UAAU,GAAG,WAAW,SACzE,
|
|
1
|
+
{"version":3,"file":"NativeSelect.mjs","names":[],"sources":["../../../src/components/NativeSelect/NativeSelect.tsx"],"sourcesContent":["import { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { ComboboxChevron, ComboboxData, getParsedComboboxData } from '../Combobox';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { NativeSelectOption } from './NativeSelectOption';\n\nexport interface NativeSelectProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<NativeSelectFactory>,\n ElementProps<'select', 'size'> {\n /**\n * Data used to render options. Accepts strings, objects with label/value,\n * or grouped options. If `children` prop is provided, `data` will be ignored.\n */\n data?: ComboboxData;\n}\n\nexport type NativeSelectFactory = Factory<{\n props: NativeSelectProps;\n ref: HTMLSelectElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n rightSectionPointerEvents: 'none',\n} satisfies Partial<NativeSelectProps>;\n\nexport const NativeSelect = factory<NativeSelectFactory>((props) => {\n const { data, children, size, error, rightSection, unstyled, ...others } = useProps(\n ['Input', 'InputWrapper', 'NativeSelect'],\n defaultProps,\n props\n );\n\n const options = getParsedComboboxData<string>(data).map((item, index) => (\n <NativeSelectOption key={index} data={item} />\n ));\n\n return (\n <InputBase\n component=\"select\"\n {...others}\n __staticSelector=\"NativeSelect\"\n size={size}\n pointer\n error={error}\n unstyled={unstyled}\n rightSection={\n rightSection || <ComboboxChevron size={size} error={error} unstyled={unstyled} />\n }\n >\n {children || options}\n </InputBase>\n );\n});\n\nNativeSelect.classes = InputBase.classes;\nNativeSelect.displayName = '@mantine/core/NativeSelect';\n\nexport namespace NativeSelect {\n export type Props = NativeSelectProps;\n export type Factory = NativeSelectFactory;\n export type StylesNames = __InputStylesNames;\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,eAAe;CACnB,MAAM;CACN,2BAA2B;CAC5B;AAED,MAAa,eAAe,SAA8B,UAAU;CAClE,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,cAAc,UAAU,GAAG,WAAW,SACzE;EAAC;EAAS;EAAgB;EAAe,EACzC,cACA,MACD;CAED,MAAM,UAAU,sBAA8B,KAAK,CAAC,KAAK,MAAM,UAC7D,oBAAC,oBAAD,EAAgC,MAAM,MAAQ,EAArB,MAAqB,CAC9C;AAEF,QACE,oBAAC,WAAD;EACE,WAAU;EACV,GAAI;EACJ,kBAAiB;EACX;EACN,SAAA;EACO;EACG;EACV,cACE,gBAAgB,oBAAC,iBAAD;GAAuB;GAAa;GAAiB;GAAY,CAAA;YAGlF,YAAY;EACH,CAAA;EAEd;AAEF,aAAa,UAAU,UAAU;AACjC,aAAa,cAAc"}
|
|
@@ -98,7 +98,11 @@ function clampAndSanitizeBigIntInput(sanitizedValue, options) {
|
|
|
98
98
|
return options.clampBehavior === "blur" ? clampBigInt(parsed, options.min, options.max) : parsed;
|
|
99
99
|
}
|
|
100
100
|
const NumberInput = genericFactory((_props) => {
|
|
101
|
-
const props = useProps(
|
|
101
|
+
const props = useProps([
|
|
102
|
+
"Input",
|
|
103
|
+
"InputWrapper",
|
|
104
|
+
"NumberInput"
|
|
105
|
+
], defaultProps, _props);
|
|
102
106
|
const { className, classNames, styles, unstyled, vars, onChange, onValueChange, value, defaultValue, max, min, step, hideControls, rightSection, isAllowed, clampBehavior, onBlur, allowDecimal, decimalScale, onKeyDown, onKeyDownCapture, handlersRef, startValue, disabled, rightSectionPointerEvents, allowNegative, readOnly, size, rightSectionWidth, stepHoldInterval, stepHoldDelay, allowLeadingZeros, withKeyboardEvents, trimLeadingZeroesOnBlur, allowedDecimalSeparators, selectAllOnFocus, onMinReached, onMaxReached, onFocus, attributes, ref, ...others } = props;
|
|
103
107
|
const allowNegativeResolved = allowNegative ?? true;
|
|
104
108
|
const allowLeadingZerosResolved = allowLeadingZeros ?? true;
|