@react-md/core 1.0.0-next.16 → 1.0.0-next.18

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 (665) hide show
  1. package/dist/_box-shadows.scss +76 -0
  2. package/dist/_colors.scss +279 -277
  3. package/dist/_core.scss +107 -16
  4. package/dist/_object-fit.scss +86 -0
  5. package/dist/_utils.scss +246 -72
  6. package/dist/app-bar/AppBar.d.ts +1 -90
  7. package/dist/app-bar/AppBar.js +1 -40
  8. package/dist/app-bar/AppBar.js.map +1 -1
  9. package/dist/app-bar/AppBarTitle.d.ts +1 -27
  10. package/dist/app-bar/AppBarTitle.js +1 -15
  11. package/dist/app-bar/AppBarTitle.js.map +1 -1
  12. package/dist/app-bar/_app-bar.scss +156 -25
  13. package/dist/app-bar/styles.d.ts +117 -0
  14. package/dist/app-bar/styles.js +55 -0
  15. package/dist/app-bar/styles.js.map +1 -0
  16. package/dist/autocomplete/Autocomplete.d.ts +8 -79
  17. package/dist/autocomplete/Autocomplete.js +112 -83
  18. package/dist/autocomplete/Autocomplete.js.map +1 -1
  19. package/dist/autocomplete/AutocompleteChip.d.ts +8 -0
  20. package/dist/autocomplete/AutocompleteChip.js +34 -0
  21. package/dist/autocomplete/AutocompleteChip.js.map +1 -0
  22. package/dist/autocomplete/AutocompleteCircularProgress.d.ts +5 -11
  23. package/dist/autocomplete/AutocompleteCircularProgress.js +4 -0
  24. package/dist/autocomplete/AutocompleteCircularProgress.js.map +1 -1
  25. package/dist/autocomplete/AutocompleteClearButton.d.ts +9 -0
  26. package/dist/autocomplete/AutocompleteClearButton.js +29 -0
  27. package/dist/autocomplete/AutocompleteClearButton.js.map +1 -0
  28. package/dist/autocomplete/AutocompleteDropdownButton.d.ts +4 -26
  29. package/dist/autocomplete/AutocompleteDropdownButton.js +5 -1
  30. package/dist/autocomplete/AutocompleteDropdownButton.js.map +1 -1
  31. package/dist/autocomplete/AutocompleteListboxChildren.d.ts +22 -0
  32. package/dist/autocomplete/AutocompleteListboxChildren.js +37 -0
  33. package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -0
  34. package/dist/autocomplete/_autocomplete.scss +362 -34
  35. package/dist/autocomplete/autocompleteStyles.d.ts +22 -0
  36. package/dist/autocomplete/autocompleteStyles.js +17 -8
  37. package/dist/autocomplete/autocompleteStyles.js.map +1 -1
  38. package/dist/autocomplete/defaults.d.ts +9 -9
  39. package/dist/autocomplete/defaults.js +13 -13
  40. package/dist/autocomplete/defaults.js.map +1 -1
  41. package/dist/autocomplete/types.d.ts +554 -56
  42. package/dist/autocomplete/types.js.map +1 -1
  43. package/dist/autocomplete/useAutocomplete.d.ts +22 -0
  44. package/dist/autocomplete/useAutocomplete.js +281 -0
  45. package/dist/autocomplete/useAutocomplete.js.map +1 -0
  46. package/dist/autocomplete/utils.d.ts +81 -0
  47. package/dist/autocomplete/utils.js +108 -0
  48. package/dist/autocomplete/utils.js.map +1 -0
  49. package/dist/avatar/_avatar.scss +93 -2
  50. package/dist/badge/Badge.d.ts +1 -20
  51. package/dist/badge/Badge.js +1 -14
  52. package/dist/badge/Badge.js.map +1 -1
  53. package/dist/badge/_badge.scss +90 -3
  54. package/dist/badge/styles.d.ts +26 -0
  55. package/dist/badge/styles.js +18 -0
  56. package/dist/badge/styles.js.map +1 -0
  57. package/dist/box/Box.js +2 -1
  58. package/dist/box/Box.js.map +1 -1
  59. package/dist/box/_box.scss +130 -17
  60. package/dist/box/styles.d.ts +6 -0
  61. package/dist/box/styles.js +2 -1
  62. package/dist/box/styles.js.map +1 -1
  63. package/dist/button/AsyncButton.d.ts +1 -1
  64. package/dist/button/AsyncButton.js.map +1 -1
  65. package/dist/button/Button.d.ts +2 -1
  66. package/dist/button/Button.js +2 -1
  67. package/dist/button/Button.js.map +1 -1
  68. package/dist/button/_button.scss +157 -25
  69. package/dist/card/Card.d.ts +16 -0
  70. package/dist/card/Card.js +11 -3
  71. package/dist/card/Card.js.map +1 -1
  72. package/dist/card/ClickableCard.d.ts +2 -1
  73. package/dist/card/ClickableCard.js +5 -2
  74. package/dist/card/ClickableCard.js.map +1 -1
  75. package/dist/card/_card.scss +90 -19
  76. package/dist/card/styles.d.ts +0 -7
  77. package/dist/card/styles.js +2 -3
  78. package/dist/card/styles.js.map +1 -1
  79. package/dist/chip/Chip.d.ts +2 -1
  80. package/dist/chip/Chip.js +2 -1
  81. package/dist/chip/Chip.js.map +1 -1
  82. package/dist/chip/_chip.scss +45 -22
  83. package/dist/chip/styles.d.ts +12 -10
  84. package/dist/chip/styles.js.map +1 -1
  85. package/dist/cssUtils.js.map +1 -1
  86. package/dist/delegateEvent.d.ts +2 -2
  87. package/dist/delegateEvent.js.map +1 -1
  88. package/dist/dialog/Dialog.d.ts +8 -21
  89. package/dist/dialog/Dialog.js +27 -27
  90. package/dist/dialog/Dialog.js.map +1 -1
  91. package/dist/dialog/FixedDialog.d.ts +1 -3
  92. package/dist/dialog/FixedDialog.js +0 -8
  93. package/dist/dialog/FixedDialog.js.map +1 -1
  94. package/dist/dialog/_dialog.scss +67 -13
  95. package/dist/dialog/styles.d.ts +56 -0
  96. package/dist/dialog/styles.js +29 -2
  97. package/dist/dialog/styles.js.map +1 -1
  98. package/dist/divider/Divider.d.ts +0 -11
  99. package/dist/divider/Divider.js.map +1 -1
  100. package/dist/divider/_divider.scss +7 -1
  101. package/dist/divider/styles.d.ts +11 -0
  102. package/dist/divider/styles.js.map +1 -1
  103. package/dist/draggable/useDraggable.d.ts +6 -6
  104. package/dist/draggable/useDraggable.js.map +1 -1
  105. package/dist/draggable/utils.d.ts +3 -3
  106. package/dist/draggable/utils.js.map +1 -1
  107. package/dist/expansion-panel/ExpansionPanel.d.ts +1 -1
  108. package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
  109. package/dist/expansion-panel/_expansion-panel.scss +5 -1
  110. package/dist/expansion-panel/useExpansionPanels.js +12 -24
  111. package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
  112. package/dist/{form → files}/FileInput.d.ts +3 -6
  113. package/dist/{form → files}/FileInput.js +3 -6
  114. package/dist/files/FileInput.js.map +1 -0
  115. package/dist/files/_files.scss +22 -0
  116. package/dist/files/styles.d.ts +5 -0
  117. package/dist/files/styles.js +7 -0
  118. package/dist/files/styles.js.map +1 -0
  119. package/dist/{form → files}/useFileUpload.d.ts +7 -9
  120. package/dist/{form → files}/useFileUpload.js +5 -7
  121. package/dist/files/useFileUpload.js.map +1 -0
  122. package/dist/files/utils.d.ts +169 -0
  123. package/dist/files/utils.js +114 -0
  124. package/dist/files/utils.js.map +1 -0
  125. package/dist/{form/fileUtils.d.ts → files/validation.d.ts} +11 -176
  126. package/dist/{form/fileUtils.js → files/validation.js} +10 -135
  127. package/dist/files/validation.js.map +1 -0
  128. package/dist/focus/useFocusContainer.d.ts +2 -2
  129. package/dist/focus/useFocusContainer.js.map +1 -1
  130. package/dist/focus/utils.js.map +1 -1
  131. package/dist/form/FormMessage.js.map +1 -1
  132. package/dist/form/FormMessageContainer.js +4 -2
  133. package/dist/form/FormMessageContainer.js.map +1 -1
  134. package/dist/form/InputToggle.d.ts +2 -1
  135. package/dist/form/InputToggle.js +2 -1
  136. package/dist/form/InputToggle.js.map +1 -1
  137. package/dist/form/InputToggleIcon.js.map +1 -1
  138. package/dist/form/Label.js +2 -2
  139. package/dist/form/Label.js.map +1 -1
  140. package/dist/form/Listbox.d.ts +24 -0
  141. package/dist/form/Listbox.js +46 -0
  142. package/dist/form/Listbox.js.map +1 -0
  143. package/dist/form/ListboxProvider.d.ts +21 -0
  144. package/dist/form/{useListboxProvider.js → ListboxProvider.js} +1 -1
  145. package/dist/form/ListboxProvider.js.map +1 -0
  146. package/dist/form/MenuItemTextField.js +1 -2
  147. package/dist/form/MenuItemTextField.js.map +1 -1
  148. package/dist/form/NativeSelect.js +7 -4
  149. package/dist/form/NativeSelect.js.map +1 -1
  150. package/dist/form/Option.d.ts +49 -10
  151. package/dist/form/Option.js +11 -9
  152. package/dist/form/Option.js.map +1 -1
  153. package/dist/form/Password.js.map +1 -1
  154. package/dist/form/Select.d.ts +2 -2
  155. package/dist/form/Select.js +81 -85
  156. package/dist/form/Select.js.map +1 -1
  157. package/dist/form/SelectedOption.js +2 -1
  158. package/dist/form/SelectedOption.js.map +1 -1
  159. package/dist/form/Slider.d.ts +4 -4
  160. package/dist/form/Slider.js +6 -2
  161. package/dist/form/Slider.js.map +1 -1
  162. package/dist/form/SliderThumb.d.ts +3 -3
  163. package/dist/form/SliderThumb.js.map +1 -1
  164. package/dist/form/SliderValueMarks.d.ts +2 -2
  165. package/dist/form/SliderValueMarks.js.map +1 -1
  166. package/dist/form/SliderValueTooltip.js.map +1 -1
  167. package/dist/form/TextArea.js +1 -2
  168. package/dist/form/TextArea.js.map +1 -1
  169. package/dist/form/TextField.js +1 -2
  170. package/dist/form/TextField.js.map +1 -1
  171. package/dist/form/TextFieldContainer.js +1 -2
  172. package/dist/form/TextFieldContainer.js.map +1 -1
  173. package/dist/form/_form.scss +193 -124
  174. package/dist/form/formMessageContainerStyles.d.ts +10 -0
  175. package/dist/form/formMessageContainerStyles.js +11 -0
  176. package/dist/form/formMessageContainerStyles.js.map +1 -0
  177. package/dist/form/inputToggleStyles.js.map +1 -1
  178. package/dist/form/optionStyles.d.ts +1 -0
  179. package/dist/form/optionStyles.js +2 -2
  180. package/dist/form/optionStyles.js.map +1 -1
  181. package/dist/form/selectUtils.js.map +1 -1
  182. package/dist/form/sliderUtils.d.ts +1 -1
  183. package/dist/form/sliderUtils.js.map +1 -1
  184. package/dist/form/textFieldContainerStyles.d.ts +0 -2
  185. package/dist/form/textFieldContainerStyles.js +1 -2
  186. package/dist/form/textFieldContainerStyles.js.map +1 -1
  187. package/dist/form/types.d.ts +3 -10
  188. package/dist/form/types.js.map +1 -1
  189. package/dist/form/useCheckboxGroup.d.ts +17 -17
  190. package/dist/form/useCheckboxGroup.js +9 -17
  191. package/dist/form/useCheckboxGroup.js.map +1 -1
  192. package/dist/form/useCombobox.d.ts +56 -21
  193. package/dist/form/useCombobox.js +19 -4
  194. package/dist/form/useCombobox.js.map +1 -1
  195. package/dist/form/useEditableCombobox.d.ts +24 -4
  196. package/dist/form/useEditableCombobox.js +5 -0
  197. package/dist/form/useEditableCombobox.js.map +1 -1
  198. package/dist/form/useNumberField.js.map +1 -1
  199. package/dist/form/useRadioGroup.d.ts +6 -6
  200. package/dist/form/useRadioGroup.js.map +1 -1
  201. package/dist/form/useResizingTextArea.js.map +1 -1
  202. package/dist/form/useSelectCombobox.d.ts +3 -4
  203. package/dist/form/useSelectCombobox.js.map +1 -1
  204. package/dist/form/useTextField.d.ts +1 -1
  205. package/dist/form/useTextField.js.map +1 -1
  206. package/dist/form/useTextFieldContainerAddons.js.map +1 -1
  207. package/dist/hoverMode/useHoverMode.d.ts +3 -3
  208. package/dist/hoverMode/useHoverMode.js.map +1 -1
  209. package/dist/hoverMode/useHoverModeProvider.d.ts +4 -4
  210. package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
  211. package/dist/icon/FontIcon.d.ts +4 -2
  212. package/dist/icon/FontIcon.js.map +1 -1
  213. package/dist/icon/TextIconSpacing.d.ts +3 -1
  214. package/dist/icon/TextIconSpacing.js.map +1 -1
  215. package/dist/icon/_icon.scss +151 -2
  216. package/dist/icon/iconConfig.d.ts +10 -0
  217. package/dist/icon/iconConfig.js +7 -0
  218. package/dist/icon/iconConfig.js.map +1 -1
  219. package/dist/icon/materialConfig.js.map +1 -1
  220. package/dist/icon/styles.js.map +1 -1
  221. package/dist/interaction/UserInteractionModeProvider.d.ts +5 -5
  222. package/dist/interaction/UserInteractionModeProvider.js +12 -8
  223. package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
  224. package/dist/interaction/types.d.ts +20 -2
  225. package/dist/interaction/types.js.map +1 -1
  226. package/dist/interaction/useElementInteraction.d.ts +7 -1
  227. package/dist/interaction/useElementInteraction.js +1 -2
  228. package/dist/interaction/useElementInteraction.js.map +1 -1
  229. package/dist/interaction/utils.d.ts +2 -2
  230. package/dist/interaction/utils.js +2 -2
  231. package/dist/interaction/utils.js.map +1 -1
  232. package/dist/layout/LayoutWindowSplitter.js.map +1 -1
  233. package/dist/layout/_layout.scss +23 -10
  234. package/dist/layout/useExpandableLayout.d.ts +3 -3
  235. package/dist/layout/useExpandableLayout.js.map +1 -1
  236. package/dist/layout/useLayoutAppBarHeight.d.ts +2 -3
  237. package/dist/layout/useLayoutAppBarHeight.js.map +1 -1
  238. package/dist/layout/useTemporaryLayout.d.ts +2 -2
  239. package/dist/layout/useTemporaryLayout.js.map +1 -1
  240. package/dist/link/SkipToMainContent.js.map +1 -1
  241. package/dist/list/ListItem.d.ts +2 -1
  242. package/dist/list/ListItem.js +2 -1
  243. package/dist/list/ListItem.js.map +1 -1
  244. package/dist/list/ListItemChildren.js.map +1 -1
  245. package/dist/list/ListItemLink.d.ts +2 -1
  246. package/dist/list/ListItemLink.js +2 -1
  247. package/dist/list/ListItemLink.js.map +1 -1
  248. package/dist/list/_list.scss +6 -5
  249. package/dist/media-queries/_media-queries.scss +12 -0
  250. package/dist/media-queries/appSize.js.map +1 -1
  251. package/dist/media-queries/useMediaQuery.js +3 -1
  252. package/dist/media-queries/useMediaQuery.js.map +1 -1
  253. package/dist/menu/DropdownMenu.js.map +1 -1
  254. package/dist/menu/Menu.d.ts +8 -3
  255. package/dist/menu/Menu.js +2 -1
  256. package/dist/menu/Menu.js.map +1 -1
  257. package/dist/menu/MenuItemButton.js +6 -2
  258. package/dist/menu/MenuItemButton.js.map +1 -1
  259. package/dist/menu/useContextMenu.d.ts +3 -3
  260. package/dist/menu/useContextMenu.js.map +1 -1
  261. package/dist/movement/types.d.ts +5 -5
  262. package/dist/movement/types.js.map +1 -1
  263. package/dist/navigation/CollapsibleNavGroup.d.ts +5 -3
  264. package/dist/navigation/CollapsibleNavGroup.js +3 -4
  265. package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
  266. package/dist/navigation/DefaultNavigationRenderer.d.ts +1 -2
  267. package/dist/navigation/DefaultNavigationRenderer.js +6 -2
  268. package/dist/navigation/DefaultNavigationRenderer.js.map +1 -1
  269. package/dist/navigation/NavItemButton.d.ts +1 -1
  270. package/dist/navigation/NavItemButton.js +1 -0
  271. package/dist/navigation/NavItemButton.js.map +1 -1
  272. package/dist/navigation/NavItemLink.d.ts +3 -2
  273. package/dist/navigation/NavItemLink.js +6 -2
  274. package/dist/navigation/NavItemLink.js.map +1 -1
  275. package/dist/navigation/NavSubheader.d.ts +2 -3
  276. package/dist/navigation/NavSubheader.js.map +1 -1
  277. package/dist/navigation/Navigation.d.ts +1 -1
  278. package/dist/navigation/Navigation.js.map +1 -1
  279. package/dist/navigation/_navigation.scss +6 -5
  280. package/dist/navigation/types.d.ts +54 -6
  281. package/dist/navigation/types.js.map +1 -1
  282. package/dist/navigation/useActiveHeadingId.d.ts +1 -1
  283. package/dist/navigation/useActiveHeadingId.js.map +1 -1
  284. package/dist/navigation/useNavigationExpansion.d.ts +104 -0
  285. package/dist/navigation/useNavigationExpansion.js +77 -0
  286. package/dist/navigation/useNavigationExpansion.js.map +1 -0
  287. package/dist/navigation/utils.d.ts +13 -0
  288. package/dist/navigation/utils.js +36 -0
  289. package/dist/navigation/utils.js.map +1 -0
  290. package/dist/objectFit.d.ts +69 -0
  291. package/dist/objectFit.js +52 -0
  292. package/dist/objectFit.js.map +1 -0
  293. package/dist/overlay/_overlay.scss +2 -1
  294. package/dist/positioning/useFixedPositioning.d.ts +17 -4
  295. package/dist/positioning/useFixedPositioning.js +10 -5
  296. package/dist/positioning/useFixedPositioning.js.map +1 -1
  297. package/dist/positioning/utils.js.map +1 -1
  298. package/dist/progress/LinearProgress.js.map +1 -1
  299. package/dist/progress/_progress.scss +20 -14
  300. package/dist/responsive-item/ResponsiveItem.d.ts +64 -0
  301. package/dist/responsive-item/ResponsiveItem.js +68 -0
  302. package/dist/responsive-item/ResponsiveItem.js.map +1 -0
  303. package/dist/responsive-item/ResponsiveItemOverlay.d.ts +1 -19
  304. package/dist/responsive-item/ResponsiveItemOverlay.js +1 -12
  305. package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
  306. package/dist/responsive-item/_responsive-item.scss +110 -133
  307. package/dist/responsive-item/responsiveItemOverlayStyles.d.ts +19 -0
  308. package/dist/responsive-item/responsiveItemOverlayStyles.js +14 -0
  309. package/dist/responsive-item/responsiveItemOverlayStyles.js.map +1 -0
  310. package/dist/responsive-item/responsiveItemStyles.d.ts +52 -0
  311. package/dist/responsive-item/responsiveItemStyles.js +15 -0
  312. package/dist/responsive-item/responsiveItemStyles.js.map +1 -0
  313. package/dist/scroll/useScrollLock.d.ts +5 -0
  314. package/dist/scroll/useScrollLock.js.map +1 -1
  315. package/dist/searching/utils.d.ts +2 -2
  316. package/dist/searching/utils.js.map +1 -1
  317. package/dist/segmented-button/SegmentedButton.d.ts +2 -1
  318. package/dist/segmented-button/SegmentedButton.js +2 -1
  319. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  320. package/dist/segmented-button/_segmented-button.scss +6 -6
  321. package/dist/sheet/_sheet.scss +18 -6
  322. package/dist/snackbar/ToastManager.js +15 -5
  323. package/dist/snackbar/ToastManager.js.map +1 -1
  324. package/dist/snackbar/_snackbar.scss +30 -17
  325. package/dist/snackbar/useCurrentToastActions.d.ts +5 -5
  326. package/dist/snackbar/useCurrentToastActions.js.map +1 -1
  327. package/dist/table/_table.scss +15 -3
  328. package/dist/table/tableCellStyles.d.ts +7 -3
  329. package/dist/table/tableCellStyles.js +2 -2
  330. package/dist/table/tableCellStyles.js.map +1 -1
  331. package/dist/tabs/Tab.d.ts +2 -1
  332. package/dist/tabs/Tab.js +2 -1
  333. package/dist/tabs/Tab.js.map +1 -1
  334. package/dist/tabs/TabList.d.ts +2 -2
  335. package/dist/tabs/TabList.js.map +1 -1
  336. package/dist/tabs/TabListScrollButton.d.ts +1 -1
  337. package/dist/tabs/TabListScrollButton.js +1 -1
  338. package/dist/tabs/TabListScrollButton.js.map +1 -1
  339. package/dist/tabs/_tabs.scss +30 -9
  340. package/dist/tabs/getTabListScrollToOptions.d.ts +18 -0
  341. package/dist/tabs/getTabListScrollToOptions.js +19 -0
  342. package/dist/tabs/getTabListScrollToOptions.js.map +1 -0
  343. package/dist/tabs/tabStyles.d.ts +3 -0
  344. package/dist/tabs/tabStyles.js.map +1 -1
  345. package/dist/tabs/useTabList.d.ts +1 -8
  346. package/dist/tabs/useTabList.js +1 -0
  347. package/dist/tabs/useTabList.js.map +1 -1
  348. package/dist/tabs/useTabs.d.ts +6 -6
  349. package/dist/tabs/useTabs.js.map +1 -1
  350. package/dist/tabs/utils.d.ts +0 -18
  351. package/dist/tabs/utils.js +0 -15
  352. package/dist/tabs/utils.js.map +1 -1
  353. package/dist/test-utils/ResizeObserver.d.ts +11 -12
  354. package/dist/test-utils/ResizeObserver.js +11 -12
  355. package/dist/test-utils/ResizeObserver.js.map +1 -1
  356. package/dist/test-utils/matchMedia.d.ts +3 -3
  357. package/dist/test-utils/matchMedia.js +6 -6
  358. package/dist/test-utils/matchMedia.js.map +1 -1
  359. package/dist/test-utils/polyfills/TextDecoder.js +0 -1
  360. package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
  361. package/dist/test-utils/timers.d.ts +9 -5
  362. package/dist/test-utils/timers.js +5 -5
  363. package/dist/test-utils/timers.js.map +1 -1
  364. package/dist/theme/LocalStorageColorSchemeProvider.d.ts +1 -1
  365. package/dist/theme/LocalStorageColorSchemeProvider.js +2 -1
  366. package/dist/theme/LocalStorageColorSchemeProvider.js.map +1 -1
  367. package/dist/theme/ThemeProvider.js +3 -1
  368. package/dist/theme/ThemeProvider.js.map +1 -1
  369. package/dist/theme/_a11y.scss +86 -13
  370. package/dist/theme/_colors.scss +279 -277
  371. package/dist/theme/_theme.scss +308 -37
  372. package/dist/theme/isColorScheme.d.ts +16 -0
  373. package/dist/theme/isColorScheme.js +19 -0
  374. package/dist/theme/isColorScheme.js.map +1 -0
  375. package/dist/theme/types.d.ts +53 -1
  376. package/dist/theme/types.js +1 -23
  377. package/dist/theme/types.js.map +1 -1
  378. package/dist/theme/useCSSVariables.d.ts +2 -19
  379. package/dist/theme/useCSSVariables.js.map +1 -1
  380. package/dist/theme/useColorScheme.d.ts +1 -35
  381. package/dist/theme/useColorScheme.js.map +1 -1
  382. package/dist/theme/useColorSchemeMetaTag.d.ts +1 -1
  383. package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
  384. package/dist/theme/useColorSchemeProvider.d.ts +1 -1
  385. package/dist/theme/useColorSchemeProvider.js +1 -1
  386. package/dist/theme/useColorSchemeProvider.js.map +1 -1
  387. package/dist/theme/{usePrefersColorScheme.js → usePrefersDarkScheme.js} +1 -1
  388. package/dist/theme/usePrefersDarkScheme.js.map +1 -0
  389. package/dist/theme/utils.js.map +1 -1
  390. package/dist/tooltip/useTooltip.d.ts +14 -9
  391. package/dist/tooltip/useTooltip.js +2 -1
  392. package/dist/tooltip/useTooltip.js.map +1 -1
  393. package/dist/transition/_transition.scss +16 -9
  394. package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
  395. package/dist/transition/types.d.ts +1 -1
  396. package/dist/transition/types.js.map +1 -1
  397. package/dist/transition/useCarousel.d.ts +3 -3
  398. package/dist/transition/useCarousel.js.map +1 -1
  399. package/dist/transition/useCollapseTransition.js.map +1 -1
  400. package/dist/transition/useTransition.js +1 -0
  401. package/dist/transition/useTransition.js.map +1 -1
  402. package/dist/transition/utils.js.map +1 -1
  403. package/dist/tree/TreeItem.d.ts +2 -1
  404. package/dist/tree/TreeItem.js +4 -3
  405. package/dist/tree/TreeItem.js.map +1 -1
  406. package/dist/tree/TreeItemExpander.js.map +1 -1
  407. package/dist/tree/_tree.scss +8 -6
  408. package/dist/tree/useTreeExpansion.d.ts +1 -1
  409. package/dist/tree/useTreeExpansion.js +6 -18
  410. package/dist/tree/useTreeExpansion.js.map +1 -1
  411. package/dist/tree/useTreeSelection.d.ts +1 -1
  412. package/dist/tree/useTreeSelection.js +7 -25
  413. package/dist/tree/useTreeSelection.js.map +1 -1
  414. package/dist/tree/utils.d.ts +1 -1
  415. package/dist/tree/utils.js.map +1 -1
  416. package/dist/types.d.ts +12 -4
  417. package/dist/types.js.map +1 -1
  418. package/dist/typography/WritingDirectionProvider.d.ts +1 -1
  419. package/dist/typography/WritingDirectionProvider.js.map +1 -1
  420. package/dist/typography/_typography.scss +94 -37
  421. package/dist/typography/typographyStyles.js.map +1 -1
  422. package/dist/useDebouncedFunction.d.ts +1 -5
  423. package/dist/useDebouncedFunction.js +3 -1
  424. package/dist/useDebouncedFunction.js.map +1 -1
  425. package/dist/useDropzone.d.ts +4 -4
  426. package/dist/useDropzone.js.map +1 -1
  427. package/dist/useEnsuredId.js.map +1 -1
  428. package/dist/useIntersectionObserver.d.ts +5 -5
  429. package/dist/useIntersectionObserver.js.map +1 -1
  430. package/dist/useLocalStorage.d.ts +3 -3
  431. package/dist/useLocalStorage.js +1 -1
  432. package/dist/useLocalStorage.js.map +1 -1
  433. package/dist/useMutationObserver.d.ts +1 -1
  434. package/dist/useMutationObserver.js.map +1 -1
  435. package/dist/useOrientation.js +3 -1
  436. package/dist/useOrientation.js.map +1 -1
  437. package/dist/usePageInactive.d.ts +2 -2
  438. package/dist/usePageInactive.js.map +1 -1
  439. package/dist/useReadonlySet.d.ts +76 -0
  440. package/dist/useReadonlySet.js +72 -0
  441. package/dist/useReadonlySet.js.map +1 -0
  442. package/dist/useResizeListener.d.ts +1 -1
  443. package/dist/useResizeListener.js.map +1 -1
  444. package/dist/useResizeObserver.d.ts +19 -0
  445. package/dist/useResizeObserver.js +19 -0
  446. package/dist/useResizeObserver.js.map +1 -1
  447. package/dist/useThrottledFunction.d.ts +1 -5
  448. package/dist/useThrottledFunction.js +3 -1
  449. package/dist/useThrottledFunction.js.map +1 -1
  450. package/dist/useToggle.d.ts +3 -3
  451. package/dist/useToggle.js.map +1 -1
  452. package/dist/utils/RenderRecursively.d.ts +2 -2
  453. package/dist/utils/RenderRecursively.js.map +1 -1
  454. package/dist/utils/alphaNumericSort.d.ts +5 -5
  455. package/dist/utils/alphaNumericSort.js.map +1 -1
  456. package/dist/utils/bem.d.ts +1 -1
  457. package/dist/utils/bem.js +1 -1
  458. package/dist/utils/bem.js.map +1 -1
  459. package/dist/utils/debounce.d.ts +5 -0
  460. package/dist/utils/debounce.js +17 -0
  461. package/dist/utils/debounce.js.map +1 -0
  462. package/dist/utils/nearest.js.map +1 -1
  463. package/dist/utils/parseCssLengthUnit.js.map +1 -1
  464. package/dist/utils/throttle.d.ts +5 -0
  465. package/dist/utils/throttle.js +30 -0
  466. package/dist/utils/throttle.js.map +1 -0
  467. package/dist/utils/wait.js +3 -1
  468. package/dist/utils/wait.js.map +1 -1
  469. package/dist/window-splitter/WindowSplitter.d.ts +37 -15
  470. package/dist/window-splitter/WindowSplitter.js +38 -17
  471. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  472. package/dist/window-splitter/_window-splitter.scss +32 -14
  473. package/dist/window-splitter/styles.d.ts +14 -0
  474. package/dist/window-splitter/styles.js +18 -0
  475. package/dist/window-splitter/styles.js.map +1 -0
  476. package/package.json +25 -24
  477. package/src/app-bar/AppBar.tsx +1 -170
  478. package/src/app-bar/AppBarTitle.tsx +1 -44
  479. package/src/app-bar/styles.ts +206 -0
  480. package/src/autocomplete/Autocomplete.tsx +194 -211
  481. package/src/autocomplete/AutocompleteChip.tsx +48 -0
  482. package/src/autocomplete/AutocompleteCircularProgress.tsx +6 -17
  483. package/src/autocomplete/AutocompleteClearButton.tsx +44 -0
  484. package/src/autocomplete/AutocompleteDropdownButton.tsx +16 -37
  485. package/src/autocomplete/AutocompleteListboxChildren.tsx +68 -0
  486. package/src/autocomplete/autocompleteStyles.ts +48 -9
  487. package/src/autocomplete/defaults.ts +26 -17
  488. package/src/autocomplete/types.ts +744 -61
  489. package/src/autocomplete/useAutocomplete.ts +428 -0
  490. package/src/autocomplete/utils.ts +211 -0
  491. package/src/badge/Badge.tsx +1 -39
  492. package/src/badge/styles.ts +45 -0
  493. package/src/box/Box.tsx +11 -9
  494. package/src/box/styles.ts +14 -5
  495. package/src/button/AsyncButton.tsx +1 -1
  496. package/src/button/Button.tsx +5 -1
  497. package/src/card/Card.tsx +35 -4
  498. package/src/card/ClickableCard.tsx +9 -2
  499. package/src/card/styles.ts +1 -10
  500. package/src/chip/Chip.tsx +6 -1
  501. package/src/chip/styles.ts +12 -10
  502. package/src/delegateEvent.ts +5 -5
  503. package/src/dialog/Dialog.tsx +48 -61
  504. package/src/dialog/FixedDialog.tsx +1 -11
  505. package/src/dialog/styles.ts +97 -0
  506. package/src/divider/Divider.tsx +0 -12
  507. package/src/divider/styles.ts +12 -0
  508. package/src/draggable/useDraggable.ts +17 -10
  509. package/src/draggable/utils.ts +3 -3
  510. package/src/expansion-panel/ExpansionPanel.tsx +1 -1
  511. package/src/expansion-panel/useExpansionPanels.ts +18 -27
  512. package/src/{form → files}/FileInput.tsx +7 -15
  513. package/src/files/styles.ts +10 -0
  514. package/src/{form → files}/useFileUpload.ts +30 -34
  515. package/src/files/utils.ts +234 -0
  516. package/src/{form/fileUtils.ts → files/validation.ts} +15 -244
  517. package/src/focus/useFocusContainer.ts +16 -8
  518. package/src/form/FormMessageContainer.tsx +2 -2
  519. package/src/form/InputToggle.tsx +5 -1
  520. package/src/form/Label.tsx +18 -18
  521. package/src/form/Listbox.tsx +87 -0
  522. package/src/form/ListboxProvider.ts +37 -0
  523. package/src/form/MenuItemTextField.tsx +1 -2
  524. package/src/form/NativeSelect.tsx +14 -10
  525. package/src/form/Option.tsx +74 -22
  526. package/src/form/Select.tsx +89 -85
  527. package/src/form/SelectedOption.tsx +2 -0
  528. package/src/form/Slider.tsx +14 -11
  529. package/src/form/SliderThumb.tsx +4 -4
  530. package/src/form/SliderValueMarks.tsx +4 -4
  531. package/src/form/TextArea.tsx +6 -8
  532. package/src/form/TextField.tsx +0 -2
  533. package/src/form/TextFieldContainer.tsx +9 -11
  534. package/src/form/formMessageContainerStyles.ts +22 -0
  535. package/src/form/optionStyles.ts +7 -2
  536. package/src/form/sliderUtils.ts +1 -1
  537. package/src/form/textFieldContainerStyles.ts +9 -14
  538. package/src/form/types.ts +3 -11
  539. package/src/form/useCheckboxGroup.ts +28 -36
  540. package/src/form/useCombobox.ts +86 -38
  541. package/src/form/useEditableCombobox.ts +43 -8
  542. package/src/form/useRadioGroup.ts +6 -6
  543. package/src/form/useSelectCombobox.ts +4 -4
  544. package/src/form/useTextField.ts +1 -1
  545. package/src/hoverMode/useHoverMode.ts +3 -3
  546. package/src/hoverMode/useHoverModeProvider.ts +4 -4
  547. package/src/icon/FontIcon.tsx +4 -2
  548. package/src/icon/TextIconSpacing.tsx +1 -1
  549. package/src/icon/iconConfig.tsx +12 -0
  550. package/src/interaction/UserInteractionModeProvider.tsx +12 -8
  551. package/src/interaction/types.ts +21 -2
  552. package/src/interaction/useElementInteraction.tsx +9 -2
  553. package/src/interaction/utils.ts +7 -7
  554. package/src/layout/useExpandableLayout.ts +3 -3
  555. package/src/layout/useLayoutAppBarHeight.ts +3 -4
  556. package/src/layout/useTemporaryLayout.ts +2 -2
  557. package/src/list/ListItem.tsx +5 -1
  558. package/src/list/ListItemLink.tsx +5 -1
  559. package/src/media-queries/useMediaQuery.ts +2 -1
  560. package/src/menu/Menu.tsx +11 -3
  561. package/src/menu/MenuItemButton.tsx +7 -1
  562. package/src/menu/useContextMenu.ts +3 -3
  563. package/src/movement/types.ts +5 -5
  564. package/src/navigation/CollapsibleNavGroup.tsx +16 -8
  565. package/src/navigation/DefaultNavigationRenderer.tsx +8 -6
  566. package/src/navigation/NavItemButton.tsx +2 -1
  567. package/src/navigation/NavItemLink.tsx +11 -3
  568. package/src/navigation/NavSubheader.tsx +1 -1
  569. package/src/navigation/Navigation.tsx +1 -1
  570. package/src/navigation/types.ts +60 -10
  571. package/src/navigation/useActiveHeadingId.ts +1 -1
  572. package/src/navigation/useNavigationExpansion.ts +170 -0
  573. package/src/navigation/utils.ts +47 -0
  574. package/src/objectFit.ts +88 -0
  575. package/src/positioning/useFixedPositioning.ts +34 -11
  576. package/src/responsive-item/ResponsiveItem.tsx +96 -0
  577. package/src/responsive-item/ResponsiveItemOverlay.tsx +6 -46
  578. package/src/responsive-item/responsiveItemOverlayStyles.ts +46 -0
  579. package/src/responsive-item/responsiveItemStyles.ts +81 -0
  580. package/src/scroll/useScrollLock.ts +6 -0
  581. package/src/searching/utils.ts +3 -3
  582. package/src/segmented-button/SegmentedButton.tsx +5 -1
  583. package/src/snackbar/ToastManager.tsx +16 -5
  584. package/src/snackbar/useCurrentToastActions.ts +5 -5
  585. package/src/table/tableCellStyles.ts +10 -6
  586. package/src/tabs/Tab.tsx +4 -1
  587. package/src/tabs/TabList.tsx +2 -2
  588. package/src/tabs/TabListScrollButton.tsx +4 -4
  589. package/src/tabs/getTabListScrollToOptions.ts +37 -0
  590. package/src/tabs/tabStyles.ts +4 -0
  591. package/src/tabs/useTabList.ts +2 -9
  592. package/src/tabs/useTabs.ts +6 -6
  593. package/src/tabs/utils.ts +0 -38
  594. package/src/test-utils/ResizeObserver.ts +11 -12
  595. package/src/test-utils/matchMedia.ts +7 -7
  596. package/src/test-utils/polyfills/TextDecoder.ts +0 -1
  597. package/src/test-utils/timers.ts +10 -7
  598. package/src/theme/LocalStorageColorSchemeProvider.tsx +4 -4
  599. package/src/theme/ThemeProvider.tsx +3 -3
  600. package/src/theme/isColorScheme.ts +22 -0
  601. package/src/theme/types.ts +67 -1
  602. package/src/theme/useCSSVariables.ts +7 -30
  603. package/src/theme/useColorScheme.ts +1 -40
  604. package/src/theme/useColorSchemeMetaTag.ts +1 -1
  605. package/src/theme/useColorSchemeProvider.ts +2 -2
  606. package/src/tooltip/useTooltip.ts +17 -9
  607. package/src/transition/types.ts +1 -1
  608. package/src/transition/useCarousel.ts +3 -3
  609. package/src/transition/useTransition.ts +1 -0
  610. package/src/tree/TreeItem.tsx +7 -1
  611. package/src/tree/TreeItemExpander.tsx +1 -1
  612. package/src/tree/useTreeExpansion.ts +7 -25
  613. package/src/tree/useTreeSelection.ts +8 -32
  614. package/src/tree/utils.ts +6 -2
  615. package/src/types.ts +20 -4
  616. package/src/typography/WritingDirectionProvider.tsx +1 -1
  617. package/src/useDebouncedFunction.ts +4 -9
  618. package/src/useDropzone.ts +4 -4
  619. package/src/useIntersectionObserver.ts +5 -5
  620. package/src/useLocalStorage.ts +6 -6
  621. package/src/useMutationObserver.ts +1 -1
  622. package/src/useOrientation.ts +3 -1
  623. package/src/usePageInactive.ts +2 -2
  624. package/src/useReadonlySet.ts +122 -0
  625. package/src/useResizeListener.ts +1 -1
  626. package/src/useResizeObserver.ts +19 -0
  627. package/src/useThrottledFunction.ts +6 -9
  628. package/src/useToggle.ts +3 -3
  629. package/src/utils/RenderRecursively.tsx +2 -2
  630. package/src/utils/alphaNumericSort.ts +5 -5
  631. package/src/utils/bem.ts +1 -1
  632. package/src/utils/debounce.ts +22 -0
  633. package/src/utils/throttle.ts +38 -0
  634. package/src/utils/wait.ts +5 -1
  635. package/src/window-splitter/WindowSplitter.tsx +38 -43
  636. package/src/window-splitter/styles.ts +42 -0
  637. package/dist/autocomplete/FilterAutocompleteOptions.d.ts +0 -8
  638. package/dist/autocomplete/FilterAutocompleteOptions.js +0 -57
  639. package/dist/autocomplete/FilterAutocompleteOptions.js.map +0 -1
  640. package/dist/dialog/DialogContainer.d.ts +0 -14
  641. package/dist/dialog/DialogContainer.js +0 -20
  642. package/dist/dialog/DialogContainer.js.map +0 -1
  643. package/dist/form/FileInput.js.map +0 -1
  644. package/dist/form/fileUtils.js.map +0 -1
  645. package/dist/form/useFileUpload.js.map +0 -1
  646. package/dist/form/useListboxProvider.d.ts +0 -31
  647. package/dist/form/useListboxProvider.js.map +0 -1
  648. package/dist/navigation/getHrefFromParents.d.ts +0 -5
  649. package/dist/navigation/getHrefFromParents.js +0 -13
  650. package/dist/navigation/getHrefFromParents.js.map +0 -1
  651. package/dist/responsive-item/ResponsiveItemContainer.d.ts +0 -115
  652. package/dist/responsive-item/ResponsiveItemContainer.js +0 -80
  653. package/dist/responsive-item/ResponsiveItemContainer.js.map +0 -1
  654. package/dist/responsive-item/styles.d.ts +0 -34
  655. package/dist/responsive-item/styles.js +0 -17
  656. package/dist/responsive-item/styles.js.map +0 -1
  657. package/dist/theme/usePrefersColorScheme.js.map +0 -1
  658. package/src/autocomplete/FilterAutocompleteOptions.tsx +0 -86
  659. package/src/dialog/DialogContainer.tsx +0 -28
  660. package/src/form/useListboxProvider.ts +0 -45
  661. package/src/navigation/getHrefFromParents.ts +0 -15
  662. package/src/responsive-item/ResponsiveItemContainer.tsx +0 -174
  663. package/src/responsive-item/styles.ts +0 -58
  664. /package/dist/theme/{usePrefersColorScheme.d.ts → usePrefersDarkScheme.d.ts} +0 -0
  665. /package/src/theme/{usePrefersColorScheme.ts → usePrefersDarkScheme.ts} +0 -0
