@react-md/core 6.4.0 → 6.5.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 (431) hide show
  1. package/dist/_a11y.scss +3 -1
  2. package/dist/_box-shadows.scss +20 -12
  3. package/dist/_core.scss +1 -1
  4. package/dist/_utils.scss +26 -11
  5. package/dist/app-bar/_app-bar.scss +3 -3
  6. package/dist/autocomplete/AutocompleteChip.js +2 -2
  7. package/dist/autocomplete/AutocompleteChip.js.map +1 -1
  8. package/dist/autocomplete/AutocompleteListboxChildren.js +1 -1
  9. package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -1
  10. package/dist/autocomplete/_autocomplete.scss +20 -16
  11. package/dist/autocomplete/useAutocomplete.js +4 -4
  12. package/dist/autocomplete/useAutocomplete.js.map +1 -1
  13. package/dist/autocomplete/utils.js +3 -3
  14. package/dist/autocomplete/utils.js.map +1 -1
  15. package/dist/avatar/_avatar.scss +2 -1
  16. package/dist/box/styles.js +2 -2
  17. package/dist/box/styles.js.map +1 -1
  18. package/dist/button/AsyncButton.js +1 -1
  19. package/dist/button/AsyncButton.js.map +1 -1
  20. package/dist/button/_button.scss +9 -5
  21. package/dist/card/_card.scss +6 -6
  22. package/dist/chip/Chip.js +1 -1
  23. package/dist/chip/Chip.js.map +1 -1
  24. package/dist/chip/_chip.scss +6 -6
  25. package/dist/cssUtils.d.ts +11 -6
  26. package/dist/cssUtils.js.map +1 -1
  27. package/dist/datetime/useTimeField.js +1 -1
  28. package/dist/datetime/useTimeField.js.map +1 -1
  29. package/dist/delegateEvent.js +9 -9
  30. package/dist/delegateEvent.js.map +1 -1
  31. package/dist/dialog/_dialog.scss +6 -6
  32. package/dist/divider/_divider.scss +6 -2
  33. package/dist/draggable/useDraggable.js +4 -4
  34. package/dist/draggable/useDraggable.js.map +1 -1
  35. package/dist/draggable/utils.js +1 -1
  36. package/dist/draggable/utils.js.map +1 -1
  37. package/dist/expansion-panel/ExpansionPanel.js +1 -1
  38. package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
  39. package/dist/expansion-panel/useExpansionPanels.js +1 -1
  40. package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
  41. package/dist/files/FileInput.js +1 -1
  42. package/dist/files/FileInput.js.map +1 -1
  43. package/dist/files/createAcceptFromExtensions.d.ts +5 -0
  44. package/dist/files/createAcceptFromExtensions.js +15 -0
  45. package/dist/files/createAcceptFromExtensions.js.map +1 -0
  46. package/dist/files/useFileUpload.js +45 -41
  47. package/dist/files/useFileUpload.js.map +1 -1
  48. package/dist/files/utils.js +14 -10
  49. package/dist/files/utils.js.map +1 -1
  50. package/dist/files/validation.js +7 -8
  51. package/dist/files/validation.js.map +1 -1
  52. package/dist/focus/useFocusContainer.js +1 -1
  53. package/dist/focus/useFocusContainer.js.map +1 -1
  54. package/dist/focus/utils.js +12 -7
  55. package/dist/focus/utils.js.map +1 -1
  56. package/dist/form/InputToggleIcon.js +5 -1
  57. package/dist/form/InputToggleIcon.js.map +1 -1
  58. package/dist/form/NativeSelect.js +1 -1
  59. package/dist/form/NativeSelect.js.map +1 -1
  60. package/dist/form/Select.d.ts +24 -0
  61. package/dist/form/Select.js +19 -8
  62. package/dist/form/Select.js.map +1 -1
  63. package/dist/form/SelectedOption.d.ts +1 -2
  64. package/dist/form/SelectedOption.js +2 -2
  65. package/dist/form/SelectedOption.js.map +1 -1
  66. package/dist/form/_input-toggle.scss +6 -5
  67. package/dist/form/_label.scss +2 -2
  68. package/dist/form/_legend.scss +22 -13
  69. package/dist/form/_slider.scss +7 -5
  70. package/dist/form/_switch.scss +7 -5
  71. package/dist/form/_text-field.scss +13 -11
  72. package/dist/form/formConfig.js +1 -1
  73. package/dist/form/formConfig.js.map +1 -1
  74. package/dist/form/inputToggleStyles.js +7 -1
  75. package/dist/form/inputToggleStyles.js.map +1 -1
  76. package/dist/form/legendStyles.d.ts +1 -1
  77. package/dist/form/legendStyles.js.map +1 -1
  78. package/dist/form/selectUtils.js +2 -2
  79. package/dist/form/selectUtils.js.map +1 -1
  80. package/dist/form/useCombobox.js +1 -0
  81. package/dist/form/useCombobox.js.map +1 -1
  82. package/dist/form/useFormReset.js +2 -2
  83. package/dist/form/useFormReset.js.map +1 -1
  84. package/dist/form/useNumberField.js +1 -1
  85. package/dist/form/useNumberField.js.map +1 -1
  86. package/dist/form/useResizingTextArea.js +4 -4
  87. package/dist/form/useResizingTextArea.js.map +1 -1
  88. package/dist/form/useSelectCombobox.js +1 -1
  89. package/dist/form/useSelectCombobox.js.map +1 -1
  90. package/dist/form/validation.js +1 -1
  91. package/dist/form/validation.js.map +1 -1
  92. package/dist/hoverMode/useHoverMode.js +8 -8
  93. package/dist/hoverMode/useHoverMode.js.map +1 -1
  94. package/dist/hoverMode/useHoverModeProvider.js +3 -3
  95. package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
  96. package/dist/icon/config.js +3 -3
  97. package/dist/icon/config.js.map +1 -1
  98. package/dist/icon/materialConfig.js +1 -1
  99. package/dist/icon/materialConfig.js.map +1 -1
  100. package/dist/interaction/UserInteractionModeProvider.js +11 -10
  101. package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
  102. package/dist/interaction/_interaction.scss +5 -3
  103. package/dist/interaction/utils.js +7 -3
  104. package/dist/interaction/utils.js.map +1 -1
  105. package/dist/layout/useExpandableLayout.js +3 -4
  106. package/dist/layout/useExpandableLayout.js.map +1 -1
  107. package/dist/layout/useMainTabIndex.js +1 -1
  108. package/dist/layout/useMainTabIndex.js.map +1 -1
  109. package/dist/list/ListItem.js +1 -1
  110. package/dist/list/ListItem.js.map +1 -1
  111. package/dist/media-queries/AppSizeProvider.js +1 -1
  112. package/dist/media-queries/AppSizeProvider.js.map +1 -1
  113. package/dist/media-queries/config.js +2 -2
  114. package/dist/media-queries/config.js.map +1 -1
  115. package/dist/media-queries/useMediaQuery.js +3 -3
  116. package/dist/media-queries/useMediaQuery.js.map +1 -1
  117. package/dist/menu/Menu.js +4 -4
  118. package/dist/menu/Menu.js.map +1 -1
  119. package/dist/menu/MenuItemButton.js +1 -1
  120. package/dist/menu/MenuItemButton.js.map +1 -1
  121. package/dist/menu/MenuItemFileInput.js +1 -1
  122. package/dist/menu/MenuItemFileInput.js.map +1 -1
  123. package/dist/menu/MenuWidget.js +2 -2
  124. package/dist/menu/MenuWidget.js.map +1 -1
  125. package/dist/movement/findMatchIndex.js +2 -2
  126. package/dist/movement/findMatchIndex.js.map +1 -1
  127. package/dist/movement/useKeyboardMovementProvider.js +2 -2
  128. package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
  129. package/dist/movement/utils.js +12 -10
  130. package/dist/movement/utils.js.map +1 -1
  131. package/dist/navigation/getTableOfContentsHeadings.js +4 -3
  132. package/dist/navigation/getTableOfContentsHeadings.js.map +1 -1
  133. package/dist/navigation/useActiveHeadingId.js +9 -9
  134. package/dist/navigation/useActiveHeadingId.js.map +1 -1
  135. package/dist/navigation/useTableOfContentsHeadings.js +1 -1
  136. package/dist/navigation/useTableOfContentsHeadings.js.map +1 -1
  137. package/dist/navigation/utils.js +6 -5
  138. package/dist/navigation/utils.js.map +1 -1
  139. package/dist/portal/PortalContainerProvider.js +5 -3
  140. package/dist/portal/PortalContainerProvider.js.map +1 -1
  141. package/dist/positioning/getFixedPosition.js +2 -4
  142. package/dist/positioning/getFixedPosition.js.map +1 -1
  143. package/dist/positioning/useFixedPositioning.js +2 -2
  144. package/dist/positioning/useFixedPositioning.js.map +1 -1
  145. package/dist/positioning/utils.js +3 -3
  146. package/dist/positioning/utils.js.map +1 -1
  147. package/dist/scroll/getScrollbarWidth.js +4 -4
  148. package/dist/scroll/getScrollbarWidth.js.map +1 -1
  149. package/dist/searching/fuzzy.js +3 -2
  150. package/dist/searching/fuzzy.js.map +1 -1
  151. package/dist/searching/toSearchQuery.js +1 -1
  152. package/dist/searching/toSearchQuery.js.map +1 -1
  153. package/dist/searching/utils.js +1 -1
  154. package/dist/searching/utils.js.map +1 -1
  155. package/dist/snackbar/Toast.js +1 -1
  156. package/dist/snackbar/Toast.js.map +1 -1
  157. package/dist/snackbar/ToastContent.js +2 -2
  158. package/dist/snackbar/ToastContent.js.map +1 -1
  159. package/dist/snackbar/ToastManager.d.ts +1 -1
  160. package/dist/snackbar/ToastManager.js +11 -11
  161. package/dist/snackbar/ToastManager.js.map +1 -1
  162. package/dist/snackbar/_snackbar.scss +3 -3
  163. package/dist/spinbutton/useSpinButton.js +1 -1
  164. package/dist/spinbutton/useSpinButton.js.map +1 -1
  165. package/dist/spinbutton/utils/deselectNode.js +1 -1
  166. package/dist/spinbutton/utils/deselectNode.js.map +1 -1
  167. package/dist/spinbutton/utils/resolveInputEvent.js +1 -1
  168. package/dist/spinbutton/utils/resolveInputEvent.js.map +1 -1
  169. package/dist/spinbutton/utils/selectNode.js +1 -1
  170. package/dist/spinbutton/utils/selectNode.js.map +1 -1
  171. package/dist/storage/useStorage.js +8 -3
  172. package/dist/storage/useStorage.js.map +1 -1
  173. package/dist/table/useStickyTableSection.js +1 -1
  174. package/dist/table/useStickyTableSection.js.map +1 -1
  175. package/dist/tabs/TabList.js +2 -2
  176. package/dist/tabs/TabList.js.map +1 -1
  177. package/dist/tabs/_tabs.scss +5 -6
  178. package/dist/tabs/useMaxTabPanelHeight.js +4 -3
  179. package/dist/tabs/useMaxTabPanelHeight.js.map +1 -1
  180. package/dist/tabs/useTabList.js +1 -1
  181. package/dist/tabs/useTabList.js.map +1 -1
  182. package/dist/test-utils/jest-globals/match-media.d.ts +1 -1
  183. package/dist/test-utils/jest-globals/match-media.js +1 -1
  184. package/dist/test-utils/jest-globals/match-media.js.map +1 -1
  185. package/dist/test-utils/jest-globals/timers.js +1 -1
  186. package/dist/test-utils/jest-globals/timers.js.map +1 -1
  187. package/dist/test-utils/jest-globals/uploadMenuItemFileInput.js +1 -1
  188. package/dist/test-utils/jest-globals/uploadMenuItemFileInput.js.map +1 -1
  189. package/dist/test-utils/mocks/ResizeObserver.js +2 -2
  190. package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
  191. package/dist/test-utils/polyfills/IntersectionObserver.js +2 -2
  192. package/dist/test-utils/polyfills/IntersectionObserver.js.map +1 -1
  193. package/dist/test-utils/polyfills/ResizeObserver.js +2 -2
  194. package/dist/test-utils/polyfills/ResizeObserver.js.map +1 -1
  195. package/dist/test-utils/polyfills/TextDecoder.js +2 -2
  196. package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
  197. package/dist/test-utils/polyfills/TextEncoder.js +2 -2
  198. package/dist/test-utils/polyfills/TextEncoder.js.map +1 -1
  199. package/dist/test-utils/polyfills/matchMedia.js +2 -2
  200. package/dist/test-utils/polyfills/matchMedia.js.map +1 -1
  201. package/dist/test-utils/polyfills/offsetParent.js +2 -2
  202. package/dist/test-utils/polyfills/offsetParent.js.map +1 -1
  203. package/dist/test-utils/polyfills/scrollIntoView.js +1 -1
  204. package/dist/test-utils/polyfills/scrollIntoView.js.map +1 -1
  205. package/dist/test-utils/queries/select.js +2 -2
  206. package/dist/test-utils/queries/select.js.map +1 -1
  207. package/dist/test-utils/queries/slider.js +1 -1
  208. package/dist/test-utils/queries/slider.js.map +1 -1
  209. package/dist/test-utils/utils/createFileList.js +2 -0
  210. package/dist/test-utils/utils/createFileList.js.map +1 -1
  211. package/dist/test-utils/utils/createMatchMediaSpy.d.ts +1 -1
  212. package/dist/test-utils/utils/createMatchMediaSpy.js +3 -3
  213. package/dist/test-utils/utils/createMatchMediaSpy.js.map +1 -1
  214. package/dist/test-utils/vitest/match-media.d.ts +1 -1
  215. package/dist/test-utils/vitest/match-media.js +1 -1
  216. package/dist/test-utils/vitest/match-media.js.map +1 -1
  217. package/dist/test-utils/vitest/timers.js +1 -1
  218. package/dist/test-utils/vitest/timers.js.map +1 -1
  219. package/dist/test-utils/vitest/uploadMenuItemFileInput.js +1 -1
  220. package/dist/test-utils/vitest/uploadMenuItemFileInput.js.map +1 -1
  221. package/dist/theme/ThemeProvider.js +2 -2
  222. package/dist/theme/ThemeProvider.js.map +1 -1
  223. package/dist/theme/_a11y.scss +3 -1
  224. package/dist/theme/_theme.scss +16 -12
  225. package/dist/theme/getDerivedTheme.js +1 -1
  226. package/dist/theme/getDerivedTheme.js.map +1 -1
  227. package/dist/theme/useCSSVariables.js +5 -5
  228. package/dist/theme/useCSSVariables.js.map +1 -1
  229. package/dist/theme/useColorSchemeMetaTag.js +2 -2
  230. package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
  231. package/dist/theme/useInlineCSSVariables.js +4 -3
  232. package/dist/theme/useInlineCSSVariables.js.map +1 -1
  233. package/dist/theme/utils.js +8 -8
  234. package/dist/theme/utils.js.map +1 -1
  235. package/dist/tooltip/useTooltip.js +7 -7
  236. package/dist/tooltip/useTooltip.js.map +1 -1
  237. package/dist/tooltip/useTooltipPosition.js +1 -1
  238. package/dist/tooltip/useTooltipPosition.js.map +1 -1
  239. package/dist/transition/useCarousel.js +2 -2
  240. package/dist/transition/useCarousel.js.map +1 -1
  241. package/dist/transition/useCollapseTransition.js +1 -1
  242. package/dist/transition/useCollapseTransition.js.map +1 -1
  243. package/dist/transition/useSkeletonPlaceholder.js +4 -4
  244. package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
  245. package/dist/transition/useTransition.js +2 -2
  246. package/dist/transition/useTransition.js.map +1 -1
  247. package/dist/transition/utils.js +5 -5
  248. package/dist/transition/utils.js.map +1 -1
  249. package/dist/tree/TreeItem.js +1 -1
  250. package/dist/tree/TreeItem.js.map +1 -1
  251. package/dist/tree/useTreeItems.js +7 -5
  252. package/dist/tree/useTreeItems.js.map +1 -1
  253. package/dist/tree/useTreeMovement.js +1 -1
  254. package/dist/tree/useTreeMovement.js.map +1 -1
  255. package/dist/tree/utils.js +6 -9
  256. package/dist/tree/utils.js.map +1 -1
  257. package/dist/typography/HighlightText.js +2 -1
  258. package/dist/typography/HighlightText.js.map +1 -1
  259. package/dist/typography/SrOnly.js +7 -1
  260. package/dist/typography/SrOnly.js.map +1 -1
  261. package/dist/useDebouncedFunction.js +4 -4
  262. package/dist/useDebouncedFunction.js.map +1 -1
  263. package/dist/useDropzone.js +9 -9
  264. package/dist/useDropzone.js.map +1 -1
  265. package/dist/useEnsuredState.js +5 -5
  266. package/dist/useEnsuredState.js.map +1 -1
  267. package/dist/useIntersectionObserver.js +3 -3
  268. package/dist/useIntersectionObserver.js.map +1 -1
  269. package/dist/useIsomorphicLayoutEffect.js +1 -1
  270. package/dist/useIsomorphicLayoutEffect.js.map +1 -1
  271. package/dist/useOrientation.js +1 -1
  272. package/dist/useOrientation.js.map +1 -1
  273. package/dist/useReadonlySet.js +1 -1
  274. package/dist/useReadonlySet.js.map +1 -1
  275. package/dist/useResizeListener.js +2 -2
  276. package/dist/useResizeListener.js.map +1 -1
  277. package/dist/useResizeObserver.js +3 -4
  278. package/dist/useResizeObserver.js.map +1 -1
  279. package/dist/useThrottledFunction.js +3 -3
  280. package/dist/useThrottledFunction.js.map +1 -1
  281. package/dist/useWindowSize.js +1 -1
  282. package/dist/useWindowSize.js.map +1 -1
  283. package/dist/utils/alphaNumericSort.js +3 -1
  284. package/dist/utils/alphaNumericSort.js.map +1 -1
  285. package/dist/utils/bem.js +9 -12
  286. package/dist/utils/bem.js.map +1 -1
  287. package/dist/utils/getNumberOfDigits.js +1 -0
  288. package/dist/utils/getNumberOfDigits.js.map +1 -1
  289. package/dist/utils/getRangeDefaultValue.js +1 -1
  290. package/dist/utils/getRangeDefaultValue.js.map +1 -1
  291. package/dist/utils/nearest.js +2 -2
  292. package/dist/utils/nearest.js.map +1 -1
  293. package/dist/utils/parseCssLengthUnit.js +3 -3
  294. package/dist/utils/parseCssLengthUnit.js.map +1 -1
  295. package/dist/utils/trigonometry.js +1 -1
  296. package/dist/utils/trigonometry.js.map +1 -1
  297. package/dist/window-splitter/_window-splitter.scss +15 -17
  298. package/package.json +9 -7
  299. package/src/autocomplete/AutocompleteChip.tsx +2 -2
  300. package/src/autocomplete/AutocompleteListboxChildren.tsx +1 -1
  301. package/src/autocomplete/useAutocomplete.ts +4 -4
  302. package/src/autocomplete/utils.ts +3 -3
  303. package/src/box/styles.ts +2 -2
  304. package/src/button/AsyncButton.tsx +1 -3
  305. package/src/chip/Chip.tsx +1 -2
  306. package/src/cssUtils.ts +12 -6
  307. package/src/datetime/useTimeField.ts +1 -1
  308. package/src/delegateEvent.ts +9 -9
  309. package/src/draggable/useDraggable.ts +4 -4
  310. package/src/draggable/utils.ts +1 -1
  311. package/src/expansion-panel/ExpansionPanel.tsx +1 -1
  312. package/src/expansion-panel/useExpansionPanels.ts +1 -1
  313. package/src/files/FileInput.tsx +1 -1
  314. package/src/files/createAcceptFromExtensions.ts +18 -0
  315. package/src/files/useFileUpload.ts +36 -37
  316. package/src/files/utils.ts +15 -11
  317. package/src/files/validation.ts +7 -9
  318. package/src/focus/useFocusContainer.ts +1 -1
  319. package/src/focus/utils.ts +11 -6
  320. package/src/form/InputToggleIcon.tsx +5 -5
  321. package/src/form/NativeSelect.tsx +1 -1
  322. package/src/form/Select.tsx +58 -7
  323. package/src/form/SelectedOption.tsx +2 -4
  324. package/src/form/formConfig.ts +1 -1
  325. package/src/form/inputToggleStyles.ts +9 -4
  326. package/src/form/legendStyles.ts +1 -1
  327. package/src/form/selectUtils.ts +2 -2
  328. package/src/form/useCombobox.ts +1 -0
  329. package/src/form/useFormReset.ts +2 -2
  330. package/src/form/useNumberField.ts +1 -1
  331. package/src/form/useResizingTextArea.ts +5 -5
  332. package/src/form/useSelectCombobox.ts +1 -4
  333. package/src/form/validation.ts +1 -1
  334. package/src/hoverMode/useHoverMode.ts +9 -9
  335. package/src/hoverMode/useHoverModeProvider.ts +4 -4
  336. package/src/icon/config.tsx +3 -3
  337. package/src/icon/materialConfig.ts +1 -1
  338. package/src/interaction/UserInteractionModeProvider.tsx +11 -10
  339. package/src/interaction/utils.ts +3 -3
  340. package/src/layout/useExpandableLayout.ts +3 -4
  341. package/src/layout/useMainTabIndex.ts +1 -1
  342. package/src/list/ListItem.tsx +1 -1
  343. package/src/media-queries/AppSizeProvider.tsx +1 -1
  344. package/src/media-queries/config.ts +2 -2
  345. package/src/media-queries/useMediaQuery.ts +3 -3
  346. package/src/menu/Menu.tsx +4 -4
  347. package/src/menu/MenuItemButton.tsx +1 -1
  348. package/src/menu/MenuItemFileInput.tsx +1 -1
  349. package/src/menu/MenuWidget.tsx +6 -4
  350. package/src/movement/findMatchIndex.ts +2 -2
  351. package/src/movement/useKeyboardMovementProvider.ts +2 -2
  352. package/src/movement/utils.ts +15 -14
  353. package/src/navigation/getTableOfContentsHeadings.ts +4 -3
  354. package/src/navigation/useActiveHeadingId.ts +8 -8
  355. package/src/navigation/useTableOfContentsHeadings.ts +1 -1
  356. package/src/navigation/utils.ts +6 -5
  357. package/src/portal/PortalContainerProvider.tsx +5 -3
  358. package/src/positioning/getFixedPosition.ts +9 -6
  359. package/src/positioning/useFixedPositioning.ts +2 -2
  360. package/src/positioning/utils.ts +3 -3
  361. package/src/scroll/getScrollbarWidth.ts +4 -4
  362. package/src/searching/fuzzy.ts +7 -3
  363. package/src/searching/toSearchQuery.ts +1 -1
  364. package/src/searching/utils.ts +1 -1
  365. package/src/snackbar/Toast.tsx +1 -1
  366. package/src/snackbar/ToastContent.tsx +2 -2
  367. package/src/snackbar/ToastManager.ts +11 -12
  368. package/src/spinbutton/useSpinButton.ts +1 -1
  369. package/src/spinbutton/utils/deselectNode.ts +1 -1
  370. package/src/spinbutton/utils/resolveInputEvent.ts +1 -1
  371. package/src/spinbutton/utils/selectNode.ts +1 -1
  372. package/src/storage/useStorage.ts +7 -2
  373. package/src/table/useStickyTableSection.tsx +1 -1
  374. package/src/tabs/TabList.tsx +2 -2
  375. package/src/tabs/useMaxTabPanelHeight.ts +6 -3
  376. package/src/tabs/useTabList.ts +2 -2
  377. package/src/test-utils/jest-globals/match-media.ts +5 -2
  378. package/src/test-utils/jest-globals/timers.ts +1 -1
  379. package/src/test-utils/jest-globals/uploadMenuItemFileInput.ts +1 -1
  380. package/src/test-utils/mocks/ResizeObserver.ts +2 -2
  381. package/src/test-utils/polyfills/IntersectionObserver.ts +2 -2
  382. package/src/test-utils/polyfills/ResizeObserver.ts +2 -2
  383. package/src/test-utils/polyfills/TextDecoder.ts +2 -2
  384. package/src/test-utils/polyfills/TextEncoder.ts +2 -2
  385. package/src/test-utils/polyfills/matchMedia.ts +5 -2
  386. package/src/test-utils/polyfills/offsetParent.ts +2 -2
  387. package/src/test-utils/polyfills/scrollIntoView.ts +1 -1
  388. package/src/test-utils/queries/select.ts +2 -2
  389. package/src/test-utils/queries/slider.ts +1 -1
  390. package/src/test-utils/utils/createFileList.ts +2 -0
  391. package/src/test-utils/utils/createMatchMediaSpy.ts +4 -4
  392. package/src/test-utils/vitest/match-media.ts +2 -2
  393. package/src/test-utils/vitest/timers.ts +1 -1
  394. package/src/test-utils/vitest/uploadMenuItemFileInput.ts +1 -1
  395. package/src/theme/ThemeProvider.tsx +2 -2
  396. package/src/theme/getDerivedTheme.ts +1 -1
  397. package/src/theme/useCSSVariables.ts +5 -5
  398. package/src/theme/useColorSchemeMetaTag.ts +2 -2
  399. package/src/theme/useInlineCSSVariables.ts +6 -7
  400. package/src/theme/utils.ts +8 -8
  401. package/src/tooltip/useTooltip.ts +7 -7
  402. package/src/tooltip/useTooltipPosition.ts +1 -1
  403. package/src/transition/useCarousel.ts +2 -2
  404. package/src/transition/useCollapseTransition.ts +1 -1
  405. package/src/transition/useSkeletonPlaceholder.ts +4 -4
  406. package/src/transition/useTransition.ts +2 -2
  407. package/src/transition/utils.ts +5 -5
  408. package/src/tree/TreeItem.tsx +1 -1
  409. package/src/tree/useTreeItems.ts +5 -5
  410. package/src/tree/useTreeMovement.ts +1 -1
  411. package/src/tree/utils.ts +9 -9
  412. package/src/typography/HighlightText.tsx +4 -3
  413. package/src/typography/SrOnly.tsx +9 -2
  414. package/src/useDebouncedFunction.ts +5 -5
  415. package/src/useDropzone.ts +10 -10
  416. package/src/useEnsuredState.ts +5 -5
  417. package/src/useIntersectionObserver.ts +3 -3
  418. package/src/useIsomorphicLayoutEffect.ts +3 -3
  419. package/src/useOrientation.ts +1 -1
  420. package/src/useReadonlySet.ts +3 -1
  421. package/src/useResizeListener.ts +2 -2
  422. package/src/useResizeObserver.ts +3 -4
  423. package/src/useThrottledFunction.ts +4 -4
  424. package/src/useWindowSize.ts +1 -1
  425. package/src/utils/alphaNumericSort.ts +1 -1
  426. package/src/utils/bem.ts +15 -16
  427. package/src/utils/getNumberOfDigits.ts +1 -0
  428. package/src/utils/getRangeDefaultValue.ts +1 -1
  429. package/src/utils/nearest.ts +5 -2
  430. package/src/utils/parseCssLengthUnit.ts +5 -4
  431. package/src/utils/trigonometry.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/button/AsyncButton.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { type MouseEvent, type ReactNode, forwardRef } from \"react\";\n\nimport { type BoxAlignItems } from \"../box/styles.js\";\nimport { overlay } from \"../overlay/styles.js\";\nimport {\n CircularProgress,\n type CircularProgressProps,\n} from \"../progress/CircularProgress.js\";\nimport {\n LinearProgress,\n type LinearProgressProps,\n} from \"../progress/LinearProgress.js\";\nimport { type ProgressTheme } from \"../progress/types.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useAsyncFunction } from \"../useAsyncFunction.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { Button, type ButtonProps } from \"./Button.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type AsyncButtonLoadingType =\n | \"circular-before\"\n | \"circular-after\"\n | \"circular-overlay\"\n | \"linear-above\"\n | \"linear-below\";\n\n/**\n * @since 6.0.0\n */\nexport interface AsyncButtonProps extends ButtonProps {\n /**\n * @see {@link progressAriaLabelledBy}\n * @defaultValue `\"async-button\" + useId()`\n */\n id?: string;\n\n /**\n * When this is defined and returns a `Promise`, the loading indicator will\n * display until the promise has resolved.\n *\n * @defaultValue `() => {}`\n */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => Promise<void> | void;\n\n /**\n * Set this to `true` to manually display a loading spinner.\n *\n * @defaultValue `false`\n */\n loading?: boolean;\n\n /**\n * - `\"circular-overlay\"` - Covers and hides the button content with a\n * centered circular progress\n * - `\"circular-before\"` - Renders a circular progress bar before the button\n * content which is useful when rendering an icon before the button text.\n * See {@link beforeAddon} as well.\n * - `\"circular-after\"` - Renders a circular progress bar before the button\n * content which is useful when rendering an icon after the button text.\n * See {@link afterAddon} as well.\n * - `\"linear-above\"` - Renders a linear progress bar at the top of the button\n * while still displaying the button contents. Usually looks good for\n * outlined buttons.\n * - `\"linear-below\"` - Renders a linear progress bar at the bottom of the\n * button while still displaying the button contents. Usually looks good for\n * outlined buttons.\n *\n * @defaultValue `\"circular-overlay\"`\n */\n loadingType?: AsyncButtonLoadingType;\n\n /**\n * Optional content to display instead of the default `children` while\n * loading.\n */\n loadingChildren?: ReactNode;\n\n /**\n * Set this to `true` to use the `disabled` theme while loading.\n *\n * @defaultValue `false`\n */\n loadingDisabledTheme?: boolean;\n\n /**\n * This should be used when the {@link loadingType} is set to\n * `\"circular-before\"`, an icon should appear before the other content in\n * the button, and the loading indicator should replace the icon.\n */\n beforeAddon?: ReactNode;\n\n /**\n * This should be used when the {@link loadingType} is set to\n * `\"circular-after\"`, an icon should appear before the other content in\n * the button, and the loading indicator should replace the icon.\n */\n afterAddon?: ReactNode;\n\n /**\n * An optional label to provide to the progressbar.\n *\n * @see {@link progressAriaLabelledBy}\n */\n progressAriaLabel?: string;\n\n /**\n * @see {@link id}\n * @defaultValue `id`\n */\n progressAriaLabelledBy?: string;\n\n /**\n * Any additional props to pass to the `CircularProgress` bar when the\n * {@link loadingType} is one of the circular types.\n */\n linearProgressProps?: PropsWithRef<LinearProgressProps>;\n\n /**\n * Any additional props to pass to the `LinearProgress` bar when the\n * {@link loadingType} is one of the linear types.\n */\n circularProgressProps?: PropsWithRef<CircularProgressProps>;\n}\n\n/**\n * **Client Component**\n *\n * The async button can be used to render a loading indicator within a button\n * during an async task. The loading spinner can be shown either by enabling the\n * `loading` prop or returning a promise from the `onClick` event which will\n * continue to show the loading indicator until the promise has been resolved.\n *\n * @example Async onClick\n * ```tsx\n * import { AsyncButton } from \"@react-md/core/button/AsyncButton\";\n * import { useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const [data, setData] = useState(null);\n * return (\n * <AsyncButton\n * type=\"submit\"\n * onClick={async () => {\n * const response = await fetch(\"/my-api\");\n * const json = await response.json();\n * setData(json);\n * }}\n * >\n * Submit\n * </AsyncButton>\n * );\n * }\n * ```\n *\n * @example Manual Loading State\n * ```tsx\n * import { AsyncButton } from \"@react-md/core/button/AsyncButton\";\n * import { useMutation } from \"@tanstack/query\";\n * import { useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { isLoading, mutate } = useMutation({\n * mutationFn: (newTodo) => fetch('/todos', {\n * method: \"POST\",\n * body: JSON.stringify(newTodo),\n * }),\n * });\n *\n * return (\n * <AsyncButton\n * type=\"submit\"\n * loading={isLoading}\n * onClick={() => {\n * mutate({ id: Date.now(), title: \"Create example\" });\n * }}\n * >\n * Create Todo\n * </AsyncButton>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/button#async-button | AsyncButton Demos}\n * @since 6.0.0\n */\nexport const AsyncButton = forwardRef<HTMLButtonElement, AsyncButtonProps>(\n function AsyncButton(props, ref) {\n const {\n id: propId,\n onClick = noop,\n children,\n floating = null,\n theme = floating ? \"secondary\" : \"clear\",\n themeType = floating ? \"contained\" : \"flat\",\n buttonType = floating ? \"icon\" : \"text\",\n className,\n disabled,\n loading: propLoading = false,\n loadingType = \"circular-overlay\",\n loadingChildren,\n loadingDisabledTheme = false,\n afterAddon: propAfterAddon,\n beforeAddon: propBeforeAddon,\n linearProgressProps,\n circularProgressProps,\n progressAriaLabel,\n progressAriaLabelledBy: propProgressAriaLabelledBy,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"async-button\");\n const { handleAsync, pending } = useAsyncFunction({ disabled });\n const loading = pending || propLoading;\n\n let progressTheme: ProgressTheme = \"current-color\";\n if (theme === \"clear\" || theme === \"disabled\") {\n progressTheme = \"primary\";\n }\n\n let progressAriaLabelledBy = propProgressAriaLabelledBy;\n if (\n !progressAriaLabel &&\n !linearProgressProps?.[\"aria-label\"] &&\n !linearProgressProps?.[\"aria-labelledby\"] &&\n !circularProgressProps?.[\"aria-label\"] &&\n !circularProgressProps?.[\"aria-labelledby\"]\n ) {\n progressAriaLabelledBy = id;\n }\n\n const progress = loadingType.includes(\"linear\") ? (\n <LinearProgress\n aria-label={progressAriaLabel}\n aria-labelledby={progressAriaLabelledBy as string}\n {...linearProgressProps}\n theme={progressTheme}\n />\n ) : (\n <CircularProgress\n aria-label={progressAriaLabel}\n aria-labelledby={progressAriaLabelledBy as string}\n {...circularProgressProps}\n theme={progressTheme}\n />\n );\n\n let afterAddon = propAfterAddon;\n let beforeAddon = propBeforeAddon;\n let overlayElement: ReactNode;\n let isOverlayCover = false;\n switch (loadingType) {\n case \"circular-before\":\n beforeAddon = loading ? progress : propBeforeAddon;\n break;\n case \"circular-after\":\n afterAddon = loading ? progress : propAfterAddon;\n break;\n case \"circular-overlay\":\n case \"linear-above\":\n case \"linear-below\": {\n let alignItems: BoxAlignItems = \"center\";\n if (loadingType === \"linear-above\") {\n alignItems = \"start\";\n } else if (loadingType === \"linear-below\") {\n alignItems = \"end\";\n } else {\n isOverlayCover = true;\n }\n\n overlayElement = loading && (\n <span\n className={overlay({\n active: true,\n visible: true,\n absolute: true,\n align: alignItems,\n })}\n >\n {progress}\n </span>\n );\n break;\n }\n }\n\n return (\n <Button\n {...remaining}\n aria-disabled={loading || undefined}\n id={id}\n ref={ref}\n disabled={disabled}\n floating={floating}\n className={cnb(\n \"rmd-button--async\",\n loading && isOverlayCover && \"rmd-button--async-overlay\",\n className\n )}\n theme={loading && loadingDisabledTheme ? \"disabled\" : theme}\n themeType={themeType}\n buttonType={buttonType}\n onClick={handleAsync((event) => Promise.resolve(onClick(event)))}\n >\n {beforeAddon}\n {loading && typeof loadingChildren !== \"undefined\"\n ? loadingChildren\n : children}\n {afterAddon}\n {overlayElement}\n </Button>\n );\n }\n);\n"],"names":["cnb","forwardRef","overlay","CircularProgress","LinearProgress","useAsyncFunction","useEnsuredId","Button","noop","AsyncButton","props","ref","id","propId","onClick","children","floating","theme","themeType","buttonType","className","disabled","loading","propLoading","loadingType","loadingChildren","loadingDisabledTheme","afterAddon","propAfterAddon","beforeAddon","propBeforeAddon","linearProgressProps","circularProgressProps","progressAriaLabel","progressAriaLabelledBy","propProgressAriaLabelledBy","remaining","handleAsync","pending","progressTheme","progress","includes","aria-label","aria-labelledby","overlayElement","isOverlayCover","alignItems","span","active","visible","absolute","align","aria-disabled","undefined","event","Promise","resolve"],"mappings":"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"}
