@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.
Files changed (236) hide show
  1. package/cjs/components/Autocomplete/Autocomplete.cjs +5 -1
  2. package/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
  3. package/cjs/components/Card/Card.cjs +1 -1
  4. package/cjs/components/Card/Card.cjs.map +1 -1
  5. package/cjs/components/Checkbox/Checkbox.cjs +4 -1
  6. package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
  7. package/cjs/components/ColorInput/ColorInput.cjs +5 -1
  8. package/cjs/components/ColorInput/ColorInput.cjs.map +1 -1
  9. package/cjs/components/Combobox/ComboboxClearButton/ComboboxClearButton.cjs +1 -1
  10. package/cjs/components/Combobox/ComboboxClearButton/ComboboxClearButton.cjs.map +1 -1
  11. package/cjs/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.cjs +1 -0
  12. package/cjs/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.cjs.map +1 -1
  13. package/cjs/components/Combobox/ComboboxSearch/ComboboxSearch.cjs +2 -1
  14. package/cjs/components/Combobox/ComboboxSearch/ComboboxSearch.cjs.map +1 -1
  15. package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.cjs +1 -0
  16. package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.cjs.map +1 -1
  17. package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.cjs +18 -12
  18. package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.cjs.map +1 -1
  19. package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs +17 -0
  20. package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs.map +1 -0
  21. package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs +170 -0
  22. package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs.map +1 -0
  23. package/cjs/components/FileInput/FileInput.cjs +5 -1
  24. package/cjs/components/FileInput/FileInput.cjs.map +1 -1
  25. package/cjs/components/Highlight/highlighter/highlighter.cjs +3 -3
  26. package/cjs/components/Highlight/highlighter/highlighter.cjs.map +1 -1
  27. package/cjs/components/Input/use-input-props.cjs +5 -1
  28. package/cjs/components/Input/use-input-props.cjs.map +1 -1
  29. package/cjs/components/JsonInput/JsonInput.cjs +5 -2
  30. package/cjs/components/JsonInput/JsonInput.cjs.map +1 -1
  31. package/cjs/components/MaskInput/MaskInput.cjs +5 -1
  32. package/cjs/components/MaskInput/MaskInput.cjs.map +1 -1
  33. package/cjs/components/MaskInput/use-mask-input-props.cjs +3 -2
  34. package/cjs/components/MaskInput/use-mask-input-props.cjs.map +1 -1
  35. package/cjs/components/MultiSelect/MultiSelect.cjs +19 -3
  36. package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
  37. package/cjs/components/NativeSelect/NativeSelect.cjs +5 -1
  38. package/cjs/components/NativeSelect/NativeSelect.cjs.map +1 -1
  39. package/cjs/components/NumberInput/NumberInput.cjs +5 -1
  40. package/cjs/components/NumberInput/NumberInput.cjs.map +1 -1
  41. package/cjs/components/PasswordInput/PasswordInput.cjs +6 -2
  42. package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
  43. package/cjs/components/Pill/Pill.module.cjs.map +1 -1
  44. package/cjs/components/PillsInput/PillsInput.cjs +5 -1
  45. package/cjs/components/PillsInput/PillsInput.cjs.map +1 -1
  46. package/cjs/components/PinInput/PinInput.cjs +1 -1
  47. package/cjs/components/PinInput/PinInput.cjs.map +1 -1
  48. package/cjs/components/Popover/Popover.context.cjs.map +1 -1
  49. package/cjs/components/Popover/PopoverDropdown/PopoverDropdown.cjs +1 -1
  50. package/cjs/components/Popover/PopoverDropdown/PopoverDropdown.cjs.map +1 -1
  51. package/cjs/components/Radio/Radio.module.cjs.map +1 -1
  52. package/cjs/components/RollingNumber/DigitColumn.cjs +46 -0
  53. package/cjs/components/RollingNumber/DigitColumn.cjs.map +1 -0
  54. package/cjs/components/RollingNumber/RollingNumber.cjs +102 -0
  55. package/cjs/components/RollingNumber/RollingNumber.cjs.map +1 -0
  56. package/cjs/components/RollingNumber/RollingNumber.module.cjs +13 -0
  57. package/cjs/components/RollingNumber/RollingNumber.module.cjs.map +1 -0
  58. package/cjs/components/RollingNumber/build-value.cjs +22 -0
  59. package/cjs/components/RollingNumber/build-value.cjs.map +1 -0
  60. package/cjs/components/RollingNumber/get-digit-parts.cjs +40 -0
  61. package/cjs/components/RollingNumber/get-digit-parts.cjs.map +1 -0
  62. package/cjs/components/RollingNumber/get-render-slots.cjs +78 -0
  63. package/cjs/components/RollingNumber/get-render-slots.cjs.map +1 -0
  64. package/cjs/components/ScrollArea/ScrollArea.cjs +24 -10
  65. package/cjs/components/ScrollArea/ScrollArea.cjs.map +1 -1
  66. package/cjs/components/Select/Select.cjs +5 -1
  67. package/cjs/components/Select/Select.cjs.map +1 -1
  68. package/cjs/components/TagsInput/TagsInput.cjs +19 -4
  69. package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
  70. package/cjs/components/TextInput/TextInput.cjs +5 -1
  71. package/cjs/components/TextInput/TextInput.cjs.map +1 -1
  72. package/cjs/components/Textarea/Textarea.cjs +5 -2
  73. package/cjs/components/Textarea/Textarea.cjs.map +1 -1
  74. package/cjs/components/Tree/FlatTreeNode.cjs +2 -1
  75. package/cjs/components/Tree/FlatTreeNode.cjs.map +1 -1
  76. package/cjs/components/Tree/Tree.cjs +3 -1
  77. package/cjs/components/Tree/Tree.cjs.map +1 -1
  78. package/cjs/components/Tree/TreeNode.cjs +10 -5
  79. package/cjs/components/Tree/TreeNode.cjs.map +1 -1
  80. package/cjs/components/Tree/is-node-checked/is-node-checked.cjs +1 -0
  81. package/cjs/components/Tree/is-node-indeterminate/is-node-indeterminate.cjs +1 -0
  82. package/cjs/components/Tree/use-tree-node-drag-drop.cjs +46 -15
  83. package/cjs/components/Tree/use-tree-node-drag-drop.cjs.map +1 -1
  84. package/cjs/components/TreeSelect/TreeSelect.cjs +601 -0
  85. package/cjs/components/TreeSelect/TreeSelect.cjs.map +1 -0
  86. package/cjs/components/TreeSelect/TreeSelect.module.cjs +16 -0
  87. package/cjs/components/TreeSelect/TreeSelect.module.cjs.map +1 -0
  88. package/cjs/components/TreeSelect/TreeSelectOption.cjs +95 -0
  89. package/cjs/components/TreeSelect/TreeSelectOption.cjs.map +1 -0
  90. package/cjs/components/TreeSelect/flatten-tree-select-data.cjs +34 -0
  91. package/cjs/components/TreeSelect/flatten-tree-select-data.cjs.map +1 -0
  92. package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs +30 -0
  93. package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs.map +1 -0
  94. package/cjs/core/MantineProvider/use-props/use-props.cjs +10 -2
  95. package/cjs/core/MantineProvider/use-props/use-props.cjs.map +1 -1
  96. package/cjs/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.cjs +2 -2
  97. package/cjs/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.cjs.map +1 -1
  98. package/cjs/index.cjs +8 -0
  99. package/esm/components/Autocomplete/Autocomplete.mjs +5 -1
  100. package/esm/components/Autocomplete/Autocomplete.mjs.map +1 -1
  101. package/esm/components/Card/Card.mjs +1 -1
  102. package/esm/components/Card/Card.mjs.map +1 -1
  103. package/esm/components/Checkbox/Checkbox.mjs +4 -1
  104. package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
  105. package/esm/components/ColorInput/ColorInput.mjs +5 -1
  106. package/esm/components/ColorInput/ColorInput.mjs.map +1 -1
  107. package/esm/components/Combobox/ComboboxClearButton/ComboboxClearButton.mjs +1 -1
  108. package/esm/components/Combobox/ComboboxClearButton/ComboboxClearButton.mjs.map +1 -1
  109. package/esm/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.mjs +1 -0
  110. package/esm/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.mjs.map +1 -1
  111. package/esm/components/Combobox/ComboboxSearch/ComboboxSearch.mjs +2 -1
  112. package/esm/components/Combobox/ComboboxSearch/ComboboxSearch.mjs.map +1 -1
  113. package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.mjs +1 -0
  114. package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.mjs.map +1 -1
  115. package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.mjs +18 -12
  116. package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.mjs.map +1 -1
  117. package/esm/components/Combobox/use-pills-reorder/move-pill.mjs +17 -0
  118. package/esm/components/Combobox/use-pills-reorder/move-pill.mjs.map +1 -0
  119. package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs +169 -0
  120. package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs.map +1 -0
  121. package/esm/components/FileInput/FileInput.mjs +5 -1
  122. package/esm/components/FileInput/FileInput.mjs.map +1 -1
  123. package/esm/components/Highlight/highlighter/highlighter.mjs +3 -3
  124. package/esm/components/Highlight/highlighter/highlighter.mjs.map +1 -1
  125. package/esm/components/Input/use-input-props.mjs +5 -1
  126. package/esm/components/Input/use-input-props.mjs.map +1 -1
  127. package/esm/components/JsonInput/JsonInput.mjs +5 -2
  128. package/esm/components/JsonInput/JsonInput.mjs.map +1 -1
  129. package/esm/components/MaskInput/MaskInput.mjs +5 -1
  130. package/esm/components/MaskInput/MaskInput.mjs.map +1 -1
  131. package/esm/components/MaskInput/use-mask-input-props.mjs +4 -3
  132. package/esm/components/MaskInput/use-mask-input-props.mjs.map +1 -1
  133. package/esm/components/MultiSelect/MultiSelect.mjs +19 -3
  134. package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
  135. package/esm/components/NativeSelect/NativeSelect.mjs +5 -1
  136. package/esm/components/NativeSelect/NativeSelect.mjs.map +1 -1
  137. package/esm/components/NumberInput/NumberInput.mjs +5 -1
  138. package/esm/components/NumberInput/NumberInput.mjs.map +1 -1
  139. package/esm/components/PasswordInput/PasswordInput.mjs +6 -2
  140. package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
  141. package/esm/components/Pill/Pill.module.mjs.map +1 -1
  142. package/esm/components/PillsInput/PillsInput.mjs +5 -1
  143. package/esm/components/PillsInput/PillsInput.mjs.map +1 -1
  144. package/esm/components/PinInput/PinInput.mjs +1 -1
  145. package/esm/components/PinInput/PinInput.mjs.map +1 -1
  146. package/esm/components/Popover/Popover.context.mjs.map +1 -1
  147. package/esm/components/Popover/PopoverDropdown/PopoverDropdown.mjs +1 -1
  148. package/esm/components/Popover/PopoverDropdown/PopoverDropdown.mjs.map +1 -1
  149. package/esm/components/Radio/Radio.module.mjs.map +1 -1
  150. package/esm/components/RollingNumber/DigitColumn.mjs +45 -0
  151. package/esm/components/RollingNumber/DigitColumn.mjs.map +1 -0
  152. package/esm/components/RollingNumber/RollingNumber.mjs +101 -0
  153. package/esm/components/RollingNumber/RollingNumber.mjs.map +1 -0
  154. package/esm/components/RollingNumber/RollingNumber.module.mjs +13 -0
  155. package/esm/components/RollingNumber/RollingNumber.module.mjs.map +1 -0
  156. package/esm/components/RollingNumber/build-value.mjs +22 -0
  157. package/esm/components/RollingNumber/build-value.mjs.map +1 -0
  158. package/esm/components/RollingNumber/get-digit-parts.mjs +40 -0
  159. package/esm/components/RollingNumber/get-digit-parts.mjs.map +1 -0
  160. package/esm/components/RollingNumber/get-render-slots.mjs +78 -0
  161. package/esm/components/RollingNumber/get-render-slots.mjs.map +1 -0
  162. package/esm/components/ScrollArea/ScrollArea.mjs +25 -11
  163. package/esm/components/ScrollArea/ScrollArea.mjs.map +1 -1
  164. package/esm/components/Select/Select.mjs +5 -1
  165. package/esm/components/Select/Select.mjs.map +1 -1
  166. package/esm/components/TagsInput/TagsInput.mjs +19 -4
  167. package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
  168. package/esm/components/TextInput/TextInput.mjs +5 -1
  169. package/esm/components/TextInput/TextInput.mjs.map +1 -1
  170. package/esm/components/Textarea/Textarea.mjs +5 -2
  171. package/esm/components/Textarea/Textarea.mjs.map +1 -1
  172. package/esm/components/Tree/FlatTreeNode.mjs +2 -1
  173. package/esm/components/Tree/FlatTreeNode.mjs.map +1 -1
  174. package/esm/components/Tree/Tree.mjs +3 -1
  175. package/esm/components/Tree/Tree.mjs.map +1 -1
  176. package/esm/components/Tree/TreeNode.mjs +10 -5
  177. package/esm/components/Tree/TreeNode.mjs.map +1 -1
  178. package/esm/components/Tree/is-node-checked/is-node-checked.mjs +1 -1
  179. package/esm/components/Tree/is-node-indeterminate/is-node-indeterminate.mjs +1 -1
  180. package/esm/components/Tree/use-tree-node-drag-drop.mjs +45 -15
  181. package/esm/components/Tree/use-tree-node-drag-drop.mjs.map +1 -1
  182. package/esm/components/TreeSelect/TreeSelect.mjs +600 -0
  183. package/esm/components/TreeSelect/TreeSelect.mjs.map +1 -0
  184. package/esm/components/TreeSelect/TreeSelect.module.mjs +16 -0
  185. package/esm/components/TreeSelect/TreeSelect.module.mjs.map +1 -0
  186. package/esm/components/TreeSelect/TreeSelectOption.mjs +94 -0
  187. package/esm/components/TreeSelect/TreeSelectOption.mjs.map +1 -0
  188. package/esm/components/TreeSelect/flatten-tree-select-data.mjs +34 -0
  189. package/esm/components/TreeSelect/flatten-tree-select-data.mjs.map +1 -0
  190. package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs +29 -0
  191. package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs.map +1 -0
  192. package/esm/core/MantineProvider/use-props/use-props.mjs +10 -2
  193. package/esm/core/MantineProvider/use-props/use-props.mjs.map +1 -1
  194. package/esm/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.mjs +2 -2
  195. package/esm/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.mjs.map +1 -1
  196. package/esm/index.mjs +5 -1
  197. package/lib/components/Combobox/Combobox.types.d.ts +3 -0
  198. package/lib/components/Combobox/ComboboxClearButton/ComboboxClearButton.d.ts +1 -1
  199. package/lib/components/Combobox/index.d.ts +2 -0
  200. package/lib/components/Combobox/use-combobox-target-props/use-combobox-target-props.d.ts +3 -1
  201. package/lib/components/Combobox/use-pills-reorder/move-pill.d.ts +2 -0
  202. package/lib/components/Combobox/use-pills-reorder/use-pills-reorder.d.ts +26 -0
  203. package/lib/components/MaskInput/MaskInput.d.ts +2 -0
  204. package/lib/components/MultiSelect/MultiSelect.d.ts +3 -1
  205. package/lib/components/Popover/Popover.context.d.ts +1 -1
  206. package/lib/components/RollingNumber/DigitColumn.d.ts +11 -0
  207. package/lib/components/RollingNumber/RollingNumber.d.ts +41 -0
  208. package/lib/components/RollingNumber/build-value.d.ts +10 -0
  209. package/lib/components/RollingNumber/get-digit-parts.d.ts +12 -0
  210. package/lib/components/RollingNumber/get-render-slots.d.ts +35 -0
  211. package/lib/components/RollingNumber/index.d.ts +9 -0
  212. package/lib/components/Select/Select.d.ts +1 -1
  213. package/lib/components/TagsInput/TagsInput.d.ts +2 -0
  214. package/lib/components/Tree/Tree.d.ts +10 -0
  215. package/lib/components/Tree/TreeNode.d.ts +4 -1
  216. package/lib/components/Tree/index.d.ts +1 -0
  217. package/lib/components/Tree/use-tree-node-drag-drop.d.ts +19 -7
  218. package/lib/components/TreeSelect/TreeSelect.d.ts +124 -0
  219. package/lib/components/TreeSelect/TreeSelectOption.d.ts +36 -0
  220. package/lib/components/TreeSelect/flatten-tree-select-data.d.ts +12 -0
  221. package/lib/components/TreeSelect/get-checked-values-by-strategy.d.ts +4 -0
  222. package/lib/components/TreeSelect/index.d.ts +13 -0
  223. package/lib/components/index.d.ts +2 -0
  224. package/lib/core/MantineProvider/use-props/use-props.d.ts +1 -1
  225. package/lib/core/styles-api/use-resolved-styles-api/use-resolved-styles-api.d.ts +2 -2
  226. package/package.json +2 -2
  227. package/styles/Pill.css +35 -0
  228. package/styles/Pill.layer.css +35 -0
  229. package/styles/Radio.css +3 -2
  230. package/styles/Radio.layer.css +3 -2
  231. package/styles/RollingNumber.css +60 -0
  232. package/styles/RollingNumber.layer.css +61 -0
  233. package/styles/TreeSelect.css +113 -0
  234. package/styles/TreeSelect.layer.css +114 -0
  235. package/styles.css +213 -2
  236. package/styles.layer.css +213 -2
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ require("../../../_virtual/_rolldown/runtime.cjs");
3
+ const require_move_pill = require("./move-pill.cjs");
4
+ let react = require("react");
5
+ //#region packages/@mantine/core/src/components/Combobox/use-pills-reorder/use-pills-reorder.ts
6
+ const findSearchInput = (container) => {
7
+ const lastChild = container.lastElementChild;
8
+ if (!lastChild) return null;
9
+ if (lastChild instanceof HTMLInputElement) return lastChild;
10
+ return lastChild.querySelector("input");
11
+ };
12
+ const valuesMatch = (a, b) => {
13
+ if (a === b) return true;
14
+ if (a.length !== b.length) return false;
15
+ for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
16
+ return true;
17
+ };
18
+ function usePillsReorder({ value, onChange, enabled }) {
19
+ const dragStateRef = (0, react.useRef)({
20
+ draggedIndex: null,
21
+ currentDropTarget: null
22
+ });
23
+ const pendingFocusRef = (0, react.useRef)(null);
24
+ const containerRef = (0, react.useRef)(null);
25
+ const valueRef = (0, react.useRef)(value);
26
+ valueRef.current = value;
27
+ (0, react.useEffect)(() => {
28
+ const pending = pendingFocusRef.current;
29
+ if (!pending) return;
30
+ pendingFocusRef.current = null;
31
+ if (!valuesMatch(valueRef.current, pending.expectedValue)) return;
32
+ pending.container?.querySelector(`[data-mantine-pill-index="${pending.index}"]`)?.focus();
33
+ });
34
+ const setContainer = (0, react.useCallback)((node) => {
35
+ containerRef.current = node;
36
+ }, []);
37
+ const getListProps = () => {
38
+ if (!enabled) return {};
39
+ return { ref: setContainer };
40
+ };
41
+ const handleInputKeyDown = (event) => {
42
+ if (!enabled || event.key !== "ArrowLeft") return;
43
+ const input = event.currentTarget;
44
+ if (!(input.value.length === 0 || input.selectionStart === 0 && input.selectionEnd === 0)) return;
45
+ const container = containerRef.current;
46
+ if (!container) return;
47
+ const pills = container.querySelectorAll("[data-mantine-pill-index]");
48
+ if (pills.length === 0) return;
49
+ event.preventDefault();
50
+ pills[pills.length - 1].focus();
51
+ };
52
+ const getPillProps = (index) => {
53
+ if (!enabled) return;
54
+ return {
55
+ draggable: true,
56
+ tabIndex: -1,
57
+ "data-mantine-pill-index": index,
58
+ "aria-keyshortcuts": "Alt+ArrowLeft Alt+ArrowRight",
59
+ onMouseDown: (event) => {
60
+ if (event.button === 0) event.stopPropagation();
61
+ },
62
+ onDragStart: (event) => {
63
+ event.stopPropagation();
64
+ event.dataTransfer.effectAllowed = "move";
65
+ event.dataTransfer.setData("text/plain", String(index));
66
+ dragStateRef.current.draggedIndex = index;
67
+ const target = event.currentTarget;
68
+ const rect = target.getBoundingClientRect();
69
+ const ghost = target.cloneNode(true);
70
+ ghost.removeAttribute("data-dragging");
71
+ ghost.removeAttribute("data-drag-over");
72
+ ghost.style.position = "fixed";
73
+ ghost.style.top = "-9999px";
74
+ ghost.style.left = "-9999px";
75
+ ghost.style.width = `${rect.width}px`;
76
+ ghost.style.height = `${rect.height}px`;
77
+ ghost.style.pointerEvents = "none";
78
+ document.body.appendChild(ghost);
79
+ event.dataTransfer.setDragImage(ghost, event.clientX - rect.left, event.clientY - rect.top);
80
+ setTimeout(() => ghost.parentNode?.removeChild(ghost), 0);
81
+ requestAnimationFrame(() => {
82
+ target.setAttribute("data-dragging", "true");
83
+ });
84
+ },
85
+ onDragOver: (event) => {
86
+ const { draggedIndex } = dragStateRef.current;
87
+ if (draggedIndex === null || draggedIndex === index) return;
88
+ const target = event.currentTarget;
89
+ const rect = target.getBoundingClientRect();
90
+ const x = event.clientX - rect.left;
91
+ const position = (getComputedStyle(target).direction === "rtl" ? x > rect.width / 2 : x < rect.width / 2) ? "before" : "after";
92
+ event.preventDefault();
93
+ event.stopPropagation();
94
+ event.dataTransfer.dropEffect = "move";
95
+ const prevTarget = dragStateRef.current.currentDropTarget;
96
+ if (prevTarget && prevTarget !== target) prevTarget.removeAttribute("data-drag-over");
97
+ target.setAttribute("data-drag-over", position);
98
+ dragStateRef.current.currentDropTarget = target;
99
+ },
100
+ onDragLeave: (event) => {
101
+ const target = event.currentTarget;
102
+ const related = event.relatedTarget;
103
+ if (related && target.contains(related)) return;
104
+ target.removeAttribute("data-drag-over");
105
+ if (dragStateRef.current.currentDropTarget === target) dragStateRef.current.currentDropTarget = null;
106
+ },
107
+ onDrop: (event) => {
108
+ event.preventDefault();
109
+ event.stopPropagation();
110
+ const target = event.currentTarget;
111
+ const position = target.getAttribute("data-drag-over");
112
+ target.removeAttribute("data-drag-over");
113
+ const { draggedIndex } = dragStateRef.current;
114
+ if (draggedIndex !== null && position && draggedIndex !== index) {
115
+ const nextValue = require_move_pill.movePill(valueRef.current, draggedIndex, index, position);
116
+ if (nextValue !== valueRef.current) onChange(nextValue);
117
+ }
118
+ dragStateRef.current.draggedIndex = null;
119
+ dragStateRef.current.currentDropTarget = null;
120
+ },
121
+ onDragEnd: (event) => {
122
+ event.currentTarget.removeAttribute("data-dragging");
123
+ const prevTarget = dragStateRef.current.currentDropTarget;
124
+ if (prevTarget) prevTarget.removeAttribute("data-drag-over");
125
+ dragStateRef.current.draggedIndex = null;
126
+ dragStateRef.current.currentDropTarget = null;
127
+ },
128
+ onKeyDown: (event) => {
129
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
130
+ const target = event.currentTarget;
131
+ const movingForward = getComputedStyle(target).direction === "rtl" ? event.key === "ArrowLeft" : event.key === "ArrowRight";
132
+ const targetIndex = movingForward ? index + 1 : index - 1;
133
+ if (event.altKey) {
134
+ if (targetIndex < 0 || targetIndex >= valueRef.current.length) return;
135
+ event.preventDefault();
136
+ event.stopPropagation();
137
+ const position = movingForward ? "after" : "before";
138
+ const nextValue = require_move_pill.movePill(valueRef.current, index, targetIndex, position);
139
+ if (nextValue === valueRef.current) return;
140
+ pendingFocusRef.current = {
141
+ container: target.parentElement,
142
+ index: targetIndex,
143
+ expectedValue: nextValue
144
+ };
145
+ onChange(nextValue);
146
+ return;
147
+ }
148
+ if (targetIndex < 0) return;
149
+ const container = target.parentElement;
150
+ if (!container) return;
151
+ event.preventDefault();
152
+ event.stopPropagation();
153
+ if (targetIndex >= valueRef.current.length) {
154
+ findSearchInput(container)?.focus();
155
+ return;
156
+ }
157
+ container.querySelector(`[data-mantine-pill-index="${targetIndex}"]`)?.focus();
158
+ }
159
+ };
160
+ };
161
+ return {
162
+ getPillProps,
163
+ getListProps,
164
+ handleInputKeyDown
165
+ };
166
+ }
167
+ //#endregion
168
+ exports.usePillsReorder = usePillsReorder;
169
+
170
+ //# sourceMappingURL=use-pills-reorder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pills-reorder.cjs","names":["movePill"],"sources":["../../../../src/components/Combobox/use-pills-reorder/use-pills-reorder.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { movePill, PillReorderPosition } from './move-pill';\n\nexport interface PillReorderProps {\n draggable: boolean;\n tabIndex: number;\n 'data-mantine-pill-index': number;\n 'aria-keyshortcuts': string;\n onMouseDown: (event: React.MouseEvent<HTMLElement>) => void;\n onDragStart: (event: React.DragEvent<HTMLElement>) => void;\n onDragOver: (event: React.DragEvent<HTMLElement>) => void;\n onDragLeave: (event: React.DragEvent<HTMLElement>) => void;\n onDrop: (event: React.DragEvent<HTMLElement>) => void;\n onDragEnd: (event: React.DragEvent<HTMLElement>) => void;\n onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\nexport interface PillsReorderListProps {\n ref?: (node: HTMLDivElement | null) => void;\n}\n\nexport interface UsePillsReorderInput<T> {\n value: T[];\n onChange: (value: T[]) => void;\n enabled: boolean | undefined;\n}\n\ninterface PillDragState {\n draggedIndex: number | null;\n currentDropTarget: HTMLElement | null;\n}\n\ninterface PendingFocus<T> {\n container: HTMLElement | null;\n index: number;\n expectedValue: T[];\n}\n\nconst findSearchInput = (container: HTMLElement): HTMLInputElement | null => {\n const lastChild = container.lastElementChild;\n if (!lastChild) {\n return null;\n }\n if (lastChild instanceof HTMLInputElement) {\n return lastChild;\n }\n return lastChild.querySelector<HTMLInputElement>('input');\n};\n\nconst valuesMatch = <T>(a: T[], b: T[]): boolean => {\n if (a === b) {\n return true;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n};\n\nexport function usePillsReorder<T>({ value, onChange, enabled }: UsePillsReorderInput<T>) {\n const dragStateRef = useRef<PillDragState>({ draggedIndex: null, currentDropTarget: null });\n const pendingFocusRef = useRef<PendingFocus<T> | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const valueRef = useRef(value);\n valueRef.current = value;\n\n useEffect(() => {\n const pending = pendingFocusRef.current;\n if (!pending) {\n return;\n }\n pendingFocusRef.current = null;\n if (!valuesMatch(valueRef.current, pending.expectedValue)) {\n return;\n }\n pending.container\n ?.querySelector<HTMLElement>(`[data-mantine-pill-index=\"${pending.index}\"]`)\n ?.focus();\n });\n\n const setContainer = useCallback((node: HTMLDivElement | null) => {\n containerRef.current = node;\n }, []);\n\n const getListProps = (): PillsReorderListProps => {\n if (!enabled) {\n return {};\n }\n return { ref: setContainer };\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (!enabled || event.key !== 'ArrowLeft') {\n return;\n }\n\n const input = event.currentTarget;\n const caretAtStart =\n input.value.length === 0 || (input.selectionStart === 0 && input.selectionEnd === 0);\n if (!caretAtStart) {\n return;\n }\n\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n const pills = container.querySelectorAll<HTMLElement>('[data-mantine-pill-index]');\n if (pills.length === 0) {\n return;\n }\n\n event.preventDefault();\n pills[pills.length - 1].focus();\n };\n\n const getPillProps = (index: number): PillReorderProps | undefined => {\n if (!enabled) {\n return undefined;\n }\n\n return {\n draggable: true,\n tabIndex: -1,\n 'data-mantine-pill-index': index,\n 'aria-keyshortcuts': 'Alt+ArrowLeft Alt+ArrowRight',\n onMouseDown: (event) => {\n if (event.button === 0) {\n event.stopPropagation();\n }\n },\n onDragStart: (event) => {\n event.stopPropagation();\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setData('text/plain', String(index));\n dragStateRef.current.draggedIndex = index;\n\n const target = event.currentTarget;\n const rect = target.getBoundingClientRect();\n const ghost = target.cloneNode(true) as HTMLElement;\n ghost.removeAttribute('data-dragging');\n ghost.removeAttribute('data-drag-over');\n ghost.style.position = 'fixed';\n ghost.style.top = '-9999px';\n ghost.style.left = '-9999px';\n ghost.style.width = `${rect.width}px`;\n ghost.style.height = `${rect.height}px`;\n ghost.style.pointerEvents = 'none';\n document.body.appendChild(ghost);\n event.dataTransfer.setDragImage(ghost, event.clientX - rect.left, event.clientY - rect.top);\n\n setTimeout(() => ghost.parentNode?.removeChild(ghost), 0);\n\n requestAnimationFrame(() => {\n target.setAttribute('data-dragging', 'true');\n });\n },\n onDragOver: (event) => {\n const { draggedIndex } = dragStateRef.current;\n if (draggedIndex === null || draggedIndex === index) {\n return;\n }\n\n const target = event.currentTarget;\n const rect = target.getBoundingClientRect();\n const x = event.clientX - rect.left;\n const isRtl = getComputedStyle(target).direction === 'rtl';\n const isStart = isRtl ? x > rect.width / 2 : x < rect.width / 2;\n const position: PillReorderPosition = isStart ? 'before' : 'after';\n\n event.preventDefault();\n event.stopPropagation();\n event.dataTransfer.dropEffect = 'move';\n\n const prevTarget = dragStateRef.current.currentDropTarget;\n if (prevTarget && prevTarget !== target) {\n prevTarget.removeAttribute('data-drag-over');\n }\n\n target.setAttribute('data-drag-over', position);\n dragStateRef.current.currentDropTarget = target;\n },\n onDragLeave: (event) => {\n const target = event.currentTarget;\n const related = event.relatedTarget as Node | null;\n if (related && target.contains(related)) {\n return;\n }\n\n target.removeAttribute('data-drag-over');\n if (dragStateRef.current.currentDropTarget === target) {\n dragStateRef.current.currentDropTarget = null;\n }\n },\n onDrop: (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n const target = event.currentTarget;\n const position = target.getAttribute('data-drag-over') as PillReorderPosition | null;\n target.removeAttribute('data-drag-over');\n\n const { draggedIndex } = dragStateRef.current;\n if (draggedIndex !== null && position && draggedIndex !== index) {\n const nextValue = movePill(valueRef.current, draggedIndex, index, position);\n if (nextValue !== valueRef.current) {\n onChange(nextValue);\n }\n }\n\n dragStateRef.current.draggedIndex = null;\n dragStateRef.current.currentDropTarget = null;\n },\n onDragEnd: (event) => {\n const target = event.currentTarget;\n target.removeAttribute('data-dragging');\n\n const prevTarget = dragStateRef.current.currentDropTarget;\n if (prevTarget) {\n prevTarget.removeAttribute('data-drag-over');\n }\n\n dragStateRef.current.draggedIndex = null;\n dragStateRef.current.currentDropTarget = null;\n },\n onKeyDown: (event) => {\n if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {\n return;\n }\n\n const target = event.currentTarget;\n const isRtl = getComputedStyle(target).direction === 'rtl';\n const movingForward = isRtl ? event.key === 'ArrowLeft' : event.key === 'ArrowRight';\n const targetIndex = movingForward ? index + 1 : index - 1;\n\n if (event.altKey) {\n if (targetIndex < 0 || targetIndex >= valueRef.current.length) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n const position: PillReorderPosition = movingForward ? 'after' : 'before';\n const nextValue = movePill(valueRef.current, index, targetIndex, position);\n if (nextValue === valueRef.current) {\n return;\n }\n\n pendingFocusRef.current = {\n container: target.parentElement,\n index: targetIndex,\n expectedValue: nextValue,\n };\n onChange(nextValue);\n return;\n }\n\n if (targetIndex < 0) {\n return;\n }\n\n const container = target.parentElement;\n if (!container) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n if (targetIndex >= valueRef.current.length) {\n findSearchInput(container)?.focus();\n return;\n }\n\n container.querySelector<HTMLElement>(`[data-mantine-pill-index=\"${targetIndex}\"]`)?.focus();\n },\n };\n };\n\n return { getPillProps, getListProps, handleInputKeyDown };\n}\n"],"mappings":";;;;;AAsCA,MAAM,mBAAmB,cAAoD;CAC3E,MAAM,YAAY,UAAU;AAC5B,KAAI,CAAC,UACH,QAAO;AAET,KAAI,qBAAqB,iBACvB,QAAO;AAET,QAAO,UAAU,cAAgC,QAAQ;;AAG3D,MAAM,eAAkB,GAAQ,MAAoB;AAClD,KAAI,MAAM,EACR,QAAO;AAET,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK,EACjC,KAAI,EAAE,OAAO,EAAE,GACb,QAAO;AAGX,QAAO;;AAGT,SAAgB,gBAAmB,EAAE,OAAO,UAAU,WAAoC;CACxF,MAAM,gBAAA,GAAA,MAAA,QAAqC;EAAE,cAAc;EAAM,mBAAmB;EAAM,CAAC;CAC3F,MAAM,mBAAA,GAAA,MAAA,QAAiD,KAAK;CAC5D,MAAM,gBAAA,GAAA,MAAA,QAA6C,KAAK;CACxD,MAAM,YAAA,GAAA,MAAA,QAAkB,MAAM;AAC9B,UAAS,UAAU;AAEnB,EAAA,GAAA,MAAA,iBAAgB;EACd,MAAM,UAAU,gBAAgB;AAChC,MAAI,CAAC,QACH;AAEF,kBAAgB,UAAU;AAC1B,MAAI,CAAC,YAAY,SAAS,SAAS,QAAQ,cAAc,CACvD;AAEF,UAAQ,WACJ,cAA2B,6BAA6B,QAAQ,MAAM,IAAI,EAC1E,OAAO;GACX;CAEF,MAAM,gBAAA,GAAA,MAAA,cAA4B,SAAgC;AAChE,eAAa,UAAU;IACtB,EAAE,CAAC;CAEN,MAAM,qBAA4C;AAChD,MAAI,CAAC,QACH,QAAO,EAAE;AAEX,SAAO,EAAE,KAAK,cAAc;;CAG9B,MAAM,sBAAsB,UAAiD;AAC3E,MAAI,CAAC,WAAW,MAAM,QAAQ,YAC5B;EAGF,MAAM,QAAQ,MAAM;AAGpB,MAAI,EADF,MAAM,MAAM,WAAW,KAAM,MAAM,mBAAmB,KAAK,MAAM,iBAAiB,GAElF;EAGF,MAAM,YAAY,aAAa;AAC/B,MAAI,CAAC,UACH;EAGF,MAAM,QAAQ,UAAU,iBAA8B,4BAA4B;AAClF,MAAI,MAAM,WAAW,EACnB;AAGF,QAAM,gBAAgB;AACtB,QAAM,MAAM,SAAS,GAAG,OAAO;;CAGjC,MAAM,gBAAgB,UAAgD;AACpE,MAAI,CAAC,QACH;AAGF,SAAO;GACL,WAAW;GACX,UAAU;GACV,2BAA2B;GAC3B,qBAAqB;GACrB,cAAc,UAAU;AACtB,QAAI,MAAM,WAAW,EACnB,OAAM,iBAAiB;;GAG3B,cAAc,UAAU;AACtB,UAAM,iBAAiB;AACvB,UAAM,aAAa,gBAAgB;AACnC,UAAM,aAAa,QAAQ,cAAc,OAAO,MAAM,CAAC;AACvD,iBAAa,QAAQ,eAAe;IAEpC,MAAM,SAAS,MAAM;IACrB,MAAM,OAAO,OAAO,uBAAuB;IAC3C,MAAM,QAAQ,OAAO,UAAU,KAAK;AACpC,UAAM,gBAAgB,gBAAgB;AACtC,UAAM,gBAAgB,iBAAiB;AACvC,UAAM,MAAM,WAAW;AACvB,UAAM,MAAM,MAAM;AAClB,UAAM,MAAM,OAAO;AACnB,UAAM,MAAM,QAAQ,GAAG,KAAK,MAAM;AAClC,UAAM,MAAM,SAAS,GAAG,KAAK,OAAO;AACpC,UAAM,MAAM,gBAAgB;AAC5B,aAAS,KAAK,YAAY,MAAM;AAChC,UAAM,aAAa,aAAa,OAAO,MAAM,UAAU,KAAK,MAAM,MAAM,UAAU,KAAK,IAAI;AAE3F,qBAAiB,MAAM,YAAY,YAAY,MAAM,EAAE,EAAE;AAEzD,gCAA4B;AAC1B,YAAO,aAAa,iBAAiB,OAAO;MAC5C;;GAEJ,aAAa,UAAU;IACrB,MAAM,EAAE,iBAAiB,aAAa;AACtC,QAAI,iBAAiB,QAAQ,iBAAiB,MAC5C;IAGF,MAAM,SAAS,MAAM;IACrB,MAAM,OAAO,OAAO,uBAAuB;IAC3C,MAAM,IAAI,MAAM,UAAU,KAAK;IAG/B,MAAM,YAFQ,iBAAiB,OAAO,CAAC,cAAc,QAC7B,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,KACd,WAAW;AAE3D,UAAM,gBAAgB;AACtB,UAAM,iBAAiB;AACvB,UAAM,aAAa,aAAa;IAEhC,MAAM,aAAa,aAAa,QAAQ;AACxC,QAAI,cAAc,eAAe,OAC/B,YAAW,gBAAgB,iBAAiB;AAG9C,WAAO,aAAa,kBAAkB,SAAS;AAC/C,iBAAa,QAAQ,oBAAoB;;GAE3C,cAAc,UAAU;IACtB,MAAM,SAAS,MAAM;IACrB,MAAM,UAAU,MAAM;AACtB,QAAI,WAAW,OAAO,SAAS,QAAQ,CACrC;AAGF,WAAO,gBAAgB,iBAAiB;AACxC,QAAI,aAAa,QAAQ,sBAAsB,OAC7C,cAAa,QAAQ,oBAAoB;;GAG7C,SAAS,UAAU;AACjB,UAAM,gBAAgB;AACtB,UAAM,iBAAiB;IAEvB,MAAM,SAAS,MAAM;IACrB,MAAM,WAAW,OAAO,aAAa,iBAAiB;AACtD,WAAO,gBAAgB,iBAAiB;IAExC,MAAM,EAAE,iBAAiB,aAAa;AACtC,QAAI,iBAAiB,QAAQ,YAAY,iBAAiB,OAAO;KAC/D,MAAM,YAAYA,kBAAAA,SAAS,SAAS,SAAS,cAAc,OAAO,SAAS;AAC3E,SAAI,cAAc,SAAS,QACzB,UAAS,UAAU;;AAIvB,iBAAa,QAAQ,eAAe;AACpC,iBAAa,QAAQ,oBAAoB;;GAE3C,YAAY,UAAU;AACL,UAAM,cACd,gBAAgB,gBAAgB;IAEvC,MAAM,aAAa,aAAa,QAAQ;AACxC,QAAI,WACF,YAAW,gBAAgB,iBAAiB;AAG9C,iBAAa,QAAQ,eAAe;AACpC,iBAAa,QAAQ,oBAAoB;;GAE3C,YAAY,UAAU;AACpB,QAAI,MAAM,QAAQ,eAAe,MAAM,QAAQ,aAC7C;IAGF,MAAM,SAAS,MAAM;IAErB,MAAM,gBADQ,iBAAiB,OAAO,CAAC,cAAc,QACvB,MAAM,QAAQ,cAAc,MAAM,QAAQ;IACxE,MAAM,cAAc,gBAAgB,QAAQ,IAAI,QAAQ;AAExD,QAAI,MAAM,QAAQ;AAChB,SAAI,cAAc,KAAK,eAAe,SAAS,QAAQ,OACrD;AAGF,WAAM,gBAAgB;AACtB,WAAM,iBAAiB;KAEvB,MAAM,WAAgC,gBAAgB,UAAU;KAChE,MAAM,YAAYA,kBAAAA,SAAS,SAAS,SAAS,OAAO,aAAa,SAAS;AAC1E,SAAI,cAAc,SAAS,QACzB;AAGF,qBAAgB,UAAU;MACxB,WAAW,OAAO;MAClB,OAAO;MACP,eAAe;MAChB;AACD,cAAS,UAAU;AACnB;;AAGF,QAAI,cAAc,EAChB;IAGF,MAAM,YAAY,OAAO;AACzB,QAAI,CAAC,UACH;AAGF,UAAM,gBAAgB;AACtB,UAAM,iBAAiB;AAEvB,QAAI,eAAe,SAAS,QAAQ,QAAQ;AAC1C,qBAAgB,UAAU,EAAE,OAAO;AACnC;;AAGF,cAAU,cAA2B,6BAA6B,YAAY,IAAI,EAAE,OAAO;;GAE9F;;AAGH,QAAO;EAAE;EAAc;EAAc;EAAoB"}
@@ -24,7 +24,11 @@ const defaultProps = {
24
24
  size: "sm"
25
25
  };
