@mantine/core 9.0.0 → 9.0.2

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 (474) hide show
  1. package/cjs/components/Accordion/Accordion.cjs.map +1 -1
  2. package/cjs/components/Accordion/Accordion.module.cjs.map +1 -1
  3. package/cjs/components/ActionIcon/ActionIcon.cjs.map +1 -1
  4. package/cjs/components/Affix/Affix.cjs.map +1 -1
  5. package/cjs/components/Alert/Alert.cjs.map +1 -1
  6. package/cjs/components/Anchor/Anchor.cjs.map +1 -1
  7. package/cjs/components/AngleSlider/AngleSlider.cjs.map +1 -1
  8. package/cjs/components/AppShell/AppShell.cjs.map +1 -1
  9. package/cjs/components/AspectRatio/AspectRatio.cjs.map +1 -1
  10. package/cjs/components/Autocomplete/Autocomplete.cjs +1 -1
  11. package/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
  12. package/cjs/components/Avatar/Avatar.cjs.map +1 -1
  13. package/cjs/components/BackgroundImage/BackgroundImage.cjs.map +1 -1
  14. package/cjs/components/Badge/Badge.cjs.map +1 -1
  15. package/cjs/components/Badge/Badge.module.cjs.map +1 -1
  16. package/cjs/components/Blockquote/Blockquote.cjs.map +1 -1
  17. package/cjs/components/Breadcrumbs/Breadcrumbs.cjs.map +1 -1
  18. package/cjs/components/Burger/Burger.cjs.map +1 -1
  19. package/cjs/components/Button/Button.cjs.map +1 -1
  20. package/cjs/components/Card/Card.cjs.map +1 -1
  21. package/cjs/components/Center/Center.cjs.map +1 -1
  22. package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
  23. package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.cjs.map +1 -1
  24. package/cjs/components/Chip/Chip.cjs.map +1 -1
  25. package/cjs/components/Chip/ChipGroup/ChipGroup.cjs.map +1 -1
  26. package/cjs/components/CloseButton/CloseButton.cjs.map +1 -1
  27. package/cjs/components/Code/Code.cjs.map +1 -1
  28. package/cjs/components/Collapse/Collapse.cjs.map +1 -1
  29. package/cjs/components/ColorInput/ColorInput.cjs.map +1 -1
  30. package/cjs/components/ColorPicker/AlphaSlider/AlphaSlider.cjs.map +1 -1
  31. package/cjs/components/ColorPicker/ColorPicker.cjs.map +1 -1
  32. package/cjs/components/ColorPicker/HueSlider/HueSlider.cjs.map +1 -1
  33. package/cjs/components/ColorSwatch/ColorSwatch.cjs.map +1 -1
  34. package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.cjs +1 -0
  35. package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.cjs.map +1 -1
  36. package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.cjs.map +1 -1
  37. package/cjs/components/Container/Container.cjs.map +1 -1
  38. package/cjs/components/Dialog/Dialog.cjs.map +1 -1
  39. package/cjs/components/Divider/Divider.cjs.map +1 -1
  40. package/cjs/components/Fieldset/Fieldset.cjs.map +1 -1
  41. package/cjs/components/FileButton/FileButton.cjs.map +1 -1
  42. package/cjs/components/FileInput/FileInput.cjs.map +1 -1
  43. package/cjs/components/Flex/Flex.cjs.map +1 -1
  44. package/cjs/components/FloatingIndicator/FloatingIndicator.cjs.map +1 -1
  45. package/cjs/components/FloatingWindow/FloatingWindow.cjs.map +1 -1
  46. package/cjs/components/Grid/Grid.cjs.map +1 -1
  47. package/cjs/components/Group/Group.cjs.map +1 -1
  48. package/cjs/components/Highlight/Highlight.cjs.map +1 -1
  49. package/cjs/components/Image/Image.cjs.map +1 -1
  50. package/cjs/components/Indicator/Indicator.cjs.map +1 -1
  51. package/cjs/components/Input/Input.cjs +3 -2
  52. package/cjs/components/Input/Input.cjs.map +1 -1
  53. package/cjs/components/InputBase/InputBase.cjs.map +1 -1
  54. package/cjs/components/JsonInput/JsonInput.cjs.map +1 -1
  55. package/cjs/components/Kbd/Kbd.cjs.map +1 -1
  56. package/cjs/components/List/List.cjs.map +1 -1
  57. package/cjs/components/Loader/Loader.cjs.map +1 -1
  58. package/cjs/components/LoadingOverlay/LoadingOverlay.cjs +1 -0
  59. package/cjs/components/LoadingOverlay/LoadingOverlay.cjs.map +1 -1
  60. package/cjs/components/Mark/Mark.cjs.map +1 -1
  61. package/cjs/components/Marquee/Marquee.cjs.map +1 -1
  62. package/cjs/components/Menu/Menu.cjs.map +1 -1
  63. package/cjs/components/Modal/Modal.cjs.map +1 -1
  64. package/cjs/components/MultiSelect/MultiSelect.cjs +3 -1
  65. package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
  66. package/cjs/components/NativeSelect/NativeSelect.cjs +4 -1
  67. package/cjs/components/NativeSelect/NativeSelect.cjs.map +1 -1
  68. package/cjs/components/NavLink/NavLink.cjs.map +1 -1
  69. package/cjs/components/Notification/Notification.cjs.map +1 -1
  70. package/cjs/components/NumberInput/NumberInput.cjs +1 -0
  71. package/cjs/components/NumberInput/NumberInput.cjs.map +1 -1
  72. package/cjs/components/OverflowList/OverflowList.cjs.map +1 -1
  73. package/cjs/components/Overlay/Overlay.cjs.map +1 -1
  74. package/cjs/components/Pagination/Pagination.cjs.map +1 -1
  75. package/cjs/components/Paper/Paper.cjs.map +1 -1
  76. package/cjs/components/PasswordInput/PasswordInput.cjs +4 -1
  77. package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
  78. package/cjs/components/Pill/Pill.cjs.map +1 -1
  79. package/cjs/components/PillsInput/PillsInput.cjs.map +1 -1
  80. package/cjs/components/PinInput/PinInput.cjs.map +1 -1
  81. package/cjs/components/Popover/Popover.cjs +9 -0
  82. package/cjs/components/Popover/Popover.cjs.map +1 -1
  83. package/cjs/components/Portal/OptionalPortal.cjs.map +1 -1
  84. package/cjs/components/Portal/Portal.cjs.map +1 -1
  85. package/cjs/components/Progress/Progress.cjs.map +1 -1
  86. package/cjs/components/Radio/Radio.cjs.map +1 -1
  87. package/cjs/components/Radio/RadioGroup/RadioGroup.cjs.map +1 -1
  88. package/cjs/components/Rating/Rating.cjs.map +1 -1
  89. package/cjs/components/RingProgress/RingProgress.cjs +1 -0
  90. package/cjs/components/RingProgress/RingProgress.cjs.map +1 -1
  91. package/cjs/components/ScrollArea/ScrollArea.cjs.map +1 -1
  92. package/cjs/components/ScrollArea/ScrollAreaScrollbar/Scrollbar.cjs.map +1 -1
  93. package/cjs/components/Scroller/Scroller.cjs.map +1 -1
  94. package/cjs/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
  95. package/cjs/components/Select/Select.cjs +1 -0
  96. package/cjs/components/Select/Select.cjs.map +1 -1
  97. package/cjs/components/SemiCircleProgress/SemiCircleProgress.cjs +1 -2
  98. package/cjs/components/SemiCircleProgress/SemiCircleProgress.cjs.map +1 -1
  99. package/cjs/components/SimpleGrid/SimpleGrid.cjs.map +1 -1
  100. package/cjs/components/Skeleton/Skeleton.cjs.map +1 -1
  101. package/cjs/components/Slider/RangeSlider/RangeSlider.cjs.map +1 -1
  102. package/cjs/components/Slider/Slider/Slider.cjs.map +1 -1
  103. package/cjs/components/Slider/Slider.module.cjs.map +1 -1
  104. package/cjs/components/Space/Space.cjs.map +1 -1
  105. package/cjs/components/Spoiler/Spoiler.cjs.map +1 -1
  106. package/cjs/components/Stack/Stack.cjs.map +1 -1
  107. package/cjs/components/Stepper/Stepper.cjs.map +1 -1
  108. package/cjs/components/Switch/Switch.cjs.map +1 -1
  109. package/cjs/components/Switch/SwitchGroup/SwitchGroup.cjs.map +1 -1
  110. package/cjs/components/Table/Table.cjs.map +1 -1
  111. package/cjs/components/TableOfContents/TableOfContents.cjs.map +1 -1
  112. package/cjs/components/Tabs/Tabs.cjs.map +1 -1
  113. package/cjs/components/TagsInput/TagsInput.cjs +3 -1
  114. package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
  115. package/cjs/components/Text/Text.cjs.map +1 -1
  116. package/cjs/components/TextInput/TextInput.cjs.map +1 -1
  117. package/cjs/components/Textarea/Autosize.cjs +1 -0
  118. package/cjs/components/Textarea/Autosize.cjs.map +1 -1
  119. package/cjs/components/Textarea/Textarea.cjs.map +1 -1
  120. package/cjs/components/ThemeIcon/ThemeIcon.cjs.map +1 -1
  121. package/cjs/components/Timeline/Timeline.cjs.map +1 -1
  122. package/cjs/components/Title/Title.cjs.map +1 -1
  123. package/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
  124. package/cjs/components/Tree/Tree.cjs.map +1 -1
  125. package/cjs/components/Typography/Typography.cjs.map +1 -1
  126. package/cjs/components/UnstyledButton/UnstyledButton.cjs.map +1 -1
  127. package/cjs/components/VisuallyHidden/VisuallyHidden.cjs.map +1 -1
  128. package/cjs/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.cjs +3 -4
  129. package/cjs/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.cjs.map +1 -1
  130. package/cjs/core/MantineProvider/color-scheme-managers/local-storage-manager.cjs.map +1 -1
  131. package/cjs/core/utils/find-element-ancestor/find-element-ancestor.cjs.map +1 -1
  132. package/esm/components/Accordion/Accordion.mjs.map +1 -1
  133. package/esm/components/Accordion/Accordion.module.mjs.map +1 -1
  134. package/esm/components/ActionIcon/ActionIcon.mjs.map +1 -1
  135. package/esm/components/Affix/Affix.mjs.map +1 -1
  136. package/esm/components/Alert/Alert.mjs.map +1 -1
  137. package/esm/components/Anchor/Anchor.mjs.map +1 -1
  138. package/esm/components/AngleSlider/AngleSlider.mjs.map +1 -1
  139. package/esm/components/AppShell/AppShell.mjs.map +1 -1
  140. package/esm/components/AspectRatio/AspectRatio.mjs.map +1 -1
  141. package/esm/components/Autocomplete/Autocomplete.mjs +1 -1
  142. package/esm/components/Autocomplete/Autocomplete.mjs.map +1 -1
  143. package/esm/components/Avatar/Avatar.mjs.map +1 -1
  144. package/esm/components/BackgroundImage/BackgroundImage.mjs.map +1 -1
  145. package/esm/components/Badge/Badge.mjs.map +1 -1
  146. package/esm/components/Badge/Badge.module.mjs.map +1 -1
  147. package/esm/components/Blockquote/Blockquote.mjs.map +1 -1
  148. package/esm/components/Breadcrumbs/Breadcrumbs.mjs.map +1 -1
  149. package/esm/components/Burger/Burger.mjs.map +1 -1
  150. package/esm/components/Button/Button.mjs.map +1 -1
  151. package/esm/components/Card/Card.mjs.map +1 -1
  152. package/esm/components/Center/Center.mjs.map +1 -1
  153. package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
  154. package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.mjs.map +1 -1
  155. package/esm/components/Chip/Chip.mjs.map +1 -1
  156. package/esm/components/Chip/ChipGroup/ChipGroup.mjs.map +1 -1
  157. package/esm/components/CloseButton/CloseButton.mjs.map +1 -1
  158. package/esm/components/Code/Code.mjs.map +1 -1
  159. package/esm/components/Collapse/Collapse.mjs.map +1 -1
  160. package/esm/components/ColorInput/ColorInput.mjs.map +1 -1
  161. package/esm/components/ColorPicker/AlphaSlider/AlphaSlider.mjs.map +1 -1
  162. package/esm/components/ColorPicker/ColorPicker.mjs.map +1 -1
  163. package/esm/components/ColorPicker/HueSlider/HueSlider.mjs.map +1 -1
  164. package/esm/components/ColorSwatch/ColorSwatch.mjs.map +1 -1
  165. package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.mjs +1 -0
  166. package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.mjs.map +1 -1
  167. package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.mjs.map +1 -1
  168. package/esm/components/Container/Container.mjs.map +1 -1
  169. package/esm/components/Dialog/Dialog.mjs.map +1 -1
  170. package/esm/components/Divider/Divider.mjs.map +1 -1
  171. package/esm/components/Fieldset/Fieldset.mjs.map +1 -1
  172. package/esm/components/FileButton/FileButton.mjs.map +1 -1
  173. package/esm/components/FileInput/FileInput.mjs.map +1 -1
  174. package/esm/components/Flex/Flex.mjs.map +1 -1
  175. package/esm/components/FloatingIndicator/FloatingIndicator.mjs.map +1 -1
  176. package/esm/components/FloatingWindow/FloatingWindow.mjs.map +1 -1
  177. package/esm/components/Grid/Grid.mjs.map +1 -1
  178. package/esm/components/Group/Group.mjs.map +1 -1
  179. package/esm/components/Highlight/Highlight.mjs.map +1 -1
  180. package/esm/components/Image/Image.mjs.map +1 -1
  181. package/esm/components/Indicator/Indicator.mjs.map +1 -1
  182. package/esm/components/Input/Input.mjs +3 -2
  183. package/esm/components/Input/Input.mjs.map +1 -1
  184. package/esm/components/InputBase/InputBase.mjs.map +1 -1
  185. package/esm/components/JsonInput/JsonInput.mjs.map +1 -1
  186. package/esm/components/Kbd/Kbd.mjs.map +1 -1
  187. package/esm/components/List/List.mjs.map +1 -1
  188. package/esm/components/Loader/Loader.mjs.map +1 -1
  189. package/esm/components/LoadingOverlay/LoadingOverlay.mjs +1 -0
  190. package/esm/components/LoadingOverlay/LoadingOverlay.mjs.map +1 -1
  191. package/esm/components/Mark/Mark.mjs.map +1 -1
  192. package/esm/components/Marquee/Marquee.mjs.map +1 -1
  193. package/esm/components/Menu/Menu.mjs.map +1 -1
  194. package/esm/components/Modal/Modal.mjs.map +1 -1
  195. package/esm/components/MultiSelect/MultiSelect.mjs +3 -1
  196. package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
  197. package/esm/components/NativeSelect/NativeSelect.mjs +4 -1
  198. package/esm/components/NativeSelect/NativeSelect.mjs.map +1 -1
  199. package/esm/components/NavLink/NavLink.mjs.map +1 -1
  200. package/esm/components/Notification/Notification.mjs.map +1 -1
  201. package/esm/components/NumberInput/NumberInput.mjs +1 -0
  202. package/esm/components/NumberInput/NumberInput.mjs.map +1 -1
  203. package/esm/components/OverflowList/OverflowList.mjs.map +1 -1
  204. package/esm/components/Overlay/Overlay.mjs.map +1 -1
  205. package/esm/components/Pagination/Pagination.mjs.map +1 -1
  206. package/esm/components/Paper/Paper.mjs.map +1 -1
  207. package/esm/components/PasswordInput/PasswordInput.mjs +4 -1
  208. package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
  209. package/esm/components/Pill/Pill.mjs.map +1 -1
  210. package/esm/components/PillsInput/PillsInput.mjs.map +1 -1
  211. package/esm/components/PinInput/PinInput.mjs.map +1 -1
  212. package/esm/components/Popover/Popover.mjs +9 -0
  213. package/esm/components/Popover/Popover.mjs.map +1 -1
  214. package/esm/components/Portal/OptionalPortal.mjs.map +1 -1
  215. package/esm/components/Portal/Portal.mjs.map +1 -1
  216. package/esm/components/Progress/Progress.mjs.map +1 -1
  217. package/esm/components/Radio/Radio.mjs.map +1 -1
  218. package/esm/components/Radio/RadioGroup/RadioGroup.mjs.map +1 -1
  219. package/esm/components/Rating/Rating.mjs.map +1 -1
  220. package/esm/components/RingProgress/RingProgress.mjs +1 -0
  221. package/esm/components/RingProgress/RingProgress.mjs.map +1 -1
  222. package/esm/components/ScrollArea/ScrollArea.mjs.map +1 -1
  223. package/esm/components/ScrollArea/ScrollAreaScrollbar/Scrollbar.mjs.map +1 -1
  224. package/esm/components/Scroller/Scroller.mjs.map +1 -1
  225. package/esm/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
  226. package/esm/components/Select/Select.mjs +1 -0
  227. package/esm/components/Select/Select.mjs.map +1 -1
  228. package/esm/components/SemiCircleProgress/SemiCircleProgress.mjs +1 -2
  229. package/esm/components/SemiCircleProgress/SemiCircleProgress.mjs.map +1 -1
  230. package/esm/components/SimpleGrid/SimpleGrid.mjs.map +1 -1
  231. package/esm/components/Skeleton/Skeleton.mjs.map +1 -1
  232. package/esm/components/Slider/RangeSlider/RangeSlider.mjs.map +1 -1
  233. package/esm/components/Slider/Slider/Slider.mjs.map +1 -1
  234. package/esm/components/Slider/Slider.module.mjs.map +1 -1
  235. package/esm/components/Space/Space.mjs.map +1 -1
  236. package/esm/components/Spoiler/Spoiler.mjs.map +1 -1
  237. package/esm/components/Stack/Stack.mjs.map +1 -1
  238. package/esm/components/Stepper/Stepper.mjs.map +1 -1
  239. package/esm/components/Switch/Switch.mjs.map +1 -1
  240. package/esm/components/Switch/SwitchGroup/SwitchGroup.mjs.map +1 -1
  241. package/esm/components/Table/Table.mjs.map +1 -1
  242. package/esm/components/TableOfContents/TableOfContents.mjs.map +1 -1
  243. package/esm/components/Tabs/Tabs.mjs.map +1 -1
  244. package/esm/components/TagsInput/TagsInput.mjs +3 -1
  245. package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
  246. package/esm/components/Text/Text.mjs.map +1 -1
  247. package/esm/components/TextInput/TextInput.mjs.map +1 -1
  248. package/esm/components/Textarea/Autosize.mjs +1 -0
  249. package/esm/components/Textarea/Autosize.mjs.map +1 -1
  250. package/esm/components/Textarea/Textarea.mjs.map +1 -1
  251. package/esm/components/ThemeIcon/ThemeIcon.mjs.map +1 -1
  252. package/esm/components/Timeline/Timeline.mjs.map +1 -1
  253. package/esm/components/Title/Title.mjs.map +1 -1
  254. package/esm/components/Tooltip/Tooltip.mjs.map +1 -1
  255. package/esm/components/Tree/Tree.mjs.map +1 -1
  256. package/esm/components/Typography/Typography.mjs.map +1 -1
  257. package/esm/components/UnstyledButton/UnstyledButton.mjs.map +1 -1
  258. package/esm/components/VisuallyHidden/VisuallyHidden.mjs.map +1 -1
  259. package/esm/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.mjs +3 -4
  260. package/esm/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.mjs.map +1 -1
  261. package/esm/core/MantineProvider/color-scheme-managers/local-storage-manager.mjs.map +1 -1
  262. package/esm/core/utils/find-element-ancestor/find-element-ancestor.mjs.map +1 -1
  263. package/lib/components/Accordion/Accordion.d.ts +21 -3
  264. package/lib/components/Accordion/index.d.ts +0 -17
  265. package/lib/components/ActionIcon/ActionIcon.d.ts +20 -2
  266. package/lib/components/ActionIcon/index.d.ts +0 -18
  267. package/lib/components/Affix/Affix.d.ts +6 -0
  268. package/lib/components/Affix/index.d.ts +0 -6
  269. package/lib/components/Alert/Alert.d.ts +6 -0
  270. package/lib/components/Alert/index.d.ts +0 -6
  271. package/lib/components/Anchor/Anchor.d.ts +7 -0
  272. package/lib/components/Anchor/index.d.ts +0 -8
  273. package/lib/components/AngleSlider/AngleSlider.d.ts +6 -0
  274. package/lib/components/AngleSlider/index.d.ts +0 -6
  275. package/lib/components/AppShell/AppShell.d.ts +30 -6
  276. package/lib/components/AppShell/index.d.ts +0 -24
  277. package/lib/components/AspectRatio/AspectRatio.d.ts +6 -0
  278. package/lib/components/AspectRatio/index.d.ts +0 -6
  279. package/lib/components/Autocomplete/Autocomplete.d.ts +6 -0
  280. package/lib/components/Autocomplete/index.d.ts +0 -6
  281. package/lib/components/Avatar/Avatar.d.ts +15 -1
  282. package/lib/components/Avatar/index.d.ts +0 -14
  283. package/lib/components/BackgroundImage/BackgroundImage.d.ts +6 -0
  284. package/lib/components/BackgroundImage/index.d.ts +0 -6
  285. package/lib/components/Badge/Badge.d.ts +7 -0
  286. package/lib/components/Badge/index.d.ts +0 -7
  287. package/lib/components/Blockquote/Blockquote.d.ts +6 -0
  288. package/lib/components/Blockquote/index.d.ts +0 -6
  289. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +6 -0
  290. package/lib/components/Breadcrumbs/index.d.ts +0 -7
  291. package/lib/components/Burger/Burger.d.ts +6 -0
  292. package/lib/components/Burger/index.d.ts +0 -6
  293. package/lib/components/Button/Button.d.ts +22 -2
  294. package/lib/components/Button/index.d.ts +0 -20
  295. package/lib/components/Card/Card.d.ts +11 -1
  296. package/lib/components/Card/index.d.ts +0 -10
  297. package/lib/components/Center/Center.d.ts +5 -0
  298. package/lib/components/Center/index.d.ts +0 -5
  299. package/lib/components/Checkbox/Checkbox.d.ts +29 -3
  300. package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.d.ts +8 -8
  301. package/lib/components/Checkbox/index.d.ts +0 -26
  302. package/lib/components/Chip/Chip.d.ts +12 -1
  303. package/lib/components/Chip/ChipGroup/ChipGroup.d.ts +8 -8
  304. package/lib/components/Chip/index.d.ts +0 -11
  305. package/lib/components/CloseButton/CloseButton.d.ts +7 -0
  306. package/lib/components/CloseButton/index.d.ts +0 -7
  307. package/lib/components/Code/Code.d.ts +6 -0
  308. package/lib/components/Code/index.d.ts +0 -6
  309. package/lib/components/Collapse/Collapse.d.ts +4 -0
  310. package/lib/components/Collapse/index.d.ts +0 -4
  311. package/lib/components/ColorInput/ColorInput.d.ts +6 -0
  312. package/lib/components/ColorInput/index.d.ts +0 -6
  313. package/lib/components/ColorPicker/AlphaSlider/AlphaSlider.d.ts +4 -0
  314. package/lib/components/ColorPicker/ColorPicker.d.ts +6 -0
  315. package/lib/components/ColorPicker/HueSlider/HueSlider.d.ts +4 -0
  316. package/lib/components/ColorPicker/index.d.ts +0 -14
  317. package/lib/components/ColorSwatch/ColorSwatch.d.ts +6 -0
  318. package/lib/components/ColorSwatch/index.d.ts +0 -6
  319. package/lib/components/Container/Container.d.ts +6 -0
  320. package/lib/components/Container/index.d.ts +0 -6
  321. package/lib/components/Dialog/Dialog.d.ts +6 -0
  322. package/lib/components/Dialog/index.d.ts +0 -6
  323. package/lib/components/Divider/Divider.d.ts +7 -0
  324. package/lib/components/Divider/index.d.ts +0 -7
  325. package/lib/components/Fieldset/Fieldset.d.ts +6 -0
  326. package/lib/components/Fieldset/index.d.ts +0 -6
  327. package/lib/components/FileButton/FileButton.d.ts +4 -0
  328. package/lib/components/FileButton/index.d.ts +0 -4
  329. package/lib/components/FileInput/FileInput.d.ts +4 -0
  330. package/lib/components/FileInput/index.d.ts +0 -4
  331. package/lib/components/Flex/Flex.d.ts +5 -0
  332. package/lib/components/Flex/index.d.ts +0 -5
  333. package/lib/components/FloatingIndicator/FloatingIndicator.d.ts +6 -0
  334. package/lib/components/FloatingIndicator/index.d.ts +0 -6
  335. package/lib/components/FloatingWindow/FloatingWindow.d.ts +5 -0
  336. package/lib/components/FloatingWindow/index.d.ts +0 -5
  337. package/lib/components/Grid/Grid.d.ts +13 -2
  338. package/lib/components/Grid/index.d.ts +0 -11
  339. package/lib/components/Group/Group.d.ts +7 -0
  340. package/lib/components/Group/index.d.ts +0 -7
  341. package/lib/components/Highlight/Highlight.d.ts +5 -0
  342. package/lib/components/Highlight/index.d.ts +0 -5
  343. package/lib/components/Image/Image.d.ts +6 -0
  344. package/lib/components/Image/index.d.ts +0 -6
  345. package/lib/components/Indicator/Indicator.d.ts +6 -0
  346. package/lib/components/Indicator/index.d.ts +0 -6
  347. package/lib/components/Input/Input.d.ts +51 -7
  348. package/lib/components/Input/index.d.ts +0 -42
  349. package/lib/components/InputBase/InputBase.d.ts +4 -0
  350. package/lib/components/InputBase/index.d.ts +0 -4
  351. package/lib/components/JsonInput/JsonInput.d.ts +4 -0
  352. package/lib/components/JsonInput/index.d.ts +0 -4
  353. package/lib/components/Kbd/Kbd.d.ts +6 -0
  354. package/lib/components/Kbd/index.d.ts +0 -6
  355. package/lib/components/List/List.d.ts +12 -1
  356. package/lib/components/List/index.d.ts +0 -11
  357. package/lib/components/Loader/Loader.d.ts +6 -0
  358. package/lib/components/Loader/index.d.ts +0 -6
  359. package/lib/components/LoadingOverlay/LoadingOverlay.d.ts +6 -0
  360. package/lib/components/LoadingOverlay/index.d.ts +0 -6
  361. package/lib/components/Mark/Mark.d.ts +6 -0
  362. package/lib/components/Mark/index.d.ts +0 -6
  363. package/lib/components/Marquee/Marquee.d.ts +6 -0
  364. package/lib/components/Marquee/index.d.ts +0 -6
  365. package/lib/components/Menu/Menu.d.ts +43 -6
  366. package/lib/components/Menu/index.d.ts +0 -33
  367. package/lib/components/Modal/Modal.d.ts +37 -7
  368. package/lib/components/Modal/index.d.ts +0 -30
  369. package/lib/components/MultiSelect/MultiSelect.d.ts +5 -0
  370. package/lib/components/MultiSelect/index.d.ts +0 -6
  371. package/lib/components/NativeSelect/NativeSelect.d.ts +5 -0
  372. package/lib/components/NativeSelect/index.d.ts +0 -6
  373. package/lib/components/NavLink/NavLink.d.ts +7 -0
  374. package/lib/components/NavLink/index.d.ts +0 -7
  375. package/lib/components/Notification/Notification.d.ts +6 -0
  376. package/lib/components/Notification/index.d.ts +0 -6
  377. package/lib/components/NumberInput/NumberInput.d.ts +7 -0
  378. package/lib/components/NumberInput/index.d.ts +0 -7
  379. package/lib/components/OverflowList/OverflowList.d.ts +6 -0
  380. package/lib/components/OverflowList/index.d.ts +0 -6
  381. package/lib/components/Overlay/Overlay.d.ts +6 -0
  382. package/lib/components/Overlay/index.d.ts +0 -6
  383. package/lib/components/Pagination/Pagination.d.ts +25 -4
  384. package/lib/components/Pagination/index.d.ts +0 -21
  385. package/lib/components/Paper/Paper.d.ts +7 -0
  386. package/lib/components/Paper/index.d.ts +0 -7
  387. package/lib/components/PasswordInput/PasswordInput.d.ts +6 -0
  388. package/lib/components/PasswordInput/index.d.ts +0 -6
  389. package/lib/components/Pill/Pill.d.ts +14 -1
  390. package/lib/components/Pill/index.d.ts +0 -13
  391. package/lib/components/PillsInput/PillsInput.d.ts +12 -1
  392. package/lib/components/PillsInput/index.d.ts +0 -10
  393. package/lib/components/PinInput/PinInput.d.ts +5 -0
  394. package/lib/components/PinInput/index.d.ts +0 -5
  395. package/lib/components/Popover/Popover.d.ts +9 -0
  396. package/lib/components/Portal/OptionalPortal.d.ts +3 -0
  397. package/lib/components/Portal/Portal.d.ts +3 -0
  398. package/lib/components/Portal/index.d.ts +0 -6
  399. package/lib/components/Progress/Progress.d.ts +19 -3
  400. package/lib/components/Progress/index.d.ts +0 -15
  401. package/lib/components/Radio/Radio.d.ts +29 -3
  402. package/lib/components/Radio/RadioGroup/RadioGroup.d.ts +8 -8
  403. package/lib/components/Radio/index.d.ts +0 -26
  404. package/lib/components/Rating/Rating.d.ts +5 -0
  405. package/lib/components/Rating/index.d.ts +0 -5
  406. package/lib/components/RingProgress/RingProgress.d.ts +7 -0
  407. package/lib/components/RingProgress/index.d.ts +0 -7
  408. package/lib/components/ScrollArea/ScrollArea.d.ts +10 -0
  409. package/lib/components/ScrollArea/index.d.ts +0 -10
  410. package/lib/components/Scroller/Scroller.d.ts +6 -0
  411. package/lib/components/Scroller/index.d.ts +0 -6
  412. package/lib/components/SegmentedControl/SegmentedControl.d.ts +7 -0
  413. package/lib/components/SegmentedControl/index.d.ts +0 -8
  414. package/lib/components/Select/Select.d.ts +5 -0
  415. package/lib/components/Select/index.d.ts +0 -6
  416. package/lib/components/SemiCircleProgress/SemiCircleProgress.d.ts +6 -0
  417. package/lib/components/SemiCircleProgress/index.d.ts +0 -6
  418. package/lib/components/SimpleGrid/SimpleGrid.d.ts +5 -0
  419. package/lib/components/SimpleGrid/index.d.ts +0 -5
  420. package/lib/components/Skeleton/Skeleton.d.ts +6 -0
  421. package/lib/components/Skeleton/index.d.ts +0 -6
  422. package/lib/components/Slider/RangeSlider/RangeSlider.d.ts +8 -0
  423. package/lib/components/Slider/Slider/Slider.d.ts +7 -0
  424. package/lib/components/Slider/index.d.ts +0 -15
  425. package/lib/components/Space/Space.d.ts +4 -0
  426. package/lib/components/Space/index.d.ts +0 -5
  427. package/lib/components/Spoiler/Spoiler.d.ts +6 -0
  428. package/lib/components/Spoiler/index.d.ts +0 -6
  429. package/lib/components/Stack/Stack.d.ts +6 -0
  430. package/lib/components/Stack/index.d.ts +0 -6
  431. package/lib/components/Stepper/Stepper.d.ts +17 -2
  432. package/lib/components/Stepper/index.d.ts +0 -14
  433. package/lib/components/Switch/Switch.d.ts +13 -1
  434. package/lib/components/Switch/SwitchGroup/SwitchGroup.d.ts +8 -8
  435. package/lib/components/Switch/index.d.ts +0 -12
  436. package/lib/components/Table/Table.d.ts +35 -2
  437. package/lib/components/Table/index.d.ts +0 -32
  438. package/lib/components/TableOfContents/TableOfContents.d.ts +7 -0
  439. package/lib/components/TableOfContents/index.d.ts +0 -7
  440. package/lib/components/Tabs/Tabs.d.ts +24 -3
  441. package/lib/components/Tabs/index.d.ts +0 -20
  442. package/lib/components/TagsInput/TagsInput.d.ts +5 -0
  443. package/lib/components/TagsInput/index.d.ts +0 -5
  444. package/lib/components/Text/Text.d.ts +7 -0
  445. package/lib/components/Text/index.d.ts +0 -7
  446. package/lib/components/TextInput/TextInput.d.ts +4 -0
  447. package/lib/components/TextInput/index.d.ts +0 -4
  448. package/lib/components/Textarea/Textarea.d.ts +4 -0
  449. package/lib/components/Textarea/index.d.ts +0 -4
  450. package/lib/components/ThemeIcon/ThemeIcon.d.ts +7 -0
  451. package/lib/components/ThemeIcon/index.d.ts +0 -7
  452. package/lib/components/Timeline/Timeline.d.ts +12 -1
  453. package/lib/components/Timeline/index.d.ts +0 -11
  454. package/lib/components/Title/Title.d.ts +8 -0
  455. package/lib/components/Title/index.d.ts +0 -8
  456. package/lib/components/Tooltip/Tooltip.d.ts +15 -2
  457. package/lib/components/Tooltip/index.d.ts +0 -13
  458. package/lib/components/Tree/Tree.d.ts +7 -0
  459. package/lib/components/Tree/index.d.ts +0 -7
  460. package/lib/components/Typography/Typography.d.ts +5 -0
  461. package/lib/components/Typography/index.d.ts +0 -5
  462. package/lib/components/UnstyledButton/UnstyledButton.d.ts +5 -0
  463. package/lib/components/UnstyledButton/index.d.ts +0 -5
  464. package/lib/components/VisuallyHidden/VisuallyHidden.d.ts +3 -0
  465. package/lib/components/VisuallyHidden/index.d.ts +0 -3
  466. package/package.json +2 -2
  467. package/styles/Accordion.css +0 -4
  468. package/styles/Accordion.layer.css +0 -4
  469. package/styles/Badge.css +0 -2
  470. package/styles/Badge.layer.css +0 -2
  471. package/styles/Slider.css +10 -10
  472. package/styles/Slider.layer.css +10 -10
  473. package/styles.css +10 -16
  474. package/styles.layer.css +10 -16
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordInput.mjs","names":["classes"],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["import cx from 'clsx';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport { __BaseInputProps, __InputStylesNames, Input, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PasswordToggleIcon } from './PasswordToggleIcon';\nimport classes from './PasswordInput.module.css';\n\nexport type PasswordInputStylesNames =\n | 'root'\n | 'visibilityToggle'\n | 'innerInput'\n | __InputStylesNames;\nexport type PasswordInputCssVariables = {\n root: '--psi-icon-size' | '--psi-button-size';\n};\n\nexport interface PasswordInputProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<PasswordInputFactory>,\n ElementProps<'input', 'size'> {\n /** A component to replace the visibility toggle icon */\n visibilityToggleIcon?: React.FC<{ reveal: boolean }>;\n\n /** Props passed down to the visibility toggle button */\n visibilityToggleButtonProps?: Record<string, any>;\n\n /** If set, the input value is visible */\n visible?: boolean;\n\n /** If set, the input value is visible by default */\n defaultVisible?: boolean;\n\n /** Called when visibility changes */\n onVisibilityChange?: (visible: boolean) => void;\n}\n\nexport type PasswordInputFactory = Factory<{\n props: PasswordInputProps;\n ref: HTMLInputElement;\n stylesNames: PasswordInputStylesNames;\n vars: PasswordInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n visibilityToggleIcon: PasswordToggleIcon,\n} satisfies Partial<PasswordInputProps>;\n\nconst varsResolver = createVarsResolver<PasswordInputFactory>((_, { size }) => ({\n root: {\n '--psi-icon-size': getSize(size, 'psi-icon-size'),\n '--psi-button-size': getSize(size, 'psi-button-size'),\n },\n}));\n\nexport const PasswordInput = factory<PasswordInputFactory>((_props) => {\n const props = useProps('PasswordInput', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n required,\n error,\n leftSection,\n disabled,\n id,\n variant,\n inputContainer,\n description,\n label,\n size,\n errorProps,\n descriptionProps,\n labelProps,\n withAsterisk,\n inputWrapperOrder,\n wrapperProps,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n leftSectionWidth,\n visible,\n defaultVisible,\n onVisibilityChange,\n visibilityToggleIcon: VisibilityToggleIcon,\n visibilityToggleButtonProps,\n rightSectionProps,\n leftSectionProps,\n leftSectionPointerEvents,\n withErrorStyles,\n mod,\n attributes,\n ...others\n } = props;\n\n const uuid = useId(id);\n\n const [_visible, setVisibility] = useUncontrolled({\n value: visible,\n defaultValue: defaultVisible,\n finalValue: false,\n onChange: onVisibilityChange,\n });\n\n const toggleVisibility = () => setVisibility(!_visible);\n\n const getStyles = useStyles<PasswordInputFactory>({\n name: 'PasswordInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PasswordInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const errorId = errorProps?.id || `${uuid}-error`;\n const descriptionId = descriptionProps?.id || `${uuid}-description`;\n const hasError = !!error && typeof error !== 'boolean';\n const hasDescription = !!description;\n const _describedBy = `${hasError ? errorId : ''} ${hasDescription ? descriptionId : ''}`;\n const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : undefined;\n\n const visibilityToggleButton = (\n <ActionIcon<'button'>\n {...getStyles('visibilityToggle')}\n disabled={disabled}\n radius={radius}\n aria-pressed={_visible}\n tabIndex={-1}\n aria-label=\"Toggle password visibility\"\n {...visibilityToggleButtonProps}\n variant={visibilityToggleButtonProps?.variant ?? 'subtle'}\n color=\"gray\"\n unstyled={unstyled}\n onTouchEnd={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onTouchEnd?.(event);\n toggleVisibility();\n }}\n onMouseDown={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onMouseDown?.(event);\n toggleVisibility();\n }}\n onKeyDown={(event) => {\n visibilityToggleButtonProps?.onKeyDown?.(event);\n if (event.key === ' ') {\n event.preventDefault();\n toggleVisibility();\n }\n }}\n >\n <VisibilityToggleIcon reveal={_visible} />\n </ActionIcon>\n );\n\n return (\n <Input.Wrapper\n required={required}\n id={uuid}\n label={label}\n error={error}\n description={description}\n size={size}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n unstyled={unstyled}\n withAsterisk={withAsterisk}\n inputWrapperOrder={inputWrapperOrder}\n inputContainer={inputContainer}\n variant={variant}\n labelProps={{ ...labelProps, htmlFor: uuid }}\n descriptionProps={{ ...descriptionProps, id: descriptionId }}\n errorProps={{ ...errorProps, id: errorId }}\n mod={mod}\n attributes={attributes}\n {...getStyles('root')}\n {...styleProps}\n {...wrapperProps}\n >\n <Input\n component=\"div\"\n error={error}\n leftSection={leftSection}\n size={size}\n classNames={{ ...resolvedClassNames, input: cx(classes.input, resolvedClassNames.input) }}\n styles={resolvedStyles}\n radius={radius}\n disabled={disabled}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n rightSectionWidth={rightSectionWidth}\n rightSection={rightSection ?? visibilityToggleButton}\n variant={variant}\n unstyled={unstyled}\n leftSectionWidth={leftSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents || 'all'}\n rightSectionProps={rightSectionProps}\n leftSectionProps={leftSectionProps}\n leftSectionPointerEvents={leftSectionPointerEvents}\n withAria={false}\n withErrorStyles={withErrorStyles}\n attributes={attributes}\n >\n <input\n required={required}\n data-invalid={!!error || undefined}\n data-with-left-section={!!leftSection || undefined}\n {...getStyles('innerInput')}\n disabled={disabled}\n id={uuid}\n {...rest}\n aria-describedby={describedBy}\n autoComplete={rest.autoComplete || 'off'}\n type={_visible ? 'text' : 'password'}\n />\n </Input>\n </Input.Wrapper>\n );\n});\n\nPasswordInput.classes = { ...InputBase.classes, ...classes };\nPasswordInput.varsResolver = varsResolver;\nPasswordInput.displayName = '@mantine/core/PasswordInput';\n"],"mappings":";;;;;;;;;;;;;;;;;AA4DA,MAAM,eAAe,EACnB,sBAAsB,oBACvB;AAED,MAAM,eAAe,oBAA0C,GAAG,EAAE,YAAY,EAC9E,MAAM;CACJ,mBAAmB,QAAQ,MAAM,gBAAgB;CACjD,qBAAqB,QAAQ,MAAM,kBAAkB;CACtD,EACF,EAAE;AAEH,MAAa,gBAAgB,SAA+B,WAAW;CACrE,MAAM,QAAQ,SAAS,iBAAiB,cAAc,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Y,UAAU;AACpB,gCAA6B,YAAY,MAAM;AAC/C,OAAI,MAAM,QAAQ,KAAK;AACrB,UAAM,gBAAgB;AACtB,sBAAkB;;;YAItB,oBAAC,sBAAD,EAAsB,QAAQ,UAAY,CAAA;EAC/B,CAAA;AAGf,QACE,oBAAC,MAAM,SAAP;EACY;EACV,IAAI;EACG;EACA;EACM;EACP;EACN,YAAY;EACZ,QAAQ;EACR,kBAAiB;EACjB,kBAAkB;EACR;EACI;EACK;EACH;EACP;EACT,YAAY;GAAE,GAAG;GAAY,SAAS;GAAM;EAC5C,kBAAkB;GAAE,GAAG;GAAkB,IAAI;GAAe;EAC5D,YAAY;GAAE,GAAG;GAAY,IAAI;GAAS;EACrC;EACO;EACZ,GAAI,UAAU,OAAO;EACrB,GAAI;EACJ,GAAI;YAEJ,oBAAC,OAAD;GACE,WAAU;GACH;GACM;GACP;GACN,YAAY;IAAE,GAAG;IAAoB,OAAO,GAAGA,6BAAQ,OAAO,mBAAmB,MAAM;IAAE;GACzF,QAAQ;GACA;GACE;GACV,kBAAiB;GACjB,kBAAkB;GACC;GACnB,cAAc,gBAAgB;GACrB;GACC;GACQ;GAClB,2BAA2B,6BAA6B;GACrC;GACD;GACQ;GAC1B,UAAU;GACO;GACL;aAEZ,oBAAC,SAAD;IACY;IACV,gBAAc,CAAC,CAAC,SAAS,KAAA;IACzB,0BAAwB,CAAC,CAAC,eAAe,KAAA;IACzC,GAAI,UAAU,aAAa;IACjB;IACV,IAAI;IACJ,GAAI;IACJ,oBAAkB;IAClB,cAAc,KAAK,gBAAgB;IACnC,MAAM,WAAW,SAAS;IAC1B,CAAA;GACI,CAAA;EACM,CAAA;EAElB;AAEF,cAAc,UAAU;CAAE,GAAG,UAAU;CAAS,GAAGA;CAAS;AAC5D,cAAc,eAAe;AAC7B,cAAc,cAAc"}
1
+ {"version":3,"file":"PasswordInput.mjs","names":["classes"],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["import cx from 'clsx';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport { __BaseInputProps, __InputStylesNames, Input, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PasswordToggleIcon } from './PasswordToggleIcon';\nimport classes from './PasswordInput.module.css';\n\nexport type PasswordInputStylesNames =\n | 'root'\n | 'visibilityToggle'\n | 'innerInput'\n | __InputStylesNames;\nexport type PasswordInputCssVariables = {\n root: '--psi-icon-size' | '--psi-button-size';\n};\n\nexport interface PasswordInputProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<PasswordInputFactory>,\n ElementProps<'input', 'size'> {\n /** A component to replace the visibility toggle icon */\n visibilityToggleIcon?: React.FC<{ reveal: boolean }>;\n\n /** Props passed down to the visibility toggle button */\n visibilityToggleButtonProps?: Record<string, any>;\n\n /** If set, the input value is visible */\n visible?: boolean;\n\n /** If set, the input value is visible by default */\n defaultVisible?: boolean;\n\n /** Called when visibility changes */\n onVisibilityChange?: (visible: boolean) => void;\n}\n\nexport type PasswordInputFactory = Factory<{\n props: PasswordInputProps;\n ref: HTMLInputElement;\n stylesNames: PasswordInputStylesNames;\n vars: PasswordInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n visibilityToggleIcon: PasswordToggleIcon,\n size: 'sm',\n} satisfies Partial<PasswordInputProps>;\n\nconst varsResolver = createVarsResolver<PasswordInputFactory>((_, { size }) => ({\n root: {\n '--psi-icon-size': getSize(size, 'psi-icon-size'),\n '--psi-button-size': getSize(size, 'psi-button-size'),\n },\n}));\n\nexport const PasswordInput = factory<PasswordInputFactory>((_props) => {\n const props = useProps('PasswordInput', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n required,\n error,\n leftSection,\n disabled,\n id,\n variant,\n inputContainer,\n description,\n label,\n size,\n errorProps,\n descriptionProps,\n labelProps,\n withAsterisk,\n inputWrapperOrder,\n wrapperProps,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n leftSectionWidth,\n visible,\n defaultVisible,\n onVisibilityChange,\n visibilityToggleIcon: VisibilityToggleIcon,\n visibilityToggleButtonProps,\n rightSectionProps,\n leftSectionProps,\n leftSectionPointerEvents,\n withErrorStyles,\n mod,\n attributes,\n ...others\n } = props;\n\n const uuid = useId(id);\n\n const [_visible, setVisibility] = useUncontrolled({\n value: visible,\n defaultValue: defaultVisible,\n finalValue: false,\n onChange: onVisibilityChange,\n });\n\n const toggleVisibility = () => setVisibility(!_visible);\n\n const getStyles = useStyles<PasswordInputFactory>({\n name: 'PasswordInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PasswordInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const errorId = errorProps?.id || `${uuid}-error`;\n const descriptionId = descriptionProps?.id || `${uuid}-description`;\n const hasError = !!error && typeof error !== 'boolean';\n const hasDescription = !!description;\n const _describedBy = `${hasError ? errorId : ''} ${hasDescription ? descriptionId : ''}`;\n const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : undefined;\n\n const visibilityToggleButton = (\n <ActionIcon<'button'>\n {...getStyles('visibilityToggle')}\n disabled={disabled}\n radius={radius}\n aria-pressed={_visible}\n tabIndex={-1}\n aria-label=\"Toggle password visibility\"\n {...visibilityToggleButtonProps}\n variant={visibilityToggleButtonProps?.variant ?? 'subtle'}\n color=\"gray\"\n unstyled={unstyled}\n onTouchEnd={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onTouchEnd?.(event);\n toggleVisibility();\n }}\n onMouseDown={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onMouseDown?.(event);\n toggleVisibility();\n }}\n onKeyDown={(event) => {\n visibilityToggleButtonProps?.onKeyDown?.(event);\n if (event.key === ' ') {\n event.preventDefault();\n toggleVisibility();\n }\n }}\n >\n <VisibilityToggleIcon reveal={_visible} />\n </ActionIcon>\n );\n\n return (\n <Input.Wrapper\n required={required}\n id={uuid}\n label={label}\n error={error}\n description={description}\n size={size}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n unstyled={unstyled}\n withAsterisk={withAsterisk}\n inputWrapperOrder={inputWrapperOrder}\n inputContainer={inputContainer}\n variant={variant}\n labelProps={{ ...labelProps, htmlFor: uuid }}\n descriptionProps={{ ...descriptionProps, id: descriptionId }}\n errorProps={{ ...errorProps, id: errorId }}\n mod={mod}\n attributes={attributes}\n {...getStyles('root')}\n {...styleProps}\n {...wrapperProps}\n >\n <Input\n component=\"div\"\n error={error}\n leftSection={leftSection}\n size={size}\n classNames={{ ...resolvedClassNames, input: cx(classes.input, resolvedClassNames.input) }}\n styles={resolvedStyles}\n radius={radius}\n disabled={disabled}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n rightSectionWidth={rightSectionWidth}\n rightSection={rightSection ?? visibilityToggleButton}\n variant={variant}\n unstyled={unstyled}\n leftSectionWidth={leftSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents || 'all'}\n rightSectionProps={rightSectionProps}\n leftSectionProps={leftSectionProps}\n leftSectionPointerEvents={leftSectionPointerEvents}\n withAria={false}\n withErrorStyles={withErrorStyles}\n attributes={attributes}\n >\n <input\n required={required}\n data-invalid={!!error || undefined}\n data-with-left-section={!!leftSection || undefined}\n {...getStyles('innerInput')}\n disabled={disabled}\n id={uuid}\n {...rest}\n aria-describedby={describedBy}\n autoComplete={rest.autoComplete || 'off'}\n type={_visible ? 'text' : 'password'}\n />\n </Input>\n </Input.Wrapper>\n );\n});\n\nPasswordInput.classes = { ...InputBase.classes, ...classes };\nPasswordInput.varsResolver = varsResolver;\nPasswordInput.displayName = '@mantine/core/PasswordInput';\n\nexport namespace PasswordInput {\n export type Props = PasswordInputProps;\n export type StylesNames = PasswordInputStylesNames;\n export type CssVariables = PasswordInputCssVariables;\n export type Factory = PasswordInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4DA,MAAM,eAAe;CACnB,sBAAsB;CACtB,MAAM;CACP;AAED,MAAM,eAAe,oBAA0C,GAAG,EAAE,YAAY,EAC9E,MAAM;CACJ,mBAAmB,QAAQ,MAAM,gBAAgB;CACjD,qBAAqB,QAAQ,MAAM,kBAAkB;CACtD,EACF,EAAE;AAEH,MAAa,gBAAgB,SAA+B,WAAW;CACrE,MAAM,QAAQ,SAAS,iBAAiB,cAAc,OAAO;CAC7D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,OACA,aACA,UACA,IACA,SACA,gBACA,aACA,OACA,MACA,YACA,kBACA,YACA,cACA,mBACA,cACA,QACA,cACA,mBACA,2BACA,kBACA,SACA,gBACA,oBACA,sBAAsB,sBACtB,6BACA,mBACA,kBACA,0BACA,iBACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,OAAO,MAAM,GAAG;CAEtB,MAAM,CAAC,UAAU,iBAAiB,gBAAgB;EAChD,OAAO;EACP,cAAc;EACd,YAAY;EACZ,UAAU;EACX,CAAC;CAEF,MAAM,yBAAyB,cAAc,CAAC,SAAS;CAEvD,MAAM,YAAY,UAAgC;EAChD,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,oBAAoB,mBAAmB,qBAA2C;EACxF;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,YAAY,SAAS,kBAAkB,OAAO;CACtD,MAAM,UAAU,YAAY,MAAM,GAAG,KAAK;CAC1C,MAAM,gBAAgB,kBAAkB,MAAM,GAAG,KAAK;CAGtD,MAAM,eAAe,GAFJ,CAAC,C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1B,UAAU;GACO;GACL;aAEZ,oBAAC,SAAD;IACY;IACV,gBAAc,CAAC,CAAC,SAAS,KAAA;IACzB,0BAAwB,CAAC,CAAC,eAAe,KAAA;IACzC,GAAI,UAAU,aAAa;IACjB;IACV,IAAI;IACJ,GAAI;IACJ,oBAAkB;IAClB,cAAc,KAAK,gBAAgB;IACnC,MAAM,WAAW,SAAS;IAC1B,CAAA;GACI,CAAA;EACM,CAAA;EAElB;AAEF,cAAc,UAAU;CAAE,GAAG,UAAU;CAAS,GAAGA;CAAS;AAC5D,cAAc,eAAe;AAC7B,cAAc,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Pill.mjs","names":["classes"],"sources":["../../../src/components/Pill/Pill.tsx"],"sourcesContent":["import { use } from 'react';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n getSize,\n MantineRadius,\n MantineSize,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { CloseButton, CloseButtonProps } from '../CloseButton';\nimport { PillsInputContext } from '../PillsInput/PillsInput.context';\nimport { PillGroup, PillGroupContext } from './PillGroup/PillGroup';\nimport classes from './Pill.module.css';\n\nexport type PillStylesNames = 'root' | 'label' | 'remove';\nexport type PillVariant = 'default' | 'contrast';\nexport type PillCssVariables = {\n root: '--pill-fz' | '--pill-radius' | '--pill-height';\n};\n\nexport interface PillProps extends BoxProps, StylesApiProps<PillFactory>, ElementProps<'div'> {\n /** Controls pill `font-size` and `padding` @default 'sm' */\n size?: MantineSize;\n\n /** Controls visibility of the remove button @default false */\n withRemoveButton?: boolean;\n\n /** Called when the remove button is clicked */\n onRemove?: () => void;\n\n /** Props passed down to the remove button */\n removeButtonProps?: CloseButtonProps & React.ComponentProps<'button'>;\n\n /** Key of `theme.radius` or any valid CSS value to set border-radius. Numbers are converted to rem. @default 'xl' */\n radius?: MantineRadius;\n\n /** Adds disabled attribute, applies disabled styles */\n disabled?: boolean;\n}\n\nexport type PillFactory = Factory<{\n props: PillProps;\n ref: HTMLDivElement;\n stylesNames: PillStylesNames;\n vars: PillCssVariables;\n variant: PillVariant;\n ctx: { size: MantineSize | (string & {}) | undefined };\n staticComponents: {\n Group: typeof PillGroup;\n };\n}>;\n\nconst defaultProps = {\n variant: 'default',\n} satisfies Partial<PillProps>;\n\nconst varsResolver = createVarsResolver<PillFactory>((_, { radius }, { size }) => ({\n root: {\n '--pill-fz': getSize(size, 'pill-fz'),\n '--pill-height': getSize(size, 'pill-height'),\n '--pill-radius': radius === undefined ? undefined : getRadius(radius),\n },\n}));\n\nexport const Pill = factory<PillFactory>((_props) => {\n const props = useProps('Pill', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n variant,\n children,\n withRemoveButton,\n onRemove,\n removeButtonProps,\n radius,\n size,\n disabled,\n mod,\n attributes,\n ...others\n } = props;\n\n const ctx = use(PillGroupContext);\n const pillsInputCtx = use(PillsInputContext);\n const _size = size || ctx?.size || undefined;\n const _variant = pillsInputCtx?.variant === 'filled' ? 'contrast' : variant || 'default';\n\n const getStyles = useStyles<PillFactory>({\n name: 'Pill',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n stylesCtx: { size: _size },\n });\n\n return (\n <Box\n component=\"span\"\n variant={_variant}\n size={_size}\n {...getStyles('root', { variant: _variant })}\n mod={[\n { 'with-remove': withRemoveButton && !disabled, disabled: disabled || ctx?.disabled },\n mod,\n ]}\n {...others}\n >\n <span {...getStyles('label')}>{children}</span>\n {withRemoveButton && (\n <CloseButton\n variant=\"transparent\"\n radius={radius}\n tabIndex={-1}\n aria-hidden\n unstyled={unstyled}\n {...removeButtonProps}\n {...getStyles('remove', {\n className: removeButtonProps?.className,\n style: removeButtonProps?.style,\n })}\n onMouseDown={(event) => {\n event.preventDefault();\n event.stopPropagation();\n removeButtonProps?.onMouseDown?.(event);\n }}\n onClick={(event) => {\n event.stopPropagation();\n onRemove?.();\n removeButtonProps?.onClick?.(event);\n }}\n />\n )}\n </Box>\n );\n});\n\nPill.classes = classes;\nPill.varsResolver = varsResolver;\nPill.displayName = '@mantine/core/Pill';\nPill.Group = PillGroup;\n"],"mappings":";;;;;;;;;;;;;;AA2DA,MAAM,eAAe,EACnB,SAAS,WACV;AAED,MAAM,eAAe,oBAAiC,GAAG,EAAE,UAAU,EAAE,YAAY,EACjF,MAAM;CACJ,aAAa,QAAQ,MAAM,UAAU;CACrC,iBAAiB,QAAQ,MAAM,cAAc;CAC7C,iBAAiB,WAAW,KAAA,IAAY,KAAA,IAAY,UAAU,OAAO;CACtE,EACF,EAAE;AAEH,MAAa,OAAO,SAAsB,WAAW;CACnD,MAAM,QAAQ,SAAS,QAAQ,cAAc,OAAO;CACpD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,SACA,UACA,kBACA,UACA,mBACA,QACA,MACA,UACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,MAAM,IAAI,iBAAiB;CACjC,MAAM,gBAAgB,IAAI,kBAAkB;CAC5C,MAAM,QAAQ,QAAQ,KAAK,QAAQ,KAAA;CACnC,MAAM,WAAW,eAAe,YAAY,WAAW,aAAa,WAAW;CAE/E,MAAM,YAAY,UAAuB;EACvC,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,EAAE,MAAM,OAAO;EAC3B,CAAC;AAEF,QACE,qBAAC,KAAD;EACE,WAAU;EACV,SAAS;EACT,MAAM;EACN,GAAI,UAAU,QAAQ,EAAE,SAAS,UAAU,CAAC;EAC5C,KAAK,CACH;GAAE,eAAe,oBAAoB,CAAC;GAAU,UAAU,YAAY,KAAK;GAAU,EACrF,IACD;EACD,GAAI;YATN,CAWE,oBAAC,QAAD;GAAM,GAAI,UAAU,QAAQ;GAAG;GAAgB,CAAA,EAC9C,oBACC,oBAAC,aAAD;GACE,SAAQ;GACA;GACR,UAAU;GACV,eAAA;GACU;GACV,GAAI;GACJ,GAAI,UAAU,UAAU;IACtB,WAAW,mBAAmB;IAC9B,OAAO,mBAAmB;IAC3B,CAAC;GACF,cAAc,UAAU;AACtB,UAAM,gBAAgB;AACtB,UAAM,iBAAiB;AACvB,uBAAmB,cAAc,MAAM;;GAEzC,UAAU,UAAU;AAClB,UAAM,iBAAiB;AACvB,gBAAY;AACZ,uBAAmB,UAAU,MAAM;;GAErC,CAAA,CAEA;;EAER;AAEF,KAAK,UAAUA;AACf,KAAK,eAAe;AACpB,KAAK,cAAc;AACnB,KAAK,QAAQ"}
1
+ {"version":3,"file":"Pill.mjs","names":["classes"],"sources":["../../../src/components/Pill/Pill.tsx"],"sourcesContent":["import { use } from 'react';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n getSize,\n MantineRadius,\n MantineSize,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { CloseButton, CloseButtonProps } from '../CloseButton';\nimport { PillsInputContext } from '../PillsInput/PillsInput.context';\nimport {\n PillGroup,\n PillGroupContext,\n type PillGroupProps,\n type PillGroupStylesNames,\n type PillGroupCssVariables,\n type PillGroupFactory,\n} from './PillGroup/PillGroup';\nimport classes from './Pill.module.css';\nexport type PillStylesNames = 'root' | 'label' | 'remove';\nexport type PillVariant = 'default' | 'contrast';\nexport type PillCssVariables = {\n root: '--pill-fz' | '--pill-radius' | '--pill-height';\n};\n\nexport interface PillProps extends BoxProps, StylesApiProps<PillFactory>, ElementProps<'div'> {\n /** Controls pill `font-size` and `padding` @default 'sm' */\n size?: MantineSize;\n\n /** Controls visibility of the remove button @default false */\n withRemoveButton?: boolean;\n\n /** Called when the remove button is clicked */\n onRemove?: () => void;\n\n /** Props passed down to the remove button */\n removeButtonProps?: CloseButtonProps & React.ComponentProps<'button'>;\n\n /** Key of `theme.radius` or any valid CSS value to set border-radius. Numbers are converted to rem. @default 'xl' */\n radius?: MantineRadius;\n\n /** Adds disabled attribute, applies disabled styles */\n disabled?: boolean;\n}\n\nexport type PillFactory = Factory<{\n props: PillProps;\n ref: HTMLDivElement;\n stylesNames: PillStylesNames;\n vars: PillCssVariables;\n variant: PillVariant;\n ctx: { size: MantineSize | (string & {}) | undefined };\n staticComponents: {\n Group: typeof PillGroup;\n };\n}>;\n\nconst defaultProps = {\n variant: 'default',\n} satisfies Partial<PillProps>;\n\nconst varsResolver = createVarsResolver<PillFactory>((_, { radius }, { size }) => ({\n root: {\n '--pill-fz': getSize(size, 'pill-fz'),\n '--pill-height': getSize(size, 'pill-height'),\n '--pill-radius': radius === undefined ? undefined : getRadius(radius),\n },\n}));\n\nexport const Pill = factory<PillFactory>((_props) => {\n const props = useProps('Pill', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n variant,\n children,\n withRemoveButton,\n onRemove,\n removeButtonProps,\n radius,\n size,\n disabled,\n mod,\n attributes,\n ...others\n } = props;\n\n const ctx = use(PillGroupContext);\n const pillsInputCtx = use(PillsInputContext);\n const _size = size || ctx?.size || undefined;\n const _variant = pillsInputCtx?.variant === 'filled' ? 'contrast' : variant || 'default';\n\n const getStyles = useStyles<PillFactory>({\n name: 'Pill',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n stylesCtx: { size: _size },\n });\n\n return (\n <Box\n component=\"span\"\n variant={_variant}\n size={_size}\n {...getStyles('root', { variant: _variant })}\n mod={[\n { 'with-remove': withRemoveButton && !disabled, disabled: disabled || ctx?.disabled },\n mod,\n ]}\n {...others}\n >\n <span {...getStyles('label')}>{children}</span>\n {withRemoveButton && (\n <CloseButton\n variant=\"transparent\"\n radius={radius}\n tabIndex={-1}\n aria-hidden\n unstyled={unstyled}\n {...removeButtonProps}\n {...getStyles('remove', {\n className: removeButtonProps?.className,\n style: removeButtonProps?.style,\n })}\n onMouseDown={(event) => {\n event.preventDefault();\n event.stopPropagation();\n removeButtonProps?.onMouseDown?.(event);\n }}\n onClick={(event) => {\n event.stopPropagation();\n onRemove?.();\n removeButtonProps?.onClick?.(event);\n }}\n />\n )}\n </Box>\n );\n});\n\nPill.classes = classes;\nPill.varsResolver = varsResolver;\nPill.displayName = '@mantine/core/Pill';\nPill.Group = PillGroup;\n\nexport namespace Pill {\n export type Props = PillProps;\n export type StylesNames = PillStylesNames;\n export type CssVariables = PillCssVariables;\n export type Factory = PillFactory;\n export type Variant = PillVariant;\n\n export namespace Group {\n export type Props = PillGroupProps;\n export type StylesNames = PillGroupStylesNames;\n export type CssVariables = PillGroupCssVariables;\n export type Factory = PillGroupFactory;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAiEA,MAAM,eAAe,EACnB,SAAS,WACV;AAED,MAAM,eAAe,oBAAiC,GAAG,EAAE,UAAU,EAAE,YAAY,EACjF,MAAM;CACJ,aAAa,QAAQ,MAAM,UAAU;CACrC,iBAAiB,QAAQ,MAAM,cAAc;CAC7C,iBAAiB,WAAW,KAAA,IAAY,KAAA,IAAY,UAAU,OAAO;CACtE,EACF,EAAE;AAEH,MAAa,OAAO,SAAsB,WAAW;CACnD,MAAM,QAAQ,SAAS,QAAQ,cAAc,OAAO;CACpD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,SACA,UACA,kBACA,UACA,mBACA,QACA,MACA,UACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,MAAM,IAAI,iBAAiB;CACjC,MAAM,gBAAgB,IAAI,kBAAkB;CAC5C,MAAM,QAAQ,QAAQ,KAAK,QAAQ,KAAA;CACnC,MAAM,WAAW,eAAe,YAAY,WAAW,aAAa,WAAW;CAE/E,MAAM,YAAY,UAAuB;EACvC,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,EAAE,MAAM,OAAO;EAC3B,CAAC;AAEF,QACE,qBAAC,KAAD;EACE,WAAU;EACV,SAAS;EACT,MAAM;EACN,GAAI,UAAU,QAAQ,EAAE,SAAS,UAAU,CAAC;EAC5C,KAAK,CACH;GAAE,eAAe,oBAAoB,CAAC;GAAU,UAAU,YAAY,KAAK;GAAU,EACrF,IACD;EACD,GAAI;YATN,CAWE,oBAAC,QAAD;GAAM,GAAI,UAAU,QAAQ;GAAG;GAAgB,CAAA,EAC9C,oBACC,oBAAC,aAAD;GACE,SAAQ;GACA;GACR,UAAU;GACV,eAAA;GACU;GACV,GAAI;GACJ,GAAI,UAAU,UAAU;IACtB,WAAW,mBAAmB;IAC9B,OAAO,mBAAmB;IAC3B,CAAC;GACF,cAAc,UAAU;AACtB,UAAM,gBAAgB;AACtB,UAAM,iBAAiB;AACvB,uBAAmB,cAAc,MAAM;;GAEzC,UAAU,UAAU;AAClB,UAAM,iBAAiB;AACvB,gBAAY;AACZ,uBAAmB,UAAU,MAAM;;GAErC,CAAA,CAEA;;EAER;AAEF,KAAK,UAAUA;AACf,KAAK,eAAe;AACpB,KAAK,cAAc;AACnB,KAAK,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"PillsInput.mjs","names":[],"sources":["../../../src/components/PillsInput/PillsInput.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PillsInputContext } from './PillsInput.context';\nimport { PillsInputField } from './PillsInputField/PillsInputField';\n\nexport interface PillsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<PillsInputFactory>,\n ElementProps<'div', 'size'> {\n __stylesApiProps?: Record<string, any>;\n __staticSelector?: string;\n}\n\nexport type PillsInputFactory = Factory<{\n props: PillsInputProps;\n ref: HTMLDivElement;\n stylesNames: __InputStylesNames;\n staticComponents: {\n Field: typeof PillsInputField;\n };\n}>;\n\nconst defaultProps = {\n size: 'sm',\n} satisfies Partial<PillsInputProps>;\n\nexport const PillsInput = factory<PillsInputFactory>((_props) => {\n const props = useProps('PillsInput', defaultProps, _props);\n const {\n children,\n onMouseDown,\n onClick,\n size,\n disabled,\n __staticSelector,\n error,\n variant,\n ...others\n } = props;\n\n const fieldRef = useRef<HTMLInputElement>(null);\n\n return (\n <PillsInputContext value={{ fieldRef, size, disabled, hasError: !!error, variant }}>\n <InputBase\n size={size}\n error={error}\n variant={variant}\n component=\"div\"\n data-no-overflow\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n fieldRef.current?.focus();\n }}\n onClick={(event) => {\n event.preventDefault();\n const fieldset = event.currentTarget.closest('fieldset');\n if (!fieldset?.disabled) {\n fieldRef.current?.focus();\n onClick?.(event);\n }\n }}\n {...others}\n multiline\n disabled={disabled}\n __staticSelector={__staticSelector || 'PillsInput'}\n withAria={false}\n >\n {children}\n </InputBase>\n </PillsInputContext>\n );\n});\n\nPillsInput.displayName = '@mantine/core/PillsInput';\nPillsInput.classes = InputBase.classes;\nPillsInput.Field = PillsInputField;\n"],"mappings":";;;;;;;;;AA0BA,MAAM,eAAe,EACnB,MAAM,MACP;AAED,MAAa,aAAa,SAA4B,WAAW;CAE/D,MAAM,EACJ,UACA,aACA,SACA,MACA,UACA,kBACA,OACA,SACA,GAAG,WAVS,SAAS,cAAc,cAAc,OAAO;CAa1D,MAAM,WAAW,OAAyB,KAAK;AAE/C,QACE,oBAAC,mBAAD;EAAmB,OAAO;GAAE;GAAU;GAAM;GAAU,UAAU,CAAC,CAAC;GAAO;GAAS;YAChF,oBAAC,WAAD;GACQ;GACC;GACE;GACT,WAAU;GACV,oBAAA;GACA,cAAc,UAAU;AACtB,UAAM,gBAAgB;AACtB,kBAAc,MAAM;AACpB,aAAS,SAAS,OAAO;;GAE3B,UAAU,UAAU;AAClB,UAAM,gBAAgB;AAEtB,QAAI,CADa,MAAM,cAAc,QAAQ,WAAW,EACzC,UAAU;AACvB,cAAS,SAAS,OAAO;AACzB,eAAU,MAAM;;;GAGpB,GAAI;GACJ,WAAA;GACU;GACV,kBAAkB,oBAAoB;GACtC,UAAU;GAET;GACS,CAAA;EACM,CAAA;EAEtB;AAEF,WAAW,cAAc;AACzB,WAAW,UAAU,UAAU;AAC/B,WAAW,QAAQ"}
1
+ {"version":3,"file":"PillsInput.mjs","names":[],"sources":["../../../src/components/PillsInput/PillsInput.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PillsInputContext, type PillsInputContextValue } from './PillsInput.context';\nimport {\n PillsInputField,\n type PillsInputFieldProps,\n type PillsInputFieldFactory,\n type PillsInputFieldStylesNames,\n} from './PillsInputField/PillsInputField';\nexport interface PillsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<PillsInputFactory>,\n ElementProps<'div', 'size'> {\n __stylesApiProps?: Record<string, any>;\n __staticSelector?: string;\n}\n\nexport type PillsInputFactory = Factory<{\n props: PillsInputProps;\n ref: HTMLDivElement;\n stylesNames: __InputStylesNames;\n staticComponents: {\n Field: typeof PillsInputField;\n };\n}>;\n\nconst defaultProps = {\n size: 'sm',\n} satisfies Partial<PillsInputProps>;\n\nexport const PillsInput = factory<PillsInputFactory>((_props) => {\n const props = useProps('PillsInput', defaultProps, _props);\n const {\n children,\n onMouseDown,\n onClick,\n size,\n disabled,\n __staticSelector,\n error,\n variant,\n ...others\n } = props;\n\n const fieldRef = useRef<HTMLInputElement>(null);\n\n return (\n <PillsInputContext value={{ fieldRef, size, disabled, hasError: !!error, variant }}>\n <InputBase\n size={size}\n error={error}\n variant={variant}\n component=\"div\"\n data-no-overflow\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n fieldRef.current?.focus();\n }}\n onClick={(event) => {\n event.preventDefault();\n const fieldset = event.currentTarget.closest('fieldset');\n if (!fieldset?.disabled) {\n fieldRef.current?.focus();\n onClick?.(event);\n }\n }}\n {...others}\n multiline\n disabled={disabled}\n __staticSelector={__staticSelector || 'PillsInput'}\n withAria={false}\n >\n {children}\n </InputBase>\n </PillsInputContext>\n );\n});\n\nPillsInput.displayName = '@mantine/core/PillsInput';\nPillsInput.classes = InputBase.classes;\nPillsInput.Field = PillsInputField;\n\nexport namespace PillsInput {\n export type Props = PillsInputProps;\n export type Factory = PillsInputFactory;\n export type ContextValue = PillsInputContextValue;\n\n export namespace Field {\n export type Props = PillsInputFieldProps;\n export type Factory = PillsInputFieldFactory;\n export type StylesNames = PillsInputFieldStylesNames;\n }\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,eAAe,EACnB,MAAM,MACP;AAED,MAAa,aAAa,SAA4B,WAAW;CAE/D,MAAM,EACJ,UACA,aACA,SACA,MACA,UACA,kBACA,OACA,SACA,GAAG,WAVS,SAAS,cAAc,cAAc,OAAO;CAa1D,MAAM,WAAW,OAAyB,KAAK;AAE/C,QACE,oBAAC,mBAAD;EAAmB,OAAO;GAAE;GAAU;GAAM;GAAU,UAAU,CAAC,CAAC;GAAO;GAAS;YAChF,oBAAC,WAAD;GACQ;GACC;GACE;GACT,WAAU;GACV,oBAAA;GACA,cAAc,UAAU;AACtB,UAAM,gBAAgB;AACtB,kBAAc,MAAM;AACpB,aAAS,SAAS,OAAO;;GAE3B,UAAU,UAAU;AAClB,UAAM,gBAAgB;AAEtB,QAAI,CADa,MAAM,cAAc,QAAQ,WAAW,EACzC,UAAU;AACvB,cAAS,SAAS,OAAO;AACzB,eAAU,MAAM;;;GAGpB,GAAI;GACJ,WAAA;GACU;GACV,kBAAkB,oBAAoB;GACtC,UAAU;GAET;GACS,CAAA;EACM,CAAA;EAEtB;AAEF,WAAW,cAAc;AACzB,WAAW,UAAU,UAAU;AAC/B,WAAW,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"PinInput.mjs","names":["useId","classes"],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { assignRef, useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n Factory,\n factory,\n getSize,\n MantineRadius,\n MantineSize,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Group } from '../Group';\nimport { Input, InputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { createPinArray } from './create-pin-array/create-pin-array';\nimport classes from './PinInput.module.css';\n\nconst regex = {\n number: /^[0-9]+$/,\n alphanumeric: /^[a-zA-Z0-9]+$/i,\n};\n\nexport type PinInputStylesNames = 'root' | 'pinInput' | 'input';\n\nexport type PinInputCssVariables = {\n root: '--pin-input-size';\n};\n\nexport interface PinInputProps\n extends BoxProps, StylesApiProps<PinInputFactory>, ElementProps<'div', 'onChange' | 'ref'> {\n ref?: React.Ref<HTMLInputElement>;\n\n /** Hidden input `name` attribute */\n name?: string;\n\n /** Hidden input `form` attribute */\n form?: string;\n\n /** Key of `theme.spacing` or any valid CSS value to set `gap` between inputs, numbers are converted to rem @default 'md' */\n gap?: MantineSpacing;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Controls inputs `width` and `height` @default 'sm' */\n size?: MantineSize;\n\n /** If set, the first input is focused when component is mounted @default false */\n autoFocus?: boolean;\n\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 /** Called when all inputs have value */\n onComplete?: (value: string) => void;\n\n /** Inputs placeholder @default '○' */\n placeholder?: string;\n\n /** Determines whether focus should be moved automatically to the next input once filled @default true */\n manageFocus?: boolean;\n\n /** Determines whether `autocomplete=\"one-time-code\"` attribute should be set on all inputs @default true */\n oneTimeCode?: boolean;\n\n /** Base id used to generate unique ids for inputs */\n id?: string;\n\n /** Adds disabled attribute to all inputs */\n disabled?: boolean;\n\n /** Sets `aria-invalid` attribute and applies error styles to all inputs */\n error?: boolean;\n\n /** Determines which values can be entered @default 'alphanumeric' */\n type?: 'alphanumeric' | 'number' | RegExp;\n\n /** Changes input type to `\"password\"` @default false */\n mask?: boolean;\n\n /** Number of inputs @default 4 */\n length?: number;\n\n /** If set, the user cannot edit the value */\n readOnly?: boolean;\n\n /** Inputs `type` attribute, inferred from the `type` prop if not specified */\n inputType?: React.HTMLInputTypeAttribute;\n\n /** `inputmode` attribute, inferred from the `type` prop if not specified */\n inputMode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search'\n | undefined;\n\n /** `aria-label` attribute */\n ariaLabel?: string;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Props added to the input element depending on its index */\n getInputProps?: (index: number) => InputProps & ElementProps<'input', 'size'> & DataAttributes;\n}\n\nexport type PinInputFactory = Factory<{\n props: PinInputProps;\n ref: HTMLDivElement;\n stylesNames: PinInputStylesNames;\n vars: PinInputCssVariables;\n}>;\n\nconst defaultProps = {\n gap: 'sm',\n length: 4,\n manageFocus: true,\n oneTimeCode: true,\n placeholder: '○',\n type: 'alphanumeric',\n ariaLabel: 'PinInput',\n size: 'sm',\n} satisfies Partial<PinInputProps>;\n\nconst varsResolver = createVarsResolver<PinInputFactory>((_, { size }) => ({\n root: {\n '--pin-input-size': getSize(size ?? 'sm', 'pin-input-size'),\n },\n}));\n\nexport const PinInput = factory<PinInputFactory>((props) => {\n const {\n name,\n form,\n className,\n value,\n defaultValue,\n variant,\n gap,\n style,\n size,\n classNames,\n styles,\n unstyled,\n length,\n onChange,\n onComplete,\n manageFocus,\n autoFocus,\n error,\n radius,\n disabled,\n oneTimeCode,\n placeholder,\n type,\n mask,\n readOnly,\n inputType,\n inputMode,\n ariaLabel,\n vars,\n id,\n hiddenInputProps,\n rootRef,\n getInputProps,\n attributes,\n ref,\n ...others\n } = useProps('PinInput', defaultProps, props);\n\n const uuid = useId(id);\n\n const getStyles = useStyles<PinInputFactory>({\n name: 'PinInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PinInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [focusedIndex, setFocusedIndex] = useState(-1);\n const inputsRef = useRef<Array<HTMLInputElement>>([]);\n const currentLength = length ?? 4;\n\n const completedRef = useRef(false);\n\n const [_value, setValues] = useUncontrolled<string[]>({\n value: value !== undefined ? createPinArray(currentLength, value) : undefined,\n defaultValue: defaultValue?.split('').slice(0, currentLength),\n finalValue: createPinArray(currentLength, ''),\n onChange: (val) => {\n const stringValue = val.join('').trim();\n onChange?.(stringValue);\n if (stringValue.length === currentLength && !completedRef.current) {\n completedRef.current = true;\n onComplete?.(stringValue);\n } else if (stringValue.length < currentLength) {\n completedRef.current = false;\n }\n },\n });\n\n const currentValue =\n _value.length !== currentLength ? createPinArray(currentLength, _value.join('')) : _value;\n\n const _valueToString = currentValue.join('').trim();\n\n const validate = (code: string) => {\n const re = type instanceof RegExp ? type : type && type in regex ? regex[type] : null;\n return re?.test(code);\n };\n\n const focusInputField = (dir: 'next' | 'prev', index: number) => {\n if (!manageFocus) {\n return;\n }\n\n if (dir === 'next') {\n const nextIndex = index + 1;\n if (nextIndex < currentLength) {\n inputsRef.current[nextIndex]?.focus();\n }\n } else if (dir === 'prev') {\n const prevIndex = index - 1;\n if (prevIndex >= 0) {\n inputsRef.current[prevIndex]?.focus();\n }\n }\n };\n\n const setFieldValue = (val: string, index: number) => {\n const values = [...currentValue];\n values[index] = val;\n setValues(values);\n return values;\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const inputValue = event.target.value;\n\n if (inputValue.length > 1) {\n const isPaste = inputValue.length > 2;\n if (isPaste) {\n const isValid = validate(inputValue);\n if (isValid) {\n setValues(createPinArray(currentLength, inputValue));\n const filledCount = Math.min(inputValue.length, currentLength);\n if (filledCount < currentLength) {\n focusInputField('next', filledCount - 1);\n }\n }\n return;\n }\n\n const newChar = inputValue.split('')[inputValue.length - 1];\n if (validate(newChar)) {\n setFieldValue(newChar, index);\n focusInputField('next', index);\n }\n return;\n }\n\n if (inputValue.length === 1) {\n if (validate(inputValue)) {\n setFieldValue(inputValue, index);\n focusInputField('next', index);\n } else {\n setFieldValue('', index);\n }\n } else if (inputValue.length === 0) {\n setFieldValue('', index);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n const { ctrlKey, metaKey, key, shiftKey, target } = event;\n const inputValue = (target as HTMLInputElement).value;\n\n if (inputMode === 'numeric') {\n const allowedKeys = ['Backspace', 'Tab', 'Control', 'Delete', 'ArrowLeft', 'ArrowRight'];\n const isPasteShortcut = (ctrlKey || metaKey) && key === 'v';\n const isAllowedKey =\n allowedKeys.includes(key) || isPasteShortcut || !Number.isNaN(Number(key));\n\n if (!isAllowedKey) {\n event.preventDefault();\n return;\n }\n }\n\n switch (key) {\n case 'ArrowLeft':\n event.preventDefault();\n focusInputField('prev', index);\n break;\n\n case 'ArrowRight':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Tab':\n if (shiftKey) {\n if (index > 0 && manageFocus) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n case ' ':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Delete':\n event.preventDefault();\n setFieldValue('', index);\n break;\n\n case 'Backspace':\n if (inputValue === '') {\n event.preventDefault();\n focusInputField('prev', index);\n } else {\n setFieldValue('', index);\n if (index < currentLength - 1) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n default:\n if (inputValue.length > 0 && key === currentValue[index]) {\n event.preventDefault();\n focusInputField('next', index);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>, index: number) => {\n event.target.select();\n setFocusedIndex(index);\n };\n\n const handleBlur = () => {\n setFocusedIndex(-1);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n const pasteData = event.clipboardData.getData('text/plain').replace(/[\\n\\r\\s]+/g, '');\n const isValid = validate(pasteData.trim());\n\n if (isValid) {\n const pasteArray = createPinArray(currentLength, pasteData);\n setValues(pasteArray);\n const filledCount = pasteArray.filter((val) => val !== '').length;\n if (filledCount >= currentLength) {\n inputsRef.current[currentLength - 1]?.focus();\n } else {\n inputsRef.current[filledCount]?.focus();\n }\n }\n };\n\n return (\n <>\n <Group\n {...others}\n {...getStyles('root')}\n ref={rootRef}\n role=\"group\"\n id={uuid}\n gap={gap}\n unstyled={unstyled}\n wrap=\"nowrap\"\n variant={variant}\n __size={size}\n dir=\"ltr\"\n >\n {currentValue.map((char: string, index: number) => (\n <Input\n component=\"input\"\n {...getStyles('pinInput', {\n style: {\n '--input-padding': '0',\n '--input-text-align': 'center',\n } as React.CSSProperties,\n })}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n size={size}\n __staticSelector=\"PinInput\"\n id={`${uuid}-${index + 1}`}\n key={`${uuid}-${index}`}\n inputMode={inputMode || (type === 'number' ? 'numeric' : 'text')}\n onChange={(event) => handleChange(event, index)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={(event) => handleFocus(event, index)}\n onBlur={handleBlur}\n onPaste={handlePaste}\n type={inputType || (mask ? 'password' : type === 'number' ? 'tel' : 'text')}\n radius={radius}\n error={error}\n variant={variant}\n disabled={disabled}\n ref={(node) => {\n if (node) {\n index === 0 && assignRef(ref, node);\n inputsRef.current[index] = node;\n }\n }}\n autoComplete={oneTimeCode ? 'one-time-code' : 'off'}\n placeholder={focusedIndex === index ? '' : placeholder}\n value={char}\n autoFocus={autoFocus && index === 0}\n unstyled={unstyled}\n aria-label={ariaLabel}\n readOnly={readOnly}\n {...getInputProps?.(index)}\n />\n ))}\n </Group>\n\n <input type=\"hidden\" name={name} form={form} value={_valueToString} {...hiddenInputProps} />\n </>\n );\n});\n\nPinInput.classes = { ...classes, ...InputBase.classes };\nPinInput.varsResolver = varsResolver;\nPinInput.displayName = '@mantine/core/PinInput';\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ;CACZ,QAAQ;CACR,cAAc;CACf;AA2GD,MAAM,eAAe;CACnB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CACb,MAAM;CACN,WAAW;CACX,MAAM;CACP;AAED,MAAM,eAAe,oBAAqC,GAAG,EAAE,YAAY,EACzE,MAAM,EACJ,oBAAoB,QAAQ,QAAQ,MAAM,iBAAiB,EAC5D,EACF,EAAE;AAEH,MAAa,WAAW,SAA0B,UAAU;CAC1D,MAAM,EACJ,MACA,MACA,WACA,OACA,cACA,SACA,KACA,OACA,MACA,YACA,QACA,UACA,QACA,UACA,YACA,aACA,WACA,OACA,QACA,UACA,aACA,aACA,MACA,MACA,UACA,WACA,WACA,WACA,MACA,IACA,kBACA,SACA,eACA,YACA,KACA,GAAG,WACD,SAAS,YAAY,cAAc,MAAM;CAE7C,MAAM,OAAOA,QAAM,GAAG;CAEtB,MAAM,YAAY,UAA2B;EAC3C,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,oBAAoB,mBAAmB,qBAAsC;EACnF;EACA;EACA;EACD,CAAC;CAEF,MAAM,CAAC,cAAc,mBAAmB,SAAS,GAAG;CACpD,MAAM,YAAY,OAAgC,EAAE,CAAC;CACrD,MAAM,gBAAgB,UAAU;CAEhC,MAAM,eAAe,OAAO,MAAM;CAElC,MAAM,CAAC,QAAQ,aAAa,gBAA0B;EACpD,OAAO,UAAU,KAAA,IAAY,eAAe,eAAe,MAAM,GAAG,KAAA;EACpE,cAAc,cAAc,MAAM,GAAG,CAAC,MAAM,GAAG,cAAc;EAC7D,YAAY,eAAe,eAAe,GAAG;EAC7C,WAAW,QAAQ;GACjB,MAAM,cAAc,IAAI,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UAAU,KAAK,KAAK;AACnC,eAAU,QAAQ,SAAS;;;GAG/B,cAAc,cAAc,kBAAkB;GAC9C,aAAa,iBAAiB,QAAQ,KAAK;GAC3C,OAAO;GACP,WAAW,aAAa,UAAU;GACxB;GACV,cAAY;GACF;GACV,GAAI,gBAAgB,MAAM;GAC1B,CAAA,CACF;EACI,CAAA,EAER,oBAAC,SAAD;EAAO,MAAK;EAAe;EAAY;EAAM,OAAO;EAAgB,GAAI;EAAoB,CAAA,CAC3F,EAAA,CAAA;EAEL;AAEF,SAAS,UAAU;CAAE,GAAGC;CAAS,GAAG,UAAU;CAAS;AACvD,SAAS,eAAe;AACxB,SAAS,cAAc"}
1
+ {"version":3,"file":"PinInput.mjs","names":["useId","classes"],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { assignRef, useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n Factory,\n factory,\n getSize,\n MantineRadius,\n MantineSize,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Group } from '../Group';\nimport { Input, InputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { createPinArray } from './create-pin-array/create-pin-array';\nimport classes from './PinInput.module.css';\n\nconst regex = {\n number: /^[0-9]+$/,\n alphanumeric: /^[a-zA-Z0-9]+$/i,\n};\n\nexport type PinInputStylesNames = 'root' | 'pinInput' | 'input';\n\nexport type PinInputCssVariables = {\n root: '--pin-input-size';\n};\n\nexport interface PinInputProps\n extends BoxProps, StylesApiProps<PinInputFactory>, ElementProps<'div', 'onChange' | 'ref'> {\n ref?: React.Ref<HTMLInputElement>;\n\n /** Hidden input `name` attribute */\n name?: string;\n\n /** Hidden input `form` attribute */\n form?: string;\n\n /** Key of `theme.spacing` or any valid CSS value to set `gap` between inputs, numbers are converted to rem @default 'md' */\n gap?: MantineSpacing;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Controls inputs `width` and `height` @default 'sm' */\n size?: MantineSize;\n\n /** If set, the first input is focused when component is mounted @default false */\n autoFocus?: boolean;\n\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 /** Called when all inputs have value */\n onComplete?: (value: string) => void;\n\n /** Inputs placeholder @default '○' */\n placeholder?: string;\n\n /** Determines whether focus should be moved automatically to the next input once filled @default true */\n manageFocus?: boolean;\n\n /** Determines whether `autocomplete=\"one-time-code\"` attribute should be set on all inputs @default true */\n oneTimeCode?: boolean;\n\n /** Base id used to generate unique ids for inputs */\n id?: string;\n\n /** Adds disabled attribute to all inputs */\n disabled?: boolean;\n\n /** Sets `aria-invalid` attribute and applies error styles to all inputs */\n error?: boolean;\n\n /** Determines which values can be entered @default 'alphanumeric' */\n type?: 'alphanumeric' | 'number' | RegExp;\n\n /** Changes input type to `\"password\"` @default false */\n mask?: boolean;\n\n /** Number of inputs @default 4 */\n length?: number;\n\n /** If set, the user cannot edit the value */\n readOnly?: boolean;\n\n /** Inputs `type` attribute, inferred from the `type` prop if not specified */\n inputType?: React.HTMLInputTypeAttribute;\n\n /** `inputmode` attribute, inferred from the `type` prop if not specified */\n inputMode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search'\n | undefined;\n\n /** `aria-label` attribute */\n ariaLabel?: string;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Props added to the input element depending on its index */\n getInputProps?: (index: number) => InputProps & ElementProps<'input', 'size'> & DataAttributes;\n}\n\nexport type PinInputFactory = Factory<{\n props: PinInputProps;\n ref: HTMLDivElement;\n stylesNames: PinInputStylesNames;\n vars: PinInputCssVariables;\n}>;\n\nconst defaultProps = {\n gap: 'sm',\n length: 4,\n manageFocus: true,\n oneTimeCode: true,\n placeholder: '○',\n type: 'alphanumeric',\n ariaLabel: 'PinInput',\n size: 'sm',\n} satisfies Partial<PinInputProps>;\n\nconst varsResolver = createVarsResolver<PinInputFactory>((_, { size }) => ({\n root: {\n '--pin-input-size': getSize(size ?? 'sm', 'pin-input-size'),\n },\n}));\n\nexport const PinInput = factory<PinInputFactory>((props) => {\n const {\n name,\n form,\n className,\n value,\n defaultValue,\n variant,\n gap,\n style,\n size,\n classNames,\n styles,\n unstyled,\n length,\n onChange,\n onComplete,\n manageFocus,\n autoFocus,\n error,\n radius,\n disabled,\n oneTimeCode,\n placeholder,\n type,\n mask,\n readOnly,\n inputType,\n inputMode,\n ariaLabel,\n vars,\n id,\n hiddenInputProps,\n rootRef,\n getInputProps,\n attributes,\n ref,\n ...others\n } = useProps('PinInput', defaultProps, props);\n\n const uuid = useId(id);\n\n const getStyles = useStyles<PinInputFactory>({\n name: 'PinInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PinInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [focusedIndex, setFocusedIndex] = useState(-1);\n const inputsRef = useRef<Array<HTMLInputElement>>([]);\n const currentLength = length ?? 4;\n\n const completedRef = useRef(false);\n\n const [_value, setValues] = useUncontrolled<string[]>({\n value: value !== undefined ? createPinArray(currentLength, value) : undefined,\n defaultValue: defaultValue?.split('').slice(0, currentLength),\n finalValue: createPinArray(currentLength, ''),\n onChange: (val) => {\n const stringValue = val.join('').trim();\n onChange?.(stringValue);\n if (stringValue.length === currentLength && !completedRef.current) {\n completedRef.current = true;\n onComplete?.(stringValue);\n } else if (stringValue.length < currentLength) {\n completedRef.current = false;\n }\n },\n });\n\n const currentValue =\n _value.length !== currentLength ? createPinArray(currentLength, _value.join('')) : _value;\n\n const _valueToString = currentValue.join('').trim();\n\n const validate = (code: string) => {\n const re = type instanceof RegExp ? type : type && type in regex ? regex[type] : null;\n return re?.test(code);\n };\n\n const focusInputField = (dir: 'next' | 'prev', index: number) => {\n if (!manageFocus) {\n return;\n }\n\n if (dir === 'next') {\n const nextIndex = index + 1;\n if (nextIndex < currentLength) {\n inputsRef.current[nextIndex]?.focus();\n }\n } else if (dir === 'prev') {\n const prevIndex = index - 1;\n if (prevIndex >= 0) {\n inputsRef.current[prevIndex]?.focus();\n }\n }\n };\n\n const setFieldValue = (val: string, index: number) => {\n const values = [...currentValue];\n values[index] = val;\n setValues(values);\n return values;\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const inputValue = event.target.value;\n\n if (inputValue.length > 1) {\n const isPaste = inputValue.length > 2;\n if (isPaste) {\n const isValid = validate(inputValue);\n if (isValid) {\n setValues(createPinArray(currentLength, inputValue));\n const filledCount = Math.min(inputValue.length, currentLength);\n if (filledCount < currentLength) {\n focusInputField('next', filledCount - 1);\n }\n }\n return;\n }\n\n const newChar = inputValue.split('')[inputValue.length - 1];\n if (validate(newChar)) {\n setFieldValue(newChar, index);\n focusInputField('next', index);\n }\n return;\n }\n\n if (inputValue.length === 1) {\n if (validate(inputValue)) {\n setFieldValue(inputValue, index);\n focusInputField('next', index);\n } else {\n setFieldValue('', index);\n }\n } else if (inputValue.length === 0) {\n setFieldValue('', index);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n const { ctrlKey, metaKey, key, shiftKey, target } = event;\n const inputValue = (target as HTMLInputElement).value;\n\n if (inputMode === 'numeric') {\n const allowedKeys = ['Backspace', 'Tab', 'Control', 'Delete', 'ArrowLeft', 'ArrowRight'];\n const isPasteShortcut = (ctrlKey || metaKey) && key === 'v';\n const isAllowedKey =\n allowedKeys.includes(key) || isPasteShortcut || !Number.isNaN(Number(key));\n\n if (!isAllowedKey) {\n event.preventDefault();\n return;\n }\n }\n\n switch (key) {\n case 'ArrowLeft':\n event.preventDefault();\n focusInputField('prev', index);\n break;\n\n case 'ArrowRight':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Tab':\n if (shiftKey) {\n if (index > 0 && manageFocus) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n case ' ':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Delete':\n event.preventDefault();\n setFieldValue('', index);\n break;\n\n case 'Backspace':\n if (inputValue === '') {\n event.preventDefault();\n focusInputField('prev', index);\n } else {\n setFieldValue('', index);\n if (index < currentLength - 1) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n default:\n if (inputValue.length > 0 && key === currentValue[index]) {\n event.preventDefault();\n focusInputField('next', index);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>, index: number) => {\n event.target.select();\n setFocusedIndex(index);\n };\n\n const handleBlur = () => {\n setFocusedIndex(-1);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n const pasteData = event.clipboardData.getData('text/plain').replace(/[\\n\\r\\s]+/g, '');\n const isValid = validate(pasteData.trim());\n\n if (isValid) {\n const pasteArray = createPinArray(currentLength, pasteData);\n setValues(pasteArray);\n const filledCount = pasteArray.filter((val) => val !== '').length;\n if (filledCount >= currentLength) {\n inputsRef.current[currentLength - 1]?.focus();\n } else {\n inputsRef.current[filledCount]?.focus();\n }\n }\n };\n\n return (\n <>\n <Group\n {...others}\n {...getStyles('root')}\n ref={rootRef}\n role=\"group\"\n id={uuid}\n gap={gap}\n unstyled={unstyled}\n wrap=\"nowrap\"\n variant={variant}\n __size={size}\n dir=\"ltr\"\n >\n {currentValue.map((char: string, index: number) => (\n <Input\n component=\"input\"\n {...getStyles('pinInput', {\n style: {\n '--input-padding': '0',\n '--input-text-align': 'center',\n } as React.CSSProperties,\n })}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n size={size}\n __staticSelector=\"PinInput\"\n id={`${uuid}-${index + 1}`}\n key={`${uuid}-${index}`}\n inputMode={inputMode || (type === 'number' ? 'numeric' : 'text')}\n onChange={(event) => handleChange(event, index)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={(event) => handleFocus(event, index)}\n onBlur={handleBlur}\n onPaste={handlePaste}\n type={inputType || (mask ? 'password' : type === 'number' ? 'tel' : 'text')}\n radius={radius}\n error={error}\n variant={variant}\n disabled={disabled}\n ref={(node) => {\n if (node) {\n index === 0 && assignRef(ref, node);\n inputsRef.current[index] = node;\n }\n }}\n autoComplete={oneTimeCode ? 'one-time-code' : 'off'}\n placeholder={focusedIndex === index ? '' : placeholder}\n value={char}\n autoFocus={autoFocus && index === 0}\n unstyled={unstyled}\n aria-label={ariaLabel}\n readOnly={readOnly}\n {...getInputProps?.(index)}\n />\n ))}\n </Group>\n\n <input type=\"hidden\" name={name} form={form} value={_valueToString} {...hiddenInputProps} />\n </>\n );\n});\n\nPinInput.classes = { ...classes, ...InputBase.classes };\nPinInput.varsResolver = varsResolver;\nPinInput.displayName = '@mantine/core/PinInput';\n\nexport namespace PinInput {\n export type Props = PinInputProps;\n export type StylesNames = PinInputStylesNames;\n export type Factory = PinInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ;CACZ,QAAQ;CACR,cAAc;CACf;AA2GD,MAAM,eAAe;CACnB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CACb,MAAM;CACN,WAAW;CACX,MAAM;CACP;AAED,MAAM,eAAe,oBAAqC,GAAG,EAAE,YAAY,EACzE,MAAM,EACJ,oBAAoB,QAAQ,QAAQ,MAAM,iBAAiB,EAC5D,EACF,EAAE;AAEH,MAAa,WAAW,SAA0B,UAAU;CAC1D,MAAM,EACJ,MACA,MACA,WACA,OACA,cACA,SACA,KACA,OACA,MACA,YACA,QACA,UACA,QACA,UACA,YACA,aACA,WACA,OACA,QACA,UACA,aACA,aACA,M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AA,CACE,oBAAC,OAAD;EACE,GAAI;EACJ,GAAI,UAAU,OAAO;EACrB,KAAK;EACL,MAAK;EACL,IAAI;EACC;EACK;EACV,MAAK;EACI;EACT,QAAQ;EACR,KAAI;YAEH,aAAa,KAAK,MAAc,UAC/B,8BAAC,OAAD;GACE,WAAU;GACV,GAAI,UAAU,YAAY,EACxB,OAAO;IACL,mBAAmB;IACnB,sBAAsB;IACvB,EACF,CAAC;GACF,YAAY;GACZ,QAAQ;GACF;GACN,kBAAiB;GACjB,IAAI,GAAG,KAAK,GAAG,QAAQ;GACvB,KAAK,GAAG,KAAK,GAAG;GAChB,WAAW,cAAc,SAAS,WAAW,YAAY;GACzD,WAAW,UAAU,aAAa,OAAO,MAAM;GAC/C,YAAY,UAAU,cAAc,OAAO,MAAM;GACjD,UAAU,UAAU,YAAY,OAAO,MAAM;GAC7C,QAAQ;GACR,SAAS;GACT,MAAM,cAAc,OAAO,aAAa,SAAS,WAAW,QAAQ;GAC5D;GACD;GACE;GACC;GACV,MAAM,SAAS;AACb,QAAI,MAAM;AACR,eAAU,KAAK,UAAU,KAAK,KAAK;AACnC,eAAU,QAAQ,SAAS;;;GAG/B,cAAc,cAAc,kBAAkB;GAC9C,aAAa,iBAAiB,QAAQ,KAAK;GAC3C,OAAO;GACP,WAAW,aAAa,UAAU;GACxB;GACV,cAAY;GACF;GACV,GAAI,gBAAgB,MAAM;GAC1B,CAAA,CACF;EACI,CAAA,EAER,oBAAC,SAAD;EAAO,MAAK;EAAe;EAAY;EAAM,OAAO;EAAgB,GAAI;EAAoB,CAAA,CAC3F,EAAA,CAAA;EAEL;AAEF,SAAS,UAAU;CAAE,GAAGC;CAAS,GAAG,UAAU;CAAS;AACvD,SAAS,eAAe;AACxB,SAAS,cAAc"}
@@ -205,6 +205,15 @@ Popover.Dropdown = PopoverDropdown;
205
205
  Popover.varsResolver = varsResolver;
206
206
  Popover.displayName = "@mantine/core/Popover";
207
207
  Popover.extend = (input) => input;
208
+ Popover.withProps = (fixedProps) => {
209
+ const Extended = (props) => /* @__PURE__ */ jsx(Popover, {
210
+ ...fixedProps,
211
+ ...props
212
+ });
213
+ Extended.extend = Popover.extend;
214
+ Extended.displayName = `WithProps(${Popover.displayName})`;
215
+ return Extended;
216
+ };
208
217
  //#endregion
209
218
  export { Popover };
210
219
 
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.mjs","names":["useId"],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { useClickOutside, useId } from '@mantine/hooks';\nimport {\n createVarsResolver,\n ElementProps,\n ExtendComponent,\n Factory,\n getDefaultZIndex,\n getRadius,\n getShadow,\n MantineRadius,\n MantineShadow,\n StylesApiProps,\n useDirection,\n useMantineEnv,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n ArrowPosition,\n FloatingAxesOffsets,\n FloatingPosition,\n FloatingStrategy,\n getFloatingPosition,\n} from '../../utils/Floating';\nimport { Overlay, OverlayProps } from '../Overlay';\nimport { BasePortalProps, OptionalPortal } from '../Portal';\nimport { Transition, TransitionOverride } from '../Transition';\nimport { PopoverContextProvider, PopoverContextValue } from './Popover.context';\nimport { PopoverMiddlewares, PopoverWidth } from './Popover.types';\nimport { PopoverDropdown, PopoverDropdownProps } from './PopoverDropdown/PopoverDropdown';\nimport { PopoverTarget, PopoverTargetProps } from './PopoverTarget/PopoverTarget';\nimport { usePopover } from './use-popover';\nimport classes from './Popover.module.css';\n\nexport type PopoverStylesNames = 'dropdown' | 'arrow' | 'overlay';\nexport type PopoverCssVariables = {\n dropdown: '--popover-radius' | '--popover-shadow';\n};\n\nexport interface __PopoverProps {\n /** Dropdown position relative to the target element @default 'bottom' */\n position?: FloatingPosition;\n\n /** Offset of the dropdown element @default 8 */\n offset?: number | FloatingAxesOffsets;\n\n /** Called when dropdown position changes */\n onPositionChange?: (position: FloatingPosition) => void;\n\n /** Called when dropdown closes */\n onClose?: () => void;\n\n /** Called when the popover is dismissed by clicking outside or by pressing escape */\n onDismiss?: () => void;\n\n /** Called when dropdown opens */\n onOpen?: () => void;\n\n /** If set, the dropdown is not unmounted from the DOM when hidden. `display: none` styles are added instead. */\n keepMounted?: boolean;\n\n /** Props passed down to the `Transition` component. Use to configure duration and animation type. @default { duration: 150, transition: 'fade' } */\n transitionProps?: TransitionOverride;\n\n /** Called when exit transition ends */\n onExitTransitionEnd?: () => void;\n\n /** Called when enter transition ends */\n onEnterTransitionEnd?: () => void;\n\n /** Dropdown width, or `'target'` to make dropdown width the same as target element @default 'max-content' */\n width?: PopoverWidth;\n\n /** Floating ui middlewares to configure position handling @default { flip: true, shift: true, inline: false } */\n middlewares?: PopoverMiddlewares;\n\n /** Determines whether component should have an arrow @default false */\n withArrow?: boolean;\n\n /** Determines whether the overlay should be displayed when the dropdown is opened @default false */\n withOverlay?: boolean;\n\n /** Props passed down to `Overlay` component */\n overlayProps?: OverlayProps & ElementProps<'div'>;\n\n /** Arrow size in px @default 7 */\n arrowSize?: number;\n\n /** Arrow offset in px @default 5 */\n arrowOffset?: number;\n\n /** Arrow `border-radius` in px @default 0 */\n arrowRadius?: number;\n\n /** Arrow position */\n arrowPosition?: ArrowPosition;\n\n /** Determines whether dropdown should be rendered within the `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the `Portal` when `withinPortal` is true */\n portalProps?: BasePortalProps;\n\n /** Dropdown `z-index` @default 300 */\n zIndex?: string | number;\n\n /** Key of `theme.radius` or any valid CSS value to set border-radius @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Key of `theme.shadows` or any other valid CSS `box-shadow` value */\n shadow?: MantineShadow;\n\n /** If set, popover dropdown will not be rendered */\n disabled?: boolean;\n\n /** Determines whether focus should be automatically returned to control when dropdown closes @default false */\n returnFocus?: boolean;\n\n /** Changes floating ui [position strategy](https://floating-ui.com/docs/usefloating#strategy) @default 'absolute' */\n floatingStrategy?: FloatingStrategy;\n\n /** If set, the dropdown is hidden when the element is hidden with styles or not visible on the screen @default true */\n hideDetached?: boolean;\n\n /** Prevents popover from flipping/shifting when it the dropdown is visible */\n preventPositionChangeWhenVisible?: boolean;\n}\n\nexport interface PopoverProps extends __PopoverProps, StylesApiProps<PopoverFactory> {\n __staticSelector?: string;\n\n /** `Popover.Target` and `Popover.Dropdown` components */\n children?: React.ReactNode;\n\n /** Initial opened state for uncontrolled component */\n defaultOpened?: boolean;\n\n /** Controlled dropdown opened state */\n opened?: boolean;\n\n /** Called with current state when dropdown opens or closes */\n onChange?: (opened: boolean) => void;\n\n /** Determines whether dropdown should be closed on outside clicks @default true */\n closeOnClickOutside?: boolean;\n\n /** Events that trigger outside clicks */\n clickOutsideEvents?: string[];\n\n /** Determines whether focus should be trapped within dropdown @default false */\n trapFocus?: boolean;\n\n /** Determines whether dropdown should be closed when `Escape` key is pressed @default true */\n closeOnEscape?: boolean;\n\n /** Id base to create accessibility connections */\n id?: string;\n\n /** Determines whether dropdown and target elements should have accessible roles @default true */\n withRoles?: boolean;\n}\n\nexport type PopoverFactory = Factory<{\n props: PopoverProps;\n stylesNames: PopoverStylesNames;\n vars: PopoverCssVariables;\n}>;\n\nconst defaultProps = {\n position: 'bottom',\n offset: 8,\n transitionProps: { transition: 'fade', duration: 150 },\n middlewares: { flip: true, shift: true, inline: false },\n arrowSize: 7,\n arrowOffset: 5,\n arrowRadius: 0,\n arrowPosition: 'side',\n closeOnClickOutside: true,\n withinPortal: true,\n closeOnEscape: true,\n trapFocus: false,\n withRoles: true,\n returnFocus: false,\n withOverlay: false,\n hideDetached: true,\n clickOutsideEvents: ['mousedown', 'touchstart'],\n zIndex: getDefaultZIndex('popover'),\n __staticSelector: 'Popover',\n width: 'max-content',\n} satisfies Partial<PopoverProps>;\n\nconst varsResolver = createVarsResolver<PopoverFactory>((_, { radius, shadow }) => ({\n dropdown: {\n '--popover-radius': radius === undefined ? undefined : getRadius(radius),\n '--popover-shadow': getShadow(shadow),\n },\n}));\n\nexport function Popover(_props: PopoverProps) {\n const props = useProps('Popover', defaultProps, _props);\n const {\n children,\n position,\n offset,\n onPositionChange,\n opened,\n transitionProps,\n onExitTransitionEnd,\n onEnterTransitionEnd,\n width,\n middlewares,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n unstyled,\n classNames,\n styles,\n closeOnClickOutside,\n withinPortal,\n portalProps,\n closeOnEscape,\n clickOutsideEvents,\n trapFocus,\n onClose,\n onDismiss,\n onOpen,\n onChange,\n zIndex,\n radius,\n shadow,\n id,\n defaultOpened,\n __staticSelector,\n withRoles,\n disabled,\n returnFocus,\n variant,\n keepMounted,\n vars,\n floatingStrategy,\n withOverlay,\n overlayProps,\n hideDetached,\n attributes,\n preventPositionChangeWhenVisible,\n ...others\n } = props;\n\n const getStyles = useStyles<PopoverFactory>({\n name: __staticSelector,\n props,\n classes,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'dropdown',\n vars,\n varsResolver,\n });\n\n const { resolvedStyles } = useResolvedStylesApi<PopoverFactory>({ classNames, styles, props });\n\n const [dropdownVisible, setDropdownVisible] = useState(opened ?? defaultOpened ?? false);\n const positionRef = useRef<FloatingPosition>(position);\n const arrowRef = useRef<HTMLDivElement | null>(null);\n const [targetNode, setTargetNode] = useState<HTMLElement | null>(null);\n const [dropdownNode, setDropdownNode] = useState<HTMLElement | null>(null);\n const { dir } = useDirection();\n const env = useMantineEnv();\n\n const uid = useId(id);\n const popover = usePopover({\n middlewares,\n width,\n position: getFloatingPosition(dir, position),\n offset: typeof offset === 'number' ? offset + (withArrow ? arrowSize / 2 : 0) : offset,\n arrowRef,\n arrowOffset,\n onPositionChange,\n opened,\n defaultOpened,\n onChange,\n onOpen,\n onClose,\n onDismiss,\n strategy: floatingStrategy,\n dropdownVisible,\n setDropdownVisible,\n positionRef,\n disabled,\n preventPositionChangeWhenVisible,\n keepMounted,\n });\n\n useClickOutside(\n () => {\n if (closeOnClickOutside) {\n popover.onClose();\n onDismiss?.();\n }\n },\n clickOutsideEvents,\n [targetNode, dropdownNode]\n );\n\n const reference = useCallback(\n (node: HTMLElement) => {\n setTargetNode(node);\n popover.floating.refs.setReference(node);\n },\n [popover.floating.refs.setReference]\n );\n\n const floating = useCallback(\n (node: HTMLElement) => {\n setDropdownNode(node);\n popover.floating.refs.setFloating(node);\n },\n [popover.floating.refs.setFloating]\n );\n\n const onExited = useCallback(() => {\n transitionProps?.onExited?.();\n onExitTransitionEnd?.();\n setDropdownVisible(false);\n // Only reset position if preventPositionChangeWhenVisible is false\n // to maintain the flipped position on subsequent opens\n if (!preventPositionChangeWhenVisible) {\n positionRef.current = position;\n }\n }, [transitionProps?.onExited, onExitTransitionEnd, preventPositionChangeWhenVisible, position]);\n\n const onEntered = useCallback(() => {\n transitionProps?.onEntered?.();\n onEnterTransitionEnd?.();\n }, [transitionProps?.onEntered, onEnterTransitionEnd]);\n\n return (\n <PopoverContextProvider\n value={{\n returnFocus,\n disabled,\n controlled: popover.controlled,\n reference,\n floating,\n x: popover.floating.x,\n y: popover.floating.y,\n arrowX: popover.floating?.middlewareData?.arrow?.x,\n arrowY: popover.floating?.middlewareData?.arrow?.y,\n opened: popover.opened,\n arrowRef,\n transitionProps: { ...transitionProps, onExited, onEntered },\n width,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n placement: popover.floating.placement,\n trapFocus,\n withinPortal,\n portalProps,\n zIndex,\n radius,\n shadow,\n closeOnEscape,\n onDismiss,\n onClose: popover.onClose,\n onToggle: popover.onToggle,\n getTargetId: () => uid,\n getDropdownId: () => `${uid}-dropdown`,\n withRoles,\n targetProps: others,\n __staticSelector,\n classNames,\n styles,\n unstyled,\n variant,\n keepMounted,\n getStyles,\n resolvedStyles,\n floatingStrategy,\n referenceHidden:\n hideDetached && env !== 'test'\n ? popover.floating.middlewareData.hide?.referenceHidden\n : false,\n }}\n >\n {children}\n {withOverlay && (\n <Transition\n transition=\"fade\"\n mounted={popover.opened}\n duration={transitionProps?.duration || 250}\n exitDuration={transitionProps?.exitDuration || 250}\n >\n {(transitionStyles) => (\n <OptionalPortal withinPortal={withinPortal}>\n <Overlay\n {...overlayProps}\n {...getStyles('overlay', {\n className: overlayProps?.className,\n style: [transitionStyles, overlayProps?.style],\n })}\n />\n </OptionalPortal>\n )}\n </Transition>\n )}\n </PopoverContextProvider>\n );\n}\n\nPopover.Target = PopoverTarget;\nPopover.Dropdown = PopoverDropdown;\nPopover.varsResolver = varsResolver;\nPopover.displayName = '@mantine/core/Popover';\nPopover.extend = (input: ExtendComponent<PopoverFactory>) => input;\n\nexport namespace Popover {\n export type Props = PopoverProps;\n export type __Props = __PopoverProps;\n export type Factory = PopoverFactory;\n export type StylesNames = PopoverStylesNames;\n export type TargetProps = PopoverTargetProps;\n export type DropdownProps = PopoverDropdownProps;\n export type Width = PopoverWidth;\n export type ContextValue = PopoverContextValue;\n\n export namespace Target {\n export type Props = PopoverTargetProps;\n }\n\n export namespace Dropdown {\n export type Props = PopoverDropdownProps;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0KA,MAAM,eAAe;CACnB,UAAU;CACV,QAAQ;CACR,iBAAiB;EAAE,YAAY;EAAQ,UAAU;EAAK;CACtD,aAAa;EAAE,MAAM;EAAM,OAAO;EAAM,QAAQ;EAAO;CACvD,WAAW;CACX,aAAa;CACb,aAAa;CACb,eAAe;CACf,qBAAqB;CACrB,cAAc;CACd,eAAe;CACf,WAAW;CACX,WAAW;CACX,aAAa;CACb,aAAa;CACb,cAAc;CACd,oBAAoB,CAAC,aAAa,aAAa;CAC/C,QAAQ,iBAAiB,UAAU;CACnC,kBAAkB;CAClB,OAAO;CACR;AAED,MAAM,eAAe,oBAAoC,GAAG,EAAE,QAAQ,cAAc,EAClF,UAAU;CACR,oBAAoB,WAAW,KAAA,IAAY,KAAA,IAAY,UAAU,OAAO;CACxE,oBAAoB,UAAU,OAAO;CACtC,EACF,EAAE;AAEH,SAAgB,QAAQ,QAAsB;CAC5C,MAAM,QAAQ,SAAS,WAAW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Ac,MAAM;MAC/C,CAAC;KACF,CAAA;IACa,CAAA;GAER,CAAA,CAEQ;;;AAI7B,QAAQ,SAAS;AACjB,QAAQ,WAAW;AACnB,QAAQ,eAAe;AACvB,QAAQ,cAAc;AACtB,QAAQ,UAAU,UAA2C"}
1
+ {"version":3,"file":"Popover.mjs","names":["useId"],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { useClickOutside, useId } from '@mantine/hooks';\nimport {\n createVarsResolver,\n ElementProps,\n ExtendComponent,\n Factory,\n getDefaultZIndex,\n getRadius,\n getShadow,\n MantineRadius,\n MantineShadow,\n StylesApiProps,\n useDirection,\n useMantineEnv,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n ArrowPosition,\n FloatingAxesOffsets,\n FloatingPosition,\n FloatingStrategy,\n getFloatingPosition,\n} from '../../utils/Floating';\nimport { Overlay, OverlayProps } from '../Overlay';\nimport { BasePortalProps, OptionalPortal } from '../Portal';\nimport { Transition, TransitionOverride } from '../Transition';\nimport { PopoverContextProvider, PopoverContextValue } from './Popover.context';\nimport { PopoverMiddlewares, PopoverWidth } from './Popover.types';\nimport { PopoverDropdown, PopoverDropdownProps } from './PopoverDropdown/PopoverDropdown';\nimport { PopoverTarget, PopoverTargetProps } from './PopoverTarget/PopoverTarget';\nimport { usePopover } from './use-popover';\nimport classes from './Popover.module.css';\n\nexport type PopoverStylesNames = 'dropdown' | 'arrow' | 'overlay';\nexport type PopoverCssVariables = {\n dropdown: '--popover-radius' | '--popover-shadow';\n};\n\nexport interface __PopoverProps {\n /** Dropdown position relative to the target element @default 'bottom' */\n position?: FloatingPosition;\n\n /** Offset of the dropdown element @default 8 */\n offset?: number | FloatingAxesOffsets;\n\n /** Called when dropdown position changes */\n onPositionChange?: (position: FloatingPosition) => void;\n\n /** Called when dropdown closes */\n onClose?: () => void;\n\n /** Called when the popover is dismissed by clicking outside or by pressing escape */\n onDismiss?: () => void;\n\n /** Called when dropdown opens */\n onOpen?: () => void;\n\n /** If set, the dropdown is not unmounted from the DOM when hidden. `display: none` styles are added instead. */\n keepMounted?: boolean;\n\n /** Props passed down to the `Transition` component. Use to configure duration and animation type. @default { duration: 150, transition: 'fade' } */\n transitionProps?: TransitionOverride;\n\n /** Called when exit transition ends */\n onExitTransitionEnd?: () => void;\n\n /** Called when enter transition ends */\n onEnterTransitionEnd?: () => void;\n\n /** Dropdown width, or `'target'` to make dropdown width the same as target element @default 'max-content' */\n width?: PopoverWidth;\n\n /** Floating ui middlewares to configure position handling @default { flip: true, shift: true, inline: false } */\n middlewares?: PopoverMiddlewares;\n\n /** Determines whether component should have an arrow @default false */\n withArrow?: boolean;\n\n /** Determines whether the overlay should be displayed when the dropdown is opened @default false */\n withOverlay?: boolean;\n\n /** Props passed down to `Overlay` component */\n overlayProps?: OverlayProps & ElementProps<'div'>;\n\n /** Arrow size in px @default 7 */\n arrowSize?: number;\n\n /** Arrow offset in px @default 5 */\n arrowOffset?: number;\n\n /** Arrow `border-radius` in px @default 0 */\n arrowRadius?: number;\n\n /** Arrow position */\n arrowPosition?: ArrowPosition;\n\n /** Determines whether dropdown should be rendered within the `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the `Portal` when `withinPortal` is true */\n portalProps?: BasePortalProps;\n\n /** Dropdown `z-index` @default 300 */\n zIndex?: string | number;\n\n /** Key of `theme.radius` or any valid CSS value to set border-radius @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Key of `theme.shadows` or any other valid CSS `box-shadow` value */\n shadow?: MantineShadow;\n\n /** If set, popover dropdown will not be rendered */\n disabled?: boolean;\n\n /** Determines whether focus should be automatically returned to control when dropdown closes @default false */\n returnFocus?: boolean;\n\n /** Changes floating ui [position strategy](https://floating-ui.com/docs/usefloating#strategy) @default 'absolute' */\n floatingStrategy?: FloatingStrategy;\n\n /** If set, the dropdown is hidden when the element is hidden with styles or not visible on the screen @default true */\n hideDetached?: boolean;\n\n /** Prevents popover from flipping/shifting when it the dropdown is visible */\n preventPositionChangeWhenVisible?: boolean;\n}\n\nexport interface PopoverProps extends __PopoverProps, StylesApiProps<PopoverFactory> {\n __staticSelector?: string;\n\n /** `Popover.Target` and `Popover.Dropdown` components */\n children?: React.ReactNode;\n\n /** Initial opened state for uncontrolled component */\n defaultOpened?: boolean;\n\n /** Controlled dropdown opened state */\n opened?: boolean;\n\n /** Called with current state when dropdown opens or closes */\n onChange?: (opened: boolean) => void;\n\n /** Determines whether dropdown should be closed on outside clicks @default true */\n closeOnClickOutside?: boolean;\n\n /** Events that trigger outside clicks */\n clickOutsideEvents?: string[];\n\n /** Determines whether focus should be trapped within dropdown @default false */\n trapFocus?: boolean;\n\n /** Determines whether dropdown should be closed when `Escape` key is pressed @default true */\n closeOnEscape?: boolean;\n\n /** Id base to create accessibility connections */\n id?: string;\n\n /** Determines whether dropdown and target elements should have accessible roles @default true */\n withRoles?: boolean;\n}\n\nexport type PopoverFactory = Factory<{\n props: PopoverProps;\n stylesNames: PopoverStylesNames;\n vars: PopoverCssVariables;\n}>;\n\nconst defaultProps = {\n position: 'bottom',\n offset: 8,\n transitionProps: { transition: 'fade', duration: 150 },\n middlewares: { flip: true, shift: true, inline: false },\n arrowSize: 7,\n arrowOffset: 5,\n arrowRadius: 0,\n arrowPosition: 'side',\n closeOnClickOutside: true,\n withinPortal: true,\n closeOnEscape: true,\n trapFocus: false,\n withRoles: true,\n returnFocus: false,\n withOverlay: false,\n hideDetached: true,\n clickOutsideEvents: ['mousedown', 'touchstart'],\n zIndex: getDefaultZIndex('popover'),\n __staticSelector: 'Popover',\n width: 'max-content',\n} satisfies Partial<PopoverProps>;\n\nconst varsResolver = createVarsResolver<PopoverFactory>((_, { radius, shadow }) => ({\n dropdown: {\n '--popover-radius': radius === undefined ? undefined : getRadius(radius),\n '--popover-shadow': getShadow(shadow),\n },\n}));\n\nexport function Popover(_props: PopoverProps) {\n const props = useProps('Popover', defaultProps, _props);\n const {\n children,\n position,\n offset,\n onPositionChange,\n opened,\n transitionProps,\n onExitTransitionEnd,\n onEnterTransitionEnd,\n width,\n middlewares,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n unstyled,\n classNames,\n styles,\n closeOnClickOutside,\n withinPortal,\n portalProps,\n closeOnEscape,\n clickOutsideEvents,\n trapFocus,\n onClose,\n onDismiss,\n onOpen,\n onChange,\n zIndex,\n radius,\n shadow,\n id,\n defaultOpened,\n __staticSelector,\n withRoles,\n disabled,\n returnFocus,\n variant,\n keepMounted,\n vars,\n floatingStrategy,\n withOverlay,\n overlayProps,\n hideDetached,\n attributes,\n preventPositionChangeWhenVisible,\n ...others\n } = props;\n\n const getStyles = useStyles<PopoverFactory>({\n name: __staticSelector,\n props,\n classes,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'dropdown',\n vars,\n varsResolver,\n });\n\n const { resolvedStyles } = useResolvedStylesApi<PopoverFactory>({ classNames, styles, props });\n\n const [dropdownVisible, setDropdownVisible] = useState(opened ?? defaultOpened ?? false);\n const positionRef = useRef<FloatingPosition>(position);\n const arrowRef = useRef<HTMLDivElement | null>(null);\n const [targetNode, setTargetNode] = useState<HTMLElement | null>(null);\n const [dropdownNode, setDropdownNode] = useState<HTMLElement | null>(null);\n const { dir } = useDirection();\n const env = useMantineEnv();\n\n const uid = useId(id);\n const popover = usePopover({\n middlewares,\n width,\n position: getFloatingPosition(dir, position),\n offset: typeof offset === 'number' ? offset + (withArrow ? arrowSize / 2 : 0) : offset,\n arrowRef,\n arrowOffset,\n onPositionChange,\n opened,\n defaultOpened,\n onChange,\n onOpen,\n onClose,\n onDismiss,\n strategy: floatingStrategy,\n dropdownVisible,\n setDropdownVisible,\n positionRef,\n disabled,\n preventPositionChangeWhenVisible,\n keepMounted,\n });\n\n useClickOutside(\n () => {\n if (closeOnClickOutside) {\n popover.onClose();\n onDismiss?.();\n }\n },\n clickOutsideEvents,\n [targetNode, dropdownNode]\n );\n\n const reference = useCallback(\n (node: HTMLElement) => {\n setTargetNode(node);\n popover.floating.refs.setReference(node);\n },\n [popover.floating.refs.setReference]\n );\n\n const floating = useCallback(\n (node: HTMLElement) => {\n setDropdownNode(node);\n popover.floating.refs.setFloating(node);\n },\n [popover.floating.refs.setFloating]\n );\n\n const onExited = useCallback(() => {\n transitionProps?.onExited?.();\n onExitTransitionEnd?.();\n setDropdownVisible(false);\n // Only reset position if preventPositionChangeWhenVisible is false\n // to maintain the flipped position on subsequent opens\n if (!preventPositionChangeWhenVisible) {\n positionRef.current = position;\n }\n }, [transitionProps?.onExited, onExitTransitionEnd, preventPositionChangeWhenVisible, position]);\n\n const onEntered = useCallback(() => {\n transitionProps?.onEntered?.();\n onEnterTransitionEnd?.();\n }, [transitionProps?.onEntered, onEnterTransitionEnd]);\n\n return (\n <PopoverContextProvider\n value={{\n returnFocus,\n disabled,\n controlled: popover.controlled,\n reference,\n floating,\n x: popover.floating.x,\n y: popover.floating.y,\n arrowX: popover.floating?.middlewareData?.arrow?.x,\n arrowY: popover.floating?.middlewareData?.arrow?.y,\n opened: popover.opened,\n arrowRef,\n transitionProps: { ...transitionProps, onExited, onEntered },\n width,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n placement: popover.floating.placement,\n trapFocus,\n withinPortal,\n portalProps,\n zIndex,\n radius,\n shadow,\n closeOnEscape,\n onDismiss,\n onClose: popover.onClose,\n onToggle: popover.onToggle,\n getTargetId: () => uid,\n getDropdownId: () => `${uid}-dropdown`,\n withRoles,\n targetProps: others,\n __staticSelector,\n classNames,\n styles,\n unstyled,\n variant,\n keepMounted,\n getStyles,\n resolvedStyles,\n floatingStrategy,\n referenceHidden:\n hideDetached && env !== 'test'\n ? popover.floating.middlewareData.hide?.referenceHidden\n : false,\n }}\n >\n {children}\n {withOverlay && (\n <Transition\n transition=\"fade\"\n mounted={popover.opened}\n duration={transitionProps?.duration || 250}\n exitDuration={transitionProps?.exitDuration || 250}\n >\n {(transitionStyles) => (\n <OptionalPortal withinPortal={withinPortal}>\n <Overlay\n {...overlayProps}\n {...getStyles('overlay', {\n className: overlayProps?.className,\n style: [transitionStyles, overlayProps?.style],\n })}\n />\n </OptionalPortal>\n )}\n </Transition>\n )}\n </PopoverContextProvider>\n );\n}\n\nPopover.Target = PopoverTarget;\nPopover.Dropdown = PopoverDropdown;\nPopover.varsResolver = varsResolver;\nPopover.displayName = '@mantine/core/Popover';\nPopover.extend = (input: ExtendComponent<PopoverFactory>) => input;\nPopover.withProps = (fixedProps: Partial<PopoverProps>) => {\n const Extended = (props: PopoverProps) => <Popover {...fixedProps} {...props} />;\n Extended.extend = Popover.extend;\n Extended.displayName = `WithProps(${Popover.displayName})`;\n return Extended;\n};\n\nexport namespace Popover {\n export type Props = PopoverProps;\n export type __Props = __PopoverProps;\n export type Factory = PopoverFactory;\n export type StylesNames = PopoverStylesNames;\n export type TargetProps = PopoverTargetProps;\n export type DropdownProps = PopoverDropdownProps;\n export type Width = PopoverWidth;\n export type ContextValue = PopoverContextValue;\n\n export namespace Target {\n export type Props = PopoverTargetProps;\n }\n\n export namespace Dropdown {\n export type Props = PopoverDropdownProps;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0KA,MAAM,eAAe;CACnB,UAAU;CACV,QAAQ;CACR,iBAAiB;EAAE,YAAY;EAAQ,UAAU;EAAK;CACtD,aAAa;EAAE,MAAM;EAAM,OAAO;EAAM,QAAQ;EAAO;CACvD,WAAW;CACX,aAAa;CACb,aAAa;CACb,eAAe;CACf,qBAAqB;CACrB,cAAc;CACd,eAAe;CACf,WAAW;CACX,WAAW;CACX,aAAa;CACb,aAAa;CACb,cAAc;CACd,oBAAoB,CAAC,aAAa,aAAa;CAC/C,QAAQ,iBAAiB,UAAU;CACnC,kBAAkB;CAClB,OAAO;CACR;AAED,MAAM,eAAe,oBAAoC,GAAG,EAAE,QAAQ,cAAc,EAClF,UAAU;CACR,oBAAoB,WAAW,KAAA,IAAY,KAAA,IAAY,UAAU,OAA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B;cAC5B,oBAAC,SAAD;KACE,GAAI;KACJ,GAAI,UAAU,WAAW;MACvB,WAAW,cAAc;MACzB,OAAO,CAAC,kBAAkB,cAAc,MAAM;MAC/C,CAAC;KACF,CAAA;IACa,CAAA;GAER,CAAA,CAEQ;;;AAI7B,QAAQ,SAAS;AACjB,QAAQ,WAAW;AACnB,QAAQ,eAAe;AACvB,QAAQ,cAAc;AACtB,QAAQ,UAAU,UAA2C;AAC7D,QAAQ,aAAa,eAAsC;CACzD,MAAM,YAAY,UAAwB,oBAAC,SAAD;EAAS,GAAI;EAAY,GAAI;EAAS,CAAA;AAChF,UAAS,SAAS,QAAQ;AAC1B,UAAS,cAAc,aAAa,QAAQ,YAAY;AACxD,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"OptionalPortal.mjs","names":[],"sources":["../../../src/components/Portal/OptionalPortal.tsx"],"sourcesContent":["import { factory, Factory, useMantineEnv } from '../../core';\nimport { Portal, PortalProps } from './Portal';\n\nexport interface OptionalPortalProps extends PortalProps {\n /**\n * Determines whether children should be rendered inside Portal.\n * When false, children are rendered as regular React children.\n *\n * Note: In test environment, Portal is always disabled regardless of this value.\n *\n * @default true\n */\n withinPortal?: boolean;\n}\n\nexport type OptionalPortalFactory = Factory<{\n props: OptionalPortalProps;\n ref: HTMLDivElement;\n}>;\n\nexport const OptionalPortal = factory<OptionalPortalFactory>(\n ({ withinPortal = true, children, ...others }) => {\n const env = useMantineEnv();\n\n if (env === 'test' || !withinPortal) {\n return <>{children}</>;\n }\n\n return <Portal {...others}>{children}</Portal>;\n }\n);\n\nOptionalPortal.displayName = '@mantine/core/OptionalPortal';\n"],"mappings":";;;;;;AAoBA,MAAa,iBAAiB,SAC3B,EAAE,eAAe,MAAM,UAAU,GAAG,aAAa;AAGhD,KAFY,eAAe,KAEf,UAAU,CAAC,aACrB,QAAO,oBAAA,UAAA,EAAG,UAAY,CAAA;AAGxB,QAAO,oBAAC,QAAD;EAAQ,GAAI;EAAS;EAAkB,CAAA;EAEjD;AAED,eAAe,cAAc"}
1
+ {"version":3,"file":"OptionalPortal.mjs","names":[],"sources":["../../../src/components/Portal/OptionalPortal.tsx"],"sourcesContent":["import { factory, Factory, useMantineEnv } from '../../core';\nimport { Portal, PortalProps } from './Portal';\n\nexport interface OptionalPortalProps extends PortalProps {\n /**\n * Determines whether children should be rendered inside Portal.\n * When false, children are rendered as regular React children.\n *\n * Note: In test environment, Portal is always disabled regardless of this value.\n *\n * @default true\n */\n withinPortal?: boolean;\n}\n\nexport type OptionalPortalFactory = Factory<{\n props: OptionalPortalProps;\n ref: HTMLDivElement;\n}>;\n\nexport const OptionalPortal = factory<OptionalPortalFactory>(\n ({ withinPortal = true, children, ...others }) => {\n const env = useMantineEnv();\n\n if (env === 'test' || !withinPortal) {\n return <>{children}</>;\n }\n\n return <Portal {...others}>{children}</Portal>;\n }\n);\n\nOptionalPortal.displayName = '@mantine/core/OptionalPortal';\n\nexport namespace OptionalPortal {\n export type Props = OptionalPortalProps;\n}\n"],"mappings":";;;;;;AAoBA,MAAa,iBAAiB,SAC3B,EAAE,eAAe,MAAM,UAAU,GAAG,aAAa;AAGhD,KAFY,eAAe,KAEf,UAAU,CAAC,aACrB,QAAO,oBAAA,UAAA,EAAG,UAAY,CAAA;AAGxB,QAAO,oBAAC,QAAD;EAAQ,GAAI;EAAS;EAAkB,CAAA;EAEjD;AAED,eAAe,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.mjs","names":[],"sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { assignRef, useIsomorphicEffect } from '@mantine/hooks';\nimport { Factory, factory, useProps } from '../../core';\n\nfunction createPortalNode(props: React.ComponentProps<'div'>) {\n const node = document.createElement('div');\n node.setAttribute('data-portal', 'true');\n typeof props.className === 'string' &&\n node.classList.add(...props.className.split(' ').filter(Boolean));\n typeof props.style === 'object' && Object.assign(node.style, props.style);\n typeof props.id === 'string' && node.setAttribute('id', props.id);\n return node;\n}\n\nexport interface BasePortalProps extends React.ComponentProps<'div'> {\n /**\n * Target element where portal should be rendered. Accepts:\n * - HTMLElement: Renders portal inside this element\n * - string: CSS selector - renders inside first matching element\n * - undefined: Uses shared portal node or creates new one based on `reuseTargetNode`\n *\n * Note: If selector doesn't match any element, portal will not render\n */\n target?: HTMLElement | string;\n\n /**\n * When true and target is not specified, all Portal instances share a single\n * container node appended to document.body. When false, each Portal creates\n * its own container node.\n *\n * Has no effect when target is specified.\n *\n * @default true\n */\n reuseTargetNode?: boolean;\n}\n\nexport interface PortalProps extends BasePortalProps {\n /** Content to render inside the portal */\n children: React.ReactNode;\n}\n\nfunction getTargetNode({ target, reuseTargetNode, ...others }: BasePortalProps): HTMLElement {\n if (target) {\n if (typeof target === 'string') {\n return document.querySelector<HTMLElement>(target) || createPortalNode(others);\n }\n\n return target;\n }\n\n if (reuseTargetNode) {\n const existingNode = document.querySelector<HTMLElement>('[data-mantine-shared-portal-node]');\n\n if (existingNode) {\n return existingNode;\n }\n\n const node = createPortalNode(others);\n node.setAttribute('data-mantine-shared-portal-node', 'true');\n document.body.appendChild(node);\n return node;\n }\n\n return createPortalNode(others);\n}\n\nexport type PortalFactory = Factory<{\n props: PortalProps;\n ref: HTMLDivElement;\n}>;\n\nconst defaultProps = {\n reuseTargetNode: true,\n} satisfies Partial<PortalProps>;\n\nexport const Portal = factory<PortalFactory>((props) => {\n const { children, target, reuseTargetNode, ref, ...others } = useProps(\n 'Portal',\n defaultProps,\n props\n );\n\n const [mounted, setMounted] = useState(false);\n const nodeRef = useRef<HTMLElement | null>(null);\n\n useIsomorphicEffect(() => {\n setMounted(true);\n nodeRef.current = getTargetNode({ target, reuseTargetNode, ...others });\n assignRef(ref, nodeRef.current);\n\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.appendChild(nodeRef.current);\n }\n\n return () => {\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.removeChild(nodeRef.current);\n }\n };\n }, [target]);\n\n if (!mounted || !nodeRef.current) {\n return null;\n }\n\n return createPortal(<>{children}</>, nodeRef.current);\n});\n\nPortal.displayName = '@mantine/core/Portal';\n"],"mappings":";;;;;;;;AAKA,SAAS,iBAAiB,OAAoC;CAC5D,MAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,MAAK,aAAa,eAAe,OAAO;AACxC,QAAO,MAAM,cAAc,YACzB,KAAK,UAAU,IAAI,GAAG,MAAM,UAAU,MAAM,IAAI,CAAC,OAAO,QAAQ,CAAC;AACnE,QAAO,MAAM,UAAU,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,MAAM;AACzE,QAAO,MAAM,OAAO,YAAY,KAAK,aAAa,MAAM,MAAM,GAAG;AACjE,QAAO;;AA+BT,SAAS,cAAc,EAAE,QAAQ,iBAAiB,GAAG,UAAwC;AAC3F,KAAI,QAAQ;AACV,MAAI,OAAO,WAAW,SACpB,QAAO,SAAS,cAA2B,OAAO,IAAI,iBAAiB,OAAO;AAGhF,SAAO;;AAGT,KAAI,iBAAiB;EACnB,MAAM,eAAe,SAAS,cAA2B,oCAAoC;AAE7F,MAAI,aACF,QAAO;EAGT,MAAM,OAAO,iBAAiB,OAAO;AACrC,OAAK,aAAa,mCAAmC,OAAO;AAC5D,WAAS,KAAK,YAAY,KAAK;AAC/B,SAAO;;AAGT,QAAO,iBAAiB,OAAO;;AAQjC,MAAM,eAAe,EACnB,iBAAiB,MAClB;AAED,MAAa,SAAS,SAAwB,UAAU;CACtD,MAAM,EAAE,UAAU,QAAQ,iBAAiB,KAAK,GAAG,WAAW,SAC5D,UACA,cACA,MACD;CAED,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAC7C,MAAM,UAAU,OAA2B,KAAK;AAEhD,2BAA0B;AACxB,aAAW,KAAK;AAChB,UAAQ,UAAU,cAAc;GAAE;GAAQ;GAAiB,GAAG;GAAQ,CAAC;AACvE,YAAU,KAAK,QAAQ,QAAQ;AAE/B,MAAI,CAAC,UAAU,CAAC,mBAAmB,QAAQ,QACzC,UAAS,KAAK,YAAY,QAAQ,QAAQ;AAG5C,eAAa;AACX,OAAI,CAAC,UAAU,CAAC,mBAAmB,QAAQ,QACzC,UAAS,KAAK,YAAY,QAAQ,QAAQ;;IAG7C,CAAC,OAAO,CAAC;AAEZ,KAAI,CAAC,WAAW,CAAC,QAAQ,QACvB,QAAO;AAGT,QAAO,aAAa,oBAAA,YAAA,EAAG,UAAY,CAAA,EAAE,QAAQ,QAAQ;EACrD;AAEF,OAAO,cAAc"}
1
+ {"version":3,"file":"Portal.mjs","names":[],"sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { assignRef, useIsomorphicEffect } from '@mantine/hooks';\nimport { Factory, factory, useProps } from '../../core';\n\nfunction createPortalNode(props: React.ComponentProps<'div'>) {\n const node = document.createElement('div');\n node.setAttribute('data-portal', 'true');\n typeof props.className === 'string' &&\n node.classList.add(...props.className.split(' ').filter(Boolean));\n typeof props.style === 'object' && Object.assign(node.style, props.style);\n typeof props.id === 'string' && node.setAttribute('id', props.id);\n return node;\n}\n\nexport interface BasePortalProps extends React.ComponentProps<'div'> {\n /**\n * Target element where portal should be rendered. Accepts:\n * - HTMLElement: Renders portal inside this element\n * - string: CSS selector - renders inside first matching element\n * - undefined: Uses shared portal node or creates new one based on `reuseTargetNode`\n *\n * Note: If selector doesn't match any element, portal will not render\n */\n target?: HTMLElement | string;\n\n /**\n * When true and target is not specified, all Portal instances share a single\n * container node appended to document.body. When false, each Portal creates\n * its own container node.\n *\n * Has no effect when target is specified.\n *\n * @default true\n */\n reuseTargetNode?: boolean;\n}\n\nexport interface PortalProps extends BasePortalProps {\n /** Content to render inside the portal */\n children: React.ReactNode;\n}\n\nfunction getTargetNode({ target, reuseTargetNode, ...others }: BasePortalProps): HTMLElement {\n if (target) {\n if (typeof target === 'string') {\n return document.querySelector<HTMLElement>(target) || createPortalNode(others);\n }\n\n return target;\n }\n\n if (reuseTargetNode) {\n const existingNode = document.querySelector<HTMLElement>('[data-mantine-shared-portal-node]');\n\n if (existingNode) {\n return existingNode;\n }\n\n const node = createPortalNode(others);\n node.setAttribute('data-mantine-shared-portal-node', 'true');\n document.body.appendChild(node);\n return node;\n }\n\n return createPortalNode(others);\n}\n\nexport type PortalFactory = Factory<{\n props: PortalProps;\n ref: HTMLDivElement;\n}>;\n\nconst defaultProps = {\n reuseTargetNode: true,\n} satisfies Partial<PortalProps>;\n\nexport const Portal = factory<PortalFactory>((props) => {\n const { children, target, reuseTargetNode, ref, ...others } = useProps(\n 'Portal',\n defaultProps,\n props\n );\n\n const [mounted, setMounted] = useState(false);\n const nodeRef = useRef<HTMLElement | null>(null);\n\n useIsomorphicEffect(() => {\n setMounted(true);\n nodeRef.current = getTargetNode({ target, reuseTargetNode, ...others });\n assignRef(ref, nodeRef.current);\n\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.appendChild(nodeRef.current);\n }\n\n return () => {\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.removeChild(nodeRef.current);\n }\n };\n }, [target]);\n\n if (!mounted || !nodeRef.current) {\n return null;\n }\n\n return createPortal(<>{children}</>, nodeRef.current);\n});\n\nPortal.displayName = '@mantine/core/Portal';\n\nexport namespace Portal {\n export type Props = PortalProps;\n}\n"],"mappings":";;;;;;;;AAKA,SAAS,iBAAiB,OAAoC;CAC5D,MAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,MAAK,aAAa,eAAe,OAAO;AACxC,QAAO,MAAM,cAAc,YACzB,KAAK,UAAU,IAAI,GAAG,MAAM,UAAU,MAAM,IAAI,CAAC,OAAO,QAAQ,CAAC;AACnE,QAAO,MAAM,UAAU,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,MAAM;AACzE,QAAO,MAAM,OAAO,YAAY,KAAK,aAAa,MAAM,MAAM,GAAG;AACjE,QAAO;;AA+BT,SAAS,cAAc,EAAE,QAAQ,iBAAiB,GAAG,UAAwC;AAC3F,KAAI,QAAQ;AACV,MAAI,OAAO,WAAW,SACpB,QAAO,SAAS,cAA2B,OAAO,IAAI,iBAAiB,OAAO;AAGhF,SAAO;;AAGT,KAAI,iBAAiB;EACnB,MAAM,eAAe,SAAS,cAA2B,oCAAoC;AAE7F,MAAI,aACF,QAAO;EAGT,MAAM,OAAO,iBAAiB,OAAO;AACrC,OAAK,aAAa,mCAAmC,OAAO;AAC5D,WAAS,KAAK,YAAY,KAAK;AAC/B,SAAO;;AAGT,QAAO,iBAAiB,OAAO;;AAQjC,MAAM,eAAe,EACnB,iBAAiB,MAClB;AAED,MAAa,SAAS,SAAwB,UAAU;CACtD,MAAM,EAAE,UAAU,QAAQ,iBAAiB,KAAK,GAAG,WAAW,SAC5D,UACA,cACA,MACD;CAED,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAC7C,MAAM,UAAU,OAA2B,KAAK;AAEhD,2BAA0B;AACxB,aAAW,KAAK;AAChB,UAAQ,UAAU,cAAc;GAAE;GAAQ;GAAiB,GAAG;GAAQ,CAAC;AACvE,YAAU,KAAK,QAAQ,QAAQ;AAE/B,MAAI,CAAC,UAAU,CAAC,mBAAmB,QAAQ,QACzC,UAAS,KAAK,YAAY,QAAQ,QAAQ;AAG5C,eAAa;AACX,OAAI,CAAC,UAAU,CAAC,mBAAmB,QAAQ,QACzC,UAAS,KAAK,YAAY,QAAQ,QAAQ;;IAG7C,CAAC,OAAO,CAAC;AAEZ,KAAI,CAAC,WAAW,CAAC,QAAQ,QACvB,QAAO;AAGT,QAAO,aAAa,oBAAA,YAAA,EAAG,UAAY,CAAA,EAAE,QAAQ,QAAQ;EACrD;AAEF,OAAO,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.mjs","names":["classes"],"sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["import {\n factory,\n Factory,\n MantineColor,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport { ProgressLabel } from './ProgressLabel/ProgressLabel';\nimport {\n __ProgressRootProps,\n ProgressRoot,\n ProgressRootCssVariables,\n ProgressRootStylesNames,\n} from './ProgressRoot/ProgressRoot';\nimport { ProgressSection } from './ProgressSection/ProgressSection';\nimport classes from './Progress.module.css';\n\nexport type ProgressStylesNames = ProgressRootStylesNames;\n\nexport interface ProgressProps extends __ProgressRootProps, StylesApiProps<ProgressFactory> {\n /** Value of the progress */\n value: number;\n\n /** Key of `theme.colors` or any valid CSS value @default theme.primaryColor */\n color?: MantineColor;\n\n /** If set, the section has stripes @default false */\n striped?: boolean;\n\n /** If set, the sections stripes are animated (automatically enables striped) @default false */\n animated?: boolean;\n}\n\nexport type ProgressFactory = Factory<{\n props: ProgressProps;\n ref: HTMLDivElement;\n stylesNames: ProgressStylesNames;\n vars: ProgressRootCssVariables;\n staticComponents: {\n Section: typeof ProgressSection;\n Root: typeof ProgressRoot;\n Label: typeof ProgressLabel;\n };\n}>;\n\nexport const Progress = factory<ProgressFactory>((_props) => {\n const props = useProps('Progress', null, _props);\n const {\n value,\n classNames,\n styles,\n vars,\n color,\n striped,\n animated,\n 'aria-label': label,\n ...others\n } = props;\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ProgressFactory>({\n classNames,\n styles,\n props,\n });\n\n return (\n <ProgressRoot\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n vars={vars as any}\n {...others}\n >\n <ProgressSection\n value={value}\n color={color}\n striped={striped}\n animated={animated}\n aria-label={label}\n />\n </ProgressRoot>\n );\n});\n\nProgress.classes = classes;\nProgress.displayName = '@mantine/core/Progress';\nProgress.Section = ProgressSection;\nProgress.Root = ProgressRoot;\nProgress.Label = ProgressLabel;\n"],"mappings":";;;;;;;;;;AA8CA,MAAa,WAAW,SAA0B,WAAW;CAC3D,MAAM,QAAQ,SAAS,YAAY,MAAM,OAAO;CAChD,MAAM,EACJ,OACA,YACA,QACA,MACA,OACA,SACA,UACA,cAAc,OACd,GAAG,WACD;CAEJ,MAAM,EAAE,oBAAoB,mBAAmB,qBAAsC;EACnF;EACA;EACA;EACD,CAAC;AAEF,QACE,oBAAC,cAAD;EACE,YAAY;EACZ,QAAQ;EACF;EACN,GAAI;YAEJ,oBAAC,iBAAD;GACS;GACA;GACE;GACC;GACV,cAAY;GACZ,CAAA;EACW,CAAA;EAEjB;AAEF,SAAS,UAAUA;AACnB,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,OAAO;AAChB,SAAS,QAAQ"}
1
+ {"version":3,"file":"Progress.mjs","names":["classes"],"sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["import {\n factory,\n Factory,\n MantineColor,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport { ProgressLabel, type ProgressLabelProps } from './ProgressLabel/ProgressLabel';\nimport {\n __ProgressRootProps,\n ProgressRoot,\n ProgressRootCssVariables,\n ProgressRootStylesNames,\n type ProgressRootProps,\n} from './ProgressRoot/ProgressRoot';\nimport { ProgressSection, type ProgressSectionProps } from './ProgressSection/ProgressSection';\nimport classes from './Progress.module.css';\nimport type { ProgressContextValue } from './Progress.context';\nexport type ProgressStylesNames = ProgressRootStylesNames;\n\nexport interface ProgressProps extends __ProgressRootProps, StylesApiProps<ProgressFactory> {\n /** Value of the progress */\n value: number;\n\n /** Key of `theme.colors` or any valid CSS value @default theme.primaryColor */\n color?: MantineColor;\n\n /** If set, the section has stripes @default false */\n striped?: boolean;\n\n /** If set, the sections stripes are animated (automatically enables striped) @default false */\n animated?: boolean;\n}\n\nexport type ProgressFactory = Factory<{\n props: ProgressProps;\n ref: HTMLDivElement;\n stylesNames: ProgressStylesNames;\n vars: ProgressRootCssVariables;\n staticComponents: {\n Section: typeof ProgressSection;\n Root: typeof ProgressRoot;\n Label: typeof ProgressLabel;\n };\n}>;\n\nexport const Progress = factory<ProgressFactory>((_props) => {\n const props = useProps('Progress', null, _props);\n const {\n value,\n classNames,\n styles,\n vars,\n color,\n striped,\n animated,\n 'aria-label': label,\n ...others\n } = props;\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ProgressFactory>({\n classNames,\n styles,\n props,\n });\n\n return (\n <ProgressRoot\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n vars={vars as any}\n {...others}\n >\n <ProgressSection\n value={value}\n color={color}\n striped={striped}\n animated={animated}\n aria-label={label}\n />\n </ProgressRoot>\n );\n});\n\nProgress.classes = classes;\nProgress.displayName = '@mantine/core/Progress';\nProgress.Section = ProgressSection;\nProgress.Root = ProgressRoot;\nProgress.Label = ProgressLabel;\n\nexport namespace Progress {\n export type Props = ProgressProps;\n export type Factory = ProgressFactory;\n export type StylesNames = ProgressStylesNames;\n export type ContextValue = ProgressContextValue;\n\n export namespace Label {\n export type Props = ProgressLabelProps;\n }\n\n export namespace Root {\n export type Props = ProgressRootProps;\n }\n\n export namespace Section {\n export type Props = ProgressSectionProps;\n }\n}\n"],"mappings":";;;;;;;;;;AA+CA,MAAa,WAAW,SAA0B,WAAW;CAC3D,MAAM,QAAQ,SAAS,YAAY,MAAM,OAAO;CAChD,MAAM,EACJ,OACA,YACA,QACA,MACA,OACA,SACA,UACA,cAAc,OACd,GAAG,WACD;CAEJ,MAAM,EAAE,oBAAoB,mBAAmB,qBAAsC;EACnF;EACA;EACA;EACD,CAAC;AAEF,QACE,oBAAC,cAAD;EACE,YAAY;EACZ,QAAQ;EACF;EACN,GAAI;YAEJ,oBAAC,iBAAD;GACS;GACA;GACE;GACC;GACV,cAAY;GACZ,CAAA;EACW,CAAA;EAEjB;AAEF,SAAS,UAAUA;AACnB,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,OAAO;AAChB,SAAS,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.mjs","names":["useId","classes"],"sources":["../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import { use } from 'react';\nimport { useId } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getAutoContrastValue,\n getContrastColor,\n getRadius,\n getSize,\n getThemeColor,\n MantineColor,\n MantineRadius,\n MantineSize,\n parseThemeColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { InlineInput, InlineInputStylesNames } from '../../utils/InlineInput';\nimport { RadioCard } from './RadioCard/RadioCard';\nimport { RadioGroup, RadioGroupContext } from './RadioGroup/RadioGroup';\nimport { RadioIcon, RadioIconProps } from './RadioIcon';\nimport { RadioIndicator } from './RadioIndicator/RadioIndicator';\nimport classes from './Radio.module.css';\n\nexport type RadioVariant = 'filled' | 'outline';\nexport type RadioStylesNames = InlineInputStylesNames | 'inner' | 'radio' | 'icon';\nexport type RadioCssVariables = {\n root:\n | '--radio-size'\n | '--radio-radius'\n | '--radio-color'\n | '--radio-icon-color'\n | '--radio-icon-size';\n};\n\nexport interface RadioProps\n extends BoxProps, StylesApiProps<RadioFactory>, ElementProps<'input', 'size' | 'children'> {\n /** Content of the `label` associated with the radio */\n label?: React.ReactNode;\n\n /** Key of theme.colors or any valid CSS color to set radio background color in checked state @default theme.primaryColor */\n color?: MantineColor;\n\n /** Controls size of the component @default 'sm' */\n size?: MantineSize | (string & {});\n\n /** A component that replaces the default radio icon (centered dot) */\n icon?: React.FC<RadioIconProps>;\n\n /** Props passed down to the root element */\n wrapperProps?: React.ComponentProps<'div'> & DataAttributes;\n\n /** Position of the label relative to the input @default 'right' */\n labelPosition?: 'left' | 'right';\n\n /** Description displayed below the label */\n description?: React.ReactNode;\n\n /** Error displayed below the label */\n error?: React.ReactNode;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default 'xl' */\n radius?: MantineRadius;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Key of theme.colors or any valid CSS color to set icon color. When not set, icon color is determined automatically based on theme.autoContrast setting */\n iconColor?: MantineColor;\n\n /** If set, adjusts text color based on background color for `filled` variant */\n autoContrast?: boolean;\n\n /** If set, applies error styles to the radio when `error` prop is set @default true */\n withErrorStyles?: boolean;\n}\n\nexport type RadioFactory = Factory<{\n props: RadioProps;\n ref: HTMLInputElement;\n stylesNames: RadioStylesNames;\n vars: RadioCssVariables;\n variant: RadioVariant;\n staticComponents: {\n Group: typeof RadioGroup;\n Card: typeof RadioCard;\n Indicator: typeof RadioIndicator;\n };\n}>;\n\nconst defaultProps = {\n labelPosition: 'right',\n withErrorStyles: true,\n} satisfies Partial<RadioProps>;\n\nconst varsResolver = createVarsResolver<RadioFactory>(\n (theme, { size, radius, color, iconColor, variant, autoContrast }) => {\n const parsedColor = parseThemeColor({ color: color || theme.primaryColor, theme });\n const outlineColor =\n parsedColor.isThemeColor && parsedColor.shade === undefined\n ? `var(--mantine-color-${parsedColor.color}-outline)`\n : parsedColor.color;\n\n return {\n root: {\n '--radio-size': getSize(size, 'radio-size'),\n '--radio-radius': radius === undefined ? undefined : getRadius(radius),\n '--radio-color': variant === 'outline' ? outlineColor : getThemeColor(color, theme),\n '--radio-icon-color': iconColor\n ? getThemeColor(iconColor, theme)\n : getAutoContrastValue(autoContrast, theme)\n ? getContrastColor({ color, theme, autoContrast })\n : undefined,\n '--radio-icon-size': getSize(size, 'radio-icon-size'),\n },\n };\n }\n);\n\nexport const Radio = factory<RadioFactory>((_props) => {\n const props = useProps('Radio', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n id,\n size,\n label,\n labelPosition,\n description,\n error,\n radius,\n color,\n variant,\n disabled,\n wrapperProps,\n icon: Icon = RadioIcon,\n rootRef,\n iconColor,\n onChange,\n mod,\n attributes,\n withErrorStyles,\n checked,\n ...others\n } = props;\n\n const getStyles = useStyles<RadioFactory>({\n name: 'Radio',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const ctx = use(RadioGroupContext);\n\n const contextSize = ctx?.size ?? size;\n const componentSize = props.size ? size : contextSize;\n\n const { styleProps, rest } = extractStyleProps(others);\n const uuid = useId(id);\n\n const contextChecked = ctx ? ctx.value === rest.value : undefined;\n\n const withContextProps = {\n checked: contextChecked ?? checked,\n name: rest.name ?? ctx?.name,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n ctx?.onChange(event);\n onChange?.(event);\n },\n disabled: ctx?.disabled ?? disabled,\n };\n\n return (\n <InlineInput\n {...getStyles('root')}\n __staticSelector=\"Radio\"\n __stylesApiProps={props}\n id={uuid}\n size={componentSize}\n labelPosition={labelPosition}\n label={label}\n description={description}\n error={error}\n disabled={withContextProps.disabled}\n classNames={classNames}\n styles={styles}\n unstyled={unstyled}\n data-checked={(contextChecked ?? checked) || undefined}\n variant={variant}\n ref={rootRef}\n mod={mod}\n attributes={attributes}\n {...styleProps}\n {...wrapperProps}\n >\n <Box {...getStyles('inner')} mod={{ 'label-position': labelPosition }}>\n <Box\n {...getStyles('radio', { focusable: true, variant })}\n {...rest}\n {...withContextProps}\n component=\"input\"\n mod={{ error: !!error, 'with-error-styles': withErrorStyles }}\n id={uuid}\n type=\"radio\"\n />\n <Icon {...getStyles('icon')} aria-hidden />\n </Box>\n </InlineInput>\n );\n});\n\nRadio.classes = classes;\nRadio.varsResolver = varsResolver;\nRadio.displayName = '@mantine/core/Radio';\nRadio.Group = RadioGroup;\nRadio.Card = RadioCard;\nRadio.Indicator = RadioIndicator;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiGA,MAAM,eAAe;CACnB,eAAe;CACf,iBAAiB;CAClB;AAED,MAAM,eAAe,oBAClB,OAAO,EAAE,MAAM,QAAQ,OAAO,WAAW,SAAS,mBAAmB;CACpE,MAAM,cAAc,gBAAgB;EAAE,OAAO,SAAS,MAAM;EAAc;EAAO,CAAC;CAClF,MAAM,eACJ,YAAY,gBAAgB,YAAY,UAAU,KAAA,IAC9C,uBAAuB,YAAY,MAAM,aACzC,YAAY;AAElB,QAAO,EACL,MAAM;EACJ,gBAAgB,QAAQ,MAAM,aAAa;EAC3C,kBAAkB,WAAW,K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EACJ,GAAI;YAEJ,qBAAC,KAAD;GAAK,GAAI,UAAU,QAAQ;GAAE,KAAK,EAAE,kBAAkB,eAAe;aAArE,CACE,oBAAC,KAAD;IACE,GAAI,UAAU,SAAS;KAAE,WAAW;KAAM;KAAS,CAAC;IACpD,GAAI;IACJ,GAAI;IACJ,WAAU;IACV,KAAK;KAAE,OAAO,CAAC,CAAC;KAAO,qBAAqB;KAAiB;IAC7D,IAAI;IACJ,MAAK;IACL,CAAA,EACF,oBAAC,MAAD;IAAM,GAAI,UAAU,OAAO;IAAE,eAAA;IAAc,CAAA,CACvC;;EACM,CAAA;EAEhB;AAEF,MAAM,UAAUC;AAChB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,QAAQ;AACd,MAAM,OAAO;AACb,MAAM,YAAY"}
1
+ {"version":3,"file":"Radio.mjs","names":["useId","classes"],"sources":["../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import { use } from 'react';\nimport { useId } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getAutoContrastValue,\n getContrastColor,\n getRadius,\n getSize,\n getThemeColor,\n MantineColor,\n MantineRadius,\n MantineSize,\n parseThemeColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { InlineInput, InlineInputStylesNames } from '../../utils/InlineInput';\nimport {\n RadioCard,\n type RadioCardProps,\n type RadioCardStylesNames,\n type RadioCardFactory,\n type RadioCardCssVariables,\n type RadioCardContextValue,\n} from './RadioCard/RadioCard';\nimport {\n RadioGroup,\n RadioGroupContext,\n type RadioGroupProps,\n type RadioGroupStylesNames,\n type RadioGroupFactory,\n type RadioGroupContextValue,\n} from './RadioGroup/RadioGroup';\nimport { RadioIcon, RadioIconProps } from './RadioIcon';\nimport {\n RadioIndicator,\n type RadioIndicatorProps,\n type RadioIndicatorStylesNames,\n type RadioIndicatorFactory,\n type RadioIndicatorCssVariables,\n type RadioIndicatorVariant,\n} from './RadioIndicator/RadioIndicator';\nimport classes from './Radio.module.css';\nexport type RadioVariant = 'filled' | 'outline';\nexport type RadioStylesNames = InlineInputStylesNames | 'inner' | 'radio' | 'icon';\nexport type RadioCssVariables = {\n root:\n | '--radio-size'\n | '--radio-radius'\n | '--radio-color'\n | '--radio-icon-color'\n | '--radio-icon-size';\n};\n\nexport interface RadioProps\n extends BoxProps, StylesApiProps<RadioFactory>, ElementProps<'input', 'size' | 'children'> {\n /** Content of the `label` associated with the radio */\n label?: React.ReactNode;\n\n /** Key of theme.colors or any valid CSS color to set radio background color in checked state @default theme.primaryColor */\n color?: MantineColor;\n\n /** Controls size of the component @default 'sm' */\n size?: MantineSize | (string & {});\n\n /** A component that replaces the default radio icon (centered dot) */\n icon?: React.FC<RadioIconProps>;\n\n /** Props passed down to the root element */\n wrapperProps?: React.ComponentProps<'div'> & DataAttributes;\n\n /** Position of the label relative to the input @default 'right' */\n labelPosition?: 'left' | 'right';\n\n /** Description displayed below the label */\n description?: React.ReactNode;\n\n /** Error displayed below the label */\n error?: React.ReactNode;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default 'xl' */\n radius?: MantineRadius;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Key of theme.colors or any valid CSS color to set icon color. When not set, icon color is determined automatically based on theme.autoContrast setting */\n iconColor?: MantineColor;\n\n /** If set, adjusts text color based on background color for `filled` variant */\n autoContrast?: boolean;\n\n /** If set, applies error styles to the radio when `error` prop is set @default true */\n withErrorStyles?: boolean;\n}\n\nexport type RadioFactory = Factory<{\n props: RadioProps;\n ref: HTMLInputElement;\n stylesNames: RadioStylesNames;\n vars: RadioCssVariables;\n variant: RadioVariant;\n staticComponents: {\n Group: typeof RadioGroup;\n Card: typeof RadioCard;\n Indicator: typeof RadioIndicator;\n };\n}>;\n\nconst defaultProps = {\n labelPosition: 'right',\n withErrorStyles: true,\n} satisfies Partial<RadioProps>;\n\nconst varsResolver = createVarsResolver<RadioFactory>(\n (theme, { size, radius, color, iconColor, variant, autoContrast }) => {\n const parsedColor = parseThemeColor({ color: color || theme.primaryColor, theme });\n const outlineColor =\n parsedColor.isThemeColor && parsedColor.shade === undefined\n ? `var(--mantine-color-${parsedColor.color}-outline)`\n : parsedColor.color;\n\n return {\n root: {\n '--radio-size': getSize(size, 'radio-size'),\n '--radio-radius': radius === undefined ? undefined : getRadius(radius),\n '--radio-color': variant === 'outline' ? outlineColor : getThemeColor(color, theme),\n '--radio-icon-color': iconColor\n ? getThemeColor(iconColor, theme)\n : getAutoContrastValue(autoContrast, theme)\n ? getContrastColor({ color, theme, autoContrast })\n : undefined,\n '--radio-icon-size': getSize(size, 'radio-icon-size'),\n },\n };\n }\n);\n\nexport const Radio = factory<RadioFactory>((_props) => {\n const props = useProps('Radio', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n id,\n size,\n label,\n labelPosition,\n description,\n error,\n radius,\n color,\n variant,\n disabled,\n wrapperProps,\n icon: Icon = RadioIcon,\n rootRef,\n iconColor,\n onChange,\n mod,\n attributes,\n withErrorStyles,\n checked,\n ...others\n } = props;\n\n const getStyles = useStyles<RadioFactory>({\n name: 'Radio',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const ctx = use(RadioGroupContext);\n\n const contextSize = ctx?.size ?? size;\n const componentSize = props.size ? size : contextSize;\n\n const { styleProps, rest } = extractStyleProps(others);\n const uuid = useId(id);\n\n const contextChecked = ctx ? ctx.value === rest.value : undefined;\n\n const withContextProps = {\n checked: contextChecked ?? checked,\n name: rest.name ?? ctx?.name,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n ctx?.onChange(event);\n onChange?.(event);\n },\n disabled: ctx?.disabled ?? disabled,\n };\n\n return (\n <InlineInput\n {...getStyles('root')}\n __staticSelector=\"Radio\"\n __stylesApiProps={props}\n id={uuid}\n size={componentSize}\n labelPosition={labelPosition}\n label={label}\n description={description}\n error={error}\n disabled={withContextProps.disabled}\n classNames={classNames}\n styles={styles}\n unstyled={unstyled}\n data-checked={(contextChecked ?? checked) || undefined}\n variant={variant}\n ref={rootRef}\n mod={mod}\n attributes={attributes}\n {...styleProps}\n {...wrapperProps}\n >\n <Box {...getStyles('inner')} mod={{ 'label-position': labelPosition }}>\n <Box\n {...getStyles('radio', { focusable: true, variant })}\n {...rest}\n {...withContextProps}\n component=\"input\"\n mod={{ error: !!error, 'with-error-styles': withErrorStyles }}\n id={uuid}\n type=\"radio\"\n />\n <Icon {...getStyles('icon')} aria-hidden />\n </Box>\n </InlineInput>\n );\n});\n\nRadio.classes = classes;\nRadio.varsResolver = varsResolver;\nRadio.displayName = '@mantine/core/Radio';\nRadio.Group = RadioGroup;\nRadio.Card = RadioCard;\nRadio.Indicator = RadioIndicator;\n\nexport namespace Radio {\n export type Props = RadioProps;\n export type StylesNames = RadioStylesNames;\n export type Factory = RadioFactory;\n export type Variant = RadioVariant;\n\n export namespace Group {\n export type Props = RadioGroupProps;\n export type StylesNames = RadioGroupStylesNames;\n export type Factory = RadioGroupFactory;\n export type ContextValue = RadioGroupContextValue;\n }\n\n export namespace Card {\n export type Props = RadioCardProps;\n export type StylesNames = RadioCardStylesNames;\n export type Factory = RadioCardFactory;\n export type CssVariables = RadioCardCssVariables;\n export type ContextValue = RadioCardContextValue;\n }\n\n export namespace Indicator {\n export type Props = RadioIndicatorProps;\n export type StylesNames = RadioIndicatorStylesNames;\n export type Factory = RadioIndicatorFactory;\n export type CssVariables = RadioIndicatorCssVariables;\n export type Variant = RadioIndicatorVariant;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqHA,MAAM,eAAe;CACnB,eAAe;CACf,iBAAiB;CAClB;AAED,MAAM,eAAe,oBAClB,OAAO,EAAE,MAAM,QAAQ,OAAO,WAAW,SAAS,mBAAmB;CACpE,MAAM,cAAc,gBAAgB;EAAE,OAAO,SAAS,MAAM;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AU,OAAO;EACrB,kBAAiB;EACjB,kBAAkB;EAClB,IAAI;EACJ,MAAM;EACS;EACR;EACM;EACN;EACP,UAAU,iBAAiB;EACf;EACJ;EACE;EACV,iBAAe,kBAAkB,YAAY,KAAA;EACpC;EACT,KAAK;EACA;EACO;EACZ,GAAI;EACJ,GAAI;YAEJ,qBAAC,KAAD;GAAK,GAAI,UAAU,QAAQ;GAAE,KAAK,EAAE,kBAAkB,eAAe;aAArE,CACE,oBAAC,KAAD;IACE,GAAI,UAAU,SAAS;KAAE,WAAW;KAAM;KAAS,CAAC;IACpD,GAAI;IACJ,GAAI;IACJ,WAAU;IACV,KAAK;KAAE,OAAO,CAAC,CAAC;KAAO,qBAAqB;KAAiB;IAC7D,IAAI;IACJ,MAAK;IACL,CAAA,EACF,oBAAC,MAAD;IAAM,GAAI,UAAU,OAAO;IAAE,eAAA;IAAc,CAAA,CACvC;;EACM,CAAA;EAEhB;AAEF,MAAM,UAAUC;AAChB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,QAAQ;AACd,MAAM,OAAO;AACb,MAAM,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.mjs","names":["useId"],"sources":["../../../../src/components/Radio/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport { DataAttributes, Factory, genericFactory, MantineSize, useProps } from '../../../core';\nimport { InputsGroupFieldset } from '../../../utils/InputsGroupFieldset';\nimport { Input, InputWrapperProps, InputWrapperStylesNames } from '../../Input';\n\nexport interface RadioGroupContextValue<Value extends string = string> {\n size: MantineSize | undefined;\n value: Value | null;\n onChange: (event: React.ChangeEvent<HTMLInputElement> | string) => void;\n name: string;\n disabled: boolean | undefined;\n}\n\nexport const RadioGroupContext = createContext<RadioGroupContextValue | null>(null);\n\nexport type RadioGroupStylesNames = InputWrapperStylesNames;\n\nexport interface RadioGroupProps<Value extends string = string> extends Omit<\n InputWrapperProps,\n 'onChange' | 'value' | 'defaultValue'\n> {\n /** `Radio` components and any other elements */\n children: React.ReactNode;\n\n /** Controlled component value */\n value?: Value | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Value | null;\n\n /** Called when value changes */\n onChange?: (value: Value) => void;\n\n /** Props passed down to the `Input.Wrapper` */\n wrapperProps?: React.ComponentProps<'div'> & DataAttributes;\n\n /** Controls size of the `Input.Wrapper` @default 'sm' */\n size?: MantineSize;\n\n /** `name` attribute of child radio inputs. By default, `name` is generated randomly. */\n name?: string;\n\n /** If set, value cannot be changed */\n readOnly?: boolean;\n\n /** Sets `disabled` attribute, prevents interactions */\n disabled?: boolean;\n}\n\nexport type RadioGroupFactory = Factory<{\n props: RadioGroupProps;\n ref: HTMLDivElement;\n stylesNames: RadioGroupStylesNames;\n signature: <Value extends string = string>(props: RadioGroupProps<Value>) => React.JSX.Element;\n}>;\n\nexport const RadioGroup = genericFactory<RadioGroupFactory>(((props: RadioGroupProps<string>) => {\n const {\n value,\n defaultValue,\n onChange,\n size,\n wrapperProps,\n children,\n name,\n readOnly,\n disabled,\n ...others\n } = useProps('RadioGroup', null, props);\n\n const _name = useId(name);\n\n const [_value, setValue] = useUncontrolled<string | null>({\n value,\n defaultValue,\n finalValue: '',\n onChange: onChange as any,\n });\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement> | string) =>\n !readOnly && setValue(typeof event === 'string' ? event : event.currentTarget.value);\n\n return (\n <RadioGroupContext\n value={{ value: _value, onChange: handleChange, size, name: _name, disabled }}\n >\n <Input.Wrapper\n size={size}\n {...wrapperProps}\n {...others}\n labelElement=\"div\"\n __staticSelector=\"RadioGroup\"\n >\n <InputsGroupFieldset role=\"radiogroup\">{children}</InputsGroupFieldset>\n </Input.Wrapper>\n </RadioGroupContext>\n );\n}) as any);\n\nRadioGroup.classes = Input.Wrapper.classes;\nRadioGroup.displayName = '@mantine/core/RadioGroup';\n"],"mappings":";;;;;;;;;AAcA,MAAa,oBAAoB,cAA6C,KAAK;AA2CnF,MAAa,aAAa,iBAAoC,UAAmC;CAC/F,MAAM,EACJ,OACA,cACA,UACA,MACA,cACA,UACA,MACA,UACA,UACA,GAAG,WACD,SAAS,cAAc,MAAM,MAAM;CAEvC,MAAM,QAAQA,QAAM,KAAK;CAEzB,MAAM,CAAC,QAAQ,YAAY,gBAA+B;EACxD;EACA;EACA,YAAY;EACF;EACX,CAAC;CAEF,MAAM,gBAAgB,UACpB,CAAC,YAAY,SAAS,OAAO,UAAU,WAAW,QAAQ,MAAM,cAAc,MAAM;AAEtF,QACE,oBAAC,mBAAD;EACE,OAAO;GAAE,OAAO;GAAQ,UAAU;GAAc;GAAM,MAAM;GAAO;GAAU;YAE7E,oBAAC,MAAM,SAAP;GACQ;GACN,GAAI;GACJ,GAAI;GACJ,cAAa;GACb,kBAAiB;aAEjB,oBAAC,qBAAD;IAAqB,MAAK;IAAc;IAA+B,CAAA;GACzD,CAAA;EACE,CAAA;GAEd;AAEV,WAAW,UAAU,MAAM,QAAQ;AACnC,WAAW,cAAc"}
1
+ {"version":3,"file":"RadioGroup.mjs","names":["useId"],"sources":["../../../../src/components/Radio/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n DataAttributes,\n Factory,\n genericFactory,\n MantineSize,\n Primitive,\n useProps,\n} from '../../../core';\nimport { InputsGroupFieldset } from '../../../utils/InputsGroupFieldset';\nimport { Input, InputWrapperProps, InputWrapperStylesNames } from '../../Input';\n\nexport interface RadioGroupContextValue<Value extends Primitive = string> {\n size: MantineSize | undefined;\n value: Value | null;\n onChange: (event: React.ChangeEvent<HTMLInputElement> | string) => void;\n name: string;\n disabled: boolean | undefined;\n}\n\nexport const RadioGroupContext = createContext<RadioGroupContextValue | null>(null);\n\nexport type RadioGroupStylesNames = InputWrapperStylesNames;\n\nexport interface RadioGroupProps<Value extends Primitive = string> extends Omit<\n InputWrapperProps,\n 'onChange' | 'value' | 'defaultValue'\n> {\n /** `Radio` components and any other elements */\n children: React.ReactNode;\n\n /** Controlled component value */\n value?: Value | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Value | null;\n\n /** Called when value changes */\n onChange?: (value: Value) => void;\n\n /** Props passed down to the `Input.Wrapper` */\n wrapperProps?: React.ComponentProps<'div'> & DataAttributes;\n\n /** Controls size of the `Input.Wrapper` @default 'sm' */\n size?: MantineSize;\n\n /** `name` attribute of child radio inputs. By default, `name` is generated randomly. */\n name?: string;\n\n /** If set, value cannot be changed */\n readOnly?: boolean;\n\n /** Sets `disabled` attribute, prevents interactions */\n disabled?: boolean;\n}\n\nexport type RadioGroupFactory = Factory<{\n props: RadioGroupProps;\n ref: HTMLDivElement;\n stylesNames: RadioGroupStylesNames;\n signature: <Value extends Primitive = string>(props: RadioGroupProps<Value>) => React.JSX.Element;\n}>;\n\nexport const RadioGroup = genericFactory<RadioGroupFactory>(((props: RadioGroupProps<string>) => {\n const {\n value,\n defaultValue,\n onChange,\n size,\n wrapperProps,\n children,\n name,\n readOnly,\n disabled,\n ...others\n } = useProps('RadioGroup', null, props);\n\n const _name = useId(name);\n\n const [_value, setValue] = useUncontrolled<string | null>({\n value,\n defaultValue,\n finalValue: '',\n onChange: onChange as any,\n });\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement> | string) =>\n !readOnly && setValue(typeof event === 'string' ? event : event.currentTarget.value);\n\n return (\n <RadioGroupContext\n value={{ value: _value, onChange: handleChange, size, name: _name, disabled }}\n >\n <Input.Wrapper\n size={size}\n {...wrapperProps}\n {...others}\n labelElement=\"div\"\n __staticSelector=\"RadioGroup\"\n >\n <InputsGroupFieldset role=\"radiogroup\">{children}</InputsGroupFieldset>\n </Input.Wrapper>\n </RadioGroupContext>\n );\n}) as any);\n\nRadioGroup.classes = Input.Wrapper.classes;\nRadioGroup.displayName = '@mantine/core/RadioGroup';\n"],"mappings":";;;;;;;;;AAqBA,MAAa,oBAAoB,cAA6C,KAAK;AA2CnF,MAAa,aAAa,iBAAoC,UAAmC;CAC/F,MAAM,EACJ,OACA,cACA,UACA,MACA,cACA,UACA,MACA,UACA,UACA,GAAG,WACD,SAAS,cAAc,MAAM,MAAM;CAEvC,MAAM,QAAQA,QAAM,KAAK;CAEzB,MAAM,CAAC,QAAQ,YAAY,gBAA+B;EACxD;EACA;EACA,YAAY;EACF;EACX,CAAC;CAEF,MAAM,gBAAgB,UACpB,CAAC,YAAY,SAAS,OAAO,UAAU,WAAW,QAAQ,MAAM,cAAc,MAAM;AAEtF,QACE,oBAAC,mBAAD;EACE,OAAO;GAAE,OAAO;GAAQ,UAAU;GAAc;GAAM,MAAM;GAAO;GAAU;YAE7E,oBAAC,MAAM,SAAP;GACQ;GACN,GAAI;GACJ,GAAI;GACJ,cAAa;GACb,kBAAiB;aAEjB,oBAAC,qBAAD;IAAqB,MAAK;IAAc;IAA+B,CAAA;GACzD,CAAA;EACE,CAAA;GAEd;AAEV,WAAW,UAAU,MAAM,QAAQ;AACnC,WAAW,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Rating.mjs","names":["useId","classes"],"sources":["../../../src/components/Rating/Rating.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { clamp, useId, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSize,\n getThemeColor,\n MantineColor,\n MantineSize,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../core';\nimport { RatingProvider } from './Rating.context';\nimport { RatingItem } from './RatingItem/RatingItem';\nimport classes from './Rating.module.css';\n\nfunction roundValueTo(value: number, to: number) {\n const rounded = Math.round(value / to) * to;\n const precision = `${to}`.split('.')[1]?.length || 0;\n return Number(rounded.toFixed(precision));\n}\n\nexport type RatingStylesNames =\n | 'root'\n | 'starSymbol'\n | 'input'\n | 'label'\n | 'symbolBody'\n | 'symbolGroup';\n\nexport type RatingCssVariables = {\n root: '--rating-size' | '--rating-color';\n};\n\nexport interface RatingProps\n extends BoxProps, StylesApiProps<RatingFactory>, ElementProps<'div', 'onChange'> {\n /** Uncontrolled component default value */\n defaultValue?: number;\n\n /** Controlled component value */\n value?: number;\n\n /** Called when value changes */\n onChange?: (value: number) => void;\n\n /** Icon displayed for unselected rating items. Can be a function that receives the rating value. */\n emptySymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Icon displayed for selected rating items. Can be a function that receives the rating value. */\n fullSymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Number of fractions each item can be divided into, default is 1 */\n fractions?: number;\n\n /** Controls component size @default 'sm' */\n size?: MantineSize | number | (string & {});\n\n /** Number of rating items (stars), default is 5 */\n count?: number;\n\n /** Called when rating item is hovered. Receives -1 when hover ends. */\n onHover?: (value: number) => void;\n\n /** Function to generate aria-label for each rating value. Receives the rating value as argument, default is (value) => String(value) */\n getSymbolLabel?: (index: number) => string;\n\n /** Name attribute for form submission. If not provided, a unique id will be generated. */\n name?: string;\n\n /** When true, rating cannot be changed by user interaction, default is false */\n readOnly?: boolean;\n\n /** When true, clicking the same rating value clears the rating to 0, default is false */\n allowClear?: boolean;\n\n /** When true, only the clicked rating item is highlighted, not all items up to the selected value, default is false */\n highlightSelectedOnly?: boolean;\n\n /** Key of theme.colors or any CSS color value, default is 'yellow' */\n color?: MantineColor;\n}\n\nexport type RatingFactory = Factory<{\n props: RatingProps;\n ref: HTMLDivElement;\n stylesNames: RatingStylesNames;\n vars: RatingCssVariables;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n getSymbolLabel: (value) => `${value}`,\n count: 5,\n fractions: 1,\n color: 'yellow',\n} satisfies Partial<RatingProps>;\n\nconst varsResolver = createVarsResolver<RatingFactory>((theme, { size, color }) => ({\n root: {\n '--rating-size': getSize(size, 'rating-size'),\n '--rating-color': getThemeColor(color, theme),\n },\n}));\n\nexport const Rating = factory<RatingFactory>((_props) => {\n const props = useProps('Rating', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n name,\n id,\n value,\n defaultValue,\n onChange,\n fractions,\n count,\n onMouseEnter,\n readOnly,\n allowClear,\n onMouseMove,\n onHover,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n size,\n variant,\n getSymbolLabel,\n color,\n emptySymbol,\n fullSymbol,\n highlightSelectedOnly,\n attributes,\n ref,\n ...others\n } = props;\n\n const getStyles = useStyles<RatingFactory>({\n name: 'Rating',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { dir } = useDirection();\n\n const _name = useId(name);\n const _id = useId(id);\n const rootRef = useRef<HTMLDivElement>(null);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: 0,\n onChange,\n });\n\n const [hovered, setHovered] = useState(-1);\n const [isOutside, setOutside] = useState(true);\n\n const _fractions = Math.floor(fractions);\n const _count = Math.floor(count);\n\n const decimalUnit = 1 / _fractions;\n const stableValueRounded = roundValueTo(_value, decimalUnit);\n const finalValue = hovered !== -1 ? hovered : stableValueRounded;\n\n const getRatingFromCoordinates = (x: number) => {\n if (!rootRef.current) {\n return 0;\n }\n\n const { left, right, width } = rootRef.current.getBoundingClientRect();\n const symbolWidth = width / _count;\n\n const hoverPosition = dir === 'rtl' ? right - x : x - left;\n const hoverValue = hoverPosition / symbolWidth;\n\n return clamp(roundValueTo(hoverValue + decimalUnit / 2, decimalUnit), decimalUnit, _count);\n };\n\n const handleMouseEnter = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseEnter?.(event);\n !readOnly && setOutside(false);\n };\n\n const handleMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseMove?.(event);\n\n if (readOnly) {\n return;\n }\n\n const rounded = getRatingFromCoordinates(event.clientX);\n\n setHovered(rounded);\n rounded !== hovered && onHover?.(rounded);\n };\n\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseLeave?.(event);\n\n if (readOnly) {\n return;\n }\n\n setHovered(-1);\n setOutside(true);\n hovered !== -1 && onHover?.(-1);\n };\n\n const handleTouchStart = (event: React.TouchEvent<HTMLDivElement>) => {\n const { touches } = event;\n if (touches.length !== 1) {\n return;\n }\n\n if (!readOnly) {\n const touch = touches[0];\n setValue(getRatingFromCoordinates(touch.clientX));\n }\n\n onTouchStart?.(event);\n };\n\n const handleTouchEnd = (event: React.TouchEvent<HTMLDivElement>) => {\n event.preventDefault();\n\n onTouchEnd?.(event);\n };\n\n const handleItemBlur = () => isOutside && setHovered(-1);\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n if (typeof event === 'number') {\n setHovered(event);\n } else {\n setHovered(parseFloat(event.target.value));\n }\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n const newValue = typeof event === 'number' ? event : parseFloat(event.target.value);\n\n // If allowClear is true and clicking the same value, reset to 0\n if (allowClear && newValue === stableValueRounded) {\n setValue(0);\n } else {\n setValue(newValue);\n }\n }\n };\n\n const items = Array(_count)\n .fill(0)\n .map((_, index) => {\n const integerValue = index + 1;\n const fractionItems = Array.from(new Array(index === 0 ? _fractions + 1 : _fractions));\n const isGroupActive = !readOnly && Math.ceil(hovered) === integerValue;\n\n return (\n <div\n key={integerValue}\n data-active={isGroupActive || undefined}\n {...getStyles('symbolGroup')}\n >\n {fractionItems.map((__, fractionIndex) => {\n const fractionValue = decimalUnit * (index === 0 ? fractionIndex : fractionIndex + 1);\n const symbolValue = roundValueTo(integerValue - 1 + fractionValue, decimalUnit);\n\n return (\n <RatingItem\n key={`${integerValue}-${symbolValue}`}\n getSymbolLabel={getSymbolLabel}\n emptyIcon={emptySymbol}\n fullIcon={fullSymbol}\n full={\n highlightSelectedOnly ? symbolValue === finalValue : symbolValue <= finalValue\n }\n active={symbolValue === finalValue}\n checked={symbolValue === stableValueRounded}\n readOnly={readOnly}\n fractionValue={fractionValue}\n value={symbolValue}\n name={_name}\n onChange={handleChange}\n onBlur={handleItemBlur}\n onInputChange={handleInputChange}\n id={`${_id}-${index}-${fractionIndex}`}\n />\n );\n })}\n </div>\n );\n });\n\n return (\n <RatingProvider value={{ getStyles }}>\n <Box\n ref={useMergedRef(rootRef, ref)}\n {...getStyles('root')}\n onMouseMove={handleMouseMove}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n variant={variant}\n size={size}\n id={_id}\n {...others}\n >\n {items}\n </Box>\n </RatingProvider>\n );\n});\n\nRating.classes = classes;\nRating.varsResolver = varsResolver;\nRating.displayName = '@mantine/core/Rating';\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,SAAS,aAAa,OAAe,IAAY;CAC/C,MAAM,UAAU,KAAK,MAAM,QAAQ,GAAG,GAAG;CACzC,MAAM,YAAY,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,UAAU;AACnD,QAAO,OAAO,QAAQ,QAAQ,UAAU,CAAC;;AAsE3C,MAAM,eAAe;CACnB,MAAM;CACN,iBAAiB,UAAU,GAAG;CAC9B,OAAO;CACP,WAAW;CACX,OAAO;CACR;AAED,MAAM,eAAe,oBAAmC,OAAO,EAAE,MAAM,aAAa,EAClF,MAAM;CACJ,iBAAiB,QAAQ,MAAM,cAAc;CAC7C,kBAAkB,cAAc,OAAO,MAAM;CAC9C,EACF,EAAE;AAEH,MAAa,SAAS,SAAwB,WAAW;CACvD,MAAM,QAAQ,SAAS,UAAU,cAAc,OAAO;CACtD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,IACA,OACA,cACA,UACA,WACA,OACA,cACA,UACA,YACA,aACA,SACA,cACA,cACA,YACA,MACA,SACA,gBACA,OACA,aACA,YACA,uBACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAAyB;EACzC,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CA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9BC,aA8BD;GAER;AAEJ,QACE,oBAAC,gBAAD;EAAgB,OAAO,EAAE,WAAW;YAClC,oBAAC,KAAD;GACE,KAAK,aAAa,SAAS,IAAI;GAC/B,GAAI,UAAU,OAAO;GACrB,aAAa;GACb,cAAc;GACd,cAAc;GACd,cAAc;GACd,YAAY;GACH;GACH;GACN,IAAI;GACJ,GAAI;aAEH;GACG,CAAA;EACS,CAAA;EAEnB;AAEF,OAAO,UAAUC;AACjB,OAAO,eAAe;AACtB,OAAO,cAAc"}
1
+ {"version":3,"file":"Rating.mjs","names":["useId","classes"],"sources":["../../../src/components/Rating/Rating.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { clamp, useId, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSize,\n getThemeColor,\n MantineColor,\n MantineSize,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../core';\nimport { RatingProvider } from './Rating.context';\nimport { RatingItem } from './RatingItem/RatingItem';\nimport classes from './Rating.module.css';\n\nfunction roundValueTo(value: number, to: number) {\n const rounded = Math.round(value / to) * to;\n const precision = `${to}`.split('.')[1]?.length || 0;\n return Number(rounded.toFixed(precision));\n}\n\nexport type RatingStylesNames =\n | 'root'\n | 'starSymbol'\n | 'input'\n | 'label'\n | 'symbolBody'\n | 'symbolGroup';\n\nexport type RatingCssVariables = {\n root: '--rating-size' | '--rating-color';\n};\n\nexport interface RatingProps\n extends BoxProps, StylesApiProps<RatingFactory>, ElementProps<'div', 'onChange'> {\n /** Uncontrolled component default value */\n defaultValue?: number;\n\n /** Controlled component value */\n value?: number;\n\n /** Called when value changes */\n onChange?: (value: number) => void;\n\n /** Icon displayed for unselected rating items. Can be a function that receives the rating value. */\n emptySymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Icon displayed for selected rating items. Can be a function that receives the rating value. */\n fullSymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Number of fractions each item can be divided into, default is 1 */\n fractions?: number;\n\n /** Controls component size @default 'sm' */\n size?: MantineSize | number | (string & {});\n\n /** Number of rating items (stars), default is 5 */\n count?: number;\n\n /** Called when rating item is hovered. Receives -1 when hover ends. */\n onHover?: (value: number) => void;\n\n /** Function to generate aria-label for each rating value. Receives the rating value as argument, default is (value) => String(value) */\n getSymbolLabel?: (index: number) => string;\n\n /** Name attribute for form submission. If not provided, a unique id will be generated. */\n name?: string;\n\n /** When true, rating cannot be changed by user interaction, default is false */\n readOnly?: boolean;\n\n /** When true, clicking the same rating value clears the rating to 0, default is false */\n allowClear?: boolean;\n\n /** When true, only the clicked rating item is highlighted, not all items up to the selected value, default is false */\n highlightSelectedOnly?: boolean;\n\n /** Key of theme.colors or any CSS color value, default is 'yellow' */\n color?: MantineColor;\n}\n\nexport type RatingFactory = Factory<{\n props: RatingProps;\n ref: HTMLDivElement;\n stylesNames: RatingStylesNames;\n vars: RatingCssVariables;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n getSymbolLabel: (value) => `${value}`,\n count: 5,\n fractions: 1,\n color: 'yellow',\n} satisfies Partial<RatingProps>;\n\nconst varsResolver = createVarsResolver<RatingFactory>((theme, { size, color }) => ({\n root: {\n '--rating-size': getSize(size, 'rating-size'),\n '--rating-color': getThemeColor(color, theme),\n },\n}));\n\nexport const Rating = factory<RatingFactory>((_props) => {\n const props = useProps('Rating', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n name,\n id,\n value,\n defaultValue,\n onChange,\n fractions,\n count,\n onMouseEnter,\n readOnly,\n allowClear,\n onMouseMove,\n onHover,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n size,\n variant,\n getSymbolLabel,\n color,\n emptySymbol,\n fullSymbol,\n highlightSelectedOnly,\n attributes,\n ref,\n ...others\n } = props;\n\n const getStyles = useStyles<RatingFactory>({\n name: 'Rating',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { dir } = useDirection();\n\n const _name = useId(name);\n const _id = useId(id);\n const rootRef = useRef<HTMLDivElement>(null);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: 0,\n onChange,\n });\n\n const [hovered, setHovered] = useState(-1);\n const [isOutside, setOutside] = useState(true);\n\n const _fractions = Math.floor(fractions);\n const _count = Math.floor(count);\n\n const decimalUnit = 1 / _fractions;\n const stableValueRounded = roundValueTo(_value, decimalUnit);\n const finalValue = hovered !== -1 ? hovered : stableValueRounded;\n\n const getRatingFromCoordinates = (x: number) => {\n if (!rootRef.current) {\n return 0;\n }\n\n const { left, right, width } = rootRef.current.getBoundingClientRect();\n const symbolWidth = width / _count;\n\n const hoverPosition = dir === 'rtl' ? right - x : x - left;\n const hoverValue = hoverPosition / symbolWidth;\n\n return clamp(roundValueTo(hoverValue + decimalUnit / 2, decimalUnit), decimalUnit, _count);\n };\n\n const handleMouseEnter = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseEnter?.(event);\n !readOnly && setOutside(false);\n };\n\n const handleMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseMove?.(event);\n\n if (readOnly) {\n return;\n }\n\n const rounded = getRatingFromCoordinates(event.clientX);\n\n setHovered(rounded);\n rounded !== hovered && onHover?.(rounded);\n };\n\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseLeave?.(event);\n\n if (readOnly) {\n return;\n }\n\n setHovered(-1);\n setOutside(true);\n hovered !== -1 && onHover?.(-1);\n };\n\n const handleTouchStart = (event: React.TouchEvent<HTMLDivElement>) => {\n const { touches } = event;\n if (touches.length !== 1) {\n return;\n }\n\n if (!readOnly) {\n const touch = touches[0];\n setValue(getRatingFromCoordinates(touch.clientX));\n }\n\n onTouchStart?.(event);\n };\n\n const handleTouchEnd = (event: React.TouchEvent<HTMLDivElement>) => {\n event.preventDefault();\n\n onTouchEnd?.(event);\n };\n\n const handleItemBlur = () => isOutside && setHovered(-1);\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n if (typeof event === 'number') {\n setHovered(event);\n } else {\n setHovered(parseFloat(event.target.value));\n }\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n const newValue = typeof event === 'number' ? event : parseFloat(event.target.value);\n\n // If allowClear is true and clicking the same value, reset to 0\n if (allowClear && newValue === stableValueRounded) {\n setValue(0);\n } else {\n setValue(newValue);\n }\n }\n };\n\n const items = Array(_count)\n .fill(0)\n .map((_, index) => {\n const integerValue = index + 1;\n const fractionItems = Array.from(new Array(index === 0 ? _fractions + 1 : _fractions));\n const isGroupActive = !readOnly && Math.ceil(hovered) === integerValue;\n\n return (\n <div\n key={integerValue}\n data-active={isGroupActive || undefined}\n {...getStyles('symbolGroup')}\n >\n {fractionItems.map((__, fractionIndex) => {\n const fractionValue = decimalUnit * (index === 0 ? fractionIndex : fractionIndex + 1);\n const symbolValue = roundValueTo(integerValue - 1 + fractionValue, decimalUnit);\n\n return (\n <RatingItem\n key={`${integerValue}-${symbolValue}`}\n getSymbolLabel={getSymbolLabel}\n emptyIcon={emptySymbol}\n fullIcon={fullSymbol}\n full={\n highlightSelectedOnly ? symbolValue === finalValue : symbolValue <= finalValue\n }\n active={symbolValue === finalValue}\n checked={symbolValue === stableValueRounded}\n readOnly={readOnly}\n fractionValue={fractionValue}\n value={symbolValue}\n name={_name}\n onChange={handleChange}\n onBlur={handleItemBlur}\n onInputChange={handleInputChange}\n id={`${_id}-${index}-${fractionIndex}`}\n />\n );\n })}\n </div>\n );\n });\n\n return (\n <RatingProvider value={{ getStyles }}>\n <Box\n ref={useMergedRef(rootRef, ref)}\n {...getStyles('root')}\n onMouseMove={handleMouseMove}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n variant={variant}\n size={size}\n id={_id}\n {...others}\n >\n {items}\n </Box>\n </RatingProvider>\n );\n});\n\nRating.classes = classes;\nRating.varsResolver = varsResolver;\nRating.displayName = '@mantine/core/Rating';\n\nexport namespace Rating {\n export type Props = RatingProps;\n export type StylesNames = RatingStylesNames;\n export type Factory = RatingFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,SAAS,aAAa,OAAe,IAAY;CAC/C,MAAM,UAAU,KAAK,MAAM,QAAQ,GAAG,GAAG;CACzC,MAAM,YAAY,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,UAAU;AACnD,QAAO,OAAO,QAAQ,QAAQ,UAAU,CAAC;;AAsE3C,MAAM,eAAe;CACnB,MAAM;CACN,iBAAiB,UAAU,GAAG;CAC9B,OAAO;CACP,WAAW;CACX,OAAO;CACR;AAED,MAAM,eAAe,oBAAmC,OAAO,EAAE,MAAM,aAAa,EAClF,MAAM;CACJ,iBAAiB,QAAQ,MAAM,cAAc;CAC7C,kBAAkB,cAAc,OAAO,MAAM;CAC9C,EACF,EAAE;AAEH,MAAa,SAAS,SAAwB,WAAW;CACvD,MAAM,QAAQ,SAAS,UAAU,cAAc,OAAO;CACtD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,IACA,OACA,cACA,UACA,WACA,OACA,cACA,UACA,YACA,aACA,SACA,cACA,cACA,YACA,MACA,SACA,gBACA,OACA,aACA,YACA,uBACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAAyB;EACzC,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,QAAQ,cAAc;CAE9B,MAAM,QAAQA,QAAM,KAAK;CACzB,MAAM,MAAMA,QAAM,GAAG;CACrB,MAAM,UAAU,OAAuB,KAAK;CAE5C,MAAM,CAAC,QAAQ,YAAY,gBAAgB;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,CAAC,SAAS,cAAc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EH;GACG,CAAA;EACS,CAAA;EAEnB;AAEF,OAAO,UAAUC;AACjB,OAAO,eAAe;AACtB,OAAO,cAAc"}
@@ -69,6 +69,7 @@ const RingProgress = factory((_props) => {
69
69
  ...others,
70
70
  children: [/* @__PURE__ */ jsx("svg", {
71
71
  ...getStyles("svg"),
72
+ viewBox: `0 0 ${size} ${size}`,
72
73
  children: curves
73
74
  }), label && /* @__PURE__ */ jsx("div", {
74
75
  ...getStyles("label"),
@@ -1 +1 @@
1
- {"version":3,"file":"RingProgress.mjs","names":["classes"],"sources":["../../../src/components/RingProgress/RingProgress.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n factory,\n Factory,\n MantineColor,\n rem,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { Curve } from './Curve/Curve';\nimport { getCurves } from './get-curves/get-curves';\nimport classes from './RingProgress.module.css';\n\nfunction getClampedThickness(thickness: number, size: number) {\n return Math.min(thickness || 12, (size || 120) / 4);\n}\n\nexport interface RingProgressSection extends React.ComponentProps<'circle'>, DataAttributes {\n value: number;\n color: MantineColor;\n tooltip?: React.ReactNode;\n}\n\nexport type RingProgressStylesNames = 'root' | 'svg' | 'label' | 'curve';\nexport type RingProgressCssVariables = {\n root: '--rp-size' | '--rp-label-offset' | '--rp-transition-duration';\n svg: '--rp-start-angle';\n};\n\nexport interface RingProgressProps\n extends BoxProps, StylesApiProps<RingProgressFactory>, ElementProps<'div'> {\n /** Label displayed in the center of the ring */\n label?: React.ReactNode;\n\n /** Ring thickness in pixels. Cannot exceed size / 4 and will be automatically clamped if necessary @default 12 */\n thickness?: number;\n\n /** Width and height of the progress ring @default 120 */\n size?: number;\n\n /** Applies rounded line caps to the start and end of visible sections @default false */\n roundCaps?: boolean;\n\n /**\n * Array of sections to display in the ring. Each section should have a `value` (0-100),\n * `color`, and optional `tooltip`. Sections can also receive any valid SVG circle element props.\n */\n sections: RingProgressSection[];\n\n /** Color of the unfilled portion of the ring (background). Defaults to gray-2 in light mode, dark-4 in dark mode */\n rootColor?: MantineColor;\n\n /** Transition duration in milliseconds for section value and color changes @default 0 */\n transitionDuration?: number;\n\n /** Gap between sections in degrees. Reduces the visual size of each section @default 0 */\n sectionGap?: number;\n\n /** Starting angle in degrees. 0 = right, 90 = bottom, 180 = left, 270 = top @default 270 */\n startAngle?: number;\n}\n\nexport type RingProgressFactory = Factory<{\n props: RingProgressProps;\n ref: HTMLDivElement;\n stylesNames: RingProgressStylesNames;\n vars: RingProgressCssVariables;\n}>;\n\nconst defaultProps = {\n size: 120,\n thickness: 12,\n startAngle: 270,\n} satisfies Partial<RingProgressProps>;\n\nconst varsResolver = createVarsResolver<RingProgressFactory>(\n (_, { size, thickness, transitionDuration, startAngle }) => ({\n root: {\n '--rp-size': rem(size),\n '--rp-label-offset': rem(thickness! * 2),\n '--rp-transition-duration': transitionDuration ? `${transitionDuration}ms` : undefined,\n },\n svg: {\n '--rp-start-angle': `${startAngle}deg`,\n },\n })\n);\n\nexport const RingProgress = factory<RingProgressFactory>((_props) => {\n const props = useProps('RingProgress', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n label,\n sections,\n size,\n thickness,\n roundCaps,\n rootColor,\n transitionDuration,\n sectionGap,\n startAngle,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<RingProgressFactory>({\n name: 'RingProgress',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const clampedThickness = getClampedThickness(thickness, size);\n\n const curves = getCurves({\n size,\n thickness: clampedThickness,\n sections,\n renderRoundedLineCaps: roundCaps,\n rootColor,\n sectionGap,\n }).map(({ data, sum, root, lineRoundCaps, offset }, index) => (\n <Curve\n {...data}\n key={index}\n size={size}\n thickness={clampedThickness}\n sum={sum}\n offset={offset}\n color={data?.color}\n root={root}\n lineRoundCaps={lineRoundCaps}\n getStyles={getStyles}\n />\n ));\n\n return (\n <Box {...getStyles('root')} size={size} {...others}>\n <svg {...getStyles('svg')}>{curves}</svg>\n {label && <div {...getStyles('label')}>{label}</div>}\n </Box>\n );\n});\n\nRingProgress.classes = classes;\nRingProgress.varsResolver = varsResolver;\nRingProgress.displayName = '@mantine/core/RingProgress';\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,oBAAoB,WAAmB,MAAc;AAC5D,QAAO,KAAK,IAAI,aAAa,KAAK,QAAQ,OAAO,EAAE;;AAuDrD,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,YAAY;CACb;AAED,MAAM,eAAe,oBAClB,GAAG,EAAE,MAAM,WAAW,oBAAoB,kBAAkB;CAC3D,MAAM;EACJ,aAAa,IAAI,KAAK;EACtB,qBAAqB,IAAI,YAAa,EAAE;EACxC,4BAA4B,qBAAqB,GAAG,mBAAmB,MAAM,KAAA;EAC9E;CACD,KAAK,EACH,oBAAoB,GAAG,WAAW,MACnC;CACF,EACF;AAED,MAAa,eAAe,SAA8B,WAAW;CACnE,MAAM,QAAQ,SAAS,gBAAgB,cAAc,OAAO;CAC5D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,OACA,UACA,MACA,WACA,WACA,WACA,oBACA,YACA,YACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAA+B;EAC/C,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,mBAAmB,oBAAoB,WAAW,KAAK;CAE7D,MAAM,SAAS,UAAU;EACvB;EACA,WAAW;EACX;EACA,uBAAuB;EACvB;EACA;EACD,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,eAAe,UAAU,UAClD,8BAAC,OAAD;EACE,GAAI;EACJ,KAAK;EACC;EACN,WAAW;EACN;EACG;EACR,OAAO,MAAM;EACP;EACS;EACJ;EACX,CAAA,CACF;AAEF,QACE,qBAAC,KAAD;EAAK,GAAI,UAAU,OAAO;EAAQ;EAAM,GAAI;YAA5C,CACE,oBAAC,OAAD;GAAK,GAAI,UAAU,MAAM;aAAG;GAAa,CAAA,EACxC,SAAS,oBAAC,OAAD;GAAK,GAAI,UAAU,QAAQ;aAAG;GAAY,CAAA,CAChD;;EAER;AAEF,aAAa,UAAUA;AACvB,aAAa,eAAe;AAC5B,aAAa,cAAc"}
1
+ {"version":3,"file":"RingProgress.mjs","names":["classes"],"sources":["../../../src/components/RingProgress/RingProgress.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n factory,\n Factory,\n MantineColor,\n rem,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { Curve } from './Curve/Curve';\nimport { getCurves } from './get-curves/get-curves';\nimport classes from './RingProgress.module.css';\n\nfunction getClampedThickness(thickness: number, size: number) {\n return Math.min(thickness || 12, (size || 120) / 4);\n}\n\nexport interface RingProgressSection extends React.ComponentProps<'circle'>, DataAttributes {\n value: number;\n color: MantineColor;\n tooltip?: React.ReactNode;\n}\n\nexport type RingProgressStylesNames = 'root' | 'svg' | 'label' | 'curve';\nexport type RingProgressCssVariables = {\n root: '--rp-size' | '--rp-label-offset' | '--rp-transition-duration';\n svg: '--rp-start-angle';\n};\n\nexport interface RingProgressProps\n extends BoxProps, StylesApiProps<RingProgressFactory>, ElementProps<'div'> {\n /** Label displayed in the center of the ring */\n label?: React.ReactNode;\n\n /** Ring thickness in pixels. Cannot exceed size / 4 and will be automatically clamped if necessary @default 12 */\n thickness?: number;\n\n /** Width and height of the progress ring @default 120 */\n size?: number;\n\n /** Applies rounded line caps to the start and end of visible sections @default false */\n roundCaps?: boolean;\n\n /**\n * Array of sections to display in the ring. Each section should have a `value` (0-100),\n * `color`, and optional `tooltip`. Sections can also receive any valid SVG circle element props.\n */\n sections: RingProgressSection[];\n\n /** Color of the unfilled portion of the ring (background). Defaults to gray-2 in light mode, dark-4 in dark mode */\n rootColor?: MantineColor;\n\n /** Transition duration in milliseconds for section value and color changes @default 0 */\n transitionDuration?: number;\n\n /** Gap between sections in degrees. Reduces the visual size of each section @default 0 */\n sectionGap?: number;\n\n /** Starting angle in degrees. 0 = right, 90 = bottom, 180 = left, 270 = top @default 270 */\n startAngle?: number;\n}\n\nexport type RingProgressFactory = Factory<{\n props: RingProgressProps;\n ref: HTMLDivElement;\n stylesNames: RingProgressStylesNames;\n vars: RingProgressCssVariables;\n}>;\n\nconst defaultProps = {\n size: 120,\n thickness: 12,\n startAngle: 270,\n} satisfies Partial<RingProgressProps>;\n\nconst varsResolver = createVarsResolver<RingProgressFactory>(\n (_, { size, thickness, transitionDuration, startAngle }) => ({\n root: {\n '--rp-size': rem(size),\n '--rp-label-offset': rem(thickness! * 2),\n '--rp-transition-duration': transitionDuration ? `${transitionDuration}ms` : undefined,\n },\n svg: {\n '--rp-start-angle': `${startAngle}deg`,\n },\n })\n);\n\nexport const RingProgress = factory<RingProgressFactory>((_props) => {\n const props = useProps('RingProgress', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n label,\n sections,\n size,\n thickness,\n roundCaps,\n rootColor,\n transitionDuration,\n sectionGap,\n startAngle,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<RingProgressFactory>({\n name: 'RingProgress',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const clampedThickness = getClampedThickness(thickness, size);\n\n const curves = getCurves({\n size,\n thickness: clampedThickness,\n sections,\n renderRoundedLineCaps: roundCaps,\n rootColor,\n sectionGap,\n }).map(({ data, sum, root, lineRoundCaps, offset }, index) => (\n <Curve\n {...data}\n key={index}\n size={size}\n thickness={clampedThickness}\n sum={sum}\n offset={offset}\n color={data?.color}\n root={root}\n lineRoundCaps={lineRoundCaps}\n getStyles={getStyles}\n />\n ));\n\n return (\n <Box {...getStyles('root')} size={size} {...others}>\n <svg {...getStyles('svg')} viewBox={`0 0 ${size} ${size}`}>\n {curves}\n </svg>\n {label && <div {...getStyles('label')}>{label}</div>}\n </Box>\n );\n});\n\nRingProgress.classes = classes;\nRingProgress.varsResolver = varsResolver;\nRingProgress.displayName = '@mantine/core/RingProgress';\n\nexport namespace RingProgress {\n export type Props = RingProgressProps;\n export type StylesNames = RingProgressStylesNames;\n export type Factory = RingProgressFactory;\n export type CssVariables = RingProgressCssVariables;\n export type Section = RingProgressSection;\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,oBAAoB,WAAmB,MAAc;AAC5D,QAAO,KAAK,IAAI,aAAa,KAAK,QAAQ,OAAO,EAAE;;AAuDrD,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,YAAY;CACb;AAED,MAAM,eAAe,oBAClB,GAAG,EAAE,MAAM,WAAW,oBAAoB,kBAAkB;CAC3D,MAAM;EACJ,aAAa,IAAI,KAAK;EACtB,qBAAqB,IAAI,YAAa,EAAE;EACxC,4BAA4B,qBAAqB,GAAG,mBAAmB,MAAM,KAAA;EAC9E;CACD,KAAK,EACH,oBAAoB,GAAG,WAAW,MACnC;CACF,EACF;AAED,MAAa,eAAe,SAA8B,WAAW;CACnE,MAAM,QAAQ,SAAS,gBAAgB,cAAc,OAAO;CAC5D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,OACA,UACA,MACA,WACA,WACA,WACA,oBACA,YACA,YACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAA+B;EAC/C,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,mBAAmB,oBAAoB,WAAW,KAAK;CAE7D,MAAM,SAAS,UAAU;EACvB;EACA,WAAW;EACX;EACA,uBAAuB;EACvB;EACA;EACD,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,eAAe,UAAU,UAClD,8BAAC,OAAD;EACE,GAAI;EACJ,KAAK;EACC;EACN,WAAW;EACN;EACG;EACR,OAAO,MAAM;EACP;EACS;EACJ;EAC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