@zj-dynamics/components 0.0.0-stage → 0.2.0

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 (674) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.react-is +21 -0
  3. package/NOTICE.tabbable +22 -0
  4. package/README.md +31 -2
  5. package/compatibility.css +2 -0
  6. package/dist/Button.d.ts +90 -0
  7. package/dist/Button.js +58 -0
  8. package/dist/ButtonDismiss.d.ts +6 -0
  9. package/dist/ButtonDismiss.js +5 -0
  10. package/dist/Dialog.d.ts +75 -0
  11. package/dist/Dialog.js +59 -0
  12. package/dist/Icon.d.ts +20 -0
  13. package/dist/Icon.js +11 -0
  14. package/dist/InputText.d.ts +26 -0
  15. package/dist/InputText.js +63 -0
  16. package/dist/Switch.d.ts +8 -0
  17. package/dist/Switch.js +19 -0
  18. package/dist/Toast.d.ts +21 -0
  19. package/dist/Toast.js +58 -0
  20. package/dist/browserFocus.d.ts +11 -0
  21. package/dist/browserFocus.js +85 -0
  22. package/dist/browserHooks.d.ts +5 -0
  23. package/dist/browserHooks.js +4 -0
  24. package/dist/index.d.ts +100 -0
  25. package/dist/index.js +91 -0
  26. package/dist/legacyModalPortal.d.ts +1 -0
  27. package/dist/legacyModalPortal.js +2 -0
  28. package/dist/mockViewportWidth.d.ts +5 -0
  29. package/dist/mockViewportWidth.js +58 -0
  30. package/dist/slotChildren.d.ts +2 -0
  31. package/dist/slotChildren.js +6 -0
  32. package/dist/theme.d.ts +26 -0
  33. package/dist/theme.js +65 -0
  34. package/dist/unstyledPrimitives.d.ts +12 -0
  35. package/dist/unstyledPrimitives.js +12 -0
  36. package/dist/useBreakpoints.d.ts +3 -0
  37. package/dist/useBreakpoints.js +2 -0
  38. package/dist/useFocusTrap.d.ts +1 -0
  39. package/dist/useFocusTrap.js +1 -0
  40. package/dist/useInView.d.ts +1 -0
  41. package/dist/useInView.js +1 -0
  42. package/dist/useIsSmallScreen.d.ts +1 -0
  43. package/dist/useIsSmallScreen.js +1 -0
  44. package/dist/useLiveAnnounce.d.ts +1 -0
  45. package/dist/useLiveAnnounce.js +1 -0
  46. package/dist/useOnKeyDown.d.ts +1 -0
  47. package/dist/useOnKeyDown.js +1 -0
  48. package/dist/useRefocusOnActivator.d.ts +1 -0
  49. package/dist/useRefocusOnActivator.js +1 -0
  50. package/dist/useResizeObserver.d.ts +22 -0
  51. package/dist/useResizeObserver.js +47 -0
  52. package/dist/useWindowDimensions.d.ts +2 -0
  53. package/dist/useWindowDimensions.js +1 -0
  54. package/dist/viewport.d.ts +46 -0
  55. package/dist/viewport.js +141 -0
  56. package/foundation/ActivityIndicator/ActivityIndicator.d.ts +38 -0
  57. package/foundation/ActivityIndicator/index.d.mts +2 -0
  58. package/foundation/ActivityIndicator/index.mjs +6 -0
  59. package/foundation/ActivityIndicator-es.js +30 -0
  60. package/foundation/Autocomplete/Autocomplete.d.ts +8 -0
  61. package/foundation/Autocomplete/Autocomplete.types.d.ts +401 -0
  62. package/foundation/Autocomplete/hooks/useAutocompleteListNav.d.ts +30 -0
  63. package/foundation/Autocomplete/index.d.mts +3 -0
  64. package/foundation/Autocomplete/index.mjs +39 -0
  65. package/foundation/Autocomplete/utils/interactionUtils.d.ts +14 -0
  66. package/foundation/Autocomplete-es.js +1322 -0
  67. package/foundation/Avatar/Avatar.d.ts +77 -0
  68. package/foundation/Avatar/index.d.mts +1 -0
  69. package/foundation/Avatar/index.mjs +6 -0
  70. package/foundation/Avatar-es.js +80 -0
  71. package/foundation/Banner/Banner.d.ts +10 -0
  72. package/foundation/Banner/Banner.types.d.ts +165 -0
  73. package/foundation/Banner/index.d.mts +2 -0
  74. package/foundation/Banner/index.mjs +14 -0
  75. package/foundation/Banner-es.js +134 -0
  76. package/foundation/Body-es.js +45 -0
  77. package/foundation/BottomSheet-es.js +110 -0
  78. package/foundation/Box/Box.d.ts +3 -0
  79. package/foundation/Box/Box.types.d.ts +40 -0
  80. package/foundation/Box/index.d.mts +1 -0
  81. package/foundation/Box/index.mjs +4 -0
  82. package/foundation/Box-es.js +130 -0
  83. package/foundation/Button/Button.d.ts +17 -0
  84. package/foundation/Button/Button.types.d.ts +112 -0
  85. package/foundation/Button/ButtonInternals.d.ts +11 -0
  86. package/foundation/Button/ButtonProvider.d.ts +11 -0
  87. package/foundation/Button/index.d.mts +4 -0
  88. package/foundation/Button/useButtonStyles.d.ts +17 -0
  89. package/foundation/Button-es.js +122 -0
  90. package/foundation/ButtonDismiss/ButtonDismiss.d.ts +6 -0
  91. package/foundation/ButtonDismiss/index.d.mts +1 -0
  92. package/foundation/ButtonDismiss-es.js +9 -0
  93. package/foundation/Card/Card.d.ts +78 -0
  94. package/foundation/Card/cardcolors.module.d.ts +90 -0
  95. package/foundation/Card/index.d.mts +1 -0
  96. package/foundation/Card/index.mjs +37 -0
  97. package/foundation/Card/types.d.ts +63 -0
  98. package/foundation/Card-es.js +138 -0
  99. package/foundation/Checkbox/Checkbox.d.ts +7 -0
  100. package/foundation/Checkbox/Checkbox.types.d.ts +51 -0
  101. package/foundation/Checkbox/index.d.mts +2 -0
  102. package/foundation/Checkbox/index.mjs +8 -0
  103. package/foundation/Checkbox-es.js +57 -0
  104. package/foundation/Chip/Chip.d.ts +14 -0
  105. package/foundation/Chip/Chip.types.d.ts +70 -0
  106. package/foundation/Chip/components/ChipDismissible/ChipDismissible.d.ts +3 -0
  107. package/foundation/Chip/components/ChipPrefix/Chip.Prefix.d.ts +3 -0
  108. package/foundation/Chip/components/ChipSelectable/ChipSelectable.d.ts +3 -0
  109. package/foundation/Chip/components/ChipSuffix/Chip.Suffix.d.ts +9 -0
  110. package/foundation/Chip/index.d.mts +4 -0
  111. package/foundation/Chip/index.mjs +19 -0
  112. package/foundation/Chip-es.js +165 -0
  113. package/foundation/ChipDismissible-es.js +19 -0
  114. package/foundation/Chips/Chip.d.ts +9 -0
  115. package/foundation/Chips/ChipDismissible.d.ts +11 -0
  116. package/foundation/Chips/ChipTypes.d.ts +59 -0
  117. package/foundation/Chips/Chips.d.ts +8 -0
  118. package/foundation/Chips/ChipsTypes.d.ts +106 -0
  119. package/foundation/Chips/InternalChipButton.d.ts +11 -0
  120. package/foundation/Chips/index.d.mts +3 -0
  121. package/foundation/Chips/index.mjs +56 -0
  122. package/foundation/Chips-es.js +114 -0
  123. package/foundation/Cluster/Cluster.d.ts +3 -0
  124. package/foundation/Cluster/index.d.mts +2 -0
  125. package/foundation/Cluster/index.mjs +4 -0
  126. package/foundation/Cluster/types.d.ts +47 -0
  127. package/foundation/Cluster-es.js +12 -0
  128. package/foundation/Combobox/Combobox.d.ts +71 -0
  129. package/foundation/Combobox/Combobox.footer.d.ts +7 -0
  130. package/foundation/Combobox/Combobox.items.d.ts +25 -0
  131. package/foundation/Combobox/Combobox.selectAll.d.ts +4 -0
  132. package/foundation/Combobox/Combobox.slotFactory.d.ts +7 -0
  133. package/foundation/Combobox/Combobox.types.d.ts +168 -0
  134. package/foundation/Combobox/index.d.mts +2 -0
  135. package/foundation/Combobox/index.mjs +28 -0
  136. package/foundation/Combobox-es.js +782 -0
  137. package/foundation/ComboboxPrimitive-es.js +187 -0
  138. package/foundation/ComboboxSeparator-es.js +3541 -0
  139. package/foundation/ComponentSettingsContext/ComponentSettingsContext.d.ts +41 -0
  140. package/foundation/ComponentSettingsContext/index.d.mts +4 -0
  141. package/foundation/ComponentSettingsContext/index.mjs +5 -0
  142. package/foundation/ComponentSettingsContext-es.js +18 -0
  143. package/foundation/ConfirmationModal/ConfirmationModal.d.ts +79 -0
  144. package/foundation/ConfirmationModal/index.d.mts +1 -0
  145. package/foundation/ConfirmationModal/index.mjs +37 -0
  146. package/foundation/ConfirmationModal-es.js +111 -0
  147. package/foundation/Container/Container.d.ts +6 -0
  148. package/foundation/Container/index.d.mts +1 -0
  149. package/foundation/Container/index.mjs +3 -0
  150. package/foundation/Container/types.d.ts +22 -0
  151. package/foundation/Container-es.js +16 -0
  152. package/foundation/Content/Content.d.ts +22 -0
  153. package/foundation/Content/Spacing.module.d.ts +14 -0
  154. package/foundation/Content/index.d.mts +1 -0
  155. package/foundation/Content/index.mjs +3 -0
  156. package/foundation/Content-es.js +13 -0
  157. package/foundation/ContentBlock/ContentBlock.d.ts +3 -0
  158. package/foundation/ContentBlock/index.d.mts +2 -0
  159. package/foundation/ContentBlock/index.mjs +4 -0
  160. package/foundation/ContentBlock/types.d.ts +37 -0
  161. package/foundation/ContentBlock-es.js +29 -0
  162. package/foundation/Countdown/Countdown.d.ts +30 -0
  163. package/foundation/Countdown/index.d.mts +1 -0
  164. package/foundation/Countdown/index.mjs +4 -0
  165. package/foundation/Countdown-es.js +649 -0
  166. package/foundation/Cover/Cover.d.ts +6 -0
  167. package/foundation/Cover/index.d.mts +2 -0
  168. package/foundation/Cover/index.mjs +4 -0
  169. package/foundation/Cover/types.d.ts +34 -0
  170. package/foundation/Cover-es.js +14 -0
  171. package/foundation/DataDump/DataDump.d.ts +21 -0
  172. package/foundation/DataDump/index.d.mts +1 -0
  173. package/foundation/DataDump/index.mjs +40 -0
  174. package/foundation/DataDump-es.js +26 -0
  175. package/foundation/DataList/DataList.const.d.ts +22 -0
  176. package/foundation/DataList/DataList.d.ts +28 -0
  177. package/foundation/DataList/DataList.types.d.ts +323 -0
  178. package/foundation/DataList/components/DataListAction/DataListAction.d.ts +3 -0
  179. package/foundation/DataList/components/DataListAction/index.d.mts +1 -0
  180. package/foundation/DataList/components/DataListBulkActions/DataListBulkActions.d.ts +4 -0
  181. package/foundation/DataList/components/DataListBulkActions/index.d.mts +1 -0
  182. package/foundation/DataList/components/DataListEmptyState/DataListEmptyState.d.ts +4 -0
  183. package/foundation/DataList/components/DataListEmptyState/index.d.mts +1 -0
  184. package/foundation/DataList/components/DataListFilters/DataListFilters.d.ts +11 -0
  185. package/foundation/DataList/components/DataListFilters/index.d.mts +1 -0
  186. package/foundation/DataList/components/DataListItemActions/DataListItemActions.d.ts +9 -0
  187. package/foundation/DataList/components/DataListItemActions/index.d.mts +1 -0
  188. package/foundation/DataList/components/DataListLayout/DataListLayout.d.ts +3 -0
  189. package/foundation/DataList/components/DataListLayout/index.d.mts +1 -0
  190. package/foundation/DataList/components/DataListLayoutActions/DataListLayoutActions.d.ts +2 -0
  191. package/foundation/DataList/components/DataListLayoutActions/index.d.mts +1 -0
  192. package/foundation/DataList/components/DataListSearch/DataListSearch.d.ts +8 -0
  193. package/foundation/DataList/components/DataListSearch/index.d.mts +1 -0
  194. package/foundation/DataList/components/DataListStatusBar/DataListStatusBar.d.ts +11 -0
  195. package/foundation/DataList/components/DataListStatusBar/index.d.mts +1 -0
  196. package/foundation/DataList/index.d.mts +2 -0
  197. package/foundation/DataList/index.mjs +96 -0
  198. package/foundation/DataList-es.js +141 -0
  199. package/foundation/DataList.const-es.js +26 -0
  200. package/foundation/DataList.module-es.js +3 -0
  201. package/foundation/DataList.utils-es.js +167 -0
  202. package/foundation/DataListAction-es.js +43 -0
  203. package/foundation/DataListActions-es.js +53 -0
  204. package/foundation/DataListActionsMenu-es.js +52 -0
  205. package/foundation/DataListBulkActions-es.js +28 -0
  206. package/foundation/DataListContext-es.js +26 -0
  207. package/foundation/DataListEmptyState-es.js +54 -0
  208. package/foundation/DataListFilters-es.js +43 -0
  209. package/foundation/DataListHeader-es.js +130 -0
  210. package/foundation/DataListHeaderTile-es.js +86 -0
  211. package/foundation/DataListItem-es.js +118 -0
  212. package/foundation/DataListItemActions-es.js +29 -0
  213. package/foundation/DataListItemActionsOverflow-es.js +34 -0
  214. package/foundation/DataListItemClickable-es.js +45 -0
  215. package/foundation/DataListItems-es.js +19 -0
  216. package/foundation/DataListLayout-es.js +19 -0
  217. package/foundation/DataListLayoutActions-es.js +36 -0
  218. package/foundation/DataListLayoutContext-es.js +14 -0
  219. package/foundation/DataListLayoutContext-es2.js +8 -0
  220. package/foundation/DataListLoadMore-es.js +32 -0
  221. package/foundation/DataListLoadingState-es.js +22 -0
  222. package/foundation/DataListOverflowFade-es.js +22 -0
  223. package/foundation/DataListSearch-es.js +84 -0
  224. package/foundation/DataListSort-es.js +74 -0
  225. package/foundation/DataListSortingOptions-es.js +34 -0
  226. package/foundation/DataListStatusBar-es.js +22 -0
  227. package/foundation/DataListStickyHeader-es.js +23 -0
  228. package/foundation/DataListTags-es.js +62 -0
  229. package/foundation/DataListTotalCount-es.js +38 -0
  230. package/foundation/DataTable/DataTable.d.ts +74 -0
  231. package/foundation/DataTable/SortIcon.d.ts +11 -0
  232. package/foundation/DataTable/components/DataTableActions.d.ts +2 -0
  233. package/foundation/DataTable/components/DataTableBody.d.ts +2 -0
  234. package/foundation/DataTable/components/DataTableCell.d.ts +2 -0
  235. package/foundation/DataTable/components/DataTableContainer.d.ts +2 -0
  236. package/foundation/DataTable/components/DataTableFooter.d.ts +5 -0
  237. package/foundation/DataTable/components/DataTableHeader.d.ts +2 -0
  238. package/foundation/DataTable/components/DataTableHeaderCell.d.ts +5 -0
  239. package/foundation/DataTable/components/DataTablePagination.d.ts +5 -0
  240. package/foundation/DataTable/components/DataTablePaginationButton.d.ts +21 -0
  241. package/foundation/DataTable/components/DataTableRow.d.ts +2 -0
  242. package/foundation/DataTable/components/DataTableRowActions.d.ts +4 -0
  243. package/foundation/DataTable/components/DataTableSortableHeader.d.ts +24 -0
  244. package/foundation/DataTable/components/DataTableTable.d.ts +11 -0
  245. package/foundation/DataTable/components/index.d.mts +13 -0
  246. package/foundation/DataTable/index.d.mts +6 -0
  247. package/foundation/DataTable/index.mjs +29 -0
  248. package/foundation/DataTable/test-utilities/helpers.d.ts +1 -0
  249. package/foundation/DataTable/types.d.ts +83 -0
  250. package/foundation/DataTable-es.js +262 -0
  251. package/foundation/DataTableTable-es.js +117 -0
  252. package/foundation/DatePicker/DatePicker.d.ts +74 -0
  253. package/foundation/DatePicker/DatePickerActivator.d.ts +18 -0
  254. package/foundation/DatePicker/index.d.mts +1 -0
  255. package/foundation/DatePicker/index.mjs +26 -0
  256. package/foundation/DatePicker-es.js +13627 -0
  257. package/foundation/Dialog/dialogReturnFocus.d.ts +43 -0
  258. package/foundation/Disclosure/Disclosure.d.ts +68 -0
  259. package/foundation/Disclosure/index.d.mts +1 -0
  260. package/foundation/Disclosure/index.mjs +7 -0
  261. package/foundation/Disclosure-es.js +46 -0
  262. package/foundation/Divider/Divider.d.ts +39 -0
  263. package/foundation/Divider/DividerDirections.module.d.ts +6 -0
  264. package/foundation/Divider/DividerSizes.module.d.ts +8 -0
  265. package/foundation/Divider/index.d.mts +1 -0
  266. package/foundation/Divider/index.mjs +3 -0
  267. package/foundation/Divider-es.js +15 -0
  268. package/foundation/Drawer/Drawer.d.ts +14 -0
  269. package/foundation/Drawer/DrawerGrid.d.ts +7 -0
  270. package/foundation/Drawer/index.d.mts +2 -0
  271. package/foundation/Drawer/index.mjs +13 -0
  272. package/foundation/DrawerGrid-es.js +39 -0
  273. package/foundation/DrawerTitle-es.js +90 -0
  274. package/foundation/Emphasis/Emphasis.d.ts +12 -0
  275. package/foundation/Emphasis/index.d.mts +1 -0
  276. package/foundation/Emphasis/index.mjs +4 -0
  277. package/foundation/Emphasis-es.js +13 -0
  278. package/foundation/FeatureSwitch/FeatureSwitch.d.ts +52 -0
  279. package/foundation/FeatureSwitch/index.d.mts +1 -0
  280. package/foundation/FeatureSwitch/index.mjs +20 -0
  281. package/foundation/FeatureSwitch-es.js +66 -0
  282. package/foundation/FieldDescription-es.js +859 -0
  283. package/foundation/FilterPicker/FilterPicker.d.ts +11 -0
  284. package/foundation/FilterPicker/FilterPicker.types.d.ts +282 -0
  285. package/foundation/FilterPicker/FilterPickerProvider.d.ts +18 -0
  286. package/foundation/FilterPicker/components/FilterPickerAction/FilterPickerAction.d.ts +3 -0
  287. package/foundation/FilterPicker/components/FilterPickerAction/index.d.mts +1 -0
  288. package/foundation/FilterPicker/components/FilterPickerActivator/FilterPickerActivator.d.ts +3 -0
  289. package/foundation/FilterPicker/components/FilterPickerActivator/index.d.mts +1 -0
  290. package/foundation/FilterPicker/components/FilterPickerOption/FilterPickerOption.d.ts +3 -0
  291. package/foundation/FilterPicker/index.d.mts +3 -0
  292. package/foundation/FilterPicker/index.mjs +49 -0
  293. package/foundation/FilterPicker-es.js +110 -0
  294. package/foundation/FilterPicker.messages-es.js +56 -0
  295. package/foundation/FilterPickerAction-es.js +30 -0
  296. package/foundation/FilterPickerActivator-es.js +36 -0
  297. package/foundation/FilterPickerContent-es.js +180 -0
  298. package/foundation/FilterPickerContentHeader-es.js +23 -0
  299. package/foundation/FilterPickerContentList-es.js +74 -0
  300. package/foundation/FilterPickerContentSearch-es.js +35 -0
  301. package/foundation/FilterPickerLoadMore-es.js +14 -0
  302. package/foundation/FilterPickerOption-es.js +29 -0
  303. package/foundation/FilterPickerProvider-es.js +10 -0
  304. package/foundation/FilterPickerTrigger-es.js +19 -0
  305. package/foundation/Flex/Flex.d.ts +33 -0
  306. package/foundation/Flex/Flex.types.d.ts +6 -0
  307. package/foundation/Flex/index.d.mts +1 -0
  308. package/foundation/Flex/index.mjs +3 -0
  309. package/foundation/Flex-es.js +28 -0
  310. package/foundation/FormField/FormFieldAffix.d.ts +19 -0
  311. package/foundation/FormField/FormFieldTypes.d.ts +185 -0
  312. package/foundation/FormField/FormFieldWrapper.d.ts +57 -0
  313. package/foundation/FormField/hooks/useFormFieldName.d.ts +6 -0
  314. package/foundation/FormField/hooks/useFormFieldWrapperStyles.d.ts +35 -0
  315. package/foundation/FormField/index.d.mts +5 -0
  316. package/foundation/FormField/index.mjs +17 -0
  317. package/foundation/FormFieldPostFix-es.js +13 -0
  318. package/foundation/FormFieldWrapper-es.js +233 -0
  319. package/foundation/FormatFile/FormatFile.d.ts +42 -0
  320. package/foundation/FormatFile/index.d.mts +4 -0
  321. package/foundation/FormatFile/index.mjs +42 -0
  322. package/foundation/FormatFile/types.d.ts +27 -0
  323. package/foundation/FormatFile/useFormatFile.d.ts +5 -0
  324. package/foundation/FormatFile/useFormatFileStyles.d.ts +10 -0
  325. package/foundation/FormatFile-es.js +137 -0
  326. package/foundation/Frame/Frame.d.ts +3 -0
  327. package/foundation/Frame/index.d.mts +2 -0
  328. package/foundation/Frame/index.mjs +3 -0
  329. package/foundation/Frame/types.d.ts +24 -0
  330. package/foundation/Frame-es.js +10 -0
  331. package/foundation/Gallery/Gallery.d.ts +3 -0
  332. package/foundation/Gallery/GalleryTypes.d.ts +36 -0
  333. package/foundation/Gallery/index.d.mts +3 -0
  334. package/foundation/Gallery/index.mjs +64 -0
  335. package/foundation/Gallery-es.js +88 -0
  336. package/foundation/Glimmer/Glimmer.d.ts +71 -0
  337. package/foundation/Glimmer/index.d.mts +1 -0
  338. package/foundation/Glimmer/index.mjs +5 -0
  339. package/foundation/Glimmer/style/Shape.module.d.ts +9 -0
  340. package/foundation/Glimmer/style/Sizes.module.d.ts +10 -0
  341. package/foundation/Glimmer/style/Timing.module.d.ts +6 -0
  342. package/foundation/Glimmer-es.js +53 -0
  343. package/foundation/Grid/Grid.d.ts +32 -0
  344. package/foundation/Grid/GridAlign.module.d.ts +8 -0
  345. package/foundation/Grid/GridCell/GridCell.d.ts +23 -0
  346. package/foundation/Grid/GridCell/index.d.mts +1 -0
  347. package/foundation/Grid/index.d.mts +1 -0
  348. package/foundation/Grid/index.mjs +5 -0
  349. package/foundation/Grid-es.js +30 -0
  350. package/foundation/GridCell-es.js +34 -0
  351. package/foundation/Heading/Heading.d.ts +41 -0
  352. package/foundation/Heading/index.d.mts +2 -0
  353. package/foundation/Heading/index.mjs +4 -0
  354. package/foundation/Heading-es.js +55 -0
  355. package/foundation/HelperText-es.js +19 -0
  356. package/foundation/Icon/Icon.d.ts +47 -0
  357. package/foundation/Icon/index.d.mts +1 -0
  358. package/foundation/Icon-es.js +22 -0
  359. package/foundation/InlineLabel/InlineLabel.d.ts +18 -0
  360. package/foundation/InlineLabel/index.d.mts +1 -0
  361. package/foundation/InlineLabel/index.mjs +4 -0
  362. package/foundation/InlineLabel-es.js +19 -0
  363. package/foundation/InputAvatar/InputAvatar.d.ts +23 -0
  364. package/foundation/InputAvatar/index.d.mts +1 -0
  365. package/foundation/InputAvatar/index.mjs +22 -0
  366. package/foundation/InputAvatar-es.js +64 -0
  367. package/foundation/InputDate/InputDate.d.ts +3 -0
  368. package/foundation/InputDate/InputDate.types.d.ts +36 -0
  369. package/foundation/InputDate/index.d.mts +2 -0
  370. package/foundation/InputDate/index.mjs +39 -0
  371. package/foundation/InputDate-es.js +104 -0
  372. package/foundation/InputEmail/InputEmail.d.ts +3 -0
  373. package/foundation/InputEmail/InputEmail.types.d.ts +16 -0
  374. package/foundation/InputEmail/index.d.mts +2 -0
  375. package/foundation/InputEmail/index.mjs +22 -0
  376. package/foundation/InputEmail-es.js +105 -0
  377. package/foundation/InputFile/FileTypes.d.ts +17 -0
  378. package/foundation/InputFile/InputFile.d.ts +187 -0
  379. package/foundation/InputFile/InputFileButton.d.ts +6 -0
  380. package/foundation/InputFile/InputFileContentContext.d.ts +12 -0
  381. package/foundation/InputFile/InputFileDescription.d.ts +4 -0
  382. package/foundation/InputFile/InputFileDropzoneWrapper.d.ts +4 -0
  383. package/foundation/InputFile/InputFileHintText.d.ts +4 -0
  384. package/foundation/InputFile/index.d.mts +3 -0
  385. package/foundation/InputFile/index.mjs +16 -0
  386. package/foundation/InputFile-es.js +1780 -0
  387. package/foundation/InputGroup/InputGroup.d.ts +12 -0
  388. package/foundation/InputGroup/index.d.mts +1 -0
  389. package/foundation/InputGroup/index.mjs +3 -0
  390. package/foundation/InputGroup-es.js +26 -0
  391. package/foundation/InputNumber/InputNumber.d.ts +77 -0
  392. package/foundation/InputNumber/index.d.mts +2 -0
  393. package/foundation/InputNumber/index.mjs +33 -0
  394. package/foundation/InputNumber/types.d.ts +197 -0
  395. package/foundation/InputNumber-es.js +348 -0
  396. package/foundation/InputPhoneNumber/InputPhoneNumber.d.ts +3 -0
  397. package/foundation/InputPhoneNumber/InputPhoneNumber.types.d.ts +24 -0
  398. package/foundation/InputPhoneNumber/index.d.mts +2 -0
  399. package/foundation/InputPhoneNumber/index.mjs +22 -0
  400. package/foundation/InputPhoneNumber-es.js +188 -0
  401. package/foundation/InputText/InputText.d.ts +3 -0
  402. package/foundation/InputText/InputText.types.d.ts +58 -0
  403. package/foundation/InputText/index.d.mts +2 -0
  404. package/foundation/InputText/index.mjs +23 -0
  405. package/foundation/InputText-es.js +196 -0
  406. package/foundation/InputTime/InputTime.d.ts +3 -0
  407. package/foundation/InputTime/InputTime.types.d.ts +34 -0
  408. package/foundation/InputTime/index.d.mts +2 -0
  409. package/foundation/InputTime/index.mjs +23 -0
  410. package/foundation/InputTime-es.js +297 -0
  411. package/foundation/InputValidation/InputValidation.d.ts +10 -0
  412. package/foundation/InputValidation/index.d.mts +1 -0
  413. package/foundation/InputValidation/index.mjs +8 -0
  414. package/foundation/InputValidation-es.js +22 -0
  415. package/foundation/InternalChipDismissible-es.js +68 -0
  416. package/foundation/LICENSE +21 -0
  417. package/foundation/LegacySelect/LegacySelect.d.ts +7 -0
  418. package/foundation/LegacySelect/LegacySelect.types.d.ts +18 -0
  419. package/foundation/LegacySelect/Option.d.ts +18 -0
  420. package/foundation/LegacySelect/OptionGroup.d.ts +29 -0
  421. package/foundation/LegacySelect/index.d.mts +3 -0
  422. package/foundation/LegacySelect/index.mjs +23 -0
  423. package/foundation/LegacySelect-es.js +76 -0
  424. package/foundation/LegacyThemeContext/LegacyThemeContext.d.ts +5 -0
  425. package/foundation/LegacyThemeContext/index.d.mts +3 -0
  426. package/foundation/LegacyThemeContext/index.mjs +12 -0
  427. package/foundation/LegacyThemeContext/types.d.ts +59 -0
  428. package/foundation/LegacyThemeContext/updateTheme.d.ts +7 -0
  429. package/foundation/LegacyThemeContext-es.js +457 -0
  430. package/foundation/LightBox/LightBox.d.ts +165 -0
  431. package/foundation/LightBox/LightBox.types.d.ts +153 -0
  432. package/foundation/LightBox/LightBoxContext.d.ts +5 -0
  433. package/foundation/LightBox/index.d.mts +3 -0
  434. package/foundation/LightBox/index.mjs +50 -0
  435. package/foundation/LightBox-es.js +454 -0
  436. package/foundation/Link/Link.d.ts +9 -0
  437. package/foundation/Link/index.d.mts +2 -0
  438. package/foundation/Link/index.mjs +2 -0
  439. package/foundation/Link-es.js +12 -0
  440. package/foundation/List/List.d.ts +41 -0
  441. package/foundation/List/ListItem.d.ts +59 -0
  442. package/foundation/List/index.d.mts +2 -0
  443. package/foundation/List/index.mjs +22 -0
  444. package/foundation/List-es.js +199 -0
  445. package/foundation/Markdown/Markdown.d.ts +24 -0
  446. package/foundation/Markdown/index.d.mts +1 -0
  447. package/foundation/Markdown/index.mjs +10 -0
  448. package/foundation/Markdown-es.js +20558 -0
  449. package/foundation/Menu/Menu.d.ts +89 -0
  450. package/foundation/Menu/Menu.types.d.ts +105 -0
  451. package/foundation/Menu/index.d.mts +2 -0
  452. package/foundation/Menu/index.mjs +35 -0
  453. package/foundation/Menu/menuComposableTypes.d.ts +103 -0
  454. package/foundation/Menu-es.js +1033 -0
  455. package/foundation/MenuSubmenuTrigger-es.js +3088 -0
  456. package/foundation/Modal/Modal.rebuilt.d.ts +16 -0
  457. package/foundation/Modal/Modal.types.d.ts +138 -0
  458. package/foundation/Modal/ModalContext.rebuilt.d.ts +19 -0
  459. package/foundation/Modal/ModalSizes.module.d.ts +7 -0
  460. package/foundation/Modal/index.d.mts +17 -0
  461. package/foundation/Modal/index.mjs +302 -0
  462. package/foundation/Modal/useModalStyles.d.ts +12 -0
  463. package/foundation/MultiSelect/MultiSelect.d.ts +30 -0
  464. package/foundation/MultiSelect/index.d.mts +1 -0
  465. package/foundation/MultiSelect/index.mjs +9 -0
  466. package/foundation/MultiSelect/types.d.ts +13 -0
  467. package/foundation/MultiSelect-es.js +172 -0
  468. package/foundation/OverlaySeparator-es.js +13 -0
  469. package/foundation/Page/Page.d.ts +74 -0
  470. package/foundation/Page/index.d.mts +2 -0
  471. package/foundation/Page/index.mjs +42 -0
  472. package/foundation/Page/types.d.ts +123 -0
  473. package/foundation/Page-es.js +196 -0
  474. package/foundation/Popover/Popover.d.ts +9 -0
  475. package/foundation/Popover/Popover.types.d.ts +109 -0
  476. package/foundation/Popover/PopoverContext.d.ts +18 -0
  477. package/foundation/Popover/index.d.mts +4 -0
  478. package/foundation/Popover/index.mjs +27 -0
  479. package/foundation/Popover/usePopoverStyles.d.ts +5 -0
  480. package/foundation/Popover-es.js +166 -0
  481. package/foundation/ProgressBar/ProgressBar.d.ts +41 -0
  482. package/foundation/ProgressBar/ProgressBarSizes.module.d.ts +7 -0
  483. package/foundation/ProgressBar/index.d.mts +1 -0
  484. package/foundation/ProgressBar/index.mjs +5 -0
  485. package/foundation/ProgressBar-es.js +48 -0
  486. package/foundation/ProgressIndicator/ProgressIndicator.d.ts +60 -0
  487. package/foundation/ProgressIndicator/index.d.mts +1 -0
  488. package/foundation/ProgressIndicator/index.mjs +3 -0
  489. package/foundation/ProgressIndicator-es.js +41 -0
  490. package/foundation/RadioGroup/RadioGroup.d.ts +33 -0
  491. package/foundation/RadioGroup/RadioOption.d.ts +48 -0
  492. package/foundation/RadioGroup/index.d.mts +2 -0
  493. package/foundation/RadioGroup/index.mjs +5 -0
  494. package/foundation/RadioGroup-es.js +42 -0
  495. package/foundation/ResponsiveSwitcher/ResponsiveSwitcher.d.ts +3 -0
  496. package/foundation/ResponsiveSwitcher/index.d.mts +2 -0
  497. package/foundation/ResponsiveSwitcher/index.mjs +4 -0
  498. package/foundation/ResponsiveSwitcher/types.d.ts +26 -0
  499. package/foundation/ResponsiveSwitcher-es.js +11 -0
  500. package/foundation/RulnarPortalContent-es.js +1 -0
  501. package/foundation/ScrollAreaViewport-es.js +3959 -0
  502. package/foundation/SegmentedControl/SegmentedControl.d.ts +39 -0
  503. package/foundation/SegmentedControl/SegmentedControlBase.d.ts +7 -0
  504. package/foundation/SegmentedControl/SegmentedControlOption.d.ts +15 -0
  505. package/foundation/SegmentedControl/SegmentedControlProvider.d.ts +17 -0
  506. package/foundation/SegmentedControl/index.d.mts +2 -0
  507. package/foundation/SegmentedControl/index.mjs +3 -0
  508. package/foundation/SegmentedControl-es.js +64 -0
  509. package/foundation/Select/Select.d.ts +31 -0
  510. package/foundation/Select/Select.types.d.ts +145 -0
  511. package/foundation/Select/index.d.mts +2 -0
  512. package/foundation/Select/index.mjs +29 -0
  513. package/foundation/Select-es.js +227 -0
  514. package/foundation/SelectGroupLabel-es.js +1763 -0
  515. package/foundation/SelectPrimitive-es.js +126 -0
  516. package/foundation/Separator-es.js +33 -0
  517. package/foundation/SideDrawer/SideDrawer.d.ts +56 -0
  518. package/foundation/SideDrawer/SideDrawerActions.d.ts +3 -0
  519. package/foundation/SideDrawer/SideDrawerBackButton.d.ts +3 -0
  520. package/foundation/SideDrawer/SideDrawerFooter.d.ts +3 -0
  521. package/foundation/SideDrawer/SideDrawerTitle.d.ts +3 -0
  522. package/foundation/SideDrawer/SideDrawerToolbar.d.ts +2 -0
  523. package/foundation/SideDrawer/index.d.mts +1 -0
  524. package/foundation/SideDrawer/index.mjs +16 -0
  525. package/foundation/SideDrawer-es.js +198 -0
  526. package/foundation/SideKick/SideKick.d.ts +3 -0
  527. package/foundation/SideKick/index.d.mts +2 -0
  528. package/foundation/SideKick/index.mjs +4 -0
  529. package/foundation/SideKick/types.d.ts +35 -0
  530. package/foundation/SideKick-es.js +15 -0
  531. package/foundation/Spinner/Spinner.d.ts +22 -0
  532. package/foundation/Spinner/index.d.mts +1 -0
  533. package/foundation/Spinner/index.mjs +6 -0
  534. package/foundation/Spinner-es.js +21 -0
  535. package/foundation/Stack/Stack.d.ts +3 -0
  536. package/foundation/Stack/index.d.mts +2 -0
  537. package/foundation/Stack/index.mjs +4 -0
  538. package/foundation/Stack/types.d.ts +32 -0
  539. package/foundation/Stack-es.js +13 -0
  540. package/foundation/StatusIndicator/StatusIndicator.d.ts +7 -0
  541. package/foundation/StatusIndicator/StatusIndicator.type.d.ts +1 -0
  542. package/foundation/StatusIndicator/index.d.mts +2 -0
  543. package/foundation/StatusIndicator/index.mjs +2 -0
  544. package/foundation/StatusIndicator-es.js +9 -0
  545. package/foundation/StatusLabel/StatusLabel.d.ts +26 -0
  546. package/foundation/StatusLabel/index.d.mts +1 -0
  547. package/foundation/StatusLabel/index.mjs +5 -0
  548. package/foundation/StatusLabel-es.js +16 -0
  549. package/foundation/Table/Body.d.ts +7 -0
  550. package/foundation/Table/Cells/Cell.d.ts +8 -0
  551. package/foundation/Table/Cells/CellCurrency.d.ts +9 -0
  552. package/foundation/Table/Cells/CellNumeric.d.ts +5 -0
  553. package/foundation/Table/Footer.d.ts +7 -0
  554. package/foundation/Table/Header.d.ts +7 -0
  555. package/foundation/Table/Row.d.ts +7 -0
  556. package/foundation/Table/Table.d.ts +7 -0
  557. package/foundation/Table/index.d.mts +8 -0
  558. package/foundation/Table/index.mjs +4 -0
  559. package/foundation/Tabs/Tabs.d.ts +38 -0
  560. package/foundation/Tabs/index.d.mts +1 -0
  561. package/foundation/Tabs/index.mjs +8 -0
  562. package/foundation/Tabs-es.js +227 -0
  563. package/foundation/Text/Text.d.ts +29 -0
  564. package/foundation/Text/index.d.mts +2 -0
  565. package/foundation/Text/index.mjs +4 -0
  566. package/foundation/Text-es.js +25 -0
  567. package/foundation/Thumbnail/Thumbnail.d.ts +25 -0
  568. package/foundation/Thumbnail/index.d.mts +1 -0
  569. package/foundation/Thumbnail/index.mjs +9 -0
  570. package/foundation/Thumbnail-es.js +119 -0
  571. package/foundation/Tiles/Tiles.d.ts +3 -0
  572. package/foundation/Tiles/index.d.mts +2 -0
  573. package/foundation/Tiles/index.mjs +4 -0
  574. package/foundation/Tiles/types.d.ts +34 -0
  575. package/foundation/Tiles-es.js +11 -0
  576. package/foundation/Tooltip/Tooltip.d.ts +18 -0
  577. package/foundation/Tooltip/Tooltip.types.d.ts +1 -0
  578. package/foundation/Tooltip/index.d.mts +1 -0
  579. package/foundation/Tooltip/index.mjs +8 -0
  580. package/foundation/Tooltip-es.js +137 -0
  581. package/foundation/Typography/Typography.d.ts +64 -0
  582. package/foundation/Typography/css/Emphasis.module.d.ts +6 -0
  583. package/foundation/Typography/css/FontFamilies.module.d.ts +6 -0
  584. package/foundation/Typography/css/FontSizes.module.d.ts +12 -0
  585. package/foundation/Typography/css/FontWeights.module.d.ts +10 -0
  586. package/foundation/Typography/css/TextAlignment.module.d.ts +7 -0
  587. package/foundation/Typography/css/TextCases.module.d.ts +8 -0
  588. package/foundation/Typography/css/TextColors.module.d.ts +69 -0
  589. package/foundation/Typography/index.d.mts +1 -0
  590. package/foundation/Typography/index.mjs +3 -0
  591. package/foundation/Typography/types.d.ts +7 -0
  592. package/foundation/Typography-es.js +53 -0
  593. package/foundation/_baseAssignValue-es.js +29 -0
  594. package/foundation/_baseEach-es.js +1028 -0
  595. package/foundation/_baseFlatten-es.js +65 -0
  596. package/foundation/_baseFor-es.js +45 -0
  597. package/foundation/_commonjsHelpers-es.js +7 -0
  598. package/foundation/_getAllKeys-es.js +506 -0
  599. package/foundation/_getTag-es.js +133 -0
  600. package/foundation/_isIterateeCall-es.js +55 -0
  601. package/foundation/_setToString-es.js +168 -0
  602. package/foundation/buttonRenderAdapter-es.js +52 -0
  603. package/foundation/buttonStyles.d.mts +1 -0
  604. package/foundation/buttonStyles.mjs +1 -0
  605. package/foundation/clearable.d.ts +1 -0
  606. package/foundation/common.messages-es.js +18 -0
  607. package/foundation/compatHooks.mjs +2 -0
  608. package/foundation/constants-es.js +3 -0
  609. package/foundation/dateLocale-es.js +1142 -0
  610. package/foundation/debounce-es.js +329 -0
  611. package/foundation/dialogFocus.d.mts +1 -0
  612. package/foundation/dialogFocus.mjs +66 -0
  613. package/foundation/filterDataAttributes-es.js +24 -0
  614. package/foundation/floating-ui.react-es.js +6174 -0
  615. package/foundation/getMappedSpaceToken-es.js +18 -0
  616. package/foundation/helpers-es.js +15 -0
  617. package/foundation/identity-es.js +809 -0
  618. package/foundation/imageTypes.d.mts +1 -0
  619. package/foundation/imageTypes.mjs +1 -0
  620. package/foundation/index-es.js +1186 -0
  621. package/foundation/isObjectLike-es.js +190 -0
  622. package/foundation/isSymbol-es.js +33 -0
  623. package/foundation/isTypedArray-es.js +589 -0
  624. package/foundation/keysIn-es.js +385 -0
  625. package/foundation/linkEvents.d.mts +1 -0
  626. package/foundation/linkEvents.mjs +9 -0
  627. package/foundation/maxHeight-es.js +22 -0
  628. package/foundation/mergeClassName-es.js +10 -0
  629. package/foundation/mergeRefs-es.js +18 -0
  630. package/foundation/nestedEscape-es.js +91 -0
  631. package/foundation/noop-es.js +24 -0
  632. package/foundation/primitives/BottomSheet/BottomSheet.d.ts +37 -0
  633. package/foundation/primitives/BottomSheet/BottomSheet.types.d.ts +36 -0
  634. package/foundation/primitives/BottomSheet/index.d.mts +2 -0
  635. package/foundation/primitives/ComboboxPrimitive/ComboboxPrimitive.d.ts +32 -0
  636. package/foundation/primitives/ComboboxPrimitive/ComboboxPrimitive.types.d.ts +30 -0
  637. package/foundation/primitives/ComboboxPrimitive/index.d.mts +2 -0
  638. package/foundation/primitives/HelperText/HelperText.d.ts +25 -0
  639. package/foundation/primitives/HelperText/index.d.mts +1 -0
  640. package/foundation/primitives/OverlaySeparator/OverlaySeparator.d.ts +6 -0
  641. package/foundation/primitives/OverlaySeparator/index.d.mts +1 -0
  642. package/foundation/primitives/SelectPrimitive/SelectPrimitive.d.ts +74 -0
  643. package/foundation/primitives/SelectPrimitive/index.d.mts +2 -0
  644. package/foundation/primitives/SelectPrimitive/types.d.ts +31 -0
  645. package/foundation/primitives/index.d.mts +12 -0
  646. package/foundation/primitives/index.mjs +29 -0
  647. package/foundation/routerLink.d.mts +3 -0
  648. package/foundation/routerLink.mjs +1 -0
  649. package/foundation/scrollEdges-es.js +64 -0
  650. package/foundation/scrollable-es.js +54 -0
  651. package/foundation/sharedHelpers/getMappedBreakpointWidth.d.ts +8 -0
  652. package/foundation/sharedHelpers/types.d.ts +254 -0
  653. package/foundation/stringifyLocale-es.js +11 -0
  654. package/foundation/styles.css +16646 -0
  655. package/foundation/tslib.es6-es.js +97 -0
  656. package/foundation/unstyledPrimitives/index.d.mts +22 -0
  657. package/foundation/useActiveLayout-es.js +14 -0
  658. package/foundation/useBatchSelect-es.js +36 -0
  659. package/foundation/useChildComponent-es.js +15 -0
  660. package/foundation/useComponentMessages-es.js +86 -0
  661. package/foundation/useCompositeListItem-es.js +3955 -0
  662. package/foundation/useFormFieldFocus-es.js +37 -0
  663. package/foundation/useFormFieldName-es.js +11 -0
  664. package/foundation/useLabel-es.js +81 -0
  665. package/foundation/useRenderElement-es.js +628 -0
  666. package/foundation/useResponsiveSizing-es.js +8 -0
  667. package/foundation/useScrollLock-es.js +5746 -0
  668. package/foundation/useScrollToActive-es.js +581 -0
  669. package/foundation/utils/isNormalClick.d.ts +6 -0
  670. package/foundation/utils/isPreviewableImage.d.ts +1 -0
  671. package/foundation/utils/meta/meta.json +298 -0
  672. package/foundation.css +67 -0
  673. package/package.json +540 -4
  674. package/src/styles.css +181 -0