26
26
  const FileInput = require_factory.genericFactory((_props) => {
27
- const props = require_use_props.useProps("FileInput", defaultProps, _props);
27
+ const props = require_use_props.useProps([
28
+ "Input",
29
+ "InputWrapper",
30
+ "FileInput"
31
+ ], defaultProps, _props);
28
32
  const { unstyled, vars, onChange, value, defaultValue, multiple, accept, name, form, valueComponent: ValueComponent, clearable, clearSectionMode, clearButtonProps, readOnly, capture, fileInputProps, rightSection, size, placeholder, component, resetRef: resetRefProp, classNames, styles, attributes, ...others } = props;
29
33
  const resetRef = (0, react.useRef)(null);
30
34
  const { resolvedClassNames, resolvedStyles } = require_use_resolved_styles_api.useResolvedStylesApi({
@@ -1 +1 @@
1
- {"version":3,"file":"FileInput.cjs","names":["genericFactory","useProps","useResolvedStylesApi","CloseButton","FileButton","InputBase","Input"],"sources":["../../../src/components/FileInput/FileInput.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n Factory,\n genericFactory,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport { CloseButton } from '../CloseButton';\nimport { FileButton } from '../FileButton';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n Input,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase/InputBase';\n\nexport interface FileInputProps<Multiple = false>\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<FileInputFactory>,\n ElementProps<'button', 'value' | 'defaultValue' | 'onChange' | 'placeholder'> {\n component?: any;\n\n /** Called when value changes */\n onChange?: (payload: Multiple extends true ? File[] : File | null) => void;\n\n /** Controlled component value */\n value?: Multiple extends true ? File[] : File | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Multiple extends true ? File[] : File | null;\n\n /** If set, user can pick more than one file @default false */\n multiple?: Multiple;\n\n /** File input accept attribute, for example, `\"image/png,image/jpeg\"` */\n accept?: string;\n\n /** Input name attribute */\n name?: string;\n\n /** Input form attribute */\n form?: string;\n\n /** Value renderer. By default, displays file name. */\n valueComponent?: React.FC<{ value: null | File | File[] }>;\n\n /** If set, the clear button is displayed in the right section @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?: React.ComponentProps<'button'>;\n\n /** If set, the input value cannot be changed */\n readOnly?: boolean;\n\n /** Specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the accept attribute. */\n capture?: boolean | 'user' | 'environment';\n\n /** Props passed down to the hidden `input[type=\"file\"]` */\n fileInputProps?: React.ComponentProps<'input'>;\n\n /** Input placeholder */\n placeholder?: React.ReactNode;\n\n /** Reference of the function that should be called when value changes to null or empty array */\n resetRef?: React.Ref<() => void>;\n}\n\nexport type FileInputFactory = Factory<{\n props: FileInputProps;\n ref: HTMLButtonElement;\n stylesNames: __InputStylesNames | 'placeholder';\n variant: InputVariant;\n signature: <Multiple extends boolean = false>(\n props: FileInputProps<Multiple>\n ) => React.JSX.Element;\n}>;\n\nconst DefaultValue: FileInputProps['valueComponent'] = ({ value }) => (\n <div style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {Array.isArray(value) ? value.map((file) => file.name).join(', ') : value?.name}\n </div>\n);\n\nconst defaultProps = {\n valueComponent: DefaultValue,\n size: 'sm',\n} satisfies Partial<FileInputProps>;\n\nexport const FileInput = genericFactory<FileInputFactory>((_props) => {\n const props = useProps('FileInput', defaultProps, _props);\n const {\n unstyled,\n vars,\n onChange,\n value,\n defaultValue,\n multiple,\n accept,\n name,\n form,\n valueComponent: ValueComponent,\n clearable,\n clearSectionMode,\n clearButtonProps,\n readOnly,\n capture,\n fileInputProps,\n rightSection,\n size,\n placeholder,\n component,\n resetRef: resetRefProp,\n classNames,\n styles,\n attributes,\n ...others\n } = props;\n\n const resetRef = useRef<() => void>(null);\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<FileInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [_value, setValue] = useUncontrolled<null | File | File[]>({\n value,\n defaultValue,\n onChange: onChange as any,\n finalValue: multiple ? [] : null,\n });\n\n const hasValue = Array.isArray(_value) ? _value.length !== 0 : _value !== null;\n\n const clearButton = (\n <CloseButton\n {...clearButtonProps}\n variant=\"subtle\"\n onClick={() => setValue(multiple ? [] : null)}\n size={size}\n unstyled={unstyled}\n />\n );\n\n const _clearable = clearable && hasValue && !readOnly;\n\n useEffect(() => {\n if ((Array.isArray(_value) && _value.length === 0) || _value === null) {\n resetRef.current?.();\n }\n }, [_value]);\n\n return (\n <FileButton\n onChange={setValue}\n multiple={multiple}\n accept={accept}\n name={name}\n form={form}\n resetRef={useMergedRef(resetRef, resetRefProp)}\n disabled={readOnly}\n capture={capture}\n inputProps={fileInputProps}\n >\n {(fileButtonProps) => (\n <InputBase\n component={component || 'button'}\n rightSection={rightSection}\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n {...fileButtonProps}\n {...others}\n __staticSelector=\"FileInput\"\n multiline\n type=\"button\"\n pointer\n __stylesApiProps={props}\n unstyled={unstyled}\n size={size}\n classNames={classNames}\n styles={styles}\n attributes={attributes}\n >\n {!hasValue ? (\n <Input.Placeholder\n __staticSelector=\"FileInput\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n attributes={attributes}\n >\n {placeholder}\n </Input.Placeholder>\n ) : (\n <ValueComponent value={_value} />\n )}\n </InputBase>\n )}\n </FileButton>\n );\n});\n\nFileInput.classes = InputBase.classes;\nFileInput.displayName = '@mantine/core/FileInput';\n\nexport namespace FileInput {\n export type Props<Multiple extends boolean = false> = FileInputProps<Multiple>;\n export type Factory = FileInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AAyFA,MAAM,gBAAkD,EAAE,YACxD,iBAAA,GAAA,kBAAA,KAAC,OAAD;CAAK,OAAO;EAAE,UAAU;EAAU,cAAc;EAAY,YAAY;EAAU;WAC/E,MAAM,QAAQ,MAAM,GAAG,MAAM,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,KAAK,GAAG,OAAO;CACvE,CAAA;AAGR,MAAM,eAAe;CACnB,gBAAgB;CAChB,MAAM;CACP;AAED,MAAa,YAAYA,gBAAAA,gBAAkC,WAAW;CACpE,MAAM,QAAQC,kBAAAA,SAAS,aAAa,cAAc,OAAO;CACzD,MAAM,EACJ,UACA,MACA,UACA,OACA,cACA,UACA,QACA,MACA,MACA,gBAAgB,gBAChB,WACA,kBACA,kBACA,UACA,SACA,gBACA,cACA,MACA,aACA,WACA,UAAU,cACV,YACA,QACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAA,GAAA,MAAA,QAA8B,KAAK;CACzC,MAAM,EAAE,oBAAoB,mBAAmBC,gCAAAA,qBAAuC;EACpF;EACA;EACA;EACD,CAAC;CAEF,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAAkD;EAC/D;EACA;EACU;EACV,YAAY,WAAW,EAAE,GAAG;EAC7B,CAAC;CAEF,MAAM,WAAW,MAAM,QAAQ,OAAO,GAAG,OAAO,WAAW,IAAI,WAAW;CAE1E,MAAM,cACJ,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,aAAD;EACE,GAAI;EACJ,SAAQ;EACR,eAAe,SAAS,WAAW,EAAE,GAAG,KAAK;EACvC;EACI;EACV,CAAA;CAGJ,MAAM,aAAa,aAAa,YAAY,CAAC;AAE7C,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAK,MAAM,QAAQ,OAAO,IAAI,OAAO,WAAW,KAAM,WAAW,KAC/D,UAAS,WAAW;IAErB,CAAC,OAAO,CAAC;AAEZ,QACE,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,YAAD;EACE,UAAU;EACA;EACF;EACF;EACA;EACN,WAAA,GAAA,eAAA,cAAuB,UAAU,aAAa;EAC9C,UAAU;EACD;EACT,YAAY;aAEV,oBACA,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;GACE,WAAW,aAAa;GACV;GACd,gBAAgB;GAChB,aAAa;GACb,oBAAoB;GACpB,GAAI;GACJ,GAAI;GACJ,kBAAiB;GACjB,WAAA;GACA,MAAK;GACL,SAAA;GACA,kBAAkB;GACR;GACJ;GACM;GACJ;GACI;aAEX,CAAC,WACA,iBAAA,GAAA,kBAAA,KAACC,cAAAA,MAAM,aAAP;IACE,kBAAiB;IACjB,YAAY;IACZ,QAAQ;IACI;cAEX;IACiB,CAAA,GAEpB,iBAAA,GAAA,kBAAA,KAAC,gBAAD,EAAgB,OAAO,QAAU,CAAA;GAEzB,CAAA;EAEH,CAAA;EAEf;AAEF,UAAU,UAAUD,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
1
+ {"version":3,"file":"FileInput.cjs","names":["genericFactory","useProps","useResolvedStylesApi","CloseButton","FileButton","InputBase","Input"],"sources":["../../../src/components/FileInput/FileInput.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n Factory,\n genericFactory,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport { CloseButton } from '../CloseButton';\nimport { FileButton } from '../FileButton';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n Input,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase/InputBase';\n\nexport interface FileInputProps<Multiple = false>\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<FileInputFactory>,\n ElementProps<'button', 'value' | 'defaultValue' | 'onChange' | 'placeholder'> {\n component?: any;\n\n /** Called when value changes */\n onChange?: (payload: Multiple extends true ? File[] : File | null) => void;\n\n /** Controlled component value */\n value?: Multiple extends true ? File[] : File | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Multiple extends true ? File[] : File | null;\n\n /** If set, user can pick more than one file @default false */\n multiple?: Multiple;\n\n /** File input accept attribute, for example, `\"image/png,image/jpeg\"` */\n accept?: string;\n\n /** Input name attribute */\n name?: string;\n\n /** Input form attribute */\n form?: string;\n\n /** Value renderer. By default, displays file name. */\n valueComponent?: React.FC<{ value: null | File | File[] }>;\n\n /** If set, the clear button is displayed in the right section @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?: React.ComponentProps<'button'>;\n\n /** If set, the input value cannot be changed */\n readOnly?: boolean;\n\n /** Specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the accept attribute. */\n capture?: boolean | 'user' | 'environment';\n\n /** Props passed down to the hidden `input[type=\"file\"]` */\n fileInputProps?: React.ComponentProps<'input'>;\n\n /** Input placeholder */\n placeholder?: React.ReactNode;\n\n /** Reference of the function that should be called when value changes to null or empty array */\n resetRef?: React.Ref<() => void>;\n}\n\nexport type FileInputFactory = Factory<{\n props: FileInputProps;\n ref: HTMLButtonElement;\n stylesNames: __InputStylesNames | 'placeholder';\n variant: InputVariant;\n signature: <Multiple extends boolean = false>(\n props: FileInputProps<Multiple>\n ) => React.JSX.Element;\n}>;\n\nconst DefaultValue: FileInputProps['valueComponent'] = ({ value }) => (\n <div style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {Array.isArray(value) ? value.map((file) => file.name).join(', ') : value?.name}\n </div>\n);\n\nconst defaultProps = {\n valueComponent: DefaultValue,\n size: 'sm',\n} satisfies Partial<FileInputProps>;\n\nexport const FileInput = genericFactory<FileInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'FileInput'], defaultProps, _props);\n const {\n unstyled,\n vars,\n onChange,\n value,\n defaultValue,\n multiple,\n accept,\n name,\n form,\n valueComponent: ValueComponent,\n clearable,\n clearSectionMode,\n clearButtonProps,\n readOnly,\n capture,\n fileInputProps,\n rightSection,\n size,\n placeholder,\n component,\n resetRef: resetRefProp,\n classNames,\n styles,\n attributes,\n ...others\n } = props;\n\n const resetRef = useRef<() => void>(null);\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<FileInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [_value, setValue] = useUncontrolled<null | File | File[]>({\n value,\n defaultValue,\n onChange: onChange as any,\n finalValue: multiple ? [] : null,\n });\n\n const hasValue = Array.isArray(_value) ? _value.length !== 0 : _value !== null;\n\n const clearButton = (\n <CloseButton\n {...clearButtonProps}\n variant=\"subtle\"\n onClick={() => setValue(multiple ? [] : null)}\n size={size}\n unstyled={unstyled}\n />\n );\n\n const _clearable = clearable && hasValue && !readOnly;\n\n useEffect(() => {\n if ((Array.isArray(_value) && _value.length === 0) || _value === null) {\n resetRef.current?.();\n }\n }, [_value]);\n\n return (\n <FileButton\n onChange={setValue}\n multiple={multiple}\n accept={accept}\n name={name}\n form={form}\n resetRef={useMergedRef(resetRef, resetRefProp)}\n disabled={readOnly}\n capture={capture}\n inputProps={fileInputProps}\n >\n {(fileButtonProps) => (\n <InputBase\n component={component || 'button'}\n rightSection={rightSection}\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n {...fileButtonProps}\n {...others}\n __staticSelector=\"FileInput\"\n multiline\n type=\"button\"\n pointer\n __stylesApiProps={props}\n unstyled={unstyled}\n size={size}\n classNames={classNames}\n styles={styles}\n attributes={attributes}\n >\n {!hasValue ? (\n <Input.Placeholder\n __staticSelector=\"FileInput\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n attributes={attributes}\n >\n {placeholder}\n </Input.Placeholder>\n ) : (\n <ValueComponent value={_value} />\n )}\n </InputBase>\n )}\n </FileButton>\n );\n});\n\nFileInput.classes = InputBase.classes;\nFileInput.displayName = '@mantine/core/FileInput';\n\nexport namespace FileInput {\n export type Props<Multiple extends boolean = false> = FileInputProps<Multiple>;\n export type Factory = FileInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AAyFA,MAAM,gBAAkD,EAAE,YACxD,iBAAA,GAAA,kBAAA,KAAC,OAAD;CAAK,OAAO;EAAE,UAAU;EAAU,cAAc;EAAY,YAAY;EAAU;WAC/E,MAAM,QAAQ,MAAM,GAAG,MAAM,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,KAAK,GAAG,OAAO;CACvE,CAAA;AAGR,MAAM,eAAe;CACnB,gBAAgB;CAChB,MAAM;CACP;AAED,MAAa,YAAYA,gBAAAA,gBAAkC,WAAW;CACpE,MAAM,QAAQC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;EAAY,EAAE,cAAc,OAAO;CACpF,MAAM,EACJ,UACA,MACA,UACA,OACA,cACA,UACA,QACA,MACA,MACA,gBAAgB,gBAChB,WACA,kBACA,kBACA,UACA,SACA,gBACA,cACA,MACA,aACA,WACA,UAAU,cACV,YACA,QACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAA,GAAA,MAAA,QAA8B,KAAK;CACzC,MAAM,EAAE,oBAAoB,mBAAmBC,gCAAAA,qBAAuC;EACpF;EACA;EACA;EACD,CAAC;CAEF,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAAkD;EAC/D;EACA;EACU;EACV,YAAY,WAAW,EAAE,GAAG;EAC7B,CAAC;CAEF,MAAM,WAAW,MAAM,QAAQ,OAAO,GAAG,OAAO,WAAW,IAAI,WAAW;CAE1E,MAAM,cACJ,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,aAAD;EACE,GAAI;EACJ,SAAQ;EACR,eAAe,SAAS,WAAW,EAAE,GAAG,KAAK;EACvC;EACI;EACV,CAAA;CAGJ,MAAM,aAAa,aAAa,YAAY,CAAC;AAE7C,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAK,MAAM,QAAQ,OAAO,IAAI,OAAO,WAAW,KAAM,WAAW,KAC/D,UAAS,WAAW;IAErB,CAAC,OAAO,CAAC;AAEZ,QACE,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,YAAD;EACE,UAAU;EACA;EACF;EACF;EACA;EACN,WAAA,GAAA,eAAA,cAAuB,UAAU,aAAa;EAC9C,UAAU;EACD;EACT,YAAY;aAEV,oBACA,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;GACE,WAAW,aAAa;GACV;GACd,gBAAgB;GAChB,aAAa;GACb,oBAAoB;GACpB,GAAI;GACJ,GAAI;GACJ,kBAAiB;GACjB,WAAA;GACA,MAAK;GACL,SAAA;GACA,kBAAkB;GACR;GACJ;GACM;GACJ;GACI;aAEX,CAAC,WACA,iBAAA,GAAA,kBAAA,KAACC,cAAAA,MAAM,aAAP;IACE,kBAAiB;IACjB,YAAY;IACZ,QAAQ;IACI;cAEX;IACiB,CAAA,GAEpB,iBAAA,GAAA,kBAAA,KAAC,gBAAD,EAAgB,OAAO,QAAU,CAAA;GAEzB,CAAA;EAEH,CAAA;EAEf;AAEF,UAAU,UAAUD,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
@@ -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(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
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 ? `\\b(${matcher})\\b` : `(${matcher})`;
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.cjs","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 ? `\\\\b(${matcher})\\\\b` : `(${matcher})`;\n const re = new RegExp(pattern, '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,0BAA0B,OAAO;;AAaxD,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,YAAY,OAAO,QAAQ,QAAQ,IAAI,QAAQ;CACvE,MAAM,KAAK,IAAI,OAAO,SAAS,KAAK;AAMpC,QALe,MACZ,MAAM,GAAG,CACT,KAAK,MAAM,WAAW;EAAE,OAAO;EAAM,aAAa,QAAQ,MAAM;EAAG,EAAE,CACrE,QAAQ,EAAE,YAAY,MAAM"}
1
+ {"version":3,"file":"highlighter.cjs","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 @@ const require_use_props = require("../../core/MantineProvider/use-props/use-prop
3
3
  const require_extract_style_props = require("../../core/Box/style-props/extract-style-props/extract-style-props.cjs");
4
4
  //#region packages/@mantine/core/src/components/Input/use-input-props.ts
5
5
  function useInputProps(component, defaultProps, _props) {
6
- const props = require_use_props.useProps(component, defaultProps, _props);
6
+ const props = require_use_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 } = require_extract_style_props.extractStyleProps(others);
9
13
  const wrapperProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"use-input-props.cjs","names":["useProps","extractStyleProps"],"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,QAAQA,kBAAAA,SAAe,WAAW,cAAc,OAAO;CAC7D,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,SAASC,4BAAAA,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"}
1
+ {"version":3,"file":"use-input-props.cjs","names":["useProps","extractStyleProps"],"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,QAAQA,kBAAAA,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,SAASC,4BAAAA,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"}
@@ -12,11 +12,14 @@ let react_jsx_runtime = require("react/jsx-runtime");
12
12
  const defaultProps = {
13
13
  serialize: JSON.stringify,
14
14
  deserialize: JSON.parse,
15
- size: "sm",
16
15
  indentSpaces: 2
17
16
  };
18
17
  const JsonInput = require_factory.factory((props) => {
19
- const { value, defaultValue, onChange, formatOnBlur, validationError, serialize, deserialize, onFocus, onBlur, readOnly, error, indentSpaces, ...others } = require_use_props.useProps("JsonInput", defaultProps, props);
18
+ const { value, defaultValue, onChange, formatOnBlur, validationError, serialize, deserialize, onFocus, onBlur, readOnly, error, indentSpaces, ...others } = require_use_props.useProps([
19
+ "Input",
20
+ "InputWrapper",
21
+ "JsonInput"
22
+ ], defaultProps, props);
20
23
  const [_value, setValue] = (0, _mantine_hooks.useUncontrolled)({
21
24
  value,
22
25
  defaultValue,
@@ -1 +1 @@
1
- {"version":3,"file":"JsonInput.cjs","names":["factory","useProps","validateJson","Textarea","InputBase"],"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 size: 'sm',\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('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,MAAM;CACN,cAAc;CACf;AAED,MAAa,YAAYA,gBAAAA,SAA2B,UAAU;CAC5D,MAAM,EACJ,OACA,cACA,UACA,cACA,iBACA,WACA,aACA,SACA,QACA,UACA,OACA,cACA,GAAG,WACDC,kBAAAA,SAAS,aAAa,cAAc,MAAM;CAE9C,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAA4B;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqBC,sBAAAA,aAAa,QAAQ,YAAY,CAAC;CAErE,MAAM,eAAe,UAAiD;AACpE,YAAU,MAAM;AAChB,WAAS,KAAK;;CAGhB,MAAM,cAAc,UAAiD;AACnE,WAAS,MAAM;EACf,MAAM,UAAUA,sBAAAA,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,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,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,UAAUC,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
1
+ {"version":3,"file":"JsonInput.cjs","names":["factory","useProps","validateJson","Textarea","InputBase"],"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,YAAYA,gBAAAA,SAA2B,UAAU;CAC5D,MAAM,EACJ,OACA,cACA,UACA,cACA,iBACA,WACA,aACA,SACA,QACA,UACA,OACA,cACA,GAAG,WACDC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;EAAY,EAAE,cAAc,MAAM;CAEzE,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAA4B;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqBC,sBAAAA,aAAa,QAAQ,YAAY,CAAC;CAErE,MAAM,eAAe,UAAiD;AACpE,YAAU,MAAM;AAChB,WAAS,KAAK;;CAGhB,MAAM,cAAc,UAAiD;AACnE,WAAS,MAAM;EACf,MAAM,UAAUA,sBAAAA,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,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,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,UAAUC,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
@@ -8,7 +8,11 @@ let react_jsx_runtime = require("react/jsx-runtime");
8
8
  //#region packages/@mantine/core/src/components/MaskInput/MaskInput.tsx
9
9
  const defaultProps = {};
10
10
  const MaskInput = require_factory.factory((props) => {
11
- const { maskRef, elementProps } = require_use_mask_input_props.useMaskInputProps(require_use_props.useProps("MaskInput", defaultProps, props));
11
+ const { maskRef, elementProps } = require_use_mask_input_props.useMaskInputProps(require_use_props.useProps([
12
+ "Input",
13
+ "InputWrapper",
14
+ "MaskInput"
15
+ ], defaultProps, props));
12
16
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InputBase.InputBase, {
13
17
  component: "input",
14
18
  ref: maskRef,
@@ -1 +1 @@
1
- {"version":3,"file":"MaskInput.cjs","names":["factory","useMaskInputProps","useProps","InputBase"],"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":";;;;;;;;AA6DA,MAAM,eAAe,EAAE;AAEvB,MAAa,YAAYA,gBAAAA,SAA2B,UAAU;CAE5D,MAAM,EAAE,SAAS,iBAAiBC,6BAAAA,kBADnBC,kBAAAA,SAAS,aAAa,cAAc,MAAM,CACE;AAE3D,QACE,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;EACE,WAAU;EACV,KAAK;EACL,GAAK;EACL,kBAAiB;EACjB,CAAA;EAEJ;AAEF,UAAU,UAAUA,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
1
+ {"version":3,"file":"MaskInput.cjs","names":["factory","useMaskInputProps","useProps","InputBase"],"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,YAAYA,gBAAAA,SAA2B,UAAU;CAE5D,MAAM,EAAE,SAAS,iBAAiBC,6BAAAA,kBADnBC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;EAAY,EAAE,cAAc,MAAM,CACzB;AAE3D,QACE,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;EACE,WAAU;EACV,KAAK;EACL,GAAK;EACL,kBAAiB;EACjB,CAAA;EAEJ;AAEF,UAAU,UAAUA,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
@@ -3,8 +3,8 @@ require("../../_virtual/_rolldown/runtime.cjs");
3
3
  let _mantine_hooks = require("@mantine/hooks");
4
4
  //#region packages/@mantine/core/src/components/MaskInput/use-mask-input-props.ts
5
5
  function useMaskInputProps(props) {
6
- const { mask, tokens, modify, separate, slotChar, alwaysShowMask, showMaskOnFocus, transform, autoClear, onChangeRaw, onComplete, beforeMaskedStateChange, ref, ...elementProps } = props;
7
- const { ref: maskCallbackRef } = (0, _mantine_hooks.useMask)({
6
+ const { mask, tokens, modify, separate, slotChar, alwaysShowMask, showMaskOnFocus, transform, autoClear, onChangeRaw, onComplete, beforeMaskedStateChange, resetRef, ref, ...elementProps } = props;
7
+ const { ref: maskCallbackRef, reset } = (0, _mantine_hooks.useMask)({
8
8
  mask,
9
9
  tokens,
10
10
  modify,
@@ -18,6 +18,7 @@ function useMaskInputProps(props) {
18
18
  onComplete,
19
19
  beforeMaskedStateChange
20
20
  });
21
+ (0, _mantine_hooks.assignRef)(resetRef, reset);
21
22
  return {
22
23
  maskRef: (0, _mantine_hooks.useMergedRef)(ref, maskCallbackRef),
23
24
  elementProps
@@ -1 +1 @@
1
- {"version":3,"file":"use-mask-input-props.cjs","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,qBAAA,GAAA,eAAA,SAA4B;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAIF,QAAO;EAAE,UAAA,GAAA,eAAA,cAFoB,KAAK,gBAAgB;EAEhC;EAAc"}
1
+ {"version":3,"file":"use-mask-input-props.cjs","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,WAAA,GAAA,eAAA,SAAkB;EAC9C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,EAAA,GAAA,eAAA,WAAU,UAAU,MAAM;AAI1B,QAAO;EAAE,UAAA,GAAA,eAAA,cAFoB,KAAK,gBAAgB;EAEhC;EAAc"}
@@ -11,6 +11,7 @@ const require_get_options_lockup = require("../Combobox/get-options-lockup/get-o
11
11
  const require_use_combobox = require("../Combobox/use-combobox/use-combobox.cjs");
12
12
  const require_Combobox = require("../Combobox/Combobox.cjs");
13
13
  const require_OptionsDropdown = require("../Combobox/OptionsDropdown/OptionsDropdown.cjs");
14
+ const require_use_pills_reorder = require("../Combobox/use-pills-reorder/use-pills-reorder.cjs");
14
15
  const require_Pill = require("../Pill/Pill.cjs");
15
16
  const require_PillsInput = require("../PillsInput/PillsInput.cjs");
16
17
  const require_filter_picked_values = require("./filter-picked-values.cjs");
@@ -35,8 +36,12 @@ const defaultProps = {
35
36
  size: "sm"
36
37
  };
37
38
  const MultiSelect = require_factory.genericFactory((_props) => {
38
- const props = require_use_props.useProps("MultiSelect", defaultProps, _props);
39
- 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, ...others } = props;
39
+ const props = require_use_props.useProps([
40
+ "Input",
41
+ "InputWrapper",
42
+ "MultiSelect"
43
+ ], defaultProps, _props);
44
+ 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;
40
45
  const _id = (0, _mantine_hooks.useId)(id);
41
46
  const parsedData = require_get_parsed_combobox_data.getParsedComboboxData(data);
42
47
  const optionsLockup = require_get_options_lockup.getOptionsLockup(parsedData);
@@ -60,6 +65,11 @@ const MultiSelect = require_factory.genericFactory((_props) => {
60
65
  finalValue: [],
61
66
  onChange
62
67
  });
68
+ const { getPillProps, getListProps, handleInputKeyDown } = require_use_pills_reorder.usePillsReorder({
69
+ value: _value,
70
+ onChange: setValue,
71
+ enabled: withPillsReorder && !disabled && !readOnly
72
+ });
63
73
  const [_searchValue, setSearchValue] = (0, _mantine_hooks.useUncontrolled)({
64
74
  value: searchValue,
65
75
  defaultValue: defaultSearchValue,
@@ -86,6 +96,7 @@ const MultiSelect = require_factory.genericFactory((_props) => {
86
96
  });
87
97
  const handleInputKeydown = (event) => {
88
98
  onKeyDown?.(event);
99
+ if (event.defaultPrevented) return;
89
100
  if (event.key === " " && !searchable) {
90
101
  event.preventDefault();
91
102
  combobox.toggleDropdown();
@@ -94,9 +105,11 @@ const MultiSelect = require_factory.genericFactory((_props) => {
94
105
  onRemove?.(_value[_value.length - 1]);
95
106
  setValue(_value.slice(0, _value.length - 1));
96
107
  }
108
+ handleInputKeyDown(event);
97
109
  };
98
110
  const values = _value.map((item, index) => {
99
111
  const optionData = optionsLockup[`${item}`] || retainedSelectedOptions.current[`${item}`];
112
+ const reorderProps = getPillProps(index);
100
113
  if (renderPill) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderPill({
101
114
  option: optionData,
102
115
  value: item,
@@ -104,7 +117,8 @@ const MultiSelect = require_factory.genericFactory((_props) => {
104
117
  setValue(_value.filter((i) => item !== i));
105
118
  onRemove?.(item);
106
119
  },
107
- disabled
120
+ disabled,
121
+ reorderProps
108
122
  }) }, `${item}-${index}`);
109
123
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill.Pill, {
110
124
  withRemoveButton: !readOnly && !optionsLockup[`${item}`]?.disabled,
@@ -115,6 +129,7 @@ const MultiSelect = require_factory.genericFactory((_props) => {
115
129
  unstyled,
116
130
  disabled,
117
131
  ...getStyles("pill"),
132
+ ...reorderProps,
118
133
  children: optionData?.label || item
119
134
  }, `${item}-${index}`);
120
135
  });
@@ -219,6 +234,7 @@ const MultiSelect = require_factory.genericFactory((_props) => {
219
234
  disabled,
220
235
  unstyled,
221
236
  ...getStyles("pillsList", { style: pillsListStyle }),
237
+ ...getListProps(),
222
238
  children: [values, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Combobox.Combobox.EventsTarget, {
223
239
  autoComplete,
224
240
  withExpandedAttribute: true,