1
+ {"version":3,"sources":["../../src/button/AsyncButton.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { type MouseEvent, type ReactNode, forwardRef } from \"react\";\n\nimport { type BoxAlignItems } from \"../box/styles.js\";\nimport { overlay } from \"../overlay/styles.js\";\nimport {\n CircularProgress,\n type CircularProgressProps,\n} from \"../progress/CircularProgress.js\";\nimport {\n LinearProgress,\n type LinearProgressProps,\n} from \"../progress/LinearProgress.js\";\nimport { type ProgressTheme } from \"../progress/types.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useAsyncFunction } from \"../useAsyncFunction.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { Button, type ButtonProps } from \"./Button.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type AsyncButtonLoadingType =\n | \"circular-before\"\n | \"circular-after\"\n | \"circular-overlay\"\n | \"linear-above\"\n | \"linear-below\";\n\n/**\n * @since 6.0.0\n */\nexport interface AsyncButtonProps extends ButtonProps {\n /**\n * @see {@link progressAriaLabelledBy}\n * @defaultValue `\"async-button\" + useId()`\n */\n id?: string;\n\n /**\n * When this is defined and returns a `Promise`, the loading indicator will\n * display until the promise has resolved.\n *\n * @defaultValue `() => {}`\n */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => Promise<void> | void;\n\n /**\n * Set this to `true` to manually display a loading spinner.\n *\n * @defaultValue `false`\n */\n loading?: boolean;\n\n /**\n * - `\"circular-overlay\"` - Covers and hides the button content with a\n * centered circular progress\n * - `\"circular-before\"` - Renders a circular progress bar before the button\n * content which is useful when rendering an icon before the button text.\n * See {@link beforeAddon} as well.\n * - `\"circular-after\"` - Renders a circular progress bar before the button\n * content which is useful when rendering an icon after the button text.\n * See {@link afterAddon} as well.\n * - `\"linear-above\"` - Renders a linear progress bar at the top of the button\n * while still displaying the button contents. Usually looks good for\n * outlined buttons.\n * - `\"linear-below\"` - Renders a linear progress bar at the bottom of the\n * button while still displaying the button contents. Usually looks good for\n * outlined buttons.\n *\n * @defaultValue `\"circular-overlay\"`\n */\n loadingType?: AsyncButtonLoadingType;\n\n /**\n * Optional content to display instead of the default `children` while\n * loading.\n */\n loadingChildren?: ReactNode;\n\n /**\n * Set this to `true` to use the `disabled` theme while loading.\n *\n * @defaultValue `false`\n */\n loadingDisabledTheme?: boolean;\n\n /**\n * This should be used when the {@link loadingType} is set to\n * `\"circular-before\"`, an icon should appear before the other content in\n * the button, and the loading indicator should replace the icon.\n */\n beforeAddon?: ReactNode;\n\n /**\n * This should be used when the {@link loadingType} is set to\n * `\"circular-after\"`, an icon should appear before the other content in\n * the button, and the loading indicator should replace the icon.\n */\n afterAddon?: ReactNode;\n\n /**\n * An optional label to provide to the progressbar.\n *\n * @see {@link progressAriaLabelledBy}\n */\n progressAriaLabel?: string;\n\n /**\n * @see {@link id}\n * @defaultValue `id`\n */\n progressAriaLabelledBy?: string;\n\n /**\n * Any additional props to pass to the `CircularProgress` bar when the\n * {@link loadingType} is one of the circular types.\n */\n linearProgressProps?: PropsWithRef<LinearProgressProps>;\n\n /**\n * Any additional props to pass to the `LinearProgress` bar when the\n * {@link loadingType} is one of the linear types.\n */\n circularProgressProps?: PropsWithRef<CircularProgressProps>;\n}\n\n/**\n * **Client Component**\n *\n * The async button can be used to render a loading indicator within a button\n * during an async task. The loading spinner can be shown either by enabling the\n * `loading` prop or returning a promise from the `onClick` event which will\n * continue to show the loading indicator until the promise has been resolved.\n *\n * @example Async onClick\n * ```tsx\n * import { AsyncButton } from \"@react-md/core/button/AsyncButton\";\n * import { useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const [data, setData] = useState(null);\n * return (\n * <AsyncButton\n * type=\"submit\"\n * onClick={async () => {\n * const response = await fetch(\"/my-api\");\n * const json = await response.json();\n * setData(json);\n * }}\n * >\n * Submit\n * </AsyncButton>\n * );\n * }\n * ```\n *\n * @example Manual Loading State\n * ```tsx\n * import { AsyncButton } from \"@react-md/core/button/AsyncButton\";\n * import { useMutation } from \"@tanstack/query\";\n * import { useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { isLoading, mutate } = useMutation({\n * mutationFn: (newTodo) => fetch('/todos', {\n * method: \"POST\",\n * body: JSON.stringify(newTodo),\n * }),\n * });\n *\n * return (\n * <AsyncButton\n * type=\"submit\"\n * loading={isLoading}\n * onClick={() => {\n * mutate({ id: Date.now(), title: \"Create example\" });\n * }}\n * >\n * Create Todo\n * </AsyncButton>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/button#async-button | AsyncButton Demos}\n * @since 6.0.0\n */\nexport const AsyncButton = forwardRef<HTMLButtonElement, AsyncButtonProps>(\n function AsyncButton(props, ref) {\n const {\n id: propId,\n onClick = noop,\n children,\n floating = null,\n theme = floating ? \"secondary\" : \"clear\",\n themeType = floating ? \"contained\" : \"flat\",\n buttonType = floating ? \"icon\" : \"text\",\n className,\n disabled,\n loading: propLoading = false,\n loadingType = \"circular-overlay\",\n loadingChildren,\n loadingDisabledTheme = false,\n afterAddon: propAfterAddon,\n beforeAddon: propBeforeAddon,\n linearProgressProps,\n circularProgressProps,\n progressAriaLabel,\n progressAriaLabelledBy: propProgressAriaLabelledBy,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"async-button\");\n const { handleAsync, pending } = useAsyncFunction({ disabled });\n const loading = pending || propLoading;\n\n let progressTheme: ProgressTheme = \"current-color\";\n if (theme === \"clear\" || theme === \"disabled\") {\n progressTheme = \"primary\";\n }\n\n let progressAriaLabelledBy = propProgressAriaLabelledBy;\n if (\n !progressAriaLabel &&\n !linearProgressProps?.[\"aria-label\"] &&\n !linearProgressProps?.[\"aria-labelledby\"] &&\n !circularProgressProps?.[\"aria-label\"] &&\n !circularProgressProps?.[\"aria-labelledby\"]\n ) {\n progressAriaLabelledBy = id;\n }\n\n const progress = loadingType.includes(\"linear\") ? (\n <LinearProgress\n aria-label={progressAriaLabel}\n aria-labelledby={progressAriaLabelledBy as string}\n {...linearProgressProps}\n theme={progressTheme}\n />\n ) : (\n <CircularProgress\n aria-label={progressAriaLabel}\n aria-labelledby={progressAriaLabelledBy as string}\n {...circularProgressProps}\n theme={progressTheme}\n />\n );\n\n let afterAddon = propAfterAddon;\n let beforeAddon = propBeforeAddon;\n let overlayElement: ReactNode;\n let isOverlayCover = false;\n switch (loadingType) {\n case \"circular-before\":\n beforeAddon = loading ? progress : propBeforeAddon;\n break;\n case \"circular-after\":\n afterAddon = loading ? progress : propAfterAddon;\n break;\n case \"circular-overlay\":\n case \"linear-above\":\n case \"linear-below\": {\n let alignItems: BoxAlignItems = \"center\";\n if (loadingType === \"linear-above\") {\n alignItems = \"start\";\n } else if (loadingType === \"linear-below\") {\n alignItems = \"end\";\n } else {\n isOverlayCover = true;\n }\n\n overlayElement = loading && (\n <span\n className={overlay({\n active: true,\n visible: true,\n absolute: true,\n align: alignItems,\n })}\n >\n {progress}\n </span>\n );\n break;\n }\n }\n\n return (\n <Button\n {...remaining}\n aria-disabled={loading || undefined}\n id={id}\n ref={ref}\n disabled={disabled}\n floating={floating}\n className={cnb(\n \"rmd-button--async\",\n loading && isOverlayCover && \"rmd-button--async-overlay\",\n className\n )}\n theme={loading && loadingDisabledTheme ? \"disabled\" : theme}\n themeType={themeType}\n buttonType={buttonType}\n onClick={handleAsync((event) => Promise.resolve(onClick(event)))}\n >\n {beforeAddon}\n {loading && loadingChildren !== undefined ? loadingChildren : children}\n {afterAddon}\n {overlayElement}\n </Button>\n );\n }\n);\n"],"names":["cnb","forwardRef","overlay","CircularProgress","LinearProgress","useAsyncFunction","useEnsuredId","Button","noop","AsyncButton","props","ref","id","propId","onClick","children","floating","theme","themeType","buttonType","className","disabled","loading","propLoading","loadingType","loadingChildren","loadingDisabledTheme","afterAddon","propAfterAddon","beforeAddon","propBeforeAddon","linearProgressProps","circularProgressProps","progressAriaLabel","progressAriaLabelledBy","propProgressAriaLabelledBy","remaining","handleAsync","pending","progressTheme","progress","includes","aria-label","aria-labelledby","overlayElement","isOverlayCover","alignItems","span","active","visible","absolute","align","aria-disabled","undefined","event","Promise","resolve"],"mappings":"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"}
@@ -408,6 +408,14 @@ $variables: (
408
408
  }