@@ -0,0 +1,1780 @@
1
+ import { a as __awaiter, b as __generator, c as __spread, _ as __rest } from './tslib.es6-es.js';
2
+ import React__default, { useMemo, useRef, useReducer, useEffect, useState, useCallback, forwardRef, useImperativeHandle, Fragment, createContext, useContext } from 'react';
3
+ import classnames from 'classnames';
4
+ import { P as PropTypes } from './index-es.js';
5
+ import axios from 'axios';
6
+ import { T as Text } from './Text-es.js';
7
+ import { B as Button } from './Button-es.js';
8
+ import { I as InputValidation } from './InputValidation-es.js';
9
+ import { C as Content } from './Content-es.js';
10
+ import { d as defineMessages, u as useComponentMessages } from './useComponentMessages-es.js';
11
+
12
+ var COMMON_MIME_TYPES = new Map([
13
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
14
+ ['aac', 'audio/aac'],
15
+ ['abw', 'application/x-abiword'],
16
+ ['arc', 'application/x-freearc'],
17
+ ['avif', 'image/avif'],
18
+ ['avi', 'video/x-msvideo'],
19
+ ['azw', 'application/vnd.amazon.ebook'],
20
+ ['bin', 'application/octet-stream'],
21
+ ['bmp', 'image/bmp'],
22
+ ['bz', 'application/x-bzip'],
23
+ ['bz2', 'application/x-bzip2'],
24
+ ['cda', 'application/x-cdf'],
25
+ ['csh', 'application/x-csh'],
26
+ ['css', 'text/css'],
27
+ ['csv', 'text/csv'],
28
+ ['doc', 'application/msword'],
29
+ ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
30
+ ['eot', 'application/vnd.ms-fontobject'],
31
+ ['epub', 'application/epub+zip'],
32
+ ['gz', 'application/gzip'],
33
+ ['gif', 'image/gif'],
34
+ ['htm', 'text/html'],
35
+ ['html', 'text/html'],
36
+ ['ico', 'image/vnd.microsoft.icon'],
37
+ ['ics', 'text/calendar'],
38
+ ['jar', 'application/java-archive'],
39
+ ['jpeg', 'image/jpeg'],
40
+ ['jpg', 'image/jpeg'],
41
+ ['js', 'text/javascript'],
42
+ ['json', 'application/json'],
43
+ ['jsonld', 'application/ld+json'],
44
+ ['mid', 'audio/midi'],
45
+ ['midi', 'audio/midi'],
46
+ ['mjs', 'text/javascript'],
47
+ ['mp3', 'audio/mpeg'],
48
+ ['mp4', 'video/mp4'],
49
+ ['mpeg', 'video/mpeg'],
50
+ ['mpkg', 'application/vnd.apple.installer+xml'],
51
+ ['odp', 'application/vnd.oasis.opendocument.presentation'],
52
+ ['ods', 'application/vnd.oasis.opendocument.spreadsheet'],
53
+ ['odt', 'application/vnd.oasis.opendocument.text'],
54
+ ['oga', 'audio/ogg'],
55
+ ['ogv', 'video/ogg'],
56
+ ['ogx', 'application/ogg'],
57
+ ['opus', 'audio/opus'],
58
+ ['otf', 'font/otf'],
59
+ ['png', 'image/png'],
60
+ ['pdf', 'application/pdf'],
61
+ ['php', 'application/x-httpd-php'],
62
+ ['ppt', 'application/vnd.ms-powerpoint'],
63
+ ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
64
+ ['rar', 'application/vnd.rar'],
65
+ ['rtf', 'application/rtf'],
66
+ ['sh', 'application/x-sh'],
67
+ ['svg', 'image/svg+xml'],
68
+ ['swf', 'application/x-shockwave-flash'],
69
+ ['tar', 'application/x-tar'],
70
+ ['tif', 'image/tiff'],
71
+ ['tiff', 'image/tiff'],
72
+ ['ts', 'video/mp2t'],
73
+ ['ttf', 'font/ttf'],
74
+ ['txt', 'text/plain'],
75
+ ['vsd', 'application/vnd.visio'],
76
+ ['wav', 'audio/wav'],
77
+ ['weba', 'audio/webm'],
78
+ ['webm', 'video/webm'],
79
+ ['webp', 'image/webp'],
80
+ ['woff', 'font/woff'],
81
+ ['woff2', 'font/woff2'],
82
+ ['xhtml', 'application/xhtml+xml'],
83
+ ['xls', 'application/vnd.ms-excel'],
84
+ ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
85
+ ['xml', 'application/xml'],
86
+ ['xul', 'application/vnd.mozilla.xul+xml'],
87
+ ['zip', 'application/zip'],
88
+ ['7z', 'application/x-7z-compressed'],
89
+ // Others
90
+ ['mkv', 'video/x-matroska'],
91
+ ['mov', 'video/quicktime'],
92
+ ['msg', 'application/vnd.ms-outlook']
93
+ ]);
94
+ function toFileWithPath(file, path) {
95
+ var f = withMimeType(file);
96
+ if (typeof f.path !== 'string') { // on electron, path is already set to the absolute path
97
+ var webkitRelativePath = file.webkitRelativePath;
98
+ Object.defineProperty(f, 'path', {
99
+ value: typeof path === 'string'
100
+ ? path
101
+ // If <input webkitdirectory> is set,
102
+ // the File will have a {webkitRelativePath} property
103
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
104
+ : typeof webkitRelativePath === 'string' && webkitRelativePath.length > 0
105
+ ? webkitRelativePath
106
+ : file.name,
107
+ writable: false,
108
+ configurable: false,
109
+ enumerable: true
110
+ });
111
+ }
112
+ return f;
113
+ }
114
+ function withMimeType(file) {
115
+ var name = file.name;
116
+ var hasExtension = name && name.lastIndexOf('.') !== -1;
117
+ if (hasExtension && !file.type) {
118
+ var ext = name.split('.')
119
+ .pop().toLowerCase();
120
+ var type = COMMON_MIME_TYPES.get(ext);
121
+ if (type) {
122
+ Object.defineProperty(file, 'type', {
123
+ value: type,
124
+ writable: false,
125
+ configurable: false,
126
+ enumerable: true
127
+ });
128
+ }
129
+ }
130
+ return file;
131
+ }
132
+
133
+ var FILES_TO_IGNORE = [
134
+ // Thumbnail cache files for macOS and Windows
135
+ '.DS_Store',
136
+ 'Thumbs.db' // Windows
137
+ ];
138
+ /**
139
+ * Convert a DragEvent's DataTrasfer object to a list of File objects
140
+ * NOTE: If some of the items are folders,
141
+ * everything will be flattened and placed in the same list but the paths will be kept as a {path} property.
142
+ *
143
+ * EXPERIMENTAL: A list of https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle objects can also be passed as an arg
144
+ * and a list of File objects will be returned.
145
+ *
146
+ * @param evt
147
+ */
148
+ function fromEvent(evt) {
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ return __generator(this, function (_a) {
151
+ if (isObject(evt) && isDataTransfer(evt)) {
152
+ return [2 /*return*/, getDataTransferFiles(evt.dataTransfer, evt.type)];
153
+ }
154
+ else if (isChangeEvt(evt)) {
155
+ return [2 /*return*/, getInputFiles(evt)];
156
+ }
157
+ else if (Array.isArray(evt) && evt.every(function (item) { return 'getFile' in item && typeof item.getFile === 'function'; })) {
158
+ return [2 /*return*/, getFsHandleFiles(evt)];
159
+ }
160
+ return [2 /*return*/, []];
161
+ });
162
+ });
163
+ }
164
+ function isDataTransfer(value) {
165
+ return isObject(value.dataTransfer);
166
+ }
167
+ function isChangeEvt(value) {
168
+ return isObject(value) && isObject(value.target);
169
+ }
170
+ function isObject(v) {
171
+ return typeof v === 'object' && v !== null;
172
+ }
173
+ function getInputFiles(evt) {
174
+ return fromList(evt.target.files).map(function (file) { return toFileWithPath(file); });
175
+ }
176
+ // Ee expect each handle to be https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle
177
+ function getFsHandleFiles(handles) {
178
+ return __awaiter(this, void 0, void 0, function () {
179
+ var files;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
182
+ case 0: return [4 /*yield*/, Promise.all(handles.map(function (h) { return h.getFile(); }))];
183
+ case 1:
184
+ files = _a.sent();
185
+ return [2 /*return*/, files.map(function (file) { return toFileWithPath(file); })];
186
+ }
187
+ });
188
+ });
189
+ }
190
+ function getDataTransferFiles(dt, type) {
191
+ return __awaiter(this, void 0, void 0, function () {
192
+ var items, files;
193
+ return __generator(this, function (_a) {
194
+ switch (_a.label) {
195
+ case 0:
196
+ if (dt === null) {
197
+ return [2 /*return*/, []];
198
+ }
199
+ if (!dt.items) return [3 /*break*/, 2];
200
+ items = fromList(dt.items)
201
+ .filter(function (item) { return item.kind === 'file'; });
202
+ // According to https://html.spec.whatwg.org/multipage/dnd.html#dndevents,
203
+ // only 'dragstart' and 'drop' has access to the data (source node)
204
+ if (type !== 'drop') {
205
+ return [2 /*return*/, items];
206
+ }
207
+ return [4 /*yield*/, Promise.all(items.map(toFilePromises))];
208
+ case 1:
209
+ files = _a.sent();
210
+ return [2 /*return*/, noIgnoredFiles(flatten(files))];
211
+ case 2: return [2 /*return*/, noIgnoredFiles(fromList(dt.files)
212
+ .map(function (file) { return toFileWithPath(file); }))];
213
+ }
214
+ });
215
+ });
216
+ }
217
+ function noIgnoredFiles(files) {
218
+ return files.filter(function (file) { return FILES_TO_IGNORE.indexOf(file.name) === -1; });
219
+ }
220
+ // IE11 does not support Array.from()
221
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Browser_compatibility
222
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileList
223
+ // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList
224
+ function fromList(items) {
225
+ if (items === null) {
226
+ return [];
227
+ }
228
+ var files = [];
229
+ // tslint:disable: prefer-for-of
230
+ for (var i = 0; i < items.length; i++) {
231
+ var file = items[i];
232
+ files.push(file);
233
+ }
234
+ return files;
235
+ }
236
+ // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem
237
+ function toFilePromises(item) {
238
+ if (typeof item.webkitGetAsEntry !== 'function') {
239
+ return fromDataTransferItem(item);
240
+ }
241
+ var entry = item.webkitGetAsEntry();
242
+ // Safari supports dropping an image node from a different window and can be retrieved using
243
+ // the DataTransferItem.getAsFile() API
244
+ // NOTE: FileSystemEntry.file() throws if trying to get the file
245
+ if (entry && entry.isDirectory) {
246
+ return fromDirEntry(entry);
247
+ }
248
+ return fromDataTransferItem(item);
249
+ }
250
+ function flatten(items) {
251
+ return items.reduce(function (acc, files) { return __spread(acc, (Array.isArray(files) ? flatten(files) : [files])); }, []);
252
+ }
253
+ function fromDataTransferItem(item) {
254
+ var file = item.getAsFile();
255
+ if (!file) {
256
+ return Promise.reject(item + " is not a File");
257
+ }
258
+ var fwp = toFileWithPath(file);
259
+ return Promise.resolve(fwp);
260
+ }
261
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry
262
+ function fromEntry(entry) {
263
+ return __awaiter(this, void 0, void 0, function () {
264
+ return __generator(this, function (_a) {
265
+ return [2 /*return*/, entry.isDirectory ? fromDirEntry(entry) : fromFileEntry(entry)];
266
+ });
267
+ });
268
+ }
269
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry
270
+ function fromDirEntry(entry) {
271
+ var reader = entry.createReader();
272
+ return new Promise(function (resolve, reject) {
273
+ var entries = [];
274
+ function readEntries() {
275
+ var _this = this;
276
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry/createReader
277
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader/readEntries
278
+ reader.readEntries(function (batch) { return __awaiter(_this, void 0, void 0, function () {
279
+ var files, err_1, items;
280
+ return __generator(this, function (_a) {
281
+ switch (_a.label) {
282
+ case 0:
283
+ if (!!batch.length) return [3 /*break*/, 5];
284
+ _a.label = 1;
285
+ case 1:
286
+ _a.trys.push([1, 3, , 4]);
287
+ return [4 /*yield*/, Promise.all(entries)];
288
+ case 2:
289
+ files = _a.sent();
290
+ resolve(files);
291
+ return [3 /*break*/, 4];
292
+ case 3:
293
+ err_1 = _a.sent();
294
+ reject(err_1);
295
+ return [3 /*break*/, 4];
296
+ case 4: return [3 /*break*/, 6];
297
+ case 5:
298
+ items = Promise.all(batch.map(fromEntry));
299
+ entries.push(items);
300
+ // Continue reading
301
+ readEntries();
302
+ _a.label = 6;
303
+ case 6: return [2 /*return*/];
304
+ }
305
+ });
306
+ }); }, function (err) {
307
+ reject(err);
308
+ });
309
+ }
310
+ readEntries();
311
+ });
312
+ }
313
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry
314
+ function fromFileEntry(entry) {
315
+ return __awaiter(this, void 0, void 0, function () {
316
+ return __generator(this, function (_a) {
317
+ return [2 /*return*/, new Promise(function (resolve, reject) {
318
+ entry.file(function (file) {
319
+ var fwp = toFileWithPath(file, entry.fullPath);
320
+ resolve(fwp);
321
+ }, function (err) {
322
+ reject(err);
323
+ });
324
+ })];
325
+ });
326
+ });
327
+ }
328
+
329
+ var _default = function (file, acceptedFiles) {
330
+ if (file && acceptedFiles) {
331
+ var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
332
+ var fileName = file.name || '';
333
+ var mimeType = (file.type || '').toLowerCase();
334
+ var baseMimeType = mimeType.replace(/\/.*$/, '');
335
+ return acceptedFilesArray.some(function (type) {
336
+ var validType = type.trim().toLowerCase();
337
+
338
+ if (validType.charAt(0) === '.') {
339
+ return fileName.toLowerCase().endsWith(validType);
340
+ } else if (validType.endsWith('/*')) {
341
+ // This is something like a image/* mime type
342
+ return baseMimeType === validType.replace(/\/.*$/, '');
343
+ }
344
+
345
+ return mimeType === validType;
346
+ });
347
+ }
348
+
349
+ return true;
350
+ };
351
+
352
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
353
+
354
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
355
+
356
+ function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
357
+
358
+ function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1(); }
359
+
360
+ function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
361
+
362
+ function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
363
+
364
+ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
365
+
366
+ function _iterableToArrayLimit$1(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
367
+
368
+ function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
369
+
370
+ var FILE_INVALID_TYPE = 'file-invalid-type';
371
+ var FILE_TOO_LARGE = 'file-too-large';
372
+ var FILE_TOO_SMALL = 'file-too-small';
373
+ var TOO_MANY_FILES = 'too-many-files';
374
+
375
+ var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr(accept) {
376
+ accept = Array.isArray(accept) && accept.length === 1 ? accept[0] : accept;
377
+ var messageSuffix = Array.isArray(accept) ? "one of ".concat(accept.join(', ')) : accept;
378
+ return {
379
+ code: FILE_INVALID_TYPE,
380
+ message: "File type must be ".concat(messageSuffix)
381
+ };
382
+ };
383
+ var getTooLargeRejectionErr = function getTooLargeRejectionErr(maxSize) {
384
+ return {
385
+ code: FILE_TOO_LARGE,
386
+ message: "File is larger than ".concat(maxSize, " ").concat(maxSize === 1 ? 'byte' : 'bytes')
387
+ };
388
+ };
389
+ var getTooSmallRejectionErr = function getTooSmallRejectionErr(minSize) {
390
+ return {
391
+ code: FILE_TOO_SMALL,
392
+ message: "File is smaller than ".concat(minSize, " ").concat(minSize === 1 ? 'byte' : 'bytes')
393
+ };
394
+ };
395
+ var TOO_MANY_FILES_REJECTION = {
396
+ code: TOO_MANY_FILES,
397
+ message: 'Too many files'
398
+ }; // Firefox versions prior to 53 return a bogus MIME type for every file drag, so dragovers with
399
+ // that MIME type will always be accepted
400
+
401
+ function fileAccepted(file, accept) {
402
+ var isAcceptable = file.type === 'application/x-moz-file' || _default(file, accept);
403
+ return [isAcceptable, isAcceptable ? null : getInvalidTypeRejectionErr(accept)];
404
+ }
405
+ function fileMatchSize(file, minSize, maxSize) {
406
+ if (isDefined(file.size)) {
407
+ if (isDefined(minSize) && isDefined(maxSize)) {
408
+ if (file.size > maxSize) return [false, getTooLargeRejectionErr(maxSize)];
409
+ if (file.size < minSize) return [false, getTooSmallRejectionErr(minSize)];
410
+ } else if (isDefined(minSize) && file.size < minSize) return [false, getTooSmallRejectionErr(minSize)];else if (isDefined(maxSize) && file.size > maxSize) return [false, getTooLargeRejectionErr(maxSize)];
411
+ }
412
+
413
+ return [true, null];
414
+ }
415
+
416
+ function isDefined(value) {
417
+ return value !== undefined && value !== null;
418
+ }
419
+
420
+ function allFilesAccepted(_ref) {
421
+ var files = _ref.files,
422
+ accept = _ref.accept,
423
+ minSize = _ref.minSize,
424
+ maxSize = _ref.maxSize,
425
+ multiple = _ref.multiple,
426
+ maxFiles = _ref.maxFiles;
427
+
428
+ if (!multiple && files.length > 1 || multiple && maxFiles >= 1 && files.length > maxFiles) {
429
+ return false;
430
+ }
431
+
432
+ return files.every(function (file) {
433
+ var _fileAccepted = fileAccepted(file, accept),
434
+ _fileAccepted2 = _slicedToArray$1(_fileAccepted, 1),
435
+ accepted = _fileAccepted2[0];
436
+
437
+ var _fileMatchSize = fileMatchSize(file, minSize, maxSize),
438
+ _fileMatchSize2 = _slicedToArray$1(_fileMatchSize, 1),
439
+ sizeMatch = _fileMatchSize2[0];
440
+
441
+ return accepted && sizeMatch;
442
+ });
443
+ } // React's synthetic events has event.isPropagationStopped,
444
+ // but to remain compatibility with other libs (Preact) fall back
445
+ // to check event.cancelBubble
446
+
447
+ function isPropagationStopped(event) {
448
+ if (typeof event.isPropagationStopped === 'function') {
449
+ return event.isPropagationStopped();
450
+ } else if (typeof event.cancelBubble !== 'undefined') {
451
+ return event.cancelBubble;
452
+ }
453
+
454
+ return false;
455
+ }
456
+ function isEvtWithFiles(event) {
457
+ if (!event.dataTransfer) {
458
+ return !!event.target && !!event.target.files;
459
+ } // https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types
460
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file
461
+
462
+
463
+ return Array.prototype.some.call(event.dataTransfer.types, function (type) {
464
+ return type === 'Files' || type === 'application/x-moz-file';
465
+ });
466
+ }
467
+
468
+ function onDocumentDragOver(event) {
469
+ event.preventDefault();
470
+ }
471
+
472
+ function isIe(userAgent) {
473
+ return userAgent.indexOf('MSIE') !== -1 || userAgent.indexOf('Trident/') !== -1;
474
+ }
475
+
476
+ function isEdge(userAgent) {
477
+ return userAgent.indexOf('Edge/') !== -1;
478
+ }
479
+
480
+ function isIeOrEdge() {
481
+ var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.navigator.userAgent;
482
+ return isIe(userAgent) || isEdge(userAgent);
483
+ }
484
+ /**
485
+ * This is intended to be used to compose event handlers
486
+ * They are executed in order until one of them calls `event.isPropagationStopped()`.
487
+ * Note that the check is done on the first invoke too,
488
+ * meaning that if propagation was stopped before invoking the fns,
489
+ * no handlers will be executed.
490
+ *
491
+ * @param {Function} fns the event hanlder functions
492
+ * @return {Function} the event handler to add to an element
493
+ */
494
+
495
+ function composeEventHandlers() {
496
+ for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
497
+ fns[_key] = arguments[_key];
498
+ }
499
+
500
+ return function (event) {
501
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
502
+ args[_key2 - 1] = arguments[_key2];
503
+ }
504
+
505
+ return fns.some(function (fn) {
506
+ if (!isPropagationStopped(event) && fn) {
507
+ fn.apply(void 0, [event].concat(args));
508
+ }
509
+
510
+ return isPropagationStopped(event);
511
+ });
512
+ };
513
+ }
514
+ /**
515
+ * canUseFileSystemAccessAPI checks if the [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API)
516
+ * is supported by the browser.
517
+ * @returns {boolean}
518
+ */
519
+
520
+ function canUseFileSystemAccessAPI() {
521
+ return 'showOpenFilePicker' in window;
522
+ }
523
+ /**
524
+ * filePickerOptionsTypes returns the {types} option for https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker
525
+ * based on the accept attr (see https://github.com/react-dropzone/attr-accept)
526
+ * E.g: converts ['image/*', 'text/*'] to {'image/*': [], 'text/*': []}
527
+ * @param {string|string[]} accept
528
+ */
529
+
530
+ function filePickerOptionsTypes(accept) {
531
+ accept = typeof accept === 'string' ? accept.split(',') : accept;
532
+ return [{
533
+ description: 'everything',
534
+ // TODO: Need to handle filtering more elegantly than this!
535
+ accept: Array.isArray(accept) // Accept just MIME types as per spec
536
+ // NOTE: accept can be https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers
537
+ ? accept.filter(function (item) {
538
+ return item === 'audio/*' || item === 'video/*' || item === 'image/*' || item === 'text/*' || /\w+\/[-+.\w]+/g.test(item);
539
+ }).reduce(function (a, b) {
540
+ return _objectSpread$1(_objectSpread$1({}, a), {}, _defineProperty$1({}, b, []));
541
+ }, {}) : {}
542
+ }];
543
+ }
544
+
545
+ var _excluded = ["children"],
546
+ _excluded2 = ["open"],
547
+ _excluded3 = ["refKey", "role", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"],
548
+ _excluded4 = ["refKey", "onChange", "onClick"];
549
+
550
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
551
+
552
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
553
+
554
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
555
+
556
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
557
+
558
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
559
+
560
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
561
+
562
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
563
+
564
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
565
+
566
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
567
+
568
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
569
+
570
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
571
+
572
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
573
+
574
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
575
+
576
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
577
+
578
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
579
+ /**
580
+ * Convenience wrapper component for the `useDropzone` hook
581
+ *
582
+ * ```jsx
583
+ * <Dropzone>
584
+ * {({getRootProps, getInputProps}) => (
585
+ * <div {...getRootProps()}>
586
+ * <input {...getInputProps()} />
587
+ * <p>Drag 'n' drop some files here, or click to select files</p>
588
+ * </div>
589
+ * )}
590
+ * </Dropzone>
591
+ * ```
592
+ */
593
+
594
+ var Dropzone = /*#__PURE__*/forwardRef(function (_ref, ref) {
595
+ var children = _ref.children,
596
+ params = _objectWithoutProperties(_ref, _excluded);
597
+
598
+ var _useDropzone = useDropzone(params),
599
+ open = _useDropzone.open,
600
+ props = _objectWithoutProperties(_useDropzone, _excluded2);
601
+
602
+ useImperativeHandle(ref, function () {
603
+ return {
604
+ open: open
605
+ };
606
+ }, [open]); // TODO: Figure out why react-styleguidist cannot create docs if we don't return a jsx element
607
+
608
+ return /*#__PURE__*/React__default.createElement(Fragment, null, children(_objectSpread(_objectSpread({}, props), {}, {
609
+ open: open
610
+ })));
611
+ });
612
+ Dropzone.displayName = 'Dropzone'; // Add default props for react-docgen
613
+
614
+ var defaultProps = {
615
+ disabled: false,
616
+ getFilesFromEvent: fromEvent,
617
+ maxSize: Infinity,
618
+ minSize: 0,
619
+ multiple: true,
620
+ maxFiles: 0,
621
+ preventDropOnDocument: true,
622
+ noClick: false,
623
+ noKeyboard: false,
624
+ noDrag: false,
625
+ noDragEventsBubbling: false,
626
+ validator: null,
627
+ useFsAccessApi: false
628
+ };
629
+ Dropzone.defaultProps = defaultProps;
630
+ Dropzone.propTypes = {
631
+ /**
632
+ * Render function that exposes the dropzone state and prop getter fns
633
+ *
634
+ * @param {object} params
635
+ * @param {Function} params.getRootProps Returns the props you should apply to the root drop container you render
636
+ * @param {Function} params.getInputProps Returns the props you should apply to hidden file input you render
637
+ * @param {Function} params.open Open the native file selection dialog
638
+ * @param {boolean} params.isFocused Dropzone area is in focus
639
+ * @param {boolean} params.isFileDialogActive File dialog is opened
640
+ * @param {boolean} params.isDragActive Active drag is in progress
641
+ * @param {boolean} params.isDragAccept Dragged files are accepted
642
+ * @param {boolean} params.isDragReject Some dragged files are rejected
643
+ * @param {File[]} params.draggedFiles Files in active drag
644
+ * @param {File[]} params.acceptedFiles Accepted files
645
+ * @param {FileRejection[]} params.fileRejections Rejected files and why they were rejected
646
+ */
647
+ children: PropTypes.func,
648
+
649
+ /**
650
+ * Set accepted file types.
651
+ * See https://github.com/okonet/attr-accept for more information.
652
+ * Keep in mind that mime type determination is not reliable across platforms. CSV files,
653
+ * for example, are reported as text/plain under macOS but as application/vnd.ms-excel under
654
+ * Windows. In some cases there might not be a mime type set at all.
655
+ * See: https://github.com/react-dropzone/react-dropzone/issues/276
656
+ */
657
+ accept: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
658
+
659
+ /**
660
+ * Allow drag 'n' drop (or selection from the file dialog) of multiple files
661
+ */
662
+ multiple: PropTypes.bool,
663
+
664
+ /**
665
+ * If false, allow dropped items to take over the current browser window
666
+ */
667
+ preventDropOnDocument: PropTypes.bool,
668
+
669
+ /**
670
+ * If true, disables click to open the native file selection dialog
671
+ */
672
+ noClick: PropTypes.bool,
673
+
674
+ /**
675
+ * If true, disables SPACE/ENTER to open the native file selection dialog.
676
+ * Note that it also stops tracking the focus state.
677
+ */
678
+ noKeyboard: PropTypes.bool,
679
+
680
+ /**
681
+ * If true, disables drag 'n' drop
682
+ */
683
+ noDrag: PropTypes.bool,
684
+
685
+ /**
686
+ * If true, stops drag event propagation to parents
687
+ */
688
+ noDragEventsBubbling: PropTypes.bool,
689
+
690
+ /**
691
+ * Minimum file size (in bytes)
692
+ */
693
+ minSize: PropTypes.number,
694
+
695
+ /**
696
+ * Maximum file size (in bytes)
697
+ */
698
+ maxSize: PropTypes.number,
699
+
700
+ /**
701
+ * Maximum accepted number of files
702
+ * The default value is 0 which means there is no limitation to how many files are accepted.
703
+ */
704
+ maxFiles: PropTypes.number,
705
+
706
+ /**
707
+ * Enable/disable the dropzone
708
+ */
709
+ disabled: PropTypes.bool,
710
+
711
+ /**
712
+ * Use this to provide a custom file aggregator
713
+ *
714
+ * @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
715
+ */
716
+ getFilesFromEvent: PropTypes.func,
717
+
718
+ /**
719
+ * Cb for when closing the file dialog with no selection
720
+ */
721
+ onFileDialogCancel: PropTypes.func,
722
+
723
+ /**
724
+ * Cb for when opening the file dialog
725
+ */
726
+ onFileDialogOpen: PropTypes.func,
727
+
728
+ /**
729
+ * Set to true to use the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
730
+ * to open the file picker instead of using an `<input type="file">` click event.
731
+ */
732
+ useFsAccessApi: PropTypes.bool,
733
+
734
+ /**
735
+ * Cb for when the `dragenter` event occurs.
736
+ *
737
+ * @param {DragEvent} event
738
+ */
739
+ onDragEnter: PropTypes.func,
740
+
741
+ /**
742
+ * Cb for when the `dragleave` event occurs
743
+ *
744
+ * @param {DragEvent} event
745
+ */
746
+ onDragLeave: PropTypes.func,
747
+
748
+ /**
749
+ * Cb for when the `dragover` event occurs
750
+ *
751
+ * @param {DragEvent} event
752
+ */
753
+ onDragOver: PropTypes.func,
754
+
755
+ /**
756
+ * Cb for when the `drop` event occurs.
757
+ * Note that this callback is invoked after the `getFilesFromEvent` callback is done.
758
+ *
759
+ * Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and `maxSize` props.
760
+ * `accept` must be a valid [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml) according to [input element specification](https://www.w3.org/wiki/HTML/Elements/input/file) or a valid file extension.
761
+ * If `multiple` is set to false and additional files are dropped,
762
+ * all files besides the first will be rejected.
763
+ * Any file which does not have a size in the [`minSize`, `maxSize`] range, will be rejected as well.
764
+ *
765
+ * Note that the `onDrop` callback will always be invoked regardless if the dropped files were accepted or rejected.
766
+ * If you'd like to react to a specific scenario, use the `onDropAccepted`/`onDropRejected` props.
767
+ *
768
+ * `onDrop` will provide you with an array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects which you can then process and send to a server.
769
+ * For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
770
+ *
771
+ * ```js
772
+ * function onDrop(acceptedFiles) {
773
+ * const req = request.post('/upload')
774
+ * acceptedFiles.forEach(file => {
775
+ * req.attach(file.name, file)
776
+ * })
777
+ * req.end(callback)
778
+ * }
779
+ * ```
780
+ *
781
+ * @param {File[]} acceptedFiles
782
+ * @param {FileRejection[]} fileRejections
783
+ * @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
784
+ */
785
+ onDrop: PropTypes.func,
786
+
787
+ /**
788
+ * Cb for when the `drop` event occurs.
789
+ * Note that if no files are accepted, this callback is not invoked.
790
+ *
791
+ * @param {File[]} files
792
+ * @param {(DragEvent|Event)} event
793
+ */
794
+ onDropAccepted: PropTypes.func,
795
+
796
+ /**
797
+ * Cb for when the `drop` event occurs.
798
+ * Note that if no files are rejected, this callback is not invoked.
799
+ *
800
+ * @param {FileRejection[]} fileRejections
801
+ * @param {(DragEvent|Event)} event
802
+ */
803
+ onDropRejected: PropTypes.func,
804
+
805
+ /**
806
+ * Custom validation function
807
+ * @param {File} file
808
+ * @returns {FileError|FileError[]}
809
+ */
810
+ validator: PropTypes.func
811
+ };
812
+ /**
813
+ * A function that is invoked for the `dragenter`,
814
+ * `dragover` and `dragleave` events.
815
+ * It is not invoked if the items are not files (such as link, text, etc.).
816
+ *
817
+ * @callback dragCb
818
+ * @param {DragEvent} event
819
+ */
820
+
821
+ /**
822
+ * A function that is invoked for the `drop` or input change event.
823
+ * It is not invoked if the items are not files (such as link, text, etc.).
824
+ *
825
+ * @callback dropCb
826
+ * @param {File[]} acceptedFiles List of accepted files
827
+ * @param {FileRejection[]} fileRejections List of rejected files and why they were rejected
828
+ * @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
829
+ */
830
+
831
+ /**
832
+ * A function that is invoked for the `drop` or input change event.
833
+ * It is not invoked if the items are files (such as link, text, etc.).
834
+ *
835
+ * @callback dropAcceptedCb
836
+ * @param {File[]} files List of accepted files that meet the given criteria
837
+ * (`accept`, `multiple`, `minSize`, `maxSize`)
838
+ * @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
839
+ */
840
+
841
+ /**
842
+ * A function that is invoked for the `drop` or input change event.
843
+ *
844
+ * @callback dropRejectedCb
845
+ * @param {File[]} files List of rejected files that do not meet the given criteria
846
+ * (`accept`, `multiple`, `minSize`, `maxSize`)
847
+ * @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
848
+ */
849
+
850
+ /**
851
+ * A function that is used aggregate files,
852
+ * in a asynchronous fashion, from drag or input change events.
853
+ *
854
+ * @callback getFilesFromEvent
855
+ * @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
856
+ * @returns {(File[]|Promise<File[]>)}
857
+ */
858
+
859
+ /**
860
+ * An object with the current dropzone state and some helper functions.
861
+ *
862
+ * @typedef {object} DropzoneState
863
+ * @property {Function} getRootProps Returns the props you should apply to the root drop container you render
864
+ * @property {Function} getInputProps Returns the props you should apply to hidden file input you render
865
+ * @property {Function} open Open the native file selection dialog
866
+ * @property {boolean} isFocused Dropzone area is in focus
867
+ * @property {boolean} isFileDialogActive File dialog is opened
868
+ * @property {boolean} isDragActive Active drag is in progress
869
+ * @property {boolean} isDragAccept Dragged files are accepted
870
+ * @property {boolean} isDragReject Some dragged files are rejected
871
+ * @property {File[]} draggedFiles Files in active drag
872
+ * @property {File[]} acceptedFiles Accepted files
873
+ * @property {FileRejection[]} fileRejections Rejected files and why they were rejected
874
+ */
875
+
876
+ var initialState = {
877
+ isFocused: false,
878
+ isFileDialogActive: false,
879
+ isDragActive: false,
880
+ isDragAccept: false,
881
+ isDragReject: false,
882
+ draggedFiles: [],
883
+ acceptedFiles: [],
884
+ fileRejections: []
885
+ };
886
+ /**
887
+ * A React hook that creates a drag 'n' drop area.
888
+ *
889
+ * ```jsx
890
+ * function MyDropzone(props) {
891
+ * const {getRootProps, getInputProps} = useDropzone({
892
+ * onDrop: acceptedFiles => {
893
+ * // do something with the File objects, e.g. upload to some server
894
+ * }
895
+ * });
896
+ * return (
897
+ * <div {...getRootProps()}>
898
+ * <input {...getInputProps()} />
899
+ * <p>Drag and drop some files here, or click to select files</p>
900
+ * </div>
901
+ * )
902
+ * }
903
+ * ```
904
+ *
905
+ * @function useDropzone
906
+ *
907
+ * @param {object} props
908
+ * @param {string|string[]} [props.accept] Set accepted file types.
909
+ * See https://github.com/okonet/attr-accept for more information.
910
+ * Keep in mind that mime type determination is not reliable across platforms. CSV files,
911
+ * for example, are reported as text/plain under macOS but as application/vnd.ms-excel under
912
+ * Windows. In some cases there might not be a mime type set at all.
913
+ * See: https://github.com/react-dropzone/react-dropzone/issues/276
914
+ * @param {boolean} [props.multiple=true] Allow drag 'n' drop (or selection from the file dialog) of multiple files
915
+ * @param {boolean} [props.preventDropOnDocument=true] If false, allow dropped items to take over the current browser window
916
+ * @param {boolean} [props.noClick=false] If true, disables click to open the native file selection dialog
917
+ * @param {boolean} [props.noKeyboard=false] If true, disables SPACE/ENTER to open the native file selection dialog.
918
+ * Note that it also stops tracking the focus state.
919
+ * @param {boolean} [props.noDrag=false] If true, disables drag 'n' drop
920
+ * @param {boolean} [props.noDragEventsBubbling=false] If true, stops drag event propagation to parents
921
+ * @param {number} [props.minSize=0] Minimum file size (in bytes)
922
+ * @param {number} [props.maxSize=Infinity] Maximum file size (in bytes)
923
+ * @param {boolean} [props.disabled=false] Enable/disable the dropzone
924
+ * @param {getFilesFromEvent} [props.getFilesFromEvent] Use this to provide a custom file aggregator
925
+ * @param {Function} [props.onFileDialogCancel] Cb for when closing the file dialog with no selection
926
+ * @param {boolean} [props.useFsAccessApi] Set to true to use the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
927
+ * to open the file picker instead of using an `<input type="file">` click event.
928
+ * @param {Function} [props.onFileDialogOpen] Cb for when opening the file dialog
929
+ * @param {dragCb} [props.onDragEnter] Cb for when the `dragenter` event occurs.
930
+ * @param {dragCb} [props.onDragLeave] Cb for when the `dragleave` event occurs
931
+ * @param {dragCb} [props.onDragOver] Cb for when the `dragover` event occurs
932
+ * @param {dropCb} [props.onDrop] Cb for when the `drop` event occurs.
933
+ * Note that this callback is invoked after the `getFilesFromEvent` callback is done.
934
+ *
935
+ * Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and `maxSize` props.
936
+ * `accept` must be a valid [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml) according to [input element specification](https://www.w3.org/wiki/HTML/Elements/input/file) or a valid file extension.
937
+ * If `multiple` is set to false and additional files are dropped,
938
+ * all files besides the first will be rejected.
939
+ * Any file which does not have a size in the [`minSize`, `maxSize`] range, will be rejected as well.
940
+ *
941
+ * Note that the `onDrop` callback will always be invoked regardless if the dropped files were accepted or rejected.
942
+ * If you'd like to react to a specific scenario, use the `onDropAccepted`/`onDropRejected` props.
943
+ *
944
+ * `onDrop` will provide you with an array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects which you can then process and send to a server.
945
+ * For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
946
+ *
947
+ * ```js
948
+ * function onDrop(acceptedFiles) {
949
+ * const req = request.post('/upload')
950
+ * acceptedFiles.forEach(file => {
951
+ * req.attach(file.name, file)
952
+ * })
953
+ * req.end(callback)
954
+ * }
955
+ * ```
956
+ * @param {dropAcceptedCb} [props.onDropAccepted]
957
+ * @param {dropRejectedCb} [props.onDropRejected]
958
+ *
959
+ * @returns {DropzoneState}
960
+ */
961
+
962
+ function useDropzone() {
963
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
964
+
965
+ var _defaultProps$options = _objectSpread(_objectSpread({}, defaultProps), options),
966
+ accept = _defaultProps$options.accept,
967
+ disabled = _defaultProps$options.disabled,
968
+ getFilesFromEvent = _defaultProps$options.getFilesFromEvent,
969
+ maxSize = _defaultProps$options.maxSize,
970
+ minSize = _defaultProps$options.minSize,
971
+ multiple = _defaultProps$options.multiple,
972
+ maxFiles = _defaultProps$options.maxFiles,
973
+ onDragEnter = _defaultProps$options.onDragEnter,
974
+ onDragLeave = _defaultProps$options.onDragLeave,
975
+ onDragOver = _defaultProps$options.onDragOver,
976
+ onDrop = _defaultProps$options.onDrop,
977
+ onDropAccepted = _defaultProps$options.onDropAccepted,
978
+ onDropRejected = _defaultProps$options.onDropRejected,
979
+ onFileDialogCancel = _defaultProps$options.onFileDialogCancel,
980
+ onFileDialogOpen = _defaultProps$options.onFileDialogOpen,
981
+ useFsAccessApi = _defaultProps$options.useFsAccessApi,
982
+ preventDropOnDocument = _defaultProps$options.preventDropOnDocument,
983
+ noClick = _defaultProps$options.noClick,
984
+ noKeyboard = _defaultProps$options.noKeyboard,
985
+ noDrag = _defaultProps$options.noDrag,
986
+ noDragEventsBubbling = _defaultProps$options.noDragEventsBubbling,
987
+ validator = _defaultProps$options.validator;
988
+
989
+ var onFileDialogOpenCb = useMemo(function () {
990
+ return typeof onFileDialogOpen === 'function' ? onFileDialogOpen : noop;
991
+ }, [onFileDialogOpen]);
992
+ var onFileDialogCancelCb = useMemo(function () {
993
+ return typeof onFileDialogCancel === 'function' ? onFileDialogCancel : noop;
994
+ }, [onFileDialogCancel]);
995
+ var rootRef = useRef(null);
996
+ var inputRef = useRef(null);
997
+
998
+ var _useReducer = useReducer(reducer, initialState),
999
+ _useReducer2 = _slicedToArray(_useReducer, 2),
1000
+ state = _useReducer2[0],
1001
+ dispatch = _useReducer2[1];
1002
+
1003
+ var isFocused = state.isFocused,
1004
+ isFileDialogActive = state.isFileDialogActive,
1005
+ draggedFiles = state.draggedFiles; // Update file dialog active state when the window is focused on
1006
+
1007
+ var onWindowFocus = function onWindowFocus() {
1008
+ // Execute the timeout only if the file dialog is opened in the browser
1009
+ if (isFileDialogActive) {
1010
+ setTimeout(function () {
1011
+ if (inputRef.current) {
1012
+ var files = inputRef.current.files;
1013
+
1014
+ if (!files.length) {
1015
+ dispatch({
1016
+ type: 'closeDialog'
1017
+ });
1018
+ onFileDialogCancelCb();
1019
+ }
1020
+ }
1021
+ }, 300);
1022
+ }
1023
+ };
1024
+
1025
+ useEffect(function () {
1026
+ if (useFsAccessApi && canUseFileSystemAccessAPI()) {
1027
+ return function () {};
1028
+ }
1029
+
1030
+ window.addEventListener('focus', onWindowFocus, false);
1031
+ return function () {
1032
+ window.removeEventListener('focus', onWindowFocus, false);
1033
+ };
1034
+ }, [inputRef, isFileDialogActive, onFileDialogCancelCb, useFsAccessApi]);
1035
+ var dragTargetsRef = useRef([]);
1036
+
1037
+ var onDocumentDrop = function onDocumentDrop(event) {
1038
+ if (rootRef.current && rootRef.current.contains(event.target)) {
1039
+ // If we intercepted an event for our instance, let it propagate down to the instance's onDrop handler
1040
+ return;
1041
+ }
1042
+
1043
+ event.preventDefault();
1044
+ dragTargetsRef.current = [];
1045
+ };
1046
+
1047
+ useEffect(function () {
1048
+ if (preventDropOnDocument) {
1049
+ document.addEventListener('dragover', onDocumentDragOver, false);
1050
+ document.addEventListener('drop', onDocumentDrop, false);
1051
+ }
1052
+
1053
+ return function () {
1054
+ if (preventDropOnDocument) {
1055
+ document.removeEventListener('dragover', onDocumentDragOver);
1056
+ document.removeEventListener('drop', onDocumentDrop);
1057
+ }
1058
+ };
1059
+ }, [rootRef, preventDropOnDocument]);
1060
+ var onDragEnterCb = useCallback(function (event) {
1061
+ event.preventDefault(); // Persist here because we need the event later after getFilesFromEvent() is done
1062
+
1063
+ event.persist();
1064
+ stopPropagation(event);
1065
+ dragTargetsRef.current = [].concat(_toConsumableArray(dragTargetsRef.current), [event.target]);
1066
+
1067
+ if (isEvtWithFiles(event)) {
1068
+ Promise.resolve(getFilesFromEvent(event)).then(function (draggedFiles) {
1069
+ if (isPropagationStopped(event) && !noDragEventsBubbling) {
1070
+ return;
1071
+ }
1072
+
1073
+ dispatch({
1074
+ draggedFiles: draggedFiles,
1075
+ isDragActive: true,
1076
+ type: 'setDraggedFiles'
1077
+ });
1078
+
1079
+ if (onDragEnter) {
1080
+ onDragEnter(event);
1081
+ }
1082
+ });
1083
+ }
1084
+ }, [getFilesFromEvent, onDragEnter, noDragEventsBubbling]);
1085
+ var onDragOverCb = useCallback(function (event) {
1086
+ event.preventDefault();
1087
+ event.persist();
1088
+ stopPropagation(event);
1089
+ var hasFiles = isEvtWithFiles(event);
1090
+
1091
+ if (hasFiles && event.dataTransfer) {
1092
+ try {
1093
+ event.dataTransfer.dropEffect = 'copy';
1094
+ } catch (_unused) {}
1095
+ /* eslint-disable-line no-empty */
1096
+
1097
+ }
1098
+
1099
+ if (hasFiles && onDragOver) {
1100
+ onDragOver(event);
1101
+ }
1102
+
1103
+ return false;
1104
+ }, [onDragOver, noDragEventsBubbling]);
1105
+ var onDragLeaveCb = useCallback(function (event) {
1106
+ event.preventDefault();
1107
+ event.persist();
1108
+ stopPropagation(event); // Only deactivate once the dropzone and all children have been left
1109
+
1110
+ var targets = dragTargetsRef.current.filter(function (target) {
1111
+ return rootRef.current && rootRef.current.contains(target);
1112
+ }); // Make sure to remove a target present multiple times only once
1113
+ // (Firefox may fire dragenter/dragleave multiple times on the same element)
1114
+
1115
+ var targetIdx = targets.indexOf(event.target);
1116
+
1117
+ if (targetIdx !== -1) {
1118
+ targets.splice(targetIdx, 1);
1119
+ }
1120
+
1121
+ dragTargetsRef.current = targets;
1122
+
1123
+ if (targets.length > 0) {
1124
+ return;
1125
+ }
1126
+
1127
+ dispatch({
1128
+ isDragActive: false,
1129
+ type: 'setDraggedFiles',
1130
+ draggedFiles: []
1131
+ });
1132
+
1133
+ if (isEvtWithFiles(event) && onDragLeave) {
1134
+ onDragLeave(event);
1135
+ }
1136
+ }, [rootRef, onDragLeave, noDragEventsBubbling]);
1137
+ var setFiles = useCallback(function (files, event) {
1138
+ var acceptedFiles = [];
1139
+ var fileRejections = [];
1140
+ files.forEach(function (file) {
1141
+ var _fileAccepted = fileAccepted(file, accept),
1142
+ _fileAccepted2 = _slicedToArray(_fileAccepted, 2),
1143
+ accepted = _fileAccepted2[0],
1144
+ acceptError = _fileAccepted2[1];
1145
+
1146
+ var _fileMatchSize = fileMatchSize(file, minSize, maxSize),
1147
+ _fileMatchSize2 = _slicedToArray(_fileMatchSize, 2),
1148
+ sizeMatch = _fileMatchSize2[0],
1149
+ sizeError = _fileMatchSize2[1];
1150
+
1151
+ var customErrors = validator ? validator(file) : null;
1152
+
1153
+ if (accepted && sizeMatch && !customErrors) {
1154
+ acceptedFiles.push(file);
1155
+ } else {
1156
+ var errors = [acceptError, sizeError];
1157
+
1158
+ if (customErrors) {
1159
+ errors = errors.concat(customErrors);
1160
+ }
1161
+
1162
+ fileRejections.push({
1163
+ file: file,
1164
+ errors: errors.filter(function (e) {
1165
+ return e;
1166
+ })
1167
+ });
1168
+ }
1169
+ });
1170
+
1171
+ if (!multiple && acceptedFiles.length > 1 || multiple && maxFiles >= 1 && acceptedFiles.length > maxFiles) {
1172
+ // Reject everything and empty accepted files
1173
+ acceptedFiles.forEach(function (file) {
1174
+ fileRejections.push({
1175
+ file: file,
1176
+ errors: [TOO_MANY_FILES_REJECTION]
1177
+ });
1178
+ });
1179
+ acceptedFiles.splice(0);
1180
+ }
1181
+
1182
+ dispatch({
1183
+ acceptedFiles: acceptedFiles,
1184
+ fileRejections: fileRejections,
1185
+ type: 'setFiles'
1186
+ });
1187
+
1188
+ if (onDrop) {
1189
+ onDrop(acceptedFiles, fileRejections, event);
1190
+ }
1191
+
1192
+ if (fileRejections.length > 0 && onDropRejected) {
1193
+ onDropRejected(fileRejections, event);
1194
+ }
1195
+
1196
+ if (acceptedFiles.length > 0 && onDropAccepted) {
1197
+ onDropAccepted(acceptedFiles, event);
1198
+ }
1199
+ }, [dispatch, multiple, accept, minSize, maxSize, maxFiles, onDrop, onDropAccepted, onDropRejected, validator]);
1200
+ var onDropCb = useCallback(function (event) {
1201
+ event.preventDefault(); // Persist here because we need the event later after getFilesFromEvent() is done
1202
+
1203
+ event.persist();
1204
+ stopPropagation(event);
1205
+ dragTargetsRef.current = [];
1206
+
1207
+ if (isEvtWithFiles(event)) {
1208
+ Promise.resolve(getFilesFromEvent(event)).then(function (files) {
1209
+ if (isPropagationStopped(event) && !noDragEventsBubbling) {
1210
+ return;
1211
+ }
1212
+
1213
+ setFiles(files, event);
1214
+ });
1215
+ }
1216
+
1217
+ dispatch({
1218
+ type: 'reset'
1219
+ });
1220
+ }, [getFilesFromEvent, setFiles, noDragEventsBubbling]); // Fn for opening the file dialog programmatically
1221
+
1222
+ var openFileDialog = useCallback(function () {
1223
+ if (useFsAccessApi && canUseFileSystemAccessAPI()) {
1224
+ dispatch({
1225
+ type: 'openDialog'
1226
+ });
1227
+ onFileDialogOpenCb(); // https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker
1228
+
1229
+ var opts = {
1230
+ multiple: multiple,
1231
+ types: filePickerOptionsTypes(accept)
1232
+ };
1233
+ window.showOpenFilePicker(opts).then(function (handles) {
1234
+ return getFilesFromEvent(handles);
1235
+ }).then(function (files) {
1236
+ return setFiles(files, null);
1237
+ }).catch(function (e) {
1238
+ return onFileDialogCancelCb(e);
1239
+ }).finally(function () {
1240
+ return dispatch({
1241
+ type: 'closeDialog'
1242
+ });
1243
+ });
1244
+ return;
1245
+ }
1246
+
1247
+ if (inputRef.current) {
1248
+ dispatch({
1249
+ type: 'openDialog'
1250
+ });
1251
+ onFileDialogOpenCb();
1252
+ inputRef.current.value = null;
1253
+ inputRef.current.click();
1254
+ }
1255
+ }, [dispatch, onFileDialogOpenCb, onFileDialogCancelCb, useFsAccessApi, setFiles, accept, multiple]); // Cb to open the file dialog when SPACE/ENTER occurs on the dropzone
1256
+
1257
+ var onKeyDownCb = useCallback(function (event) {
1258
+ // Ignore keyboard events bubbling up the DOM tree
1259
+ if (!rootRef.current || !rootRef.current.isEqualNode(event.target)) {
1260
+ return;
1261
+ }
1262
+
1263
+ if (event.keyCode === 32 || event.keyCode === 13) {
1264
+ event.preventDefault();
1265
+ openFileDialog();
1266
+ }
1267
+ }, [rootRef, inputRef, openFileDialog]); // Update focus state for the dropzone
1268
+
1269
+ var onFocusCb = useCallback(function () {
1270
+ dispatch({
1271
+ type: 'focus'
1272
+ });
1273
+ }, []);
1274
+ var onBlurCb = useCallback(function () {
1275
+ dispatch({
1276
+ type: 'blur'
1277
+ });
1278
+ }, []); // Cb to open the file dialog when click occurs on the dropzone
1279
+
1280
+ var onClickCb = useCallback(function () {
1281
+ if (noClick) {
1282
+ return;
1283
+ } // In IE11/Edge the file-browser dialog is blocking, therefore, use setTimeout()
1284
+ // to ensure React can handle state changes
1285
+ // See: https://github.com/react-dropzone/react-dropzone/issues/450
1286
+
1287
+
1288
+ if (isIeOrEdge()) {
1289
+ setTimeout(openFileDialog, 0);
1290
+ } else {
1291
+ openFileDialog();
1292
+ }
1293
+ }, [inputRef, noClick, openFileDialog]);
1294
+
1295
+ var composeHandler = function composeHandler(fn) {
1296
+ return disabled ? null : fn;
1297
+ };
1298
+
1299
+ var composeKeyboardHandler = function composeKeyboardHandler(fn) {
1300
+ return noKeyboard ? null : composeHandler(fn);
1301
+ };
1302
+
1303
+ var composeDragHandler = function composeDragHandler(fn) {
1304
+ return noDrag ? null : composeHandler(fn);
1305
+ };
1306
+
1307
+ var stopPropagation = function stopPropagation(event) {
1308
+ if (noDragEventsBubbling) {
1309
+ event.stopPropagation();
1310
+ }
1311
+ };
1312
+
1313
+ var getRootProps = useMemo(function () {
1314
+ return function () {
1315
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1316
+ _ref2$refKey = _ref2.refKey,
1317
+ refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
1318
+ role = _ref2.role,
1319
+ onKeyDown = _ref2.onKeyDown,
1320
+ onFocus = _ref2.onFocus,
1321
+ onBlur = _ref2.onBlur,
1322
+ onClick = _ref2.onClick,
1323
+ onDragEnter = _ref2.onDragEnter,
1324
+ onDragOver = _ref2.onDragOver,
1325
+ onDragLeave = _ref2.onDragLeave,
1326
+ onDrop = _ref2.onDrop,
1327
+ rest = _objectWithoutProperties(_ref2, _excluded3);
1328
+
1329
+ return _objectSpread(_objectSpread(_defineProperty({
1330
+ onKeyDown: composeKeyboardHandler(composeEventHandlers(onKeyDown, onKeyDownCb)),
1331
+ onFocus: composeKeyboardHandler(composeEventHandlers(onFocus, onFocusCb)),
1332
+ onBlur: composeKeyboardHandler(composeEventHandlers(onBlur, onBlurCb)),
1333
+ onClick: composeHandler(composeEventHandlers(onClick, onClickCb)),
1334
+ onDragEnter: composeDragHandler(composeEventHandlers(onDragEnter, onDragEnterCb)),
1335
+ onDragOver: composeDragHandler(composeEventHandlers(onDragOver, onDragOverCb)),
1336
+ onDragLeave: composeDragHandler(composeEventHandlers(onDragLeave, onDragLeaveCb)),
1337
+ onDrop: composeDragHandler(composeEventHandlers(onDrop, onDropCb)),
1338
+ role: typeof role === 'string' && role !== '' ? role : 'button'
1339
+ }, refKey, rootRef), !disabled && !noKeyboard ? {
1340
+ tabIndex: 0
1341
+ } : {}), rest);
1342
+ };
1343
+ }, [rootRef, onKeyDownCb, onFocusCb, onBlurCb, onClickCb, onDragEnterCb, onDragOverCb, onDragLeaveCb, onDropCb, noKeyboard, noDrag, disabled]);
1344
+ var onInputElementClick = useCallback(function (event) {
1345
+ event.stopPropagation();
1346
+ }, []);
1347
+ var getInputProps = useMemo(function () {
1348
+ return function () {
1349
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1350
+ _ref3$refKey = _ref3.refKey,
1351
+ refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
1352
+ onChange = _ref3.onChange,
1353
+ onClick = _ref3.onClick,
1354
+ rest = _objectWithoutProperties(_ref3, _excluded4);
1355
+
1356
+ var inputProps = _defineProperty({
1357
+ accept: accept,
1358
+ multiple: multiple,
1359
+ type: 'file',
1360
+ style: {
1361
+ display: 'none'
1362
+ },
1363
+ onChange: composeHandler(composeEventHandlers(onChange, onDropCb)),
1364
+ onClick: composeHandler(composeEventHandlers(onClick, onInputElementClick)),
1365
+ autoComplete: 'off',
1366
+ tabIndex: -1
1367
+ }, refKey, inputRef);
1368
+
1369
+ return _objectSpread(_objectSpread({}, inputProps), rest);
1370
+ };
1371
+ }, [inputRef, accept, multiple, onDropCb, disabled]);
1372
+ var fileCount = draggedFiles.length;
1373
+ var isDragAccept = fileCount > 0 && allFilesAccepted({
1374
+ files: draggedFiles,
1375
+ accept: accept,
1376
+ minSize: minSize,
1377
+ maxSize: maxSize,
1378
+ multiple: multiple,
1379
+ maxFiles: maxFiles
1380
+ });
1381
+ var isDragReject = fileCount > 0 && !isDragAccept;
1382
+ return _objectSpread(_objectSpread({}, state), {}, {
1383
+ isDragAccept: isDragAccept,
1384
+ isDragReject: isDragReject,
1385
+ isFocused: isFocused && !disabled,
1386
+ getRootProps: getRootProps,
1387
+ getInputProps: getInputProps,
1388
+ rootRef: rootRef,
1389
+ inputRef: inputRef,
1390
+ open: composeHandler(openFileDialog)
1391
+ });
1392
+ }
1393
+
1394
+ function reducer(state, action) {
1395
+ /* istanbul ignore next */
1396
+ switch (action.type) {
1397
+ case 'focus':
1398
+ return _objectSpread(_objectSpread({}, state), {}, {
1399
+ isFocused: true
1400
+ });
1401
+
1402
+ case 'blur':
1403
+ return _objectSpread(_objectSpread({}, state), {}, {
1404
+ isFocused: false
1405
+ });
1406
+
1407
+ case 'openDialog':
1408
+ return _objectSpread(_objectSpread({}, initialState), {}, {
1409
+ isFileDialogActive: true
1410
+ });
1411
+
1412
+ case 'closeDialog':
1413
+ return _objectSpread(_objectSpread({}, state), {}, {
1414
+ isFileDialogActive: false
1415
+ });
1416
+
1417
+ case 'setDraggedFiles':
1418
+ /* eslint no-case-declarations: 0 */
1419
+ var isDragActive = action.isDragActive,
1420
+ draggedFiles = action.draggedFiles;
1421
+ return _objectSpread(_objectSpread({}, state), {}, {
1422
+ draggedFiles: draggedFiles,
1423
+ isDragActive: isDragActive
1424
+ });
1425
+
1426
+ case 'setFiles':
1427
+ return _objectSpread(_objectSpread({}, state), {}, {
1428
+ acceptedFiles: action.acceptedFiles,
1429
+ fileRejections: action.fileRejections
1430
+ });
1431
+
1432
+ case 'reset':
1433
+ return _objectSpread({}, initialState);
1434
+
1435
+ default:
1436
+ return state;
1437
+ }
1438
+ }
1439
+
1440
+ function noop() {}
1441
+
1442
+ var styles = {"dropZoneBase":"fSDkYM-382I-","dropZone":"yT6m1v71VK8-","active":"fCb0O1wAjR0-","error":"Cm5wIem0XQI-","validationErrors":"wyjYhAlF1qA-","dropzoneContent":"sAxF04DcAi4-","spinning":"SUZshYRxxl4-"};
1443
+
1444
+ var FileTypes;
1445
+ (function (FileTypes) {
1446
+ FileTypes["JPEG"] = "image/jpeg";
1447
+ FileTypes["JPG"] = "image/jpg";
1448
+ FileTypes["PNG"] = "image/png";
1449
+ FileTypes["HEIC"] = "image/heic";
1450
+ FileTypes["WEBP"] = "image/webp";
1451
+ FileTypes["GIF"] = "image/gif";
1452
+ FileTypes["AVIF"] = "image/avif";
1453
+ FileTypes["PDF"] = "application/pdf";
1454
+ FileTypes["DOCX"] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
1455
+ FileTypes["XLSX"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
1456
+ FileTypes["CSV"] = "text/csv";
1457
+ })(FileTypes || (FileTypes = {}));
1458
+ const BASIC_IMAGE_TYPES = ["PNG", "JPEG", "JPG"];
1459
+ const FILE_TYPE_EXTENSIONS = {
1460
+ [FileTypes.JPEG]: [".jpeg", ".jpg"],
1461
+ [FileTypes.JPG]: [".jpg", ".jpeg"],
1462
+ [FileTypes.PNG]: [".png"],
1463
+ [FileTypes.HEIC]: [".heic"],
1464
+ [FileTypes.WEBP]: [".webp"],
1465
+ [FileTypes.GIF]: [".gif"],
1466
+ [FileTypes.AVIF]: [".avif"],
1467
+ [FileTypes.PDF]: [".pdf"],
1468
+ [FileTypes.DOCX]: [".docx"],
1469
+ [FileTypes.XLSX]: [".xlsx"],
1470
+ [FileTypes.CSV]: [".csv"],
1471
+ };
1472
+ function toAcceptAttribute(types) {
1473
+ const tokens = convertToMimeTypes(types).flatMap(type => {
1474
+ const mime = type.toLowerCase();
1475
+ return Object.hasOwn(FILE_TYPE_EXTENSIONS, mime) ? [type, ...FILE_TYPE_EXTENSIONS[mime]] : [type];
1476
+ });
1477
+ return [...new Set(tokens)].join(",");
1478
+ }
1479
+
1480
+ const inputFileMessages = defineMessages({
1481
+ fileLimit: {
1482
+ en: { one: "Cannot exceed a maximum of {count} file.", other: "Cannot exceed a maximum of {count} files." },
1483
+ es: { one: "No se puede superar el máximo de {count} archivo.", other: "No se puede superar el máximo de {count} archivos." },
1484
+ },
1485
+ uploadFile: { en: "Upload file", es: "Subir archivo" },
1486
+ invalidImage: { en: "{name} must be an image.", es: "{name} debe ser una imagen." },
1487
+ invalidFileType: { en: "{name} must be in {formats} format.", es: "{name} debe estar en formato {formats}." },
1488
+ });
1489
+ // Converts a MIME type to its readable format
1490
+ const mimeTypeToReadable = (mimeType) => {
1491
+ const entry = Object.entries(FileTypes).find(([, value]) => value === mimeType);
1492
+ return entry ? entry[0] : mimeType;
1493
+ };
1494
+ // Converts an array of readable file type names to their corresponding MIME types
1495
+ const convertToMimeTypes = (types) => {
1496
+ return types.map(type => FileTypes[type.toUpperCase()] || type);
1497
+ };
1498
+ function formatMimeTypes(types) {
1499
+ if (types.length === 0) {
1500
+ return "";
1501
+ }
1502
+ else if (types.length === 1) {
1503
+ return types[0];
1504
+ }
1505
+ else {
1506
+ return `${types.slice(0, -1).join(", ")} or ${types[types.length - 1]}`;
1507
+ }
1508
+ }
1509
+
1510
+ const InputFileContentContext = createContext({
1511
+ fileType: "File",
1512
+ allowMultiple: false,
1513
+ description: undefined,
1514
+ hintText: getDefaultHintText("File", false),
1515
+ buttonLabel: getDefaultLabel(false, "File"),
1516
+ size: "base",
1517
+ });
1518
+ function useInputFileContentContext() {
1519
+ const context = useContext(InputFileContentContext);
1520
+ const computedHintText = context.hintText ||
1521
+ getDefaultHintText(context.fileType, context.allowMultiple);
1522
+ const computedButtonLabel = context.buttonLabel ||
1523
+ getDefaultLabel(context.allowMultiple, context.fileType);
1524
+ return Object.assign(Object.assign({}, context), { hintText: computedHintText, buttonLabel: computedButtonLabel });
1525
+ }
1526
+ function getDefaultLabel(multiple, fileType) {
1527
+ return multiple ? `Upload ${fileType}s` : `Upload ${fileType}`;
1528
+ }
1529
+ function getDefaultHintText(fileType, multiple) {
1530
+ const fileTypeDeterminer = fileType === "Image" ? "an" : "a";
1531
+ const hintText = multiple
1532
+ ? `Select or drag ${fileType.toLowerCase()}s here to upload`
1533
+ : `Select or drag ${fileTypeDeterminer} ${fileType.toLowerCase()} here to upload`;
1534
+ return hintText;
1535
+ }
1536
+
1537
+ function InputFileHintText(_a) {
1538
+ var { size = "small", children } = _a, textProps = __rest(_a, ["size", "children"]);
1539
+ const { hintText } = useInputFileContentContext();
1540
+ return (React__default.createElement(Text, Object.assign({}, textProps, { size: size }), children || hintText));
1541
+ }
1542
+
1543
+ function InputFileDescription(_a) {
1544
+ var { size = "small", variation = "subdued", children } = _a, textProps = __rest(_a, ["size", "variation", "children"]);
1545
+ const { description } = useInputFileContentContext();
1546
+ if (!children && !description) {
1547
+ return null;
1548
+ }
1549
+ return (React__default.createElement(Text, Object.assign({ size: size, variation: variation }, textProps), children || description));
1550
+ }
1551
+
1552
+ function InputFileButton(_a) {
1553
+ var { label, size, fullWidth = false } = _a, buttonProps = __rest(_a, ["label", "size", "fullWidth"]);
1554
+ const { buttonLabel: contextLabel, size: contextSize } = useInputFileContentContext();
1555
+ return (React__default.createElement(Button, Object.assign({}, buttonProps, { label: label || contextLabel, size: size !== null && size !== void 0 ? size : contextSize, type: "secondary", fullWidth: fullWidth })));
1556
+ }
1557
+
1558
+ function InputFileDropzoneWrapper({ children, }) {
1559
+ return React__default.createElement("div", { className: styles.dropzoneContent }, children);
1560
+ }
1561
+
1562
+ function InputFileValidationErrors({ validationErrors, }) {
1563
+ if (validationErrors.length === 0) {
1564
+ return null;
1565
+ }
1566
+ return (React__default.createElement("div", { className: styles.validationErrors }, validationErrors.map((error, index) => (React__default.createElement(InputValidation, { message: error.message, key: `${error.code}-${index}` })))));
1567
+ }
1568
+
1569
+ /* eslint-disable max-statements */
1570
+ function InputFile({ variation = "dropzone", size = "base", name, buttonLabel: providedButtonLabel, allowMultiple = false, allowedTypes = "all", description, hintText, maxFilesValidation, getUploadParams, onUploadStart, onUploadProgress, onUploadComplete, onUploadError, validator, children, }) {
1571
+ const { locale, plural, t } = useComponentMessages(inputFileMessages);
1572
+ const maxFiles = maxFilesValidation?.maxFiles || 0;
1573
+ const numberOfCurrentFiles = maxFilesValidation?.numberOfCurrentFiles || 0;
1574
+ const [rejectedBatchLimit, setRejectedBatchLimit] = useState();
1575
+ const options = { multiple: true, onDrop: handleDrop, validator };
1576
+ if (allowedTypes === "images") {
1577
+ options.accept = "image/*";
1578
+ }
1579
+ else if (allowedTypes === "basicImages") {
1580
+ options.accept = toAcceptAttribute(BASIC_IMAGE_TYPES);
1581
+ }
1582
+ else if (Array.isArray(allowedTypes)) {
1583
+ options.accept = toAcceptAttribute(allowedTypes);
1584
+ }
1585
+ const { getRootProps, getInputProps, isDragActive, fileRejections } = useDropzone(options);
1586
+ const allowedFormats = allowedTypes === "basicImages" ? BASIC_IMAGE_TYPES : allowedTypes;
1587
+ const formats = Array.isArray(allowedFormats) ? allowedFormats.map(mimeTypeToReadable) : [allowedFormats];
1588
+ const formatMessage = locale.split("-")[0] === "es"
1589
+ ? new Intl.ListFormat("es", { type: "disjunction" }).format(formats)
1590
+ : formatMimeTypes(formats);
1591
+ const validationErrors = fileRejections === null || fileRejections === void 0 ? void 0 : fileRejections.reduce((acc, { file, errors }) => {
1592
+ errors.forEach(error => {
1593
+ if (error.code === "file-invalid-type") {
1594
+ const message = allowedTypes === "images"
1595
+ ? t("invalidImage", { name: file.name })
1596
+ : t("invalidFileType", { name: file.name, formats: formatMessage });
1597
+ acc.push({
1598
+ code: error.code,
1599
+ message: message,
1600
+ });
1601
+ }
1602
+ else {
1603
+ acc.push({
1604
+ code: error.code,
1605
+ message: `${file.name} ${error.message}`,
1606
+ });
1607
+ }
1608
+ });
1609
+ return acc;
1610
+ }, []);
1611
+ if (rejectedBatchLimit !== undefined) {
1612
+ validationErrors.push({ code: "too-many-files", message: plural("fileLimit", rejectedBatchLimit) });
1613
+ }
1614
+ const dropZone = classnames(styles.dropZoneBase, {
1615
+ [styles.dropZone]: variation === "dropzone",
1616
+ [styles.active]: isDragActive,
1617
+ [styles.error]: validationErrors.length > 0,
1618
+ });
1619
+ const fileType = allowedTypes === "images" || allowedTypes === "basicImages"
1620
+ ? "Image"
1621
+ : "File";
1622
+ const contentContext = {
1623
+ fileType: fileType,
1624
+ allowMultiple,
1625
+ description,
1626
+ hintText: hintText || "",
1627
+ buttonLabel: providedButtonLabel || "",
1628
+ size,
1629
+ };
1630
+ const defaultContent = (React__default.createElement(React__default.Fragment, null,
1631
+ variation === "dropzone" && (React__default.createElement(InputFile.DropzoneWrapper, null,
1632
+ React__default.createElement(Content, { spacing: "small" },
1633
+ React__default.createElement(InputFile.Button, { size: "small", fullWidth: false }),
1634
+ size === "base" && (React__default.createElement(React__default.Fragment, null,
1635
+ React__default.createElement(InputFile.HintText, null),
1636
+ React__default.createElement(InputFile.Description, null)))))),
1637
+ variation === "button" && React__default.createElement(InputFile.Button, { fullWidth: true })));
1638
+ return (React__default.createElement(React__default.Fragment, null,
1639
+ React__default.createElement("div", Object.assign({}, getRootProps({ className: dropZone }), { tabIndex: variation === "button" ? -1 : 0 }),
1640
+ React__default.createElement("input", Object.assign({}, getInputProps({ multiple: allowMultiple, "aria-label": providedButtonLabel || t("uploadFile") }), { "data-testid": "input-file-input", name: name })),
1641
+ React__default.createElement(InputFileContentContext.Provider, { value: contentContext }, children || defaultContent)),
1642
+ React__default.createElement(InputFileValidationErrors, { validationErrors: validationErrors })));
1643
+ function handleDrop(acceptedFiles) {
1644
+ const remainingCapacity = maxFiles > 0 ? Math.max(0, maxFiles - numberOfCurrentFiles) : Infinity;
1645
+ const capacity = allowMultiple ? remainingCapacity : Math.min(1, remainingCapacity);
1646
+ if (acceptedFiles.length > capacity) {
1647
+ const maximum = allowMultiple || remainingCapacity === 0 ? maxFiles : 1;
1648
+ setRejectedBatchLimit(maximum);
1649
+ return;
1650
+ }
1651
+ setRejectedBatchLimit(undefined);
1652
+ acceptedFiles.forEach(file => {
1653
+ uploadFile(file);
1654
+ });
1655
+ }
1656
+ function uploadFile(file) {
1657
+ return __awaiter(this, void 0, void 0, function* () {
1658
+ let params;
1659
+ try {
1660
+ params = yield getUploadParams(file);
1661
+ }
1662
+ catch (error) {
1663
+ onUploadError &&
1664
+ onUploadError(error instanceof Error
1665
+ ? error
1666
+ : new Error("Failed to get upload params"));
1667
+ return;
1668
+ }
1669
+ const { url, key = generateId(), fields = {}, httpMethod = "POST", signal, } = params;
1670
+ const cancelError = () => new DOMException("Upload cancelled", "AbortError");
1671
+ if (signal?.aborted) {
1672
+ onUploadError?.(cancelError());
1673
+ return;
1674
+ }
1675
+ const fileUpload = getFileUpload(file, key, url);
1676
+ onUploadStart && onUploadStart(Object.assign({}, fileUpload));
1677
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1678
+ const handleUploadProgress = (progressEvent) => {
1679
+ if (signal?.aborted || !progressEvent.total) return;
1680
+ onUploadProgress &&
1681
+ onUploadProgress(Object.assign(Object.assign({}, fileUpload), { progress: progressEvent.loaded / progressEvent.total }));
1682
+ };
1683
+ const handleUploadComplete = () => {
1684
+ onUploadComplete === null || onUploadComplete === void 0 ? void 0 : onUploadComplete(Object.assign(Object.assign({}, fileUpload), { progress: 1 }));
1685
+ };
1686
+ const axiosConfig = createAxiosConfig({
1687
+ url,
1688
+ httpMethod,
1689
+ fields,
1690
+ file,
1691
+ handleUploadProgress,
1692
+ signal,
1693
+ });
1694
+ axios
1695
+ .request(axiosConfig)
1696
+ .then(handleUploadComplete, () => {
1697
+ onUploadError?.(signal?.aborted ? cancelError() : new Error("Failed to upload file"));
1698
+ });
1699
+ });
1700
+ }
1701
+ }
1702
+ function createAxiosConfig({ url, httpMethod = "POST", fields = {}, file, handleUploadProgress, signal, }) {
1703
+ let data;
1704
+ let headers;
1705
+ if (httpMethod === "POST") {
1706
+ const formData = new FormData();
1707
+ Object.entries(fields).forEach(([field, value]) => formData.append(field, value));
1708
+ formData.append("file", file);
1709
+ data = formData;
1710
+ headers = { "X-Requested-With": "XMLHttpRequest" };
1711
+ }
1712
+ else {
1713
+ data = file;
1714
+ headers = fields;
1715
+ }
1716
+ return {
1717
+ method: httpMethod,
1718
+ url: url,
1719
+ headers: headers,
1720
+ data: data,
1721
+ onUploadProgress: handleUploadProgress,
1722
+ signal,
1723
+ };
1724
+ }
1725
+ function getFileUpload(file, key, uploadUrl) {
1726
+ return {
1727
+ key: key,
1728
+ name: file.name,
1729
+ type: file.type,
1730
+ size: file.size,
1731
+ progress: 0,
1732
+ src: getSrc,
1733
+ uploadUrl,
1734
+ };
1735
+ function getSrc() {
1736
+ const promise = new Promise((resolve, reject) => {
1737
+ const reader = new FileReader();
1738
+ reader.onload = event => {
1739
+ if (event.target &&
1740
+ event.target.result &&
1741
+ typeof event.target.result === "string") {
1742
+ resolve(event.target.result);
1743
+ }
1744
+ else {
1745
+ reject("Could not generate file data url.");
1746
+ }
1747
+ };
1748
+ reader.readAsDataURL(file);
1749
+ });
1750
+ return promise;
1751
+ }
1752
+ }
1753
+ /**
1754
+ * Upsert a given `FileUpload` into an array of `FileUpload`s.
1755
+ * `key` is used to uniquely identify files.
1756
+ *
1757
+ * @param updatedFile FileUpload File that was updated.
1758
+ * @param files Existing array of FileUploads.
1759
+ * @returns FileUpload[] updated set of files.
1760
+ */
1761
+ function updateFiles(updatedFile, files) {
1762
+ const newFiles = [...files];
1763
+ const index = files.findIndex(file => file.key === updatedFile.key);
1764
+ if (index !== -1) {
1765
+ newFiles[index] = updatedFile;
1766
+ }
1767
+ else {
1768
+ newFiles.push(updatedFile);
1769
+ }
1770
+ return newFiles;
1771
+ }
1772
+ function generateId() {
1773
+ return Math.floor(Math.random() * Date.now()).toString(16);
1774
+ }
1775
+ InputFile.Button = InputFileButton;
1776
+ InputFile.Description = InputFileDescription;
1777
+ InputFile.DropzoneWrapper = InputFileDropzoneWrapper;
1778
+ InputFile.HintText = InputFileHintText;
1779
+
1780
+ export { FileTypes as F, InputFile as I, InputFileContentContext as a, useInputFileContentContext as b, convertToMimeTypes as c, formatMimeTypes as f, mimeTypeToReadable as m, updateFiles as u };