@react-md/core 6.2.1 → 6.3.1

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 (345) hide show
  1. package/dist/_base.scss +1 -1
  2. package/dist/app-bar/styles.d.ts +0 -2
  3. package/dist/app-bar/styles.js.map +1 -1
  4. package/dist/autocomplete/types.d.ts +12 -0
  5. package/dist/autocomplete/types.js.map +1 -1
  6. package/dist/avatar/Avatar.d.ts +0 -10
  7. package/dist/avatar/Avatar.js.map +1 -1
  8. package/dist/avatar/styles.d.ts +10 -0
  9. package/dist/avatar/styles.js.map +1 -1
  10. package/dist/badge/Badge.d.ts +11 -0
  11. package/dist/badge/Badge.js.map +1 -1
  12. package/dist/badge/styles.d.ts +0 -8
  13. package/dist/badge/styles.js.map +1 -1
  14. package/dist/box/_box.scss +8 -8
  15. package/dist/box/styles.d.ts +9 -0
  16. package/dist/box/styles.js.map +1 -1
  17. package/dist/button/_button.scss +4 -0
  18. package/dist/button/styles.d.ts +5 -1
  19. package/dist/button/styles.js.map +1 -1
  20. package/dist/card/Card.d.ts +0 -7
  21. package/dist/card/Card.js.map +1 -1
  22. package/dist/card/styles.d.ts +6 -0
  23. package/dist/card/styles.js +8 -8
  24. package/dist/card/styles.js.map +1 -1
  25. package/dist/chip/Chip.d.ts +6 -13
  26. package/dist/chip/Chip.js.map +1 -1
  27. package/dist/chip/styles.d.ts +26 -1
  28. package/dist/chip/styles.js.map +1 -1
  29. package/dist/datetime/NativeDateField.d.ts +24 -0
  30. package/dist/datetime/NativeDateField.js +63 -0
  31. package/dist/datetime/NativeDateField.js.map +1 -0
  32. package/dist/datetime/NativeTimeField.d.ts +26 -0
  33. package/dist/datetime/NativeTimeField.js +63 -0
  34. package/dist/datetime/NativeTimeField.js.map +1 -0
  35. package/dist/datetime/useDateField.d.ts +120 -0
  36. package/dist/datetime/useDateField.js +35 -0
  37. package/dist/datetime/useDateField.js.map +1 -0
  38. package/dist/datetime/useTimeField.d.ts +124 -0
  39. package/dist/datetime/useTimeField.js +65 -0
  40. package/dist/datetime/useTimeField.js.map +1 -0
  41. package/dist/datetime/utils.d.ts +34 -0
  42. package/dist/datetime/utils.js +27 -0
  43. package/dist/datetime/utils.js.map +1 -0
  44. package/dist/dialog/styles.d.ts +5 -2
  45. package/dist/dialog/styles.js.map +1 -1
  46. package/dist/divider/styles.d.ts +1 -1
  47. package/dist/divider/styles.js.map +1 -1
  48. package/dist/draggable/utils.d.ts +3 -6
  49. package/dist/draggable/utils.js.map +1 -1
  50. package/dist/error-boundary/ErrorBoundary.js.map +1 -1
  51. package/dist/expansion-panel/ExpansionList.js +1 -1
  52. package/dist/expansion-panel/ExpansionList.js.map +1 -1
  53. package/dist/expansion-panel/useExpansionList.d.ts +2 -7
  54. package/dist/expansion-panel/useExpansionList.js.map +1 -1
  55. package/dist/files/validation.js.map +1 -1
  56. package/dist/form/FormMessage.js +3 -1
  57. package/dist/form/FormMessage.js.map +1 -1
  58. package/dist/form/FormMessageContainer.d.ts +2 -1
  59. package/dist/form/FormMessageContainer.js +3 -2
  60. package/dist/form/FormMessageContainer.js.map +1 -1
  61. package/dist/form/FormMessageCounter.d.ts +3 -2
  62. package/dist/form/FormMessageCounter.js +5 -2
  63. package/dist/form/FormMessageCounter.js.map +1 -1
  64. package/dist/form/InputToggle.js.map +1 -1
  65. package/dist/form/Label.d.ts +0 -10
  66. package/dist/form/Label.js.map +1 -1
  67. package/dist/form/Listbox.d.ts +3 -10
  68. package/dist/form/Listbox.js +8 -27
  69. package/dist/form/Listbox.js.map +1 -1
  70. package/dist/form/ListboxProvider.d.ts +17 -0
  71. package/dist/form/ListboxProvider.js +33 -1
  72. package/dist/form/ListboxProvider.js.map +1 -1
  73. package/dist/form/NativeSelect.js +1 -0
  74. package/dist/form/NativeSelect.js.map +1 -1
  75. package/dist/form/Slider.d.ts +4 -0
  76. package/dist/form/Slider.js.map +1 -1
  77. package/dist/form/Switch.js.map +1 -1
  78. package/dist/form/TextArea.js +1 -0
  79. package/dist/form/TextArea.js.map +1 -1
  80. package/dist/form/TextField.js +1 -0
  81. package/dist/form/TextField.js.map +1 -1
  82. package/dist/form/TextFieldContainer.d.ts +0 -13
  83. package/dist/form/TextFieldContainer.js.map +1 -1
  84. package/dist/form/_form-message.scss +13 -0
  85. package/dist/form/_select.scss +5 -1
  86. package/dist/form/_text-area.scss +2 -1
  87. package/dist/form/_text-field.scss +13 -3
  88. package/dist/form/formMessageContainerStyles.d.ts +7 -0
  89. package/dist/form/formMessageContainerStyles.js +4 -2
  90. package/dist/form/formMessageContainerStyles.js.map +1 -1
  91. package/dist/form/sliderUtils.d.ts +3 -7
  92. package/dist/form/sliderUtils.js.map +1 -1
  93. package/dist/form/types.d.ts +33 -0
  94. package/dist/form/types.js.map +1 -1
  95. package/dist/form/useCombobox.d.ts +6 -2
  96. package/dist/form/useCombobox.js +8 -9
  97. package/dist/form/useCombobox.js.map +1 -1
  98. package/dist/form/useFormReset.d.ts +4 -1
  99. package/dist/form/useFormReset.js +9 -4
  100. package/dist/form/useFormReset.js.map +1 -1
  101. package/dist/form/useNumberField.d.ts +5 -5
  102. package/dist/form/useNumberField.js +10 -2
  103. package/dist/form/useNumberField.js.map +1 -1
  104. package/dist/form/useSelectCombobox.js +2 -2
  105. package/dist/form/useSelectCombobox.js.map +1 -1
  106. package/dist/form/useTextField.d.ts +76 -59
  107. package/dist/form/useTextField.js +7 -1
  108. package/dist/form/useTextField.js.map +1 -1
  109. package/dist/interaction/types.d.ts +5 -1
  110. package/dist/interaction/types.js.map +1 -1
  111. package/dist/interaction/utils.d.ts +14 -0
  112. package/dist/interaction/utils.js +23 -12
  113. package/dist/interaction/utils.js.map +1 -1
  114. package/dist/link/Link.d.ts +0 -7
  115. package/dist/link/Link.js.map +1 -1
  116. package/dist/link/styles.d.ts +7 -0
  117. package/dist/link/styles.js.map +1 -1
  118. package/dist/list/List.d.ts +5 -20
  119. package/dist/list/List.js.map +1 -1
  120. package/dist/list/ListItem.d.ts +4 -38
  121. package/dist/list/ListItem.js.map +1 -1
  122. package/dist/list/listItemStyles.d.ts +24 -2
  123. package/dist/list/listItemStyles.js.map +1 -1
  124. package/dist/list/listStyles.d.ts +17 -2
  125. package/dist/list/listStyles.js.map +1 -1
  126. package/dist/menu/Menu.js.map +1 -1
  127. package/dist/menu/MenuBar.js +1 -1
  128. package/dist/menu/MenuBar.js.map +1 -1
  129. package/dist/menu/MenuItemTextField.d.ts +1 -2
  130. package/dist/menu/MenuItemTextField.js.map +1 -1
  131. package/dist/menu/MenuWidget.js +3 -2
  132. package/dist/menu/MenuWidget.js.map +1 -1
  133. package/dist/movement/constants.d.ts +10 -0
  134. package/dist/movement/constants.js +20 -4
  135. package/dist/movement/constants.js.map +1 -1
  136. package/dist/movement/types.d.ts +59 -10
  137. package/dist/movement/types.js.map +1 -1
  138. package/dist/movement/useKeyboardMovementProvider.d.ts +5 -1
  139. package/dist/movement/useKeyboardMovementProvider.js +171 -73
  140. package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
  141. package/dist/navigation/NavItem.d.ts +4 -1
  142. package/dist/navigation/NavItem.js.map +1 -1
  143. package/dist/navigation/navItemStyles.d.ts +7 -0
  144. package/dist/navigation/navItemStyles.js.map +1 -1
  145. package/dist/overlay/Overlay.d.ts +4 -23
  146. package/dist/overlay/Overlay.js.map +1 -1
  147. package/dist/overlay/styles.d.ts +26 -8
  148. package/dist/overlay/styles.js.map +1 -1
  149. package/dist/progress/LinearProgress.d.ts +4 -9
  150. package/dist/progress/LinearProgress.js.map +1 -1
  151. package/dist/progress/circularProgressStyles.d.ts +6 -0
  152. package/dist/progress/circularProgressStyles.js.map +1 -1
  153. package/dist/progress/linearProgressStyles.d.ts +20 -5
  154. package/dist/progress/linearProgressStyles.js.map +1 -1
  155. package/dist/progress/types.d.ts +0 -9
  156. package/dist/progress/types.js.map +1 -1
  157. package/dist/segmented-button/SegmentedButton.d.ts +7 -12
  158. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  159. package/dist/segmented-button/segmentedButtonStyles.d.ts +26 -3
  160. package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
  161. package/dist/sheet/Sheet.d.ts +0 -12
  162. package/dist/sheet/Sheet.js.map +1 -1
  163. package/dist/sheet/styles.d.ts +12 -0
  164. package/dist/sheet/styles.js.map +1 -1
  165. package/dist/snackbar/Toast.d.ts +2 -13
  166. package/dist/snackbar/Toast.js.map +1 -1
  167. package/dist/snackbar/ToastManager.js.map +1 -1
  168. package/dist/snackbar/toastStyles.d.ts +17 -2
  169. package/dist/snackbar/toastStyles.js.map +1 -1
  170. package/dist/tabs/Tab.d.ts +2 -41
  171. package/dist/tabs/Tab.js.map +1 -1
  172. package/dist/tabs/tabStyles.d.ts +45 -4
  173. package/dist/tabs/tabStyles.js.map +1 -1
  174. package/dist/tabs/useTabList.js +1 -1
  175. package/dist/tabs/useTabList.js.map +1 -1
  176. package/dist/test-utils/drag.d.ts +6 -9
  177. package/dist/test-utils/mocks/IntersectionObserver.js.map +1 -1
  178. package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
  179. package/dist/test-utils/utils/createFileList.js.map +1 -1
  180. package/dist/theme/_theme.scss +0 -1
  181. package/dist/theme/getDerivedTheme.d.ts +0 -24
  182. package/dist/theme/getDerivedTheme.js.map +1 -1
  183. package/dist/theme/types.d.ts +25 -0
  184. package/dist/theme/types.js.map +1 -1
  185. package/dist/tooltip/Tooltip.d.ts +4 -32
  186. package/dist/tooltip/Tooltip.js.map +1 -1
  187. package/dist/tooltip/styles.d.ts +38 -1
  188. package/dist/tooltip/styles.js +1 -1
  189. package/dist/tooltip/styles.js.map +1 -1
  190. package/dist/transition/SkeletonPlaceholder.d.ts +0 -7
  191. package/dist/transition/SkeletonPlaceholder.js.map +1 -1
  192. package/dist/transition/Slide.js.map +1 -1
  193. package/dist/transition/skeletonPlaceholderUtils.d.ts +7 -0
  194. package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
  195. package/dist/transition/useCarousel.d.ts +2 -2
  196. package/dist/transition/useCarousel.js.map +1 -1
  197. package/dist/transition/useMaxWidthTransition.d.ts +14 -2
  198. package/dist/transition/useMaxWidthTransition.js.map +1 -1
  199. package/dist/transition/useSlideTransition.d.ts +5 -0
  200. package/dist/transition/useSlideTransition.js.map +1 -1
  201. package/dist/tree/Tree.d.ts +5 -9
  202. package/dist/tree/Tree.js +1 -1
  203. package/dist/tree/Tree.js.map +1 -1
  204. package/dist/tree/styles.d.ts +9 -1
  205. package/dist/tree/styles.js.map +1 -1
  206. package/dist/tree/useTreeMovement.d.ts +2 -1
  207. package/dist/tree/useTreeMovement.js +2 -1
  208. package/dist/tree/useTreeMovement.js.map +1 -1
  209. package/dist/types.d.ts +14 -0
  210. package/dist/types.js.map +1 -1
  211. package/dist/typography/Mark.d.ts +4 -1
  212. package/dist/typography/Mark.js.map +1 -1
  213. package/dist/typography/TextContainer.d.ts +0 -6
  214. package/dist/typography/TextContainer.js.map +1 -1
  215. package/dist/typography/markStyles.d.ts +5 -0
  216. package/dist/typography/markStyles.js.map +1 -1
  217. package/dist/typography/textContainerStyles.d.ts +6 -0
  218. package/dist/typography/textContainerStyles.js.map +1 -1
  219. package/dist/typography/typographyStyles.d.ts +9 -0
  220. package/dist/typography/typographyStyles.js.map +1 -1
  221. package/dist/useResizeObserver.js.map +1 -1
  222. package/dist/utils/getMiddleOfRange.d.ts +2 -3
  223. package/dist/utils/getMiddleOfRange.js.map +1 -1
  224. package/dist/utils/getPercentage.d.ts +2 -9
  225. package/dist/utils/getPercentage.js +1 -1
  226. package/dist/utils/getPercentage.js.map +1 -1
  227. package/dist/utils/getRangeSteps.d.ts +2 -3
  228. package/dist/utils/getRangeSteps.js +0 -3
  229. package/dist/utils/getRangeSteps.js.map +1 -1
  230. package/dist/utils/nearest.d.ts +2 -3
  231. package/dist/utils/nearest.js +0 -3
  232. package/dist/utils/nearest.js.map +1 -1
  233. package/dist/utils/trigonometry.d.ts +31 -0
  234. package/dist/utils/trigonometry.js +25 -0
  235. package/dist/utils/trigonometry.js.map +1 -0
  236. package/dist/window-splitter/WindowSplitter.d.ts +5 -19
  237. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  238. package/dist/window-splitter/styles.d.ts +27 -3
  239. package/dist/window-splitter/styles.js.map +1 -1
  240. package/dist/window-splitter/useWindowSplitter.d.ts +1 -1
  241. package/dist/window-splitter/useWindowSplitter.js.map +1 -1
  242. package/package.json +8 -8
  243. package/src/app-bar/styles.ts +0 -2
  244. package/src/autocomplete/types.ts +17 -0
  245. package/src/avatar/Avatar.tsx +0 -11
  246. package/src/avatar/styles.ts +11 -0
  247. package/src/badge/Badge.tsx +12 -0
  248. package/src/badge/styles.ts +0 -9
  249. package/src/box/styles.ts +9 -0
  250. package/src/button/styles.ts +5 -1
  251. package/src/card/Card.tsx +0 -8
  252. package/src/card/styles.ts +15 -8
  253. package/src/chip/Chip.tsx +9 -15
  254. package/src/chip/styles.ts +29 -1
  255. package/src/datetime/NativeDateField.tsx +92 -0
  256. package/src/datetime/NativeTimeField.tsx +94 -0
  257. package/src/datetime/useDateField.ts +193 -0
  258. package/src/datetime/useTimeField.ts +233 -0
  259. package/src/datetime/utils.ts +48 -0
  260. package/src/dialog/styles.ts +5 -2
  261. package/src/divider/styles.ts +1 -1
  262. package/src/draggable/utils.ts +3 -6
  263. package/src/expansion-panel/ExpansionList.tsx +2 -1
  264. package/src/expansion-panel/useExpansionList.ts +6 -12
  265. package/src/form/FormMessage.tsx +4 -0
  266. package/src/form/FormMessageContainer.tsx +8 -4
  267. package/src/form/FormMessageCounter.tsx +17 -6
  268. package/src/form/InputToggle.tsx +2 -0
  269. package/src/form/Label.tsx +0 -11
  270. package/src/form/Listbox.tsx +18 -46
  271. package/src/form/ListboxProvider.ts +61 -1
  272. package/src/form/NativeSelect.tsx +1 -0
  273. package/src/form/Slider.tsx +6 -0
  274. package/src/form/Switch.tsx +2 -0
  275. package/src/form/TextArea.tsx +3 -0
  276. package/src/form/TextField.tsx +1 -0
  277. package/src/form/TextFieldContainer.tsx +0 -14
  278. package/src/form/formMessageContainerStyles.ts +10 -2
  279. package/src/form/sliderUtils.ts +3 -7
  280. package/src/form/types.ts +44 -0
  281. package/src/form/useCombobox.ts +15 -10
  282. package/src/form/useFormReset.ts +12 -5
  283. package/src/form/useNumberField.ts +17 -14
  284. package/src/form/useSelectCombobox.ts +2 -2
  285. package/src/form/useTextField.ts +102 -69
  286. package/src/interaction/types.ts +5 -1
  287. package/src/interaction/utils.ts +18 -20
  288. package/src/link/Link.tsx +0 -8
  289. package/src/link/styles.ts +8 -0
  290. package/src/list/List.tsx +7 -24
  291. package/src/list/ListItem.tsx +7 -43
  292. package/src/list/listItemStyles.ts +26 -2
  293. package/src/list/listStyles.ts +18 -2
  294. package/src/menu/Menu.tsx +2 -0
  295. package/src/menu/MenuBar.tsx +1 -1
  296. package/src/menu/MenuItemTextField.tsx +1 -3
  297. package/src/menu/MenuWidget.tsx +4 -2
  298. package/src/movement/constants.ts +26 -4
  299. package/src/movement/types.ts +84 -19
  300. package/src/movement/useKeyboardMovementProvider.ts +209 -95
  301. package/src/navigation/NavItem.tsx +6 -2
  302. package/src/navigation/navItemStyles.ts +8 -0
  303. package/src/overlay/Overlay.tsx +4 -26
  304. package/src/overlay/styles.ts +29 -10
  305. package/src/progress/LinearProgress.tsx +8 -10
  306. package/src/progress/circularProgressStyles.ts +7 -0
  307. package/src/progress/linearProgressStyles.ts +22 -5
  308. package/src/progress/types.ts +0 -10
  309. package/src/segmented-button/SegmentedButton.tsx +14 -15
  310. package/src/segmented-button/segmentedButtonStyles.ts +28 -3
  311. package/src/sheet/Sheet.tsx +0 -13
  312. package/src/sheet/styles.ts +13 -0
  313. package/src/snackbar/Toast.tsx +2 -15
  314. package/src/snackbar/toastStyles.ts +20 -2
  315. package/src/tabs/Tab.tsx +4 -49
  316. package/src/tabs/tabStyles.ts +52 -4
  317. package/src/tabs/useTabList.ts +1 -1
  318. package/src/test-utils/drag.ts +8 -12
  319. package/src/theme/getDerivedTheme.ts +0 -26
  320. package/src/theme/types.ts +26 -0
  321. package/src/tooltip/Tooltip.tsx +4 -36
  322. package/src/tooltip/styles.ts +43 -2
  323. package/src/transition/SkeletonPlaceholder.tsx +0 -8
  324. package/src/transition/Slide.tsx +2 -0
  325. package/src/transition/skeletonPlaceholderUtils.ts +8 -0
  326. package/src/transition/useCarousel.ts +2 -2
  327. package/src/transition/useMaxWidthTransition.ts +17 -2
  328. package/src/transition/useSlideTransition.ts +8 -0
  329. package/src/tree/Tree.tsx +6 -11
  330. package/src/tree/styles.ts +10 -1
  331. package/src/tree/useTreeMovement.ts +4 -0
  332. package/src/types.ts +16 -0
  333. package/src/typography/Mark.tsx +6 -2
  334. package/src/typography/TextContainer.tsx +0 -7
  335. package/src/typography/markStyles.ts +6 -0
  336. package/src/typography/textContainerStyles.ts +7 -0
  337. package/src/typography/typographyStyles.ts +10 -0
  338. package/src/utils/getMiddleOfRange.ts +2 -3
  339. package/src/utils/getPercentage.ts +3 -11
  340. package/src/utils/getRangeSteps.ts +3 -3
  341. package/src/utils/nearest.ts +3 -3
  342. package/src/utils/trigonometry.ts +46 -0
  343. package/src/window-splitter/WindowSplitter.tsx +9 -22
  344. package/src/window-splitter/styles.ts +31 -3
  345. package/src/window-splitter/useWindowSplitter.ts +3 -2
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { useRef } from "react";
3
+ import { useTextField } from "../form/useTextField.js";
4
+ /**
5
+ * @since 6.3.0
6
+ * @see {@link https://react-md.dev/components/native-date-field | NativeTimeField Demos}
7
+ * @see {@link https://react-md.dev/hooks/use-date-field | useTimeField Demos}
8
+ */ export function useDateField(options) {
9
+ const { min, max, step, ...fieldOptions } = options;
10
+ const { fieldProps, ...impl } = useTextField(fieldOptions);
11
+ // NOTE: Unlike the other text field components, the `value` should **not**
12
+ // be provided since the time input behaves a bit weirdly with the `onChange`
13
+ // event and it is better to rely on default browser behavior instead of
14
+ // controlling the value. The flow is:
15
+ // - user types `12:30`
16
+ // - `onChange` is fired with `12:30`
17
+ // - user selects `30` and hits backspace
18
+ // - `onChange` is fired with `""`
19
+ // If the `value` is set, the other time values would be lost
20
+ const { value, ...allowedFieldProps } = fieldProps;
21
+ const initial = useRef(value);
22
+ return {
23
+ ...impl,
24
+ fieldProps: {
25
+ ...allowedFieldProps,
26
+ defaultValue: initial.current,
27
+ min,
28
+ max,
29
+ step,
30
+ type: "date"
31
+ }
32
+ };
33
+ }
34
+
35
+ //# sourceMappingURL=useDateField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/datetime/useDateField.ts"],"sourcesContent":["\"use client\";\n\nimport { type InputHTMLAttributes, useRef } from \"react\";\n\nimport {\n type ProvidedFormMessageProps,\n type ProvidedTextFieldProps,\n type TextFieldHookOptions,\n type TextFieldImplementation,\n type TextFieldWithMessageImplementation,\n useTextField,\n} from \"../form/useTextField.js\";\n\n/**\n * @since 6.3.0\n */\nexport interface DateFieldConstraints {\n /**\n * This **must** be in the format `yyyy-mm-dd`\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#min | min attribute}\n */\n min?: string;\n\n /**\n * This **must** be in the format `yyyy-mm-dd`\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#max | max attribute}\n */\n max?: string;\n\n /**\n * For date inputs, the value of step is given in days; and is treated as a\n * number of milliseconds equal to 86,400,000 times the step value (the\n * underlying numeric value is in milliseconds). The default value of step is\n * 1, indicating 1 day.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#step | step attribute}\n */\n step?: number | \"any\";\n}\n\n/** @since 6.3.0 */\nexport interface DateFieldOptions\n extends Omit<\n TextFieldHookOptions,\n | \"isNumber\"\n | \"counter\"\n | \"pattern\"\n | \"maxLength\"\n | \"minLength\"\n | \"disableMaxLength\"\n >,\n DateFieldConstraints {}\n\n/** @since 6.3.0 */\nexport interface ProvidedDateFieldProps\n extends Omit<ProvidedTextFieldProps, \"value\">,\n Omit<DateFieldConstraints, \"step\"> {\n type: \"date\";\n step?: number | \"any\";\n defaultValue: Required<InputHTMLAttributes<HTMLInputElement>>[\"defaultValue\"];\n}\n\n/** @since 6.3.0 */\nexport interface ProvidedDateFieldMessageProps extends ProvidedDateFieldProps {\n /**\n * These props will be defined as long as the `disableMessage` prop is not\n * `true` from the `useTextField` hook.\n */\n messageProps: ProvidedFormMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface DateFieldImplementation\n extends Omit<TextFieldImplementation, \"fieldProps\"> {\n fieldProps: ProvidedDateFieldProps;\n}\n\n/** @since 6.3.0 */\nexport interface DateFieldWithMessageImplementation\n extends Omit<TextFieldWithMessageImplementation, \"fieldProps\"> {\n fieldProps: ProvidedDateFieldMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface ValidatedDateFieldImplementation\n extends DateFieldImplementation {\n fieldProps: ProvidedDateFieldProps | ProvidedDateFieldMessageProps;\n}\n\n/**\n * The `useDateField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"date\" />`. It is used in the `NativeDateField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useDateField } from \"@react-md/core/datetime/useDateField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps, error, errorMessage } = useDateField({\n * name: \"delivery\",\n * required: true,\n * min: \"2025-01-01\",\n * max: \"2026-01-01\",\n * disableMessage: true,\n * });\n *\n * // value: `\"\"` or `\"yyyy-mm-dd\"`\n *\n * return <TextField label=\"Delivery Date\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-date-field | NativeDateField Demos}\n * @see {@link https://react-md.dev/hooks/use-date-field | useDateField Demos}\n */\nexport function useDateField(\n options: DateFieldOptions & { disableMessage: true }\n): DateFieldImplementation;\n\n/**\n * The `useDateField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"date\" />`. It is used in the `NativeDateField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useDateField } from \"@react-md/core/datetime/useDateField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps } = useDateField({\n * name: \"delivery\",\n * required: true,\n * min: \"2025-01-01\",\n * max: \"2026-01-01\",\n * });\n *\n * // value: `\"\"` or `\"yyyy-mm-dd\"`\n *\n * return <TextField label=\"Delivery Date\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-date-field | NativeDateField Demos}\n * @see {@link https://react-md.dev/hooks/use-date-field | useDateField Demos}\n */\nexport function useDateField(\n options: DateFieldOptions\n): DateFieldWithMessageImplementation;\n\n/**\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-date-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-date-field | useTimeField Demos}\n */\nexport function useDateField(\n options: DateFieldOptions\n): ValidatedDateFieldImplementation {\n const { min, max, step, ...fieldOptions } = options;\n const { fieldProps, ...impl } = useTextField(fieldOptions);\n\n // NOTE: Unlike the other text field components, the `value` should **not**\n // be provided since the time input behaves a bit weirdly with the `onChange`\n // event and it is better to rely on default browser behavior instead of\n // controlling the value. The flow is:\n // - user types `12:30`\n // - `onChange` is fired with `12:30`\n // - user selects `30` and hits backspace\n // - `onChange` is fired with `\"\"`\n // If the `value` is set, the other time values would be lost\n const { value, ...allowedFieldProps } = fieldProps;\n const initial = useRef(value);\n\n return {\n ...impl,\n fieldProps: {\n ...allowedFieldProps,\n defaultValue: initial.current,\n min,\n max,\n step,\n type: \"date\",\n },\n };\n}\n"],"names":["useRef","useTextField","useDateField","options","min","max","step","fieldOptions","fieldProps","impl","value","allowedFieldProps","initial","defaultValue","current","type"],"mappings":"AAAA;AAEA,SAAmCA,MAAM,QAAQ,QAAQ;AAEzD,SAMEC,YAAY,QACP,0BAA0B;AAmJjC;;;;CAIC,GACD,OAAO,SAASC,aACdC,OAAyB;IAEzB,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGC,cAAc,GAAGJ;IAC5C,MAAM,EAAEK,UAAU,EAAE,GAAGC,MAAM,GAAGR,aAAaM;IAE7C,2EAA2E;IAC3E,6EAA6E;IAC7E,wEAAwE;IACxE,sCAAsC;IACtC,uBAAuB;IACvB,uCAAuC;IACvC,yCAAyC;IACzC,oCAAoC;IACpC,6DAA6D;IAC7D,MAAM,EAAEG,KAAK,EAAE,GAAGC,mBAAmB,GAAGH;IACxC,MAAMI,UAAUZ,OAAOU;IAEvB,OAAO;QACL,GAAGD,IAAI;QACPD,YAAY;YACV,GAAGG,iBAAiB;YACpBE,cAAcD,QAAQE,OAAO;YAC7BV;YACAC;YACAC;YACAS,MAAM;QACR;IACF;AACF"}
@@ -0,0 +1,124 @@
1
+ import { type InputHTMLAttributes } from "react";
2
+ import { type ProvidedFormMessageProps, type ProvidedTextFieldProps, type TextFieldHookOptions, type TextFieldImplementation, type TextFieldWithMessageImplementation } from "../form/useTextField.js";
3
+ import { type TimeFieldStepOptions } from "./utils.js";
4
+ /** @since 6.3.0 */
5
+ export interface TimeFieldConstraints {
6
+ /**
7
+ * This **must** be in the format `HH:mm`:
8
+ * - `00:30` (12:30 AM)
9
+ * - `15:15` (03:15 PM)
10
+ *
11
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}
12
+ */
13
+ min?: string;
14
+ /**
15
+ * This **must** be in the format `HH:mm`:
16
+ * - `00:30` (12:30 AM)
17
+ * - `15:15` (03:15 PM)
18
+ *
19
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}
20
+ */
21
+ max?: string;
22
+ /**
23
+ * For time inputs, the value of step is given in seconds, with a scaling
24
+ * factor of 1000 (since the underlying numeric value is in milliseconds).
25
+ * The default value of step is 60, indicating 60 seconds (or 1 minute, or
26
+ * 60,000 milliseconds).
27
+ *
28
+ * When any is set as the value for step, the default 60 seconds is used, and
29
+ * the seconds value is not displayed in the UI.
30
+ *
31
+ * Here are a few examples:
32
+ *
33
+ * - `15` -&gt; 15 seconds
34
+ * - `60` -&gt; 1 minute
35
+ * - `900` -&gt; 15 minutes
36
+ * - `3600` -&gt; 1 hour
37
+ *
38
+ * Since this might be a bit confusing, the values can be provided in an
39
+ * object instead:
40
+ *
41
+ * ```ts
42
+ * { seconds: 30 }
43
+ * { minutes: 1 }
44
+ * { minutes: 15 }
45
+ * { hours: 1 }
46
+ * { seconds: 15, minutes: 30, hours: 1 }
47
+ * ```
48
+ *
49
+ * NOTE: The `min` and `max` props **must** be provided as well for the
50
+ * `step` to work.
51
+ *
52
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#step | step attribute}
53
+ */
54
+ step?: number | "any" | TimeFieldStepOptions;
55
+ }
56
+ /** @since 6.3.0 */
57
+ export interface TimeFieldOptions extends Omit<TextFieldHookOptions, "isNumber" | "counter" | "pattern" | "maxLength" | "minLength" | "disableMaxLength">, TimeFieldConstraints {
58
+ }
59
+ /** @since 6.3.0 */
60
+ export interface ProvidedTimeFieldProps extends Omit<ProvidedTextFieldProps, "value">, Omit<TimeFieldConstraints, "step"> {
61
+ type: "time";
62
+ step?: number | "any";
63
+ defaultValue: Required<InputHTMLAttributes<HTMLInputElement>>["defaultValue"];
64
+ }
65
+ /** @since 6.3.0 */
66
+ export interface ProvidedTimeFieldMessageProps extends ProvidedTimeFieldProps {
67
+ /**
68
+ * These props will be defined as long as the `disableMessage` prop is not
69
+ * `true` from the `useTextField` hook.
70
+ */
71
+ messageProps: ProvidedFormMessageProps;
72
+ }
73
+ /** @since 6.3.0 */
74
+ export interface TimeFieldImplementation extends Omit<TextFieldImplementation, "fieldProps"> {
75
+ fieldProps: ProvidedTimeFieldProps;
76
+ }
77
+ /** @since 6.3.0 */
78
+ export interface TimeFieldWithMessageImplementation extends Omit<TextFieldWithMessageImplementation, "fieldProps"> {
79
+ fieldProps: ProvidedTimeFieldMessageProps;
80
+ }
81
+ /** @since 6.3.0 */
82
+ export interface ValidatedTimeFieldImplementation extends TimeFieldImplementation {
83
+ fieldProps: ProvidedTimeFieldProps | ProvidedTimeFieldMessageProps;
84
+ }
85
+ /**
86
+ * @since 6.3.0
87
+ * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}
88
+ * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}
89
+ */
90
+ export declare function useTimeField(options: TimeFieldOptions & {
91
+ disableMessage: true;
92
+ }): TimeFieldImplementation;
93
+ /**
94
+ * The `useTimeField` is a small wrapper around the {@link useTextField} to be used
95
+ * with `<input type="time" />`. It is used in the `NativeTimeField` if an example
96
+ * implementation would like to be seen.
97
+ *
98
+ * @example Simple Example
99
+ * ```tsx
100
+ * import { useTimeField } from "@react-md/core/datetime/useTimeField";
101
+ * import { TextField } from "@react-md/core/form/TextField";
102
+ * import { type ReactElement } from "react";
103
+ *
104
+ * function Example(): ReactElement {
105
+ * const { value, fieldProps, error, errorMessage } = useTimeField({
106
+ * name: "appt",
107
+ * required: true,
108
+ * min: "08:00",
109
+ * max: "17:00",
110
+ * step: { minute: 15 },
111
+ * disableMessage: true,
112
+ * });
113
+ *
114
+ * // value: `""` or `"HH:mm"`
115
+ *
116
+ * return <TextField label="Appointment" {...fieldProps} />
117
+ * }
118
+ * ```
119
+ *
120
+ * @since 6.3.0
121
+ * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}
122
+ * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}
123
+ */
124
+ export declare function useTimeField(options: TimeFieldOptions): TimeFieldWithMessageImplementation;
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { useRef } from "react";
3
+ import { useTextField } from "../form/useTextField.js";
4
+ import { getTimeStep } from "./utils.js";
5
+ /**
6
+ * The `useTimeField` is a small wrapper around the {@link useTextField} to be used
7
+ * with `<input type="time" />`. It is used in the `NativeTimeField` if an example
8
+ * implementation would like to be seen.
9
+ *
10
+ * @example Simple Example
11
+ * ```tsx
12
+ * import { useTimeField } from "@react-md/core/datetime/useTimeField";
13
+ * import { TextField } from "@react-md/core/form/TextField";
14
+ * import { type ReactElement } from "react";
15
+ *
16
+ * function Example(): ReactElement {
17
+ * const { value, fieldProps } = useTimeField({
18
+ * name: "appt",
19
+ * required: true,
20
+ * min: "08:00",
21
+ * max: "17:00",
22
+ * step: { minute: 15 },
23
+ * });
24
+ *
25
+ * // value: `""` or `"HH:mm"`
26
+ *
27
+ * return <TextField label="Appointment" {...fieldProps} />
28
+ * }
29
+ * ```
30
+ *
31
+ * @since 6.3.0
32
+ * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}
33
+ * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}
34
+ */ export function useTimeField(options) {
35
+ const { min, max, step, ...fieldOptions } = options;
36
+ if (process.env.NODE_ENV !== "production" && typeof step !== "undefined" && (!min || !max)) {
37
+ throw new Error("A `step` was provided to a time field without the `min` or `max` props.");
38
+ }
39
+ const { errorMessage, fieldProps, ...impl } = useTextField(fieldOptions);
40
+ // NOTE: Unlike the other text field components, the `value` should **not**
41
+ // be provided since the time input behaves a bit weirdly with the `onChange`
42
+ // event and it is better to rely on default browser behavior instead of
43
+ // controlling the value. The flow is:
44
+ // - user types `12:30`
45
+ // - `onChange` is fired with `12:30`
46
+ // - user selects `30` and hits backspace
47
+ // - `onChange` is fired with `""`
48
+ // If the `value` is set, the other time values would be lost
49
+ const { value, ...allowedFieldProps } = fieldProps;
50
+ const initial = useRef(value);
51
+ return {
52
+ ...impl,
53
+ errorMessage,
54
+ fieldProps: {
55
+ ...allowedFieldProps,
56
+ defaultValue: initial.current,
57
+ min,
58
+ max,
59
+ step: getTimeStep(step),
60
+ type: "time"
61
+ }
62
+ };
63
+ }
64
+
65
+ //# sourceMappingURL=useTimeField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/datetime/useTimeField.ts"],"sourcesContent":["\"use client\";\n\nimport { type InputHTMLAttributes, useRef } from \"react\";\n\nimport {\n type ProvidedFormMessageProps,\n type ProvidedTextFieldProps,\n type TextFieldHookOptions,\n type TextFieldImplementation,\n type TextFieldWithMessageImplementation,\n useTextField,\n} from \"../form/useTextField.js\";\nimport { type TimeFieldStepOptions, getTimeStep } from \"./utils.js\";\n\n/** @since 6.3.0 */\nexport interface TimeFieldConstraints {\n /**\n * This **must** be in the format `HH:mm`:\n * - `00:30` (12:30 AM)\n * - `15:15` (03:15 PM)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}\n */\n min?: string;\n\n /**\n * This **must** be in the format `HH:mm`:\n * - `00:30` (12:30 AM)\n * - `15:15` (03:15 PM)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}\n */\n max?: string;\n\n /**\n * For time inputs, the value of step is given in seconds, with a scaling\n * factor of 1000 (since the underlying numeric value is in milliseconds).\n * The default value of step is 60, indicating 60 seconds (or 1 minute, or\n * 60,000 milliseconds).\n *\n * When any is set as the value for step, the default 60 seconds is used, and\n * the seconds value is not displayed in the UI.\n *\n * Here are a few examples:\n *\n * - `15` -&gt; 15 seconds\n * - `60` -&gt; 1 minute\n * - `900` -&gt; 15 minutes\n * - `3600` -&gt; 1 hour\n *\n * Since this might be a bit confusing, the values can be provided in an\n * object instead:\n *\n * ```ts\n * { seconds: 30 }\n * { minutes: 1 }\n * { minutes: 15 }\n * { hours: 1 }\n * { seconds: 15, minutes: 30, hours: 1 }\n * ```\n *\n * NOTE: The `min` and `max` props **must** be provided as well for the\n * `step` to work.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#step | step attribute}\n */\n step?: number | \"any\" | TimeFieldStepOptions;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldOptions\n extends Omit<\n TextFieldHookOptions,\n | \"isNumber\"\n | \"counter\"\n | \"pattern\"\n | \"maxLength\"\n | \"minLength\"\n | \"disableMaxLength\"\n >,\n TimeFieldConstraints {}\n\n/** @since 6.3.0 */\nexport interface ProvidedTimeFieldProps\n extends Omit<ProvidedTextFieldProps, \"value\">,\n Omit<TimeFieldConstraints, \"step\"> {\n type: \"time\";\n step?: number | \"any\";\n defaultValue: Required<InputHTMLAttributes<HTMLInputElement>>[\"defaultValue\"];\n}\n\n/** @since 6.3.0 */\nexport interface ProvidedTimeFieldMessageProps extends ProvidedTimeFieldProps {\n /**\n * These props will be defined as long as the `disableMessage` prop is not\n * `true` from the `useTextField` hook.\n */\n messageProps: ProvidedFormMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldImplementation\n extends Omit<TextFieldImplementation, \"fieldProps\"> {\n fieldProps: ProvidedTimeFieldProps;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldWithMessageImplementation\n extends Omit<TextFieldWithMessageImplementation, \"fieldProps\"> {\n fieldProps: ProvidedTimeFieldMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface ValidatedTimeFieldImplementation\n extends TimeFieldImplementation {\n fieldProps: ProvidedTimeFieldProps | ProvidedTimeFieldMessageProps;\n}\n\n/**\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}\n */\nexport function useTimeField(\n options: TimeFieldOptions & { disableMessage: true }\n): TimeFieldImplementation;\n\n/**\n * The `useTimeField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"time\" />`. It is used in the `NativeTimeField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useTimeField } from \"@react-md/core/datetime/useTimeField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps, error, errorMessage } = useTimeField({\n * name: \"appt\",\n * required: true,\n * min: \"08:00\",\n * max: \"17:00\",\n * step: { minute: 15 },\n * disableMessage: true,\n * });\n *\n * // value: `\"\"` or `\"HH:mm\"`\n *\n * return <TextField label=\"Appointment\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}\n */\nexport function useTimeField(\n options: TimeFieldOptions\n): TimeFieldWithMessageImplementation;\n\n/**\n * The `useTimeField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"time\" />`. It is used in the `NativeTimeField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useTimeField } from \"@react-md/core/datetime/useTimeField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps } = useTimeField({\n * name: \"appt\",\n * required: true,\n * min: \"08:00\",\n * max: \"17:00\",\n * step: { minute: 15 },\n * });\n *\n * // value: `\"\"` or `\"HH:mm\"`\n *\n * return <TextField label=\"Appointment\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}\n */\nexport function useTimeField(\n options: TimeFieldOptions\n): ValidatedTimeFieldImplementation {\n const { min, max, step, ...fieldOptions } = options;\n if (\n process.env.NODE_ENV !== \"production\" &&\n typeof step !== \"undefined\" &&\n (!min || !max)\n ) {\n throw new Error(\n \"A `step` was provided to a time field without the `min` or `max` props.\"\n );\n }\n\n const { errorMessage, fieldProps, ...impl } = useTextField(fieldOptions);\n\n // NOTE: Unlike the other text field components, the `value` should **not**\n // be provided since the time input behaves a bit weirdly with the `onChange`\n // event and it is better to rely on default browser behavior instead of\n // controlling the value. The flow is:\n // - user types `12:30`\n // - `onChange` is fired with `12:30`\n // - user selects `30` and hits backspace\n // - `onChange` is fired with `\"\"`\n // If the `value` is set, the other time values would be lost\n const { value, ...allowedFieldProps } = fieldProps;\n const initial = useRef(value);\n\n return {\n ...impl,\n errorMessage,\n fieldProps: {\n ...allowedFieldProps,\n defaultValue: initial.current,\n min,\n max,\n step: getTimeStep(step),\n type: \"time\",\n },\n };\n}\n"],"names":["useRef","useTextField","getTimeStep","useTimeField","options","min","max","step","fieldOptions","process","env","NODE_ENV","Error","errorMessage","fieldProps","impl","value","allowedFieldProps","initial","defaultValue","current","type"],"mappings":"AAAA;AAEA,SAAmCA,MAAM,QAAQ,QAAQ;AAEzD,SAMEC,YAAY,QACP,0BAA0B;AACjC,SAAoCC,WAAW,QAAQ,aAAa;AAsJpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,SAASC,aACdC,OAAyB;IAEzB,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGC,cAAc,GAAGJ;IAC5C,IACEK,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzB,OAAOJ,SAAS,eACf,CAAA,CAACF,OAAO,CAACC,GAAE,GACZ;QACA,MAAM,IAAIM,MACR;IAEJ;IAEA,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGC,MAAM,GAAGd,aAAaO;IAE3D,2EAA2E;IAC3E,6EAA6E;IAC7E,wEAAwE;IACxE,sCAAsC;IACtC,uBAAuB;IACvB,uCAAuC;IACvC,yCAAyC;IACzC,oCAAoC;IACpC,6DAA6D;IAC7D,MAAM,EAAEQ,KAAK,EAAE,GAAGC,mBAAmB,GAAGH;IACxC,MAAMI,UAAUlB,OAAOgB;IAEvB,OAAO;QACL,GAAGD,IAAI;QACPF;QACAC,YAAY;YACV,GAAGG,iBAAiB;YACpBE,cAAcD,QAAQE,OAAO;YAC7Bf;YACAC;YACAC,MAAML,YAAYK;YAClBc,MAAM;QACR;IACF;AACF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Since time input steps are based on seconds, this is a simple helper to
3
+ * create the step in a human-readable form.
4
+ *
5
+ * @since 6.3.0
6
+ */
7
+ export interface TimeFieldStepOptions {
8
+ /**
9
+ * @defaultValue `0`
10
+ */
11
+ seconds?: number;
12
+ /**
13
+ * @defaultValue `0`
14
+ */
15
+ minutes?: number;
16
+ /**
17
+ * @defaultValue `0`
18
+ */
19
+ hours?: number;
20
+ }
21
+ /**
22
+ * Since time input steps are based on seconds, this is a simple helper to
23
+ * create the step in a human-readable form.
24
+ *
25
+ * @example Simple Example
26
+ * ```tsx
27
+ * const step1 = getTimeStep({ minutes: 15 });
28
+ * const step2 = getTimeStep({ hours: 1 });
29
+ * const step3 = getTimeStep({ seconds: 15, minutes: 30, hours: 2 });
30
+ * ```
31
+ *
32
+ * @since 6.3.0
33
+ */
34
+ export declare function getTimeStep(step: TimeFieldStepOptions | "any" | number | undefined): number | "any" | undefined;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Since time input steps are based on seconds, this is a simple helper to
3
+ * create the step in a human-readable form.
4
+ *
5
+ * @since 6.3.0
6
+ */ /**
7
+ * Since time input steps are based on seconds, this is a simple helper to
8
+ * create the step in a human-readable form.
9
+ *
10
+ * @example Simple Example
11
+ * ```tsx
12
+ * const step1 = getTimeStep({ minutes: 15 });
13
+ * const step2 = getTimeStep({ hours: 1 });
14
+ * const step3 = getTimeStep({ seconds: 15, minutes: 30, hours: 2 });
15
+ * ```
16
+ *
17
+ * @since 6.3.0
18
+ */ export function getTimeStep(step) {
19
+ if (!step || typeof step === "string" || typeof step === "number") {
20
+ return step;
21
+ }
22
+ const { hours = 0, minutes = 0, seconds = 0 } = step;
23
+ const total = Math.abs(Math.round(seconds + minutes * 60 + hours * 60 * 60));
24
+ return total === 0 ? undefined : total;
25
+ }
26
+
27
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/datetime/utils.ts"],"sourcesContent":["/**\n * Since time input steps are based on seconds, this is a simple helper to\n * create the step in a human-readable form.\n *\n * @since 6.3.0\n */\nexport interface TimeFieldStepOptions {\n /**\n * @defaultValue `0`\n */\n seconds?: number;\n\n /**\n * @defaultValue `0`\n */\n minutes?: number;\n\n /**\n * @defaultValue `0`\n */\n hours?: number;\n}\n\n/**\n * Since time input steps are based on seconds, this is a simple helper to\n * create the step in a human-readable form.\n *\n * @example Simple Example\n * ```tsx\n * const step1 = getTimeStep({ minutes: 15 });\n * const step2 = getTimeStep({ hours: 1 });\n * const step3 = getTimeStep({ seconds: 15, minutes: 30, hours: 2 });\n * ```\n *\n * @since 6.3.0\n */\nexport function getTimeStep(\n step: TimeFieldStepOptions | \"any\" | number | undefined\n): number | \"any\" | undefined {\n if (!step || typeof step === \"string\" || typeof step === \"number\") {\n return step;\n }\n\n const { hours = 0, minutes = 0, seconds = 0 } = step;\n\n const total = Math.abs(Math.round(seconds + minutes * 60 + hours * 60 * 60));\n return total === 0 ? undefined : total;\n}\n"],"names":["getTimeStep","step","hours","minutes","seconds","total","Math","abs","round","undefined"],"mappings":"AAAA;;;;;CAKC,GAkBD;;;;;;;;;;;;CAYC,GACD,OAAO,SAASA,YACdC,IAAuD;IAEvD,IAAI,CAACA,QAAQ,OAAOA,SAAS,YAAY,OAAOA,SAAS,UAAU;QACjE,OAAOA;IACT;IAEA,MAAM,EAAEC,QAAQ,CAAC,EAAEC,UAAU,CAAC,EAAEC,UAAU,CAAC,EAAE,GAAGH;IAEhD,MAAMI,QAAQC,KAAKC,GAAG,CAACD,KAAKE,KAAK,CAACJ,UAAUD,UAAU,KAAKD,QAAQ,KAAK;IACxE,OAAOG,UAAU,IAAII,YAAYJ;AACnC"}
@@ -1,7 +1,5 @@
1
1
  declare module "react" {
2
2
  interface CSSProperties {
3
- "--rmd-dialog-background-color"?: string;
4
- "--rmd-dialog-color"?: string;
5
3
  "--rmd-dialog-min-width"?: string | number;
6
4
  "--rmd-dialog-horizontal-margin"?: string | number;
7
5
  "--rmd-dialog-vertical-margin"?: string | number;
@@ -10,6 +8,11 @@ declare module "react" {
10
8
  "--rmd-dialog-header-padding-bottom"?: string | number;
11
9
  "--rmd-dialog-content-padding"?: string | number;
12
10
  "--rmd-dialog-footer-padding"?: string | number;
11
+ "--rmd-dialog-width"?: string | number;
12
+ "--rmd-dialog-small-width"?: string | number;
13
+ "--rmd-dialog-medium-width"?: string | number;
14
+ "--rmd-dialog-large-width"?: string | number;
15
+ "--rmd-dialog-extra-large-width"?: string | number;
13
16
  }
14
17
  }
15
18
  export type DialogType = "full-page" | "centered" | "custom";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/dialog/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport {\n type CSSTransitionClassNames,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-dialog-background-color\"?: string;\n \"--rmd-dialog-color\"?: string;\n \"--rmd-dialog-min-width\"?: string | number;\n \"--rmd-dialog-horizontal-margin\"?: string | number;\n \"--rmd-dialog-vertical-margin\"?: string | number;\n \"--rmd-dialog-z-index\"?: string | number;\n \"--rmd-dialog-header-padding\"?: string | number;\n \"--rmd-dialog-header-padding-bottom\"?: string | number;\n \"--rmd-dialog-content-padding\"?: string | number;\n \"--rmd-dialog-footer-padding\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-dialog\");\nconst containerStyles = bem(\"rmd-dialog-container\");\n\nexport type DialogType = \"full-page\" | \"centered\" | \"custom\";\n\n/**\n * This can be used to enforce a specific width for dialogs instead of relying\n * on the size of the content to determine the width. The width will also ensure\n * that it does not overflow based on the viewport width and margins applied.\n *\n * For example: if the `width=\"extra-large\"` and the total viewport size is\n * `600px`, the dialog width would be `420px` since there is a default `80px`\n * margin to the left and right of the dialog. If the user expands the browser,\n * the dialog width will continue to grow until it reaches the `extra-large`\n * width and stop growing from that point.\n *\n * @since 6.0.0\n */\nexport type DialogWidth = \"auto\" | \"small\" | \"medium\" | \"large\" | \"extra-large\";\n\n/**\n * @since 6.0.0\n */\nexport interface DialogContainerClassNameOptions {\n className?: string;\n\n centered?: boolean;\n displayNone?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function dialogContainer(\n options: DialogContainerClassNameOptions = {}\n): string {\n const { className, centered, displayNone } = options;\n\n return cnb(\n containerStyles({ centered }),\n displayNone && DISPLAY_NONE_CLASS,\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogClassNameOptions {\n className?: string;\n\n /**\n * @defaultValue `\"centered\"`\n */\n type?: DialogType;\n\n /**\n * @defaultValue `\"auto\"`\n */\n width?: DialogWidth;\n\n /**\n * @defaultValue `false`\n */\n fixed?: boolean;\n\n /**\n * @defaultValue `type === \"full-page\"`\n */\n outline?: boolean;\n\n /**\n * This is mostly used for handling nested dialogs and removes any box shadow\n * on a dialog that has a child visible.\n *\n * @defaultValue `false`\n */\n disableBoxShadow?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialog(options: DialogClassNameOptions = {}): string {\n const {\n type = \"centered\",\n width,\n fixed = false,\n outline = type === \"full-page\",\n disableBoxShadow,\n className,\n } = options;\n\n return cnb(\n styles({\n fixed,\n outline,\n centered: type === \"centered\",\n \"full-page\": type === \"full-page\",\n \"no-box-shadow\": type === \"centered\" && disableBoxShadow,\n \"s-width\": width === \"small\",\n \"m-width\": width === \"medium\",\n \"l-width\": width === \"large\",\n \"xl-width\": width === \"extra-large\",\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogHeaderClassNameOptions {\n className?: string;\n}\n\n/**\n * NOTE: The default `DialogHeader` component uses the `Box` component so the\n * `box` class name utility function or `Box` component will probably be\n * required if using this util\n *\n * @since 6.0.0\n */\nexport function dialogHeader(\n options: DialogHeaderClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(\"header\"), className);\n}\n\n/** @since 6.0.0 */\nexport interface DialogContentClassNameOptions {\n className?: string;\n\n /** @defaultValue `false` */\n disablePadding?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialogContent(\n options: DialogContentClassNameOptions = {}\n): string {\n const { className, disablePadding = false } = options;\n\n return cnb(styles(\"content\", { padded: !disablePadding }), className);\n}\n\n/**\n * An optional alignment for the content within the footer. Since the majority\n * of dialog footers are used to contain action buttons, the default alignment\n * is near the end.\n *\n * @since 3.1.0\n */\nexport type DialogFooterAlignment =\n | \"none\"\n | \"start\"\n | \"end\"\n | \"between\"\n | \"stacked-start\"\n | \"stacked-end\";\n\n/** @since 6.0.0 */\nexport interface DialogFooterClassNameOptions {\n className?: string;\n\n /** @defaultValue `\"end\"` */\n align?: DialogFooterAlignment;\n}\n\n/** @since 6.0.0 */\nexport function dialogFooter(\n options: DialogFooterClassNameOptions = {}\n): string {\n const { align = \"end\", className } = options;\n\n return cnb(\n styles(\"footer\", {\n flex: align !== \"none\",\n \"flex-v\": align === \"stacked-start\" || align === \"stacked-end\",\n start: align === \"start\" || align === \"stacked-start\",\n between: align === \"between\",\n end: align === \"end\" || align === \"stacked-end\",\n }),\n className\n );\n}\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_TIMEOUT = {\n enter: 200,\n exit: 150,\n} as const satisfies TransitionTimeout;\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_CLASSNAMES = {\n appear: \"rmd-dialog--enter\",\n appearActive: \"rmd-dialog--enter-active\",\n enter: \"rmd-dialog--enter\",\n enterActive: \"rmd-dialog--enter-active\",\n exit: \"rmd-dialog--exit\",\n exitActive: \"rmd-dialog--exit-active\",\n} as const satisfies CSSTransitionClassNames;\n"],"names":["cnb","bem","DISPLAY_NONE_CLASS","styles","containerStyles","dialogContainer","options","className","centered","displayNone","dialog","type","width","fixed","outline","disableBoxShadow","dialogHeader","dialogContent","disablePadding","padded","dialogFooter","align","flex","start","between","end","DEFAULT_DIALOG_TIMEOUT","enter","exit","DEFAULT_DIALOG_CLASSNAMES","appear","appearActive","enterActive","exitActive"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAMhC,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,kBAAkB,QAAQ,+BAA+B;AAiBlE,MAAMC,SAASF,IAAI;AACnB,MAAMG,kBAAkBH,IAAI;AA6B5B;;CAEC,GACD,OAAO,SAASI,gBACdC,UAA2C,CAAC,CAAC;IAE7C,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGH;IAE7C,OAAON,IACLI,gBAAgB;QAAEI;IAAS,IAC3BC,eAAeP,oBACfK;AAEJ;AAmCA,iBAAiB,GACjB,OAAO,SAASG,OAAOJ,UAAkC,CAAC,CAAC;IACzD,MAAM,EACJK,OAAO,UAAU,EACjBC,KAAK,EACLC,QAAQ,KAAK,EACbC,UAAUH,SAAS,WAAW,EAC9BI,gBAAgB,EAChBR,SAAS,EACV,GAAGD;IAEJ,OAAON,IACLG,OAAO;QACLU;QACAC;QACAN,UAAUG,SAAS;QACnB,aAAaA,SAAS;QACtB,iBAAiBA,SAAS,cAAcI;QACxC,WAAWH,UAAU;QACrB,WAAWA,UAAU;QACrB,WAAWA,UAAU;QACrB,YAAYA,UAAU;IACxB,IACAL;AAEJ;AAOA;;;;;;CAMC,GACD,OAAO,SAASS,aACdV,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAON,IAAIG,OAAO,WAAWI;AAC/B;AAUA,iBAAiB,GACjB,OAAO,SAASU,cACdX,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,SAAS,EAAEW,iBAAiB,KAAK,EAAE,GAAGZ;IAE9C,OAAON,IAAIG,OAAO,WAAW;QAAEgB,QAAQ,CAACD;IAAe,IAAIX;AAC7D;AAyBA,iBAAiB,GACjB,OAAO,SAASa,aACdd,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEe,QAAQ,KAAK,EAAEd,SAAS,EAAE,GAAGD;IAErC,OAAON,IACLG,OAAO,UAAU;QACfmB,MAAMD,UAAU;QAChB,UAAUA,UAAU,mBAAmBA,UAAU;QACjDE,OAAOF,UAAU,WAAWA,UAAU;QACtCG,SAASH,UAAU;QACnBI,KAAKJ,UAAU,SAASA,UAAU;IACpC,IACAd;AAEJ;AAEA,iBAAiB,GACjB,OAAO,MAAMmB,yBAAyB;IACpCC,OAAO;IACPC,MAAM;AACR,EAAuC;AAEvC,iBAAiB,GACjB,OAAO,MAAMC,4BAA4B;IACvCC,QAAQ;IACRC,cAAc;IACdJ,OAAO;IACPK,aAAa;IACbJ,MAAM;IACNK,YAAY;AACd,EAA6C"}
1
+ {"version":3,"sources":["../../src/dialog/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport {\n type CSSTransitionClassNames,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-dialog-min-width\"?: string | number;\n \"--rmd-dialog-horizontal-margin\"?: string | number;\n \"--rmd-dialog-vertical-margin\"?: string | number;\n \"--rmd-dialog-z-index\"?: string | number;\n \"--rmd-dialog-header-padding\"?: string | number;\n \"--rmd-dialog-header-padding-bottom\"?: string | number;\n \"--rmd-dialog-content-padding\"?: string | number;\n \"--rmd-dialog-footer-padding\"?: string | number;\n \"--rmd-dialog-width\"?: string | number;\n \"--rmd-dialog-small-width\"?: string | number;\n \"--rmd-dialog-medium-width\"?: string | number;\n \"--rmd-dialog-large-width\"?: string | number;\n \"--rmd-dialog-extra-large-width\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-dialog\");\nconst containerStyles = bem(\"rmd-dialog-container\");\n\nexport type DialogType = \"full-page\" | \"centered\" | \"custom\";\n\n/**\n * This can be used to enforce a specific width for dialogs instead of relying\n * on the size of the content to determine the width. The width will also ensure\n * that it does not overflow based on the viewport width and margins applied.\n *\n * For example: if the `width=\"extra-large\"` and the total viewport size is\n * `600px`, the dialog width would be `420px` since there is a default `80px`\n * margin to the left and right of the dialog. If the user expands the browser,\n * the dialog width will continue to grow until it reaches the `extra-large`\n * width and stop growing from that point.\n *\n * @since 6.0.0\n */\nexport type DialogWidth = \"auto\" | \"small\" | \"medium\" | \"large\" | \"extra-large\";\n\n/**\n * @since 6.0.0\n */\nexport interface DialogContainerClassNameOptions {\n className?: string;\n\n centered?: boolean;\n displayNone?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function dialogContainer(\n options: DialogContainerClassNameOptions = {}\n): string {\n const { className, centered, displayNone } = options;\n\n return cnb(\n containerStyles({ centered }),\n displayNone && DISPLAY_NONE_CLASS,\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogClassNameOptions {\n className?: string;\n\n /**\n * @defaultValue `\"centered\"`\n */\n type?: DialogType;\n\n /**\n * @defaultValue `\"auto\"`\n */\n width?: DialogWidth;\n\n /**\n * @defaultValue `false`\n */\n fixed?: boolean;\n\n /**\n * @defaultValue `type === \"full-page\"`\n */\n outline?: boolean;\n\n /**\n * This is mostly used for handling nested dialogs and removes any box shadow\n * on a dialog that has a child visible.\n *\n * @defaultValue `false`\n */\n disableBoxShadow?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialog(options: DialogClassNameOptions = {}): string {\n const {\n type = \"centered\",\n width,\n fixed = false,\n outline = type === \"full-page\",\n disableBoxShadow,\n className,\n } = options;\n\n return cnb(\n styles({\n fixed,\n outline,\n centered: type === \"centered\",\n \"full-page\": type === \"full-page\",\n \"no-box-shadow\": type === \"centered\" && disableBoxShadow,\n \"s-width\": width === \"small\",\n \"m-width\": width === \"medium\",\n \"l-width\": width === \"large\",\n \"xl-width\": width === \"extra-large\",\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogHeaderClassNameOptions {\n className?: string;\n}\n\n/**\n * NOTE: The default `DialogHeader` component uses the `Box` component so the\n * `box` class name utility function or `Box` component will probably be\n * required if using this util\n *\n * @since 6.0.0\n */\nexport function dialogHeader(\n options: DialogHeaderClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(\"header\"), className);\n}\n\n/** @since 6.0.0 */\nexport interface DialogContentClassNameOptions {\n className?: string;\n\n /** @defaultValue `false` */\n disablePadding?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialogContent(\n options: DialogContentClassNameOptions = {}\n): string {\n const { className, disablePadding = false } = options;\n\n return cnb(styles(\"content\", { padded: !disablePadding }), className);\n}\n\n/**\n * An optional alignment for the content within the footer. Since the majority\n * of dialog footers are used to contain action buttons, the default alignment\n * is near the end.\n *\n * @since 3.1.0\n */\nexport type DialogFooterAlignment =\n | \"none\"\n | \"start\"\n | \"end\"\n | \"between\"\n | \"stacked-start\"\n | \"stacked-end\";\n\n/** @since 6.0.0 */\nexport interface DialogFooterClassNameOptions {\n className?: string;\n\n /** @defaultValue `\"end\"` */\n align?: DialogFooterAlignment;\n}\n\n/** @since 6.0.0 */\nexport function dialogFooter(\n options: DialogFooterClassNameOptions = {}\n): string {\n const { align = \"end\", className } = options;\n\n return cnb(\n styles(\"footer\", {\n flex: align !== \"none\",\n \"flex-v\": align === \"stacked-start\" || align === \"stacked-end\",\n start: align === \"start\" || align === \"stacked-start\",\n between: align === \"between\",\n end: align === \"end\" || align === \"stacked-end\",\n }),\n className\n );\n}\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_TIMEOUT = {\n enter: 200,\n exit: 150,\n} as const satisfies TransitionTimeout;\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_CLASSNAMES = {\n appear: \"rmd-dialog--enter\",\n appearActive: \"rmd-dialog--enter-active\",\n enter: \"rmd-dialog--enter\",\n enterActive: \"rmd-dialog--enter-active\",\n exit: \"rmd-dialog--exit\",\n exitActive: \"rmd-dialog--exit-active\",\n} as const satisfies CSSTransitionClassNames;\n"],"names":["cnb","bem","DISPLAY_NONE_CLASS","styles","containerStyles","dialogContainer","options","className","centered","displayNone","dialog","type","width","fixed","outline","disableBoxShadow","dialogHeader","dialogContent","disablePadding","padded","dialogFooter","align","flex","start","between","end","DEFAULT_DIALOG_TIMEOUT","enter","exit","DEFAULT_DIALOG_CLASSNAMES","appear","appearActive","enterActive","exitActive"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAMhC,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,kBAAkB,QAAQ,+BAA+B;AAoBlE,MAAMC,SAASF,IAAI;AACnB,MAAMG,kBAAkBH,IAAI;AA6B5B;;CAEC,GACD,OAAO,SAASI,gBACdC,UAA2C,CAAC,CAAC;IAE7C,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGH;IAE7C,OAAON,IACLI,gBAAgB;QAAEI;IAAS,IAC3BC,eAAeP,oBACfK;AAEJ;AAmCA,iBAAiB,GACjB,OAAO,SAASG,OAAOJ,UAAkC,CAAC,CAAC;IACzD,MAAM,EACJK,OAAO,UAAU,EACjBC,KAAK,EACLC,QAAQ,KAAK,EACbC,UAAUH,SAAS,WAAW,EAC9BI,gBAAgB,EAChBR,SAAS,EACV,GAAGD;IAEJ,OAAON,IACLG,OAAO;QACLU;QACAC;QACAN,UAAUG,SAAS;QACnB,aAAaA,SAAS;QACtB,iBAAiBA,SAAS,cAAcI;QACxC,WAAWH,UAAU;QACrB,WAAWA,UAAU;QACrB,WAAWA,UAAU;QACrB,YAAYA,UAAU;IACxB,IACAL;AAEJ;AAOA;;;;;;CAMC,GACD,OAAO,SAASS,aACdV,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAON,IAAIG,OAAO,WAAWI;AAC/B;AAUA,iBAAiB,GACjB,OAAO,SAASU,cACdX,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,SAAS,EAAEW,iBAAiB,KAAK,EAAE,GAAGZ;IAE9C,OAAON,IAAIG,OAAO,WAAW;QAAEgB,QAAQ,CAACD;IAAe,IAAIX;AAC7D;AAyBA,iBAAiB,GACjB,OAAO,SAASa,aACdd,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEe,QAAQ,KAAK,EAAEd,SAAS,EAAE,GAAGD;IAErC,OAAON,IACLG,OAAO,UAAU;QACfmB,MAAMD,UAAU;QAChB,UAAUA,UAAU,mBAAmBA,UAAU;QACjDE,OAAOF,UAAU,WAAWA,UAAU;QACtCG,SAASH,UAAU;QACnBI,KAAKJ,UAAU,SAASA,UAAU;IACpC,IACAd;AAEJ;AAEA,iBAAiB,GACjB,OAAO,MAAMmB,yBAAyB;IACpCC,OAAO;IACPC,MAAM;AACR,EAAuC;AAEvC,iBAAiB,GACjB,OAAO,MAAMC,4BAA4B;IACvCC,QAAQ;IACRC,cAAc;IACdJ,OAAO;IACPK,aAAa;IACbJ,MAAM;IACNK,YAAY;AACd,EAA6C"}
@@ -1,7 +1,7 @@
1
1
  declare module "react" {
2
2
  interface CSSProperties {
3
3
  "--rmd-divider-size"?: string | number;
4
- "--rmd-divider-vertical-size"?: string | number;
4
+ "--rmd-divider-border-size"?: string | number;
5
5
  "--rmd-divider-color"?: string;
6
6
  "--rmd-divider-spacing"?: string | number;
7
7
  "--rmd-divider-vertical-spacing"?: string | number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/divider/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-divider-size\"?: string | number;\n \"--rmd-divider-vertical-size\"?: string | number;\n \"--rmd-divider-color\"?: string;\n \"--rmd-divider-spacing\"?: string | number;\n \"--rmd-divider-vertical-spacing\"?: string | number;\n \"--rmd-divider-inset\"?: string | number;\n \"--rmd-divider-max-size\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-divider\");\n\n/** @since 6.0.0 */\nexport interface DividerClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the divider should appear inset instead of full width. This\n * really just applied a margin-left (or margin-right when dir=\"rtl\").\n *\n * If you want to create a divider that is centered, you most likely want to\n * use the `rmd-divider-theme-update-var` mixin instead to update the\n * `max-size` of the divider.\n *\n * @defaultValue `false`\n */\n inset?: boolean;\n\n /**\n * Boolean if the divider should be vertical instead of horizontal. This will\n * change the divider to be rendered as a `<div>` instead of an `<hr>`.\n *\n * Note: If your parent element of the divider does not have a static height\n * set, you **must** manually set the height of the divider to a static\n * non-percentage number OR use the `VerticalDivider` component instead to\n * automagically create a valid percentage height.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function divider(options: DividerClassNameOptions = {}): string {\n const { inset = false, vertical = false, className } = options;\n\n return cnb(\n styles({\n inset: inset && !vertical,\n vertical,\n }),\n className\n );\n}\n"],"names":["cnb","bem","styles","divider","options","inset","vertical","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AActC,MAAMC,SAASD,IAAI;AAgCnB;;CAEC,GACD,OAAO,SAASE,QAAQC,UAAmC,CAAC,CAAC;IAC3D,MAAM,EAAEC,QAAQ,KAAK,EAAEC,WAAW,KAAK,EAAEC,SAAS,EAAE,GAAGH;IAEvD,OAAOJ,IACLE,OAAO;QACLG,OAAOA,SAAS,CAACC;QACjBA;IACF,IACAC;AAEJ"}
1
+ {"version":3,"sources":["../../src/divider/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-divider-size\"?: string | number;\n \"--rmd-divider-border-size\"?: string | number;\n \"--rmd-divider-color\"?: string;\n \"--rmd-divider-spacing\"?: string | number;\n \"--rmd-divider-vertical-spacing\"?: string | number;\n \"--rmd-divider-inset\"?: string | number;\n \"--rmd-divider-max-size\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-divider\");\n\n/** @since 6.0.0 */\nexport interface DividerClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the divider should appear inset instead of full width. This\n * really just applied a margin-left (or margin-right when dir=\"rtl\").\n *\n * If you want to create a divider that is centered, you most likely want to\n * use the `rmd-divider-theme-update-var` mixin instead to update the\n * `max-size` of the divider.\n *\n * @defaultValue `false`\n */\n inset?: boolean;\n\n /**\n * Boolean if the divider should be vertical instead of horizontal. This will\n * change the divider to be rendered as a `<div>` instead of an `<hr>`.\n *\n * Note: If your parent element of the divider does not have a static height\n * set, you **must** manually set the height of the divider to a static\n * non-percentage number OR use the `VerticalDivider` component instead to\n * automagically create a valid percentage height.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function divider(options: DividerClassNameOptions = {}): string {\n const { inset = false, vertical = false, className } = options;\n\n return cnb(\n styles({\n inset: inset && !vertical,\n vertical,\n }),\n className\n );\n}\n"],"names":["cnb","bem","styles","divider","options","inset","vertical","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AActC,MAAMC,SAASD,IAAI;AAgCnB;;CAEC,GACD,OAAO,SAASE,QAAQC,UAAmC,CAAC,CAAC;IAC3D,MAAM,EAAEC,QAAQ,KAAK,EAAEC,WAAW,KAAK,EAAEC,SAAS,EAAE,GAAGH;IAEvD,OAAOJ,IACLE,OAAO;QACLG,OAAOA,SAAS,CAACC;QACjBA;IACF,IACAC;AAEJ"}
@@ -1,4 +1,5 @@
1
1
  import { type MouseEvent, type RefObject, type TouchEvent } from "react";
2
+ import { type MinMaxRange } from "../types.js";
2
3
  import { type ClientPositionEvent, type ClientPositionOptions } from "../utils/getClientPosition.js";
3
4
  /**
4
5
  * @internal
@@ -23,9 +24,7 @@ export declare const getDragPosition: (options: DragPositionOptions) => number;
23
24
  /**
24
25
  * @internal
25
26
  */
26
- interface RelativeDragPositionOptions extends DragPositionOptions {
27
- min: number;
28
- max: number;
27
+ interface RelativeDragPositionOptions extends DragPositionOptions, MinMaxRange {
29
28
  step: number;
30
29
  rangeMin: number;
31
30
  rangeMax: number;
@@ -62,9 +61,7 @@ export declare const updateDragPosition: (options: UpdateDragPositionOptions) =>
62
61
  * @internal
63
62
  * @since 6.0.0
64
63
  */
65
- export interface DeserializeDraggableValueOptions {
66
- min: number;
67
- max: number;
64
+ export interface DeserializeDraggableValueOptions extends MinMaxRange {
68
65
  item: string;
69
66
  }
70
67
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/draggable/utils.ts"],"sourcesContent":["import { type MouseEvent, type RefObject, type TouchEvent } from \"react\";\n\nimport {\n type ClientPositionEvent,\n type ClientPositionOptions,\n getClientPosition,\n} from \"../utils/getClientPosition.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\nimport { nearest } from \"../utils/nearest.js\";\nimport { withinRange } from \"../utils/withinRange.js\";\n\n/**\n * @internal\n */\nexport const isMouseDragStartEvent = (event: MouseEvent): boolean =>\n event.button === 0 &&\n !event.altKey &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.shiftKey;\n\n/**\n * @internal\n */\nexport const isTouchDragStartEvent = (event: TouchEvent): boolean =>\n event.changedTouches.length === 1;\n\n/**\n * @internal\n */\ninterface DragPositionOptions extends ClientPositionOptions {\n isRTL: boolean;\n reversed: boolean;\n container: Element;\n}\n\n/**\n * @internal\n */\nexport const getDragPosition = (options: DragPositionOptions): number => {\n const { isRTL, reversed, vertical, container } = options;\n\n const clientPosition = getClientPosition(options);\n const { left, right, top } = container.getBoundingClientRect();\n if (vertical) {\n if (reversed) {\n return window.innerHeight - clientPosition;\n }\n\n // added `Math.max` since the `top` will be a negative number if rendered\n // within a portal element like a dialog/sheet\n return clientPosition - Math.max(0, top);\n }\n\n if (reversed ? !isRTL : isRTL) {\n return right - clientPosition;\n }\n\n return clientPosition - left;\n};\n\n/**\n * @internal\n */\ninterface RelativeDragPositionOptions extends DragPositionOptions {\n min: number;\n max: number;\n step: number;\n rangeMin: number;\n rangeMax: number;\n}\n\n/**\n * @internal\n */\ninterface RelativeDragPosition {\n value: number;\n dragPercentage: number;\n}\n\n/**\n * @internal\n */\nexport const getRelativeDragPosition = (\n options: RelativeDragPositionOptions\n): RelativeDragPosition => {\n const { min, max, rangeMin, rangeMax, step, isRTL, vertical, container } =\n options;\n\n const { height, width, left, top } = container.getBoundingClientRect();\n const containerSize = vertical ? height : width;\n const containerPosition = vertical ? top + height : left;\n const clientPosition = getClientPosition(options);\n\n const position = vertical\n ? containerPosition - clientPosition\n : clientPosition - containerPosition;\n const distanceDragged = Math.min(Math.max(0, position), containerSize);\n let dragPercentage = distanceDragged / containerSize;\n if (isRTL && !vertical) {\n dragPercentage = 1 - dragPercentage;\n }\n\n const range = rangeMax - rangeMin;\n const steps = getRangeSteps({ min: rangeMin, max: rangeMax, step });\n const value = dragPercentage * range + rangeMin;\n const nextValue = nearest({\n min,\n max,\n steps,\n range,\n value,\n });\n\n return {\n value: nextValue,\n dragPercentage,\n };\n};\n\n/**\n * @internal\n */\ninterface UpdateDragPositionOptions\n extends Omit<RelativeDragPositionOptions, \"container\"> {\n event: ClientPositionEvent;\n nodeRef: RefObject<HTMLElement>;\n focus?: boolean;\n isDragStart: boolean;\n setValue: (value: number) => void;\n setDragging: (dragging: boolean) => void;\n setDragPercentage: (value: number) => void;\n withinOffsetParent: boolean;\n}\n\n/**\n * @internal\n */\nexport const updateDragPosition = (\n options: UpdateDragPositionOptions\n): void => {\n const {\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n isDragStart,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n } = options;\n\n const element = nodeRef.current;\n if (!element) {\n return;\n }\n\n if (isDragStart) {\n // need to focus so that Chromium based browsers allow drag events. this\n // really appeared while trying to create a DnD tree\n element.focus({ preventScroll: true });\n\n if (!withinOffsetParent && !(\"changedTouches\" in event)) {\n return;\n }\n\n // unlike the other flow, start dragging immediately so that you can trigger\n // a mousedown or touchstart event on the container element and drag until\n // the user lets go\n setDragging(true);\n }\n\n // firefox defaults to `document.body` while chrome will return `null`\n const container = element.offsetParent || document.body;\n if (!withinOffsetParent) {\n const dragPosition = getDragPosition({\n event,\n isRTL,\n reversed,\n vertical,\n container,\n });\n const nextValue = withinRange({\n min,\n max,\n value: dragPosition,\n });\n setValue(nextValue);\n\n return;\n }\n\n const { value, dragPercentage } = getRelativeDragPosition({\n min,\n max,\n rangeMin,\n rangeMax,\n step,\n event,\n isRTL,\n reversed,\n vertical,\n container,\n });\n\n setValue(value);\n setDragPercentage(dragPercentage);\n};\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface DeserializeDraggableValueOptions {\n min: number;\n max: number;\n item: string;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function deserializeDraggableValue(\n options: DeserializeDraggableValueOptions\n): number {\n const { item, min, max } = options;\n\n const value = parseFloat(item);\n if (Number.isNaN(item)) {\n return min;\n }\n\n return Math.max(min, Math.min(max, value));\n}\n"],"names":["getClientPosition","getRangeSteps","nearest","withinRange","isMouseDragStartEvent","event","button","altKey","metaKey","ctrlKey","shiftKey","isTouchDragStartEvent","changedTouches","length","getDragPosition","options","isRTL","reversed","vertical","container","clientPosition","left","right","top","getBoundingClientRect","window","innerHeight","Math","max","getRelativeDragPosition","min","rangeMin","rangeMax","step","height","width","containerSize","containerPosition","position","distanceDragged","dragPercentage","range","steps","value","nextValue","updateDragPosition","nodeRef","isDragStart","setValue","setDragging","setDragPercentage","withinOffsetParent","element","current","focus","preventScroll","offsetParent","document","body","dragPosition","deserializeDraggableValue","item","parseFloat","Number","isNaN"],"mappings":"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"}
1
+ {"version":3,"sources":["../../src/draggable/utils.ts"],"sourcesContent":["import { type MouseEvent, type RefObject, type TouchEvent } from \"react\";\n\nimport { type MinMaxRange } from \"../types.js\";\nimport {\n type ClientPositionEvent,\n type ClientPositionOptions,\n getClientPosition,\n} from \"../utils/getClientPosition.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\nimport { nearest } from \"../utils/nearest.js\";\nimport { withinRange } from \"../utils/withinRange.js\";\n\n/**\n * @internal\n */\nexport const isMouseDragStartEvent = (event: MouseEvent): boolean =>\n event.button === 0 &&\n !event.altKey &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.shiftKey;\n\n/**\n * @internal\n */\nexport const isTouchDragStartEvent = (event: TouchEvent): boolean =>\n event.changedTouches.length === 1;\n\n/**\n * @internal\n */\ninterface DragPositionOptions extends ClientPositionOptions {\n isRTL: boolean;\n reversed: boolean;\n container: Element;\n}\n\n/**\n * @internal\n */\nexport const getDragPosition = (options: DragPositionOptions): number => {\n const { isRTL, reversed, vertical, container } = options;\n\n const clientPosition = getClientPosition(options);\n const { left, right, top } = container.getBoundingClientRect();\n if (vertical) {\n if (reversed) {\n return window.innerHeight - clientPosition;\n }\n\n // added `Math.max` since the `top` will be a negative number if rendered\n // within a portal element like a dialog/sheet\n return clientPosition - Math.max(0, top);\n }\n\n if (reversed ? !isRTL : isRTL) {\n return right - clientPosition;\n }\n\n return clientPosition - left;\n};\n\n/**\n * @internal\n */\ninterface RelativeDragPositionOptions extends DragPositionOptions, MinMaxRange {\n step: number;\n rangeMin: number;\n rangeMax: number;\n}\n\n/**\n * @internal\n */\ninterface RelativeDragPosition {\n value: number;\n dragPercentage: number;\n}\n\n/**\n * @internal\n */\nexport const getRelativeDragPosition = (\n options: RelativeDragPositionOptions\n): RelativeDragPosition => {\n const { min, max, rangeMin, rangeMax, step, isRTL, vertical, container } =\n options;\n\n const { height, width, left, top } = container.getBoundingClientRect();\n const containerSize = vertical ? height : width;\n const containerPosition = vertical ? top + height : left;\n const clientPosition = getClientPosition(options);\n\n const position = vertical\n ? containerPosition - clientPosition\n : clientPosition - containerPosition;\n const distanceDragged = Math.min(Math.max(0, position), containerSize);\n let dragPercentage = distanceDragged / containerSize;\n if (isRTL && !vertical) {\n dragPercentage = 1 - dragPercentage;\n }\n\n const range = rangeMax - rangeMin;\n const steps = getRangeSteps({ min: rangeMin, max: rangeMax, step });\n const value = dragPercentage * range + rangeMin;\n const nextValue = nearest({\n min,\n max,\n steps,\n range,\n value,\n });\n\n return {\n value: nextValue,\n dragPercentage,\n };\n};\n\n/**\n * @internal\n */\ninterface UpdateDragPositionOptions\n extends Omit<RelativeDragPositionOptions, \"container\"> {\n event: ClientPositionEvent;\n nodeRef: RefObject<HTMLElement>;\n focus?: boolean;\n isDragStart: boolean;\n setValue: (value: number) => void;\n setDragging: (dragging: boolean) => void;\n setDragPercentage: (value: number) => void;\n withinOffsetParent: boolean;\n}\n\n/**\n * @internal\n */\nexport const updateDragPosition = (\n options: UpdateDragPositionOptions\n): void => {\n const {\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n isDragStart,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n } = options;\n\n const element = nodeRef.current;\n if (!element) {\n return;\n }\n\n if (isDragStart) {\n // need to focus so that Chromium based browsers allow drag events. this\n // really appeared while trying to create a DnD tree\n element.focus({ preventScroll: true });\n\n if (!withinOffsetParent && !(\"changedTouches\" in event)) {\n return;\n }\n\n // unlike the other flow, start dragging immediately so that you can trigger\n // a mousedown or touchstart event on the container element and drag until\n // the user lets go\n setDragging(true);\n }\n\n // firefox defaults to `document.body` while chrome will return `null`\n const container = element.offsetParent || document.body;\n if (!withinOffsetParent) {\n const dragPosition = getDragPosition({\n event,\n isRTL,\n reversed,\n vertical,\n container,\n });\n const nextValue = withinRange({\n min,\n max,\n value: dragPosition,\n });\n setValue(nextValue);\n\n return;\n }\n\n const { value, dragPercentage } = getRelativeDragPosition({\n min,\n max,\n rangeMin,\n rangeMax,\n step,\n event,\n isRTL,\n reversed,\n vertical,\n container,\n });\n\n setValue(value);\n setDragPercentage(dragPercentage);\n};\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface DeserializeDraggableValueOptions extends MinMaxRange {\n item: string;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function deserializeDraggableValue(\n options: DeserializeDraggableValueOptions\n): number {\n const { item, min, max } = options;\n\n const value = parseFloat(item);\n if (Number.isNaN(item)) {\n return min;\n }\n\n return Math.max(min, Math.min(max, value));\n}\n"],"names":["getClientPosition","getRangeSteps","nearest","withinRange","isMouseDragStartEvent","event","button","altKey","metaKey","ctrlKey","shiftKey","isTouchDragStartEvent","changedTouches","length","getDragPosition","options","isRTL","reversed","vertical","container","clientPosition","left","right","top","getBoundingClientRect","window","innerHeight","Math","max","getRelativeDragPosition","min","rangeMin","rangeMax","step","height","width","containerSize","containerPosition","position","distanceDragged","dragPercentage","range","steps","value","nextValue","updateDragPosition","nodeRef","isDragStart","setValue","setDragging","setDragPercentage","withinOffsetParent","element","current","focus","preventScroll","offsetParent","document","body","dragPosition","deserializeDraggableValue","item","parseFloat","Number","isNaN"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error-boundary/ErrorBoundary.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Component,\n type ErrorInfo,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { Provider } from \"./context.js\";\nimport { type ErrorBoundaryContext, type ErrorBoundaryState } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ErrorBoundaryProps {\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n fallback: ReactNode;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This is a minimal fork of the `react-error-boundary` package from\n * {@link https://github.com/bvaughn/react-error-boundary/tree/5.0.0}\n * that only includes things I consider useful. Use the `react-error-boundary`\n * if more complex behavior is required.\n *\n * @example Main Use Case\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { ErrorBoundary } from \"@react-md/core/error-boundary/ErrorBoundary\";\n * import { useErrorBoundary } from \"@react-md/core/error-boundary/useErrorBoundary\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <ErrorBoundary\n * fallback={<SomeFallbackComponent />}\n * >\n * <SomeComponentThatMightError />\n * </ErrorBoundary>\n * );\n * }\n *\n * \"use client\";\n *\n * function SomeFallbackComponent() {\n * const { error, errored, reset } = useErrorBoundary();\n *\n * return (\n * <>\n * <Typography>Uh oh, something broke!</Typography>\n * <Button onClick={reset}>Try Again?</Button>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = { error: null, errored: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { error, errored: true };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n this.props.onError?.(error, errorInfo);\n }\n\n reset = (): void => {\n this.setState({ error: null, errored: false });\n };\n\n render(): ReactElement {\n const { fallback } = this.props;\n const { error, errored } = this.state;\n\n let { children } = this.props;\n if (errored) {\n children = fallback;\n }\n\n return (\n <Provider\n // should always match\n value={{ error, errored, reset: this.reset } as ErrorBoundaryContext}\n >\n {children}\n </Provider>\n );\n }\n}\n"],"names":["Component","Provider","ErrorBoundary","getDerivedStateFromError","error","errored","componentDidCatch","errorInfo","props","onError","render","fallback","state","children","value","reset","constructor","setState"],"mappings":"AAAA;;;;;;;;;;;;;;;AAEA,SACEA,SAAS,QAIJ,QAAQ;AAEf,SAASC,QAAQ,QAAQ,eAAe;AAYxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC,GACD,OAAO,MAAMC,sBAAsBF;IAUjC,OAAOG,yBAAyBC,KAAY,EAAsB;QAChE,OAAO;YAAEA;YAAOC,SAAS;QAAK;IAChC;IAEAC,kBAAkBF,KAAY,EAAEG,SAAoB,EAAQ;QAC1D,IAAI,CAACC,KAAK,CAACC,OAAO,GAAGL,OAAOG;IAC9B;IAMAG,SAAuB;QACrB,MAAM,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACH,KAAK;QAC/B,MAAM,EAAEJ,KAAK,EAAEC,OAAO,EAAE,GAAG,IAAI,CAACO,KAAK;QAErC,IAAI,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACL,KAAK;QAC7B,IAAIH,SAAS;YACXQ,WAAWF;QACb;QAEA,qBACE,KAACV;YACC,sBAAsB;YACtBa,OAAO;gBAAEV;gBAAOC;gBAASU,OAAO,IAAI,CAACA,KAAK;YAAC;sBAE1CF;;IAGP;IAnCAG,YAAYR,KAAyB,CAAE;QACrC,KAAK,CAACA,QAaRO,uBAAAA,SAAQ;YACN,IAAI,CAACE,QAAQ,CAAC;gBAAEb,OAAO;gBAAMC,SAAS;YAAM;QAC9C;QAbE,IAAI,CAACO,KAAK,GAAG;YAAER,OAAO;YAAMC,SAAS;QAAM;IAC7C;AAgCF"}
1
+ {"version":3,"sources":["../../src/error-boundary/ErrorBoundary.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Component,\n type ErrorInfo,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { Provider } from \"./context.js\";\nimport { type ErrorBoundaryContext, type ErrorBoundaryState } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ErrorBoundaryProps {\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n fallback: ReactNode;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This is a minimal fork of the `react-error-boundary` package from\n * {@link https://github.com/bvaughn/react-error-boundary/tree/5.0.0}\n * that only includes things I consider useful. Use the `react-error-boundary`\n * if more complex behavior is required.\n *\n * @example Main Use Case\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { ErrorBoundary } from \"@react-md/core/error-boundary/ErrorBoundary\";\n * import { useErrorBoundary } from \"@react-md/core/error-boundary/useErrorBoundary\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <ErrorBoundary\n * fallback={<SomeFallbackComponent />}\n * >\n * <SomeComponentThatMightError />\n * </ErrorBoundary>\n * );\n * }\n *\n * \"use client\";\n *\n * function SomeFallbackComponent() {\n * const { error, errored, reset } = useErrorBoundary();\n *\n * return (\n * <>\n * <Typography>Uh oh, something broke!</Typography>\n * <Button onClick={reset}>Try Again?</Button>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = { error: null, errored: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { error, errored: true };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n this.props.onError?.(error, errorInfo);\n }\n\n reset = (): void => {\n this.setState({ error: null, errored: false });\n };\n\n render(): ReactElement {\n const { fallback } = this.props;\n const { error, errored } = this.state;\n\n let { children } = this.props;\n if (errored) {\n children = fallback;\n }\n\n return (\n <Provider\n // should always match\n value={{ error, errored, reset: this.reset } as ErrorBoundaryContext}\n >\n {children}\n </Provider>\n );\n }\n}\n"],"names":["Component","Provider","ErrorBoundary","getDerivedStateFromError","error","errored","componentDidCatch","errorInfo","props","onError","render","fallback","state","children","value","reset","setState"],"mappings":"AAAA;;;;;;;;;;;;;;;AAEA,SACEA,SAAS,QAIJ,QAAQ;AAEf,SAASC,QAAQ,QAAQ,eAAe;AAYxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC,GACD,OAAO,MAAMC,sBAAsBF;IAUjC,OAAOG,yBAAyBC,KAAY,EAAsB;QAChE,OAAO;YAAEA;YAAOC,SAAS;QAAK;IAChC;IAEAC,kBAAkBF,KAAY,EAAEG,SAAoB,EAAQ;QAC1D,IAAI,CAACC,KAAK,CAACC,OAAO,GAAGL,OAAOG;IAC9B;IAMAG,SAAuB;QACrB,MAAM,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACH,KAAK;QAC/B,MAAM,EAAEJ,KAAK,EAAEC,OAAO,EAAE,GAAG,IAAI,CAACO,KAAK;QAErC,IAAI,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACL,KAAK;QAC7B,IAAIH,SAAS;YACXQ,WAAWF;QACb;QAEA,qBACE,KAACV;YACC,sBAAsB;YACtBa,OAAO;gBAAEV;gBAAOC;gBAASU,OAAO,IAAI,CAACA,KAAK;YAAC;sBAE1CF;;IAGP;IAnCA,YAAYL,KAAyB,CAAE;QACrC,KAAK,CAACA,QAaRO,uBAAAA,SAAQ;YACN,IAAI,CAACC,QAAQ,CAAC;gBAAEZ,OAAO;gBAAMC,SAAS;YAAM;QAC9C;QAbE,IAAI,CAACO,KAAK,GAAG;YAAER,OAAO;YAAMC,SAAS;QAAM;IAC7C;AAgCF"}
@@ -17,6 +17,7 @@ import { useExpansionList } from "./useExpansionList.js";
17
17
  */ export const ExpansionList = /*#__PURE__*/ forwardRef(function ExpansionList(props, ref) {
18
18
  const { onClick, onFocus, onKeyDown, children, ...remaining } = props;
19
19
  const { movementContext, movementProps } = useExpansionList({
20
+ ref,
20
21
  onClick,
21
22
  onFocus,
22
23
  onKeyDown
@@ -26,7 +27,6 @@ import { useExpansionList } from "./useExpansionList.js";
26
27
  children: /*#__PURE__*/ _jsx("div", {
27
28
  ...remaining,
28
29
  ...movementProps,
29
- ref: ref,
30
30
  children: children
31
31
  })
32
32
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expansion-panel/ExpansionList.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { useExpansionList } from \"./useExpansionList.js\";\n\n/**\n * @since 6.0.0 No longer requires the `onKeyDown` prop.\n */\nexport interface ExpansionListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This component is only used to implement the keyboard movement behavior for\n * the `ExpansionPanel` components.\n *\n * @see {@link https://react-md.dev/components/expansion-panel | ExpansionPanel Demos}\n * @see {@link useExpansionList} for a custom implementation example if you do\n * not want to use a `<div>` for this wrapper component.\n * @since 6.0.0 Uses the new keyboard movement API and does not\n * require the `onKeyDown` prop to be provided.\n */\nexport const ExpansionList = forwardRef<HTMLDivElement, ExpansionListProps>(\n function ExpansionList(props, ref) {\n const { onClick, onFocus, onKeyDown, children, ...remaining } = props;\n\n const { movementContext, movementProps } = useExpansionList({\n onClick,\n onFocus,\n onKeyDown,\n });\n\n return (\n <KeyboardMovementProvider value={movementContext}>\n <div {...remaining} {...movementProps} ref={ref}>\n {children}\n </div>\n </KeyboardMovementProvider>\n );\n }\n);\n"],"names":["forwardRef","KeyboardMovementProvider","useExpansionList","ExpansionList","props","ref","onClick","onFocus","onKeyDown","children","remaining","movementContext","movementProps","value","div"],"mappings":"AAAA;;AAEA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAASC,wBAAwB,QAAQ,6CAA6C;AACtF,SAASC,gBAAgB,QAAQ,wBAAwB;AASzD;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,8BAAgBH,WAC3B,SAASG,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGN;IAEhE,MAAM,EAAEO,eAAe,EAAEC,aAAa,EAAE,GAAGV,iBAAiB;QAC1DI;QACAC;QACAC;IACF;IAEA,qBACE,KAACP;QAAyBY,OAAOF;kBAC/B,cAAA,KAACG;YAAK,GAAGJ,SAAS;YAAG,GAAGE,aAAa;YAAEP,KAAKA;sBACzCI;;;AAIT,GACA"}
1
+ {"version":3,"sources":["../../src/expansion-panel/ExpansionList.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { useExpansionList } from \"./useExpansionList.js\";\n\n/**\n * @since 6.0.0 No longer requires the `onKeyDown` prop.\n */\nexport interface ExpansionListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This component is only used to implement the keyboard movement behavior for\n * the `ExpansionPanel` components.\n *\n * @see {@link https://react-md.dev/components/expansion-panel | ExpansionPanel Demos}\n * @see {@link useExpansionList} for a custom implementation example if you do\n * not want to use a `<div>` for this wrapper component.\n * @since 6.0.0 Uses the new keyboard movement API and does not\n * require the `onKeyDown` prop to be provided.\n */\nexport const ExpansionList = forwardRef<HTMLDivElement, ExpansionListProps>(\n function ExpansionList(props, ref) {\n const { onClick, onFocus, onKeyDown, children, ...remaining } = props;\n\n const { movementContext, movementProps } = useExpansionList({\n ref,\n onClick,\n onFocus,\n onKeyDown,\n });\n\n return (\n <KeyboardMovementProvider value={movementContext}>\n <div {...remaining} {...movementProps}>\n {children}\n </div>\n </KeyboardMovementProvider>\n );\n }\n);\n"],"names":["forwardRef","KeyboardMovementProvider","useExpansionList","ExpansionList","props","ref","onClick","onFocus","onKeyDown","children","remaining","movementContext","movementProps","value","div"],"mappings":"AAAA;;AAEA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAASC,wBAAwB,QAAQ,6CAA6C;AACtF,SAASC,gBAAgB,QAAQ,wBAAwB;AASzD;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,8BAAgBH,WAC3B,SAASG,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGN;IAEhE,MAAM,EAAEO,eAAe,EAAEC,aAAa,EAAE,GAAGV,iBAAiB;QAC1DG;QACAC;QACAC;QACAC;IACF;IAEA,qBACE,KAACP;QAAyBY,OAAOF;kBAC/B,cAAA,KAACG;YAAK,GAAGJ,SAAS;YAAG,GAAGE,aAAa;sBAClCH;;;AAIT,GACA"}
@@ -1,11 +1,6 @@
1
- import type { FocusEventHandler, KeyboardEventHandler, MouseEventHandler } from "react";
2
- import type { KeyboardMovementProviderImplementation } from "../movement/types.js";
1
+ import { type KeyboardMovementProviderImplementation, type SimpleKeyboardMovementWrapperOptions } from "../movement/types.js";
3
2
  /** @since 6.0.0 */
4
- export interface ExpansionListHookOptions<E extends HTMLElement> {
5
- onClick?: MouseEventHandler<E>;
6
- onFocus?: FocusEventHandler<E>;
7
- onKeyDown?: KeyboardEventHandler<E>;
8
- }
3
+ export type ExpansionListHookOptions<E extends HTMLElement> = SimpleKeyboardMovementWrapperOptions<E>;
9
4
  /** @since 6.0.0 */
10
5
  export type ExpansionListImplementation<E extends HTMLElement> = KeyboardMovementProviderImplementation<E>;
11
6
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expansion-panel/useExpansionList.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n FocusEventHandler,\n KeyboardEventHandler,\n MouseEventHandler,\n} from \"react\";\n\nimport type { KeyboardMovementProviderImplementation } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nconst getPanelsOnly = (container: HTMLElement): readonly HTMLElement[] => [\n ...container.querySelectorAll<HTMLElement>(\".rmd-expansion-panel__button\"),\n];\n\n/** @since 6.0.0 */\nexport interface ExpansionListHookOptions<E extends HTMLElement> {\n onClick?: MouseEventHandler<E>;\n onFocus?: FocusEventHandler<E>;\n onKeyDown?: KeyboardEventHandler<E>;\n}\n\n/** @since 6.0.0 */\nexport type ExpansionListImplementation<E extends HTMLElement> =\n KeyboardMovementProviderImplementation<E>;\n\n/**\n * @example Custom Implementation\n * ```tsx\n * import { ExpansionPanel } from \"@react-md/core/expansion-panel/ExpansionPanel\";\n * import { useExpansionList } from \"@react-md/core/expansion-panel/useExpansionList\";\n * import { useExpansionPanels } from \"@react-md/core/expansion-panel/useExpansionPanels\";\n * import { KeyboardMovementProvider } from \"@react-md/core/movement/useKeyboardMovementProvider\";\n * import { Form } from \"@react-md/core/form/Form\";\n * import { type ReactElement } from \"react\";\n *\n * import { BillingAddress } from \"./BillingAddress\";\n * import { BillingInformation } from \"./BillingInformation\";\n * import { PersonalInformation } from \"./PersonalInformation\";\n *\n * function Example(): ReactElement {\n * const { movementContext, movementProps } = useExpansionList();\n * const { getPanelProps } = useExpansionPanels();\n *\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <Form {...movementProps}>\n * <ExpansionPanel {...getPanelProps(\"personal-information-panel\")}>\n * <PersonalInformation />\n * </ExpansionPanel>\n * <ExpansionPanel {...getPanelProps(\"billing-information-panel\")}>\n * <BillingInformation />\n * </ExpansionPanel>\n * <ExpansionPanel {...getPanelProps(\"billing-address-panel\")}>\n * <BillingAddress />\n * </ExpansionPanel>\n * </Form>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/expansion-panel | ExpansionPanel Demos}\n * @since 6.0.0\n */\nexport function useExpansionList<E extends HTMLElement>(\n options: ExpansionListHookOptions<E> = {}\n): ExpansionListImplementation<E> {\n return useKeyboardMovementProvider({\n ...options,\n loopable: true,\n includeDisabled: true,\n getFocusableElements: getPanelsOnly,\n });\n}\n"],"names":["useKeyboardMovementProvider","getPanelsOnly","container","querySelectorAll","useExpansionList","options","loopable","includeDisabled","getFocusableElements"],"mappings":"AAAA;AASA,SAASA,2BAA2B,QAAQ,6CAA6C;AAEzF;;;CAGC,GACD,MAAMC,gBAAgB,CAACC,YAAmD;WACrEA,UAAUC,gBAAgB,CAAc;KAC5C;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,SAASC,iBACdC,UAAuC,CAAC,CAAC;IAEzC,OAAOL,4BAA4B;QACjC,GAAGK,OAAO;QACVC,UAAU;QACVC,iBAAiB;QACjBC,sBAAsBP;IACxB;AACF"}
1
+ {"version":3,"sources":["../../src/expansion-panel/useExpansionList.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type KeyboardMovementProviderImplementation,\n type SimpleKeyboardMovementWrapperOptions,\n} from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nconst getPanelsOnly = (container: HTMLElement): readonly HTMLElement[] => [\n ...container.querySelectorAll<HTMLElement>(\".rmd-expansion-panel__button\"),\n];\n\n/** @since 6.0.0 */\nexport type ExpansionListHookOptions<E extends HTMLElement> =\n SimpleKeyboardMovementWrapperOptions<E>;\n\n/** @since 6.0.0 */\nexport type ExpansionListImplementation<E extends HTMLElement> =\n KeyboardMovementProviderImplementation<E>;\n\n/**\n * @example Custom Implementation\n * ```tsx\n * import { ExpansionPanel } from \"@react-md/core/expansion-panel/ExpansionPanel\";\n * import { useExpansionList } from \"@react-md/core/expansion-panel/useExpansionList\";\n * import { useExpansionPanels } from \"@react-md/core/expansion-panel/useExpansionPanels\";\n * import { KeyboardMovementProvider } from \"@react-md/core/movement/useKeyboardMovementProvider\";\n * import { Form } from \"@react-md/core/form/Form\";\n * import { type ReactElement } from \"react\";\n *\n * import { BillingAddress } from \"./BillingAddress\";\n * import { BillingInformation } from \"./BillingInformation\";\n * import { PersonalInformation } from \"./PersonalInformation\";\n *\n * function Example(): ReactElement {\n * const { movementContext, movementProps } = useExpansionList();\n * const { getPanelProps } = useExpansionPanels();\n *\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <Form {...movementProps}>\n * <ExpansionPanel {...getPanelProps(\"personal-information-panel\")}>\n * <PersonalInformation />\n * </ExpansionPanel>\n * <ExpansionPanel {...getPanelProps(\"billing-information-panel\")}>\n * <BillingInformation />\n * </ExpansionPanel>\n * <ExpansionPanel {...getPanelProps(\"billing-address-panel\")}>\n * <BillingAddress />\n * </ExpansionPanel>\n * </Form>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/expansion-panel | ExpansionPanel Demos}\n * @since 6.0.0\n */\nexport function useExpansionList<E extends HTMLElement>(\n options: ExpansionListHookOptions<E> = {}\n): ExpansionListImplementation<E> {\n return useKeyboardMovementProvider({\n ...options,\n loopable: true,\n includeDisabled: true,\n getFocusableElements: getPanelsOnly,\n });\n}\n"],"names":["useKeyboardMovementProvider","getPanelsOnly","container","querySelectorAll","useExpansionList","options","loopable","includeDisabled","getFocusableElements"],"mappings":"AAAA;AAMA,SAASA,2BAA2B,QAAQ,6CAA6C;AAEzF;;;CAGC,GACD,MAAMC,gBAAgB,CAACC,YAAmD;WACrEA,UAAUC,gBAAgB,CAAc;KAC5C;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,SAASC,iBACdC,UAAuC,CAAC,CAAC;IAEzC,OAAOL,4BAA4B;QACjC,GAAGK,OAAO;QACVC,UAAU;QACVC,iBAAiB;QACjBC,sBAAsBP;IACxB;AACF"}