409
409
 
410
410
  @if not $disable-contained {
411
+ $contained-elevation-end: null;
412
+ @if not
413
+ $disable-contained-pressed-elevation and
414
+ $contained-pressed-elevation
415
+ {
416
+ $contained-elevation-end: $contained-pressed-elevation;
417
+ }
418
+
411
419
  &--contained {
412
420
  // contained buttons should _normally_ always force dark background
413
421
  // colors for the interaction states This means use the default light
@@ -424,11 +432,7 @@ $variables: (
424
432
 
425
433
  @include box-shadows.elevation-transition(
426
434
  $contained-elevation,
427
- if(
428
- $disable-contained-pressed-elevation,
429
- null,
430
- $contained-pressed-elevation
431
- ),
435
+ $contained-elevation-end,
432
436
  "&.rmd-button--pressed",
433
437
  $pseudo-before: false,
434
438
  $position-relative: false
@@ -59,10 +59,10 @@ $light-theme-background-color: theme.theme-get-var(surface-color) !default;
59
59
 
60
60
  /// The background color to use when using the global dark theme
61
61
  /// @type Color
62
+ // prettier-ignore
62
63
  $dark-theme-background-color: if(
63
- theme.$disable-dark-elevation,
64
- theme.$dark-theme-surface-color,
65
- map.get(theme.$dark-elevation-colors, $elevation)
64
+ sass(theme.$disable-dark-elevation): theme.$dark-theme-surface-color;
65
+ else: map.get(theme.$dark-elevation-colors, $elevation)
66
66
  ) !default;
67
67
 
68
68
  /// The default card background color
@@ -226,10 +226,10 @@ $variables: (background-color, color);
226
226
  column-gap: $header-spacing;
227
227
  display: flex;
228
228
  max-width: 100%;
229
+ // prettier-ignore
229
230
  padding: if(
230
- $header-padding == $header-padding-top or not $header-padding-top,
231
- $header-padding,
232
- $header-padding-top $header-padding $header-padding
231
+ sass($header-padding == $header-padding-top or not $header-padding-top): $header-padding;
232
+ else: $header-padding-top $header-padding $header-padding
233
233
  );
234
234
  }
235
235
 
package/dist/chip/Chip.js CHANGED
@@ -78,7 +78,7 @@ import { chip, chipContent } from "./styles.js";
78
78
  let leftAddon = propLeftAddon;
79
79
  let rightAddon = propRightAddon;
80
80
  const selectedIconNode = getIcon("selected", propSelectedIcon);
81
- const isTransitionable = !selectedThemed && typeof selected === "boolean" && typeof (selectedIconAfter ? propRightAddon : propLeftAddon) === "undefined";
81
+ const isTransitionable = !selectedThemed && typeof selected === "boolean" && (selectedIconAfter ? propRightAddon : propLeftAddon) === undefined;
82
82
  const selectedIcon = useMaxWidthTransition({
83
83
  element: selectedIconNode,
84
84
  transitionIn: !!selected,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/chip/Chip.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type ButtonHTMLAttributes,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type BackgroundColor } from \"../cssUtils.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport {\n type BaseMaxWidthTransitionOptions,\n useMaxWidthTransition,\n} from \"../transition/useMaxWidthTransition.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { type ChipTheme, chip, chipContent } from \"./styles.js\";\n\n/**\n * @since 6.0.0 Renamed the `noninteractive` prop to\n * `noninteractable`.\n * @since 6.3.1 Extends BaseMaxWidthTransitionOptions for CSSProperties module\n * augmentation.\n */\nexport interface ChipProps\n extends\n ButtonHTMLAttributes<HTMLButtonElement>,\n BaseMaxWidthTransitionOptions,\n ComponentWithRippleProps {\n /**\n * @defaultValue `\"solid\"`\n */\n theme?: ChipTheme;\n\n /**\n * Set this to `true` if the chip should gain additional box shadow while the\n * user is pressing down on the chip.\n *\n * @defaultValue `false`\n */\n raisable?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * When this is a boolean, a selected icon will be displayed before the\n * `children` and appear/disappear when `true`/`false`.\n *\n * @see {@link selectedIcon}\n * @see {@link selectedIconAfter}\n * @see {@link selectedThemed}\n */\n selected?: boolean;\n\n /**\n * Set this to `true` if the chip should change background color while\n * {@link selected} instead of displaying an icon. The default background\n * color is a lighter swatch of the theme primary color.\n *\n * @defaultValue `false`\n */\n selectedThemed?: boolean;\n\n /**\n * An optional className to provide only while {@link selected} is `true`.\n */\n selectedClassName?: string;\n\n /**\n * This will be ignored if {@link selected} is `undefined`.\n *\n * @defaultValue `getIcon(\"selected\")`\n */\n selectedIcon?: ReactNode;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should display as the\n * {@link rightAddon} instead of the {@link leftAddon}.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n selectedIconAfter?: boolean;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should not animate and\n * instead apply `display: none`\n *\n * @defaultValue `false`\n */\n disableIconTransition?: boolean;\n\n /**\n * Set this to `true` to render the chip as a `<span>` instead of a button.\n *\n * @since 2.6.0\n * @since 6.0.0 Renamed from `noninteractable`\n * @defaultValue `false`\n */\n noninteractive?: boolean;\n\n /**\n * An optional background color theme to use.\n *\n * @since 6.0.0\n */\n backgroundColor?: BackgroundColor;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * before the `children`. This will remove some of the leading horizontal\n * padding on the chip as well.\n */\n leftAddon?: ReactNode;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * after the `children`. This will remove some of the trailing horizontal\n * padding on the chip as well.\n */\n rightAddon?: ReactNode;\n\n /**\n * Set this to true if the `children` should not be wrapped in a span to apply\n * the {@link chipContent} styles which allow for shrinking text and\n * truncating text with ellipsis.\n *\n * @defaultValue `false`\n */\n disableContentWrap?: boolean;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n *\n * @since 6.0.0\n */\n contentProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentStyle?: CSSProperties;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentClassName?: string;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip>Content</Chip>;\n * }\n * ```\n *\n * @example Outlined Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip theme=\"outline\">Content</Chip>;\n * }\n * ```\n *\n * @example Addons Example\n * ```tsx\n * import { Avatar } from \"@react-md/core/avatar/Avatar\";\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import AddCircleIcon from \"@react-md/material-icons/AddCircleIcon\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <Chip\n * leftAddon={\n * <Avatar>\n * <img src=\"https://i.pravatar.cc/40?img=3\" alt=\"\" />\n * </Avatar>\n * }\n * rightAddon={<AddCircleIcon />}\n * >\n * Chip\n * </Chip>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/chip | Chip Demos}\n * @since 6.0.0 Renamed the `noninteractable` prop to\n * `noninteractive`.\n */\nexport const Chip = forwardRef<HTMLButtonElement, ChipProps>(\n function Chip(props, ref) {\n const {\n \"aria-pressed\": ariaPressed,\n theme = \"solid\",\n className,\n raisable = false,\n disabled = false,\n selected,\n selectedThemed = false,\n selectedClassName,\n selectedIcon: propSelectedIcon,\n selectedIconAfter = false,\n backgroundColor,\n noninteractive = false,\n disableRipple,\n disableIconTransition = false,\n children: propChildren,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n leftAddon: propLeftAddon,\n rightAddon: propRightAddon,\n contentProps,\n contentStyle,\n contentClassName,\n disableContentWrap = false,\n ...remaining\n } = props;\n\n let buttonProps: ButtonHTMLAttributes<HTMLButtonElement> | undefined;\n if (!noninteractive) {\n buttonProps = {\n \"aria-pressed\": ariaPressed ?? (!!selected || undefined),\n type: \"button\",\n disabled,\n };\n }\n\n let content = propChildren;\n if (!disableContentWrap) {\n content = (\n <span\n style={contentStyle}\n {...contentProps}\n className={cnb(\n chipContent({ className: contentClassName }),\n contentProps?.className\n )}\n >\n {propChildren}\n </span>\n );\n }\n\n let leftAddon = propLeftAddon;\n let rightAddon = propRightAddon;\n const selectedIconNode = getIcon(\"selected\", propSelectedIcon);\n const isTransitionable =\n !selectedThemed &&\n typeof selected === \"boolean\" &&\n typeof (selectedIconAfter ? propRightAddon : propLeftAddon) ===\n \"undefined\";\n const selectedIcon = useMaxWidthTransition({\n element: selectedIconNode,\n transitionIn: !!selected,\n disabled: !isTransitionable,\n disableTransition: disableIconTransition,\n });\n if (isTransitionable) {\n if (selectedIconAfter) {\n rightAddon = selectedIcon;\n } else {\n leftAddon = selectedIcon;\n }\n }\n\n const { pressed, pressedClassName, ripples, handlers } =\n useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled: disabled || noninteractive,\n });\n const children = useHigherContrastChildren(content);\n const Component = noninteractive ? \"span\" : \"button\";\n\n return (\n <Component\n {...remaining}\n {...buttonProps}\n {...handlers}\n className={chip({\n className,\n theme,\n pressed: raisable && pressed,\n disabled,\n selected,\n selectedThemed,\n selectedClassName,\n noninteractive,\n backgroundColor,\n pressedClassName,\n leftAddon: !!leftAddon && (selectedIconAfter || selected !== false),\n rightAddon:\n !!rightAddon && (!selectedIconAfter || selected !== false),\n })}\n ref={ref}\n >\n {leftAddon}\n {children}\n {rightAddon}\n {ripples}\n </Component>\n );\n }\n);\n"],"names":["cnb","forwardRef","getIcon","useElementInteraction","useHigherContrastChildren","useMaxWidthTransition","chip","chipContent","Chip","props","ref","ariaPressed","theme","className","raisable","disabled","selected","selectedThemed","selectedClassName","selectedIcon","propSelectedIcon","selectedIconAfter","backgroundColor","noninteractive","disableRipple","disableIconTransition","children","propChildren","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","leftAddon","propLeftAddon","rightAddon","propRightAddon","contentProps","contentStyle","contentClassName","disableContentWrap","remaining","buttonProps","undefined","type","content","span","style","selectedIconNode","isTransitionable","element","transitionIn","disableTransition","pressed","pressedClassName","ripples","handlers","mode","Component"],"mappings":"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"}
1
+ {"version":3,"sources":["../../src/chip/Chip.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type ButtonHTMLAttributes,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type BackgroundColor } from \"../cssUtils.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport {\n type BaseMaxWidthTransitionOptions,\n useMaxWidthTransition,\n} from \"../transition/useMaxWidthTransition.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { type ChipTheme, chip, chipContent } from \"./styles.js\";\n\n/**\n * @since 6.0.0 Renamed the `noninteractive` prop to\n * `noninteractable`.\n * @since 6.3.1 Extends BaseMaxWidthTransitionOptions for CSSProperties module\n * augmentation.\n */\nexport interface ChipProps\n extends\n ButtonHTMLAttributes<HTMLButtonElement>,\n BaseMaxWidthTransitionOptions,\n ComponentWithRippleProps {\n /**\n * @defaultValue `\"solid\"`\n */\n theme?: ChipTheme;\n\n /**\n * Set this to `true` if the chip should gain additional box shadow while the\n * user is pressing down on the chip.\n *\n * @defaultValue `false`\n */\n raisable?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * When this is a boolean, a selected icon will be displayed before the\n * `children` and appear/disappear when `true`/`false`.\n *\n * @see {@link selectedIcon}\n * @see {@link selectedIconAfter}\n * @see {@link selectedThemed}\n */\n selected?: boolean;\n\n /**\n * Set this to `true` if the chip should change background color while\n * {@link selected} instead of displaying an icon. The default background\n * color is a lighter swatch of the theme primary color.\n *\n * @defaultValue `false`\n */\n selectedThemed?: boolean;\n\n /**\n * An optional className to provide only while {@link selected} is `true`.\n */\n selectedClassName?: string;\n\n /**\n * This will be ignored if {@link selected} is `undefined`.\n *\n * @defaultValue `getIcon(\"selected\")`\n */\n selectedIcon?: ReactNode;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should display as the\n * {@link rightAddon} instead of the {@link leftAddon}.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n selectedIconAfter?: boolean;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should not animate and\n * instead apply `display: none`\n *\n * @defaultValue `false`\n */\n disableIconTransition?: boolean;\n\n /**\n * Set this to `true` to render the chip as a `<span>` instead of a button.\n *\n * @since 2.6.0\n * @since 6.0.0 Renamed from `noninteractable`\n * @defaultValue `false`\n */\n noninteractive?: boolean;\n\n /**\n * An optional background color theme to use.\n *\n * @since 6.0.0\n */\n backgroundColor?: BackgroundColor;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * before the `children`. This will remove some of the leading horizontal\n * padding on the chip as well.\n */\n leftAddon?: ReactNode;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * after the `children`. This will remove some of the trailing horizontal\n * padding on the chip as well.\n */\n rightAddon?: ReactNode;\n\n /**\n * Set this to true if the `children` should not be wrapped in a span to apply\n * the {@link chipContent} styles which allow for shrinking text and\n * truncating text with ellipsis.\n *\n * @defaultValue `false`\n */\n disableContentWrap?: boolean;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n *\n * @since 6.0.0\n */\n contentProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentStyle?: CSSProperties;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentClassName?: string;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip>Content</Chip>;\n * }\n * ```\n *\n * @example Outlined Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip theme=\"outline\">Content</Chip>;\n * }\n * ```\n *\n * @example Addons Example\n * ```tsx\n * import { Avatar } from \"@react-md/core/avatar/Avatar\";\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import AddCircleIcon from \"@react-md/material-icons/AddCircleIcon\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <Chip\n * leftAddon={\n * <Avatar>\n * <img src=\"https://i.pravatar.cc/40?img=3\" alt=\"\" />\n * </Avatar>\n * }\n * rightAddon={<AddCircleIcon />}\n * >\n * Chip\n * </Chip>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/chip | Chip Demos}\n * @since 6.0.0 Renamed the `noninteractable` prop to\n * `noninteractive`.\n */\nexport const Chip = forwardRef<HTMLButtonElement, ChipProps>(\n function Chip(props, ref) {\n const {\n \"aria-pressed\": ariaPressed,\n theme = \"solid\",\n className,\n raisable = false,\n disabled = false,\n selected,\n selectedThemed = false,\n selectedClassName,\n selectedIcon: propSelectedIcon,\n selectedIconAfter = false,\n backgroundColor,\n noninteractive = false,\n disableRipple,\n disableIconTransition = false,\n children: propChildren,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n leftAddon: propLeftAddon,\n rightAddon: propRightAddon,\n contentProps,\n contentStyle,\n contentClassName,\n disableContentWrap = false,\n ...remaining\n } = props;\n\n let buttonProps: ButtonHTMLAttributes<HTMLButtonElement> | undefined;\n if (!noninteractive) {\n buttonProps = {\n \"aria-pressed\": ariaPressed ?? (!!selected || undefined),\n type: \"button\",\n disabled,\n };\n }\n\n let content = propChildren;\n if (!disableContentWrap) {\n content = (\n <span\n style={contentStyle}\n {...contentProps}\n className={cnb(\n chipContent({ className: contentClassName }),\n contentProps?.className\n )}\n >\n {propChildren}\n </span>\n );\n }\n\n let leftAddon = propLeftAddon;\n let rightAddon = propRightAddon;\n const selectedIconNode = getIcon(\"selected\", propSelectedIcon);\n const isTransitionable =\n !selectedThemed &&\n typeof selected === \"boolean\" &&\n (selectedIconAfter ? propRightAddon : propLeftAddon) === undefined;\n const selectedIcon = useMaxWidthTransition({\n element: selectedIconNode,\n transitionIn: !!selected,\n disabled: !isTransitionable,\n disableTransition: disableIconTransition,\n });\n if (isTransitionable) {\n if (selectedIconAfter) {\n rightAddon = selectedIcon;\n } else {\n leftAddon = selectedIcon;\n }\n }\n\n const { pressed, pressedClassName, ripples, handlers } =\n useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled: disabled || noninteractive,\n });\n const children = useHigherContrastChildren(content);\n const Component = noninteractive ? \"span\" : \"button\";\n\n return (\n <Component\n {...remaining}\n {...buttonProps}\n {...handlers}\n className={chip({\n className,\n theme,\n pressed: raisable && pressed,\n disabled,\n selected,\n selectedThemed,\n selectedClassName,\n noninteractive,\n backgroundColor,\n pressedClassName,\n leftAddon: !!leftAddon && (selectedIconAfter || selected !== false),\n rightAddon:\n !!rightAddon && (!selectedIconAfter || selected !== false),\n })}\n ref={ref}\n >\n {leftAddon}\n {children}\n {rightAddon}\n {ripples}\n </Component>\n );\n }\n);\n"],"names":["cnb","forwardRef","getIcon","useElementInteraction","useHigherContrastChildren","useMaxWidthTransition","chip","chipContent","Chip","props","ref","ariaPressed","theme","className","raisable","disabled","selected","selectedThemed","selectedClassName","selectedIcon","propSelectedIcon","selectedIconAfter","backgroundColor","noninteractive","disableRipple","disableIconTransition","children","propChildren","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","leftAddon","propLeftAddon","rightAddon","propRightAddon","contentProps","contentStyle","contentClassName","disableContentWrap","remaining","buttonProps","undefined","type","content","span","style","selectedIconNode","isTransitionable","element","transitionIn","disableTransition","pressed","pressedClassName","ripples","handlers","mode","Component"],"mappings":"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"}
@@ -182,10 +182,10 @@ $solid-light-color: a11y.contrast-color($solid-light-background-color) !default;
182
182
 
183
183
  /// The dark theme background color for the `theme="solid"`
184
184
  /// @type Color
185
+ // prettier-ignore
185
186
  $solid-dark-background-color: if(
186
- theme.$disable-dark-elevation,
187
- colors.$grey-900,
188
- map.get(theme.$dark-elevation-colors, 12)
187
+ sass(theme.$disable-dark-elevation): colors.$grey-900;
188
+ else: map.get(theme.$dark-elevation-colors, 12)
189
189
  ) !default;
190
190
 
191
191
  /// The dark theme background color for the `theme="solid"` and the `Chip` is
@@ -261,10 +261,10 @@ $outline-dark-color: $outline-light-color !default;
261
261
 
262
262
  /// The background-color to use in dark themes when `theme="outline"`
263
263
  /// @type Color
264
+ // prettier-ignore
264
265
  $outline-dark-background-color: if(
265
- theme.$disable-dark-elevation,
266
- theme.$dark-theme-surface-color,
267
- map.get(theme.$dark-elevation-colors, $outline-raisable-box-shadow-z-value)
266
+ sass(theme.$disable-dark-elevation): theme.$dark-theme-surface-color;
267
+ else: map.get( theme.$dark-elevation-colors, $outline-raisable-box-shadow-z-value)
268
268
  ) !default;
269
269
 
270
270
  /// The text color to use in dark themes when `theme="outline"`
@@ -80,20 +80,25 @@ export interface TextCssUtilsOptions {
80
80
  */
81
81
  textOverflow?: TextOverflow;
82
82
  }
83
+ /**
84
+ * Set this to `true` to allow the content to only be visible for screen
85
+ * readers. Set this to `"focusable"` to allow the content to be visible to
86
+ * screen readers and once focused. Set this to `"phone"` to only render the
87
+ * content as screen reader only text on phones.
88
+ *
89
+ * @since 6.5.1
90
+ */
91
+ export type SrOnlyBehavior = boolean | "focusable" | "phone";
83
92
  /**
84
93
  * @since 6.0.0
85
94
  */
86
95
  export interface CssUtilsOptions extends TextCssUtilsOptions {
87
96
  className?: string;
88
97
  /**
89
- * Set this to `true` to allow the content to only be visible for screen
90
- * readers. Set this to `"focusable"` to allow the content to be visible to
91
- * screen readers and once focused. Set this to `"phone"` to only render the
92
- * the content as screen reader only text on phones.
93
- *
98
+ * @see {@link SrOnlyBehavior}
94
99
  * @defaultValue `false`
95
100
  */
96
- srOnly?: boolean | "focusable" | "phone";
101
+ srOnly?: SrOnlyBehavior;
97
102
  /**
98
103
  * Set this to `"current-color"` to inherit the current text color or a
99
104
  * specific theme color as the outline `box-shadow`.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cssUtils.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\n/**\n * - `primary -> $primary-color`\n * - `secondary -> $secondary-color`\n * - `warning -> $warning-color`\n * - `success -> $success-color`\n * - `error -> $error-color`\n *\n * @since 6.0.0\n */\nexport type ThemeColor =\n | \"primary\"\n | \"secondary\"\n | \"warning\"\n | \"success\"\n | \"error\";\n\n/**\n * - `text-primary -> $text-primary-color`\n * - `text-secondary -> $text-secondary-color`\n * - `text-hint -> $text-hint-color`\n * - `text-disabled -> $text-disabled-color`\n *\n * @since 6.0.0\n */\nexport type TextColor =\n | \"text-primary\"\n | \"text-secondary\"\n | \"text-hint\"\n | \"text-disabled\"\n | `on-${ThemeColor}`;\n\n/**\n * @since 6.0.0\n */\nexport type OutlineColor = ThemeColor | \"greyscale\" | \"current-color\";\n\n/**\n * @since 6.0.0\n */\nexport type BackgroundColor = ThemeColor | \"surface\" | \"current-color\";\n\nexport type TextAlign = \"left\" | \"center\" | \"right\";\nexport type TextDecoration = \"underline\" | \"overline\" | \"line-through\" | \"none\";\nexport type TextTransform = \"capitalize\" | \"uppercase\" | \"lowercase\";\nexport type FontStyle = \"italic\" | \"oblique\" | \"normal\";\n\n/**\n * The supported css `font-weight` values.\n *\n * Note: You will need to ensure that you are using a web safe font for all the\n * font weights to work, use variable fonts, or load all font weights for your\n * custom font.\n *\n * @see {@link https://www.google.com/search?q=web+safe+fonts | Web Safe Fonts}\n * @see {@link https://www.google.com/search?q=variable+fonts | Variable Fonts}\n * @since 6.0.0 This was `TextWeight` beforehand.\n */\nexport type FontWeight =\n | \"thin\"\n | \"light\"\n | \"regular\"\n | \"medium\"\n | \"bold\"\n | \"semi-bold\"\n | \"black\";\n\n/**\n * Since the typography within react-md tries to not modify base elements, the\n * default margin applied to heading tags (h1-h6) and paragraph (p) might have\n * large margin that you don't want applied when using this component. You can\n * disable:\n *\n * - only the top margin by setting this prop to `\"bottom\"`\n * - only the bottom margin by setting this prop to `\"top\"`\n * - top and bottom margin by setting this prop to `\"none\"`\n * - or keep the initial behavior: `\"initial\"`\n *\n * @since 6.0.0\n */\nexport type Margin = \"none\" | \"top\" | \"bottom\" | \"centered\";\n\n/** @since 6.0.0 */\nexport type TextOverflow = \"allow\" | \"nowrap\" | \"ellipsis\";\n\n/** @since 6.0.0 */\nexport interface TextCssUtilsOptions {\n textColor?: ThemeColor | TextColor | null;\n\n textAlign?: TextAlign;\n\n textDecoration?: TextDecoration;\n\n textTransform?: TextTransform;\n\n fontWeight?: FontWeight;\n\n fontStyle?: FontStyle;\n\n /**\n * This can be used to remove margin from an element (usually typography\n * elements since the browser applies default margin for those elements).\n *\n * @see {@link Margin}\n */\n margin?: Margin;\n\n /**\n * Set this to `\"nowrap\"` to only prevent line wrap behavior or `\"ellipsis\"`\n * to also hide additional text with ellipsis.\n *\n * @defaultValue `\"allow\"`\n */\n textOverflow?: TextOverflow;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface CssUtilsOptions extends TextCssUtilsOptions {\n className?: string;\n\n /**\n * Set this to `true` to allow the content to only be visible for screen\n * readers. Set this to `\"focusable\"` to allow the content to be visible to\n * screen readers and once focused. Set this to `\"phone\"` to only render the\n * the content as screen reader only text on phones.\n *\n * @defaultValue `false`\n */\n srOnly?: boolean | \"focusable\" | \"phone\";\n\n /**\n * Set this to `\"current-color\"` to inherit the current text color or a\n * specific theme color as the outline `box-shadow`.\n */\n outlineColor?: OutlineColor;\n\n /**\n * When this is defined, a specific theme background-color will be applied\n * along with updating the text color be either `#000` or `#fff` depending on\n * which has the highest contrast ratio.\n */\n backgroundColor?: BackgroundColor;\n\n /**\n * Set this to `true` if the element should act as an interaction surface\n * which will:\n * - display a pointer while hovered\n * - increase the z-index of children to enable higher contrast when\n * `core.$interaction-disable-higher-contrast` is not `true`\n * - add a `::before` pseudo element that will:\n * - gain the focus shadow while `:focus`-ed\n * - add a background-color while `:hover`-ed\n * - show no hover/focus styles while `:disabled` or `[aria-disabled=\"true\"]`\n *\n * @defaultValue `false`\n */\n surface?: boolean;\n\n /**\n * Set this to `\"light\"` or `\"dark\"` to update the hover, focus, press,\n * selected, and ripple colors for the surface type. `\"light\"` surfaces will\n * use `#000` while `\"dark\"` will use `#fff`.\n */\n surfaceColor?: \"light\" | \"dark\";\n}\n\n/**\n * This is used to apply css utility functions to any element within your\n * application such as:\n * - specific theme colors as background, text, or outline color\n * - removing margin\n * - screen reader visible only text\n * - text-align, text-decoration, text-transform, font-style, font-weight\n * - disable line wrap\n *\n * @since 6.0.0\n */\nexport function cssUtils(options: CssUtilsOptions): string {\n const {\n className,\n srOnly,\n textColor,\n outlineColor,\n backgroundColor,\n surface,\n surfaceColor,\n margin,\n fontStyle,\n fontWeight,\n textAlign,\n textDecoration,\n textTransform,\n textOverflow,\n } = options;\n\n const isMarginTop = margin === \"top\";\n const isTextColor =\n textColor === \"text-primary\" ||\n textColor === \"text-secondary\" ||\n textColor === \"text-hint\" ||\n textColor === \"text-disabled\";\n\n return cnb(\n !backgroundColor && !isTextColor && textColor && `rmd-${textColor}-color`,\n !backgroundColor && isTextColor && `rmd-${textColor}-color`,\n backgroundColor && \"rmd-background-container\",\n backgroundColor &&\n backgroundColor !== \"current-color\" &&\n backgroundColor !== \"surface\" &&\n `rmd-${backgroundColor}-container`,\n outlineColor && \"rmd-outline\",\n outlineColor && `rmd-${outlineColor}-outline`,\n (isMarginTop || margin === \"bottom\") &&\n `rmd-no-margin-${isMarginTop ? \"bottom\" : \"top\"}`,\n margin === \"none\" && \"rmd-no-margin\",\n margin === \"centered\" && \"rmd-centered\",\n textAlign && `rmd-align-${textAlign}`,\n textDecoration && `rmd-${textDecoration}`,\n textTransform && `rmd-${textTransform}`,\n fontStyle && `rmd-${fontStyle}`,\n fontWeight && `rmd-${fontWeight}`,\n srOnly && srOnly !== \"phone\" && \"rmd-sr-only\",\n srOnly === \"phone\" && \"rmd-phone-sr-only\",\n srOnly === \"focusable\" && \"rmd-sr-only--focusable\",\n surfaceColor === \"light\" && \"rmd-light-surface\",\n surfaceColor === \"dark\" && \"rmd-dark-surface\",\n textOverflow && textOverflow !== \"allow\" && \"rmd-nowrap\",\n textOverflow === \"ellipsis\" && \"rmd-ellipsis\",\n surface && \"rmd-interaction-surface\",\n className\n );\n}\n"],"names":["cnb","cssUtils","options","className","srOnly","textColor","outlineColor","backgroundColor","surface","surfaceColor","margin","fontStyle","fontWeight","textAlign","textDecoration","textTransform","textOverflow","isMarginTop","isTextColor"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAyKhC;;;;;;;;;;CAUC,GACD,OAAO,SAASC,SAASC,OAAwB;IAC/C,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,eAAe,EACfC,OAAO,EACPC,YAAY,EACZC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,YAAY,EACb,GAAGd;IAEJ,MAAMe,cAAcP,WAAW;IAC/B,MAAMQ,cACJb,cAAc,kBACdA,cAAc,oBACdA,cAAc,eACdA,cAAc;IAEhB,OAAOL,IACL,CAACO,mBAAmB,CAACW,eAAeb,aAAa,CAAC,IAAI,EAAEA,UAAU,MAAM,CAAC,EACzE,CAACE,mBAAmBW,eAAe,CAAC,IAAI,EAAEb,UAAU,MAAM,CAAC,EAC3DE,mBAAmB,4BACnBA,mBACEA,oBAAoB,mBACpBA,oBAAoB,aACpB,CAAC,IAAI,EAAEA,gBAAgB,UAAU,CAAC,EACpCD,gBAAgB,eAChBA,gBAAgB,CAAC,IAAI,EAAEA,aAAa,QAAQ,CAAC,EAC7C,AAACW,CAAAA,eAAeP,WAAW,QAAO,KAChC,CAAC,cAAc,EAAEO,cAAc,WAAW,OAAO,EACnDP,WAAW,UAAU,iBACrBA,WAAW,cAAc,gBACzBG,aAAa,CAAC,UAAU,EAAEA,WAAW,EACrCC,kBAAkB,CAAC,IAAI,EAAEA,gBAAgB,EACzCC,iBAAiB,CAAC,IAAI,EAAEA,eAAe,EACvCJ,aAAa,CAAC,IAAI,EAAEA,WAAW,EAC/BC,cAAc,CAAC,IAAI,EAAEA,YAAY,EACjCR,UAAUA,WAAW,WAAW,eAChCA,WAAW,WAAW,qBACtBA,WAAW,eAAe,0BAC1BK,iBAAiB,WAAW,qBAC5BA,iBAAiB,UAAU,oBAC3BO,gBAAgBA,iBAAiB,WAAW,cAC5CA,iBAAiB,cAAc,gBAC/BR,WAAW,2BACXL;AAEJ"}
1
+ {"version":3,"sources":["../src/cssUtils.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\n/**\n * - `primary -> $primary-color`\n * - `secondary -> $secondary-color`\n * - `warning -> $warning-color`\n * - `success -> $success-color`\n * - `error -> $error-color`\n *\n * @since 6.0.0\n */\nexport type ThemeColor =\n | \"primary\"\n | \"secondary\"\n | \"warning\"\n | \"success\"\n | \"error\";\n\n/**\n * - `text-primary -> $text-primary-color`\n * - `text-secondary -> $text-secondary-color`\n * - `text-hint -> $text-hint-color`\n * - `text-disabled -> $text-disabled-color`\n *\n * @since 6.0.0\n */\nexport type TextColor =\n | \"text-primary\"\n | \"text-secondary\"\n | \"text-hint\"\n | \"text-disabled\"\n | `on-${ThemeColor}`;\n\n/**\n * @since 6.0.0\n */\nexport type OutlineColor = ThemeColor | \"greyscale\" | \"current-color\";\n\n/**\n * @since 6.0.0\n */\nexport type BackgroundColor = ThemeColor | \"surface\" | \"current-color\";\n\nexport type TextAlign = \"left\" | \"center\" | \"right\";\nexport type TextDecoration = \"underline\" | \"overline\" | \"line-through\" | \"none\";\nexport type TextTransform = \"capitalize\" | \"uppercase\" | \"lowercase\";\nexport type FontStyle = \"italic\" | \"oblique\" | \"normal\";\n\n/**\n * The supported css `font-weight` values.\n *\n * Note: You will need to ensure that you are using a web safe font for all the\n * font weights to work, use variable fonts, or load all font weights for your\n * custom font.\n *\n * @see {@link https://www.google.com/search?q=web+safe+fonts | Web Safe Fonts}\n * @see {@link https://www.google.com/search?q=variable+fonts | Variable Fonts}\n * @since 6.0.0 This was `TextWeight` beforehand.\n */\nexport type FontWeight =\n | \"thin\"\n | \"light\"\n | \"regular\"\n | \"medium\"\n | \"bold\"\n | \"semi-bold\"\n | \"black\";\n\n/**\n * Since the typography within react-md tries to not modify base elements, the\n * default margin applied to heading tags (h1-h6) and paragraph (p) might have\n * large margin that you don't want applied when using this component. You can\n * disable:\n *\n * - only the top margin by setting this prop to `\"bottom\"`\n * - only the bottom margin by setting this prop to `\"top\"`\n * - top and bottom margin by setting this prop to `\"none\"`\n * - or keep the initial behavior: `\"initial\"`\n *\n * @since 6.0.0\n */\nexport type Margin = \"none\" | \"top\" | \"bottom\" | \"centered\";\n\n/** @since 6.0.0 */\nexport type TextOverflow = \"allow\" | \"nowrap\" | \"ellipsis\";\n\n/** @since 6.0.0 */\nexport interface TextCssUtilsOptions {\n textColor?: ThemeColor | TextColor | null;\n\n textAlign?: TextAlign;\n\n textDecoration?: TextDecoration;\n\n textTransform?: TextTransform;\n\n fontWeight?: FontWeight;\n\n fontStyle?: FontStyle;\n\n /**\n * This can be used to remove margin from an element (usually typography\n * elements since the browser applies default margin for those elements).\n *\n * @see {@link Margin}\n */\n margin?: Margin;\n\n /**\n * Set this to `\"nowrap\"` to only prevent line wrap behavior or `\"ellipsis\"`\n * to also hide additional text with ellipsis.\n *\n * @defaultValue `\"allow\"`\n */\n textOverflow?: TextOverflow;\n}\n\n/**\n * Set this to `true` to allow the content to only be visible for screen\n * readers. Set this to `\"focusable\"` to allow the content to be visible to\n * screen readers and once focused. Set this to `\"phone\"` to only render the\n * content as screen reader only text on phones.\n *\n * @since 6.5.1\n */\nexport type SrOnlyBehavior = boolean | \"focusable\" | \"phone\";\n\n/**\n * @since 6.0.0\n */\nexport interface CssUtilsOptions extends TextCssUtilsOptions {\n className?: string;\n\n /**\n * @see {@link SrOnlyBehavior}\n * @defaultValue `false`\n */\n srOnly?: SrOnlyBehavior;\n\n /**\n * Set this to `\"current-color\"` to inherit the current text color or a\n * specific theme color as the outline `box-shadow`.\n */\n outlineColor?: OutlineColor;\n\n /**\n * When this is defined, a specific theme background-color will be applied\n * along with updating the text color be either `#000` or `#fff` depending on\n * which has the highest contrast ratio.\n */\n backgroundColor?: BackgroundColor;\n\n /**\n * Set this to `true` if the element should act as an interaction surface\n * which will:\n * - display a pointer while hovered\n * - increase the z-index of children to enable higher contrast when\n * `core.$interaction-disable-higher-contrast` is not `true`\n * - add a `::before` pseudo element that will:\n * - gain the focus shadow while `:focus`-ed\n * - add a background-color while `:hover`-ed\n * - show no hover/focus styles while `:disabled` or `[aria-disabled=\"true\"]`\n *\n * @defaultValue `false`\n */\n surface?: boolean;\n\n /**\n * Set this to `\"light\"` or `\"dark\"` to update the hover, focus, press,\n * selected, and ripple colors for the surface type. `\"light\"` surfaces will\n * use `#000` while `\"dark\"` will use `#fff`.\n */\n surfaceColor?: \"light\" | \"dark\";\n}\n\n/**\n * This is used to apply css utility functions to any element within your\n * application such as:\n * - specific theme colors as background, text, or outline color\n * - removing margin\n * - screen reader visible only text\n * - text-align, text-decoration, text-transform, font-style, font-weight\n * - disable line wrap\n *\n * @since 6.0.0\n */\nexport function cssUtils(options: CssUtilsOptions): string {\n const {\n className,\n srOnly,\n textColor,\n outlineColor,\n backgroundColor,\n surface,\n surfaceColor,\n margin,\n fontStyle,\n fontWeight,\n textAlign,\n textDecoration,\n textTransform,\n textOverflow,\n } = options;\n\n const isMarginTop = margin === \"top\";\n const isTextColor =\n textColor === \"text-primary\" ||\n textColor === \"text-secondary\" ||\n textColor === \"text-hint\" ||\n textColor === \"text-disabled\";\n\n return cnb(\n !backgroundColor && !isTextColor && textColor && `rmd-${textColor}-color`,\n !backgroundColor && isTextColor && `rmd-${textColor}-color`,\n backgroundColor && \"rmd-background-container\",\n backgroundColor &&\n backgroundColor !== \"current-color\" &&\n backgroundColor !== \"surface\" &&\n `rmd-${backgroundColor}-container`,\n outlineColor && \"rmd-outline\",\n outlineColor && `rmd-${outlineColor}-outline`,\n (isMarginTop || margin === \"bottom\") &&\n `rmd-no-margin-${isMarginTop ? \"bottom\" : \"top\"}`,\n margin === \"none\" && \"rmd-no-margin\",\n margin === \"centered\" && \"rmd-centered\",\n textAlign && `rmd-align-${textAlign}`,\n textDecoration && `rmd-${textDecoration}`,\n textTransform && `rmd-${textTransform}`,\n fontStyle && `rmd-${fontStyle}`,\n fontWeight && `rmd-${fontWeight}`,\n srOnly && srOnly !== \"phone\" && \"rmd-sr-only\",\n srOnly === \"phone\" && \"rmd-phone-sr-only\",\n srOnly === \"focusable\" && \"rmd-sr-only--focusable\",\n surfaceColor === \"light\" && \"rmd-light-surface\",\n surfaceColor === \"dark\" && \"rmd-dark-surface\",\n textOverflow && textOverflow !== \"allow\" && \"rmd-nowrap\",\n textOverflow === \"ellipsis\" && \"rmd-ellipsis\",\n surface && \"rmd-interaction-surface\",\n className\n );\n}\n"],"names":["cnb","cssUtils","options","className","srOnly","textColor","outlineColor","backgroundColor","surface","surfaceColor","margin","fontStyle","fontWeight","textAlign","textDecoration","textTransform","textOverflow","isMarginTop","isTextColor"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AA+KhC;;;;;;;;;;CAUC,GACD,OAAO,SAASC,SAASC,OAAwB;IAC/C,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,eAAe,EACfC,OAAO,EACPC,YAAY,EACZC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,YAAY,EACb,GAAGd;IAEJ,MAAMe,cAAcP,WAAW;IAC/B,MAAMQ,cACJb,cAAc,kBACdA,cAAc,oBACdA,cAAc,eACdA,cAAc;IAEhB,OAAOL,IACL,CAACO,mBAAmB,CAACW,eAAeb,aAAa,CAAC,IAAI,EAAEA,UAAU,MAAM,CAAC,EACzE,CAACE,mBAAmBW,eAAe,CAAC,IAAI,EAAEb,UAAU,MAAM,CAAC,EAC3DE,mBAAmB,4BACnBA,mBACEA,oBAAoB,mBACpBA,oBAAoB,aACpB,CAAC,IAAI,EAAEA,gBAAgB,UAAU,CAAC,EACpCD,gBAAgB,eAChBA,gBAAgB,CAAC,IAAI,EAAEA,aAAa,QAAQ,CAAC,EAC7C,AAACW,CAAAA,eAAeP,WAAW,QAAO,KAChC,CAAC,cAAc,EAAEO,cAAc,WAAW,OAAO,EACnDP,WAAW,UAAU,iBACrBA,WAAW,cAAc,gBACzBG,aAAa,CAAC,UAAU,EAAEA,WAAW,EACrCC,kBAAkB,CAAC,IAAI,EAAEA,gBAAgB,EACzCC,iBAAiB,CAAC,IAAI,EAAEA,eAAe,EACvCJ,aAAa,CAAC,IAAI,EAAEA,WAAW,EAC/BC,cAAc,CAAC,IAAI,EAAEA,YAAY,EACjCR,UAAUA,WAAW,WAAW,eAChCA,WAAW,WAAW,qBACtBA,WAAW,eAAe,0BAC1BK,iBAAiB,WAAW,qBAC5BA,iBAAiB,UAAU,oBAC3BO,gBAAgBA,iBAAiB,WAAW,cAC5CA,iBAAiB,cAAc,gBAC/BR,WAAW,2BACXL;AAEJ"}
@@ -33,7 +33,7 @@ import { getTimeStep } from "./utils.js";
33
33
  * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}
34
34
  */ export function useTimeField(options) {
35
35
  const { min, max, step, ...fieldOptions } = options;
36
- if (process.env.NODE_ENV !== "production" && typeof step !== "undefined" && (!min || !max)) {
36
+ if (process.env.NODE_ENV !== "production" && step !== undefined && (!min || !max)) {
37
37
  throw new Error("A `step` was provided to a time field without the `min` or `max` props.");
38
38
  }
39
39
  const { errorMessage, fieldProps, ...impl } = useTextField(fieldOptions);
@@ -1 +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\n 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\n 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 extends Omit<\n TextFieldImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedTimeFieldProps;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldWithMessageImplementation extends Omit<\n TextFieldWithMessageImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedTimeFieldMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface ValidatedTimeFieldImplementation 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;AA2JpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
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\n 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\n 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 extends Omit<\n TextFieldImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedTimeFieldProps;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldWithMessageImplementation extends Omit<\n TextFieldWithMessageImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedTimeFieldMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface ValidatedTimeFieldImplementation 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 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","undefined","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;AA2JpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,gBACzBJ,SAASK,aACR,CAAA,CAACP,OAAO,CAACC,GAAE,GACZ;QACA,MAAM,IAAIO,MACR;IAEJ;IAEA,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGC,MAAM,GAAGf,aAAaO;IAE3D,2EAA2E;IAC3E,6EAA6E;IAC7E,wEAAwE;IACxE,sCAAsC;IACtC,uBAAuB;IACvB,uCAAuC;IACvC,yCAAyC;IACzC,oCAAoC;IACpC,6DAA6D;IAC7D,MAAM,EAAES,KAAK,EAAE,GAAGC,mBAAmB,GAAGH;IACxC,MAAMI,UAAUnB,OAAOiB;IAEvB,OAAO;QACL,GAAGD,IAAI;QACPF;QACAC,YAAY;YACV,GAAGG,iBAAiB;YACpBE,cAAcD,QAAQE,OAAO;YAC7BhB;YACAC;YACAC,MAAML,YAAYK;YAClBe,MAAM;QACR;IACF;AACF"}
@@ -12,8 +12,8 @@
12
12
  */ function createEventHandler(throttle, callbacks) {
13
13
  let running = false;
14
14
  const runCallbacks = (event)=>()=>{
15
- for(let i = 0; i < callbacks.length; i += 1){
16
- callbacks[i](event);
15
+ for (const callback of callbacks){
16
+ callback(event);
17
17
  }
18
18
  running = false;
19
19
  };
@@ -26,13 +26,13 @@
26
26
  return;
27
27
  }
28
28
  running = true;
29
- window.requestAnimationFrame(runCallbacks(event));
29
+ globalThis.requestAnimationFrame(runCallbacks(event));
30
30
  };
31
31
  }
32
32
  /**
33
33
  * Creates a throttled event handler for the provided event type and event
34
34
  * target.
35
- */ function createDelegatedEventHandler(eventType, eventTarget = window, throttle = false, options) {
35
+ */ function createDelegatedEventHandler(eventType, eventTarget = globalThis.window, throttle = false, options) {
36
36
  const callbacks = [];
37
37
  const handler = createEventHandler(throttle, callbacks);
38
38
  return {
@@ -41,10 +41,10 @@
41
41
  * throttled event. If this is the first callback to be added, the throttled
42
42
  * event will also be started.
43
43
  */ add: (callback)=>{
44
- if (!callbacks.length) {
44
+ if (callbacks.length === 0) {
45
45
  eventTarget.addEventListener(eventType, handler, options);
46
46
  }
47
- if (callbacks.indexOf(callback) === -1) {
47
+ if (!callbacks.includes(callback)) {
48
48
  callbacks.push(callback);
49
49
  }
50
50
  },
@@ -54,9 +54,9 @@
54
54
  * throttled event will also be stopped.
55
55
  */ remove: (callback)=>{
56
56
  const i = callbacks.indexOf(callback);
57
- if (i >= 0) {
57
+ if (i !== -1) {
58
58
  callbacks.splice(i, 1);
59
- if (!callbacks.length) {
59
+ if (callbacks.length === 0) {
60
60
  eventTarget.removeEventListener(eventType, handler, options);
61
61
  }
62
62
  }
@@ -87,7 +87,7 @@
87
87
  * @returns The delegated event handler that allows you to add or remove
88
88
  * `EventListener`s to that event.
89
89
  * @internal
90
- */ export function delegateEvent(eventType, eventTarget = window, throttle = eventType === "resize" || eventType === "scroll", options) {
90
+ */ export function delegateEvent(eventType, eventTarget = globalThis.window, throttle = eventType === "resize" || eventType === "scroll", options) {
91
91
  let index = delegatedEvents.findIndex((event)=>event.type === eventType && event.target === eventTarget && event.options === options && event.throttle === throttle);
92
92
  if (index === -1) {
93
93
  delegatedEvents.push({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/delegateEvent.ts"],"sourcesContent":["/** @internal */\nexport type DelegatedEventTarget = Window | Document | HTMLElement;\n\n/**\n * This is a \"shared\" event handler for the provided `eventType`. The event\n * listener will only be created once, but every single callback will be called\n * when the throttled event is triggered. This means that you will need to make\n * sure to remove the provided callback when it is no longer in use.\n *\n * @internal\n */\nexport interface DelegatedEventHandler {\n /**\n * Adds the provided callback to the throttled event listener.\n */\n add: (callback: EventListener) => void;\n\n /**\n * Attempts to remove the provided callback from the throttled event listener.\n */\n remove: (callback: EventListener) => void;\n}\n\n/** @internal */\nexport interface DelegableEvent {\n type: string;\n target: DelegatedEventTarget;\n throttle: boolean;\n handler: DelegatedEventHandler;\n options?: boolean | AddEventListenerOptions;\n}\n\nconst delegatedEvents: DelegableEvent[] = [];\n\n/**\n * Creates the delegated event handler that will run all the callbacks once an\n * event happens. The callbacks' invocation can also be throttled for event\n * types that trigger rapidly for additional performance.\n *\n * The `<K extends keyof WindowEventMap` is a nice thing I found while looking\n * through the `lib.d.ts` implementation of `addEventListener` that will allow\n * you to get the \"correct\" event type when using the `add` and `remove`\n * functions once you have created this event handler. Otherwise there'd be ts\n * errors trying to do `MouseEvent` or `KeyboardEvent` in your listeners.\n */\nfunction createEventHandler(\n throttle: boolean,\n callbacks: readonly EventListener[]\n): (event: WindowEventMap[keyof WindowEventMap]) => void {\n let running = false;\n const runCallbacks = (event: WindowEventMap[keyof WindowEventMap]) => () => {\n for (let i = 0; i < callbacks.length; i += 1) {\n callbacks[i](event);\n }\n\n running = false;\n };\n\n return function eventHandler(event) {\n if (!throttle) {\n runCallbacks(event)();\n return;\n }\n\n if (running) {\n return;\n }\n\n running = true;\n window.requestAnimationFrame(runCallbacks(event));\n };\n}\n\n/**\n * Creates a throttled event handler for the provided event type and event\n * target.\n */\nfunction createDelegatedEventHandler(\n eventType: string,\n eventTarget: DelegatedEventTarget = window,\n throttle = false,\n options?: boolean | AddEventListenerOptions\n): DelegatedEventHandler {\n const callbacks: EventListener[] = [];\n const handler = createEventHandler(throttle, callbacks);\n\n return {\n /**\n * Attempts to add the provided callback to the list of callbacks for the\n * throttled event. If this is the first callback to be added, the throttled\n * event will also be started.\n */\n add: (callback: EventListener) => {\n if (!callbacks.length) {\n eventTarget.addEventListener(eventType, handler, options);\n }\n\n if (callbacks.indexOf(callback) === -1) {\n callbacks.push(callback);\n }\n },\n\n /**\n * Attempts to remove the provided callback from the list of callbacks for\n * the throttled event. If this is the last callback that was removed, the\n * throttled event will also be stopped.\n */\n remove: (callback: EventListener) => {\n const i = callbacks.indexOf(callback);\n if (i >= 0) {\n callbacks.splice(i, 1);\n\n if (!callbacks.length) {\n eventTarget.removeEventListener(eventType, handler, options);\n }\n }\n },\n };\n}\n\n/**\n * Creates a delegated event listener using custom events. Most of this code\n * comes from the MDN about resize listeners.\n *\n * This will return an object for adding or removing event handlers for the\n * provided `eventType` since only one base throttled event listener will be\n * created. Each callback that is added will be called with the event each time\n * the event is triggered. This does mean that you will manually need to remove\n * your callback like normal or else it can be called when no longer in use.\n * This also means that it doesn't \"hurt\" to call this function without\n * immediately calling the `add` function since the event won't start until\n * there is at least 1 callback.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Events/resize#Examples\n * @param eventType - One of the event types that should be used to create a\n * delegated event for. This should be things like resize, click, scroll, etc.\n * @param eventTarget - The target that should have the delegated event handler\n * attached to. This is normally the window, but can be any element as needed.\n * @param throttle - Boolean if the event should be throttled or not. Normally\n * only event types like resize or scroll should be throttled for performance\n * boosts, but anything can be.\n * @returns The delegated event handler that allows you to add or remove\n * `EventListener`s to that event.\n * @internal\n */\nexport function delegateEvent(\n eventType: string,\n eventTarget: DelegatedEventTarget = window,\n throttle: boolean = eventType === \"resize\" || eventType === \"scroll\",\n options?: boolean | AddEventListenerOptions\n): DelegatedEventHandler {\n let index = delegatedEvents.findIndex(\n (event) =>\n event.type === eventType &&\n event.target === eventTarget &&\n event.options === options &&\n event.throttle === throttle\n );\n\n if (index === -1) {\n delegatedEvents.push({\n type: eventType,\n target: eventTarget,\n options,\n throttle,\n handler: createDelegatedEventHandler(\n eventType,\n eventTarget,\n throttle,\n options\n ),\n });\n\n index = delegatedEvents.length - 1;\n }\n\n return delegatedEvents[index].handler;\n}\n"],"names":["delegatedEvents","createEventHandler","throttle","callbacks","running","runCallbacks","event","i","length","eventHandler","window","requestAnimationFrame","createDelegatedEventHandler","eventType","eventTarget","options","handler","add","callback","addEventListener","indexOf","push","remove","splice","removeEventListener","delegateEvent","index","findIndex","type","target"],"mappings":"AAAA,cAAc,GAgCd,MAAMA,kBAAoC,EAAE;AAE5C;;;;;;;;;;CAUC,GACD,SAASC,mBACPC,QAAiB,EACjBC,SAAmC;IAEnC,IAAIC,UAAU;IACd,MAAMC,eAAe,CAACC,QAAgD;YACpE,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,UAAUK,MAAM,EAAED,KAAK,EAAG;gBAC5CJ,SAAS,CAACI,EAAE,CAACD;YACf;YAEAF,UAAU;QACZ;IAEA,OAAO,SAASK,aAAaH,KAAK;QAChC,IAAI,CAACJ,UAAU;YACbG,aAAaC;YACb;QACF;QAEA,IAAIF,SAAS;YACX;QACF;QAEAA,UAAU;QACVM,OAAOC,qBAAqB,CAACN,aAAaC;IAC5C;AACF;AAEA;;;CAGC,GACD,SAASM,4BACPC,SAAiB,EACjBC,cAAoCJ,MAAM,EAC1CR,WAAW,KAAK,EAChBa,OAA2C;IAE3C,MAAMZ,YAA6B,EAAE;IACrC,MAAMa,UAAUf,mBAAmBC,UAAUC;IAE7C,OAAO;QACL;;;;KAIC,GACDc,KAAK,CAACC;YACJ,IAAI,CAACf,UAAUK,MAAM,EAAE;gBACrBM,YAAYK,gBAAgB,CAACN,WAAWG,SAASD;YACnD;YAEA,IAAIZ,UAAUiB,OAAO,CAACF,cAAc,CAAC,GAAG;gBACtCf,UAAUkB,IAAI,CAACH;YACjB;QACF;QAEA;;;;KAIC,GACDI,QAAQ,CAACJ;YACP,MAAMX,IAAIJ,UAAUiB,OAAO,CAACF;YAC5B,IAAIX,KAAK,GAAG;gBACVJ,UAAUoB,MAAM,CAAChB,GAAG;gBAEpB,IAAI,CAACJ,UAAUK,MAAM,EAAE;oBACrBM,YAAYU,mBAAmB,CAACX,WAAWG,SAASD;gBACtD;YACF;QACF;IACF;AACF;AAEA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASU,cACdZ,SAAiB,EACjBC,cAAoCJ,MAAM,EAC1CR,WAAoBW,cAAc,YAAYA,cAAc,QAAQ,EACpEE,OAA2C;IAE3C,IAAIW,QAAQ1B,gBAAgB2B,SAAS,CACnC,CAACrB,QACCA,MAAMsB,IAAI,KAAKf,aACfP,MAAMuB,MAAM,KAAKf,eACjBR,MAAMS,OAAO,KAAKA,WAClBT,MAAMJ,QAAQ,KAAKA;IAGvB,IAAIwB,UAAU,CAAC,GAAG;QAChB1B,gBAAgBqB,IAAI,CAAC;YACnBO,MAAMf;YACNgB,QAAQf;YACRC;YACAb;YACAc,SAASJ,4BACPC,WACAC,aACAZ,UACAa;QAEJ;QAEAW,QAAQ1B,gBAAgBQ,MAAM,GAAG;IACnC;IAEA,OAAOR,eAAe,CAAC0B,MAAM,CAACV,OAAO;AACvC"}
1
+ {"version":3,"sources":["../src/delegateEvent.ts"],"sourcesContent":["/** @internal */\nexport type DelegatedEventTarget = Window | Document | HTMLElement;\n\n/**\n * This is a \"shared\" event handler for the provided `eventType`. The event\n * listener will only be created once, but every single callback will be called\n * when the throttled event is triggered. This means that you will need to make\n * sure to remove the provided callback when it is no longer in use.\n *\n * @internal\n */\nexport interface DelegatedEventHandler {\n /**\n * Adds the provided callback to the throttled event listener.\n */\n add: (callback: EventListener) => void;\n\n /**\n * Attempts to remove the provided callback from the throttled event listener.\n */\n remove: (callback: EventListener) => void;\n}\n\n/** @internal */\nexport interface DelegableEvent {\n type: string;\n target: DelegatedEventTarget;\n throttle: boolean;\n handler: DelegatedEventHandler;\n options?: boolean | AddEventListenerOptions;\n}\n\nconst delegatedEvents: DelegableEvent[] = [];\n\n/**\n * Creates the delegated event handler that will run all the callbacks once an\n * event happens. The callbacks' invocation can also be throttled for event\n * types that trigger rapidly for additional performance.\n *\n * The `<K extends keyof WindowEventMap` is a nice thing I found while looking\n * through the `lib.d.ts` implementation of `addEventListener` that will allow\n * you to get the \"correct\" event type when using the `add` and `remove`\n * functions once you have created this event handler. Otherwise there'd be ts\n * errors trying to do `MouseEvent` or `KeyboardEvent` in your listeners.\n */\nfunction createEventHandler(\n throttle: boolean,\n callbacks: readonly EventListener[]\n): (event: WindowEventMap[keyof WindowEventMap]) => void {\n let running = false;\n const runCallbacks = (event: WindowEventMap[keyof WindowEventMap]) => () => {\n for (const callback of callbacks) {\n callback(event);\n }\n\n running = false;\n };\n\n return function eventHandler(event) {\n if (!throttle) {\n runCallbacks(event)();\n return;\n }\n\n if (running) {\n return;\n }\n\n running = true;\n globalThis.requestAnimationFrame(runCallbacks(event));\n };\n}\n\n/**\n * Creates a throttled event handler for the provided event type and event\n * target.\n */\nfunction createDelegatedEventHandler(\n eventType: string,\n eventTarget: DelegatedEventTarget = globalThis.window,\n throttle = false,\n options?: boolean | AddEventListenerOptions\n): DelegatedEventHandler {\n const callbacks: EventListener[] = [];\n const handler = createEventHandler(throttle, callbacks);\n\n return {\n /**\n * Attempts to add the provided callback to the list of callbacks for the\n * throttled event. If this is the first callback to be added, the throttled\n * event will also be started.\n */\n add: (callback: EventListener) => {\n if (callbacks.length === 0) {\n eventTarget.addEventListener(eventType, handler, options);\n }\n\n if (!callbacks.includes(callback)) {\n callbacks.push(callback);\n }\n },\n\n /**\n * Attempts to remove the provided callback from the list of callbacks for\n * the throttled event. If this is the last callback that was removed, the\n * throttled event will also be stopped.\n */\n remove: (callback: EventListener) => {\n const i = callbacks.indexOf(callback);\n if (i !== -1) {\n callbacks.splice(i, 1);\n\n if (callbacks.length === 0) {\n eventTarget.removeEventListener(eventType, handler, options);\n }\n }\n },\n };\n}\n\n/**\n * Creates a delegated event listener using custom events. Most of this code\n * comes from the MDN about resize listeners.\n *\n * This will return an object for adding or removing event handlers for the\n * provided `eventType` since only one base throttled event listener will be\n * created. Each callback that is added will be called with the event each time\n * the event is triggered. This does mean that you will manually need to remove\n * your callback like normal or else it can be called when no longer in use.\n * This also means that it doesn't \"hurt\" to call this function without\n * immediately calling the `add` function since the event won't start until\n * there is at least 1 callback.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Events/resize#Examples\n * @param eventType - One of the event types that should be used to create a\n * delegated event for. This should be things like resize, click, scroll, etc.\n * @param eventTarget - The target that should have the delegated event handler\n * attached to. This is normally the window, but can be any element as needed.\n * @param throttle - Boolean if the event should be throttled or not. Normally\n * only event types like resize or scroll should be throttled for performance\n * boosts, but anything can be.\n * @returns The delegated event handler that allows you to add or remove\n * `EventListener`s to that event.\n * @internal\n */\nexport function delegateEvent(\n eventType: string,\n eventTarget: DelegatedEventTarget = globalThis.window,\n throttle: boolean = eventType === \"resize\" || eventType === \"scroll\",\n options?: boolean | AddEventListenerOptions\n): DelegatedEventHandler {\n let index = delegatedEvents.findIndex(\n (event) =>\n event.type === eventType &&\n event.target === eventTarget &&\n event.options === options &&\n event.throttle === throttle\n );\n\n if (index === -1) {\n delegatedEvents.push({\n type: eventType,\n target: eventTarget,\n options,\n throttle,\n handler: createDelegatedEventHandler(\n eventType,\n eventTarget,\n throttle,\n options\n ),\n });\n\n index = delegatedEvents.length - 1;\n }\n\n return delegatedEvents[index].handler;\n}\n"],"names":["delegatedEvents","createEventHandler","throttle","callbacks","running","runCallbacks","event","callback","eventHandler","globalThis","requestAnimationFrame","createDelegatedEventHandler","eventType","eventTarget","window","options","handler","add","length","addEventListener","includes","push","remove","i","indexOf","splice","removeEventListener","delegateEvent","index","findIndex","type","target"],"mappings":"AAAA,cAAc,GAgCd,MAAMA,kBAAoC,EAAE;AAE5C;;;;;;;;;;CAUC,GACD,SAASC,mBACPC,QAAiB,EACjBC,SAAmC;IAEnC,IAAIC,UAAU;IACd,MAAMC,eAAe,CAACC,QAAgD;YACpE,KAAK,MAAMC,YAAYJ,UAAW;gBAChCI,SAASD;YACX;YAEAF,UAAU;QACZ;IAEA,OAAO,SAASI,aAAaF,KAAK;QAChC,IAAI,CAACJ,UAAU;YACbG,aAAaC;YACb;QACF;QAEA,IAAIF,SAAS;YACX;QACF;QAEAA,UAAU;QACVK,WAAWC,qBAAqB,CAACL,aAAaC;IAChD;AACF;AAEA;;;CAGC,GACD,SAASK,4BACPC,SAAiB,EACjBC,cAAoCJ,WAAWK,MAAM,EACrDZ,WAAW,KAAK,EAChBa,OAA2C;IAE3C,MAAMZ,YAA6B,EAAE;IACrC,MAAMa,UAAUf,mBAAmBC,UAAUC;IAE7C,OAAO;QACL;;;;KAIC,GACDc,KAAK,CAACV;YACJ,IAAIJ,UAAUe,MAAM,KAAK,GAAG;gBAC1BL,YAAYM,gBAAgB,CAACP,WAAWI,SAASD;YACnD;YAEA,IAAI,CAACZ,UAAUiB,QAAQ,CAACb,WAAW;gBACjCJ,UAAUkB,IAAI,CAACd;YACjB;QACF;QAEA;;;;KAIC,GACDe,QAAQ,CAACf;YACP,MAAMgB,IAAIpB,UAAUqB,OAAO,CAACjB;YAC5B,IAAIgB,MAAM,CAAC,GAAG;gBACZpB,UAAUsB,MAAM,CAACF,GAAG;gBAEpB,IAAIpB,UAAUe,MAAM,KAAK,GAAG;oBAC1BL,YAAYa,mBAAmB,CAACd,WAAWI,SAASD;gBACtD;YACF;QACF;IACF;AACF;AAEA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASY,cACdf,SAAiB,EACjBC,cAAoCJ,WAAWK,MAAM,EACrDZ,WAAoBU,cAAc,YAAYA,cAAc,QAAQ,EACpEG,OAA2C;IAE3C,IAAIa,QAAQ5B,gBAAgB6B,SAAS,CACnC,CAACvB,QACCA,MAAMwB,IAAI,KAAKlB,aACfN,MAAMyB,MAAM,KAAKlB,eACjBP,MAAMS,OAAO,KAAKA,WAClBT,MAAMJ,QAAQ,KAAKA;IAGvB,IAAI0B,UAAU,CAAC,GAAG;QAChB5B,gBAAgBqB,IAAI,CAAC;YACnBS,MAAMlB;YACNmB,QAAQlB;YACRE;YACAb;YACAc,SAASL,4BACPC,WACAC,aACAX,UACAa;QAEJ;QAEAa,QAAQ5B,gBAAgBkB,MAAM,GAAG;IACnC;IAEA,OAAOlB,eAAe,CAAC4B,MAAM,CAACZ,OAAO;AACvC"}
@@ -87,18 +87,18 @@ $z-index: utils.$temporary-element-z-index !default;
87
87
 
88
88
  /// The default background color for a dialog.
89
89
  /// @type Color
90
+ // prettier-ignore
90
91
  $background-color: if(
91
- theme.$disable-dark-elevation,
92
- theme.theme-get-var(surface-color),
93
- null
92
+ sass(theme.$disable-dark-elevation): theme.theme-get-var(surface-color);
93
+ else: null
94
94
  ) !default;
95
95
 
96
96
  /// The default text color for a dialog.
97
97
  /// @type Color
98
+ // prettier-ignore
98
99
  $color: if(
99
- theme.$disable-dark-elevation,
100
- theme.theme-get-var(text-primary-color),
101
- null
100
+ sass(theme.$disable-dark-elevation): theme.theme-get-var(text-primary-color);
101
+ else: null,
102
102
  ) !default;
103
103
 
104
104
  /// The `min-width` to apply to all `Dialog`s.
@@ -125,8 +125,12 @@ $variables: (
125
125
  /// @param {String} position [null] - This should be one of `left`, `right`,
126
126
  /// `top`, `bottom`
127
127
  @mixin border-style($position: null) {
128
- $property: if(not $position, border, "border-#{$position}");
129
- $var-name: if(not $position, size, border-size);
128
+ $property: border;
129
+ $var-name: size;
130
+ @if $position {
131
+ $property: "border-#{$position}";
132
+ $var-name: border-size;
133
+ }
130
134
 
131
135
  #{$property}: get-var($var-name) solid get-var(color);
132
136
  }
@@ -138,11 +138,11 @@ const noop = ()=>{
138
138
  const passive = isTouch ? {
139
139
  passive: false
140
140
  } : undefined;
141
- window.addEventListener(updateKey, updatePosition, passive);
142
- window.addEventListener(stopKey, stopDragging);
141
+ globalThis.addEventListener(updateKey, updatePosition, passive);
142
+ globalThis.addEventListener(stopKey, stopDragging);
143
143
  return ()=>{
144
- window.removeEventListener(updateKey, updatePosition);
145
- window.removeEventListener(stopKey, stopDragging);
144
+ globalThis.removeEventListener(updateKey, updatePosition);
145
+ globalThis.removeEventListener(stopKey, stopDragging);
146
146
  };
147
147
  }, [
148
148
  dragging,