@@ -1,20 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { cnb } from "cnbuilder";
3
- /**
4
- * @since 6.0.0
5
- * @internal
6
- */ export function DialogContainer(props) {
7
- const { className, enabled, children, ...remaining } = props;
8
- if (!enabled) {
9
- return /*#__PURE__*/ _jsx(_Fragment, {
10
- children: children
11
- });
12
- }
13
- return /*#__PURE__*/ _jsx("div", {
14
- ...remaining,
15
- className: cnb("rmd-dialog-container", className),
16
- children: children
17
- });
18
- }
19
-
20
- //# sourceMappingURL=DialogContainer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/dialog/DialogContainer.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { type HTMLAttributes, type ReactElement, type ReactNode } from \"react\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface DialogContainerProps extends HTMLAttributes<HTMLDivElement> {\n enabled: boolean;\n children: ReactNode;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function DialogContainer(props: DialogContainerProps): ReactElement {\n const { className, enabled, children, ...remaining } = props;\n if (!enabled) {\n return <>{children}</>;\n }\n\n return (\n <div {...remaining} className={cnb(\"rmd-dialog-container\", className)}>\n {children}\n </div>\n );\n}\n"],"names":["cnb","DialogContainer","props","className","enabled","children","remaining","div"],"mappings":";AAAA,SAASA,GAAG,QAAQ,YAAY;AAYhC;;;CAGC,GACD,OAAO,SAASC,gBAAgBC,KAA2B;IACzD,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IACvD,IAAI,CAACE,SAAS;QACZ,qBAAO;sBAAGC;;IACZ;IAEA,qBACE,KAACE;QAAK,GAAGD,SAAS;QAAEH,WAAWH,IAAI,wBAAwBG;kBACxDE;;AAGP"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/form/FileInput.tsx"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport {\n forwardRef,\n type InputHTMLAttributes,\n type LabelHTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport {\n button,\n type ButtonClassNameOptions,\n type ButtonClassNameThemeOptions,\n} from \"../button/buttonStyles.js\";\nimport { getIcon } from \"../icon/iconConfig.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { SrOnly } from \"../typography/SrOnly.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\n\n/** @since 6.0.0 */\nexport type FileInputClassNameOptions = ButtonClassNameOptions;\n\n/** @since 6.0.0 */\nexport function fileInput(options: FileInputClassNameOptions = {}): string {\n return cnb(\"rmd-file-input\", button(options));\n}\n\n/** @since 6.0.0 */\nexport type FileInputHTMLAttributes = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\"\n>;\n\n/**\n * @since 6.0.0 Removed the `disableIconSpacing` prop since it is no\n * longer required.\n */\nexport interface FileInputProps\n extends ButtonClassNameThemeOptions,\n FileInputHTMLAttributes {\n /**\n * This is the label text for icon-only file inputs.\n *\n * @defaultValue `\"Upload\"`\n */\n srOnlyLabel?: ReactNode;\n\n /**\n * Any additional props to provide to the container `<label>` element since\n * most props get passed to the `<input type=\"file\">`. So this would be useful\n * for inline style or click handlers.\n */\n labelProps?: PropsWithRef<\n LabelHTMLAttributes<HTMLLabelElement>,\n HTMLLabelElement\n >;\n\n /**\n * An optional icon to display for the file input.\n *\n * @defaultValue `getIcon(\"upload\")`\n */\n icon?: ReactNode;\n\n /**\n * Boolean if the icon should appear after the children in the label.\n *\n * @defaultValue `false`\n */\n iconAfter?: boolean;\n\n /**\n * Boolean if the file input should no longer allow the same file to be\n * selected multiple times and trigger the `onChange` each time it is\n * selected.\n *\n * @defaultValue `false`\n */\n disableRepeatableFiles?: boolean;\n\n /**\n * Children should generally be provided when the {@link buttonType} is\n * set to `\"text\"`. This defaults to a screen-reader only accessible text.\n *\n * @defaultValue `<SrOnly phoneOnly={responsive}>Upload</SrOnly>`\n */\n children?: ReactNode;\n}\n\n/**\n * **Client Component**\n * This might be able to become a server component if I remove the getIcon hook\n *\n * @example Simple Example\n * ```tsx\n * import { FileInput, Form } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * const extensions = [\n * \"svg\",\n * \"jpeg\",\n * \"jpg\",\n * \"png\",\n * \"apng\",\n * \"mkv\",\n * \"mp4\",\n * \"mpeg\",\n * \"mpg\",\n * \"webm\",\n * \"mov\",\n * ] as const;\n *\n * const FOUR_HUNDRED_MB = 400 * 1024 * 1024;\n * const maxFiles = 10;\n *\n * function Example(): ReactElement {\n * const { stats, errors, onChange, clearErrors, reset, remove, accept } =\n * useFileUpload({\n * maxFiles,\n * maxFileSize: FOUR_HUNDRED_MB,\n * extensions,\n * });\n *\n * return (\n * <Form>\n * <FileInput accept={accept} multiple={maxFiles > 1} onChange={onChange} />\n * <Button onClick={reset} disabled={!stats.length}>\n * Remove all files\n * </Button>\n * </Form>\n * );\n * }\n * ```\n *\n * @since 6.0.0 Added additional support for `iconSize` and\n * `responsive`. Also removed the `disableIconSpacing` prop since it is no\n * longer required.\n */\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n function FileInput(props, ref) {\n const {\n id: propId,\n className,\n children: propChildren,\n icon: propIcon,\n iconAfter = false,\n srOnlyLabel = \"Upload\",\n disableRepeatableFiles = false,\n labelProps,\n theme = \"primary\",\n themeType = \"contained\",\n buttonType = propChildren ? \"text\" : \"icon\",\n disabled = false,\n iconSize,\n responsive,\n multiple = false,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"file-input\");\n const { pressed, pressedClassName, ripples, handlers } =\n useElementInteraction({\n ...labelProps,\n onClick(event) {\n labelProps?.onClick?.(event);\n\n // stop propagation so 2 ripples are not created\n event.stopPropagation();\n },\n disabled,\n });\n\n const icon = getIcon(\"upload\", propIcon);\n let children = propChildren;\n if (\n typeof propChildren === \"undefined\" &&\n !props[\"aria-label\"] &&\n !props[\"aria-labelledby\"]\n ) {\n children = <SrOnly phoneOnly={responsive}>{srOnlyLabel}</SrOnly>;\n }\n\n return (\n <label\n {...labelProps}\n {...handlers}\n className={fileInput({\n theme,\n themeType,\n buttonType,\n disabled,\n iconSize,\n pressed,\n responsive,\n pressedClassName,\n className: className || labelProps?.className,\n })}\n >\n {!iconAfter && icon}\n {children}\n {iconAfter && icon}\n <input\n {...remaining}\n id={id}\n ref={ref}\n value={\n disableRepeatableFiles || !props.onChange ? remaining.value : \"\"\n }\n type=\"file\"\n className=\"rmd-hidden-input\"\n disabled={disabled}\n multiple={multiple}\n />\n {ripples}\n </label>\n );\n }\n);\n"],"names":["cnb","forwardRef","button","getIcon","useElementInteraction","SrOnly","useEnsuredId","fileInput","options","FileInput","props","ref","id","propId","className","children","propChildren","icon","propIcon","iconAfter","srOnlyLabel","disableRepeatableFiles","labelProps","theme","themeType","buttonType","disabled","iconSize","responsive","multiple","remaining","pressed","pressedClassName","ripples","handlers","onClick","event","stopPropagation","phoneOnly","label","input","value","onChange","type"],"mappings":"AAAA;;AACA,SAASA,GAAG,QAAQ,YAAY;AAChC,SACEC,UAAU,QAIL,QAAQ;AACf,SACEC,MAAM,QAGD,4BAA4B;AAC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;YACAC;YACAC;YACAC;YACAI;YACAH;YACAI;YACAlB,WAAWA,aAAaQ,YAAYR;QACtC;;YAEC,CAACK,aAAaF;YACdF;YACAI,aAAaF;0BACd,KAACuB;gBACE,GAAGV,SAAS;gBACblB,IAAIA;gBACJD,KAAKA;gBACL8B,OACEpB,0BAA0B,CAACX,MAAMgC,QAAQ,GAAGZ,UAAUW,KAAK,GAAG;gBAEhEE,MAAK;gBACL7B,WAAU;gBACVY,UAAUA;gBACVG,UAAUA;;YAEXI;;;AAGP,GACA"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/form/fileUtils.ts"],"sourcesContent":["import { nanoid } from \"nanoid\";\nimport { type ChangeEventHandler, type DragEventHandler } from \"react\";\n\n/** @since 2.9.0 */\nexport interface BaseFileUploadStats {\n /**\n * A unique key associated with each upload generated by `nanoid`.\n */\n key: string;\n\n /**\n * The file instance that is being uploaded.\n */\n file: File;\n\n /**\n * The current upload progress as a percentage from 0 - 100 percent.\n */\n progress: number;\n}\n\n/** @since 2.9.0 */\nexport interface ProcessingFileUploadStats extends BaseFileUploadStats {\n status: \"pending\" | \"uploading\";\n}\n\n/** @since 2.9.0 */\nexport type FileReaderResult = FileReader[\"result\"];\n\n/** @since 2.9.0 */\nexport interface CompletedFileUploadStats extends BaseFileUploadStats {\n status: \"complete\";\n\n /**\n * The result after a `FileReader` has read a file completely.\n *\n * Note: This _should_ be an `ArrayBuffer` if the next step is to upload to a\n * server.\n *\n * @see {@link FileReaderParser}\n * @see {@link getFileParser}\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/FileReader | FileReader}\n */\n result: FileReaderResult;\n}\n\n/** @since 2.9.0 */\nexport type FileUploadStats =\n | ProcessingFileUploadStats\n | CompletedFileUploadStats;\n\n/** @since 2.9.0 */\nexport type FileUploadStatus = FileUploadStats[\"status\"];\n\n/** @since 2.9.0 */\nexport interface FileUploadHandlers<E extends HTMLElement> {\n onDrop?: DragEventHandler<E>;\n onChange?: ChangeEventHandler<HTMLInputElement>;\n}\n\n/**\n * An error that will be created if a user tries dragging and dropping files\n * from a shared directory that they do not have access to. This error will not\n * occur much.\n *\n * @since 2.9.0\n */\nexport class FileAccessError extends Error {\n /**\n * A unique key generated by `nanoid` that can be used as a `React` key\n */\n public key: string;\n\n /**\n *\n * @param message - An optional message for the error.\n */\n constructor(message?: string) {\n super(message);\n this.key = nanoid();\n this.name = \"FileAccessError\";\n }\n}\n\n/**\n * An error that just requires a `File` to be passed as the first argument.\n *\n * @since 2.9.0\n */\nexport class GenericFileError extends Error {\n /**\n * A unique key generated by `nanoid` that can be used as a `React` key\n */\n public key: string;\n\n /**\n *\n * @param files - A list of files that caused the error.\n * @param reason - An optional reason for the error\n */\n constructor(\n public files: readonly File[],\n public reason?: string\n ) {\n super(\"Invalid files\");\n this.key = nanoid();\n this.name = \"GenericFileError\";\n }\n}\n\n/**\n * An error that is created during the upload process if the number of files\n * exceeds the {@link FileUploadOptions.maxFiles} amount.\n *\n * @since 2.9.0\n */\nexport class TooManyFilesError extends GenericFileError {\n /**\n *\n * @param files - The list of files that could not be uploaded due to the file\n * limit defined.\n * @param limit - The max limit of files allowed.\n */\n constructor(\n files: readonly File[],\n public limit: number\n ) {\n super(files, \"file limit\");\n this.name = \"TooManyFilesError\";\n }\n}\n\n/**\n * An error that will be created if a user tries to upload a file that\n * is either:\n * - less than the {@link FileValidationOptions.minFileSize}\n * - greater than the {@link FileValidationOptions.maxFileSize}\n * - including the file would be greater than the {@link FileValidationOptions.totalFileSize}\n *\n * @since 2.9.0\n */\nexport class FileSizeError extends GenericFileError {\n /**\n *\n * @param files - The list of files that have the file size error\n * @param type - The file size error type\n * @param limit - The number of bytes allowed based on the type\n */\n constructor(\n files: readonly File[],\n public type: \"min\" | \"max\" | \"total\",\n public limit: number\n ) {\n super(files, \"file size\");\n this.name = \"FileSizeError\";\n }\n}\n\n/**\n * An error that will be created if a user tries to upload a file that does not\n * end with one of the {@link FileValidationOptions.extensions}.\n *\n * @since 2.9.0\n */\nexport class FileExtensionError extends GenericFileError {\n /**\n *\n * @param files - The file that caused the error\n * @param extensions - The allowed list of file extensions\n */\n constructor(\n files: readonly File[],\n public extensions: readonly string[]\n ) {\n super(files, \"extension\");\n this.name = \"FileExtensionError\";\n }\n}\n\n/**\n * Mostly an internal type that is used to allow custom validation errors\n *\n * @since 2.9.0\n */\nexport type FileValidationError<E = GenericFileError> =\n | FileAccessError\n | TooManyFilesError\n | FileSizeError\n | FileExtensionError\n | E;\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link GenericFileError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileAccessError}\n */\nexport function isGenericFileError<CustomError extends {}>(\n error: FileValidationError<CustomError>\n): error is GenericFileError {\n return \"name\" in error && error.name === \"GenericFileError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileAccessError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileAccessError}\n */\nexport function isFileAccessError<CustomError extends {}>(\n error: FileValidationError<CustomError>\n): error is FileAccessError {\n return \"name\" in error && error.name === \"FileAccessError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link TooManyFilesError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link TooManyFilesError}\n */\nexport function isTooManyFilesError<CustomError extends {}>(\n error: FileValidationError<CustomError>\n): error is TooManyFilesError {\n return \"name\" in error && error.name === \"TooManyFilesError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileSizeError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileSizeError}\n */\nexport function isFileSizeError<CustomError extends {}>(\n error: FileValidationError<CustomError>\n): error is FileSizeError {\n return \"name\" in error && error.name === \"FileSizeError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileExtensionError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileExtensionError}\n */\nexport function isFileExtensionError<CustomError extends {}>(\n error: FileValidationError<CustomError>\n): error is FileExtensionError {\n return \"name\" in error && error.name === \"FileExtensionError\";\n}\n\n/**\n * This function is used to determine if a file should be added to the\n * {@link FileExtensionError}. The default implementation should work for most\n * use cases except when files that do not have extensions can be uploaded. i.e.\n * LICENSE files.\n *\n * @param file - The file being checked\n * @param extensionRegExp - A regex that will only be defined if the\n * `extensions` list had at least one value.\n * @param extensions - The list of extensions allowed\n * @returns true if the file has a valid name.\n * @since 3.1.0\n */\nexport type IsValidFileName = (\n file: File,\n extensionRegExp: RegExp | undefined,\n extensions: readonly string[]\n) => boolean;\n\n/**\n *\n * @defaultValue `matcher?.test(file.name) ?? true`\n * @since 3.1.0\n */\nexport const isValidFileName: IsValidFileName = (file, matcher) =>\n matcher?.test(file.name) ?? true;\n\n/** @since 2.9.0 */\nexport interface FileValidationOptions {\n /**\n * If the number of files should be limited, set this value to a number\n * greater than `0`.\n *\n * Note: This still allows \"infinite\" files when set to `0` since the\n * `<input>` element should normally be set to `disabled` if files should not\n * be able to be uploaded.\n *\n * @defaultValue `-1`\n */\n maxFiles?: number;\n\n /**\n * An optional minimum file size to enforce for each file. This will only be\n * used when it is greater than `0`.\n *\n * @defaultValue `-1`\n */\n minFileSize?: number;\n\n /**\n * An optional maximum file size to enforce for each file. This will only be\n * used when it is greater than `0`.\n *\n * @defaultValue `-1`\n */\n maxFileSize?: number;\n\n /**\n * An optional list of extensions to enforce when uploading files.\n *\n * Note: The extensions and file names will be compared ignoring case.\n *\n * @example Only Allow Images\n * ```ts\n * const extensions = [\"png\", \"jpeg\", \"jpg\", \"gif\"];\n * ```\n */\n extensions?: readonly string[];\n\n /** {@inheritDoc IsValidFileName} */\n isValidFileName?: IsValidFileName;\n\n /**\n * An optional total file size to enforce when the {@link maxFiles} option is\n * not set to `1`.\n *\n * @defaultValue `-1`\n */\n totalFileSize?: number;\n}\n\n/** @since 2.9.0 */\nexport interface FilesValidationOptions\n extends Required<FileValidationOptions> {\n /**\n * The total number of bytes in the {@link FileUploadHookReturnValue.stats}\n * list. This is really just:\n *\n * ```ts\n * const totalBytes = stats.reduce((total, stat) => total + stat.file.size, 0);\n * ```\n */\n totalBytes: number;\n\n /**\n * The total number of files in the {@link FileUploadHookReturnValue.stats}.\n */\n totalFiles: number;\n}\n\n/** @since 2.9.0 */\nexport interface ValidatedFilesResult<CustomError> {\n /**\n * A filtered list of files that have been validated and can be queued for the\n * upload process.\n */\n pending: readonly File[];\n\n /**\n * A list of {@link FileValidationError} that occurred during the validation\n * step.\n *\n * Note: If an error has occurred, the file **should not** be added to the\n * {@link pending} list of files.\n */\n errors: readonly FileValidationError<CustomError>[];\n}\n\n/**\n * This function will be called whenever a file has been uploaded by the user\n * either through an `<input type=\"file\">` or drag and drop behavior.\n *\n * @example Simple Example\n * ```ts\n * const validateFiles: FilesValidator = (files, options) => {\n * const invalid: File[] = [];\n * const pending: File[] = [];\n * for (const file of files) {\n * if (!/\\.(jpe?g|svg|png)$/i.test(name)) {\n * invalid.push(file);\n * } else {\n * pending.push(file);\n * }\n * }\n *\n * const errors: FileValidationError[] = [];\n * if (invalid.length) {\n * errors.push(new GenericFileError(invalid))\n * }\n *\n * return { pending, errors };\n * };\n * ```\n *\n * @typeparam E - An optional custom file validation error.\n * @param files - The list of files to check\n * @param options - The {@link FilesValidationOptions}\n * @returns the {@link ValidatedFilesResult}\n * @see {@link validateFiles} for the default implementation\n * @since 2.9.0\n */\nexport type FilesValidator<CustomError = never> = (\n files: readonly File[],\n options: FilesValidationOptions\n) => ValidatedFilesResult<CustomError>;\n\n/**\n * A pretty decent default implementation for validating files with the\n * {@link useFileUpload} that ensures the {@link FilesValidationOptions} are\n * enforced before allowing a file to be uploaded.\n *\n * @typeparam E - An optional custom file validation error.\n * @param files - The list of files to check\n * @param options - The {@link FilesValidationOptions}\n * @returns the {@link ValidatedFilesResult}\n * @since 2.9.0\n */\nexport function validateFiles<CustomError>(\n files: readonly File[],\n {\n maxFiles,\n extensions,\n minFileSize,\n maxFileSize,\n totalBytes,\n totalFiles,\n totalFileSize,\n isValidFileName,\n }: FilesValidationOptions\n): ValidatedFilesResult<CustomError> {\n const errors: FileValidationError<CustomError>[] = [];\n const pending: File[] = [];\n const extraFiles: File[] = [];\n const extensionRegExp =\n extensions.length > 0\n ? new RegExp(`\\\\.(${extensions.join(\"|\")})$`, \"i\")\n : undefined;\n\n let maxFilesReached = maxFiles > 0 && totalFiles >= maxFiles;\n let remainingBytes = totalFileSize - totalBytes;\n const extensionErrors: File[] = [];\n const minErrors: File[] = [];\n const maxErrors: File[] = [];\n const totalSizeErrors: File[] = [];\n for (let i = 0; i < files.length; i += 1) {\n const file = files[i];\n\n let valid = true;\n const { size } = file;\n if (!isValidFileName(file, extensionRegExp, extensions)) {\n valid = false;\n extensionErrors.push(file);\n }\n\n if (minFileSize > 0 && size < minFileSize) {\n valid = false;\n minErrors.push(file);\n }\n\n if (maxFileSize > 0 && size > maxFileSize) {\n valid = false;\n maxErrors.push(file);\n } else if (totalFileSize > 0 && remainingBytes - file.size < 0) {\n // don't want both errors displaying\n valid = false;\n totalSizeErrors.push(file);\n }\n\n if (maxFilesReached && valid) {\n extraFiles.push(file);\n } else if (!maxFilesReached && valid) {\n pending.push(file);\n remainingBytes -= file.size;\n maxFilesReached =\n maxFilesReached ||\n (maxFiles > 0 && totalFiles + pending.length >= maxFiles);\n }\n }\n\n if (extensionErrors.length) {\n errors.push(new FileExtensionError(extensionErrors, extensions));\n }\n\n if (minErrors.length) {\n errors.push(new FileSizeError(minErrors, \"min\", minFileSize));\n }\n\n if (maxErrors.length) {\n errors.push(new FileSizeError(maxErrors, \"max\", maxFileSize));\n }\n\n if (totalSizeErrors.length) {\n errors.push(new FileSizeError(totalSizeErrors, \"total\", totalFileSize));\n }\n\n if (extraFiles.length) {\n errors.push(new TooManyFilesError(extraFiles, maxFiles));\n }\n\n return { pending, errors };\n}\n\n/**\n * This will first check if the mime-type of the file starts with `text/` and\n * fallback to checking a few file names or extensions that should be considered\n * text.\n *\n * This function is not guaranteed to be 100% correct and is only useful if\n * trying to generate a preview of files uploaded to the browser.\n *\n * @param file - The file to check\n * @returns `true` if the file should be considered as a text-content file.\n * @since 2.9.0\n */\nexport function isTextFile(file: File): boolean {\n return /\\.((j|t)sx?|json|lock|hbs|ya?ml|log|txt|md)$/i.test(file.name);\n}\n\n/**\n * This will first check if the mime-type of the file starts with `text\\/` and\n * fallback to checking a few file names or extensions that should be considered\n * text.\n *\n * This function is not guaranteed to be 100% correct and is only useful if\n * trying to generate a preview of files uploaded to the browser.\n *\n * @param file - The file to check\n * @returns `true` if the file should be considered as a text content file.\n * @since 2.9.0\n */\nexport function isImageFile(file: File): boolean {\n return /\\.(a?png|avif|svg|tiff|gifv?|jpe?g)/i.test(file.name);\n}\n\n/**\n * This will first check if the mime-type of the file starts with `audio/` and\n * fallback to checking a few file names or extensions that should be considered\n * audio.\n *\n * This function is not guaranteed to be 100% correct and is only useful if\n * trying to generate a preview of files uploaded to the browser.\n *\n * @param file - The file to check\n * @returns `true` if the file should be considered as a audio content file.\n * @since 2.9.0\n */\nexport function isAudioFile(file: File): boolean {\n return /\\.(mp3|wav|ogg|m4p|flac)$/i.test(file.name);\n}\n\n/**\n * This will first check if the mime-type of the file starts with `video/` and\n * fallback to checking a few file names or extensions that should be considered\n * video.\n *\n * This function is not guaranteed to be 100% correct and is only useful if\n * trying to generate a preview of files uploaded to the browser.\n *\n * @param file - The file to check\n * @returns `true` if the file should be considered as a video content file.\n * @since 2.9.0\n */\nexport function isVideoFile(file: File): boolean {\n return /\\.(mkv|mpe?g|mov|avi|flv|webm|mp4)$/i.test(file.name);\n}\n\n/**\n * This function is not guaranteed to be 100% correct and is only useful if\n * trying to generate a preview of files uploaded to the browser.\n *\n * @param file - The file to check\n * @returns `true` if the file matches an image, audio, or video file.\n * @since 2.9.0\n */\nexport function isMediaFile(file: File): boolean {\n return isImageFile(file) || isAudioFile(file) || isVideoFile(file);\n}\n\n/**\n * One of the function names from a `FileReader` to upload a file to the\n * client.\n *\n * Note: If this file does not need to be previewed in the browser and will\n * immediately be uploaded to a server, use `readAsArrayBuffer`.\n *\n * @since 2.9.0\n */\nexport type FileReaderParser =\n | \"readAsText\"\n | \"readAsDataURL\"\n | \"readAsBinaryString\"\n | \"readAsArrayBuffer\";\n\n/**\n * A function that should return one of the {@link FileReaderParser} functions\n * to start uploading a file to the browser.\n *\n * @example The Default File Upload Parser\n * ```ts\n * export const getFileParser: GetFileParser = (file) => {\n * if (isMediaFile(file)) {\n * return \"readAsDataURL\";\n * }\n *\n * if (isTextFile(file)) {\n * return \"readAsText\";\n * }\n *\n * return \"readAsArrayBuffer\";\n * };\n * ```\n *\n * @param file - The file to get a parser for\n * @returns the {@link FileReaderParser} string.\n * @since 2.9.0\n */\nexport type GetFileParser = (file: File) => FileReaderParser;\n\n/**\n * This function will attempt to read:\n * - media (image, audio, and video) files as a data url so they can be\n * previewed in `<img>`, `<audio>`, and `<video>` tags\n * - text files as plain text\n * - everything else as an `ArrayBuffer` which can be manually converted into a\n * data url if needed with `URL.createObjectURL`\n *\n * @since 2.9.0\n */\nexport const getFileParser: GetFileParser = (file) => {\n if (isMediaFile(file)) {\n return \"readAsDataURL\";\n }\n\n if (isTextFile(file)) {\n return \"readAsText\";\n }\n\n return \"readAsArrayBuffer\";\n};\n\n/** @since 2.9.0 */\nexport interface SplitFileUploads {\n readonly pending: readonly ProcessingFileUploadStats[];\n readonly uploading: readonly ProcessingFileUploadStats[];\n readonly complete: readonly CompletedFileUploadStats[];\n}\n\n/**\n * This util will split all the current upload stats by status.\n *\n * @param stats - The {@link FileUploadStats} list generally returned by the\n * {@link useFileUpload} hook.\n * @returns the {@link SplitFileUploads}.\n * @since 2.9.0\n */\nexport function getSplitFileUploads(\n stats: readonly FileUploadStats[]\n): SplitFileUploads {\n const pending: ProcessingFileUploadStats[] = [];\n const uploading: ProcessingFileUploadStats[] = [];\n const complete: CompletedFileUploadStats[] = [];\n stats.forEach((stat) => {\n if (stat.status === \"pending\") {\n pending.push(stat);\n } else if (stat.status === \"uploading\") {\n uploading.push(stat);\n } else if (stat.status === \"complete\") {\n complete.push(stat);\n } else {\n /* istanbul ignore next */\n throw new Error(\"Invalid upload stat\");\n }\n });\n\n return { pending, uploading, complete };\n}\n"],"names":["nanoid","FileAccessError","Error","constructor","message","key","name","GenericFileError","files","reason","TooManyFilesError","limit","FileSizeError","type","FileExtensionError","extensions","isGenericFileError","error","isFileAccessError","isTooManyFilesError","isFileSizeError","isFileExtensionError","isValidFileName","file","matcher","test","validateFiles","maxFiles","minFileSize","maxFileSize","totalBytes","totalFiles","totalFileSize","errors","pending","extraFiles","extensionRegExp","length","RegExp","join","undefined","maxFilesReached","remainingBytes","extensionErrors","minErrors","maxErrors","totalSizeErrors","i","valid","size","push","isTextFile","isImageFile","isAudioFile","isVideoFile","isMediaFile","getFileParser","getSplitFileUploads","stats","uploading","complete","forEach","stat","status"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,SAAS;AA4DhC;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAwBC;IAMnC;;;GAGC,GACDC,YAAYC,OAAgB,CAAE;QAC5B,KAAK,CAACA;QAVR;;GAEC,GACD,uBAAOC,OAAP,KAAA;QAQE,IAAI,CAACA,GAAG,GAAGL;QACX,IAAI,CAACM,IAAI,GAAG;IACd;AACF;AAEA;;;;CAIC,GACD,OAAO,MAAMC,yBAAyBL;IAMpC;;;;GAIC,GACDC,YACE,AAAOK,KAAsB,EAC7B,AAAOC,MAAe,CACtB;QACA,KAAK,CAAC;;;QAdR;;GAEC,GACD,uBAAOJ,OAAP,KAAA;aAQSG,QAAAA;aACAC,SAAAA;QAGP,IAAI,CAACJ,GAAG,GAAGL;QACX,IAAI,CAACM,IAAI,GAAG;IACd;AACF;AAEA;;;;;CA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AY/B;AAC/D;AA0CA;;;;;;;;;CASC,GACD,OAAO,MAAMiC,gBAA+B,CAACjC;IAC3C,IAAIgC,YAAYhC,OAAO;QACrB,OAAO;IACT;IAEA,IAAI4B,WAAW5B,OAAO;QACpB,OAAO;IACT;IAEA,OAAO;AACT,EAAE;AASF;;;;;;;CAOC,GACD,OAAO,SAASkC,oBACdC,KAAiC;IAEjC,MAAMxB,UAAuC,EAAE;IAC/C,MAAMyB,YAAyC,EAAE;IACjD,MAAMC,WAAuC,EAAE;IAC/CF,MAAMG,OAAO,CAAC,CAACC;QACb,IAAIA,KAAKC,MAAM,KAAK,WAAW;YAC7B7B,QAAQgB,IAAI,CAACY;QACf,OAAO,IAAIA,KAAKC,MAAM,KAAK,aAAa;YACtCJ,UAAUT,IAAI,CAACY;QACjB,OAAO,IAAIA,KAAKC,MAAM,KAAK,YAAY;YACrCH,SAASV,IAAI,CAACY;QAChB,OAAO;YACL,wBAAwB,GACxB,MAAM,IAAI5D,MAAM;QAClB;IACF;IAEA,OAAO;QAAEgC;QAASyB;QAAWC;IAAS;AACxC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/form/useFileUpload.ts"],"sourcesContent":["\"use client\";\nimport { nanoid } from \"nanoid\";\nimport {\n useCallback,\n useEffect,\n useReducer,\n type ChangeEvent,\n type DragEvent,\n} from \"react\";\nimport {\n FileAccessError,\n getFileParser as defaultGetFileParser,\n isValidFileName as defaultIsValidFileName,\n validateFiles as defaultValidateFiles,\n type CompletedFileUploadStats,\n type FileReaderResult,\n type FileUploadHandlers,\n type FileUploadStats,\n type FileValidationError,\n type FileValidationOptions,\n type FilesValidator,\n type GetFileParser,\n type ProcessingFileUploadStats,\n} from \"./fileUtils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n *\n * @typeParam CustomError - An optional error type that gets returned from the\n * {@link FilesValidator}.\n * @since 2.9.0\n */\nexport interface FileUploadState<CustomError = never> {\n /**\n * All the files that have been validated and are either:\n * - pending upload\n * - uploading\n * - complete\n *\n * Each key in this object is the {@link BaseFileUploadStats.key} generated\n * once the upload starts pending.\n */\n stats: Readonly<Record<string, Readonly<FileUploadStats>>>;\n\n /**\n * A list of validation errors that have occurred before starting the upload\n * process.\n *\n * @see {@link FileAccessError}\n * @see {@link TooManyFilesError}\n * @see {@link FileValidationError}\n */\n errors: readonly FileValidationError<CustomError>[];\n}\n\n/**\n *\n * @typeParam CustomError - An optional error type that gets returned from the\n * {@link FilesValidator}.\n * @since 2.9.0\n * @internal\n */\nexport interface FileUploadHookState<CustomError = never>\n extends FileUploadState<CustomError> {\n /**\n * All the current readers used for uploading files to the browser.\n *\n * Note: Once an upload has completed, the reader will be removed.\n */\n readers: Readonly<Record<string, FileReader>>;\n}\n\n/**\n *\n * @typeParam E - An optional HTMLElement type that is used for the\n * {@link FileUploadHandlers}.\n * @typeParam CustomError - An optional error type that gets returned from the\n * {@link FilesValidator}.\n * @since 2.9.0\n */\nexport interface FileUploadOptions<E extends HTMLElement, CustomError = never>\n extends FileUploadHandlers<E>,\n FileValidationOptions {\n /**\n * Setting this value to a number greater than `0` will update the browser\n * upload process to queue the uploads in chunks instead of all at once. This\n * can help prevent the browser from freezing if dealing with large files that\n * are being converted to data urls.\n *\n * @defaultValue `-1`\n */\n concurrency?: number;\n\n /** {@inheritDoc FilesValidator} */\n validateFiles?: FilesValidator<CustomError>;\n /** {@inheritDoc GetFileParser} */\n getFileParser?: GetFileParser;\n}\n\n/** @internal */\ntype Action<E = never> =\n | {\n type: \"queue\";\n errors: readonly FileValidationError<E>[];\n files: readonly File[];\n }\n | { type: \"reset\" }\n | { type: \"remove\"; files: readonly string[] }\n | { type: \"start\"; key: string; reader: FileReader }\n | { type: \"progress\"; key: string; progress: number }\n | { type: \"complete\"; key: string; result: FileReaderResult }\n | { type: \"clearErrors\" };\n\n/** @since 2.9.0 */\nexport interface FileUploadActions {\n /**\n * Reset everything related to uploads ensuring that all file readers have\n * been aborted.\n */\n reset(): void;\n\n /**\n * Removes all the errors that exist in state without cancelling any of the\n * uploads already in progress.\n */\n clearErrors(): void;\n\n /**\n * This function is used to cancel pending and uploading files or removing\n * completed files.\n *\n * @param keyOrKeys - A single or list of {@link BaseFileUploadStats.key} to\n * remove from state.\n */\n remove(keyOrKeys: string | readonly string[]): void;\n}\n\n/**\n *\n * @typeParam E - An optional HTMLElement type that is used for the\n * {@link FileUploadHandlers}.\n * @typeParam CustomError - An optional error type that gets returned from the\n * {@link FilesValidator}.\n * @since 2.9.0\n */\nexport interface FileUploadHookReturnValue<\n E extends HTMLElement = HTMLElement,\n CustomError = never,\n> extends FileUploadActions,\n Required<FileUploadHandlers<E>> {\n /** {@inheritDoc FileUploadState.errors} */\n errors: readonly FileValidationError<CustomError>[];\n\n /**\n * A list of all the {@link FileUploadStats}.\n *\n * @see {@link getSplitFileUploads} for separating by status\n */\n stats: readonly Readonly<FileUploadStats>[];\n\n /**\n * The total number of bytes for all the files that exist in the\n * {@link stats} list.\n */\n totalBytes: number;\n\n /**\n * The total number of files in the {@link stats} list.\n */\n totalFiles: number;\n\n /**\n * An `accept` string that can be passed to the {@link FileInput} component\n * when the {@link FileValidationOptions.extensions} list has been provided to\n * limit which files the OS will _attempt_ to allow access to.\n *\n * @example Simple example\n * ```ts\n * const extensions = ['pdf', 'docx', 'ppt'];\n * const { accept } = useFileUpload({ extensions, ...others });\n *\n * expect(accept).toBe(\"*.pdf,*.docx,*.ppt\")\n * ```\n *\n * @defaultValue `\"*\"`\n */\n accept: string;\n}\n\n/** @internal */\nconst EMPTY_LIST = [] as const;\n/** @internal */\nconst EMPTY_OBJECT = {} as const;\n\n/**\n * This hook is generally used to upload files **to the browser** in different\n * formats to be previewed `<img>`, `<video>`, `<embed>`, etc tags. However, it\n * can also be used to upload the files as an `ArrayBuffer` and then uploaded to\n * a server.\n *\n * Note: If using the `aws-sdk` to upload files directly to S3, **do not use\n * this hook** since it uses its own upload process.\n *\n * @typeParam E - An optional HTMLElement type that is used for the\n * {@link FileUploadHandlers}.\n * @typeParam CustomError - An optional error type that gets returned from the\n * {@link FilesValidator}.\n * @param options - All the {@link FileUploadOptions}\n * @returns the {@link FileUploadHookReturnValue}\n * @since 2.9.0\n */\nexport function useFileUpload<E extends HTMLElement, CustomError = never>({\n maxFiles = -1,\n extensions = EMPTY_LIST,\n minFileSize = -1,\n maxFileSize = -1,\n totalFileSize = -1,\n concurrency = -1,\n onDrop: propOnDrop = noop,\n onChange: propOnChange = noop,\n validateFiles = defaultValidateFiles,\n getFileParser = defaultGetFileParser,\n isValidFileName = defaultIsValidFileName,\n}: FileUploadOptions<E, CustomError> = {}): Readonly<\n FileUploadHookReturnValue<E, CustomError>\n> {\n const [state, dispatch] = useReducer(\n function reducer(\n state: FileUploadHookState<CustomError>,\n action: Action<CustomError>\n ): FileUploadHookState<CustomError> {\n switch (action.type) {\n case \"reset\":\n // need to reuse constants so that calling reset doesn't cause an\n // infinite loop in an effect\n return {\n stats: EMPTY_OBJECT,\n errors: EMPTY_LIST,\n readers: EMPTY_OBJECT,\n };\n case \"remove\": {\n const stats: Record<string, FileUploadStats> = {};\n for (const key in state.stats) {\n if (!action.files.includes(key)) {\n stats[key] = state.stats[key];\n }\n }\n\n return {\n ...state,\n stats,\n };\n }\n case \"queue\":\n return {\n ...state,\n stats: {\n ...state.stats,\n ...action.files.reduce<Record<string, ProcessingFileUploadStats>>(\n (files, file) => {\n const key = nanoid();\n files[key] = {\n key,\n file,\n progress: 0,\n status: \"pending\",\n };\n\n return files;\n },\n {}\n ),\n },\n errors: [...state.errors, ...action.errors],\n };\n case \"start\": {\n const { key, reader } = action;\n const fileStats: ProcessingFileUploadStats = {\n key,\n file: state.stats[key].file,\n progress: 0,\n status: \"uploading\",\n };\n\n return {\n ...state,\n readers: {\n ...state.readers,\n [key]: reader,\n },\n stats: {\n ...state.stats,\n [key]: fileStats,\n },\n };\n }\n case \"progress\": {\n const { key, progress } = action;\n return {\n ...state,\n stats: {\n ...state.stats,\n [key]: {\n ...state.stats[key],\n progress,\n },\n },\n };\n }\n case \"complete\": {\n const { key, result } = action;\n const file: CompletedFileUploadStats = {\n key,\n file: state.stats[key].file,\n status: \"complete\",\n result,\n progress: 100,\n };\n const { [key]: _reader, ...readers } = state.readers;\n\n return {\n ...state,\n readers,\n stats: {\n ...state.stats,\n [key]: file,\n },\n };\n }\n case \"clearErrors\":\n return { ...state, errors: [] };\n }\n },\n {\n stats: EMPTY_OBJECT,\n errors: EMPTY_LIST,\n readers: EMPTY_OBJECT,\n }\n );\n const { stats, errors, readers } = state;\n\n const statsList = Object.values(stats);\n const totalFiles = statsList.length;\n const totalBytes = statsList.reduce(\n (result, { file: { size } }) => result + size,\n 0\n );\n const queueFiles = useCallback(\n (files: readonly File[]) => {\n const { pending, errors } = validateFiles(files, {\n maxFiles,\n extensions,\n minFileSize,\n maxFileSize,\n totalBytes,\n totalFiles,\n totalFileSize,\n isValidFileName,\n });\n\n dispatch({ type: \"queue\", errors, files: pending });\n },\n [\n validateFiles,\n maxFiles,\n extensions,\n minFileSize,\n maxFileSize,\n totalBytes,\n totalFiles,\n totalFileSize,\n isValidFileName,\n ]\n );\n const onDrop = useCallback(\n (event: DragEvent<E>) => {\n propOnDrop(event);\n event.preventDefault();\n event.stopPropagation();\n\n try {\n const files = event.dataTransfer.files;\n if (files) {\n queueFiles(Array.from(files));\n }\n } catch (e) {\n dispatch({\n type: \"queue\",\n files: [],\n errors: [\n new FileAccessError(e instanceof Error ? e.message : undefined),\n ],\n });\n }\n },\n [queueFiles, propOnDrop]\n );\n const onChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n propOnChange(event);\n try {\n const files = event.currentTarget.files;\n if (files) {\n queueFiles(Array.from(files));\n } else {\n throw new Error();\n }\n } catch (e) {\n dispatch({\n type: \"queue\",\n files: [],\n errors: [\n new FileAccessError(e instanceof Error ? e.message : undefined),\n ],\n });\n }\n },\n [queueFiles, propOnChange]\n );\n\n const remove = useCallback(\n (keyOrKeys: string | readonly string[]) => {\n const files = typeof keyOrKeys === \"string\" ? [keyOrKeys] : keyOrKeys;\n files.forEach((fileKey) => {\n readers[fileKey]?.abort();\n });\n\n dispatch({ type: \"remove\", files });\n },\n [readers]\n );\n const reset = useCallback(() => {\n Object.values(readers).forEach((reader) => {\n reader.abort();\n });\n\n dispatch({ type: \"reset\" });\n }, [readers]);\n const clearErrors = useCallback(() => {\n dispatch({ type: \"clearErrors\" });\n }, []);\n const start = useCallback((key: string, reader: FileReader) => {\n dispatch({ type: \"start\", key, reader });\n }, []);\n const complete = useCallback(\n (key: string, result: FileReaderResult = null) => {\n dispatch({ type: \"complete\", key, result });\n },\n []\n );\n const createProgressEventHandler = useCallback(\n (key: string) => (event: ProgressEvent) => {\n if (event.lengthComputable) {\n const percentage = Math.round((event.loaded * 100) / event.total);\n dispatch({ type: \"progress\", key, progress: percentage });\n }\n },\n []\n );\n\n useEffect(() => {\n const pending: ProcessingFileUploadStats[] = [];\n const uploading: ProcessingFileUploadStats[] = [];\n Object.values(stats).forEach((file) => {\n if (file.status === \"pending\") {\n pending.push(file);\n } else if (file.status === \"uploading\") {\n uploading.push(file);\n }\n });\n\n const lastIndex =\n concurrency === -1\n ? pending.length\n : Math.max(0, concurrency - uploading.length);\n const queue = pending.slice(0, lastIndex);\n if (!queue.length) {\n return;\n }\n\n queue.forEach((stats) => {\n const { key, file } = stats;\n const reader = new FileReader();\n\n // using `addEventListener` instead of directly setting to\n // `reader.progress`/`reader.load` so it's easier to test\n reader.addEventListener(\"progress\", createProgressEventHandler(key));\n reader.addEventListener(\"load\", () => {\n complete(key, reader.result);\n });\n\n start(key, reader);\n const parser = getFileParser(file);\n /* istanbul ignore next */\n if (\n process.env.NODE_ENV !== \"production\" &&\n ![\n \"readAsText\",\n \"readAsDataURL\",\n \"readAsArrayBuffer\",\n \"readAsBinaryString\",\n ].includes(parser)\n ) {\n throw new Error(\"Invalid file reader parser\");\n }\n\n reader[parser](file);\n });\n }, [\n concurrency,\n stats,\n getFileParser,\n createProgressEventHandler,\n start,\n complete,\n ]);\n\n let accept = \"\";\n if (extensions.length) {\n accept = extensions.reduce((s, ext) => `${s ? `${s},` : \"\"}.${ext}`, \"\");\n }\n\n return {\n stats: statsList,\n errors,\n accept,\n totalBytes,\n totalFiles,\n onDrop,\n onChange,\n reset,\n remove,\n clearErrors,\n };\n}\n"],"names":["nanoid","useCallback","useEffect","useReducer","FileAccessError","getFileParser","defaultGetFileParser","isValidFileName","defaultIsValidFileName","validateFiles","defaultValidateFiles","noop","EMPTY_LIST","EMPTY_OBJECT","useFileUpload","maxFiles","extensions","minFileSize","maxFileSize","totalFileSize","concurrency","onDrop","propOnDrop","onChange","propOnChange","state","dispatch","reducer","action","type","stats","errors","readers","key","files","includes","reduce","file","progress","status","reader","fileStats","result","_reader","statsList","Object","values","totalFiles","length","totalBytes","size","queueFiles","pending","event","preventDefault","stopPropagation","dataTransfer","Array","from","e","Error","message","undefined","currentTarget","remove","keyOrKeys","forEach","fileKey","abort","reset","clearErrors","start","complete","createProgressEventHandler","lengthComputable","percentage","Math","round","loaded","total","uploading","push","lastIndex","max","queue","slice","FileReader","addEventListener","parser","process","env","NODE_ENV","accept","s","ext"],"mappings":"AAAA;AACA,SAASA,MAAM,QAAQ,SAAS;AAChC,SACEC,WAAW,EACXC,SAAS,EACTC,UAAU,QAGL,QAAQ;AACf,SACEC,eAAe,EACfC,iBAAiBC,oBAAoB,EACrCC,mBAAmBC,sBAAsB,EACzCC,iBAAiBC,oBAAoB,QAUhC,iBAAiB;AAExB,MAAMC,OAAO;AACX,aAAa;AACf;AAqKA,cAAc,GACd,MAAMC,aAAa,EAAE;AACrB,cAAc,GACd,MAAMC,eAAe,CAAC;AAEtB;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,cAA0D,EACxEC,WAAW,CAAC,CAAC,EACbC,aAAaJ,UAAU,EACvBK,cAAc,CAAC,CAAC,EAChBC,cAAc,CAAC,CAAC,EAChBC,gBAAgB,CAAC,CAAC,EAClBC,cAAc,CAAC,CAAC,EA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hC,QAAQiC,KAAK,CAAC,GAAGH;QAC/B,IAAI,CAACE,MAAMpC,MAAM,EAAE;YACjB;QACF;QAEAoC,MAAMlB,OAAO,CAAC,CAACpC;YACb,MAAM,EAAEG,GAAG,EAAEI,IAAI,EAAE,GAAGP;YACtB,MAAMU,SAAS,IAAI8C;YAEnB,0DAA0D;YAC1D,yDAAyD;YACzD9C,OAAO+C,gBAAgB,CAAC,YAAYd,2BAA2BxC;YAC/DO,OAAO+C,gBAAgB,CAAC,QAAQ;gBAC9Bf,SAASvC,KAAKO,OAAOE,MAAM;YAC7B;YAEA6B,MAAMtC,KAAKO;YACX,MAAMgD,SAASnF,cAAcgC;YAC7B,wBAAwB,GACxB,IACEoD,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzB,CAAC;gBACC;gBACA;gBACA;gBACA;aACD,CAACxD,QAAQ,CAACqD,SACX;gBACA,MAAM,IAAI5B,MAAM;YAClB;YAEApB,MAAM,CAACgD,OAAO,CAACnD;QACjB;IACF,GAAG;QACDjB;QACAU;QACAzB;QACAoE;QACAF;QACAC;KACD;IAED,IAAIoB,SAAS;IACb,IAAI5E,WAAWgC,MAAM,EAAE;QACrB4C,SAAS5E,WAAWoB,MAAM,CAAC,CAACyD,GAAGC,MAAQ,CAAC,EAAED,IAAI,CAAC,EAAEA,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,EAAEC,IAAI,CAAC,EAAE;IACvE;IAEA,OAAO;QACLhE,OAAOc;QACPb;QACA6D;QACA3C;QACAF;QACA1B;QACAE;QACA8C;QACAL;QACAM;IACF;AACF"}
@@ -1,31 +0,0 @@
1
- import { type RefObject } from "react";
2
- import { type ChangeableHTMLElement } from "./utils.js";
3
- /**
4
- * @internal
5
- * @since 6.0.0
6
- */
7
- export interface ListboxContext {
8
- /**
9
- * This ref is used to trigger the change event when an option is clicked.
10
- */
11
- inputRef: RefObject<ChangeableHTMLElement>;
12
- /**
13
- * This is used within the `Option` component to determine if it is currently
14
- * selected or not.
15
- */
16
- currentValue: string | number | null;
17
- selectedIconAfter: boolean;
18
- disableSelectedIcon: boolean;
19
- }
20
- /**
21
- * **Client Component**
22
- *
23
- * @internal
24
- * @since 6.0.0
25
- */
26
- export declare const ListboxProvider: import("react").Provider<ListboxContext | null>;
27
- /**
28
- * @internal
29
- * @since 6.0.0
30
- */
31
- export declare function useListboxContext(): ListboxContext;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/form/useListboxProvider.ts"],"sourcesContent":["\"use client\";\nimport { createContext, useContext, type RefObject } from \"react\";\nimport { type ChangeableHTMLElement } from \"./utils.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface ListboxContext {\n /**\n * This ref is used to trigger the change event when an option is clicked.\n */\n inputRef: RefObject<ChangeableHTMLElement>;\n\n /**\n * This is used within the `Option` component to determine if it is currently\n * selected or not.\n */\n currentValue: string | number | null;\n\n selectedIconAfter: boolean;\n disableSelectedIcon: boolean;\n}\n\nconst context = createContext<ListboxContext | null>(null);\n\n/**\n * **Client Component**\n *\n * @internal\n * @since 6.0.0\n */\nexport const { Provider: ListboxProvider } = context;\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function useListboxContext(): ListboxContext {\n const value = useContext(context);\n if (!value) {\n throw new Error(\"The `ListboxProvider` must be a parent component\");\n }\n return value;\n}\n"],"names":["createContext","useContext","context","Provider","ListboxProvider","useListboxContext","value","Error"],"mappings":"AAAA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAwB,QAAQ;AAuBlE,MAAMC,UAAUF,cAAqC;AAErD;;;;;CAKC,GACD,OAAO,MAAM,EAAEG,UAAUC,eAAe,EAAE,GAAGF,QAAQ;AAErD;;;CAGC,GACD,OAAO,SAASG;IACd,MAAMC,QAAQL,WAAWC;IACzB,IAAI,CAACI,OAAO;QACV,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOD;AACT"}
@@ -1,5 +0,0 @@
1
- import { type NavigationItem } from "./types.js";
2
- /**
3
- * @since 6.0.0
4
- */
5
- export declare function getHrefFromParents(parents: readonly NavigationItem[]): string;
@@ -1,13 +0,0 @@
1
- /**
2
- * @since 6.0.0
3
- */ export function getHrefFromParents(parents) {
4
- return parents.reduce((result, parent)=>{
5
- if ("href" in parent && parent.href) {
6
- const { href } = parent;
7
- return result + href;
8
- }
9
- return result;
10
- }, "");
11
- }
12
-
13
- //# sourceMappingURL=getHrefFromParents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/navigation/getHrefFromParents.ts"],"sourcesContent":["import { type NavigationItem } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport function getHrefFromParents(parents: readonly NavigationItem[]): string {\n return parents.reduce<string>((result, parent) => {\n if (\"href\" in parent && parent.href) {\n const { href } = parent;\n return result + href;\n }\n\n return result;\n }, \"\");\n}\n"],"names":["getHrefFromParents","parents","reduce","result","parent","href"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,mBAAmBC,OAAkC;IACnE,OAAOA,QAAQC,MAAM,CAAS,CAACC,QAAQC;QACrC,IAAI,UAAUA,UAAUA,OAAOC,IAAI,EAAE;YACnC,MAAM,EAAEA,IAAI,EAAE,GAAGD;YACjB,OAAOD,SAASE;QAClB;QAEA,OAAOF;IACT,GAAG;AACL"}
@@ -1,115 +0,0 @@
1
- import { type HTMLAttributes } from "react";
2
- /** @since 6.0.0 */
3
- export interface ResponsiveItemContainerClassNameOptions {
4
- className?: string;
5
- /**
6
- * Set this to `true` if the container should gain the following styles:
7
- *
8
- * ```scss
9
- * display: block;
10
- * width: 100%;
11
- * ```
12
- *
13
- * @defaultValue `false`
14
- */
15
- fullWidth?: boolean;
16
- /**
17
- * Set this to a custom aspect ratio to use.
18
- *
19
- * @example Valid Aspect Ratios
20
- * ```tsx
21
- * aspectRatio="16-9"
22
- * aspectRatio="9-16"
23
- * aspectRatio="3-4"
24
- * aspectRatio="4-3"
25
- * aspectRatio="1-1"
26
- * ```
27
- *
28
- * These values are based on the `core.$responsive-item-aspect-ratios` map.
29
- *
30
- * @defaultValue `""`
31
- */
32
- aspectRatio?: `${number}-${number}`;
33
- /**
34
- * Set this to `"manual"` if you want to manually specify which elements are
35
- * responsive items using custom class names. You probably don't really want
36
- * to use this.
37
- *
38
- * Set this to `"auto"` to automatically update all visual media that appear
39
- * as a child in this component to a responsive item.
40
- *
41
- * Set this to `"container"` to automatically update all visual media that
42
- * appear as a child in this component to be a responsive item that scales to
43
- * the container's dimensions.
44
- *
45
- * Note: The `"auto"` and `"container"` values use the
46
- * `core.$responsive-item-selectors` value for their behavior.
47
- *
48
- * @defaultValue `"auto"`
49
- */
50
- responsive?: "auto" | "manual" | "container";
51
- }
52
- /** @since 6.0.0 */
53
- export declare function responsiveItemContainer(options?: ResponsiveItemContainerClassNameOptions): string;
54
- /**
55
- * @since 6.0.0 Renamed from `MediaContainerProps` to
56
- * `ResponsiveItemContainerProps`
57
- * @since 6.0.0 The `height` and `width` props were removed in favor of the
58
- * `aspectRatio` props since the latest typescript string interpolation supports
59
- * enforcing the correct format.
60
- * @since 6.0.0 The `auto` prop was removed in favor of the new
61
- * {@link ResponsiveItemContainerProps.responsive} prop.
62
- */
63
- export interface ResponsiveItemContainerProps extends HTMLAttributes<HTMLSpanElement>, ResponsiveItemContainerClassNameOptions {
64
- }
65
- /**
66
- * @example Image Example
67
- * ```tsx
68
- * import { ResponsiveItemContainer } from "@react-md/core";
69
- * import type { ReactElement } from "react";
70
- *
71
- * function Example(): ReactElement {
72
- * return (
73
- * <ResponsiveItemContainer>
74
- * <img alt="" src="/some-image.png" />
75
- * </ResponsiveItemContainer>
76
- * );
77
- * }
78
- * ```
79
- *
80
- * @example Iframe Example
81
- * ```tsx
82
- * import { ResponsiveItemContainer } from "@react-md/core";
83
- * import type { ReactElement } from "react";
84
- *
85
- * function Example(): ReactElement {
86
- * return (
87
- * <ResponsiveItemContainer>
88
- * <iframe
89
- * src="https://youtube.com/some-video-url"
90
- * title="Some YouTube video"
91
- * allowFullScreen
92
- * />
93
- * </ResponsiveItemContainer>
94
- * );
95
- * }
96
- * ```
97
- *
98
- * @example Forced Aspect Ratio
99
- * ```tsx
100
- * import { ResponsiveItemContainer } from "@react-md/core";
101
- * import type { ReactElement } from "react";
102
- *
103
- * function Example(): ReactElement {
104
- * return (
105
- * <ResponsiveItemContainer aspectRatio="16-9">
106
- * <img alt="" src="/some-image.png" />
107
- * </ResponsiveItemContainer>
108
- * );
109
- * }
110
- * ```
111
- *
112
- * @since 6.0.0 Renamed from `MediaContainer` to
113
- * `ResponsiveItemContainer` and renders a `<span>` instead of a `<div>`.
114
- */
115
- export declare const ResponsiveItemContainer: import("react").ForwardRefExoticComponent<ResponsiveItemContainerProps & import("react").RefAttributes<HTMLSpanElement>>;
@@ -1,80 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { cnb } from "cnbuilder";
3
- import { forwardRef } from "react";
4
- import { bem } from "../utils/bem.js";
5
- const styles = bem("rmd-responsive-item-container");
6
- /** @since 6.0.0 */ export function responsiveItemContainer(options = {}) {
7
- const { className, fullWidth = false, aspectRatio = "", responsive = "auto" } = options;
8
- return cnb(styles({
9
- auto: responsive !== "manual",
10
- "auto-scale": responsive === "container",
11
- "aspect-ratio": aspectRatio,
12
- [aspectRatio]: aspectRatio,
13
- "full-width": fullWidth
14
- }), className);
15
- }
16
- /**
17
- * @example Image Example
18
- * ```tsx
19
- * import { ResponsiveItemContainer } from "@react-md/core";
20
- * import type { ReactElement } from "react";
21
- *
22
- * function Example(): ReactElement {
23
- * return (
24
- * <ResponsiveItemContainer>
25
- * <img alt="" src="/some-image.png" />
26
- * </ResponsiveItemContainer>
27
- * );
28
- * }
29
- * ```
30
- *
31
- * @example Iframe Example
32
- * ```tsx
33
- * import { ResponsiveItemContainer } from "@react-md/core";
34
- * import type { ReactElement } from "react";
35
- *
36
- * function Example(): ReactElement {
37
- * return (
38
- * <ResponsiveItemContainer>
39
- * <iframe
40
- * src="https://youtube.com/some-video-url"
41
- * title="Some YouTube video"
42
- * allowFullScreen
43
- * />
44
- * </ResponsiveItemContainer>
45
- * );
46
- * }
47
- * ```
48
- *
49
- * @example Forced Aspect Ratio
50
- * ```tsx
51
- * import { ResponsiveItemContainer } from "@react-md/core";
52
- * import type { ReactElement } from "react";
53
- *
54
- * function Example(): ReactElement {
55
- * return (
56
- * <ResponsiveItemContainer aspectRatio="16-9">
57
- * <img alt="" src="/some-image.png" />
58
- * </ResponsiveItemContainer>
59
- * );
60
- * }
61
- * ```
62
- *
63
- * @since 6.0.0 Renamed from `MediaContainer` to
64
- * `ResponsiveItemContainer` and renders a `<span>` instead of a `<div>`.
65
- */ export const ResponsiveItemContainer = /*#__PURE__*/ forwardRef(function ResponsiveItemContainer(props, ref) {
66
- const { className, fullWidth = false, aspectRatio, responsive = "auto", children, ...remaining } = props;
67
- return /*#__PURE__*/ _jsx("span", {
68
- ...remaining,
69
- ref: ref,
70
- className: responsiveItemContainer({
71
- className,
72
- fullWidth,
73
- aspectRatio,
74
- responsive
75
- }),
76
- children: children
77
- });
78
- });
79
-
80
- //# sourceMappingURL=ResponsiveItemContainer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/responsive-item/ResponsiveItemContainer.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { forwardRef, type HTMLAttributes } from \"react\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-responsive-item-container\");\n\n/** @since 6.0.0 */\nexport interface ResponsiveItemContainerClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` if the container should gain the following styles:\n *\n * ```scss\n * display: block;\n * width: 100%;\n * ```\n *\n * @defaultValue `false`\n */\n fullWidth?: boolean;\n\n /**\n * Set this to a custom aspect ratio to use.\n *\n * @example Valid Aspect Ratios\n * ```tsx\n * aspectRatio=\"16-9\"\n * aspectRatio=\"9-16\"\n * aspectRatio=\"3-4\"\n * aspectRatio=\"4-3\"\n * aspectRatio=\"1-1\"\n * ```\n *\n * These values are based on the `core.$responsive-item-aspect-ratios` map.\n *\n * @defaultValue `\"\"`\n */\n aspectRatio?: `${number}-${number}`;\n\n /**\n * Set this to `\"manual\"` if you want to manually specify which elements are\n * responsive items using custom class names. You probably don't really want\n * to use this.\n *\n * Set this to `\"auto\"` to automatically update all visual media that appear\n * as a child in this component to a responsive item.\n *\n * Set this to `\"container\"` to automatically update all visual media that\n * appear as a child in this component to be a responsive item that scales to\n * the container's dimensions.\n *\n * Note: The `\"auto\"` and `\"container\"` values use the\n * `core.$responsive-item-selectors` value for their behavior.\n *\n * @defaultValue `\"auto\"`\n */\n responsive?: \"auto\" | \"manual\" | \"container\";\n}\n\n/** @since 6.0.0 */\nexport function responsiveItemContainer(\n options: ResponsiveItemContainerClassNameOptions = {}\n): string {\n const {\n className,\n fullWidth = false,\n aspectRatio = \"\",\n responsive = \"auto\",\n } = options;\n\n return cnb(\n styles({\n auto: responsive !== \"manual\",\n \"auto-scale\": responsive === \"container\",\n \"aspect-ratio\": aspectRatio,\n [aspectRatio]: aspectRatio,\n \"full-width\": fullWidth,\n }),\n className\n );\n}\n\n/**\n * @since 6.0.0 Renamed from `MediaContainerProps` to\n * `ResponsiveItemContainerProps`\n * @since 6.0.0 The `height` and `width` props were removed in favor of the\n * `aspectRatio` props since the latest typescript string interpolation supports\n * enforcing the correct format.\n * @since 6.0.0 The `auto` prop was removed in favor of the new\n * {@link ResponsiveItemContainerProps.responsive} prop.\n */\nexport interface ResponsiveItemContainerProps\n extends HTMLAttributes<HTMLSpanElement>,\n ResponsiveItemContainerClassNameOptions {}\n\n/**\n * @example Image Example\n * ```tsx\n * import { ResponsiveItemContainer } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <ResponsiveItemContainer>\n * <img alt=\"\" src=\"/some-image.png\" />\n * </ResponsiveItemContainer>\n * );\n * }\n * ```\n *\n * @example Iframe Example\n * ```tsx\n * import { ResponsiveItemContainer } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <ResponsiveItemContainer>\n * <iframe\n * src=\"https://youtube.com/some-video-url\"\n * title=\"Some YouTube video\"\n * allowFullScreen\n * />\n * </ResponsiveItemContainer>\n * );\n * }\n * ```\n *\n * @example Forced Aspect Ratio\n * ```tsx\n * import { ResponsiveItemContainer } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <ResponsiveItemContainer aspectRatio=\"16-9\">\n * <img alt=\"\" src=\"/some-image.png\" />\n * </ResponsiveItemContainer>\n * );\n * }\n * ```\n *\n * @since 6.0.0 Renamed from `MediaContainer` to\n * `ResponsiveItemContainer` and renders a `<span>` instead of a `<div>`.\n */\nexport const ResponsiveItemContainer = forwardRef<\n HTMLSpanElement,\n ResponsiveItemContainerProps\n>(function ResponsiveItemContainer(props, ref) {\n const {\n className,\n fullWidth = false,\n aspectRatio,\n responsive = \"auto\",\n children,\n ...remaining\n } = props;\n\n return (\n <span\n {...remaining}\n ref={ref}\n className={responsiveItemContainer({\n className,\n fullWidth,\n aspectRatio,\n responsive,\n })}\n >\n {children}\n </span>\n );\n});\n"],"names":["cnb","forwardRef","bem","styles","responsiveItemContainer","options","className","fullWidth","aspectRatio","responsive","auto","ResponsiveItemContainer","props","ref","children","remaining","span"],"mappings":";AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,UAAU,QAA6B,QAAQ;AACxD,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAwDnB,iBAAiB,GACjB,OAAO,SAASE,wBACdC,UAAmD,CAAC,CAAC;IAErD,MAAM,EACJC,SAAS,EACTC,YAAY,KAAK,EACjBC,cAAc,EAAE,EAChBC,aAAa,MAAM,EACpB,GAAGJ;IAEJ,OAAOL,IACLG,OAAO;QACLO,MAAMD,eAAe;QACrB,cAAcA,eAAe;QAC7B,gBAAgBD;QAChB,CAACA,YAAY,EAAEA;QACf,cAAcD;IAChB,IACAD;AAEJ;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDC,GACD,OAAO,MAAMK,wCAA0BV,WAGrC,SAASU,wBAAwBC,KAAK,EAAEC,GAAG;IAC3C,MAAM,EACJP,SAAS,EACTC,YAAY,KAAK,EACjBC,WAAW,EACXC,aAAa,MAAM,EACnBK,QAAQ,EACR,GAAGC,WACJ,GAAGH;IAEJ,qBACE,KAACI;QACE,GAAGD,SAAS;QACbF,KAAKA;QACLP,WAAWF,wBAAwB;YACjCE;YACAC;YACAC;YACAC;QACF;kBAECK;;AAGP,GAAG"}
@@ -1,34 +0,0 @@
1
- /** @since 6.0.0 */
2
- export interface ResponsiveItemClassNameOptions {
3
- className?: string;
4
- /**
5
- * Set this to `true` to apply the following styles:
6
- * ```scss
7
- * max-height: 100%;
8
- * max-width: 100%;
9
- * object-fit: contain;
10
- * ```
11
- *
12
- * This is useful for displaying images in a full page dialog so that scroll
13
- * bars do not appear while maintaining the correct aspect ratio for the item.
14
- *
15
- * @defaultValue `false`
16
- */
17
- scaleToContainer?: boolean;
18
- /**
19
- * Set this to `true` to force a specific aspect ratio.
20
- *
21
- * Note: This will only work if the parent element has applied the correct
22
- * {@link ResponsiveItemContainerStyles} as well.
23
- *
24
- * @defaultValue `false`
25
- */
26
- forcedAspectRatio?: boolean;
27
- }
28
- /**
29
- * Applies the visual media responsive styles manually if you cannot use the
30
- * `ResponsiveItemContainer` component.
31
- *
32
- * @since 6.0.0
33
- */
34
- export declare function responsiveItem(options?: ResponsiveItemClassNameOptions): string;
@@ -1,17 +0,0 @@
1
- import { cnb } from "cnbuilder";
2
- import { bem } from "../utils/bem.js";
3
- const styles = bem("rmd-responsive-item");
4
- /**
5
- * Applies the visual media responsive styles manually if you cannot use the
6
- * `ResponsiveItemContainer` component.
7
- *
8
- * @since 6.0.0
9
- */ export function responsiveItem(options = {}) {
10
- const { className, scaleToContainer = false, forcedAspectRatio = false } = options;
11
- return cnb(styles({
12
- scale: scaleToContainer,
13
- "aspect-ratio": forcedAspectRatio
14
- }), className);
15
- }
16
-
17
- //# sourceMappingURL=styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/responsive-item/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-responsive-item\");\n\n/** @since 6.0.0 */\nexport interface ResponsiveItemClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` to apply the following styles:\n * ```scss\n * max-height: 100%;\n * max-width: 100%;\n * object-fit: contain;\n * ```\n *\n * This is useful for displaying images in a full page dialog so that scroll\n * bars do not appear while maintaining the correct aspect ratio for the item.\n *\n * @defaultValue `false`\n */\n scaleToContainer?: boolean;\n\n /**\n * Set this to `true` to force a specific aspect ratio.\n *\n * Note: This will only work if the parent element has applied the correct\n * {@link ResponsiveItemContainerStyles} as well.\n *\n * @defaultValue `false`\n */\n forcedAspectRatio?: boolean;\n}\n\n/**\n * Applies the visual media responsive styles manually if you cannot use the\n * `ResponsiveItemContainer` component.\n *\n * @since 6.0.0\n */\nexport function responsiveItem(\n options: ResponsiveItemClassNameOptions = {}\n): string {\n const {\n className,\n scaleToContainer = false,\n forcedAspectRatio = false,\n } = options;\n\n return cnb(\n styles({\n scale: scaleToContainer,\n \"aspect-ratio\": forcedAspectRatio,\n }),\n className\n );\n}\n"],"names":["cnb","bem","styles","responsiveItem","options","className","scaleToContainer","forcedAspectRatio","scale"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAgCnB;;;;;CAKC,GACD,OAAO,SAASE,eACdC,UAA0C,CAAC,CAAC;IAE5C,MAAM,EACJC,SAAS,EACTC,mBAAmB,KAAK,EACxBC,oBAAoB,KAAK,EAC1B,GAAGH;IAEJ,OAAOJ,IACLE,OAAO;QACLM,OAAOF;QACP,gBAAgBC;IAClB,IACAF;AAEJ"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/theme/usePrefersColorScheme.ts"],"sourcesContent":["\"use client\";\nimport { useMediaQuery } from \"../media-queries/useMediaQuery.js\";\n\n/**\n * A simple wrapper around the {@link useMediaQuery} hook with:\n * `\"(prefers-color-scheme: dark)\"`.\n *\n * @since 6.0.0\n */\nexport function usePrefersDarkTheme(disabled = false): boolean {\n return useMediaQuery(\"(prefers-color-scheme: dark)\", disabled);\n}\n"],"names":["useMediaQuery","usePrefersDarkTheme","disabled"],"mappings":"AAAA;AACA,SAASA,aAAa,QAAQ,oCAAoC;AAElE;;;;;CAKC,GACD,OAAO,SAASC,oBAAoBC,WAAW,KAAK;IAClD,OAAOF,cAAc,gCAAgCE;AACvD"}
@@ -1,86 +0,0 @@
1
- "use client";
2
- import { useMemo, type ReactElement, type RefObject } from "react";
3
- import {
4
- triggerManualChangeEvent,
5
- type EditableHTMLElement,
6
- } from "../form/utils.js";
7
- import { ListSubheader } from "../list/ListSubheader.js";
8
- import { MenuItem } from "../menu/MenuItem.js";
9
- import {
10
- defaultAutocompleteExtractor,
11
- defaultAutocompleteFilter,
12
- defaultAutocompleteOptionProps,
13
- } from "./defaults.js";
14
- import { type AutocompleteOptionsProps } from "./types.js";
15
-
16
- const noop = (): void => {
17
- // do nothing
18
- };
19
-
20
- export interface FilterAutocompleteOptionsProps<T>
21
- extends AutocompleteOptionsProps<T> {
22
- query: string;
23
- comboboxRef: RefObject<EditableHTMLElement>;
24
- }
25
-
26
- export function FilterAutocompleteOptions<T>(
27
- props: FilterAutocompleteOptionsProps<T>
28
- ): ReactElement {
29
- const {
30
- query,
31
- filter = defaultAutocompleteFilter,
32
- options,
33
- extractor = defaultAutocompleteExtractor,
34
- whitespace = "keep",
35
- comboboxRef,
36
- disableFilter,
37
- onAutocomplete = noop,
38
- getOptionProps = defaultAutocompleteOptionProps,
39
- clearOnAutocomplete,
40
- noOptionsChildren = <ListSubheader>No Options</ListSubheader>,
41
- } = props;
42
- const filtered = useMemo(() => {
43
- if (disableFilter) {
44
- return options;
45
- }
46
-
47
- return filter({
48
- list: options,
49
- query,
50
- extractor,
51
- whitespace,
52
- });
53
- }, [disableFilter, extractor, filter, options, query, whitespace]);
54
-
55
- return (
56
- <>
57
- {!filtered.length && noOptionsChildren}
58
- {filtered.map((option, index) => {
59
- const label = extractor(option);
60
- const optionProps = getOptionProps({
61
- index,
62
- option,
63
- });
64
-
65
- return (
66
- <MenuItem
67
- key={label}
68
- role="option"
69
- {...optionProps}
70
- onClick={(event) => {
71
- optionProps?.onClick?.(event);
72
-
73
- triggerManualChangeEvent(
74
- comboboxRef.current,
75
- clearOnAutocomplete ? "" : label
76
- );
77
- onAutocomplete(option);
78
- }}
79
- >
80
- {optionProps?.children ?? label}
81
- </MenuItem>
82
- );
83
- })}
84
- </>
85
- );
86
- }
@@ -1,28 +0,0 @@
1
- import { cnb } from "cnbuilder";
2
- import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
3
-
4
- /**
5
- * @since 6.0.0
6
- * @internal
7
- */
8
- export interface DialogContainerProps extends HTMLAttributes<HTMLDivElement> {
9
- enabled: boolean;
10
- children: ReactNode;
11
- }
12
-
13
- /**
14
- * @since 6.0.0
15
- * @internal
16
- */
17
- export function DialogContainer(props: DialogContainerProps): ReactElement {
18
- const { className, enabled, children, ...remaining } = props;
19
- if (!enabled) {
20
- return <>{children}</>;
21
- }
22
-
23
- return (
24
- <div {...remaining} className={cnb("rmd-dialog-container", className)}>
25
- {children}
26
- </div>
27
- );
28
- }