@react-md/core 6.2.1 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/dist/_base.scss +1 -1
  2. package/dist/app-bar/styles.d.ts +0 -2
  3. package/dist/app-bar/styles.js.map +1 -1
  4. package/dist/autocomplete/types.d.ts +12 -0
  5. package/dist/autocomplete/types.js.map +1 -1
  6. package/dist/avatar/Avatar.d.ts +0 -10
  7. package/dist/avatar/Avatar.js.map +1 -1
  8. package/dist/avatar/styles.d.ts +10 -0
  9. package/dist/avatar/styles.js.map +1 -1
  10. package/dist/badge/Badge.d.ts +11 -0
  11. package/dist/badge/Badge.js.map +1 -1
  12. package/dist/badge/styles.d.ts +0 -8
  13. package/dist/badge/styles.js.map +1 -1
  14. package/dist/box/_box.scss +8 -8
  15. package/dist/box/styles.d.ts +9 -0
  16. package/dist/box/styles.js.map +1 -1
  17. package/dist/button/_button.scss +4 -0
  18. package/dist/button/styles.d.ts +5 -1
  19. package/dist/button/styles.js.map +1 -1
  20. package/dist/card/Card.d.ts +0 -7
  21. package/dist/card/Card.js.map +1 -1
  22. package/dist/card/styles.d.ts +6 -0
  23. package/dist/card/styles.js +8 -8
  24. package/dist/card/styles.js.map +1 -1
  25. package/dist/chip/Chip.d.ts +6 -13
  26. package/dist/chip/Chip.js.map +1 -1
  27. package/dist/chip/styles.d.ts +26 -1
  28. package/dist/chip/styles.js.map +1 -1
  29. package/dist/datetime/NativeDateField.d.ts +24 -0
  30. package/dist/datetime/NativeDateField.js +63 -0
  31. package/dist/datetime/NativeDateField.js.map +1 -0
  32. package/dist/datetime/NativeTimeField.d.ts +26 -0
  33. package/dist/datetime/NativeTimeField.js +63 -0
  34. package/dist/datetime/NativeTimeField.js.map +1 -0
  35. package/dist/datetime/useDateField.d.ts +120 -0
  36. package/dist/datetime/useDateField.js +35 -0
  37. package/dist/datetime/useDateField.js.map +1 -0
  38. package/dist/datetime/useTimeField.d.ts +124 -0
  39. package/dist/datetime/useTimeField.js +65 -0
  40. package/dist/datetime/useTimeField.js.map +1 -0
  41. package/dist/datetime/utils.d.ts +34 -0
  42. package/dist/datetime/utils.js +27 -0
  43. package/dist/datetime/utils.js.map +1 -0
  44. package/dist/dialog/styles.d.ts +5 -2
  45. package/dist/dialog/styles.js.map +1 -1
  46. package/dist/divider/styles.d.ts +1 -1
  47. package/dist/divider/styles.js.map +1 -1
  48. package/dist/draggable/utils.d.ts +3 -6
  49. package/dist/draggable/utils.js.map +1 -1
  50. package/dist/error-boundary/ErrorBoundary.js.map +1 -1
  51. package/dist/expansion-panel/ExpansionList.js +1 -1
  52. package/dist/expansion-panel/ExpansionList.js.map +1 -1
  53. package/dist/expansion-panel/useExpansionList.d.ts +2 -7
  54. package/dist/expansion-panel/useExpansionList.js.map +1 -1
  55. package/dist/files/validation.js.map +1 -1
  56. package/dist/form/FormMessage.js +3 -1
  57. package/dist/form/FormMessage.js.map +1 -1
  58. package/dist/form/FormMessageContainer.d.ts +2 -1
  59. package/dist/form/FormMessageContainer.js +3 -2
  60. package/dist/form/FormMessageContainer.js.map +1 -1
  61. package/dist/form/FormMessageCounter.d.ts +3 -2
  62. package/dist/form/FormMessageCounter.js +5 -2
  63. package/dist/form/FormMessageCounter.js.map +1 -1
  64. package/dist/form/InputToggle.js.map +1 -1
  65. package/dist/form/Label.d.ts +0 -10
  66. package/dist/form/Label.js.map +1 -1
  67. package/dist/form/Listbox.d.ts +3 -10
  68. package/dist/form/Listbox.js +8 -27
  69. package/dist/form/Listbox.js.map +1 -1
  70. package/dist/form/ListboxProvider.d.ts +17 -0
  71. package/dist/form/ListboxProvider.js +33 -1
  72. package/dist/form/ListboxProvider.js.map +1 -1
  73. package/dist/form/NativeSelect.js +1 -0
  74. package/dist/form/NativeSelect.js.map +1 -1
  75. package/dist/form/Slider.d.ts +4 -0
  76. package/dist/form/Slider.js.map +1 -1
  77. package/dist/form/Switch.js.map +1 -1
  78. package/dist/form/TextArea.js +1 -0
  79. package/dist/form/TextArea.js.map +1 -1
  80. package/dist/form/TextField.js +1 -0
  81. package/dist/form/TextField.js.map +1 -1
  82. package/dist/form/TextFieldContainer.d.ts +0 -13
  83. package/dist/form/TextFieldContainer.js.map +1 -1
  84. package/dist/form/_form-message.scss +13 -0
  85. package/dist/form/_select.scss +5 -1
  86. package/dist/form/_text-area.scss +2 -1
  87. package/dist/form/_text-field.scss +13 -3
  88. package/dist/form/formMessageContainerStyles.d.ts +7 -0
  89. package/dist/form/formMessageContainerStyles.js +4 -2
  90. package/dist/form/formMessageContainerStyles.js.map +1 -1
  91. package/dist/form/sliderUtils.d.ts +3 -7
  92. package/dist/form/sliderUtils.js.map +1 -1
  93. package/dist/form/types.d.ts +33 -0
  94. package/dist/form/types.js.map +1 -1
  95. package/dist/form/useCombobox.d.ts +6 -2
  96. package/dist/form/useCombobox.js +8 -9
  97. package/dist/form/useCombobox.js.map +1 -1
  98. package/dist/form/useFormReset.d.ts +4 -1
  99. package/dist/form/useFormReset.js +9 -4
  100. package/dist/form/useFormReset.js.map +1 -1
  101. package/dist/form/useNumberField.d.ts +5 -5
  102. package/dist/form/useNumberField.js +10 -2
  103. package/dist/form/useNumberField.js.map +1 -1
  104. package/dist/form/useSelectCombobox.js +2 -2
  105. package/dist/form/useSelectCombobox.js.map +1 -1
  106. package/dist/form/useTextField.d.ts +76 -59
  107. package/dist/form/useTextField.js +7 -1
  108. package/dist/form/useTextField.js.map +1 -1
  109. package/dist/interaction/types.d.ts +5 -1
  110. package/dist/interaction/types.js.map +1 -1
  111. package/dist/interaction/utils.d.ts +14 -0
  112. package/dist/interaction/utils.js +23 -12
  113. package/dist/interaction/utils.js.map +1 -1
  114. package/dist/link/Link.d.ts +0 -7
  115. package/dist/link/Link.js.map +1 -1
  116. package/dist/link/styles.d.ts +7 -0
  117. package/dist/link/styles.js.map +1 -1
  118. package/dist/list/List.d.ts +5 -20
  119. package/dist/list/List.js.map +1 -1
  120. package/dist/list/ListItem.d.ts +4 -38
  121. package/dist/list/ListItem.js.map +1 -1
  122. package/dist/list/listItemStyles.d.ts +24 -2
  123. package/dist/list/listItemStyles.js.map +1 -1
  124. package/dist/list/listStyles.d.ts +17 -2
  125. package/dist/list/listStyles.js.map +1 -1
  126. package/dist/menu/Menu.js.map +1 -1
  127. package/dist/menu/MenuBar.js +1 -1
  128. package/dist/menu/MenuBar.js.map +1 -1
  129. package/dist/menu/MenuItemTextField.d.ts +1 -2
  130. package/dist/menu/MenuItemTextField.js.map +1 -1
  131. package/dist/menu/MenuWidget.js +3 -2
  132. package/dist/menu/MenuWidget.js.map +1 -1
  133. package/dist/movement/constants.d.ts +10 -0
  134. package/dist/movement/constants.js +20 -4
  135. package/dist/movement/constants.js.map +1 -1
  136. package/dist/movement/types.d.ts +59 -10
  137. package/dist/movement/types.js.map +1 -1
  138. package/dist/movement/useKeyboardMovementProvider.d.ts +5 -1
  139. package/dist/movement/useKeyboardMovementProvider.js +171 -73
  140. package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
  141. package/dist/navigation/NavItem.d.ts +4 -1
  142. package/dist/navigation/NavItem.js.map +1 -1
  143. package/dist/navigation/navItemStyles.d.ts +7 -0
  144. package/dist/navigation/navItemStyles.js.map +1 -1
  145. package/dist/overlay/Overlay.d.ts +4 -23
  146. package/dist/overlay/Overlay.js.map +1 -1
  147. package/dist/overlay/styles.d.ts +26 -8
  148. package/dist/overlay/styles.js.map +1 -1
  149. package/dist/progress/LinearProgress.d.ts +4 -9
  150. package/dist/progress/LinearProgress.js.map +1 -1
  151. package/dist/progress/circularProgressStyles.d.ts +6 -0
  152. package/dist/progress/circularProgressStyles.js.map +1 -1
  153. package/dist/progress/linearProgressStyles.d.ts +20 -5
  154. package/dist/progress/linearProgressStyles.js.map +1 -1
  155. package/dist/progress/types.d.ts +0 -9
  156. package/dist/progress/types.js.map +1 -1
  157. package/dist/segmented-button/SegmentedButton.d.ts +7 -12
  158. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  159. package/dist/segmented-button/segmentedButtonStyles.d.ts +26 -3
  160. package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
  161. package/dist/sheet/Sheet.d.ts +0 -12
  162. package/dist/sheet/Sheet.js.map +1 -1
  163. package/dist/sheet/styles.d.ts +12 -0
  164. package/dist/sheet/styles.js.map +1 -1
  165. package/dist/snackbar/Toast.d.ts +2 -13
  166. package/dist/snackbar/Toast.js.map +1 -1
  167. package/dist/snackbar/ToastManager.js.map +1 -1
  168. package/dist/snackbar/toastStyles.d.ts +17 -2
  169. package/dist/snackbar/toastStyles.js.map +1 -1
  170. package/dist/tabs/Tab.d.ts +2 -41
  171. package/dist/tabs/Tab.js.map +1 -1
  172. package/dist/tabs/tabStyles.d.ts +45 -4
  173. package/dist/tabs/tabStyles.js.map +1 -1
  174. package/dist/tabs/useTabList.js +1 -1
  175. package/dist/tabs/useTabList.js.map +1 -1
  176. package/dist/test-utils/drag.d.ts +6 -9
  177. package/dist/test-utils/mocks/IntersectionObserver.js.map +1 -1
  178. package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
  179. package/dist/test-utils/utils/createFileList.js.map +1 -1
  180. package/dist/theme/_theme.scss +0 -1
  181. package/dist/theme/getDerivedTheme.d.ts +0 -24
  182. package/dist/theme/getDerivedTheme.js.map +1 -1
  183. package/dist/theme/types.d.ts +25 -0
  184. package/dist/theme/types.js.map +1 -1
  185. package/dist/tooltip/Tooltip.d.ts +4 -32
  186. package/dist/tooltip/Tooltip.js.map +1 -1
  187. package/dist/tooltip/styles.d.ts +38 -1
  188. package/dist/tooltip/styles.js +1 -1
  189. package/dist/tooltip/styles.js.map +1 -1
  190. package/dist/transition/SkeletonPlaceholder.d.ts +0 -7
  191. package/dist/transition/SkeletonPlaceholder.js.map +1 -1
  192. package/dist/transition/Slide.js.map +1 -1
  193. package/dist/transition/skeletonPlaceholderUtils.d.ts +7 -0
  194. package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
  195. package/dist/transition/useCarousel.d.ts +2 -2
  196. package/dist/transition/useCarousel.js.map +1 -1
  197. package/dist/transition/useMaxWidthTransition.d.ts +14 -2
  198. package/dist/transition/useMaxWidthTransition.js.map +1 -1
  199. package/dist/transition/useSlideTransition.d.ts +5 -0
  200. package/dist/transition/useSlideTransition.js.map +1 -1
  201. package/dist/tree/Tree.d.ts +5 -9
  202. package/dist/tree/Tree.js +1 -1
  203. package/dist/tree/Tree.js.map +1 -1
  204. package/dist/tree/styles.d.ts +9 -1
  205. package/dist/tree/styles.js.map +1 -1
  206. package/dist/tree/useTreeMovement.d.ts +2 -1
  207. package/dist/tree/useTreeMovement.js +2 -1
  208. package/dist/tree/useTreeMovement.js.map +1 -1
  209. package/dist/types.d.ts +14 -0
  210. package/dist/types.js.map +1 -1
  211. package/dist/typography/Mark.d.ts +4 -1
  212. package/dist/typography/Mark.js.map +1 -1
  213. package/dist/typography/TextContainer.d.ts +0 -6
  214. package/dist/typography/TextContainer.js.map +1 -1
  215. package/dist/typography/markStyles.d.ts +5 -0
  216. package/dist/typography/markStyles.js.map +1 -1
  217. package/dist/typography/textContainerStyles.d.ts +6 -0
  218. package/dist/typography/textContainerStyles.js.map +1 -1
  219. package/dist/typography/typographyStyles.d.ts +9 -0
  220. package/dist/typography/typographyStyles.js.map +1 -1
  221. package/dist/useResizeObserver.js.map +1 -1
  222. package/dist/utils/getMiddleOfRange.d.ts +2 -3
  223. package/dist/utils/getMiddleOfRange.js.map +1 -1
  224. package/dist/utils/getPercentage.d.ts +2 -9
  225. package/dist/utils/getPercentage.js +1 -1
  226. package/dist/utils/getPercentage.js.map +1 -1
  227. package/dist/utils/getRangeSteps.d.ts +2 -3
  228. package/dist/utils/getRangeSteps.js +0 -3
  229. package/dist/utils/getRangeSteps.js.map +1 -1
  230. package/dist/utils/nearest.d.ts +2 -3
  231. package/dist/utils/nearest.js +0 -3
  232. package/dist/utils/nearest.js.map +1 -1
  233. package/dist/utils/trigonometry.d.ts +31 -0
  234. package/dist/utils/trigonometry.js +25 -0
  235. package/dist/utils/trigonometry.js.map +1 -0
  236. package/dist/window-splitter/WindowSplitter.d.ts +5 -19
  237. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  238. package/dist/window-splitter/styles.d.ts +27 -3
  239. package/dist/window-splitter/styles.js.map +1 -1
  240. package/dist/window-splitter/useWindowSplitter.d.ts +1 -1
  241. package/dist/window-splitter/useWindowSplitter.js.map +1 -1
  242. package/package.json +8 -8
  243. package/src/app-bar/styles.ts +0 -2
  244. package/src/autocomplete/types.ts +17 -0
  245. package/src/avatar/Avatar.tsx +0 -11
  246. package/src/avatar/styles.ts +11 -0
  247. package/src/badge/Badge.tsx +12 -0
  248. package/src/badge/styles.ts +0 -9
  249. package/src/box/styles.ts +9 -0
  250. package/src/button/styles.ts +5 -1
  251. package/src/card/Card.tsx +0 -8
  252. package/src/card/styles.ts +15 -8
  253. package/src/chip/Chip.tsx +9 -15
  254. package/src/chip/styles.ts +29 -1
  255. package/src/datetime/NativeDateField.tsx +92 -0
  256. package/src/datetime/NativeTimeField.tsx +94 -0
  257. package/src/datetime/useDateField.ts +193 -0
  258. package/src/datetime/useTimeField.ts +233 -0
  259. package/src/datetime/utils.ts +48 -0
  260. package/src/dialog/styles.ts +5 -2
  261. package/src/divider/styles.ts +1 -1
  262. package/src/draggable/utils.ts +3 -6
  263. package/src/expansion-panel/ExpansionList.tsx +2 -1
  264. package/src/expansion-panel/useExpansionList.ts +6 -12
  265. package/src/form/FormMessage.tsx +4 -0
  266. package/src/form/FormMessageContainer.tsx +8 -4
  267. package/src/form/FormMessageCounter.tsx +17 -6
  268. package/src/form/InputToggle.tsx +2 -0
  269. package/src/form/Label.tsx +0 -11
  270. package/src/form/Listbox.tsx +18 -46
  271. package/src/form/ListboxProvider.ts +61 -1
  272. package/src/form/NativeSelect.tsx +1 -0
  273. package/src/form/Slider.tsx +6 -0
  274. package/src/form/Switch.tsx +2 -0
  275. package/src/form/TextArea.tsx +3 -0
  276. package/src/form/TextField.tsx +1 -0
  277. package/src/form/TextFieldContainer.tsx +0 -14
  278. package/src/form/formMessageContainerStyles.ts +10 -2
  279. package/src/form/sliderUtils.ts +3 -7
  280. package/src/form/types.ts +44 -0
  281. package/src/form/useCombobox.ts +15 -10
  282. package/src/form/useFormReset.ts +12 -5
  283. package/src/form/useNumberField.ts +17 -14
  284. package/src/form/useSelectCombobox.ts +2 -2
  285. package/src/form/useTextField.ts +102 -69
  286. package/src/interaction/types.ts +5 -1
  287. package/src/interaction/utils.ts +18 -20
  288. package/src/link/Link.tsx +0 -8
  289. package/src/link/styles.ts +8 -0
  290. package/src/list/List.tsx +7 -24
  291. package/src/list/ListItem.tsx +7 -43
  292. package/src/list/listItemStyles.ts +26 -2
  293. package/src/list/listStyles.ts +18 -2
  294. package/src/menu/Menu.tsx +2 -0
  295. package/src/menu/MenuBar.tsx +1 -1
  296. package/src/menu/MenuItemTextField.tsx +1 -3
  297. package/src/menu/MenuWidget.tsx +4 -2
  298. package/src/movement/constants.ts +26 -4
  299. package/src/movement/types.ts +84 -19
  300. package/src/movement/useKeyboardMovementProvider.ts +209 -95
  301. package/src/navigation/NavItem.tsx +6 -2
  302. package/src/navigation/navItemStyles.ts +8 -0
  303. package/src/overlay/Overlay.tsx +4 -26
  304. package/src/overlay/styles.ts +29 -10
  305. package/src/progress/LinearProgress.tsx +8 -10
  306. package/src/progress/circularProgressStyles.ts +7 -0
  307. package/src/progress/linearProgressStyles.ts +22 -5
  308. package/src/progress/types.ts +0 -10
  309. package/src/segmented-button/SegmentedButton.tsx +14 -15
  310. package/src/segmented-button/segmentedButtonStyles.ts +28 -3
  311. package/src/sheet/Sheet.tsx +0 -13
  312. package/src/sheet/styles.ts +13 -0
  313. package/src/snackbar/Toast.tsx +2 -15
  314. package/src/snackbar/toastStyles.ts +20 -2
  315. package/src/tabs/Tab.tsx +4 -49
  316. package/src/tabs/tabStyles.ts +52 -4
  317. package/src/tabs/useTabList.ts +1 -1
  318. package/src/test-utils/drag.ts +8 -12
  319. package/src/theme/getDerivedTheme.ts +0 -26
  320. package/src/theme/types.ts +26 -0
  321. package/src/tooltip/Tooltip.tsx +4 -36
  322. package/src/tooltip/styles.ts +43 -2
  323. package/src/transition/SkeletonPlaceholder.tsx +0 -8
  324. package/src/transition/Slide.tsx +2 -0
  325. package/src/transition/skeletonPlaceholderUtils.ts +8 -0
  326. package/src/transition/useCarousel.ts +2 -2
  327. package/src/transition/useMaxWidthTransition.ts +17 -2
  328. package/src/transition/useSlideTransition.ts +8 -0
  329. package/src/tree/Tree.tsx +6 -11
  330. package/src/tree/styles.ts +10 -1
  331. package/src/tree/useTreeMovement.ts +4 -0
  332. package/src/types.ts +16 -0
  333. package/src/typography/Mark.tsx +6 -2
  334. package/src/typography/TextContainer.tsx +0 -7
  335. package/src/typography/markStyles.ts +6 -0
  336. package/src/typography/textContainerStyles.ts +7 -0
  337. package/src/typography/typographyStyles.ts +10 -0
  338. package/src/utils/getMiddleOfRange.ts +2 -3
  339. package/src/utils/getPercentage.ts +3 -11
  340. package/src/utils/getRangeSteps.ts +3 -3
  341. package/src/utils/nearest.ts +3 -3
  342. package/src/utils/trigonometry.ts +46 -0
  343. package/src/window-splitter/WindowSplitter.tsx +9 -22
  344. package/src/window-splitter/styles.ts +31 -3
  345. package/src/window-splitter/useWindowSplitter.ts +3 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transition/useCarousel.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useState } from \"react\";\n\nimport type { UseStateSetter } from \"../types.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { loop } from \"../utils/loop.js\";\nimport type { SlideDirection } from \"./SlideContainer.js\";\n\n/** @since 6.0.0 */\nexport interface CarouselSlideState {\n direction: SlideDirection;\n activeIndex: number;\n}\n\n/** @since 6.0.0 */\nexport interface CarouselState extends CarouselSlideState {\n paused: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface CarouselImplementation extends CarouselState {\n /**\n * Increments the carousel slide active index by 1 ensuring it does not\n * advance past the {@link CarouselOptions.totalSlides} index.\n */\n increment: () => void;\n\n /**\n * Decrements the carousel slide active index by 1 and prevents decrementing\n * past 0.\n */\n decrement: () => void;\n\n /**\n * This can be used to manually control the {@link paused} state.\n */\n setPaused: UseStateSetter<boolean>;\n\n /**\n * Toggles the {@link paused} state.\n */\n togglePaused: () => void;\n\n /**\n * A convenience wrapper for the {@link setCarouselSlideState} that will\n * ensure the {@link CarouselSlideState.direction} is correct based on the\n * current active index and next active index.\n */\n setActiveIndex: UseStateSetter<number>;\n\n /**\n * This can be used if the provided carousel actions do not solve your use\n * case.\n */\n setCarouselSlideState: UseStateSetter<CarouselSlideState>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface CarouselOptions {\n /**\n * The amount of time in milliseconds each slide should be visible before\n * advancing to the next slide.\n *\n * @defaultValue `8000`\n */\n duration?: number;\n\n /**\n * The total number of slides within your carousel so that you can safely loop\n * through all slides.\n */\n totalSlides: number;\n}\n\n/**\n * @example Accessible Carousel Example\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Slide } from \"@react-md/core/transition/Slide\";\n * import { SlideContainer } from \"@react-md/core/transition/SlideContainer\";\n * import { useCarousel } from \"@react-md/core/transition/useCarousel\";\n * import ChevronLeftIcon from \"@react-md/material-icons/ChevronLeftIcon\";\n * import ChevronRightIcon from \"@react-md/material-icons/ChevronRightIcon\";\n * import PauseIcon from \"@react-md/material-icons/PauseIcon\";\n * import PlayArrowIcon from \"@react-md/material-icons/PlayArrowIcon\";\n * import type { ReactElement } from \"react\";\n *\n * const slides = [\n * { title: \"Slide 1\" },\n * { title: \"Slide 2\" },\n * { title: \"Slide 3\" },\n * ] as const;\n *\n * function Example(): ReactElement {\n * const {\n * paused,\n * direction,\n * activeIndex,\n * togglePaused,\n * setActiveIndex,\n * increment,\n * decrement,\n * } = useCarousel({\n * duration: 5000,\n * totalSlides: slides.length,\n * });\n *\n * const slideId = useId();\n *\n * return (\n * <div\n * aria-roledescription=\"carousel\"\n * aria-label=\"Carousel\"\n * id={useId()}\n * role=\"region\"\n * >\n * <SlideContainer aria-live=\"off\" direction={direction}>\n * {slides.map(({ title }, index) => (\n * <Slide\n * key={title}\n * aria-label={`Slide ${index + 1} of ${slides.length - 1}`}\n * aria-roledescription=\"slide\"\n * id={`${slideId}-${index}`}\n * role=\"group\"\n * active={activeIndex === index}\n * >\n * {title}\n * </Slide>\n * ))}\n * </SlideContainer>\n * <Button\n * aria-label=\"Pause\"\n * aria-pressed={paused}\n * button=\"icon\"\n * onClick={togglePaused}\n * >\n * {paused ? <PlayArrowIcon /> : <PauseIcon />}\n * </Button>\n * {slides.map(({ title }, index) => (\n * <Button\n * key={title}\n * aria-label={`Slide ${index + 1}`}\n * aria-selected={activeIndex === index}\n * aria-controls={`${slideId}-${index}`}\n * role=\"tab\"\n * onClick={() => setActiveIndex(index))}\n * />\n * ))}\n * <Button\n * aria-label=\"Previous Slide\"\n * onClick={decrement}\n * disabled={activeIndex === 0}\n * buttonType=\"icon\"\n * >\n * <ChevronLeftIcon />\n * </Button>\n * <Button\n * aria-label=\"Next Slide\"\n * onClick={increment}\n * disabled={activeIndex === slides.length - 1}\n * buttonType=\"icon\"\n * >\n * <ChevronRightIcon />\n * </Button>\n * </div>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/carousel | Carousel Demos}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/carousel/}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/example-index/carousel/carousel-2-tablist.html}\n * @since 6.0.0\n */\nexport function useCarousel(options: CarouselOptions): CarouselImplementation {\n const { duration = 8000, totalSlides } = options;\n const total = totalSlides - 1;\n\n const [state, setCarouselSlideState] = useState<CarouselSlideState>({\n direction: \"forward\",\n activeIndex: 0,\n });\n const {\n toggled: paused,\n toggle: togglePaused,\n setToggled: setPaused,\n } = useToggle(false);\n const setActiveIndex = useCallback<UseStateSetter<number>>(\n (activeIndexOrGetter) => {\n setCarouselSlideState((prevState) => {\n const prevActiveIndex = prevState.activeIndex;\n const nextActiveIndex =\n typeof activeIndexOrGetter === \"function\"\n ? activeIndexOrGetter(prevActiveIndex)\n : activeIndexOrGetter;\n\n return {\n direction: prevActiveIndex < nextActiveIndex ? \"forward\" : \"backward\",\n activeIndex: nextActiveIndex,\n };\n });\n },\n []\n );\n const increment = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"forward\",\n activeIndex: Math.min(total, prevState.activeIndex + 1),\n }));\n }, [total]);\n const decrement = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"backward\",\n activeIndex: Math.max(0, prevState.activeIndex - 1),\n }));\n }, []);\n\n const { activeIndex } = state;\n useEffect(() => {\n if (paused) {\n return;\n }\n\n const timeout = window.setTimeout(() => {\n const nextActiveIndex = loop({\n min: 0,\n max: total,\n value: activeIndex,\n increment: true,\n });\n setCarouselSlideState({\n direction: activeIndex < nextActiveIndex ? \"forward\" : \"backward\",\n activeIndex: nextActiveIndex,\n });\n }, duration);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [paused, duration, activeIndex, total]);\n\n return {\n ...state,\n increment,\n decrement,\n paused,\n setPaused,\n togglePaused,\n setActiveIndex,\n setCarouselSlideState,\n };\n}\n"],"names":["useCallback","useEffect","useState","useToggle","loop","useCarousel","options","duration","totalSlides","total","state","setCarouselSlideState","direction","activeIndex","toggled","paused","toggle","togglePaused","setToggled","setPaused","setActiveIndex","activeIndexOrGetter","prevState","prevActiveIndex","nextActiveIndex","increment","Math","min","decrement","max","timeout","window","setTimeout","value","clearTimeout"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAGzD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,IAAI,QAAQ,mBAAmB;AAuExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmGC,GACD,OAAO,SAASC,YAAYC,OAAwB;IAClD,MAAM,EAAEC,WAAW,IAAI,EAAEC,WAAW,EAAE,GAAGF;IACzC,MAAMG,QAAQD,cAAc;IAE5B,MAAM,CAACE,OAAOC,sBAAsB,GAAGT,SAA6B;QAClEU,WAAW;QACXC,aAAa;IACf;IACA,MAAM,EACJC,SAASC,MAAM,EACfC,QAAQC,YAAY,EACpBC,YAAYC,SAAS,EACtB,GAAGhB,UAAU;IACd,MAAMiB,iBAAiBpB,YACrB,CAACqB;QACCV,sBAAsB,CAACW;YACrB,MAAMC,kBAAkBD,UAAUT,WAAW;YAC7C,MAAMW,kBACJ,OAAOH,wBAAwB,aAC3BA,oBAAoBE,mBACpBF;YAEN,OAAO;gBACLT,WAAWW,kBAAkBC,kBAAkB,YAAY;gBAC3DX,aAAaW;YACf;QACF;IACF,GACA,EAAE;IAEJ,MAAMC,YAAYzB,YAAY;QAC5BW,sBAAsB,CAACW,YAAe,CAAA;gBACpCV,WAAW;gBACXC,aAAaa,KAAKC,GAAG,CAAClB,OAAOa,UAAUT,WAAW,GAAG;YACvD,CAAA;IACF,GAAG;QAACJ;KAAM;IACV,MAAMmB,YAAY5B,YAAY;QAC5BW,sBAAsB,CAACW,YAAe,CAAA;gBACpCV,WAAW;gBACXC,aAAaa,KAAKG,GAAG,CAAC,GAAGP,UAAUT,WAAW,GAAG;YACnD,CAAA;IACF,GAAG,EAAE;IAEL,MAAM,EAAEA,WAAW,EAAE,GAAGH;IACxBT,UAAU;QACR,IAAIc,QAAQ;YACV;QACF;QAEA,MAAMe,UAAUC,OAAOC,UAAU,CAAC;YAChC,MAAMR,kBAAkBpB,KAAK;gBAC3BuB,KAAK;gBACLE,KAAKpB;gBACLwB,OAAOpB;gBACPY,WAAW;YACb;YACAd,sBAAsB;gBACpBC,WAAWC,cAAcW,kBAAkB,YAAY;gBACvDX,aAAaW;YACf;QACF,GAAGjB;QAEH,OAAO;YACLwB,OAAOG,YAAY,CAACJ;QACtB;IACF,GAAG;QAACf;QAAQR;QAAUM;QAAaJ;KAAM;IAEzC,OAAO;QACL,GAAGC,KAAK;QACRe;QACAG;QACAb;QACAI;QACAF;QACAG;QACAT;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/transition/useCarousel.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useState } from \"react\";\n\nimport { type UseStateSetter } from \"../types.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { loop } from \"../utils/loop.js\";\nimport { type SlideDirection } from \"./SlideContainer.js\";\n\n/** @since 6.0.0 */\nexport interface CarouselSlideState {\n direction: SlideDirection;\n activeIndex: number;\n}\n\n/** @since 6.0.0 */\nexport interface CarouselState extends CarouselSlideState {\n paused: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface CarouselImplementation extends CarouselState {\n /**\n * Increments the carousel slide active index by 1 ensuring it does not\n * advance past the {@link CarouselOptions.totalSlides} index.\n */\n increment: () => void;\n\n /**\n * Decrements the carousel slide active index by 1 and prevents decrementing\n * past 0.\n */\n decrement: () => void;\n\n /**\n * This can be used to manually control the {@link paused} state.\n */\n setPaused: UseStateSetter<boolean>;\n\n /**\n * Toggles the {@link paused} state.\n */\n togglePaused: () => void;\n\n /**\n * A convenience wrapper for the {@link setCarouselSlideState} that will\n * ensure the {@link CarouselSlideState.direction} is correct based on the\n * current active index and next active index.\n */\n setActiveIndex: UseStateSetter<number>;\n\n /**\n * This can be used if the provided carousel actions do not solve your use\n * case.\n */\n setCarouselSlideState: UseStateSetter<CarouselSlideState>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface CarouselOptions {\n /**\n * The amount of time in milliseconds each slide should be visible before\n * advancing to the next slide.\n *\n * @defaultValue `8000`\n */\n duration?: number;\n\n /**\n * The total number of slides within your carousel so that you can safely loop\n * through all slides.\n */\n totalSlides: number;\n}\n\n/**\n * @example Accessible Carousel Example\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Slide } from \"@react-md/core/transition/Slide\";\n * import { SlideContainer } from \"@react-md/core/transition/SlideContainer\";\n * import { useCarousel } from \"@react-md/core/transition/useCarousel\";\n * import ChevronLeftIcon from \"@react-md/material-icons/ChevronLeftIcon\";\n * import ChevronRightIcon from \"@react-md/material-icons/ChevronRightIcon\";\n * import PauseIcon from \"@react-md/material-icons/PauseIcon\";\n * import PlayArrowIcon from \"@react-md/material-icons/PlayArrowIcon\";\n * import type { ReactElement } from \"react\";\n *\n * const slides = [\n * { title: \"Slide 1\" },\n * { title: \"Slide 2\" },\n * { title: \"Slide 3\" },\n * ] as const;\n *\n * function Example(): ReactElement {\n * const {\n * paused,\n * direction,\n * activeIndex,\n * togglePaused,\n * setActiveIndex,\n * increment,\n * decrement,\n * } = useCarousel({\n * duration: 5000,\n * totalSlides: slides.length,\n * });\n *\n * const slideId = useId();\n *\n * return (\n * <div\n * aria-roledescription=\"carousel\"\n * aria-label=\"Carousel\"\n * id={useId()}\n * role=\"region\"\n * >\n * <SlideContainer aria-live=\"off\" direction={direction}>\n * {slides.map(({ title }, index) => (\n * <Slide\n * key={title}\n * aria-label={`Slide ${index + 1} of ${slides.length - 1}`}\n * aria-roledescription=\"slide\"\n * id={`${slideId}-${index}`}\n * role=\"group\"\n * active={activeIndex === index}\n * >\n * {title}\n * </Slide>\n * ))}\n * </SlideContainer>\n * <Button\n * aria-label=\"Pause\"\n * aria-pressed={paused}\n * button=\"icon\"\n * onClick={togglePaused}\n * >\n * {paused ? <PlayArrowIcon /> : <PauseIcon />}\n * </Button>\n * {slides.map(({ title }, index) => (\n * <Button\n * key={title}\n * aria-label={`Slide ${index + 1}`}\n * aria-selected={activeIndex === index}\n * aria-controls={`${slideId}-${index}`}\n * role=\"tab\"\n * onClick={() => setActiveIndex(index))}\n * />\n * ))}\n * <Button\n * aria-label=\"Previous Slide\"\n * onClick={decrement}\n * disabled={activeIndex === 0}\n * buttonType=\"icon\"\n * >\n * <ChevronLeftIcon />\n * </Button>\n * <Button\n * aria-label=\"Next Slide\"\n * onClick={increment}\n * disabled={activeIndex === slides.length - 1}\n * buttonType=\"icon\"\n * >\n * <ChevronRightIcon />\n * </Button>\n * </div>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/carousel | Carousel Demos}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/carousel/}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/example-index/carousel/carousel-2-tablist.html}\n * @since 6.0.0\n */\nexport function useCarousel(options: CarouselOptions): CarouselImplementation {\n const { duration = 8000, totalSlides } = options;\n const total = totalSlides - 1;\n\n const [state, setCarouselSlideState] = useState<CarouselSlideState>({\n direction: \"forward\",\n activeIndex: 0,\n });\n const {\n toggled: paused,\n toggle: togglePaused,\n setToggled: setPaused,\n } = useToggle(false);\n const setActiveIndex = useCallback<UseStateSetter<number>>(\n (activeIndexOrGetter) => {\n setCarouselSlideState((prevState) => {\n const prevActiveIndex = prevState.activeIndex;\n const nextActiveIndex =\n typeof activeIndexOrGetter === \"function\"\n ? activeIndexOrGetter(prevActiveIndex)\n : activeIndexOrGetter;\n\n return {\n direction: prevActiveIndex < nextActiveIndex ? \"forward\" : \"backward\",\n activeIndex: nextActiveIndex,\n };\n });\n },\n []\n );\n const increment = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"forward\",\n activeIndex: Math.min(total, prevState.activeIndex + 1),\n }));\n }, [total]);\n const decrement = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"backward\",\n activeIndex: Math.max(0, prevState.activeIndex - 1),\n }));\n }, []);\n\n const { activeIndex } = state;\n useEffect(() => {\n if (paused) {\n return;\n }\n\n const timeout = window.setTimeout(() => {\n const nextActiveIndex = loop({\n min: 0,\n max: total,\n value: activeIndex,\n increment: true,\n });\n setCarouselSlideState({\n direction: activeIndex < nextActiveIndex ? \"forward\" : \"backward\",\n activeIndex: nextActiveIndex,\n });\n }, duration);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [paused, duration, activeIndex, total]);\n\n return {\n ...state,\n increment,\n decrement,\n paused,\n setPaused,\n togglePaused,\n setActiveIndex,\n setCarouselSlideState,\n };\n}\n"],"names":["useCallback","useEffect","useState","useToggle","loop","useCarousel","options","duration","totalSlides","total","state","setCarouselSlideState","direction","activeIndex","toggled","paused","toggle","togglePaused","setToggled","setPaused","setActiveIndex","activeIndexOrGetter","prevState","prevActiveIndex","nextActiveIndex","increment","Math","min","decrement","max","timeout","window","setTimeout","value","clearTimeout"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAGzD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,IAAI,QAAQ,mBAAmB;AAuExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmGC,GACD,OAAO,SAASC,YAAYC,OAAwB;IAClD,MAAM,EAAEC,WAAW,IAAI,EAAEC,WAAW,EAAE,GAAGF;IACzC,MAAMG,QAAQD,cAAc;IAE5B,MAAM,CAACE,OAAOC,sBAAsB,GAAGT,SAA6B;QAClEU,WAAW;QACXC,aAAa;IACf;IACA,MAAM,EACJC,SAASC,MAAM,EACfC,QAAQC,YAAY,EACpBC,YAAYC,SAAS,EACtB,GAAGhB,UAAU;IACd,MAAMiB,iBAAiBpB,YACrB,CAACqB;QACCV,sBAAsB,CAACW;YACrB,MAAMC,kBAAkBD,UAAUT,WAAW;YAC7C,MAAMW,kBACJ,OAAOH,wBAAwB,aAC3BA,oBAAoBE,mBACpBF;YAEN,OAAO;gBACLT,WAAWW,kBAAkBC,kBAAkB,YAAY;gBAC3DX,aAAaW;YACf;QACF;IACF,GACA,EAAE;IAEJ,MAAMC,YAAYzB,YAAY;QAC5BW,sBAAsB,CAACW,YAAe,CAAA;gBACpCV,WAAW;gBACXC,aAAaa,KAAKC,GAAG,CAAClB,OAAOa,UAAUT,WAAW,GAAG;YACvD,CAAA;IACF,GAAG;QAACJ;KAAM;IACV,MAAMmB,YAAY5B,YAAY;QAC5BW,sBAAsB,CAACW,YAAe,CAAA;gBACpCV,WAAW;gBACXC,aAAaa,KAAKG,GAAG,CAAC,GAAGP,UAAUT,WAAW,GAAG;YACnD,CAAA;IACF,GAAG,EAAE;IAEL,MAAM,EAAEA,WAAW,EAAE,GAAGH;IACxBT,UAAU;QACR,IAAIc,QAAQ;YACV;QACF;QAEA,MAAMe,UAAUC,OAAOC,UAAU,CAAC;YAChC,MAAMR,kBAAkBpB,KAAK;gBAC3BuB,KAAK;gBACLE,KAAKpB;gBACLwB,OAAOpB;gBACPY,WAAW;YACb;YACAd,sBAAsB;gBACpBC,WAAWC,cAAcW,kBAAkB,YAAY;gBACvDX,aAAaW;YACf;QACF,GAAGjB;QAEH,OAAO;YACLwB,OAAOG,YAAY,CAACJ;QACtB;IACF,GAAG;QAACf;QAAQR;QAAUM;QAAaJ;KAAM;IAEzC,OAAO;QACL,GAAGC,KAAK;QACRe;QACAG;QACAb;QACAI;QACAF;QACAG;QACAT;IACF;AACF"}
@@ -1,11 +1,23 @@
1
1
  import type { ReactNode } from "react";
2
+ declare module "react" {
3
+ interface CSSProperites {
4
+ "--rmd-max-width"?: string | number;
5
+ "--rmd-max-width-gap"?: string | number;
6
+ }
7
+ }
8
+ /**
9
+ * @since 6.3.1
10
+ */
11
+ export interface BaseMaxWidthTransitionOptions {
12
+ className?: string;
13
+ }
2
14
  /**
3
15
  * @since 6.0.0
16
+ * @since 6.3.1 Extends BaseMaxWidthTransitionOptions
4
17
  */
5
- export interface MaxWidthTransitionOptions {
18
+ export interface MaxWidthTransitionOptions extends BaseMaxWidthTransitionOptions {
6
19
  element: ReactNode;
7
20
  transitionIn: boolean;
8
- className?: string;
9
21
  disabled?: boolean;
10
22
  disableTransition?: boolean;
11
23
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transition/useMaxWidthTransition.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport type { ReactNode } from \"react\";\nimport { Children, cloneElement, isValidElement } from \"react\";\n\nimport { maxWidthTransition } from \"./maxWidthTransition.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MaxWidthTransitionOptions {\n element: ReactNode;\n transitionIn: boolean;\n\n className?: string;\n disabled?: boolean;\n disableTransition?: boolean;\n}\n\n/**\n * The `useMaxWidthTransition` hook is used to animate the `max-width` using\n * the {@link maxWidthTransition} utility classes.\n *\n * NOTE: This hook clones the className into the child element using the\n * `cloneElement` API. The child **must** accept and pass the `className` forward\n * to work correctly.\n *\n * @see {@link maxWidthTransition}\n *\n * @since 6.0.0\n */\nexport function useMaxWidthTransition(\n options: MaxWidthTransitionOptions\n): ReactNode {\n const { element, disabled, disableTransition, transitionIn, className } =\n options;\n\n if (disabled || !isValidElement<{ className?: string }>(element)) {\n return element;\n }\n\n const child = Children.only(element);\n return cloneElement(element, {\n className: maxWidthTransition({\n className: cnb(child.props.className, className),\n disabled: disableTransition,\n transitionIn,\n }),\n });\n}\n"],"names":["cnb","Children","cloneElement","isValidElement","maxWidthTransition","useMaxWidthTransition","options","element","disabled","disableTransition","transitionIn","className","child","only","props"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,EAAEC,YAAY,EAAEC,cAAc,QAAQ,QAAQ;AAE/D,SAASC,kBAAkB,QAAQ,0BAA0B;AAc7D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,sBACdC,OAAkC;IAElC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,SAAS,EAAE,GACrEL;IAEF,IAAIE,YAAY,CAACL,eAAuCI,UAAU;QAChE,OAAOA;IACT;IAEA,MAAMK,QAAQX,SAASY,IAAI,CAACN;IAC5B,OAAOL,aAAaK,SAAS;QAC3BI,WAAWP,mBAAmB;YAC5BO,WAAWX,IAAIY,MAAME,KAAK,CAACH,SAAS,EAAEA;YACtCH,UAAUC;YACVC;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/transition/useMaxWidthTransition.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport type { ReactNode } from \"react\";\nimport { Children, cloneElement, isValidElement } from \"react\";\n\nimport { maxWidthTransition } from \"./maxWidthTransition.js\";\n\ndeclare module \"react\" {\n interface CSSProperites {\n \"--rmd-max-width\"?: string | number;\n \"--rmd-max-width-gap\"?: string | number;\n }\n}\n\n/**\n * @since 6.3.1\n */\nexport interface BaseMaxWidthTransitionOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Extends BaseMaxWidthTransitionOptions\n */\nexport interface MaxWidthTransitionOptions\n extends BaseMaxWidthTransitionOptions {\n element: ReactNode;\n transitionIn: boolean;\n\n disabled?: boolean;\n disableTransition?: boolean;\n}\n\n/**\n * The `useMaxWidthTransition` hook is used to animate the `max-width` using\n * the {@link maxWidthTransition} utility classes.\n *\n * NOTE: This hook clones the className into the child element using the\n * `cloneElement` API. The child **must** accept and pass the `className` forward\n * to work correctly.\n *\n * @see {@link maxWidthTransition}\n *\n * @since 6.0.0\n */\nexport function useMaxWidthTransition(\n options: MaxWidthTransitionOptions\n): ReactNode {\n const { element, disabled, disableTransition, transitionIn, className } =\n options;\n\n if (disabled || !isValidElement<{ className?: string }>(element)) {\n return element;\n }\n\n const child = Children.only(element);\n return cloneElement(element, {\n className: maxWidthTransition({\n className: cnb(child.props.className, className),\n disabled: disableTransition,\n transitionIn,\n }),\n });\n}\n"],"names":["cnb","Children","cloneElement","isValidElement","maxWidthTransition","useMaxWidthTransition","options","element","disabled","disableTransition","transitionIn","className","child","only","props"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,EAAEC,YAAY,EAAEC,cAAc,QAAQ,QAAQ;AAE/D,SAASC,kBAAkB,QAAQ,0BAA0B;AA6B7D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,sBACdC,OAAkC;IAElC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,SAAS,EAAE,GACrEL;IAEF,IAAIE,YAAY,CAACL,eAAuCI,UAAU;QAChE,OAAOA;IACT;IAEA,MAAMK,QAAQX,SAASY,IAAI,CAACN;IAC5B,OAAOL,aAAaK,SAAS;QAC3BI,WAAWP,mBAAmB;YAC5BO,WAAWX,IAAIY,MAAME,KAAK,CAACH,SAAS,EAAEA;YACtCH,UAAUC;YACVC;QACF;IACF;AACF"}
@@ -1,4 +1,9 @@
1
1
  import { type CSSTransitionHookReturnValue, type PreconfiguredCSSTransitionOptions } from "./types.js";
2
+ declare module "react" {
3
+ interface CSSProperties {
4
+ "--rmd-slide-duration"?: string | number;
5
+ }
6
+ }
2
7
  /** @since 6.0.0 */
3
8
  export declare const DEFAULT_SLIDE_TRANSITION_TIMEOUT: 150;
4
9
  /** @since 6.0.0 */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transition/useSlideTransition.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\n\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionHookReturnValue,\n type PreconfiguredCSSTransitionOptions,\n type TransitionTimeout,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/** @since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_TIMEOUT =\n 150 as const satisfies TransitionTimeout;\n\n/** @since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_CLASSNAMES = {\n enter: \"rmd-slide--enter\",\n enterActive: \"rmd-slide--enter-active rmd-slide--animate\",\n exit: \"rmd-slide--exit\",\n exitActive: \"rmd-slide--exit-active rmd-slide--animate\",\n} as const satisfies CSSTransitionClassNames;\n\n/** @since 6.0.0 */\nexport type SlideTransitionOptions<E extends HTMLElement> =\n PreconfiguredCSSTransitionOptions<E>;\n\n/**\n * @example Simple Example\n * ```tsx\n * import {\n * type SlideDirection,\n * slideContainer,\n * } from \"@react-md/core/transition/SlideContainer\";\n * import { useSlideTransition } from \"@react-md/core/transition/useSlideTransition\";\n * import { type ReactElement, type ReactNode, useState } from \"react\";\n *\n * interface SlideProps {\n * active: boolean;\n * children: ReactNode;\n * }\n *\n * function Slide({ active, children }: SlideProps): ReactElement | null {\n * const { rendered, elementProps } = useSlideTransition({\n * transitionIn: active,\n * });\n *\n * if (!rendered) {\n * return null;\n * }\n *\n * return <div {...elementProps}>{children}</div>;\n * }\n *\n * interface State {\n * direction: SlideDirection;\n * activeIndex: number;\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * direction: \"left\",\n * activeIndex: 0,\n * });\n * const { direction, activeIndex } = state;\n *\n * // when changing a slide, `direction` should be set to \"left\" if the\n * // previous `activeIndex` is less than the next index\n * //\n * // i.e.\n * // setState((prevState) => ({\n * // direction: prevState.activeIndex < index ? \"left\" : \"right\",\n * // activeIndex: index,\n * // }))\n *\n * return (\n * <div className={slideContainer({ direction })}>\n * <Slide active={activeIndex === 0}>Slide 1</Slide>\n * <Slide active={activeIndex === 1}>Slide 2</Slide>\n * <Slide active={activeIndex === 2}>Slide 3</Slide>\n * </div>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/slide | Slide Demos}\n * @see {@link SlideContainer} and {@link Slide} for convenient default\n * implementations.\n * @since 6.0.0\n */\nexport function useSlideTransition<E extends HTMLElement>(\n options: SlideTransitionOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n timeout = DEFAULT_SLIDE_TRANSITION_TIMEOUT,\n className,\n temporary = false,\n exitedHidden = true,\n ...transitionOptions\n } = options;\n\n return useCSSTransition({\n ...transitionOptions,\n timeout,\n className: cnb(\"rmd-slide\", className),\n classNames: DEFAULT_SLIDE_TRANSITION_CLASSNAMES,\n temporary,\n exitedHidden,\n });\n}\n"],"names":["cnb","useCSSTransition","DEFAULT_SLIDE_TRANSITION_TIMEOUT","DEFAULT_SLIDE_TRANSITION_CLASSNAMES","enter","enterActive","exit","exitActive","useSlideTransition","options","timeout","className","temporary","exitedHidden","transitionOptions","classNames"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAQhC,SAASC,gBAAgB,QAAQ,wBAAwB;AAEzD,iBAAiB,GACjB,OAAO,MAAMC,mCACX,IAAyC;AAE3C,iBAAiB,GACjB,OAAO,MAAMC,sCAAsC;IACjDC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,YAAY;AACd,EAA6C;AAM7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DC,GACD,OAAO,SAASC,mBACdC,OAAkC;IAElC,MAAM,EACJC,UAAUR,gCAAgC,EAC1CS,SAAS,EACTC,YAAY,KAAK,EACjBC,eAAe,IAAI,EACnB,GAAGC,mBACJ,GAAGL;IAEJ,OAAOR,iBAAiB;QACtB,GAAGa,iBAAiB;QACpBJ;QACAC,WAAWX,IAAI,aAAaW;QAC5BI,YAAYZ;QACZS;QACAC;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/transition/useSlideTransition.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\n\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionHookReturnValue,\n type PreconfiguredCSSTransitionOptions,\n type TransitionTimeout,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n// NOTE: Tis is in both `useSlideTransition` and `Slide` since there are no\n// reusable types between these two files.\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-slide-duration\"?: string | number;\n }\n}\n\n/** @since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_TIMEOUT =\n 150 as const satisfies TransitionTimeout;\n\n/** @since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_CLASSNAMES = {\n enter: \"rmd-slide--enter\",\n enterActive: \"rmd-slide--enter-active rmd-slide--animate\",\n exit: \"rmd-slide--exit\",\n exitActive: \"rmd-slide--exit-active rmd-slide--animate\",\n} as const satisfies CSSTransitionClassNames;\n\n/** @since 6.0.0 */\nexport type SlideTransitionOptions<E extends HTMLElement> =\n PreconfiguredCSSTransitionOptions<E>;\n\n/**\n * @example Simple Example\n * ```tsx\n * import {\n * type SlideDirection,\n * slideContainer,\n * } from \"@react-md/core/transition/SlideContainer\";\n * import { useSlideTransition } from \"@react-md/core/transition/useSlideTransition\";\n * import { type ReactElement, type ReactNode, useState } from \"react\";\n *\n * interface SlideProps {\n * active: boolean;\n * children: ReactNode;\n * }\n *\n * function Slide({ active, children }: SlideProps): ReactElement | null {\n * const { rendered, elementProps } = useSlideTransition({\n * transitionIn: active,\n * });\n *\n * if (!rendered) {\n * return null;\n * }\n *\n * return <div {...elementProps}>{children}</div>;\n * }\n *\n * interface State {\n * direction: SlideDirection;\n * activeIndex: number;\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * direction: \"left\",\n * activeIndex: 0,\n * });\n * const { direction, activeIndex } = state;\n *\n * // when changing a slide, `direction` should be set to \"left\" if the\n * // previous `activeIndex` is less than the next index\n * //\n * // i.e.\n * // setState((prevState) => ({\n * // direction: prevState.activeIndex < index ? \"left\" : \"right\",\n * // activeIndex: index,\n * // }))\n *\n * return (\n * <div className={slideContainer({ direction })}>\n * <Slide active={activeIndex === 0}>Slide 1</Slide>\n * <Slide active={activeIndex === 1}>Slide 2</Slide>\n * <Slide active={activeIndex === 2}>Slide 3</Slide>\n * </div>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/slide | Slide Demos}\n * @see {@link SlideContainer} and {@link Slide} for convenient default\n * implementations.\n * @since 6.0.0\n */\nexport function useSlideTransition<E extends HTMLElement>(\n options: SlideTransitionOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n timeout = DEFAULT_SLIDE_TRANSITION_TIMEOUT,\n className,\n temporary = false,\n exitedHidden = true,\n ...transitionOptions\n } = options;\n\n return useCSSTransition({\n ...transitionOptions,\n timeout,\n className: cnb(\"rmd-slide\", className),\n classNames: DEFAULT_SLIDE_TRANSITION_CLASSNAMES,\n temporary,\n exitedHidden,\n });\n}\n"],"names":["cnb","useCSSTransition","DEFAULT_SLIDE_TRANSITION_TIMEOUT","DEFAULT_SLIDE_TRANSITION_CLASSNAMES","enter","enterActive","exit","exitActive","useSlideTransition","options","timeout","className","temporary","exitedHidden","transitionOptions","classNames"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAQhC,SAASC,gBAAgB,QAAQ,wBAAwB;AAUzD,iBAAiB,GACjB,OAAO,MAAMC,mCACX,IAAyC;AAE3C,iBAAiB,GACjB,OAAO,MAAMC,sCAAsC;IACjDC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,YAAY;AACd,EAA6C;AAM7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DC,GACD,OAAO,SAASC,mBACdC,OAAkC;IAElC,MAAM,EACJC,UAAUR,gCAAgC,EAC1CS,SAAS,EACTC,YAAY,KAAK,EACjBC,eAAe,IAAI,EACnB,GAAGC,mBACJ,GAAGL;IAEJ,OAAOR,iBAAiB;QACtB,GAAGa,iBAAiB;QACpBJ;QACAC,WAAWX,IAAI,aAAaW;QAC5BI,YAAYZ;QACZS;QACAC;IACF;AACF"}
@@ -2,17 +2,10 @@ import { type ComponentType, type HTMLAttributes, type ReactElement, type ReactN
2
2
  import { type CustomLinkComponent } from "../link/Link.js";
3
3
  import { type LabelRequiredForA11y } from "../types.js";
4
4
  import { type TreeExpansionMode } from "./TreeProvider.js";
5
+ import { type TreeClassNameOptions } from "./styles.js";
5
6
  import { type TreeData, type TreeItemNode, type TreeItemRendererProps, type TreeItemSorter } from "./types.js";
6
7
  import { type TreeExpansion } from "./useTreeExpansion.js";
7
8
  import { type TreeSelection } from "./useTreeSelection.js";
8
- declare module "react" {
9
- interface CSSProperties {
10
- "--rmd-tree-depth"?: number;
11
- "--rmd-tree-item-padding"?: string | number;
12
- "--rmd-tree-item-padding-base"?: string | number;
13
- "--rmd-tree-item-padding-incrementor"?: string | number;
14
- }
15
- }
16
9
  /**
17
10
  * @since 6.0.0
18
11
  */
@@ -26,8 +19,11 @@ export type TreeHTMLAttributes = Omit<HTMLAttributes<HTMLUListElement>, "role" |
26
19
  * - `getItemLabel`
27
20
  * - `getItemValue`
28
21
  * - `getItemProps`
22
+ *
23
+ * @since 6.3.1 Extends TreeClassNameOptions for CSSProperties module
24
+ * augmentation.
29
25
  */
30
- export interface TreeProps<T extends TreeItemNode> extends TreeHTMLAttributes, TreeExpansion, TreeSelection {
26
+ export interface TreeProps<T extends TreeItemNode> extends TreeHTMLAttributes, TreeClassNameOptions, TreeExpansion, TreeSelection {
31
27
  /** @see {@link TreeData} */
32
28
  data: TreeData<T>;
33
29
  /**
package/dist/tree/Tree.js CHANGED
@@ -77,6 +77,7 @@ import { useTreeMovement } from "./useTreeMovement.js";
77
77
  rootId
78
78
  });
79
79
  const { metadataLookup, movementContext, movementProps } = useTreeMovement({
80
+ ref: treeRef,
80
81
  onClick,
81
82
  onFocus,
82
83
  onKeyDown,
@@ -110,7 +111,6 @@ import { useTreeMovement } from "./useTreeMovement.js";
110
111
  ...remaining,
111
112
  ...movementProps,
112
113
  id: treeId,
113
- ref: treeRef,
114
114
  role: "tree",
115
115
  tabIndex: 0,
116
116
  className: tree({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tree/Tree.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from \"react\";\n\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { List } from \"../list/List.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { RenderRecursively } from \"../utils/RenderRecursively.js\";\nimport { identity } from \"../utils/identity.js\";\nimport { DefaultTreeItemRenderer } from \"./DefaultTreeItemRenderer.js\";\nimport { type TreeExpansionMode, TreeProvider } from \"./TreeProvider.js\";\nimport { tree } from \"./styles.js\";\nimport {\n type TreeData,\n type TreeItemNode,\n type TreeItemRendererProps,\n type TreeItemSorter,\n} from \"./types.js\";\nimport { type TreeExpansion } from \"./useTreeExpansion.js\";\nimport { useTreeItems } from \"./useTreeItems.js\";\nimport { useTreeMovement } from \"./useTreeMovement.js\";\nimport { type TreeSelection } from \"./useTreeSelection.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tree-depth\"?: number;\n \"--rmd-tree-item-padding\"?: string | number;\n \"--rmd-tree-item-padding-base\"?: string | number;\n \"--rmd-tree-item-padding-incrementor\"?: string | number;\n }\n}\n\n/**\n * @since 6.0.0\n */\nexport type TreeHTMLAttributes = Omit<\n HTMLAttributes<HTMLUListElement>,\n \"role\" | \"tabIndex\" | \"children\"\n>;\n\n/**\n * @since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n */\nexport interface TreeProps<T extends TreeItemNode>\n extends TreeHTMLAttributes,\n TreeExpansion,\n TreeSelection {\n /** @see {@link TreeData} */\n data: TreeData<T>;\n\n /**\n * An optional ref to pass to the tree element.\n *\n * @since 6.0.0\n */\n treeRef?: Ref<HTMLUListElement>;\n\n /** @defaultValue `identity` */\n sort?: TreeItemSorter<T>;\n\n /**\n * Any nodes in the {@link data} that have a `parentId` set to this value will\n * appear at the root of the tree.\n *\n * @defaultValue `null`\n */\n rootId?: string | null;\n\n /**\n * @defaultValue `\"auto\"`\n * @see {@link TreeExpansionMode}\n */\n expansionMode?: TreeExpansionMode;\n\n /**\n * Set this to `true` to display the expander icon to the left instead of the\n * right. This will also update the styles slightly so you can still provide a\n * `leftAddon`.\n *\n * @defaultValue `false`\n */\n expanderLeft?: boolean;\n\n /**\n * @defaultValue `getIcon(\"expander\")`\n */\n expanderIcon?: ReactNode;\n\n /**\n * Set this to `true` to disable the collapse transition for all tree items.\n *\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n\n /**\n * Set this to `true` if the collapsed tree items should be removed from the\n * DOM instead of hidden using `display: none`. This _might_ improve\n * performance for large trees.\n *\n * @defaultValue `false`\n */\n temporaryChildItems?: boolean;\n\n /**\n * @example Custom Tree Item Renderer\n * ```tsx\n * import { useTreeContext } from \"@react-md/core/movement/TreeProvider\"\n * import { useKeyboardMovementContext } from \"@react-md/core/movement/useKeyboardMovementProvider\"\n * import { TreeItem } from \"@react-md/core/tree/TreeItem\";\n * import { type TreeItemRendererProps } from \"@react-md/core/tree/types\";\n * import FolderIcon from \"@react-md/material-icons/FolderIcon\";\n * import FolderOpenIcon from \"@react-md/material-icons/FolderOpenIcon\";\n * import { type ReactElement } from \"react\";\n *\n * export function CustomTreeItem(props: TreeItemRendererProps): ReactElement {\n * const { item, ...remaining } = props;\n * const id = useId();\n * const { itemId } = item;\n * const {\n * data,\n * expandedIds,\n * selectedIds,\n * toggleTreeItemExpansion,\n * toggleTreeItemSelection,\n * } = useTreeContext()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * const focused = id === activeDescendantId;\n * const expanded = expandedIds.has(itemId);\n * const selected = selectedIds.has(itemId);\n * const children = ...; // do whatever\n *\n * return (\n * <TreeItem\n * {...remaining}\n * id={id}\n * itemId={itemId}\n * leftAddon={expanded ? <FolderOpenIcon /> : <FolderIcon />}\n * >\n * {children}\n * </TreeItem>\n * );\n * }\n * ```\n *\n * @see {@link DefaultTreeItemRenderer}\n * @defaultValue `DefaultTreeItemRenderer`\n */\n renderer?: ComponentType<TreeItemRendererProps<T>>;\n\n /**\n * The link component to use for any tree item nodes that have a `to` or\n * `href`.\n *\n * @see {@link CustomLinkComponent}\n * @defaultValue `Link`\n */\n linkComponent?: CustomLinkComponent;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Tree\n * ```tsx\n * import { Tree } from \"@react-md/core/tree/Tree\";\n * import { type TreeData } from \"@react-md/core/tree/types\";\n * import { useTree } from \"@react-md/core/tree/useTree\";\n * import type { ReactElement } from \"react\";\n *\n * const data: TreeData = {\n * \"item-1\": {\n * itemId: \"item-1\",\n * parentId: null,\n * name: \"Root Level Item 1\",\n * },\n * \"item-2\": {\n * itemId: \"item-2\",\n * parentId: \"item-1\",\n * name: \"A child for the first item\",\n * },\n * \"item-3\": {\n * itemId: \"item-3\",\n * parentId: \"item-1\",\n * children: \"Another child for the first item\",\n * },\n * };\n *\n * function Example(): ReactElement {\n * const tree = useTree({\n * // can enable multiple selected items\n * // multiSelect: true,\n *\n * // can set default expanded and selected items\n * // defaultSelectedIds: [\"item-1\"],\n * // defaultExpandedIds: [\"item-1\"],\n * });\n *\n * return (\n * <Tree\n * {...tree}\n * aria-label=\"Tree\"\n * data={data}\n * />\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/tree | Tree Demos}\n * @see {@link TreeProps.renderer} for a custom tree item example.\n * @since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n */\nexport function Tree<T extends TreeItemNode>(\n props: LabelRequiredForA11y<TreeProps<T>>\n): ReactElement {\n const {\n id,\n data,\n sort = identity,\n rootId = null,\n treeRef,\n className,\n expandedIds,\n selectedIds,\n toggleTreeItemSelection,\n selectMultipleTreeItems,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n onClick,\n onFocus,\n onKeyDown,\n renderer: TreeItemRenderer = DefaultTreeItemRenderer,\n multiSelect = false,\n expansionMode = \"auto\",\n expanderIcon,\n expanderLeft = false,\n linkComponent = \"a\",\n disableTransition = false,\n temporaryChildItems = false,\n ...remaining\n } = props;\n const treeId = useEnsuredId(id, \"tree\");\n const { items, treeItemChildIds } = useTreeItems({\n data,\n sort,\n rootId,\n });\n\n const { metadataLookup, movementContext, movementProps } = useTreeMovement({\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n });\n\n return (\n <TreeProvider\n data={data}\n rootId={rootId}\n multiSelect={multiSelect}\n linkComponent={linkComponent}\n selectedIds={selectedIds}\n expandedIds={expandedIds}\n expanderIcon={expanderIcon}\n expanderLeft={expanderLeft}\n expansionMode={expansionMode}\n metadataLookup={metadataLookup}\n disableTransition={disableTransition}\n temporaryChildItems={temporaryChildItems}\n toggleTreeItemSelection={toggleTreeItemSelection}\n toggleTreeItemExpansion={toggleTreeItemExpansion}\n selectMultipleTreeItems={selectMultipleTreeItems}\n expandMultipleTreeItems={expandMultipleTreeItems}\n >\n <KeyboardMovementProvider value={movementContext}>\n <List\n {...remaining}\n {...movementProps}\n id={treeId}\n ref={treeRef}\n role=\"tree\"\n tabIndex={0}\n className={tree({ className })}\n >\n <RenderRecursively\n items={items}\n render={TreeItemRenderer}\n getItemKey={(options) => options.item.itemId}\n />\n </List>\n </KeyboardMovementProvider>\n </TreeProvider>\n );\n}\n"],"names":["List","KeyboardMovementProvider","useEnsuredId","RenderRecursively","identity","DefaultTreeItemRenderer","TreeProvider","tree","useTreeItems","useTreeMovement","Tree","props","id","data","sort","rootId","treeRef","className","expandedIds","selectedIds","toggleTreeItemSelection","selectMultipleTreeItems","toggleTreeItemExpansion","expandMultipleTreeItems","onClick","onFocus","onKeyDown","renderer","TreeItemRenderer","multiSelect","expansionMode","expanderIcon","expanderLeft","linkComponent","disableTransition","temporaryChildItems","remaining","treeId","items","treeItemChildIds","metadataLookup","movementContext","movementProps","value","ref","role","tabIndex","render","getItemKey","options","item","itemId"],"mappings":"AAAA;;AAWA,SAASA,IAAI,QAAQ,kBAAkB;AACvC,SAASC,wBAAwB,QAAQ,6CAA6C;AAEtF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,uBAAuB,QAAQ,+BAA+B;AACvE,SAAiCC,YAAY,QAAQ,oBAAoB;AACzE,SAASC,IAAI,QAAQ,cAAc;AAQnC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,eAAe,QAAQ,uBAAuB;AAoJvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DC,GACD,OAAO,SAASC,KACdC,KAAyC;IAEzC,MAAM,EACJC,EAAE,EACFC,IAAI,EACJC,OAAOV,QAAQ,EACfW,SAAS,IAAI,EACbC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB,EACvBC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,UAAUC,mBAAmBvB,uBAAuB,EACpDwB,cAAc,KAAK,EACnBC,gBAAgB,MAAM,EACtBC,YAAY,EACZC,eAAe,KAAK,EACpBC,gBAAgB,GAAG,EACnBC,oBAAoB,KAAK,EACzBC,sBAAsB,KAAK,EAC3B,GAAGC,WACJ,GAAGzB;IACJ,MAAM0B,SAASnC,aAAaU,IAAI;IAChC,MAAM,EAAE0B,KAAK,EAAEC,gBAAgB,EAAE,GAAG/B,aAAa;QAC/CK;QACAC;QACAC;IACF;IAEA,MAAM,EAAEyB,cAAc,EAAEC,eAAe,EAAEC,aAAa,EAAE,GAAGjC,gBAAgB;QACzEe;QACAC;QACAC;QACAb;QACAK;QACAC;QACAoB;QACAjB;QACAC;IACF;IAEA,qBACE,KAACjB;QACCO,MAAMA;QACNE,QAAQA;QACRc,aAAaA;QACbI,eAAeA;QACfd,aAAaA;QACbD,aAAaA;QACba,cAAcA;QACdC,cAAcA;QACdF,eAAeA;QACfU,gBAAgBA;QAChBN,mBAAmBA;QACnBC,qBAAqBA;QACrBf,yBAAyBA;QACzBE,yBAAyBA;QACzBD,yBAAyBA;QACzBE,yBAAyBA;kBAEzB,cAAA,KAACtB;YAAyB0C,OAAOF;sBAC/B,cAAA,KAACzC;gBACE,GAAGoC,SAAS;gBACZ,GAAGM,aAAa;gBACjB9B,IAAIyB;gBACJO,KAAK5B;gBACL6B,MAAK;gBACLC,UAAU;gBACV7B,WAAWV,KAAK;oBAAEU;gBAAU;0BAE5B,cAAA,KAACd;oBACCmC,OAAOA;oBACPS,QAAQnB;oBACRoB,YAAY,CAACC,UAAYA,QAAQC,IAAI,CAACC,MAAM;;;;;AAMxD"}
1
+ {"version":3,"sources":["../../src/tree/Tree.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from \"react\";\n\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { List } from \"../list/List.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { RenderRecursively } from \"../utils/RenderRecursively.js\";\nimport { identity } from \"../utils/identity.js\";\nimport { DefaultTreeItemRenderer } from \"./DefaultTreeItemRenderer.js\";\nimport { type TreeExpansionMode, TreeProvider } from \"./TreeProvider.js\";\nimport { type TreeClassNameOptions, tree } from \"./styles.js\";\nimport {\n type TreeData,\n type TreeItemNode,\n type TreeItemRendererProps,\n type TreeItemSorter,\n} from \"./types.js\";\nimport { type TreeExpansion } from \"./useTreeExpansion.js\";\nimport { useTreeItems } from \"./useTreeItems.js\";\nimport { useTreeMovement } from \"./useTreeMovement.js\";\nimport { type TreeSelection } from \"./useTreeSelection.js\";\n\n/**\n * @since 6.0.0\n */\nexport type TreeHTMLAttributes = Omit<\n HTMLAttributes<HTMLUListElement>,\n \"role\" | \"tabIndex\" | \"children\"\n>;\n\n/**\n * @since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n *\n * @since 6.3.1 Extends TreeClassNameOptions for CSSProperties module\n * augmentation.\n */\nexport interface TreeProps<T extends TreeItemNode>\n extends TreeHTMLAttributes,\n TreeClassNameOptions,\n TreeExpansion,\n TreeSelection {\n /** @see {@link TreeData} */\n data: TreeData<T>;\n\n /**\n * An optional ref to pass to the tree element.\n *\n * @since 6.0.0\n */\n treeRef?: Ref<HTMLUListElement>;\n\n /** @defaultValue `identity` */\n sort?: TreeItemSorter<T>;\n\n /**\n * Any nodes in the {@link data} that have a `parentId` set to this value will\n * appear at the root of the tree.\n *\n * @defaultValue `null`\n */\n rootId?: string | null;\n\n /**\n * @defaultValue `\"auto\"`\n * @see {@link TreeExpansionMode}\n */\n expansionMode?: TreeExpansionMode;\n\n /**\n * Set this to `true` to display the expander icon to the left instead of the\n * right. This will also update the styles slightly so you can still provide a\n * `leftAddon`.\n *\n * @defaultValue `false`\n */\n expanderLeft?: boolean;\n\n /**\n * @defaultValue `getIcon(\"expander\")`\n */\n expanderIcon?: ReactNode;\n\n /**\n * Set this to `true` to disable the collapse transition for all tree items.\n *\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n\n /**\n * Set this to `true` if the collapsed tree items should be removed from the\n * DOM instead of hidden using `display: none`. This _might_ improve\n * performance for large trees.\n *\n * @defaultValue `false`\n */\n temporaryChildItems?: boolean;\n\n /**\n * @example Custom Tree Item Renderer\n * ```tsx\n * import { useTreeContext } from \"@react-md/core/movement/TreeProvider\"\n * import { useKeyboardMovementContext } from \"@react-md/core/movement/useKeyboardMovementProvider\"\n * import { TreeItem } from \"@react-md/core/tree/TreeItem\";\n * import { type TreeItemRendererProps } from \"@react-md/core/tree/types\";\n * import FolderIcon from \"@react-md/material-icons/FolderIcon\";\n * import FolderOpenIcon from \"@react-md/material-icons/FolderOpenIcon\";\n * import { type ReactElement } from \"react\";\n *\n * export function CustomTreeItem(props: TreeItemRendererProps): ReactElement {\n * const { item, ...remaining } = props;\n * const id = useId();\n * const { itemId } = item;\n * const {\n * data,\n * expandedIds,\n * selectedIds,\n * toggleTreeItemExpansion,\n * toggleTreeItemSelection,\n * } = useTreeContext()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * const focused = id === activeDescendantId;\n * const expanded = expandedIds.has(itemId);\n * const selected = selectedIds.has(itemId);\n * const children = ...; // do whatever\n *\n * return (\n * <TreeItem\n * {...remaining}\n * id={id}\n * itemId={itemId}\n * leftAddon={expanded ? <FolderOpenIcon /> : <FolderIcon />}\n * >\n * {children}\n * </TreeItem>\n * );\n * }\n * ```\n *\n * @see {@link DefaultTreeItemRenderer}\n * @defaultValue `DefaultTreeItemRenderer`\n */\n renderer?: ComponentType<TreeItemRendererProps<T>>;\n\n /**\n * The link component to use for any tree item nodes that have a `to` or\n * `href`.\n *\n * @see {@link CustomLinkComponent}\n * @defaultValue `Link`\n */\n linkComponent?: CustomLinkComponent;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Tree\n * ```tsx\n * import { Tree } from \"@react-md/core/tree/Tree\";\n * import { type TreeData } from \"@react-md/core/tree/types\";\n * import { useTree } from \"@react-md/core/tree/useTree\";\n * import type { ReactElement } from \"react\";\n *\n * const data: TreeData = {\n * \"item-1\": {\n * itemId: \"item-1\",\n * parentId: null,\n * name: \"Root Level Item 1\",\n * },\n * \"item-2\": {\n * itemId: \"item-2\",\n * parentId: \"item-1\",\n * name: \"A child for the first item\",\n * },\n * \"item-3\": {\n * itemId: \"item-3\",\n * parentId: \"item-1\",\n * children: \"Another child for the first item\",\n * },\n * };\n *\n * function Example(): ReactElement {\n * const tree = useTree({\n * // can enable multiple selected items\n * // multiSelect: true,\n *\n * // can set default expanded and selected items\n * // defaultSelectedIds: [\"item-1\"],\n * // defaultExpandedIds: [\"item-1\"],\n * });\n *\n * return (\n * <Tree\n * {...tree}\n * aria-label=\"Tree\"\n * data={data}\n * />\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/tree | Tree Demos}\n * @see {@link TreeProps.renderer} for a custom tree item example.\n * @since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n */\nexport function Tree<T extends TreeItemNode>(\n props: LabelRequiredForA11y<TreeProps<T>>\n): ReactElement {\n const {\n id,\n data,\n sort = identity,\n rootId = null,\n treeRef,\n className,\n expandedIds,\n selectedIds,\n toggleTreeItemSelection,\n selectMultipleTreeItems,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n onClick,\n onFocus,\n onKeyDown,\n renderer: TreeItemRenderer = DefaultTreeItemRenderer,\n multiSelect = false,\n expansionMode = \"auto\",\n expanderIcon,\n expanderLeft = false,\n linkComponent = \"a\",\n disableTransition = false,\n temporaryChildItems = false,\n ...remaining\n } = props;\n const treeId = useEnsuredId(id, \"tree\");\n const { items, treeItemChildIds } = useTreeItems({\n data,\n sort,\n rootId,\n });\n\n const { metadataLookup, movementContext, movementProps } = useTreeMovement({\n ref: treeRef,\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n });\n\n return (\n <TreeProvider\n data={data}\n rootId={rootId}\n multiSelect={multiSelect}\n linkComponent={linkComponent}\n selectedIds={selectedIds}\n expandedIds={expandedIds}\n expanderIcon={expanderIcon}\n expanderLeft={expanderLeft}\n expansionMode={expansionMode}\n metadataLookup={metadataLookup}\n disableTransition={disableTransition}\n temporaryChildItems={temporaryChildItems}\n toggleTreeItemSelection={toggleTreeItemSelection}\n toggleTreeItemExpansion={toggleTreeItemExpansion}\n selectMultipleTreeItems={selectMultipleTreeItems}\n expandMultipleTreeItems={expandMultipleTreeItems}\n >\n <KeyboardMovementProvider value={movementContext}>\n <List\n {...remaining}\n {...movementProps}\n id={treeId}\n role=\"tree\"\n tabIndex={0}\n className={tree({ className })}\n >\n <RenderRecursively\n items={items}\n render={TreeItemRenderer}\n getItemKey={(options) => options.item.itemId}\n />\n </List>\n </KeyboardMovementProvider>\n </TreeProvider>\n );\n}\n"],"names":["List","KeyboardMovementProvider","useEnsuredId","RenderRecursively","identity","DefaultTreeItemRenderer","TreeProvider","tree","useTreeItems","useTreeMovement","Tree","props","id","data","sort","rootId","treeRef","className","expandedIds","selectedIds","toggleTreeItemSelection","selectMultipleTreeItems","toggleTreeItemExpansion","expandMultipleTreeItems","onClick","onFocus","onKeyDown","renderer","TreeItemRenderer","multiSelect","expansionMode","expanderIcon","expanderLeft","linkComponent","disableTransition","temporaryChildItems","remaining","treeId","items","treeItemChildIds","metadataLookup","movementContext","movementProps","ref","value","role","tabIndex","render","getItemKey","options","item","itemId"],"mappings":"AAAA;;AAWA,SAASA,IAAI,QAAQ,kBAAkB;AACvC,SAASC,wBAAwB,QAAQ,6CAA6C;AAEtF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,uBAAuB,QAAQ,+BAA+B;AACvE,SAAiCC,YAAY,QAAQ,oBAAoB;AACzE,SAAoCC,IAAI,QAAQ,cAAc;AAQ9D,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,eAAe,QAAQ,uBAAuB;AA+IvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DC,GACD,OAAO,SAASC,KACdC,KAAyC;IAEzC,MAAM,EACJC,EAAE,EACFC,IAAI,EACJC,OAAOV,QAAQ,EACfW,SAAS,IAAI,EACbC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB,EACvBC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,UAAUC,mBAAmBvB,uBAAuB,EACpDwB,cAAc,KAAK,EACnBC,gBAAgB,MAAM,EACtBC,YAAY,EACZC,eAAe,KAAK,EACpBC,gBAAgB,GAAG,EACnBC,oBAAoB,KAAK,EACzBC,sBAAsB,KAAK,EAC3B,GAAGC,WACJ,GAAGzB;IACJ,MAAM0B,SAASnC,aAAaU,IAAI;IAChC,MAAM,EAAE0B,KAAK,EAAEC,gBAAgB,EAAE,GAAG/B,aAAa;QAC/CK;QACAC;QACAC;IACF;IAEA,MAAM,EAAEyB,cAAc,EAAEC,eAAe,EAAEC,aAAa,EAAE,GAAGjC,gBAAgB;QACzEkC,KAAK3B;QACLQ;QACAC;QACAC;QACAb;QACAK;QACAC;QACAoB;QACAjB;QACAC;IACF;IAEA,qBACE,KAACjB;QACCO,MAAMA;QACNE,QAAQA;QACRc,aAAaA;QACbI,eAAeA;QACfd,aAAaA;QACbD,aAAaA;QACba,cAAcA;QACdC,cAAcA;QACdF,eAAeA;QACfU,gBAAgBA;QAChBN,mBAAmBA;QACnBC,qBAAqBA;QACrBf,yBAAyBA;QACzBE,yBAAyBA;QACzBD,yBAAyBA;QACzBE,yBAAyBA;kBAEzB,cAAA,KAACtB;YAAyB2C,OAAOH;sBAC/B,cAAA,KAACzC;gBACE,GAAGoC,SAAS;gBACZ,GAAGM,aAAa;gBACjB9B,IAAIyB;gBACJQ,MAAK;gBACLC,UAAU;gBACV7B,WAAWV,KAAK;oBAAEU;gBAAU;0BAE5B,cAAA,KAACd;oBACCmC,OAAOA;oBACPS,QAAQnB;oBACRoB,YAAY,CAACC,UAAYA,QAAQC,IAAI,CAACC,MAAM;;;;;AAMxD"}
@@ -1,4 +1,12 @@
1
- import type { InternalListItemClassNameOptions } from "../list/listItemStyles.js";
1
+ import { type InternalListItemClassNameOptions } from "../list/listItemStyles.js";
2
+ declare module "react" {
3
+ interface CSSProperties {
4
+ "--rmd-tree-depth"?: number;
5
+ "--rmd-tree-item-padding"?: string | number;
6
+ "--rmd-tree-item-padding-base"?: string | number;
7
+ "--rmd-tree-item-padding-incrementor"?: string | number;
8
+ }
9
+ }
2
10
  /** @since 6.0.0 */
3
11
  export interface TreeClassNameOptions {
4
12
  className?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tree/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport type { InternalListItemClassNameOptions } from \"../list/listItemStyles.js\";\nimport { listItem } from \"../list/listItemStyles.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst treeStyles = bem(\"rmd-tree\");\nconst treeItemStyles = bem(\"rmd-tree-item\");\nconst treeGroupStyles = bem(\"rmd-tree-group\");\n\n/** @since 6.0.0 */\nexport interface TreeClassNameOptions {\n className?: string;\n}\n\n/**\n * Apply the `className`s for a tree component. This will be type-safe if using\n * typescript.\n *\n * @since 6.0.0\n */\nexport function tree(options: TreeClassNameOptions = {}): string {\n const { className } = options;\n\n return cnb(treeStyles(), className);\n}\n\n/** @since 6.0.0 */\nexport interface TreeItemClassNameOptions {\n className?: string;\n expander?: boolean;\n\n /**\n * Settings this to `true` will update the styles for the expander icon within\n * the tree item to rotate `down -> right` instead of `down -> left`.\n *\n * @defaultValue `false`\n */\n expanderLeft?: boolean;\n}\n\n/**\n * Apply the `className`s for a tree item component. This will be type-safe if\n * using typescript.\n *\n * @since 6.0.0\n */\nexport function treeItem(options: TreeItemClassNameOptions = {}): string {\n const { className, expander = false, expanderLeft = false } = options;\n\n return cnb(\n treeItemStyles({\n \"expander-left\": expander && expanderLeft,\n \"expander-right\": expander && !expanderLeft,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface TreeItemContentClassNameOptions\n extends InternalListItemClassNameOptions {\n /**\n * Set this\n *\n * @defaultValue `false`\n */\n link?: boolean;\n\n /**\n * Set this to `true` when the tree item is the current keyboard focus with\n * `aria-activedescendant`. This will apply the focus styles only while the\n * parent tree component is focused and the user is in keyboard mode.\n *\n *\n * @defaultValue `false`\n */\n focused?: boolean;\n\n /**\n * Set this to `true` hen the tree item has been selected by the user. The\n * default styles just\n *\n * @defaultValue `false`\n */\n selected?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function treeItemContent(\n options: TreeItemContentClassNameOptions = {}\n): string {\n const {\n className,\n link = false,\n focused,\n selected,\n disabled = false,\n ...remaining\n } = options;\n\n return cnb(\n treeItemStyles(\"content\", {\n link,\n focused,\n selected,\n disabled,\n }),\n listItem({\n className,\n disabled,\n ...remaining,\n })\n );\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TreeItemMediaClassNameOptions {\n className?: string;\n isLeafNode: boolean;\n isMediaLeftAddon: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function treeItemMedia(options: TreeItemMediaClassNameOptions): string {\n const { isLeafNode, isMediaLeftAddon, className } = options;\n\n return cnb(\n isMediaLeftAddon && treeItemStyles(\"media\", { single: isLeafNode }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface TreeGroupClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function treeGroup(options: TreeGroupClassNameOptions = {}): string {\n const { className } = options;\n\n return cnb(treeGroupStyles(), className);\n}\n"],"names":["cnb","listItem","bem","treeStyles","treeItemStyles","treeGroupStyles","tree","options","className","treeItem","expander","expanderLeft","treeItemContent","link","focused","selected","disabled","remaining","treeItemMedia","isLeafNode","isMediaLeftAddon","single","treeGroup"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAGhC,SAASC,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,aAAaD,IAAI;AACvB,MAAME,iBAAiBF,IAAI;AAC3B,MAAMG,kBAAkBH,IAAI;AAO5B;;;;;CAKC,GACD,OAAO,SAASI,KAAKC,UAAgC,CAAC,CAAC;IACrD,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOP,IAAIG,cAAcK;AAC3B;AAgBA;;;;;CAKC,GACD,OAAO,SAASC,SAASF,UAAoC,CAAC,CAAC;IAC7D,MAAM,EAAEC,SAAS,EAAEE,WAAW,KAAK,EAAEC,eAAe,KAAK,EAAE,GAAGJ;IAE9D,OAAOP,IACLI,eAAe;QACb,iBAAiBM,YAAYC;QAC7B,kBAAkBD,YAAY,CAACC;IACjC,IACAH;AAEJ;AA+BA;;CAEC,GACD,OAAO,SAASI,gBACdL,UAA2C,CAAC,CAAC;IAE7C,MAAM,EACJC,SAAS,EACTK,OAAO,KAAK,EACZC,OAAO,EACPC,QAAQ,EACRC,WAAW,KAAK,EAChB,GAAGC,WACJ,GAAGV;IAEJ,OAAOP,IACLI,eAAe,WAAW;QACxBS;QACAC;QACAC;QACAC;IACF,IACAf,SAAS;QACPO;QACAQ;QACA,GAAGC,SAAS;IACd;AAEJ;AAWA;;CAEC,GACD,OAAO,SAASC,cAAcX,OAAsC;IAClE,MAAM,EAAEY,UAAU,EAAEC,gBAAgB,EAAEZ,SAAS,EAAE,GAAGD;IAEpD,OAAOP,IACLoB,oBAAoBhB,eAAe,SAAS;QAAEiB,QAAQF;IAAW,IACjEX;AAEJ;AAOA;;CAEC,GACD,OAAO,SAASc,UAAUf,UAAqC,CAAC,CAAC;IAC/D,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOP,IAAIK,mBAAmBG;AAChC"}
1
+ {"version":3,"sources":["../../src/tree/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type InternalListItemClassNameOptions } from \"../list/listItemStyles.js\";\nimport { listItem } from \"../list/listItemStyles.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst treeStyles = bem(\"rmd-tree\");\nconst treeItemStyles = bem(\"rmd-tree-item\");\nconst treeGroupStyles = bem(\"rmd-tree-group\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tree-depth\"?: number;\n \"--rmd-tree-item-padding\"?: string | number;\n \"--rmd-tree-item-padding-base\"?: string | number;\n \"--rmd-tree-item-padding-incrementor\"?: string | number;\n }\n}\n\n/** @since 6.0.0 */\nexport interface TreeClassNameOptions {\n className?: string;\n}\n\n/**\n * Apply the `className`s for a tree component. This will be type-safe if using\n * typescript.\n *\n * @since 6.0.0\n */\nexport function tree(options: TreeClassNameOptions = {}): string {\n const { className } = options;\n\n return cnb(treeStyles(), className);\n}\n\n/** @since 6.0.0 */\nexport interface TreeItemClassNameOptions {\n className?: string;\n expander?: boolean;\n\n /**\n * Settings this to `true` will update the styles for the expander icon within\n * the tree item to rotate `down -> right` instead of `down -> left`.\n *\n * @defaultValue `false`\n */\n expanderLeft?: boolean;\n}\n\n/**\n * Apply the `className`s for a tree item component. This will be type-safe if\n * using typescript.\n *\n * @since 6.0.0\n */\nexport function treeItem(options: TreeItemClassNameOptions = {}): string {\n const { className, expander = false, expanderLeft = false } = options;\n\n return cnb(\n treeItemStyles({\n \"expander-left\": expander && expanderLeft,\n \"expander-right\": expander && !expanderLeft,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface TreeItemContentClassNameOptions\n extends InternalListItemClassNameOptions {\n /**\n * Set this\n *\n * @defaultValue `false`\n */\n link?: boolean;\n\n /**\n * Set this to `true` when the tree item is the current keyboard focus with\n * `aria-activedescendant`. This will apply the focus styles only while the\n * parent tree component is focused and the user is in keyboard mode.\n *\n *\n * @defaultValue `false`\n */\n focused?: boolean;\n\n /**\n * Set this to `true` hen the tree item has been selected by the user. The\n * default styles just\n *\n * @defaultValue `false`\n */\n selected?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function treeItemContent(\n options: TreeItemContentClassNameOptions = {}\n): string {\n const {\n className,\n link = false,\n focused,\n selected,\n disabled = false,\n ...remaining\n } = options;\n\n return cnb(\n treeItemStyles(\"content\", {\n link,\n focused,\n selected,\n disabled,\n }),\n listItem({\n className,\n disabled,\n ...remaining,\n })\n );\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TreeItemMediaClassNameOptions {\n className?: string;\n isLeafNode: boolean;\n isMediaLeftAddon: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function treeItemMedia(options: TreeItemMediaClassNameOptions): string {\n const { isLeafNode, isMediaLeftAddon, className } = options;\n\n return cnb(\n isMediaLeftAddon && treeItemStyles(\"media\", { single: isLeafNode }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface TreeGroupClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function treeGroup(options: TreeGroupClassNameOptions = {}): string {\n const { className } = options;\n\n return cnb(treeGroupStyles(), className);\n}\n"],"names":["cnb","listItem","bem","treeStyles","treeItemStyles","treeGroupStyles","tree","options","className","treeItem","expander","expanderLeft","treeItemContent","link","focused","selected","disabled","remaining","treeItemMedia","isLeafNode","isMediaLeftAddon","single","treeGroup"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAGhC,SAASC,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,aAAaD,IAAI;AACvB,MAAME,iBAAiBF,IAAI;AAC3B,MAAMG,kBAAkBH,IAAI;AAgB5B;;;;;CAKC,GACD,OAAO,SAASI,KAAKC,UAAgC,CAAC,CAAC;IACrD,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOP,IAAIG,cAAcK;AAC3B;AAgBA;;;;;CAKC,GACD,OAAO,SAASC,SAASF,UAAoC,CAAC,CAAC;IAC7D,MAAM,EAAEC,SAAS,EAAEE,WAAW,KAAK,EAAEC,eAAe,KAAK,EAAE,GAAGJ;IAE9D,OAAOP,IACLI,eAAe;QACb,iBAAiBM,YAAYC;QAC7B,kBAAkBD,YAAY,CAACC;IACjC,IACAH;AAEJ;AA+BA;;CAEC,GACD,OAAO,SAASI,gBACdL,UAA2C,CAAC,CAAC;IAE7C,MAAM,EACJC,SAAS,EACTK,OAAO,KAAK,EACZC,OAAO,EACPC,QAAQ,EACRC,WAAW,KAAK,EAChB,GAAGC,WACJ,GAAGV;IAEJ,OAAOP,IACLI,eAAe,WAAW;QACxBS;QACAC;QACAC;QACAC;IACF,IACAf,SAAS;QACPO;QACAQ;QACA,GAAGC,SAAS;IACd;AAEJ;AAWA;;CAEC,GACD,OAAO,SAASC,cAAcX,OAAsC;IAClE,MAAM,EAAEY,UAAU,EAAEC,gBAAgB,EAAEZ,SAAS,EAAE,GAAGD;IAEpD,OAAOP,IACLoB,oBAAoBhB,eAAe,SAAS;QAAEiB,QAAQF;IAAW,IACjEX;AAEJ;AAOA;;CAEC,GACD,OAAO,SAASc,UAAUf,UAAqC,CAAC,CAAC;IAC/D,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOP,IAAIK,mBAAmBG;AAChC"}
@@ -1,4 +1,4 @@
1
- import type { FocusEventHandler, KeyboardEventHandler, MouseEventHandler } from "react";
1
+ import type { FocusEventHandler, KeyboardEventHandler, MouseEventHandler, Ref } from "react";
2
2
  import type { KeyboardMovementProviderImplementation } from "../movement/types.js";
3
3
  import type { NonNullMutableRef } from "../types.js";
4
4
  import type { TreeItemMetadataLookup } from "./TreeProvider.js";
@@ -10,6 +10,7 @@ import type { TreeItemChildIds } from "./useTreeItems.js";
10
10
  * @internal
11
11
  */
12
12
  interface TreeMovementOptions<T extends TreeItemNode> extends TreeExpansion {
13
+ ref?: Ref<HTMLUListElement>;
13
14
  data: TreeData<T>;
14
15
  onClick: MouseEventHandler<HTMLUListElement> | undefined;
15
16
  onFocus: FocusEventHandler<HTMLUListElement> | undefined;
@@ -30,7 +30,7 @@ import { getNextFocusableIndex } from "../movement/utils.js";
30
30
  * @since 6.0.0
31
31
  * @internal
32
32
  */ export function useTreeMovement(options) {
33
- const { onClick, onFocus, onKeyDown, data, expandedIds, selectedIds, treeItemChildIds, toggleTreeItemExpansion, expandMultipleTreeItems } = options;
33
+ const { ref, onClick, onFocus, onKeyDown, data, expandedIds, selectedIds, treeItemChildIds, toggleTreeItemExpansion, expandMultipleTreeItems } = options;
34
34
  const metadataLookup = useRef({
35
35
  expandable: {},
36
36
  disabledItems: {},
@@ -38,6 +38,7 @@ import { getNextFocusableIndex } from "../movement/utils.js";
38
38
  itemToElement: {}
39
39
  });
40
40
  const movement = useKeyboardMovementProvider({
41
+ ref,
41
42
  onClick,
42
43
  onFocus,
43
44
  onKeyDown,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tree/useTreeMovement.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n FocusEventHandler,\n KeyboardEventHandler,\n MouseEventHandler,\n} from \"react\";\nimport { useRef } from \"react\";\n\nimport type { KeyboardMovementProviderImplementation } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { getNextFocusableIndex } from \"../movement/utils.js\";\nimport type { NonNullMutableRef } from \"../types.js\";\nimport type { TreeItemMetadataLookup } from \"./TreeProvider.js\";\nimport type { TreeData, TreeItemNode } from \"./types.js\";\nimport type { TreeExpansion } from \"./useTreeExpansion.js\";\nimport type { TreeItemChildIds } from \"./useTreeItems.js\";\n\n/**\n * This helps catch the edge case where the collapse transition has occurred for\n * a tree item group, but the user uses the `ArrowDown` key before it has\n * finished. So to do this:\n *\n * - find the parent group of the tree item\n * - find the tree item that controls the group (the element before the group)\n * - check if the `aria-expanded` state is `\"false\"` meaning it is considered\n * closed\n *\n * @internal\n * @since 6.0.0\n */\nconst isParentItemCollapsing = (item: HTMLElement): boolean =>\n item\n .closest(\"[role='group']\")\n ?.previousElementSibling?.getAttribute(\"aria-expanded\") === \"false\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nconst getVisibleTreeItems = (\n container: HTMLElement\n): readonly HTMLElement[] => {\n const items = [\n ...container.querySelectorAll<HTMLElement>('[role=\"treeitem\"]'),\n ];\n\n return items.filter(\n (item) =>\n // do not include items that have a `hidden` parent group\n item.offsetParent &&\n // do not include items that are about to become hidden\n !isParentItemCollapsing(item)\n );\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovementOptions<T extends TreeItemNode> extends TreeExpansion {\n data: TreeData<T>;\n onClick: MouseEventHandler<HTMLUListElement> | undefined;\n onFocus: FocusEventHandler<HTMLUListElement> | undefined;\n onKeyDown: KeyboardEventHandler<HTMLUListElement> | undefined;\n selectedIds: ReadonlySet<string>;\n treeItemChildIds: TreeItemChildIds;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovement\n extends KeyboardMovementProviderImplementation<HTMLUListElement> {\n /**\n * This will be mutated by the `TreeItem` component and used to handle\n * keyboard movement.\n */\n metadataLookup: NonNullMutableRef<TreeItemMetadataLookup>;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function useTreeMovement<T extends TreeItemNode>(\n options: TreeMovementOptions<T>\n): TreeMovement {\n const {\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n } = options;\n\n const metadataLookup = useRef<TreeItemMetadataLookup>({\n expandable: {},\n disabledItems: {},\n elementToItem: {},\n itemToElement: {},\n });\n const movement = useKeyboardMovementProvider({\n onClick,\n onFocus,\n onKeyDown,\n extendKeyDown(movementData) {\n const { event, activeDescendantId, currentFocusIndex, setFocusIndex } =\n movementData;\n const { expandable, disabledItems, elementToItem, itemToElement } =\n metadataLookup.current;\n const itemId = elementToItem[activeDescendantId];\n const item = data[itemId];\n\n /* c8 ignore start */\n if (!item) {\n return;\n }\n /* c8 ignore stop */\n\n const disabled = disabledItems[itemId];\n const expanded = expandedIds.has(itemId);\n\n let flagged = false;\n switch (event.key) {\n case \"ArrowLeft\":\n if (expanded && !disabled) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else if (item.parentId) {\n // do not flag for this case since setFocusIndex already does this\n const parentId = itemToElement[item.parentId];\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = focusables.findIndex(\n (element) => element.id === parentId\n );\n setFocusIndex(index, focusables);\n }\n\n break;\n case \"ArrowRight\":\n if (expandable[itemId] && !disabled) {\n if (!expanded) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else {\n // do not flag for this case since setFocusIndex already does this\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = getNextFocusableIndex({\n loopable: false,\n increment: true,\n focusables,\n includeDisabled: true,\n currentFocusIndex: currentFocusIndex.current,\n });\n\n setFocusIndex(index, focusables);\n }\n }\n\n break;\n case \"*\": {\n flagged = true;\n const itemIds = treeItemChildIds.get(item.parentId);\n if (itemIds) {\n const expandableIds = [...itemIds].filter(\n (itemId) => expandable[itemId]\n );\n if (expandableIds.length) {\n expandMultipleTreeItems(\n (prev) => new Set([...prev, ...expandableIds])\n );\n currentFocusIndex.current = -1;\n }\n }\n break;\n }\n }\n\n if (flagged) {\n event.stopPropagation();\n event.preventDefault();\n }\n },\n searchable: true,\n tabIndexBehavior: \"virtual\",\n getFocusableElements: getVisibleTreeItems,\n getDefaultFocusedIndex(options) {\n const { focusables } = options;\n const { elementToItem } = metadataLookup.current;\n\n return focusables.findIndex((element) =>\n selectedIds.has(elementToItem[element.id])\n );\n },\n });\n\n return {\n metadataLookup,\n ...movement,\n };\n}\n"],"names":["useRef","useKeyboardMovementProvider","getNextFocusableIndex","isParentItemCollapsing","item","closest","previousElementSibling","getAttribute","getVisibleTreeItems","container","items","querySelectorAll","filter","offsetParent","useTreeMovement","options","onClick","onFocus","onKeyDown","data","expandedIds","selectedIds","treeItemChildIds","toggleTreeItemExpansion","expandMultipleTreeItems","metadataLookup","expandable","disabledItems","elementToItem","itemToElement","movement","extendKeyDown","movementData","event","activeDescendantId","currentFocusIndex","setFocusIndex","current","itemId","disabled","expanded","has","flagged","key","parentId","focusables","currentTarget","index","findIndex","element","id","loopable","increment","includeDisabled","itemIds","get","expandableIds","length","prev","Set","stopPropagation","preventDefault","searchable","tabIndexBehavior","getFocusableElements","getDefaultFocusedIndex"],"mappings":"AAAA;AAOA,SAASA,MAAM,QAAQ,QAAQ;AAG/B,SAASC,2BAA2B,QAAQ,6CAA6C;AACzF,SAASC,qBAAqB,QAAQ,uBAAuB;AAO7D;;;;;;;;;;;;CAYC,GACD,MAAMC,yBAAyB,CAACC,OAC9BA,KACGC,OAAO,CAAC,mBACPC,wBAAwBC,aAAa,qBAAqB;AAEhE;;;CAGC,GACD,MAAMC,sBAAsB,CAC1BC;IAEA,MAAMC,QAAQ;WACTD,UAAUE,gBAAgB,CAAc;KAC5C;IAED,OAAOD,MAAME,MAAM,CACjB,CAACR,OACC,yDAAyD;QACzDA,KAAKS,YAAY,IACjB,uDAAuD;QACvD,CAACV,uBAAuBC;AAE9B;AA4BA;;;CAGC,GACD,OAAO,SAASU,gBACdC,OAA+B;IAE/B,MAAM,EACJC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACxB,GAAGT;IAEJ,MAAMU,iBAAiBzB,OAA+B;QACpD0B,YAAY,CAAC;QACbC,eAAe,CAAC;QAChBC,eAAe,CAAC;QAChBC,eAAe,CAAC;IAClB;IACA,MAAMC,WAAW7B,4BAA4B;QAC3Ce;QACAC;QACAC;QACAa,eAAcC,YAAY;YACxB,MAAM,EAAEC,KAAK,EAAEC,kBAAkB,EAAEC,iBAAiB,EAAEC,aAAa,EAAE,GACnEJ;YACF,MAAM,EAAEN,UAAU,EAAEC,aAAa,EAAEC,aAAa,EAAEC,aAAa,EAAE,GAC/DJ,eAAeY,OAAO;YACxB,MAAMC,SAASV,aAAa,CAACM,mBAAmB;YAChD,MAAM9B,OAAOe,IAAI,CAACmB,OAAO;YAEzB,mBAAmB,GACnB,IAAI,CAAClC,MAAM;gBACT;YACF;YACA,kBAAkB,GAElB,MAAMmC,WAAWZ,aAAa,CAACW,OAAO;YACtC,MAAME,WAAWpB,YAAYqB,GAAG,CAACH;YAEjC,IAAII,UAAU;YACd,OAAQT,MAAMU,GAAG;gBACf,KAAK;oBACH,IAAIH,YAAY,CAACD,UAAU;wBACzBG,UAAU;wBACVnB,wBAAwBe;oBAC1B,OAAO,IAAIlC,KAAKwC,QAAQ,EAAE;wBACxB,kEAAkE;wBAClE,MAAMA,WAAWf,aAAa,CAACzB,KAAKwC,QAAQ,CAAC;wBAC7C,MAAMC,aAAarC,oBAAoByB,MAAMa,aAAa;wBAC1D,MAAMC,QAAQF,WAAWG,SAAS,CAChC,CAACC,UAAYA,QAAQC,EAAE,KAAKN;wBAE9BR,cAAcW,OAAOF;oBACvB;oBAEA;gBACF,KAAK;oBACH,IAAInB,UAAU,CAACY,OAAO,IAAI,CAACC,UAAU;wBACnC,IAAI,CAACC,UAAU;4BACbE,UAAU;4BACVnB,wBAAwBe;wBAC1B,OAAO;4BACL,kEAAkE;4BAClE,MAAMO,aAAarC,oBAAoByB,MAAMa,aAAa;4BAC1D,MAAMC,QAAQ7C,sBAAsB;gCAClCiD,UAAU;gCACVC,WAAW;gCACXP;gCACAQ,iBAAiB;gCACjBlB,mBAAmBA,kBAAkBE,OAAO;4BAC9C;4BAEAD,cAAcW,OAAOF;wBACvB;oBACF;oBAEA;gBACF,KAAK;oBAAK;wBACRH,UAAU;wBACV,MAAMY,UAAUhC,iBAAiBiC,GAAG,CAACnD,KAAKwC,QAAQ;wBAClD,IAAIU,SAAS;4BACX,MAAME,gBAAgB;mCAAIF;6BAAQ,CAAC1C,MAAM,CACvC,CAAC0B,SAAWZ,UAAU,CAACY,OAAO;4BAEhC,IAAIkB,cAAcC,MAAM,EAAE;gCACxBjC,wBACE,CAACkC,OAAS,IAAIC,IAAI;2CAAID;2CAASF;qCAAc;gCAE/CrB,kBAAkBE,OAAO,GAAG,CAAC;4BAC/B;wBACF;wBACA;oBACF;YACF;YAEA,IAAIK,SAAS;gBACXT,MAAM2B,eAAe;gBACrB3B,MAAM4B,cAAc;YACtB;QACF;QACAC,YAAY;QACZC,kBAAkB;QAClBC,sBAAsBxD;QACtByD,wBAAuBlD,OAAO;YAC5B,MAAM,EAAE8B,UAAU,EAAE,GAAG9B;YACvB,MAAM,EAAEa,aAAa,EAAE,GAAGH,eAAeY,OAAO;YAEhD,OAAOQ,WAAWG,SAAS,CAAC,CAACC,UAC3B5B,YAAYoB,GAAG,CAACb,aAAa,CAACqB,QAAQC,EAAE,CAAC;QAE7C;IACF;IAEA,OAAO;QACLzB;QACA,GAAGK,QAAQ;IACb;AACF"}
1
+ {"version":3,"sources":["../../src/tree/useTreeMovement.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n FocusEventHandler,\n KeyboardEventHandler,\n MouseEventHandler,\n Ref,\n} from \"react\";\nimport { useRef } from \"react\";\n\nimport type { KeyboardMovementProviderImplementation } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { getNextFocusableIndex } from \"../movement/utils.js\";\nimport type { NonNullMutableRef } from \"../types.js\";\nimport type { TreeItemMetadataLookup } from \"./TreeProvider.js\";\nimport type { TreeData, TreeItemNode } from \"./types.js\";\nimport type { TreeExpansion } from \"./useTreeExpansion.js\";\nimport type { TreeItemChildIds } from \"./useTreeItems.js\";\n\n/**\n * This helps catch the edge case where the collapse transition has occurred for\n * a tree item group, but the user uses the `ArrowDown` key before it has\n * finished. So to do this:\n *\n * - find the parent group of the tree item\n * - find the tree item that controls the group (the element before the group)\n * - check if the `aria-expanded` state is `\"false\"` meaning it is considered\n * closed\n *\n * @internal\n * @since 6.0.0\n */\nconst isParentItemCollapsing = (item: HTMLElement): boolean =>\n item\n .closest(\"[role='group']\")\n ?.previousElementSibling?.getAttribute(\"aria-expanded\") === \"false\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nconst getVisibleTreeItems = (\n container: HTMLElement\n): readonly HTMLElement[] => {\n const items = [\n ...container.querySelectorAll<HTMLElement>('[role=\"treeitem\"]'),\n ];\n\n return items.filter(\n (item) =>\n // do not include items that have a `hidden` parent group\n item.offsetParent &&\n // do not include items that are about to become hidden\n !isParentItemCollapsing(item)\n );\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovementOptions<T extends TreeItemNode> extends TreeExpansion {\n ref?: Ref<HTMLUListElement>;\n data: TreeData<T>;\n onClick: MouseEventHandler<HTMLUListElement> | undefined;\n onFocus: FocusEventHandler<HTMLUListElement> | undefined;\n onKeyDown: KeyboardEventHandler<HTMLUListElement> | undefined;\n selectedIds: ReadonlySet<string>;\n treeItemChildIds: TreeItemChildIds;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovement\n extends KeyboardMovementProviderImplementation<HTMLUListElement> {\n /**\n * This will be mutated by the `TreeItem` component and used to handle\n * keyboard movement.\n */\n metadataLookup: NonNullMutableRef<TreeItemMetadataLookup>;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function useTreeMovement<T extends TreeItemNode>(\n options: TreeMovementOptions<T>\n): TreeMovement {\n const {\n ref,\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n } = options;\n\n const metadataLookup = useRef<TreeItemMetadataLookup>({\n expandable: {},\n disabledItems: {},\n elementToItem: {},\n itemToElement: {},\n });\n const movement = useKeyboardMovementProvider({\n ref,\n onClick,\n onFocus,\n onKeyDown,\n extendKeyDown(movementData) {\n const { event, activeDescendantId, currentFocusIndex, setFocusIndex } =\n movementData;\n const { expandable, disabledItems, elementToItem, itemToElement } =\n metadataLookup.current;\n const itemId = elementToItem[activeDescendantId];\n const item = data[itemId];\n\n /* c8 ignore start */\n if (!item) {\n return;\n }\n /* c8 ignore stop */\n\n const disabled = disabledItems[itemId];\n const expanded = expandedIds.has(itemId);\n\n let flagged = false;\n switch (event.key) {\n case \"ArrowLeft\":\n if (expanded && !disabled) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else if (item.parentId) {\n // do not flag for this case since setFocusIndex already does this\n const parentId = itemToElement[item.parentId];\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = focusables.findIndex(\n (element) => element.id === parentId\n );\n setFocusIndex(index, focusables);\n }\n\n break;\n case \"ArrowRight\":\n if (expandable[itemId] && !disabled) {\n if (!expanded) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else {\n // do not flag for this case since setFocusIndex already does this\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = getNextFocusableIndex({\n loopable: false,\n increment: true,\n focusables,\n includeDisabled: true,\n currentFocusIndex: currentFocusIndex.current,\n });\n\n setFocusIndex(index, focusables);\n }\n }\n\n break;\n case \"*\": {\n flagged = true;\n const itemIds = treeItemChildIds.get(item.parentId);\n if (itemIds) {\n const expandableIds = [...itemIds].filter(\n (itemId) => expandable[itemId]\n );\n if (expandableIds.length) {\n expandMultipleTreeItems(\n (prev) => new Set([...prev, ...expandableIds])\n );\n currentFocusIndex.current = -1;\n }\n }\n break;\n }\n }\n\n if (flagged) {\n event.stopPropagation();\n event.preventDefault();\n }\n },\n searchable: true,\n tabIndexBehavior: \"virtual\",\n getFocusableElements: getVisibleTreeItems,\n getDefaultFocusedIndex(options) {\n const { focusables } = options;\n const { elementToItem } = metadataLookup.current;\n\n return focusables.findIndex((element) =>\n selectedIds.has(elementToItem[element.id])\n );\n },\n });\n\n return {\n metadataLookup,\n ...movement,\n };\n}\n"],"names":["useRef","useKeyboardMovementProvider","getNextFocusableIndex","isParentItemCollapsing","item","closest","previousElementSibling","getAttribute","getVisibleTreeItems","container","items","querySelectorAll","filter","offsetParent","useTreeMovement","options","ref","onClick","onFocus","onKeyDown","data","expandedIds","selectedIds","treeItemChildIds","toggleTreeItemExpansion","expandMultipleTreeItems","metadataLookup","expandable","disabledItems","elementToItem","itemToElement","movement","extendKeyDown","movementData","event","activeDescendantId","currentFocusIndex","setFocusIndex","current","itemId","disabled","expanded","has","flagged","key","parentId","focusables","currentTarget","index","findIndex","element","id","loopable","increment","includeDisabled","itemIds","get","expandableIds","length","prev","Set","stopPropagation","preventDefault","searchable","tabIndexBehavior","getFocusableElements","getDefaultFocusedIndex"],"mappings":"AAAA;AAQA,SAASA,MAAM,QAAQ,QAAQ;AAG/B,SAASC,2BAA2B,QAAQ,6CAA6C;AACzF,SAASC,qBAAqB,QAAQ,uBAAuB;AAO7D;;;;;;;;;;;;CAYC,GACD,MAAMC,yBAAyB,CAACC,OAC9BA,KACGC,OAAO,CAAC,mBACPC,wBAAwBC,aAAa,qBAAqB;AAEhE;;;CAGC,GACD,MAAMC,sBAAsB,CAC1BC;IAEA,MAAMC,QAAQ;WACTD,UAAUE,gBAAgB,CAAc;KAC5C;IAED,OAAOD,MAAME,MAAM,CACjB,CAACR,OACC,yDAAyD;QACzDA,KAAKS,YAAY,IACjB,uDAAuD;QACvD,CAACV,uBAAuBC;AAE9B;AA6BA;;;CAGC,GACD,OAAO,SAASU,gBACdC,OAA+B;IAE/B,MAAM,EACJC,GAAG,EACHC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACxB,GAAGV;IAEJ,MAAMW,iBAAiB1B,OAA+B;QACpD2B,YAAY,CAAC;QACbC,eAAe,CAAC;QAChBC,eAAe,CAAC;QAChBC,eAAe,CAAC;IAClB;IACA,MAAMC,WAAW9B,4BAA4B;QAC3Ce;QACAC;QACAC;QACAC;QACAa,eAAcC,YAAY;YACxB,MAAM,EAAEC,KAAK,EAAEC,kBAAkB,EAAEC,iBAAiB,EAAEC,aAAa,EAAE,GACnEJ;YACF,MAAM,EAAEN,UAAU,EAAEC,aAAa,EAAEC,aAAa,EAAEC,aAAa,EAAE,GAC/DJ,eAAeY,OAAO;YACxB,MAAMC,SAASV,aAAa,CAACM,mBAAmB;YAChD,MAAM/B,OAAOgB,IAAI,CAACmB,OAAO;YAEzB,mBAAmB,GACnB,IAAI,CAACnC,MAAM;gBACT;YACF;YACA,kBAAkB,GAElB,MAAMoC,WAAWZ,aAAa,CAACW,OAAO;YACtC,MAAME,WAAWpB,YAAYqB,GAAG,CAACH;YAEjC,IAAII,UAAU;YACd,OAAQT,MAAMU,GAAG;gBACf,KAAK;oBACH,IAAIH,YAAY,CAACD,UAAU;wBACzBG,UAAU;wBACVnB,wBAAwBe;oBAC1B,OAAO,IAAInC,KAAKyC,QAAQ,EAAE;wBACxB,kEAAkE;wBAClE,MAAMA,WAAWf,aAAa,CAAC1B,KAAKyC,QAAQ,CAAC;wBAC7C,MAAMC,aAAatC,oBAAoB0B,MAAMa,aAAa;wBAC1D,MAAMC,QAAQF,WAAWG,SAAS,CAChC,CAACC,UAAYA,QAAQC,EAAE,KAAKN;wBAE9BR,cAAcW,OAAOF;oBACvB;oBAEA;gBACF,KAAK;oBACH,IAAInB,UAAU,CAACY,OAAO,IAAI,CAACC,UAAU;wBACnC,IAAI,CAACC,UAAU;4BACbE,UAAU;4BACVnB,wBAAwBe;wBAC1B,OAAO;4BACL,kEAAkE;4BAClE,MAAMO,aAAatC,oBAAoB0B,MAAMa,aAAa;4BAC1D,MAAMC,QAAQ9C,sBAAsB;gCAClCkD,UAAU;gCACVC,WAAW;gCACXP;gCACAQ,iBAAiB;gCACjBlB,mBAAmBA,kBAAkBE,OAAO;4BAC9C;4BAEAD,cAAcW,OAAOF;wBACvB;oBACF;oBAEA;gBACF,KAAK;oBAAK;wBACRH,UAAU;wBACV,MAAMY,UAAUhC,iBAAiBiC,GAAG,CAACpD,KAAKyC,QAAQ;wBAClD,IAAIU,SAAS;4BACX,MAAME,gBAAgB;mCAAIF;6BAAQ,CAAC3C,MAAM,CACvC,CAAC2B,SAAWZ,UAAU,CAACY,OAAO;4BAEhC,IAAIkB,cAAcC,MAAM,EAAE;gCACxBjC,wBACE,CAACkC,OAAS,IAAIC,IAAI;2CAAID;2CAASF;qCAAc;gCAE/CrB,kBAAkBE,OAAO,GAAG,CAAC;4BAC/B;wBACF;wBACA;oBACF;YACF;YAEA,IAAIK,SAAS;gBACXT,MAAM2B,eAAe;gBACrB3B,MAAM4B,cAAc;YACtB;QACF;QACAC,YAAY;QACZC,kBAAkB;QAClBC,sBAAsBzD;QACtB0D,wBAAuBnD,OAAO;YAC5B,MAAM,EAAE+B,UAAU,EAAE,GAAG/B;YACvB,MAAM,EAAEc,aAAa,EAAE,GAAGH,eAAeY,OAAO;YAEhD,OAAOQ,WAAWG,SAAS,CAAC,CAACC,UAC3B5B,YAAYoB,GAAG,CAACb,aAAa,CAACqB,QAAQC,EAAE,CAAC;QAE7C;IACF;IAEA,OAAO;QACLzB;QACA,GAAGK,QAAQ;IACb;AACF"}
package/dist/types.d.ts CHANGED
@@ -182,6 +182,20 @@ export interface ElementSize {
182
182
  height: number;
183
183
  width: number;
184
184
  }
185
+ /**
186
+ * @since 6.3.0
187
+ */
188
+ export interface Point {
189
+ x: number;
190
+ y: number;
191
+ }
192
+ /**
193
+ * @since 6.3.0
194
+ */
195
+ export interface MinMaxRange {
196
+ min: number;
197
+ max: number;
198
+ }
185
199
  /**
186
200
  * @since 6.2.0
187
201
  */
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import {\n type Dispatch,\n type HTMLAttributes,\n type ReactElement,\n type Ref,\n type SetStateAction,\n} from \"react\";\n\n/**\n * A helper type that allows an optional `ref` to also be applied with a props\n * object even though a `ref` isn't a real prop.\n *\n * @since 6.2.0 Automatically infer the `Element` type param from the provided\n * props.\n */\nexport type PropsWithRef<\n Props extends object,\n Element extends HTMLElement = Props extends HTMLAttributes<infer E>\n ? E extends HTMLElement\n ? E\n : never\n : never,\n> = Props & {\n /**\n * An optional ref that can be applied.\n */\n ref?: Ref<Element>;\n};\n\n/**\n * A simple type that can be used for different components that clone a\n * `className` into a child component.\n */\nexport type ClassNameCloneableChild<T = object> = ReactElement<\n T & { className?: string }\n>;\n\n/**\n * This type allows you to require at least one of the provided keys. This is\n * super helpful for things like `aria-label` or `aria-labelledby` when it's\n * required for a11y.\n *\n * @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist/49725198#49725198\n */\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport interface LabelA11y {\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n}\n\n/**\n * A small accessibility helper to ensure that either `aria-label` or\n * `aria-labelledby` have been provided to a component.\n *\n * @example Simple Example\n * ```ts\n * import type { HTMLAttributes, ReactElement } from \"react\";\n * import type { LabelRequiredForA11y } from \"@react-md/core/types\";\n *\n * type Props = LabelRequiredForA11y<HTMLAttributes<HTMLDivElement>>;\n *\n * function Component(props: Props): ReactElement {\n * return <div {...props} />;\n * }\n *\n * const test1 = <Component />\n * // ^ type error\n * const test2 = <Component aria-label=\"Label\" />\n * const test3 = <Component aria-labelledby=\"some-other-id\" />\n * ```\n */\nexport type LabelRequiredForA11y<Props extends LabelA11y> = RequireAtLeastOne<\n Props,\n keyof LabelA11y\n>;\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport interface NonNullRef<T> {\n readonly current: T;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface NonNullMutableRef<T> {\n current: T;\n}\n\n/** @since 6.0.0 */\nexport type HtmlTagName = keyof JSX.IntrinsicElements;\n\n/**\n * A function to get a string from a generic item.\n *\n * @example Simple Example\n * ```ts\n * interface Item {\n * name: string;\n * }\n *\n * const items: Item[] = [{ name: 'Hello' }, { name: 'World' }];\n *\n * const extractor: TextExtractor<Item> = (item) => item.name;\n * ```\n * @since 6.0.0\n */\nexport type TextExtractor<T> = (item: T) => string;\n\n/**\n * - `\"some value\"` -&gt; `\"some value\"`\n * - `{ label: \"Hello, world\", value: 300 }` -&gt; `\"Hello, world!\"`\n * - `{ name: \"Hello, world\", value: 300 }` -&gt; `\"Hello, world!\"`\n *\n * @since 6.2.0\n */\nexport type AutomaticTextExtraction =\n | string\n | { label: string }\n | { name: string };\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateSetter<T> = Dispatch<SetStateAction<T>>;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateInitializer<T> = T | (() => T);\n\n/**\n * @example\n * ```ts\n * type Visibility = UseStateObject<\"visible\", boolean>;\n * // type Visibility = {\n * // visible: boolean;\n * // setVisible: UseStateSetter<boolean>\n * // }\n *\n * type AnotherOne = UseStateObject<\"renderAsSheet\", RenderMenuAsSheet>;\n * // type AnotherOne = {\n * // renderAsSheet: RenderMenuAsSheet;\n * // setRenderAsSheet: UseStateSetter<RenderMenuAsSheet>;\n * // }\n * ```\n * @since 6.0.0\n * @internal\n */\nexport type UseStateObject<Name extends string, Value> = {\n [key in Name]: Value;\n} & {\n [key in `set${Capitalize<Name>}`]: UseStateSetter<Value>;\n};\n\n/**\n * @example\n * ```ts\n * interface Example {\n * value: number;\n * setValue: UseStateSetter<number>;\n * }\n *\n * type WithPrefix = RenameKeysWithPrefix<Example, \"thumb1\">;\n * // type WithPrefix = {\n * // thumb1Value: number;\n * // thumb1SetValue: UseStateSetter<number>;\n * // }\n * ```\n *\n * @since 6.0.0\n * @internal\n */\nexport type RenameKeysWithPrefix<T, Prefix extends string> = {\n [Key in keyof T & string as `${Prefix}${Capitalize<Key>}`]: T[Key];\n};\n\n/**\n * @since 6.0.0\n */\nexport type CssPosition = \"fixed\" | \"sticky\" | \"static\";\n\n/**\n * @since 6.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFunction = (...args: any[]) => any;\n\n/**\n * @since 6.0.0\n */\nexport type CancelableFunction<F extends AnyFunction> = F & {\n cancel: () => void;\n};\n\n/**\n * @since 6.0.0\n */\nexport type DebouncedFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => void\n>;\n\n/**\n * @since 6.0.0\n */\nexport type ThrottledFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => ReturnType<F>\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSize {\n height: number;\n width: number;\n}\n\n/**\n * @since 6.2.0\n */\nexport type OverridableStringUnion<\n Defaults extends string,\n Overrides extends Partial<Record<string, boolean>>,\n> =\n | Exclude<Defaults, { [K in keyof Overrides]: K }[keyof Overrides]>\n | {\n [K in keyof Overrides]: Overrides[K] extends false ? never : K;\n }[keyof Overrides];\n\n/**\n * @since 6.2.0\n */\nexport type IsEmptyObject<T> = keyof T extends never ? true : false;\n"],"names":[],"mappings":"AAiPA;;CAEC,GACD,WAAoE"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import {\n type Dispatch,\n type HTMLAttributes,\n type ReactElement,\n type Ref,\n type SetStateAction,\n} from \"react\";\n\n/**\n * A helper type that allows an optional `ref` to also be applied with a props\n * object even though a `ref` isn't a real prop.\n *\n * @since 6.2.0 Automatically infer the `Element` type param from the provided\n * props.\n */\nexport type PropsWithRef<\n Props extends object,\n Element extends HTMLElement = Props extends HTMLAttributes<infer E>\n ? E extends HTMLElement\n ? E\n : never\n : never,\n> = Props & {\n /**\n * An optional ref that can be applied.\n */\n ref?: Ref<Element>;\n};\n\n/**\n * A simple type that can be used for different components that clone a\n * `className` into a child component.\n */\nexport type ClassNameCloneableChild<T = object> = ReactElement<\n T & { className?: string }\n>;\n\n/**\n * This type allows you to require at least one of the provided keys. This is\n * super helpful for things like `aria-label` or `aria-labelledby` when it's\n * required for a11y.\n *\n * @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist/49725198#49725198\n */\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport interface LabelA11y {\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n}\n\n/**\n * A small accessibility helper to ensure that either `aria-label` or\n * `aria-labelledby` have been provided to a component.\n *\n * @example Simple Example\n * ```ts\n * import type { HTMLAttributes, ReactElement } from \"react\";\n * import type { LabelRequiredForA11y } from \"@react-md/core/types\";\n *\n * type Props = LabelRequiredForA11y<HTMLAttributes<HTMLDivElement>>;\n *\n * function Component(props: Props): ReactElement {\n * return <div {...props} />;\n * }\n *\n * const test1 = <Component />\n * // ^ type error\n * const test2 = <Component aria-label=\"Label\" />\n * const test3 = <Component aria-labelledby=\"some-other-id\" />\n * ```\n */\nexport type LabelRequiredForA11y<Props extends LabelA11y> = RequireAtLeastOne<\n Props,\n keyof LabelA11y\n>;\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport interface NonNullRef<T> {\n readonly current: T;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface NonNullMutableRef<T> {\n current: T;\n}\n\n/** @since 6.0.0 */\nexport type HtmlTagName = keyof JSX.IntrinsicElements;\n\n/**\n * A function to get a string from a generic item.\n *\n * @example Simple Example\n * ```ts\n * interface Item {\n * name: string;\n * }\n *\n * const items: Item[] = [{ name: 'Hello' }, { name: 'World' }];\n *\n * const extractor: TextExtractor<Item> = (item) => item.name;\n * ```\n * @since 6.0.0\n */\nexport type TextExtractor<T> = (item: T) => string;\n\n/**\n * - `\"some value\"` -&gt; `\"some value\"`\n * - `{ label: \"Hello, world\", value: 300 }` -&gt; `\"Hello, world!\"`\n * - `{ name: \"Hello, world\", value: 300 }` -&gt; `\"Hello, world!\"`\n *\n * @since 6.2.0\n */\nexport type AutomaticTextExtraction =\n | string\n | { label: string }\n | { name: string };\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateSetter<T> = Dispatch<SetStateAction<T>>;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateInitializer<T> = T | (() => T);\n\n/**\n * @example\n * ```ts\n * type Visibility = UseStateObject<\"visible\", boolean>;\n * // type Visibility = {\n * // visible: boolean;\n * // setVisible: UseStateSetter<boolean>\n * // }\n *\n * type AnotherOne = UseStateObject<\"renderAsSheet\", RenderMenuAsSheet>;\n * // type AnotherOne = {\n * // renderAsSheet: RenderMenuAsSheet;\n * // setRenderAsSheet: UseStateSetter<RenderMenuAsSheet>;\n * // }\n * ```\n * @since 6.0.0\n * @internal\n */\nexport type UseStateObject<Name extends string, Value> = {\n [key in Name]: Value;\n} & {\n [key in `set${Capitalize<Name>}`]: UseStateSetter<Value>;\n};\n\n/**\n * @example\n * ```ts\n * interface Example {\n * value: number;\n * setValue: UseStateSetter<number>;\n * }\n *\n * type WithPrefix = RenameKeysWithPrefix<Example, \"thumb1\">;\n * // type WithPrefix = {\n * // thumb1Value: number;\n * // thumb1SetValue: UseStateSetter<number>;\n * // }\n * ```\n *\n * @since 6.0.0\n * @internal\n */\nexport type RenameKeysWithPrefix<T, Prefix extends string> = {\n [Key in keyof T & string as `${Prefix}${Capitalize<Key>}`]: T[Key];\n};\n\n/**\n * @since 6.0.0\n */\nexport type CssPosition = \"fixed\" | \"sticky\" | \"static\";\n\n/**\n * @since 6.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFunction = (...args: any[]) => any;\n\n/**\n * @since 6.0.0\n */\nexport type CancelableFunction<F extends AnyFunction> = F & {\n cancel: () => void;\n};\n\n/**\n * @since 6.0.0\n */\nexport type DebouncedFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => void\n>;\n\n/**\n * @since 6.0.0\n */\nexport type ThrottledFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => ReturnType<F>\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSize {\n height: number;\n width: number;\n}\n\n/**\n * @since 6.3.0\n */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * @since 6.3.0\n */\nexport interface MinMaxRange {\n min: number;\n max: number;\n}\n\n/**\n * @since 6.2.0\n */\nexport type OverridableStringUnion<\n Defaults extends string,\n Overrides extends Partial<Record<string, boolean>>,\n> =\n | Exclude<Defaults, { [K in keyof Overrides]: K }[keyof Overrides]>\n | {\n [K in keyof Overrides]: Overrides[K] extends false ? never : K;\n }[keyof Overrides];\n\n/**\n * @since 6.2.0\n */\nexport type IsEmptyObject<T> = keyof T extends never ? true : false;\n"],"names":[],"mappings":"AAiQA;;CAEC,GACD,WAAoE"}
@@ -1,8 +1,11 @@
1
1
  import { type HTMLAttributes, type ReactNode } from "react";
2
+ import { type MarkClassNameOptions } from "./markStyles.js";
2
3
  /**
3
4
  * @since 6.0.0
5
+ * @since 6.3.1 Extends MarkClassNameOptions for CSSProperties module
6
+ * augmentation.
4
7
  */
5
- export interface MarkProps extends HTMLAttributes<HTMLElement> {
8
+ export interface MarkProps extends HTMLAttributes<HTMLElement>, MarkClassNameOptions {
6
9
  children: ReactNode;
7
10
  }
8
11
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/Mark.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { mark } from \"./markStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MarkProps extends HTMLAttributes<HTMLElement> {\n children: ReactNode;\n}\n\n/**\n * The `Mark` component can be used in place of the `mark` HTMLElement with\n * some default styles.\n *\n * @example Simple Example\n * ```tsx\n * import { Mark } from \"@react-md/core/typography/Mark\";\n *\n * export function Example() {\n * return (\n * <>\n * Some text <Mark>that has highlights</Mark> and some other text.\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/mark | Mark Demos}\n * @since 6.0.0\n */\nexport const Mark = forwardRef<HTMLElement, MarkProps>(\n function Mark(props, ref) {\n const { children, className, ...remaining } = props;\n return (\n <mark {...remaining} ref={ref} className={mark({ className })}>\n {children}\n </mark>\n );\n }\n);\n"],"names":["forwardRef","mark","Mark","props","ref","children","className","remaining"],"mappings":";AAAA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAASC,IAAI,QAAQ,kBAAkB;AASvC;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,qBAAOF,WAClB,SAASE,KAAKC,KAAK,EAAEC,GAAG;IACtB,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,WAAW,GAAGJ;IAC9C,qBACE,KAACF;QAAM,GAAGM,SAAS;QAAEH,KAAKA;QAAKE,WAAWL,KAAK;YAAEK;QAAU;kBACxDD;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/typography/Mark.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { type MarkClassNameOptions, mark } from \"./markStyles.js\";\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Extends MarkClassNameOptions for CSSProperties module\n * augmentation.\n */\nexport interface MarkProps\n extends HTMLAttributes<HTMLElement>,\n MarkClassNameOptions {\n children: ReactNode;\n}\n\n/**\n * The `Mark` component can be used in place of the `mark` HTMLElement with\n * some default styles.\n *\n * @example Simple Example\n * ```tsx\n * import { Mark } from \"@react-md/core/typography/Mark\";\n *\n * export function Example() {\n * return (\n * <>\n * Some text <Mark>that has highlights</Mark> and some other text.\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/mark | Mark Demos}\n * @since 6.0.0\n */\nexport const Mark = forwardRef<HTMLElement, MarkProps>(\n function Mark(props, ref) {\n const { children, className, ...remaining } = props;\n return (\n <mark {...remaining} ref={ref} className={mark({ className })}>\n {children}\n </mark>\n );\n }\n);\n"],"names":["forwardRef","mark","Mark","props","ref","children","className","remaining"],"mappings":";AAAA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAAoCC,IAAI,QAAQ,kBAAkB;AAalE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,qBAAOF,WAClB,SAASE,KAAKC,KAAK,EAAEC,GAAG;IACtB,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,WAAW,GAAGJ;IAC9C,qBACE,KAACF;QAAM,GAAGM,SAAS;QAAEH,KAAKA;QAAKE,WAAWL,KAAK;YAAEK;QAAU;kBACxDD;;AAGP,GACA"}
@@ -1,11 +1,5 @@
1
1
  import { type HTMLAttributes } from "react";
2
2
  import { type TextContainerClassNameOptions } from "./textContainerStyles.js";
3
- declare module "react" {
4
- interface CSSProperties {
5
- "--rmd-line-length"?: string | number;
6
- "--rmd-text-container-padding"?: string | number;
7
- }
8
- }
9
3
  /**
10
4
  * @since 6.0.0 Removed the `size` option since there is no longer a
11
5
  * different line-length for mobile and desktop.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/TextContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport {\n type TextContainerClassNameOptions,\n textContainer,\n} from \"./textContainerStyles.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-line-length\"?: string | number;\n \"--rmd-text-container-padding\"?: string | number;\n }\n}\n\n/**\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport interface TextContainerProps\n extends HTMLAttributes<HTMLDivElement>,\n TextContainerClassNameOptions {}\n\n/**\n * This component should be used to render text based content with an\n * appropriate max line length to optimize legibility.\n *\n * @example Simple Example\n * ```tsx\n * import { TextContainer } from \"@react-md/core/typography/TextContainer\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <TextContainer>\n * <Typography type=\"headline-1\">Heading</Typography>\n * <Typography>\n * Pretend this is a giant paragraph of text that wraps multiple lines.\n * </Typography>\n * <Typography>\n * Pretend this is another giant paragraph of text that wraps multiple\n * lines.\n * </Typography>\n * </TextContainer>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/text-container | TextContainer Demos}\n * @see {@link textContainer} If you only want to apply this class to an\n * element.\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport const TextContainer = forwardRef<HTMLDivElement, TextContainerProps>(\n function TextContainer(props, ref) {\n const { className, children, ...remaining } = props;\n\n return (\n <div {...remaining} ref={ref} className={textContainer({ className })}>\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","textContainer","TextContainer","props","ref","className","children","remaining","div"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAEEC,aAAa,QACR,2BAA2B;AAmBlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCC,GACD,OAAO,MAAMC,8BAAgBF,WAC3B,SAASE,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAE9C,qBACE,KAACK;QAAK,GAAGD,SAAS;QAAEH,KAAKA;QAAKC,WAAWJ,cAAc;YAAEI;QAAU;kBAChEC;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/typography/TextContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport {\n type TextContainerClassNameOptions,\n textContainer,\n} from \"./textContainerStyles.js\";\n\n/**\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport interface TextContainerProps\n extends HTMLAttributes<HTMLDivElement>,\n TextContainerClassNameOptions {}\n\n/**\n * This component should be used to render text based content with an\n * appropriate max line length to optimize legibility.\n *\n * @example Simple Example\n * ```tsx\n * import { TextContainer } from \"@react-md/core/typography/TextContainer\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <TextContainer>\n * <Typography type=\"headline-1\">Heading</Typography>\n * <Typography>\n * Pretend this is a giant paragraph of text that wraps multiple lines.\n * </Typography>\n * <Typography>\n * Pretend this is another giant paragraph of text that wraps multiple\n * lines.\n * </Typography>\n * </TextContainer>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/text-container | TextContainer Demos}\n * @see {@link textContainer} If you only want to apply this class to an\n * element.\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport const TextContainer = forwardRef<HTMLDivElement, TextContainerProps>(\n function TextContainer(props, ref) {\n const { className, children, ...remaining } = props;\n\n return (\n <div {...remaining} ref={ref} className={textContainer({ className })}>\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","textContainer","TextContainer","props","ref","className","children","remaining","div"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAEEC,aAAa,QACR,2BAA2B;AAYlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCC,GACD,OAAO,MAAMC,8BAAgBF,WAC3B,SAASE,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAE9C,qBACE,KAACK;QAAK,GAAGD,SAAS;QAAEH,KAAKA;QAAKC,WAAWJ,cAAc;YAAEI;QAAU;kBAChEC;;AAGP,GACA"}
@@ -1,3 +1,8 @@
1
+ declare module "react" {
2
+ interface CSSProperties {
3
+ "--rmd-mark-color"?: string;
4
+ }
5
+ }
1
6
  /**
2
7
  * @since 6.0.0
3
8
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/markStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-mark\");\n\n/**\n * @since 6.0.0\n */\nexport interface MarkClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function mark(options: MarkClassNameOptions = {}): string {\n const { className } = options;\n return cnb(styles(), className);\n}\n"],"names":["cnb","bem","styles","mark","options","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AASnB;;CAEC,GACD,OAAO,SAASE,KAAKC,UAAgC,CAAC,CAAC;IACrD,MAAM,EAAEC,SAAS,EAAE,GAAGD;IACtB,OAAOJ,IAAIE,UAAUG;AACvB"}
1
+ {"version":3,"sources":["../../src/typography/markStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-mark\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-mark-color\"?: string;\n }\n}\n\n/**\n * @since 6.0.0\n */\nexport interface MarkClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function mark(options: MarkClassNameOptions = {}): string {\n const { className } = options;\n return cnb(styles(), className);\n}\n"],"names":["cnb","bem","styles","mark","options","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAenB;;CAEC,GACD,OAAO,SAASE,KAAKC,UAAgC,CAAC,CAAC;IACrD,MAAM,EAAEC,SAAS,EAAE,GAAGD;IACtB,OAAOJ,IAAIE,UAAUG;AACvB"}
@@ -1,3 +1,9 @@
1
+ declare module "react" {
2
+ interface CSSProperties {
3
+ "--rmd-line-length"?: string | number;
4
+ "--rmd-text-container-padding"?: string | number;
5
+ }
6
+ }
1
7
  /**
2
8
  * @since 6.0.0
3
9
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/textContainerStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-text-container\");\n\n/**\n * @since 6.0.0\n */\nexport interface TextContainerClassNameOptions {\n /**\n * An optional className to merge with typography text container styles.\n */\n className?: string;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { textContainer } from \"@react-md/core/typography/textContainerStyles\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <main className={textContainer()}>\n * <Typography type=\"headline-1\">Heading</Typography>\n * <Typography>\n * Pretend this is a giant paragraph of text that wraps multiple lines.\n * </Typography>\n * <Typography>\n * Pretend this is another giant paragraph of text that wraps multiple\n * lines.\n * </Typography>\n * </main>\n * ):\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function textContainer(\n options: TextContainerClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(), className);\n}\n"],"names":["cnb","bem","styles","textContainer","options","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAYnB;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASE,cACdC,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOJ,IAAIE,UAAUG;AACvB"}
1
+ {"version":3,"sources":["../../src/typography/textContainerStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-text-container\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-line-length\"?: string | number;\n \"--rmd-text-container-padding\"?: string | number;\n }\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TextContainerClassNameOptions {\n /**\n * An optional className to merge with typography text container styles.\n */\n className?: string;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { textContainer } from \"@react-md/core/typography/textContainerStyles\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <main className={textContainer()}>\n * <Typography type=\"headline-1\">Heading</Typography>\n * <Typography>\n * Pretend this is a giant paragraph of text that wraps multiple lines.\n * </Typography>\n * <Typography>\n * Pretend this is another giant paragraph of text that wraps multiple\n * lines.\n * </Typography>\n * </main>\n * ):\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function textContainer(\n options: TextContainerClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(), className);\n}\n"],"names":["cnb","bem","styles","textContainer","options","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAmBnB;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASE,cACdC,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOJ,IAAIE,UAAUG;AACvB"}
@@ -1,4 +1,13 @@
1
1
  import { type TextCssUtilsOptions } from "../cssUtils.js";
2
+ declare module "react" {
3
+ interface CSSProperties {
4
+ "--rmd-font-size"?: string;
5
+ "--rmd-font-family"?: string;
6
+ "--rmd-font-weight"?: string | number;
7
+ "--rmd-font-height"?: string | number;
8
+ "--rmd-font-line-height"?: string | number;
9
+ }
10
+ }
2
11
  /**
3
12
  * A union of all the material design provided typography styles. When used with
4
13
  * the Typography component, this will generate the correct typography className
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/typographyStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type TextCssUtilsOptions, cssUtils } from \"../cssUtils.js\";\n\n/**\n * A union of all the material design provided typography styles. When used with\n * the Typography component, this will generate the correct typography className\n * to apply and determine what component to be rendered as if none was provided.\n *\n * @since 4.0.0\n */\nexport type TypographyType =\n | \"headline-1\"\n | \"headline-2\"\n | \"headline-3\"\n | \"headline-4\"\n | \"headline-5\"\n | \"headline-6\"\n | \"subtitle-1\"\n | \"subtitle-2\"\n | \"body-1\"\n | \"body-2\"\n | \"caption\"\n | \"overline\";\n\n/** @since 6.0.0 */\nexport interface TypographyClassNameOptions extends TextCssUtilsOptions {\n className?: string;\n\n /**\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType;\n}\n\n/** @since 6.0.0 */\nexport type NullableTypographyClassNameOptions = Omit<\n TypographyClassNameOptions,\n \"type\"\n> & {\n /**\n * When using the {@link typography} class name utility, the `type` can be set\n * to `null` to inherit font.\n *\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType | null;\n};\n\n/**\n * Get a typography class name based on different typography options. This is\n * only useful if you are unable to use the {@link Typography} component for\n * some reason.\n *\n * @example Simple Example\n * ```ts\n * import { typography } from \"@react-md/core/typography/typographyStyles\";\n *\n * function Example() {\n * return (\n * <>\n * <h1 className={typography({ type: \"headline-1\" })} />\n * <h2 className={typography({ type: \"headline-2\" })} />\n * <h3 className={typography({ type: \"headline-3\" })} />\n * <h4 className={typography({ type: \"headline-4\" })} />\n * <h5 className={typography({ type: \"headline-5\" })} />\n * <h6 className={typography({ type: \"headline-6\" })} />\n * <h5 className={typography({ type: \"subtitle-1\" })} />\n * <h6 className={typography({ type: \"subtitle-2\" })} />\n * <p className={typography()} />\n * <p className={typography({ type \"body-1\" })} />\n * <p className={typography({ type \"body-1\" })} />\n * <caption className={typography({ type: \"caption\" })} />\n * <span className={typography({ type: \"overline\" })} />\n * </>\n * );\n * }\n * ```\n *\n * @example Applying Additional Styles\n * ```ts\n * import { typography } from \"@react-md/core/typography/typographyStyles\";\n *\n * function Example() {\n * return (\n * <>\n * <h1\n * // only maintain the default margin-bottom\n * className={typography({\n * type: \"headline-1\",\n * margin: \"bottom\",\n * })}\n * />\n *\n * <h2\n * // remove all default margin\n * className={typography({\n * type: \"headline-2\",\n * margin: \"none\",\n * })}\n * />\n *\n * <h3\n * // only maintain the default margin-top\n * className={typography({\n * type: \"headline-3\",\n * margin: \"top\",\n * })}\n * />\n *\n * <p\n * // center the text, set to bold, and only maintain default margin-bottom\n * className={typography({\n * type \"subtitle-1\",\n * align: \"center\",\n * margin: \"bottom\",\n * })}\n * />\n * </>\n * );\n * }\n * ```\n *\n * @see {@link Typography}\n * @param options - An optional object of options used to create the typography\n * class name.\n * @returns a typography class name string\n * @since 6.0.0\n */\nexport function typography(\n options: NullableTypographyClassNameOptions = {}\n): string {\n const { type = \"body-1\" } = options;\n\n // using `&&` instead of `bem` since the latest version of typescript does not\n // support setting the same object key (empty string)\n return cnb(\n \"rmd-typography\",\n type && `rmd-typography--${type}`,\n cssUtils(options)\n );\n}\n"],"names":["cnb","cssUtils","typography","options","type"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAAmCC,QAAQ,QAAQ,iBAAiB;AAiDpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EC,GACD,OAAO,SAASC,WACdC,UAA8C,CAAC,CAAC;IAEhD,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGD;IAE5B,8EAA8E;IAC9E,qDAAqD;IACrD,OAAOH,IACL,kBACAI,QAAQ,CAAC,gBAAgB,EAAEA,MAAM,EACjCH,SAASE;AAEb"}
1
+ {"version":3,"sources":["../../src/typography/typographyStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type TextCssUtilsOptions, cssUtils } from \"../cssUtils.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-font-size\"?: string;\n \"--rmd-font-family\"?: string;\n \"--rmd-font-weight\"?: string | number;\n \"--rmd-font-height\"?: string | number;\n \"--rmd-font-line-height\"?: string | number;\n }\n}\n\n/**\n * A union of all the material design provided typography styles. When used with\n * the Typography component, this will generate the correct typography className\n * to apply and determine what component to be rendered as if none was provided.\n *\n * @since 4.0.0\n */\nexport type TypographyType =\n | \"headline-1\"\n | \"headline-2\"\n | \"headline-3\"\n | \"headline-4\"\n | \"headline-5\"\n | \"headline-6\"\n | \"subtitle-1\"\n | \"subtitle-2\"\n | \"body-1\"\n | \"body-2\"\n | \"caption\"\n | \"overline\";\n\n/** @since 6.0.0 */\nexport interface TypographyClassNameOptions extends TextCssUtilsOptions {\n className?: string;\n\n /**\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType;\n}\n\n/** @since 6.0.0 */\nexport type NullableTypographyClassNameOptions = Omit<\n TypographyClassNameOptions,\n \"type\"\n> & {\n /**\n * When using the {@link typography} class name utility, the `type` can be set\n * to `null` to inherit font.\n *\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType | null;\n};\n\n/**\n * Get a typography class name based on different typography options. This is\n * only useful if you are unable to use the {@link Typography} component for\n * some reason.\n *\n * @example Simple Example\n * ```ts\n * import { typography } from \"@react-md/core/typography/typographyStyles\";\n *\n * function Example() {\n * return (\n * <>\n * <h1 className={typography({ type: \"headline-1\" })} />\n * <h2 className={typography({ type: \"headline-2\" })} />\n * <h3 className={typography({ type: \"headline-3\" })} />\n * <h4 className={typography({ type: \"headline-4\" })} />\n * <h5 className={typography({ type: \"headline-5\" })} />\n * <h6 className={typography({ type: \"headline-6\" })} />\n * <h5 className={typography({ type: \"subtitle-1\" })} />\n * <h6 className={typography({ type: \"subtitle-2\" })} />\n * <p className={typography()} />\n * <p className={typography({ type \"body-1\" })} />\n * <p className={typography({ type \"body-1\" })} />\n * <caption className={typography({ type: \"caption\" })} />\n * <span className={typography({ type: \"overline\" })} />\n * </>\n * );\n * }\n * ```\n *\n * @example Applying Additional Styles\n * ```ts\n * import { typography } from \"@react-md/core/typography/typographyStyles\";\n *\n * function Example() {\n * return (\n * <>\n * <h1\n * // only maintain the default margin-bottom\n * className={typography({\n * type: \"headline-1\",\n * margin: \"bottom\",\n * })}\n * />\n *\n * <h2\n * // remove all default margin\n * className={typography({\n * type: \"headline-2\",\n * margin: \"none\",\n * })}\n * />\n *\n * <h3\n * // only maintain the default margin-top\n * className={typography({\n * type: \"headline-3\",\n * margin: \"top\",\n * })}\n * />\n *\n * <p\n * // center the text, set to bold, and only maintain default margin-bottom\n * className={typography({\n * type \"subtitle-1\",\n * align: \"center\",\n * margin: \"bottom\",\n * })}\n * />\n * </>\n * );\n * }\n * ```\n *\n * @see {@link Typography}\n * @param options - An optional object of options used to create the typography\n * class name.\n * @returns a typography class name string\n * @since 6.0.0\n */\nexport function typography(\n options: NullableTypographyClassNameOptions = {}\n): string {\n const { type = \"body-1\" } = options;\n\n // using `&&` instead of `bem` since the latest version of typescript does not\n // support setting the same object key (empty string)\n return cnb(\n \"rmd-typography\",\n type && `rmd-typography--${type}`,\n cssUtils(options)\n );\n}\n"],"names":["cnb","cssUtils","typography","options","type"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAAmCC,QAAQ,QAAQ,iBAAiB;AA2DpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EC,GACD,OAAO,SAASC,WACdC,UAA8C,CAAC,CAAC;IAEhD,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGD;IAE5B,8EAA8E;IAC9E,qDAAqD;IACrD,OAAOH,IACL,kBACAI,QAAQ,CAAC,gBAAgB,EAAEA,MAAM,EACjCH,SAASE;AAEb"}