@carbon/react 1.103.0-rc.0 → 1.104.0-rc.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 (777) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +950 -950
  2. package/es/_virtual/_rolldown/runtime.js +25 -0
  3. package/es/components/AILabel/index.d.ts +29 -2
  4. package/es/components/AILabel/index.js +114 -169
  5. package/es/components/AISkeleton/AISkeletonIcon.js +23 -27
  6. package/es/components/AISkeleton/AISkeletonPlaceholder.js +19 -27
  7. package/es/components/AISkeleton/AISkeletonText.js +26 -39
  8. package/es/components/Accordion/Accordion.Skeleton.js +55 -79
  9. package/es/components/Accordion/Accordion.js +43 -61
  10. package/es/components/Accordion/AccordionItem.js +102 -156
  11. package/es/components/Accordion/AccordionProvider.js +18 -15
  12. package/es/components/AspectRatio/AspectRatio.js +41 -47
  13. package/es/components/BadgeIndicator/index.js +28 -33
  14. package/es/components/Breadcrumb/Breadcrumb.Skeleton.js +39 -50
  15. package/es/components/Breadcrumb/Breadcrumb.js +39 -51
  16. package/es/components/Breadcrumb/BreadcrumbItem.js +80 -83
  17. package/es/components/Button/Button.Skeleton.js +49 -58
  18. package/es/components/Button/Button.d.ts +1 -1
  19. package/es/components/Button/Button.js +146 -240
  20. package/es/components/Button/ButtonBase.js +82 -104
  21. package/es/components/Button/index.js +13 -6
  22. package/es/components/ButtonSet/ButtonSet.js +74 -98
  23. package/es/components/ButtonSet/index.js +12 -4
  24. package/es/components/ChatButton/ChatButton.Skeleton.js +27 -27
  25. package/es/components/ChatButton/ChatButton.js +64 -79
  26. package/es/components/Checkbox/Checkbox.Skeleton.js +26 -25
  27. package/es/components/Checkbox/Checkbox.js +116 -195
  28. package/es/components/Checkbox/index.js +13 -5
  29. package/es/components/CheckboxGroup/CheckboxGroup.js +100 -148
  30. package/es/components/ClassPrefix/index.js +21 -17
  31. package/es/components/CodeSnippet/CodeSnippet.Skeleton.js +45 -42
  32. package/es/components/CodeSnippet/CodeSnippet.js +210 -299
  33. package/es/components/ComboBox/ComboBox.js +621 -970
  34. package/es/components/ComboBox/index.js +12 -4
  35. package/es/components/ComboButton/index.js +172 -208
  36. package/es/components/ComposedModal/ComposedModal.js +311 -450
  37. package/es/components/ComposedModal/ComposedModalPresence.js +47 -42
  38. package/es/components/ComposedModal/ModalFooter.js +127 -207
  39. package/es/components/ComposedModal/ModalHeader.js +71 -101
  40. package/es/components/ComposedModal/useComposedModalState.js +21 -15
  41. package/es/components/ContainedList/ContainedList.js +67 -102
  42. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +49 -67
  43. package/es/components/ContainedList/ContainedListItem/index.js +12 -4
  44. package/es/components/ContainedList/index.js +15 -12
  45. package/es/components/ContentSwitcher/ContentSwitcher.js +108 -140
  46. package/es/components/ContextMenu/useContextMenu.js +41 -36
  47. package/es/components/Copy/Copy.js +97 -117
  48. package/es/components/Copy/index.js +12 -4
  49. package/es/components/CopyButton/CopyButton.js +81 -94
  50. package/es/components/CopyButton/index.js +12 -4
  51. package/es/components/DangerButton/DangerButton.js +11 -9
  52. package/es/components/DataTable/DataTable.d.ts +11 -11
  53. package/es/components/DataTable/DataTable.js +448 -630
  54. package/es/components/DataTable/Table.js +111 -156
  55. package/es/components/DataTable/TableActionList.js +14 -6
  56. package/es/components/DataTable/TableBatchAction.js +25 -34
  57. package/es/components/DataTable/TableBatchActions.js +78 -113
  58. package/es/components/DataTable/TableBody.js +26 -19
  59. package/es/components/DataTable/TableCell.js +31 -46
  60. package/es/components/DataTable/TableContainer.js +75 -82
  61. package/es/components/DataTable/TableContext.js +14 -6
  62. package/es/components/DataTable/TableDecoratorRow.js +30 -36
  63. package/es/components/DataTable/TableExpandHeader.js +53 -90
  64. package/es/components/DataTable/TableExpandRow.js +82 -119
  65. package/es/components/DataTable/TableExpandedRow.js +45 -51
  66. package/es/components/DataTable/TableHead.js +7 -5
  67. package/es/components/DataTable/TableHeader.js +138 -181
  68. package/es/components/DataTable/TableRow.d.ts +1 -1
  69. package/es/components/DataTable/TableRow.js +42 -76
  70. package/es/components/DataTable/TableSelectAll.js +42 -70
  71. package/es/components/DataTable/TableSelectRow.js +63 -98
  72. package/es/components/DataTable/TableSlugRow.js +35 -43
  73. package/es/components/DataTable/TableToolbar.js +33 -45
  74. package/es/components/DataTable/TableToolbarAction.js +25 -20
  75. package/es/components/DataTable/TableToolbarContent.js +14 -6
  76. package/es/components/DataTable/TableToolbarMenu.js +35 -46
  77. package/es/components/DataTable/TableToolbarSearch.js +97 -187
  78. package/es/components/DataTable/state/getDerivedStateFromProps.js +38 -43
  79. package/es/components/DataTable/state/sortStates.js +11 -9
  80. package/es/components/DataTable/state/sorting.js +53 -72
  81. package/es/components/DataTable/tools/cells.js +15 -7
  82. package/es/components/DataTable/tools/denormalize.js +27 -19
  83. package/es/components/DataTable/tools/filter.js +21 -22
  84. package/es/components/DataTable/tools/normalize.js +57 -72
  85. package/es/components/DataTable/tools/sorting.js +50 -71
  86. package/es/components/DataTableSkeleton/DataTableSkeleton.js +66 -94
  87. package/es/components/DatePicker/DatePicker.Skeleton.js +44 -51
  88. package/es/components/DatePicker/DatePicker.d.ts +4 -2
  89. package/es/components/DatePicker/DatePicker.js +485 -749
  90. package/es/components/DatePicker/DatePickerLocales.js +75 -126
  91. package/es/components/DatePicker/index.js +13 -5
  92. package/es/components/DatePicker/plugins/appendToPlugin.js +31 -45
  93. package/es/components/DatePicker/plugins/fixEventsPlugin.js +127 -171
  94. package/es/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
  95. package/es/components/DatePicker/plugins/rangePlugin.js +40 -47
  96. package/es/components/DatePicker/utils.d.ts +7 -0
  97. package/es/components/DatePicker/utils.js +18 -0
  98. package/es/components/DatePickerInput/DatePickerInput.js +179 -289
  99. package/es/components/DatePickerInput/index.js +12 -4
  100. package/es/components/Dialog/Dialog.js +303 -574
  101. package/es/components/Dialog/index.js +18 -2
  102. package/es/components/Dropdown/Dropdown.Skeleton.js +26 -38
  103. package/es/components/Dropdown/Dropdown.js +344 -535
  104. package/es/components/Dropdown/index.js +13 -5
  105. package/es/components/ErrorBoundary/ErrorBoundary.js +36 -58
  106. package/es/components/ErrorBoundary/ErrorBoundaryContext.js +14 -9
  107. package/es/components/ExpandableSearch/ExpandableSearch.js +60 -69
  108. package/es/components/ExpandableSearch/index.js +12 -4
  109. package/es/components/FeatureFlags/index.d.ts +11 -2
  110. package/es/components/FeatureFlags/index.js +79 -77
  111. package/es/components/FileUploader/FileUploader.Skeleton.js +35 -30
  112. package/es/components/FileUploader/FileUploader.js +269 -343
  113. package/es/components/FileUploader/FileUploaderButton.js +110 -160
  114. package/es/components/FileUploader/FileUploaderDropContainer.js +144 -221
  115. package/es/components/FileUploader/FileUploaderItem.js +138 -157
  116. package/es/components/FileUploader/Filename.d.ts +1 -1
  117. package/es/components/FileUploader/Filename.js +53 -72
  118. package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +26 -28
  119. package/es/components/FluidComboBox/FluidComboBox.js +54 -105
  120. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +56 -53
  121. package/es/components/FluidDatePicker/FluidDatePicker.js +46 -68
  122. package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +23 -16
  123. package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +26 -28
  124. package/es/components/FluidDropdown/FluidDropdown.js +55 -111
  125. package/es/components/FluidForm/FluidForm.js +29 -31
  126. package/es/components/FluidForm/FormContext.js +12 -6
  127. package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +26 -28
  128. package/es/components/FluidMultiSelect/FluidMultiSelect.js +67 -197
  129. package/es/components/FluidNumberInput/FluidNumberInput.Skeleton.js +27 -30
  130. package/es/components/FluidNumberInput/FluidNumberInput.js +63 -147
  131. package/es/components/FluidSearch/FluidSearch.Skeleton.js +27 -30
  132. package/es/components/FluidSearch/FluidSearch.js +41 -84
  133. package/es/components/FluidSelect/FluidSelect.Skeleton.js +26 -28
  134. package/es/components/FluidSelect/FluidSelect.js +40 -76
  135. package/es/components/FluidSelect/index.js +13 -5
  136. package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +27 -30
  137. package/es/components/FluidTextArea/FluidTextArea.js +48 -112
  138. package/es/components/FluidTextInput/FluidPasswordInput.js +44 -99
  139. package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +27 -30
  140. package/es/components/FluidTextInput/FluidTextInput.js +49 -104
  141. package/es/components/FluidTextInput/index.js +14 -6
  142. package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +30 -33
  143. package/es/components/FluidTimePicker/FluidTimePicker.js +68 -115
  144. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +28 -47
  145. package/es/components/Form/Form.js +23 -25
  146. package/es/components/FormGroup/FormGroup.js +45 -67
  147. package/es/components/FormItem/FormItem.js +23 -25
  148. package/es/components/FormLabel/FormLabel.js +28 -34
  149. package/es/components/Grid/CSSGrid.d.ts +1 -1
  150. package/es/components/Grid/CSSGrid.js +85 -127
  151. package/es/components/Grid/Column.js +192 -324
  152. package/es/components/Grid/ColumnHang.js +28 -36
  153. package/es/components/Grid/FlexGrid.js +40 -60
  154. package/es/components/Grid/Grid.js +29 -42
  155. package/es/components/Grid/GridContext.js +36 -42
  156. package/es/components/Grid/Row.js +31 -49
  157. package/es/components/Heading/index.js +36 -51
  158. package/es/components/Icon/Icon.Skeleton.js +21 -21
  159. package/es/components/IconButton/index.js +117 -178
  160. package/es/components/IconIndicator/index.d.ts +1 -1
  161. package/es/components/IconIndicator/index.js +59 -60
  162. package/es/components/IdPrefix/index.js +21 -17
  163. package/es/components/InlineCheckbox/InlineCheckbox.js +69 -113
  164. package/es/components/InlineCheckbox/index.js +12 -4
  165. package/es/components/InlineLoading/InlineLoading.js +83 -100
  166. package/es/components/InlineLoading/index.js +12 -4
  167. package/es/components/Layer/LayerContext.js +12 -4
  168. package/es/components/Layer/LayerLevel.js +20 -4
  169. package/es/components/Layer/index.js +54 -66
  170. package/es/components/Layout/index.js +77 -109
  171. package/es/components/LayoutDirection/LayoutDirection.d.ts +1 -1
  172. package/es/components/LayoutDirection/LayoutDirection.js +33 -37
  173. package/es/components/LayoutDirection/LayoutDirectionContext.js +12 -6
  174. package/es/components/LayoutDirection/useLayoutDirection.js +15 -7
  175. package/es/components/Link/Link.js +63 -108
  176. package/es/components/Link/index.js +12 -4
  177. package/es/components/ListBox/ListBox.js +78 -126
  178. package/es/components/ListBox/ListBoxField.js +24 -43
  179. package/es/components/ListBox/ListBoxMenu.js +36 -42
  180. package/es/components/ListBox/ListBoxMenuIcon.js +39 -40
  181. package/es/components/ListBox/ListBoxMenuItem.js +67 -88
  182. package/es/components/ListBox/ListBoxPropTypes.js +17 -5
  183. package/es/components/ListBox/ListBoxSelection.js +71 -96
  184. package/es/components/ListBox/index.js +16 -14
  185. package/es/components/ListBox/next/ListBoxSelection.js +79 -117
  186. package/es/components/ListBox/next/ListBoxTrigger.js +44 -48
  187. package/es/components/ListItem/ListItem.js +25 -28
  188. package/es/components/Loading/Loading.js +64 -73
  189. package/es/components/Loading/index.js +12 -4
  190. package/es/components/Menu/Menu.js +220 -363
  191. package/es/components/Menu/MenuContext.d.ts +1 -1
  192. package/es/components/Menu/MenuContext.js +41 -38
  193. package/es/components/Menu/MenuItem.js +282 -413
  194. package/es/components/MenuButton/index.js +134 -195
  195. package/es/components/Modal/Modal.js +500 -660
  196. package/es/components/Modal/ModalPresence.js +39 -37
  197. package/es/components/Modal/index.js +13 -5
  198. package/es/components/ModalWrapper/ModalWrapper.d.ts +2 -2
  199. package/es/components/ModalWrapper/ModalWrapper.js +106 -130
  200. package/es/components/MultiSelect/FilterableMultiSelect.js +605 -918
  201. package/es/components/MultiSelect/MultiSelect.js +454 -716
  202. package/es/components/MultiSelect/MultiSelectPropTypes.js +13 -30
  203. package/es/components/MultiSelect/filter.js +14 -9
  204. package/es/components/MultiSelect/tools/sorting.js +21 -34
  205. package/es/components/Notification/Notification.js +508 -785
  206. package/es/components/NumberInput/NumberFormatPropTypes.js +69 -30
  207. package/es/components/NumberInput/NumberInput.Skeleton.js +29 -33
  208. package/es/components/NumberInput/NumberInput.js +567 -947
  209. package/es/components/OrderedList/OrderedList.js +31 -44
  210. package/es/components/OverflowMenu/OverflowMenu.js +335 -450
  211. package/es/components/OverflowMenu/index.js +25 -16
  212. package/es/components/OverflowMenu/next/index.js +154 -186
  213. package/es/components/OverflowMenuItem/OverflowMenuItem.js +100 -160
  214. package/es/components/OverflowMenuItem/index.js +12 -4
  215. package/es/components/OverflowMenuV2/index.js +15 -13
  216. package/es/components/PageHeader/PageHeader.js +297 -442
  217. package/es/components/PageHeader/index.js +24 -2
  218. package/es/components/Pagination/Pagination.Skeleton.js +34 -35
  219. package/es/components/Pagination/Pagination.d.ts +1 -1
  220. package/es/components/Pagination/Pagination.js +251 -356
  221. package/es/components/Pagination/experimental/PageSelector.js +38 -54
  222. package/es/components/Pagination/experimental/Pagination-story.d.ts +114 -0
  223. package/es/components/Pagination/experimental/Pagination.js +144 -196
  224. package/es/components/PaginationNav/PaginationNav.js +320 -426
  225. package/es/components/Popover/index.js +318 -437
  226. package/es/components/PrimaryButton/PrimaryButton.js +11 -9
  227. package/es/components/ProgressBar/ProgressBar.js +117 -143
  228. package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +42 -38
  229. package/es/components/ProgressIndicator/ProgressIndicator.js +146 -243
  230. package/es/components/RadioButton/RadioButton.Skeleton.js +23 -25
  231. package/es/components/RadioButton/RadioButton.js +101 -174
  232. package/es/components/RadioButton/index.js +12 -4
  233. package/es/components/RadioButtonGroup/RadioButtonGroup.js +135 -207
  234. package/es/components/RadioTile/RadioTile.js +104 -168
  235. package/es/components/RadioTile/index.js +12 -4
  236. package/es/components/Search/Search.Skeleton.js +28 -33
  237. package/es/components/Search/Search.js +182 -278
  238. package/es/components/Search/index.js +13 -5
  239. package/es/components/Search/utils.js +11 -3
  240. package/es/components/SecondaryButton/SecondaryButton.js +11 -9
  241. package/es/components/Select/Select.Skeleton.js +27 -30
  242. package/es/components/Select/Select.js +178 -257
  243. package/es/components/Select/index.js +13 -5
  244. package/es/components/SelectItem/SelectItem.js +33 -48
  245. package/es/components/SelectItem/index.js +12 -4
  246. package/es/components/SelectItemGroup/SelectItemGroup.js +27 -37
  247. package/es/components/ShapeIndicator/index.d.ts +1 -1
  248. package/es/components/ShapeIndicator/index.js +74 -80
  249. package/es/components/SkeletonIcon/SkeletonIcon.js +21 -24
  250. package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +15 -24
  251. package/es/components/SkeletonText/SkeletonText.js +67 -81
  252. package/es/components/SkeletonText/index.js +12 -4
  253. package/es/components/Slider/Slider.Skeleton.js +68 -91
  254. package/es/components/Slider/Slider.js +864 -1315
  255. package/es/components/Slider/SliderHandles.js +73 -66
  256. package/es/components/Stack/HStack.js +19 -11
  257. package/es/components/Stack/Stack.js +56 -80
  258. package/es/components/Stack/VStack.js +19 -11
  259. package/es/components/StructuredList/StructuredList.Skeleton.js +55 -48
  260. package/es/components/StructuredList/StructuredList.js +178 -317
  261. package/es/components/Switch/IconSwitch.js +99 -145
  262. package/es/components/Switch/Switch.js +66 -99
  263. package/es/components/TabContent/TabContent.js +28 -34
  264. package/es/components/Tabs/Tabs.Skeleton.js +41 -36
  265. package/es/components/Tabs/Tabs.js +732 -1147
  266. package/es/components/Tabs/usePressable.js +97 -112
  267. package/es/components/Tag/DismissibleTag.js +119 -156
  268. package/es/components/Tag/OperationalTag.js +91 -111
  269. package/es/components/Tag/SelectableTag.js +94 -129
  270. package/es/components/Tag/Tag.Skeleton.js +26 -30
  271. package/es/components/Tag/Tag.js +152 -200
  272. package/es/components/Tag/isEllipsisActive.js +13 -8
  273. package/es/components/Text/Text.js +66 -79
  274. package/es/components/Text/TextDirection.js +36 -37
  275. package/es/components/Text/TextDirectionContext.js +14 -8
  276. package/es/components/Text/createTextComponent.js +21 -20
  277. package/es/components/TextArea/TextArea.Skeleton.js +25 -29
  278. package/es/components/TextArea/TextArea.js +315 -422
  279. package/es/components/TextArea/index.js +13 -5
  280. package/es/components/TextInput/ControlledPasswordInput.js +133 -198
  281. package/es/components/TextInput/PasswordInput.js +196 -303
  282. package/es/components/TextInput/TextInput.Skeleton.js +24 -28
  283. package/es/components/TextInput/TextInput.js +219 -317
  284. package/es/components/TextInput/index.js +13 -5
  285. package/es/components/TextInput/util.js +21 -25
  286. package/es/components/Theme/index.js +79 -95
  287. package/es/components/Tile/Tile.d.ts +2 -2
  288. package/es/components/Tile/Tile.js +394 -588
  289. package/es/components/TileGroup/TileGroup.js +70 -111
  290. package/es/components/TimePicker/TimePicker.d.ts +1 -1
  291. package/es/components/TimePicker/TimePicker.js +148 -247
  292. package/es/components/TimePickerSelect/TimePickerSelect.js +43 -58
  293. package/es/components/Toggle/Toggle.Skeleton.js +24 -22
  294. package/es/components/Toggle/Toggle.js +102 -171
  295. package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +46 -51
  296. package/es/components/Toggletip/index.d.ts +2 -2
  297. package/es/components/Toggletip/index.js +170 -256
  298. package/es/components/Tooltip/DefinitionTooltip.js +98 -138
  299. package/es/components/Tooltip/Tooltip.js +188 -263
  300. package/es/components/TreeView/TreeContext.js +13 -5
  301. package/es/components/TreeView/TreeNode.js +361 -500
  302. package/es/components/TreeView/TreeView.js +164 -237
  303. package/es/components/UIShell/Content.js +23 -30
  304. package/es/components/UIShell/Header.js +25 -29
  305. package/es/components/UIShell/HeaderContainer.js +31 -40
  306. package/es/components/UIShell/HeaderGlobalAction.js +65 -90
  307. package/es/components/UIShell/HeaderGlobalBar.js +16 -9
  308. package/es/components/UIShell/HeaderMenu.js +141 -215
  309. package/es/components/UIShell/HeaderMenuButton.js +43 -66
  310. package/es/components/UIShell/HeaderMenuItem.js +49 -76
  311. package/es/components/UIShell/HeaderName.js +32 -44
  312. package/es/components/UIShell/HeaderNavigation.js +32 -37
  313. package/es/components/UIShell/HeaderPanel.js +74 -97
  314. package/es/components/UIShell/HeaderSideNavItems.js +27 -33
  315. package/es/components/UIShell/Link.js +29 -50
  316. package/es/components/UIShell/SideNav.js +132 -241
  317. package/es/components/UIShell/SideNavContext.js +21 -15
  318. package/es/components/UIShell/SideNavDetails.js +29 -34
  319. package/es/components/UIShell/SideNavDivider.js +21 -21
  320. package/es/components/UIShell/SideNavFooter.js +43 -52
  321. package/es/components/UIShell/SideNavHeader.js +26 -35
  322. package/es/components/UIShell/SideNavIcon.js +28 -33
  323. package/es/components/UIShell/SideNavItem.js +28 -33
  324. package/es/components/UIShell/SideNavItems.js +31 -40
  325. package/es/components/UIShell/SideNavLink.js +52 -79
  326. package/es/components/UIShell/SideNavLinkText.js +24 -25
  327. package/es/components/UIShell/SideNavMenu.js +102 -143
  328. package/es/components/UIShell/SideNavMenuItem.js +40 -52
  329. package/es/components/UIShell/SideNavSwitcher.js +59 -68
  330. package/es/components/UIShell/SkipToContent.js +28 -36
  331. package/es/components/UIShell/Switcher.js +69 -99
  332. package/es/components/UIShell/SwitcherDivider.js +16 -24
  333. package/es/components/UIShell/SwitcherItem.js +74 -114
  334. package/es/components/UnorderedList/UnorderedList.js +28 -37
  335. package/es/feature-flags.js +19 -10
  336. package/es/index.js +249 -242
  337. package/es/internal/FloatingMenu.js +246 -292
  338. package/es/internal/OptimizedResize.js +35 -46
  339. package/es/internal/Selection.js +99 -132
  340. package/es/internal/clamp.js +12 -4
  341. package/es/internal/defaultItemToString.js +15 -9
  342. package/es/internal/deprecateFieldOnObject.js +22 -14
  343. package/es/internal/environment.js +15 -7
  344. package/es/internal/getAnnouncement.js +16 -13
  345. package/es/internal/keyboard/keys.js +48 -48
  346. package/es/internal/keyboard/match.js +25 -42
  347. package/es/internal/keyboard/navigation.js +22 -27
  348. package/es/internal/noopFn.js +10 -2
  349. package/es/internal/useAttachedMenu.js +43 -51
  350. package/es/internal/useControllableState.js +43 -48
  351. package/es/internal/useDelayedState.js +30 -35
  352. package/es/internal/useEvent.js +39 -35
  353. package/es/internal/useId.js +51 -87
  354. package/es/internal/useIdPrefix.js +13 -5
  355. package/es/internal/useIsomorphicEffect.js +12 -4
  356. package/es/internal/useMatchMedia.js +29 -21
  357. package/es/internal/useMergedRefs.js +26 -22
  358. package/es/internal/useNoInteractiveChildren.js +70 -99
  359. package/es/internal/useNormalizedInputProps.js +47 -51
  360. package/es/internal/useOutsideClick.js +21 -24
  361. package/es/internal/useOverflowItems.js +89 -90
  362. package/es/internal/usePrefix.js +13 -5
  363. package/es/internal/usePresence.js +51 -54
  364. package/es/internal/usePresenceContext.js +35 -35
  365. package/es/internal/usePreviousValue.js +26 -18
  366. package/es/internal/useResizeObserver.js +57 -66
  367. package/es/internal/useSavedCallback.js +24 -17
  368. package/es/internal/utils.js +17 -9
  369. package/es/internal/warning.js +17 -22
  370. package/es/internal/wrapFocus.js +77 -98
  371. package/es/prop-types/AriaPropTypes.js +14 -6
  372. package/es/prop-types/deprecate.js +30 -27
  373. package/es/prop-types/deprecateComponent.js +17 -8
  374. package/es/prop-types/deprecateValuesWithin.js +18 -21
  375. package/es/prop-types/isRequiredOneOf.js +21 -24
  376. package/es/prop-types/requiredIfGivenPropIsTruthy.js +14 -14
  377. package/es/tools/events.js +17 -21
  378. package/es/tools/mapPopoverAlign.js +19 -18
  379. package/es/tools/mergeRefs.js +14 -17
  380. package/es/tools/setupGetInstanceId.js +16 -8
  381. package/es/tools/toggleClass.js +17 -9
  382. package/es/tools/wrapComponent.js +34 -39
  383. package/icons/index.d.ts +2 -1
  384. package/icons/index.esm.js +2 -2
  385. package/icons/index.js +7 -10
  386. package/lib/_virtual/_rolldown/runtime.js +50 -0
  387. package/lib/components/AILabel/index.d.ts +29 -2
  388. package/lib/components/AILabel/index.js +118 -171
  389. package/lib/components/AISkeleton/AISkeletonIcon.js +27 -31
  390. package/lib/components/AISkeleton/AISkeletonPlaceholder.js +29 -31
  391. package/lib/components/AISkeleton/AISkeletonText.js +30 -43
  392. package/lib/components/Accordion/Accordion.Skeleton.js +59 -84
  393. package/lib/components/Accordion/Accordion.js +47 -65
  394. package/lib/components/Accordion/AccordionItem.js +106 -160
  395. package/lib/components/Accordion/AccordionProvider.js +20 -17
  396. package/lib/components/AspectRatio/AspectRatio.js +45 -51
  397. package/lib/components/BadgeIndicator/index.js +33 -39
  398. package/lib/components/Breadcrumb/Breadcrumb.Skeleton.js +43 -55
  399. package/lib/components/Breadcrumb/Breadcrumb.js +43 -55
  400. package/lib/components/Breadcrumb/BreadcrumbItem.js +84 -87
  401. package/lib/components/Button/Button.Skeleton.js +53 -63
  402. package/lib/components/Button/Button.d.ts +1 -1
  403. package/lib/components/Button/Button.js +149 -244
  404. package/lib/components/Button/ButtonBase.js +85 -108
  405. package/lib/components/Button/index.js +13 -15
  406. package/lib/components/ButtonSet/ButtonSet.js +78 -102
  407. package/lib/components/ButtonSet/index.js +12 -9
  408. package/lib/components/ChatButton/ChatButton.Skeleton.js +31 -31
  409. package/lib/components/ChatButton/ChatButton.js +68 -83
  410. package/lib/components/Checkbox/Checkbox.Skeleton.js +30 -30
  411. package/lib/components/Checkbox/Checkbox.js +119 -198
  412. package/lib/components/Checkbox/index.js +13 -11
  413. package/lib/components/CheckboxGroup/CheckboxGroup.js +104 -152
  414. package/lib/components/ClassPrefix/index.js +24 -19
  415. package/lib/components/CodeSnippet/CodeSnippet.Skeleton.js +49 -47
  416. package/lib/components/CodeSnippet/CodeSnippet.js +215 -303
  417. package/lib/components/ComboBox/ComboBox.js +626 -974
  418. package/lib/components/ComboBox/index.js +12 -9
  419. package/lib/components/ComboButton/index.js +176 -210
  420. package/lib/components/ComposedModal/ComposedModal.js +315 -454
  421. package/lib/components/ComposedModal/ComposedModalPresence.js +49 -44
  422. package/lib/components/ComposedModal/ModalFooter.js +131 -209
  423. package/lib/components/ComposedModal/ModalHeader.js +75 -103
  424. package/lib/components/ComposedModal/useComposedModalState.js +22 -17
  425. package/lib/components/ContainedList/ContainedList.js +77 -106
  426. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +59 -71
  427. package/lib/components/ContainedList/ContainedListItem/index.js +12 -9
  428. package/lib/components/ContainedList/index.js +18 -15
  429. package/lib/components/ContentSwitcher/ContentSwitcher.js +112 -142
  430. package/lib/components/ContextMenu/useContextMenu.js +42 -40
  431. package/lib/components/Copy/Copy.js +101 -121
  432. package/lib/components/Copy/index.js +12 -9
  433. package/lib/components/CopyButton/CopyButton.js +85 -98
  434. package/lib/components/CopyButton/index.js +12 -9
  435. package/lib/components/DangerButton/DangerButton.js +19 -13
  436. package/lib/components/DataTable/DataTable.d.ts +11 -11
  437. package/lib/components/DataTable/DataTable.js +474 -655
  438. package/lib/components/DataTable/Table.js +115 -161
  439. package/lib/components/DataTable/TableActionList.js +15 -11
  440. package/lib/components/DataTable/TableBatchAction.js +28 -38
  441. package/lib/components/DataTable/TableBatchActions.js +82 -117
  442. package/lib/components/DataTable/TableBody.js +29 -23
  443. package/lib/components/DataTable/TableCell.js +35 -50
  444. package/lib/components/DataTable/TableContainer.js +79 -86
  445. package/lib/components/DataTable/TableContext.js +15 -8
  446. package/lib/components/DataTable/TableDecoratorRow.js +34 -40
  447. package/lib/components/DataTable/TableExpandHeader.js +57 -94
  448. package/lib/components/DataTable/TableExpandRow.js +86 -123
  449. package/lib/components/DataTable/TableExpandedRow.js +49 -55
  450. package/lib/components/DataTable/TableHead.js +8 -10
  451. package/lib/components/DataTable/TableHeader.js +142 -185
  452. package/lib/components/DataTable/TableRow.d.ts +1 -1
  453. package/lib/components/DataTable/TableRow.js +46 -80
  454. package/lib/components/DataTable/TableSelectAll.js +46 -74
  455. package/lib/components/DataTable/TableSelectRow.js +67 -102
  456. package/lib/components/DataTable/TableSlugRow.js +39 -47
  457. package/lib/components/DataTable/TableToolbar.js +37 -49
  458. package/lib/components/DataTable/TableToolbarAction.js +28 -24
  459. package/lib/components/DataTable/TableToolbarContent.js +15 -11
  460. package/lib/components/DataTable/TableToolbarMenu.js +39 -50
  461. package/lib/components/DataTable/TableToolbarSearch.js +101 -191
  462. package/lib/components/DataTable/state/getDerivedStateFromProps.js +38 -47
  463. package/lib/components/DataTable/state/sortStates.js +11 -10
  464. package/lib/components/DataTable/state/sorting.js +54 -76
  465. package/lib/components/DataTable/tools/cells.js +15 -8
  466. package/lib/components/DataTable/tools/denormalize.js +27 -22
  467. package/lib/components/DataTable/tools/filter.js +21 -23
  468. package/lib/components/DataTable/tools/normalize.js +57 -76
  469. package/lib/components/DataTable/tools/sorting.js +50 -75
  470. package/lib/components/DataTableSkeleton/DataTableSkeleton.js +70 -98
  471. package/lib/components/DatePicker/DatePicker.Skeleton.js +48 -56
  472. package/lib/components/DatePicker/DatePicker.d.ts +4 -2
  473. package/lib/components/DatePicker/DatePicker.js +491 -753
  474. package/lib/components/DatePicker/DatePickerLocales.js +75 -127
  475. package/lib/components/DatePicker/index.js +13 -11
  476. package/lib/components/DatePicker/plugins/appendToPlugin.js +31 -46
  477. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +127 -175
  478. package/lib/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
  479. package/lib/components/DatePicker/plugins/rangePlugin.js +42 -49
  480. package/lib/components/DatePicker/utils.d.ts +7 -0
  481. package/lib/components/DatePicker/utils.js +19 -0
  482. package/lib/components/DatePickerInput/DatePickerInput.js +183 -293
  483. package/lib/components/DatePickerInput/index.js +12 -9
  484. package/lib/components/Dialog/Dialog.js +307 -576
  485. package/lib/components/Dialog/index.js +21 -13
  486. package/lib/components/Dropdown/Dropdown.Skeleton.js +30 -43
  487. package/lib/components/Dropdown/Dropdown.js +348 -539
  488. package/lib/components/Dropdown/index.js +13 -11
  489. package/lib/components/ErrorBoundary/ErrorBoundary.js +39 -62
  490. package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +15 -11
  491. package/lib/components/ExpandableSearch/ExpandableSearch.js +63 -73
  492. package/lib/components/ExpandableSearch/index.js +12 -9
  493. package/lib/components/FeatureFlags/index.d.ts +11 -2
  494. package/lib/components/FeatureFlags/index.js +82 -79
  495. package/lib/components/FileUploader/FileUploader.Skeleton.js +39 -35
  496. package/lib/components/FileUploader/FileUploader.js +273 -347
  497. package/lib/components/FileUploader/FileUploaderButton.js +114 -164
  498. package/lib/components/FileUploader/FileUploaderDropContainer.js +148 -225
  499. package/lib/components/FileUploader/FileUploaderItem.js +142 -161
  500. package/lib/components/FileUploader/Filename.d.ts +1 -1
  501. package/lib/components/FileUploader/Filename.js +56 -76
  502. package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +30 -32
  503. package/lib/components/FluidComboBox/FluidComboBox.js +58 -109
  504. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +60 -57
  505. package/lib/components/FluidDatePicker/FluidDatePicker.js +50 -72
  506. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +25 -20
  507. package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +30 -32
  508. package/lib/components/FluidDropdown/FluidDropdown.js +59 -115
  509. package/lib/components/FluidForm/FluidForm.js +33 -35
  510. package/lib/components/FluidForm/FormContext.js +13 -8
  511. package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +30 -32
  512. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +71 -201
  513. package/lib/components/FluidNumberInput/FluidNumberInput.Skeleton.js +31 -34
  514. package/lib/components/FluidNumberInput/FluidNumberInput.js +67 -151
  515. package/lib/components/FluidSearch/FluidSearch.Skeleton.js +31 -34
  516. package/lib/components/FluidSearch/FluidSearch.js +45 -88
  517. package/lib/components/FluidSelect/FluidSelect.Skeleton.js +30 -32
  518. package/lib/components/FluidSelect/FluidSelect.js +44 -80
  519. package/lib/components/FluidSelect/index.js +13 -11
  520. package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +31 -34
  521. package/lib/components/FluidTextArea/FluidTextArea.js +52 -116
  522. package/lib/components/FluidTextInput/FluidPasswordInput.js +48 -103
  523. package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +31 -34
  524. package/lib/components/FluidTextInput/FluidTextInput.js +53 -108
  525. package/lib/components/FluidTextInput/index.js +14 -13
  526. package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +34 -37
  527. package/lib/components/FluidTimePicker/FluidTimePicker.js +72 -119
  528. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +31 -51
  529. package/lib/components/Form/Form.js +27 -29
  530. package/lib/components/FormGroup/FormGroup.js +49 -71
  531. package/lib/components/FormItem/FormItem.js +27 -29
  532. package/lib/components/FormLabel/FormLabel.js +32 -38
  533. package/lib/components/Grid/CSSGrid.d.ts +1 -1
  534. package/lib/components/Grid/CSSGrid.js +89 -129
  535. package/lib/components/Grid/Column.js +196 -328
  536. package/lib/components/Grid/ColumnHang.js +32 -38
  537. package/lib/components/Grid/FlexGrid.js +44 -62
  538. package/lib/components/Grid/Grid.js +32 -44
  539. package/lib/components/Grid/GridContext.js +39 -44
  540. package/lib/components/Grid/Row.js +35 -53
  541. package/lib/components/Heading/index.js +39 -53
  542. package/lib/components/Icon/Icon.Skeleton.js +25 -23
  543. package/lib/components/IconButton/index.js +121 -180
  544. package/lib/components/IconIndicator/index.d.ts +1 -1
  545. package/lib/components/IconIndicator/index.js +63 -63
  546. package/lib/components/IdPrefix/index.js +24 -19
  547. package/lib/components/InlineCheckbox/InlineCheckbox.js +72 -117
  548. package/lib/components/InlineCheckbox/index.js +12 -9
  549. package/lib/components/InlineLoading/InlineLoading.js +87 -104
  550. package/lib/components/InlineLoading/index.js +12 -9
  551. package/lib/components/Layer/LayerContext.js +14 -6
  552. package/lib/components/Layer/LayerLevel.js +20 -6
  553. package/lib/components/Layer/index.js +58 -68
  554. package/lib/components/Layout/index.js +81 -111
  555. package/lib/components/LayoutDirection/LayoutDirection.d.ts +1 -1
  556. package/lib/components/LayoutDirection/LayoutDirection.js +36 -40
  557. package/lib/components/LayoutDirection/LayoutDirectionContext.js +14 -8
  558. package/lib/components/LayoutDirection/useLayoutDirection.js +16 -9
  559. package/lib/components/Link/Link.js +67 -112
  560. package/lib/components/Link/index.js +12 -9
  561. package/lib/components/ListBox/ListBox.js +82 -130
  562. package/lib/components/ListBox/ListBoxField.js +33 -47
  563. package/lib/components/ListBox/ListBoxMenu.js +39 -46
  564. package/lib/components/ListBox/ListBoxMenuIcon.js +43 -44
  565. package/lib/components/ListBox/ListBoxMenuItem.js +71 -92
  566. package/lib/components/ListBox/ListBoxPropTypes.js +21 -9
  567. package/lib/components/ListBox/ListBoxSelection.js +75 -100
  568. package/lib/components/ListBox/index.js +17 -21
  569. package/lib/components/ListBox/next/ListBoxSelection.js +83 -121
  570. package/lib/components/ListBox/next/ListBoxTrigger.js +48 -52
  571. package/lib/components/ListItem/ListItem.js +29 -32
  572. package/lib/components/Loading/Loading.js +68 -77
  573. package/lib/components/Loading/index.js +12 -9
  574. package/lib/components/Menu/Menu.js +224 -365
  575. package/lib/components/Menu/MenuContext.d.ts +1 -1
  576. package/lib/components/Menu/MenuContext.js +42 -40
  577. package/lib/components/Menu/MenuItem.js +286 -415
  578. package/lib/components/MenuButton/index.js +138 -197
  579. package/lib/components/Modal/Modal.js +504 -665
  580. package/lib/components/Modal/ModalPresence.js +41 -39
  581. package/lib/components/Modal/index.js +13 -10
  582. package/lib/components/ModalWrapper/ModalWrapper.d.ts +2 -2
  583. package/lib/components/ModalWrapper/ModalWrapper.js +112 -134
  584. package/lib/components/MultiSelect/FilterableMultiSelect.js +611 -920
  585. package/lib/components/MultiSelect/MultiSelect.js +459 -718
  586. package/lib/components/MultiSelect/MultiSelectPropTypes.js +15 -32
  587. package/lib/components/MultiSelect/filter.js +14 -10
  588. package/lib/components/MultiSelect/tools/sorting.js +21 -35
  589. package/lib/components/Notification/Notification.js +514 -787
  590. package/lib/components/NumberInput/NumberFormatPropTypes.js +72 -33
  591. package/lib/components/NumberInput/NumberInput.Skeleton.js +33 -37
  592. package/lib/components/NumberInput/NumberInput.js +571 -950
  593. package/lib/components/OrderedList/OrderedList.js +35 -48
  594. package/lib/components/OverflowMenu/OverflowMenu.js +341 -454
  595. package/lib/components/OverflowMenu/index.js +27 -21
  596. package/lib/components/OverflowMenu/next/index.js +158 -188
  597. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +104 -164
  598. package/lib/components/OverflowMenuItem/index.js +12 -9
  599. package/lib/components/OverflowMenuV2/index.js +25 -15
  600. package/lib/components/PageHeader/PageHeader.js +301 -444
  601. package/lib/components/PageHeader/index.js +27 -19
  602. package/lib/components/Pagination/Pagination.Skeleton.js +38 -37
  603. package/lib/components/Pagination/Pagination.d.ts +1 -1
  604. package/lib/components/Pagination/Pagination.js +256 -360
  605. package/lib/components/Pagination/experimental/PageSelector.js +48 -58
  606. package/lib/components/Pagination/experimental/Pagination-story.d.ts +114 -0
  607. package/lib/components/Pagination/experimental/Pagination.js +148 -200
  608. package/lib/components/PaginationNav/PaginationNav.js +324 -430
  609. package/lib/components/Popover/index.js +323 -440
  610. package/lib/components/PrimaryButton/PrimaryButton.js +19 -13
  611. package/lib/components/ProgressBar/ProgressBar.js +121 -147
  612. package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +46 -43
  613. package/lib/components/ProgressIndicator/ProgressIndicator.js +150 -245
  614. package/lib/components/RadioButton/RadioButton.Skeleton.js +27 -27
  615. package/lib/components/RadioButton/RadioButton.js +105 -178
  616. package/lib/components/RadioButton/index.js +12 -9
  617. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +139 -211
  618. package/lib/components/RadioTile/RadioTile.js +108 -172
  619. package/lib/components/RadioTile/index.js +12 -9
  620. package/lib/components/Search/Search.Skeleton.js +32 -38
  621. package/lib/components/Search/Search.js +185 -281
  622. package/lib/components/Search/index.js +13 -11
  623. package/lib/components/Search/utils.js +11 -4
  624. package/lib/components/SecondaryButton/SecondaryButton.js +19 -13
  625. package/lib/components/Select/Select.Skeleton.js +31 -35
  626. package/lib/components/Select/Select.js +182 -261
  627. package/lib/components/Select/index.js +13 -11
  628. package/lib/components/SelectItem/SelectItem.js +37 -52
  629. package/lib/components/SelectItem/index.js +12 -9
  630. package/lib/components/SelectItemGroup/SelectItemGroup.js +31 -41
  631. package/lib/components/ShapeIndicator/index.d.ts +1 -1
  632. package/lib/components/ShapeIndicator/index.js +78 -83
  633. package/lib/components/SkeletonIcon/SkeletonIcon.js +25 -28
  634. package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +25 -28
  635. package/lib/components/SkeletonText/SkeletonText.js +71 -85
  636. package/lib/components/SkeletonText/index.js +12 -9
  637. package/lib/components/Slider/Slider.Skeleton.js +72 -95
  638. package/lib/components/Slider/Slider.js +868 -1319
  639. package/lib/components/Slider/SliderHandles.js +75 -68
  640. package/lib/components/Stack/HStack.js +22 -14
  641. package/lib/components/Stack/Stack.js +60 -82
  642. package/lib/components/Stack/VStack.js +22 -14
  643. package/lib/components/StructuredList/StructuredList.Skeleton.js +59 -52
  644. package/lib/components/StructuredList/StructuredList.js +182 -319
  645. package/lib/components/Switch/IconSwitch.js +103 -149
  646. package/lib/components/Switch/Switch.js +70 -103
  647. package/lib/components/TabContent/TabContent.js +32 -38
  648. package/lib/components/Tabs/Tabs.Skeleton.js +45 -41
  649. package/lib/components/Tabs/Tabs.js +738 -1151
  650. package/lib/components/Tabs/usePressable.js +98 -114
  651. package/lib/components/Tag/DismissibleTag.js +123 -160
  652. package/lib/components/Tag/OperationalTag.js +95 -115
  653. package/lib/components/Tag/SelectableTag.js +98 -133
  654. package/lib/components/Tag/Tag.Skeleton.js +30 -32
  655. package/lib/components/Tag/Tag.js +156 -204
  656. package/lib/components/Tag/isEllipsisActive.js +13 -9
  657. package/lib/components/Text/Text.js +69 -81
  658. package/lib/components/Text/TextDirection.js +39 -39
  659. package/lib/components/Text/TextDirectionContext.js +15 -10
  660. package/lib/components/Text/createTextComponent.js +29 -22
  661. package/lib/components/TextArea/TextArea.Skeleton.js +29 -34
  662. package/lib/components/TextArea/TextArea.js +319 -426
  663. package/lib/components/TextArea/index.js +13 -11
  664. package/lib/components/TextInput/ControlledPasswordInput.js +137 -202
  665. package/lib/components/TextInput/PasswordInput.js +200 -307
  666. package/lib/components/TextInput/TextInput.Skeleton.js +28 -33
  667. package/lib/components/TextInput/TextInput.js +223 -321
  668. package/lib/components/TextInput/index.js +13 -11
  669. package/lib/components/TextInput/util.js +21 -26
  670. package/lib/components/Theme/index.js +83 -97
  671. package/lib/components/Tile/Tile.d.ts +2 -2
  672. package/lib/components/Tile/Tile.js +398 -590
  673. package/lib/components/TileGroup/TileGroup.js +73 -113
  674. package/lib/components/TimePicker/TimePicker.d.ts +1 -1
  675. package/lib/components/TimePicker/TimePicker.js +152 -251
  676. package/lib/components/TimePickerSelect/TimePickerSelect.js +47 -62
  677. package/lib/components/Toggle/Toggle.Skeleton.js +28 -24
  678. package/lib/components/Toggle/Toggle.js +106 -176
  679. package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +50 -53
  680. package/lib/components/Toggletip/index.d.ts +2 -2
  681. package/lib/components/Toggletip/index.js +174 -258
  682. package/lib/components/Tooltip/DefinitionTooltip.js +102 -140
  683. package/lib/components/Tooltip/Tooltip.js +192 -265
  684. package/lib/components/TreeView/TreeContext.js +14 -7
  685. package/lib/components/TreeView/TreeNode.js +365 -504
  686. package/lib/components/TreeView/TreeView.js +169 -242
  687. package/lib/components/UIShell/Content.js +27 -34
  688. package/lib/components/UIShell/Header.js +29 -33
  689. package/lib/components/UIShell/HeaderContainer.js +34 -44
  690. package/lib/components/UIShell/HeaderGlobalAction.js +69 -94
  691. package/lib/components/UIShell/HeaderGlobalBar.js +17 -14
  692. package/lib/components/UIShell/HeaderMenu.js +146 -221
  693. package/lib/components/UIShell/HeaderMenuButton.js +47 -70
  694. package/lib/components/UIShell/HeaderMenuItem.js +53 -80
  695. package/lib/components/UIShell/HeaderName.js +36 -48
  696. package/lib/components/UIShell/HeaderNavigation.js +36 -41
  697. package/lib/components/UIShell/HeaderPanel.js +78 -101
  698. package/lib/components/UIShell/HeaderSideNavItems.js +31 -37
  699. package/lib/components/UIShell/Link.js +32 -54
  700. package/lib/components/UIShell/SideNav.js +136 -245
  701. package/lib/components/UIShell/SideNavContext.js +23 -17
  702. package/lib/components/UIShell/SideNavDetails.js +33 -38
  703. package/lib/components/UIShell/SideNavDivider.js +25 -25
  704. package/lib/components/UIShell/SideNavFooter.js +47 -56
  705. package/lib/components/UIShell/SideNavHeader.js +30 -39
  706. package/lib/components/UIShell/SideNavIcon.js +32 -37
  707. package/lib/components/UIShell/SideNavItem.js +32 -37
  708. package/lib/components/UIShell/SideNavItems.js +35 -44
  709. package/lib/components/UIShell/SideNavLink.js +56 -83
  710. package/lib/components/UIShell/SideNavLinkText.js +28 -29
  711. package/lib/components/UIShell/SideNavMenu.js +106 -148
  712. package/lib/components/UIShell/SideNavMenuItem.js +44 -56
  713. package/lib/components/UIShell/SideNavSwitcher.js +63 -72
  714. package/lib/components/UIShell/SkipToContent.js +32 -40
  715. package/lib/components/UIShell/Switcher.js +73 -103
  716. package/lib/components/UIShell/SwitcherDivider.js +26 -28
  717. package/lib/components/UIShell/SwitcherItem.js +78 -118
  718. package/lib/components/UnorderedList/UnorderedList.js +32 -41
  719. package/lib/feature-flags.js +21 -13
  720. package/lib/index.js +622 -602
  721. package/lib/internal/FloatingMenu.js +249 -296
  722. package/lib/internal/OptimizedResize.js +35 -47
  723. package/lib/internal/Selection.js +102 -134
  724. package/lib/internal/clamp.js +12 -5
  725. package/lib/internal/defaultItemToString.js +15 -10
  726. package/lib/internal/deprecateFieldOnObject.js +23 -16
  727. package/lib/internal/environment.js +15 -8
  728. package/lib/internal/getAnnouncement.js +16 -14
  729. package/lib/internal/keyboard/keys.js +48 -49
  730. package/lib/internal/keyboard/match.js +25 -43
  731. package/lib/internal/keyboard/navigation.js +22 -29
  732. package/lib/internal/noopFn.js +10 -3
  733. package/lib/internal/useAttachedMenu.js +44 -53
  734. package/lib/internal/useControllableState.js +44 -50
  735. package/lib/internal/useDelayedState.js +31 -37
  736. package/lib/internal/useEvent.js +40 -37
  737. package/lib/internal/useId.js +54 -91
  738. package/lib/internal/useIdPrefix.js +15 -7
  739. package/lib/internal/useIsomorphicEffect.js +13 -8
  740. package/lib/internal/useMatchMedia.js +30 -23
  741. package/lib/internal/useMergedRefs.js +27 -24
  742. package/lib/internal/useNoInteractiveChildren.js +73 -101
  743. package/lib/internal/useNormalizedInputProps.js +55 -53
  744. package/lib/internal/useOutsideClick.js +22 -26
  745. package/lib/internal/useOverflowItems.js +90 -94
  746. package/lib/internal/usePrefix.js +15 -7
  747. package/lib/internal/usePresence.js +52 -56
  748. package/lib/internal/usePresenceContext.js +36 -37
  749. package/lib/internal/usePreviousValue.js +27 -20
  750. package/lib/internal/useResizeObserver.js +58 -68
  751. package/lib/internal/useSavedCallback.js +25 -19
  752. package/lib/internal/utils.js +18 -11
  753. package/lib/internal/warning.js +24 -23
  754. package/lib/internal/wrapFocus.js +78 -100
  755. package/lib/prop-types/AriaPropTypes.js +17 -9
  756. package/lib/prop-types/deprecate.js +30 -29
  757. package/lib/prop-types/deprecateComponent.js +17 -10
  758. package/lib/prop-types/deprecateValuesWithin.js +18 -23
  759. package/lib/prop-types/isRequiredOneOf.js +21 -25
  760. package/lib/prop-types/requiredIfGivenPropIsTruthy.js +14 -15
  761. package/lib/tools/events.js +17 -22
  762. package/lib/tools/mapPopoverAlign.js +19 -19
  763. package/lib/tools/mergeRefs.js +14 -18
  764. package/lib/tools/setupGetInstanceId.js +16 -9
  765. package/lib/tools/toggleClass.js +17 -10
  766. package/lib/tools/wrapComponent.js +38 -43
  767. package/package.json +10 -16
  768. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -40
  769. package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
  770. package/es/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -55
  771. package/es/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -23
  772. package/es/node_modules/es-toolkit/dist/function/debounce.js +0 -70
  773. package/lib/_virtual/_rollupPluginBabelHelpers.js +0 -45
  774. package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
  775. package/lib/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -57
  776. package/lib/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -25
  777. package/lib/node_modules/es-toolkit/dist/function/debounce.js +0 -72
@@ -1,775 +1,511 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2026
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import PropTypes from 'prop-types';
10
- import React, { forwardRef, useContext, useState, useCallback, useRef, useEffect, useImperativeHandle } from 'react';
11
- import cx from 'classnames';
12
- import flatpickr from 'flatpickr';
13
- import l10n from 'flatpickr/dist/l10n/index';
14
- import DatePickerInput from '../DatePickerInput/DatePickerInput.js';
15
- import { appendToPlugin } from './plugins/appendToPlugin.js';
16
- import carbonFlatpickrFixEventsPlugin from './plugins/fixEventsPlugin.js';
17
- import { rangePlugin } from './plugins/rangePlugin.js';
18
- import { deprecate } from '../../prop-types/deprecate.js';
19
- import { Escape, Tab, Enter } from '../../internal/keyboard/keys.js';
20
- import { match } from '../../internal/keyboard/match.js';
21
- import { isComponentElement } from '../../internal/utils.js';
22
- import { usePrefix } from '../../internal/usePrefix.js';
23
- import { useSavedCallback } from '../../internal/useSavedCallback.js';
24
- import '../FluidForm/FluidForm.js';
25
- import { FormContext } from '../FluidForm/FormContext.js';
26
- import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
27
- import { datePartsOrder } from '@carbon/utilities';
28
- import { SUPPORTED_LOCALES } from './DatePickerLocales.js';
8
+ import { usePrefix } from "../../internal/usePrefix.js";
9
+ import { Enter, Escape, Tab } from "../../internal/keyboard/keys.js";
10
+ import { match } from "../../internal/keyboard/match.js";
11
+ import { deprecate } from "../../prop-types/deprecate.js";
12
+ import { isComponentElement } from "../../internal/utils.js";
13
+ import { FormContext } from "../FluidForm/FormContext.js";
14
+ import DatePickerInput_default from "../DatePickerInput/index.js";
15
+ import { appendToPlugin } from "./plugins/appendToPlugin.js";
16
+ import fixEventsPlugin_default from "./plugins/fixEventsPlugin.js";
17
+ import { isEmptyDateValue } from "./utils.js";
18
+ import { rangePlugin } from "./plugins/rangePlugin.js";
19
+ import { useSavedCallback } from "../../internal/useSavedCallback.js";
20
+ import { SUPPORTED_LOCALES } from "./DatePickerLocales.js";
21
+ import classNames from "classnames";
22
+ import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from "react";
23
+ import PropTypes from "prop-types";
24
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
25
+ import { WarningAltFilled, WarningFilled } from "@carbon/icons-react";
26
+ import flatpickr from "flatpickr";
27
+ import l10n from "flatpickr/dist/l10n/index";
28
+ import { datePartsOrder } from "@carbon/utilities";
29
29
 
30
- // Weekdays shorthand for English locale
31
- // Ensure localization exists before trying to access it
30
+ //#region src/components/DatePicker/DatePicker.tsx
31
+ /**
32
+ * Copyright IBM Corp. 2016, 2026
33
+ *
34
+ * This source code is licensed under the Apache-2.0 license found in the
35
+ * LICENSE file in the root directory of this source tree.
36
+ */
32
37
  function initializeWeekdayShorthand() {
33
- if (l10n?.en?.weekdays?.shorthand) {
34
- l10n.en.weekdays.shorthand.forEach((_day, index) => {
35
- const currentDay = l10n.en.weekdays.shorthand;
36
- if (currentDay[index] === 'Thu' || currentDay[index] === 'Th') {
37
- currentDay[index] = 'Th';
38
- } else {
39
- currentDay[index] = currentDay[index].charAt(0);
40
- }
41
- });
42
- }
38
+ if (l10n?.en?.weekdays?.shorthand) l10n.en.weekdays.shorthand.forEach((_day, index) => {
39
+ const currentDay = l10n.en.weekdays.shorthand;
40
+ if (currentDay[index] === "Thu" || currentDay[index] === "Th") currentDay[index] = "Th";
41
+ else currentDay[index] = currentDay[index].charAt(0);
42
+ });
43
43
  }
44
44
  const forEach = Array.prototype.forEach;
45
-
46
45
  /**
47
- * @param {number} monthNumber The month number.
48
- * @param {boolean} shorthand `true` to use shorthand month.
49
- * @param {Locale} locale The Flatpickr locale data.
50
- * @returns {string} The month string.
51
- */
52
- const monthToStr = (monthNumber, shorthand, locale) => locale.months[shorthand ? 'shorthand' : 'longhand'][monthNumber];
53
-
46
+ * @param {number} monthNumber The month number.
47
+ * @param {boolean} shorthand `true` to use shorthand month.
48
+ * @param {Locale} locale The Flatpickr locale data.
49
+ * @returns {string} The month string.
50
+ */
51
+ const monthToStr = (monthNumber, shorthand, locale) => locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
54
52
  /**
55
- * @param {object} config Plugin configuration.
56
- * @param {boolean} [config.shorthand] `true` to use shorthand month.
57
- * @param {string} config.selectorFlatpickrMonthYearContainer The CSS selector for the container of month/year selection UI.
58
- * @param {string} config.selectorFlatpickrYearContainer The CSS selector for the container of year selection UI.
59
- * @param {string} config.selectorFlatpickrCurrentMonth The CSS selector for the text-based month selection UI.
60
- * @param {string} config.classFlatpickrCurrentMonth The CSS class for the text-based month selection UI.
61
- * @param {string} config.locale The locale code.
62
- * @returns {Plugin} A Flatpickr plugin to use text instead of `<select>` for month picker.
63
- */
64
- const carbonFlatpickrMonthSelectPlugin = config => fp => {
65
- const setupElements = () => {
66
- if (!fp.monthElements) {
67
- return;
68
- }
69
- fp.monthElements.forEach(elem => {
70
- if (!elem.parentNode) {
71
- return;
72
- }
73
- elem.parentNode.removeChild(elem);
74
- });
75
- fp.monthElements.splice(0, fp.monthElements.length, ...fp.monthElements.map(() => {
76
- const monthElement = fp._createElement('span', config.classFlatpickrCurrentMonth);
77
- monthElement.textContent = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
78
-
79
- // Depending on the locale, toggle the order of the month and year
80
- if (datePartsOrder.isMonthFirst(config.locale)) {
81
- fp.yearElements[0].closest(config.selectorFlatpickrMonthYearContainer).insertBefore(monthElement, fp.yearElements[0].closest(config.selectorFlatpickrYearContainer));
82
- } else {
83
- fp.yearElements[0].closest(config.selectorFlatpickrMonthYearContainer).insertAdjacentElement('afterend', monthElement);
84
- }
85
- return monthElement;
86
- }));
87
- };
88
- const updateCurrentMonth = () => {
89
- if (fp.monthElements) {
90
- const monthStr = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
91
- fp.yearElements.forEach(elem => {
92
- const currentMonthContainer = elem.closest(config.selectorFlatpickrMonthYearContainer);
93
- Array.prototype.forEach.call(currentMonthContainer.querySelectorAll('.cur-month'), monthElement => {
94
- monthElement.textContent = monthStr;
95
- });
96
- });
97
- }
98
- };
99
- const register = () => {
100
- fp.loadedPlugins.push('carbonFlatpickrMonthSelectPlugin');
101
- };
102
- return {
103
- onMonthChange: updateCurrentMonth,
104
- onValueUpdate: updateCurrentMonth,
105
- onOpen: updateCurrentMonth,
106
- onReady: [setupElements, updateCurrentMonth, register]
107
- };
53
+ * @param {object} config Plugin configuration.
54
+ * @param {boolean} [config.shorthand] `true` to use shorthand month.
55
+ * @param {string} config.selectorFlatpickrMonthYearContainer The CSS selector for the container of month/year selection UI.
56
+ * @param {string} config.selectorFlatpickrYearContainer The CSS selector for the container of year selection UI.
57
+ * @param {string} config.selectorFlatpickrCurrentMonth The CSS selector for the text-based month selection UI.
58
+ * @param {string} config.classFlatpickrCurrentMonth The CSS class for the text-based month selection UI.
59
+ * @param {string} config.locale The locale code.
60
+ * @returns {Plugin} A Flatpickr plugin to use text instead of `<select>` for month picker.
61
+ */
62
+ const carbonFlatpickrMonthSelectPlugin = (config) => (fp) => {
63
+ const setupElements = () => {
64
+ if (!fp.monthElements) return;
65
+ fp.monthElements.forEach((elem) => {
66
+ if (!elem.parentNode) return;
67
+ elem.parentNode.removeChild(elem);
68
+ });
69
+ fp.monthElements.splice(0, fp.monthElements.length, ...fp.monthElements.map(() => {
70
+ const monthElement = fp._createElement("span", config.classFlatpickrCurrentMonth);
71
+ monthElement.textContent = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
72
+ if (datePartsOrder.isMonthFirst(config.locale)) fp.yearElements[0].closest(config.selectorFlatpickrMonthYearContainer).insertBefore(monthElement, fp.yearElements[0].closest(config.selectorFlatpickrYearContainer));
73
+ else fp.yearElements[0].closest(config.selectorFlatpickrMonthYearContainer).insertAdjacentElement("afterend", monthElement);
74
+ return monthElement;
75
+ }));
76
+ };
77
+ const updateCurrentMonth = () => {
78
+ if (fp.monthElements) {
79
+ const monthStr = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
80
+ fp.yearElements.forEach((elem) => {
81
+ const currentMonthContainer = elem.closest(config.selectorFlatpickrMonthYearContainer);
82
+ Array.prototype.forEach.call(currentMonthContainer.querySelectorAll(".cur-month"), (monthElement) => {
83
+ monthElement.textContent = monthStr;
84
+ });
85
+ });
86
+ }
87
+ };
88
+ const register = () => {
89
+ fp.loadedPlugins.push("carbonFlatpickrMonthSelectPlugin");
90
+ };
91
+ return {
92
+ onMonthChange: updateCurrentMonth,
93
+ onValueUpdate: updateCurrentMonth,
94
+ onOpen: updateCurrentMonth,
95
+ onReady: [
96
+ setupElements,
97
+ updateCurrentMonth,
98
+ register
99
+ ]
100
+ };
108
101
  };
109
-
110
102
  /**
111
- * Determine if every child in a list of children has no label specified
112
- * @param {Array<ReactElement>} children
113
- * @returns {boolean}
114
- */
103
+ * Determine if every child in a list of children has no label specified
104
+ * @param {Array<ReactElement>} children
105
+ * @returns {boolean}
106
+ */
115
107
  function isLabelTextEmpty(children) {
116
- return children.every(child => !child.props.labelText);
108
+ return children.every((child) => !child.props.labelText);
117
109
  }
118
110
  function updateClassNames(calendar, prefix) {
119
- const calendarContainer = calendar.calendarContainer;
120
- const daysContainer = calendar.days;
121
- if (calendarContainer && daysContainer) {
122
- // calendarContainer and daysContainer are undefined if flatpickr detects a mobile device
123
- calendarContainer.classList.add(`${prefix}--date-picker__calendar`);
124
- calendarContainer.querySelector('.flatpickr-month').classList.add(`${prefix}--date-picker__month`);
125
- calendarContainer.querySelector('.flatpickr-weekdays').classList.add(`${prefix}--date-picker__weekdays`);
126
- calendarContainer.querySelector('.flatpickr-days').classList.add(`${prefix}--date-picker__days`);
127
- forEach.call(calendarContainer.querySelectorAll('.flatpickr-weekday'), item => {
128
- const currentItem = item;
129
- currentItem.innerHTML = currentItem.innerHTML.replace(/\s+/g, '');
130
- currentItem.classList.add(`${prefix}--date-picker__weekday`);
131
- });
132
- forEach.call(daysContainer.querySelectorAll('.flatpickr-day'), item => {
133
- item.classList.add(`${prefix}--date-picker__day`);
134
- item.setAttribute('role', 'button');
135
- if (item.classList.contains('today') && calendar.selectedDates.length > 0) {
136
- item.classList.add('no-border');
137
- } else if (item.classList.contains('today') && calendar.selectedDates.length === 0) {
138
- item.classList.remove('no-border');
139
- }
140
- });
141
- }
111
+ const calendarContainer = calendar.calendarContainer;
112
+ const daysContainer = calendar.days;
113
+ if (calendarContainer && daysContainer) {
114
+ calendarContainer.classList.add(`${prefix}--date-picker__calendar`);
115
+ calendarContainer.querySelector(".flatpickr-month").classList.add(`${prefix}--date-picker__month`);
116
+ calendarContainer.querySelector(".flatpickr-weekdays").classList.add(`${prefix}--date-picker__weekdays`);
117
+ calendarContainer.querySelector(".flatpickr-days").classList.add(`${prefix}--date-picker__days`);
118
+ forEach.call(calendarContainer.querySelectorAll(".flatpickr-weekday"), (item) => {
119
+ const currentItem = item;
120
+ currentItem.innerHTML = currentItem.innerHTML.replace(/\s+/g, "");
121
+ currentItem.classList.add(`${prefix}--date-picker__weekday`);
122
+ });
123
+ forEach.call(daysContainer.querySelectorAll(".flatpickr-day"), (item) => {
124
+ item.classList.add(`${prefix}--date-picker__day`);
125
+ item.setAttribute("role", "button");
126
+ if (item.classList.contains("today") && calendar.selectedDates.length > 0) item.classList.add("no-border");
127
+ else if (item.classList.contains("today") && calendar.selectedDates.length === 0) item.classList.remove("no-border");
128
+ });
129
+ }
142
130
  }
143
- // eslint-disable-next-line react/display-name
144
- const DatePicker = /*#__PURE__*/forwardRef((props, ref) => {
145
- const {
146
- allowInput,
147
- appendTo,
148
- children,
149
- className,
150
- closeOnSelect = true,
151
- dateFormat = 'm/d/Y',
152
- datePickerType,
153
- disable,
154
- enable,
155
- inline,
156
- invalid,
157
- invalidText,
158
- warn,
159
- warnText,
160
- light = false,
161
- locale = 'en',
162
- maxDate,
163
- minDate,
164
- onChange,
165
- onClose,
166
- onOpen,
167
- readOnly = false,
168
- short = false,
169
- value,
170
- parseDate: parseDateProp,
171
- nextMonthAriaLabel = 'Next month',
172
- prevMonthAriaLabel = 'Previous month',
173
- ...rest
174
- } = props;
175
- const prefix = usePrefix();
176
- const {
177
- isFluid
178
- } = useContext(FormContext);
179
- const [hasInput, setHasInput] = useState(false);
180
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
181
- const startInputField = useCallback(node => {
182
- if (node !== null) {
183
- startInputField.current = node;
184
- setHasInput(true);
185
- }
186
- }, []);
187
- const lastStartValue = useRef('');
188
- const calendarRef = useRef(null);
189
- const [calendarCloseEvent, setCalendarCloseEvent] = useState(null);
190
-
191
- // fix datepicker deleting the selectedDate when the calendar closes
192
- const handleCalendarClose = useCallback((selectedDates, dateStr, instance) => {
193
- if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
194
- startInputField.current.value = lastStartValue.current;
195
- calendarRef.current?.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
196
- }
197
- if (onClose) {
198
- onClose(selectedDates, dateStr, instance);
199
- }
200
- },
201
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
202
- [onClose]);
203
- const onCalendarClose = (selectedDates, dateStr, instance, e) => {
204
- if (e && e.type === 'clickOutside') {
205
- return;
206
- }
207
- setCalendarCloseEvent({
208
- selectedDates,
209
- dateStr,
210
- instance
211
- });
212
- };
213
- useEffect(() => {
214
- if (calendarCloseEvent) {
215
- const {
216
- selectedDates,
217
- dateStr,
218
- instance
219
- } = calendarCloseEvent;
220
- handleCalendarClose(selectedDates, dateStr, instance);
221
- setCalendarCloseEvent(null);
222
- }
223
- }, [calendarCloseEvent, handleCalendarClose]);
224
- const endInputField = useRef(null);
225
- const lastFocusedField = useRef(null);
226
- const savedOnChange = useSavedCallback(onChange);
227
- const savedOnOpen = useSavedCallback(onOpen);
228
- const effectiveWarn = warn && !invalid;
229
- const wrapperRef = useRef(null);
230
- const datePickerClasses = cx(`${prefix}--date-picker`, {
231
- [`${prefix}--date-picker--short`]: short,
232
- [`${prefix}--date-picker--light`]: light,
233
- [`${prefix}--date-picker--simple`]: datePickerType === 'simple',
234
- [`${prefix}--date-picker--single`]: datePickerType === 'single',
235
- [`${prefix}--date-picker--range`]: datePickerType === 'range',
236
- [`${prefix}--date-picker--nolabel`]: datePickerType === 'range' && isLabelTextEmpty(children)
237
- });
238
- const wrapperClasses = cx(`${prefix}--form-item`, {
239
- [String(className)]: className
240
- });
241
-
242
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
243
- const childrenWithProps = React.Children.toArray(children).map(
244
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
245
- (child, index) => {
246
- if (index === 0 && isComponentElement(child, DatePickerInput)) {
247
- return /*#__PURE__*/React.cloneElement(child, {
248
- datePickerType,
249
- ref: startInputField,
250
- readOnly,
251
- invalid,
252
- warn: effectiveWarn
253
- });
254
- }
255
- if (index === 1 && isComponentElement(child, DatePickerInput)) {
256
- return /*#__PURE__*/React.cloneElement(child, {
257
- datePickerType,
258
- ref: endInputField,
259
- readOnly,
260
- invalid,
261
- warn: effectiveWarn
262
- });
263
- }
264
- if (index === 0) {
265
- return /*#__PURE__*/React.cloneElement(child, {
266
- ref: startInputField,
267
- readOnly,
268
- invalid,
269
- warn: effectiveWarn
270
- });
271
- }
272
- if (index === 1) {
273
- return /*#__PURE__*/React.cloneElement(child, {
274
- ref: endInputField,
275
- readOnly,
276
- invalid,
277
- warn: effectiveWarn
278
- });
279
- }
280
- });
281
- useEffect(() => {
282
- initializeWeekdayShorthand();
283
- }, []);
284
- useEffect(() => {
285
- if (datePickerType !== 'single' && datePickerType !== 'range') {
286
- return;
287
- }
288
- if (!startInputField.current) {
289
- return;
290
- }
291
- const onHook = (_electedDates, _dateStr, instance) => {
292
- updateClassNames(instance, prefix);
293
- if (startInputField?.current) {
294
- startInputField.current.readOnly = readOnly;
295
- }
296
- if (endInputField?.current) {
297
- endInputField.current.readOnly = readOnly;
298
- }
299
- };
300
-
301
- // Logic to determine if `enable` or `disable` will be passed down. If neither
302
- // is provided, we return the default empty disabled array, allowing all dates.
303
- const enableOrDisable = enable ? 'enable' : 'disable';
304
- let enableOrDisableArr;
305
- if (!enable && !disable) {
306
- enableOrDisableArr = [];
307
- } else if (enable) {
308
- enableOrDisableArr = enable;
309
- } else {
310
- enableOrDisableArr = disable;
311
- }
312
- let localeData;
313
- if (typeof locale === 'object') {
314
- const location = locale.locale ? locale.locale : 'en';
315
- localeData = {
316
- ...l10n[location],
317
- ...locale
318
- };
319
- } else {
320
- localeData = l10n[locale];
321
- }
322
-
323
- /**
324
- * parseDate is called before the date is actually set.
325
- * It attempts to parse the input value and return a valid date string.
326
- * Flatpickr's default parser results in odd dates when given invalid
327
- * values, so instead here we normalize the month/day to `1` if given
328
- * a value outside the acceptable range.
329
- */
330
- let parseDate;
331
- if (!parseDateProp && dateFormat === 'm/d/Y') {
332
- // This function only supports the default dateFormat.
333
- parseDate = date => {
334
- // Month must be 1-12. If outside these bounds, `1` should be used.
335
- const month = date.split('/')[0] <= 12 && date.split('/')[0] > 0 ? parseInt(date.split('/')[0]) : 1;
336
- const year = parseInt(date.split('/')[2]);
337
- if (month && year) {
338
- // The month and year must be provided to be able to determine
339
- // the number of days in the month.
340
- const daysInMonth = new Date(year, month, 0).getDate();
341
- // If the day does not fall within the days in the month, `1` should be used.
342
- const day = date.split('/')[1] <= daysInMonth && date.split('/')[1] > 0 ? parseInt(date.split('/')[1]) : 1;
343
- return new Date(`${year}/${month}/${day}`);
344
- } else {
345
- // With no month and year, we cannot calculate anything.
346
- // Returning false gives flatpickr an invalid date, which will clear the input
347
- return false;
348
- }
349
- };
350
- } else if (parseDateProp) {
351
- parseDate = parseDateProp;
352
- }
353
-
354
- // Accessible arrow icons (localized manually)
355
- // Flatpickr does not currently support localization of next/previous month
356
- // labels, so we inject translated aria-labels based on the provided locale.
357
- const rightArrowHTML = `<svg aria-label="${nextMonthAriaLabel}" role="img" width="16px" height="16px" viewBox="0 0 16 16">
131
+ const DatePicker = forwardRef((props, ref) => {
132
+ const { allowInput, appendTo, children, className, closeOnSelect = true, dateFormat = "m/d/Y", datePickerType, disable, enable, inline, invalid, invalidText, warn, warnText, light = false, locale = "en", maxDate, minDate, onChange, onClose, onOpen, readOnly = false, short = false, value, parseDate: parseDateProp, nextMonthAriaLabel = "Next month", prevMonthAriaLabel = "Previous month", ...rest } = props;
133
+ const prefix = usePrefix();
134
+ const { isFluid } = useContext(FormContext);
135
+ const [hasInput, setHasInput] = useState(false);
136
+ const startInputField = useCallback((node) => {
137
+ if (node !== null) {
138
+ startInputField.current = node;
139
+ setHasInput(true);
140
+ }
141
+ }, []);
142
+ const lastStartValue = useRef("");
143
+ const calendarRef = useRef(null);
144
+ const [calendarCloseEvent, setCalendarCloseEvent] = useState(null);
145
+ const handleCalendarClose = useCallback((selectedDates, dateStr, instance) => {
146
+ if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
147
+ startInputField.current.value = lastStartValue.current;
148
+ calendarRef.current?.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
149
+ }
150
+ if (onClose) onClose(selectedDates, dateStr, instance);
151
+ }, [onClose]);
152
+ const onCalendarClose = (selectedDates, dateStr, instance, e) => {
153
+ if (e && e.type === "clickOutside") return;
154
+ setCalendarCloseEvent({
155
+ selectedDates,
156
+ dateStr,
157
+ instance
158
+ });
159
+ };
160
+ useEffect(() => {
161
+ if (calendarCloseEvent) {
162
+ const { selectedDates, dateStr, instance } = calendarCloseEvent;
163
+ handleCalendarClose(selectedDates, dateStr, instance);
164
+ setCalendarCloseEvent(null);
165
+ }
166
+ }, [calendarCloseEvent, handleCalendarClose]);
167
+ const endInputField = useRef(null);
168
+ const lastFocusedField = useRef(null);
169
+ const savedOnChange = useSavedCallback(onChange);
170
+ const savedOnOpen = useSavedCallback(onOpen);
171
+ const effectiveWarn = warn && !invalid;
172
+ const wrapperRef = useRef(null);
173
+ const datePickerClasses = classNames(`${prefix}--date-picker`, {
174
+ [`${prefix}--date-picker--short`]: short,
175
+ [`${prefix}--date-picker--light`]: light,
176
+ [`${prefix}--date-picker--simple`]: datePickerType === "simple",
177
+ [`${prefix}--date-picker--single`]: datePickerType === "single",
178
+ [`${prefix}--date-picker--range`]: datePickerType === "range",
179
+ [`${prefix}--date-picker--nolabel`]: datePickerType === "range" && isLabelTextEmpty(children)
180
+ });
181
+ const wrapperClasses = classNames(`${prefix}--form-item`, { [String(className)]: className });
182
+ const childrenWithProps = React.Children.toArray(children).map((child, index) => {
183
+ if (index === 0 && isComponentElement(child, DatePickerInput_default)) return React.cloneElement(child, {
184
+ datePickerType,
185
+ ref: startInputField,
186
+ readOnly,
187
+ invalid,
188
+ warn: effectiveWarn
189
+ });
190
+ if (index === 1 && isComponentElement(child, DatePickerInput_default)) return React.cloneElement(child, {
191
+ datePickerType,
192
+ ref: endInputField,
193
+ readOnly,
194
+ invalid,
195
+ warn: effectiveWarn
196
+ });
197
+ if (index === 0) return React.cloneElement(child, {
198
+ ref: startInputField,
199
+ readOnly,
200
+ invalid,
201
+ warn: effectiveWarn
202
+ });
203
+ if (index === 1) return React.cloneElement(child, {
204
+ ref: endInputField,
205
+ readOnly,
206
+ invalid,
207
+ warn: effectiveWarn
208
+ });
209
+ });
210
+ useEffect(() => {
211
+ initializeWeekdayShorthand();
212
+ }, []);
213
+ useEffect(() => {
214
+ if (datePickerType !== "single" && datePickerType !== "range") return;
215
+ if (!startInputField.current) return;
216
+ const onHook = (_electedDates, _dateStr, instance) => {
217
+ updateClassNames(instance, prefix);
218
+ if (startInputField?.current) startInputField.current.readOnly = readOnly;
219
+ if (endInputField?.current) endInputField.current.readOnly = readOnly;
220
+ };
221
+ const enableOrDisable = enable ? "enable" : "disable";
222
+ let enableOrDisableArr;
223
+ if (!enable && !disable) enableOrDisableArr = [];
224
+ else if (enable) enableOrDisableArr = enable;
225
+ else enableOrDisableArr = disable;
226
+ let localeData;
227
+ if (typeof locale === "object") localeData = {
228
+ ...l10n[locale.locale ? locale.locale : "en"],
229
+ ...locale
230
+ };
231
+ else localeData = l10n[locale];
232
+ /**
233
+ * parseDate is called before the date is actually set.
234
+ * It attempts to parse the input value and return a valid date string.
235
+ * Flatpickr's default parser results in odd dates when given invalid
236
+ * values, so instead here we normalize the month/day to `1` if given
237
+ * a value outside the acceptable range.
238
+ */
239
+ let parseDate;
240
+ if (!parseDateProp && dateFormat === "m/d/Y") parseDate = (date) => {
241
+ const month = date.split("/")[0] <= 12 && date.split("/")[0] > 0 ? parseInt(date.split("/")[0]) : 1;
242
+ const year = parseInt(date.split("/")[2]);
243
+ if (month && year) {
244
+ const daysInMonth = new Date(year, month, 0).getDate();
245
+ const day = date.split("/")[1] <= daysInMonth && date.split("/")[1] > 0 ? parseInt(date.split("/")[1]) : 1;
246
+ return /* @__PURE__ */ new Date(`${year}/${month}/${day}`);
247
+ } else return false;
248
+ };
249
+ else if (parseDateProp) parseDate = parseDateProp;
250
+ const rightArrowHTML = `<svg aria-label="${nextMonthAriaLabel}" role="img" width="16px" height="16px" viewBox="0 0 16 16">
358
251
  <polygon points="11,8 6,13 5.3,12.3 9.6,8 5.3,3.7 6,3 "/>
359
252
  </svg>`;
360
- const leftArrowHTML = `<svg aria-label="${prevMonthAriaLabel}" role="img" width="16px" height="16px" viewBox="0 0 16 16">
253
+ const leftArrowHTML = `<svg aria-label="${prevMonthAriaLabel}" role="img" width="16px" height="16px" viewBox="0 0 16 16">
361
254
  <polygon points="5,8 10,3 10.7,3.7 6.4,8 10.7,12.3 10,13 "/>
362
255
  </svg>`;
363
- const {
364
- current: start
365
- } = startInputField;
366
- const {
367
- current: end
368
- } = endInputField;
369
- const flatpickerConfig = {
370
- inline: inline ?? false,
371
- onClose: onCalendarClose,
372
- disableMobile: true,
373
- defaultDate: value,
374
- closeOnSelect: closeOnSelect,
375
- mode: datePickerType,
376
- allowInput: allowInput ?? true,
377
- dateFormat: dateFormat,
378
- locale: localeData,
379
- [enableOrDisable]: enableOrDisableArr,
380
- minDate: minDate,
381
- maxDate: maxDate,
382
- parseDate: parseDate,
383
- plugins: [datePickerType === 'range' ? rangePlugin({
384
- input: endInputField.current ?? undefined
385
- }) : () => {}, appendTo ? appendToPlugin({
386
- appendTo
387
- }) : () => {}, carbonFlatpickrMonthSelectPlugin({
388
- selectorFlatpickrMonthYearContainer: '.flatpickr-current-month',
389
- selectorFlatpickrYearContainer: '.numInputWrapper',
390
- classFlatpickrCurrentMonth: 'cur-month',
391
- locale: locale
392
- }), carbonFlatpickrFixEventsPlugin({
393
- inputFrom: startInputField.current,
394
- inputTo: endInputField.current,
395
- lastStartValue,
396
- container: wrapperRef.current
397
- })],
398
- clickOpens: !readOnly,
399
- noCalendar: readOnly,
400
- nextArrow: rightArrowHTML,
401
- prevArrow: leftArrowHTML,
402
- onChange: (...args) => {
403
- if (!readOnly) {
404
- savedOnChange(...args);
405
- }
406
- },
407
- onReady: onHook,
408
- onMonthChange: onHook,
409
- onYearChange: onHook,
410
- onOpen: (...args) => {
411
- onHook(...args);
412
- savedOnOpen(...args);
413
- },
414
- onValueUpdate: onHook
415
- };
416
- const calendar = flatpickr(start, flatpickerConfig);
417
- calendarRef.current = calendar;
418
- const handleInputFieldKeyDown = event => {
419
- const {
420
- calendarContainer,
421
- selectedDateElem: fpSelectedDateElem,
422
- todayDateElem: fpTodayDateElem
423
- } = calendar;
424
- if (match(event, Escape)) {
425
- calendarContainer.classList.remove('open');
426
- }
427
- if (match(event, Tab)) {
428
- if (!event.shiftKey) {
429
- event.preventDefault();
430
- calendarContainer.classList.add('open');
431
- const selectedDateElem = calendarContainer.querySelector('.selected') && fpSelectedDateElem;
432
- const todayDateElem = calendarContainer.querySelector('.today') && fpTodayDateElem;
433
- const focusTarget = selectedDateElem || todayDateElem || calendarContainer.querySelector('.flatpickr-day[tabindex]') || calendarContainer;
434
- if (focusTarget instanceof HTMLElement) {
435
- focusTarget.focus();
436
- }
437
- if (event.target === startInputField.current) {
438
- lastFocusedField.current = startInputField.current;
439
- } else if (event.target === endInputField.current) {
440
- lastFocusedField.current = endInputField.current;
441
- }
442
- } else if (calendarRef.current?.isOpen && event.target === startInputField.current) {
443
- calendarRef.current.close();
444
- onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, event);
445
- }
446
- }
447
- };
448
- const handleCalendarKeyDown = event => {
449
- if (!calendarRef.current || !startInputField.current) return;
450
- const lastInputField = datePickerType == 'range' ? endInputField.current : startInputField.current;
451
- if (match(event, Tab)) {
452
- if (!event.shiftKey) {
453
- if (lastFocusedField.current === lastInputField) {
454
- lastInputField.focus();
455
- calendarRef.current.close();
456
- onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, event);
457
- } else {
458
- event.preventDefault();
459
- lastInputField.focus();
460
- }
461
- } else {
462
- event.preventDefault();
463
- (lastFocusedField.current || startInputField.current).focus();
464
- }
465
- }
466
- };
467
- function handleOnChange(event) {
468
- const {
469
- target
470
- } = event;
471
- if (target === start) {
472
- lastStartValue.current = start.value;
473
- }
474
- if (start.value !== '') {
475
- return;
476
- }
477
- if (!calendar.selectedDates) {
478
- return;
479
- }
480
- if (calendar.selectedDates.length === 0) {
481
- return;
482
- }
483
- }
484
- function handleKeyPress(event) {
485
- if (match(event, Enter) && closeOnSelect && datePickerType == 'single') {
486
- calendar.calendarContainer.classList.remove('open');
487
- }
488
- }
489
- if (start) {
490
- start.addEventListener('keydown', handleInputFieldKeyDown);
491
- start.addEventListener('change', handleOnChange);
492
- start.addEventListener('keypress', handleKeyPress);
493
- if (calendar && calendar.calendarContainer) {
494
- // Flatpickr's calendar dialog is not rendered in a landmark causing an
495
- // error with IBM Equal Access Accessibility Checker so we add an aria
496
- // role to the container div.
497
- calendar.calendarContainer.setAttribute('role', 'application');
498
- // IBM EAAC requires an aria-label on a role='region'
499
- calendar.calendarContainer.setAttribute('aria-label', 'calendar-container');
500
- }
501
- }
502
- if (end) {
503
- end.addEventListener('keydown', handleInputFieldKeyDown);
504
- end.addEventListener('change', handleOnChange);
505
- end.addEventListener('keypress', handleKeyPress);
506
- }
507
- if (calendar.calendarContainer) {
508
- calendar.calendarContainer.addEventListener('keydown', handleCalendarKeyDown);
509
- }
510
-
511
- //component did unmount equivalent
512
- return () => {
513
- // Note: if the `startInputField` ref is undefined then calendar will be
514
- // of type: Array and `destroy` will not be defined
515
- if (calendar && calendar.destroy) {
516
- calendar.destroy();
517
- }
518
-
519
- // prevent a duplicate date selection when a default value is set
520
- if (value) {
521
- if (start) {
522
- start.value = '';
523
- }
524
- if (end) {
525
- end.value = '';
526
- }
527
- }
528
- if (start) {
529
- start.removeEventListener('keydown', handleInputFieldKeyDown);
530
- start.removeEventListener('change', handleOnChange);
531
- start.removeEventListener('keypress', handleKeyPress);
532
- }
533
- if (end) {
534
- end.removeEventListener('keydown', handleInputFieldKeyDown);
535
- end.removeEventListener('change', handleOnChange);
536
- end.removeEventListener('keypress', handleKeyPress);
537
- }
538
- if (calendar.calendarContainer) {
539
- calendar.calendarContainer.removeEventListener('keydown', handleCalendarKeyDown);
540
- }
541
- };
542
- // eslint-disable-next-line react-hooks/exhaustive-deps
543
- }, [savedOnChange, savedOnOpen, readOnly, closeOnSelect, hasInput, datePickerType, nextMonthAriaLabel, prevMonthAriaLabel]);
544
-
545
- // this hook allows consumers to access the flatpickr calendar
546
- // instance for cases where functions like open() or close()
547
- // need to be imperatively called on the calendar
548
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
549
- useImperativeHandle(ref, () => ({
550
- get calendar() {
551
- return calendarRef.current;
552
- }
553
- }));
554
- useEffect(() => {
555
- if (calendarRef.current?.set) {
556
- calendarRef.current.set({
557
- dateFormat
558
- });
559
- }
560
- }, [dateFormat]);
561
- useEffect(() => {
562
- if (calendarRef.current?.set) {
563
- calendarRef.current.set('minDate', minDate);
564
- }
565
- }, [minDate]);
566
- useEffect(() => {
567
- if (calendarRef.current?.set) {
568
- calendarRef.current.set('allowInput', allowInput);
569
- }
570
- }, [allowInput]);
571
- useEffect(() => {
572
- if (calendarRef.current?.set) {
573
- calendarRef.current.set('maxDate', maxDate);
574
- }
575
- }, [maxDate]);
576
- useEffect(() => {
577
- if (calendarRef.current?.set && disable) {
578
- calendarRef.current.set('disable', disable);
579
- }
580
- }, [disable]);
581
- useEffect(() => {
582
- if (calendarRef.current?.set && enable) {
583
- calendarRef.current.set('enable', enable);
584
- }
585
- }, [enable]);
586
- useEffect(() => {
587
- if (calendarRef.current?.set && inline) {
588
- calendarRef.current.set('inline', inline);
589
- }
590
- }, [inline]);
591
- useEffect(() => {
592
- // when value prop is manually reset, this clears the flatpickr calendar instance and text input
593
- // run if both:
594
- // 1. value prop is set to a falsy value (`""`, `undefined`, `null`, etc) OR an array of all falsy values
595
- // 2. flatpickr instance contains values in its `selectedDates` property so it hasn't already been cleared
596
- if ((!value || Array.isArray(value) && value.every(date => !date)) && calendarRef.current?.selectedDates.length) {
597
- calendarRef.current?.clear();
598
- if (startInputField.current) {
599
- startInputField.current.value = '';
600
- }
601
- if (endInputField.current) {
602
- endInputField.current.value = '';
603
- }
604
- }
605
- }, [value, startInputField]);
606
- useEffect(() => {
607
- if (calendarRef.current?.set) {
608
- if (value !== undefined) {
609
- // To make up for calendarRef.current.setDate not making provision for an empty string or array
610
- if (value === '' || value === null || Array.isArray(value) && (value.length === 0 || value.every(element => !element))) {
611
- // only clear if there are selected dates to avoid unnecessary operations
612
- if (calendarRef.current.selectedDates.length > 0) {
613
- calendarRef.current.clear();
614
- }
615
- } else {
616
- calendarRef.current.setDate(value);
617
- }
618
- }
619
- updateClassNames(calendarRef.current, prefix);
620
- //for simple date picker w/o calendar; initial mount may not have value
621
- } else if (!calendarRef.current && value) {
622
- startInputField.current.value = value;
623
- }
624
- }, [value, prefix, startInputField]);
625
- let fluidError;
626
- if (isFluid) {
627
- if (invalid) {
628
- fluidError = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WarningFilled, {
629
- className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--invalid`
630
- }), /*#__PURE__*/React.createElement("hr", {
631
- className: `${prefix}--date-picker__divider`
632
- }), /*#__PURE__*/React.createElement("div", {
633
- className: `${prefix}--form-requirement`
634
- }, invalidText));
635
- } else if (warn) {
636
- fluidError = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WarningAltFilled, {
637
- className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--warn`
638
- }), /*#__PURE__*/React.createElement("hr", {
639
- className: `${prefix}--date-picker__divider`
640
- }), /*#__PURE__*/React.createElement("div", {
641
- className: `${prefix}--form-requirement`
642
- }, warnText));
643
- }
644
- }
645
- return /*#__PURE__*/React.createElement("div", _extends({
646
- className: wrapperClasses,
647
- ref: ref
648
- }, rest), /*#__PURE__*/React.createElement("div", {
649
- className: datePickerClasses,
650
- ref: wrapperRef
651
- }, childrenWithProps), fluidError);
256
+ const { current: start } = startInputField;
257
+ const { current: end } = endInputField;
258
+ const calendar = flatpickr(start, {
259
+ inline: inline ?? false,
260
+ onClose: onCalendarClose,
261
+ disableMobile: true,
262
+ defaultDate: value,
263
+ closeOnSelect,
264
+ mode: datePickerType,
265
+ allowInput: allowInput ?? true,
266
+ dateFormat,
267
+ locale: localeData,
268
+ [enableOrDisable]: enableOrDisableArr,
269
+ minDate,
270
+ maxDate,
271
+ parseDate,
272
+ plugins: [
273
+ datePickerType === "range" ? rangePlugin({ input: endInputField.current ?? void 0 }) : (() => {}),
274
+ appendTo ? appendToPlugin({ appendTo }) : (() => {}),
275
+ carbonFlatpickrMonthSelectPlugin({
276
+ selectorFlatpickrMonthYearContainer: ".flatpickr-current-month",
277
+ selectorFlatpickrYearContainer: ".numInputWrapper",
278
+ selectorFlatpickrCurrentMonth: ".cur-month",
279
+ classFlatpickrCurrentMonth: "cur-month",
280
+ locale
281
+ }),
282
+ fixEventsPlugin_default({
283
+ inputFrom: startInputField.current,
284
+ inputTo: endInputField.current,
285
+ lastStartValue,
286
+ container: wrapperRef.current
287
+ })
288
+ ],
289
+ clickOpens: !readOnly,
290
+ noCalendar: readOnly,
291
+ nextArrow: rightArrowHTML,
292
+ prevArrow: leftArrowHTML,
293
+ onChange: (...args) => {
294
+ if (!readOnly) savedOnChange(...args);
295
+ },
296
+ onReady: onHook,
297
+ onMonthChange: onHook,
298
+ onYearChange: onHook,
299
+ onOpen: (...args) => {
300
+ onHook(...args);
301
+ savedOnOpen(...args);
302
+ },
303
+ onValueUpdate: onHook
304
+ });
305
+ calendarRef.current = calendar;
306
+ const handleInputFieldKeyDown = (event) => {
307
+ const { calendarContainer, selectedDateElem: fpSelectedDateElem, todayDateElem: fpTodayDateElem } = calendar;
308
+ if (match(event, Escape)) calendarContainer.classList.remove("open");
309
+ if (match(event, Tab)) {
310
+ if (!event.shiftKey) {
311
+ event.preventDefault();
312
+ calendarContainer.classList.add("open");
313
+ const selectedDateElem = calendarContainer.querySelector(".selected") && fpSelectedDateElem;
314
+ const todayDateElem = calendarContainer.querySelector(".today") && fpTodayDateElem;
315
+ const focusTarget = selectedDateElem || todayDateElem || calendarContainer.querySelector(".flatpickr-day[tabindex]") || calendarContainer;
316
+ if (focusTarget instanceof HTMLElement) focusTarget.focus();
317
+ if (event.target === startInputField.current) lastFocusedField.current = startInputField.current;
318
+ else if (event.target === endInputField.current) lastFocusedField.current = endInputField.current;
319
+ } else if (calendarRef.current?.isOpen && event.target === startInputField.current) {
320
+ calendarRef.current.close();
321
+ onCalendarClose(calendarRef.current.selectedDates, "", calendarRef.current, event);
322
+ }
323
+ }
324
+ };
325
+ const handleCalendarKeyDown = (event) => {
326
+ if (!calendarRef.current || !startInputField.current) return;
327
+ const lastInputField = datePickerType == "range" ? endInputField.current : startInputField.current;
328
+ if (match(event, Tab)) if (!event.shiftKey) if (lastFocusedField.current === lastInputField) {
329
+ lastInputField.focus();
330
+ calendarRef.current.close();
331
+ onCalendarClose(calendarRef.current.selectedDates, "", calendarRef.current, event);
332
+ } else {
333
+ event.preventDefault();
334
+ lastInputField.focus();
335
+ }
336
+ else {
337
+ event.preventDefault();
338
+ (lastFocusedField.current || startInputField.current).focus();
339
+ }
340
+ };
341
+ function handleOnChange(event) {
342
+ const { target } = event;
343
+ if (target === start) lastStartValue.current = start.value;
344
+ if (start.value !== "") return;
345
+ if (!calendar.selectedDates) return;
346
+ if (calendar.selectedDates.length === 0) return;
347
+ }
348
+ function handleKeyPress(event) {
349
+ if (match(event, Enter) && closeOnSelect && datePickerType == "single") calendar.calendarContainer.classList.remove("open");
350
+ }
351
+ if (start) {
352
+ start.addEventListener("keydown", handleInputFieldKeyDown);
353
+ start.addEventListener("change", handleOnChange);
354
+ start.addEventListener("keypress", handleKeyPress);
355
+ if (calendar && calendar.calendarContainer) {
356
+ calendar.calendarContainer.setAttribute("role", "application");
357
+ calendar.calendarContainer.setAttribute("aria-label", "calendar-container");
358
+ }
359
+ }
360
+ if (end) {
361
+ end.addEventListener("keydown", handleInputFieldKeyDown);
362
+ end.addEventListener("change", handleOnChange);
363
+ end.addEventListener("keypress", handleKeyPress);
364
+ }
365
+ if (calendar.calendarContainer) calendar.calendarContainer.addEventListener("keydown", handleCalendarKeyDown);
366
+ return () => {
367
+ if (calendar && calendar.destroy) calendar.destroy();
368
+ if (value) {
369
+ if (start) start.value = "";
370
+ if (end) end.value = "";
371
+ }
372
+ if (start) {
373
+ start.removeEventListener("keydown", handleInputFieldKeyDown);
374
+ start.removeEventListener("change", handleOnChange);
375
+ start.removeEventListener("keypress", handleKeyPress);
376
+ }
377
+ if (end) {
378
+ end.removeEventListener("keydown", handleInputFieldKeyDown);
379
+ end.removeEventListener("change", handleOnChange);
380
+ end.removeEventListener("keypress", handleKeyPress);
381
+ }
382
+ if (calendar.calendarContainer) calendar.calendarContainer.removeEventListener("keydown", handleCalendarKeyDown);
383
+ };
384
+ }, [
385
+ savedOnChange,
386
+ savedOnOpen,
387
+ readOnly,
388
+ closeOnSelect,
389
+ hasInput,
390
+ datePickerType,
391
+ nextMonthAriaLabel,
392
+ prevMonthAriaLabel
393
+ ]);
394
+ useImperativeHandle(ref, () => ({ get calendar() {
395
+ return calendarRef.current;
396
+ } }));
397
+ useEffect(() => {
398
+ if (calendarRef.current?.set) calendarRef.current.set({ dateFormat });
399
+ }, [dateFormat]);
400
+ useEffect(() => {
401
+ if (calendarRef.current?.set) calendarRef.current.set("minDate", minDate);
402
+ }, [minDate]);
403
+ useEffect(() => {
404
+ if (calendarRef.current?.set) calendarRef.current.set("allowInput", allowInput);
405
+ }, [allowInput]);
406
+ useEffect(() => {
407
+ if (calendarRef.current?.set) calendarRef.current.set("maxDate", maxDate);
408
+ }, [maxDate]);
409
+ useEffect(() => {
410
+ if (calendarRef.current?.set && disable) calendarRef.current.set("disable", disable);
411
+ }, [disable]);
412
+ useEffect(() => {
413
+ if (calendarRef.current?.set && enable) calendarRef.current.set("enable", enable);
414
+ }, [enable]);
415
+ useEffect(() => {
416
+ if (calendarRef.current?.set && inline) calendarRef.current.set("inline", inline);
417
+ }, [inline]);
418
+ useEffect(() => {
419
+ if ((isEmptyDateValue(value) || Array.isArray(value) && value.every(isEmptyDateValue)) && calendarRef.current?.selectedDates.length) {
420
+ calendarRef.current?.clear();
421
+ if (startInputField.current) startInputField.current.value = "";
422
+ if (endInputField.current) endInputField.current.value = "";
423
+ }
424
+ }, [value, startInputField]);
425
+ useEffect(() => {
426
+ if (calendarRef.current?.set) {
427
+ if (value !== void 0) if (value === "" || value === null || Array.isArray(value) && (value.length === 0 || value.every(isEmptyDateValue))) {
428
+ if (calendarRef.current.selectedDates.length > 0) calendarRef.current.clear();
429
+ } else calendarRef.current.setDate(value);
430
+ updateClassNames(calendarRef.current, prefix);
431
+ } else if (!calendarRef.current && typeof value !== "undefined" && value !== null) startInputField.current.value = value;
432
+ }, [
433
+ value,
434
+ prefix,
435
+ startInputField
436
+ ]);
437
+ let fluidError;
438
+ if (isFluid) {
439
+ if (invalid) fluidError = /* @__PURE__ */ jsxs(Fragment, { children: [
440
+ /* @__PURE__ */ jsx(WarningFilled, { className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--invalid` }),
441
+ /* @__PURE__ */ jsx("hr", { className: `${prefix}--date-picker__divider` }),
442
+ /* @__PURE__ */ jsx("div", {
443
+ className: `${prefix}--form-requirement`,
444
+ children: invalidText
445
+ })
446
+ ] });
447
+ else if (warn) fluidError = /* @__PURE__ */ jsxs(Fragment, { children: [
448
+ /* @__PURE__ */ jsx(WarningAltFilled, { className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--warn` }),
449
+ /* @__PURE__ */ jsx("hr", { className: `${prefix}--date-picker__divider` }),
450
+ /* @__PURE__ */ jsx("div", {
451
+ className: `${prefix}--form-requirement`,
452
+ children: warnText
453
+ })
454
+ ] });
455
+ }
456
+ return /* @__PURE__ */ jsxs("div", {
457
+ className: wrapperClasses,
458
+ ref,
459
+ ...rest,
460
+ children: [/* @__PURE__ */ jsx("div", {
461
+ className: datePickerClasses,
462
+ ref: wrapperRef,
463
+ children: childrenWithProps
464
+ }), fluidError]
465
+ });
652
466
  });
653
467
  DatePicker.propTypes = {
654
- /**
655
- * Flatpickr prop passthrough enables direct date input, and when set to false,
656
- * we must clear dates manually by resetting the value prop to a falsy value (such as `""`, `null`, or `undefined`) or an array of all falsy values, making it a controlled input.
657
- */
658
- allowInput: PropTypes.bool,
659
- /**
660
- * The DOM element the Flatpicker should be inserted into. `<body>` by default.
661
- */
662
- appendTo: PropTypes.object,
663
- /**
664
- * The child nodes.
665
- */
666
- children: PropTypes.node,
667
- /**
668
- * The CSS class names.
669
- */
670
- className: PropTypes.string,
671
- /**
672
- * flatpickr prop passthrough. Controls whether the calendar dropdown closes upon selection.
673
- */
674
- closeOnSelect: PropTypes.bool,
675
- /**
676
- * The date format.
677
- */
678
- dateFormat: PropTypes.string,
679
- /**
680
- * The type of the date picker:
681
- *
682
- * * `simple` - Without calendar dropdown.
683
- * * `single` - With calendar dropdown and single date.
684
- * * `range` - With calendar dropdown and a date range.
685
- */
686
- datePickerType: PropTypes.oneOf(['simple', 'single', 'range']),
687
- /**
688
- * The flatpickr `disable` option that allows a user to disable certain dates.
689
- */
690
- disable: PropTypes.array,
691
- /**
692
- * The flatpickr `enable` option that allows a user to enable certain dates.
693
- */
694
- enable: PropTypes.array,
695
- /**
696
- * The flatpickr `inline` option.
697
- */
698
- inline: PropTypes.bool,
699
- /**
700
- * Specify whether or not the control is invalid (Fluid only)
701
- */
702
- invalid: PropTypes.bool,
703
- /**
704
- * Provide the text that is displayed when the control is in error state (Fluid Only)
705
- */
706
- invalidText: PropTypes.node,
707
- /**
708
- * `true` to use the light version.
709
- */
710
- light: deprecate(PropTypes.bool, 'The `light` prop for `DatePicker` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
711
- /**
712
- * The language locale used to format the days of the week, months, and numbers. The full list of supported locales can be found here https://github.com/flatpickr/flatpickr/tree/master/src/l10n
713
- */
714
- locale: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(SUPPORTED_LOCALES)]),
715
- /**
716
- * The maximum date that a user can pick to.
717
- */
718
- maxDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
719
- /**
720
- * The minimum date that a user can start picking from.
721
- */
722
- minDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
723
- /**
724
- * The `change` event handler.
725
- * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
726
- */
727
- onChange: PropTypes.func,
728
- /**
729
- * The `close` event handler.
730
- * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
731
- */
732
- onClose: PropTypes.func,
733
- /**
734
- * The `open` event handler.
735
- * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
736
- */
737
- onOpen: PropTypes.func,
738
- /**
739
- * flatpickr prop passthrough. Controls how dates are parsed.
740
- */
741
- parseDate: PropTypes.func,
742
- /**
743
- * whether the DatePicker is to be readOnly
744
- * if boolean applies to all inputs
745
- * if array applies to each input in order
746
- */
747
- readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]),
748
- /**
749
- * `true` to use the short version.
750
- */
751
- short: PropTypes.bool,
752
- /**
753
- * The value of the date value provided to flatpickr, could
754
- * be a date, a date number, a date string, an array of dates.
755
- */
756
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object])), PropTypes.object, PropTypes.number]),
757
- /**
758
- * Specify whether the control is currently in warning state (Fluid only)
759
- */
760
- warn: PropTypes.bool,
761
- /**
762
- * Provide the text that is displayed when the control is in warning state (Fluid only)
763
- */
764
- warnText: PropTypes.node,
765
- /**
766
- * Accessible aria-label for the "next month" arrow icon.
767
- */
768
- nextMonthAriaLabel: PropTypes.string,
769
- /**
770
- * Accessible aria-label for the "previous month" arrow icon.
771
- */
772
- prevMonthAriaLabel: PropTypes.string
468
+ allowInput: PropTypes.bool,
469
+ appendTo: PropTypes.object,
470
+ children: PropTypes.node,
471
+ className: PropTypes.string,
472
+ closeOnSelect: PropTypes.bool,
473
+ dateFormat: PropTypes.string,
474
+ datePickerType: PropTypes.oneOf([
475
+ "simple",
476
+ "single",
477
+ "range"
478
+ ]),
479
+ disable: PropTypes.array,
480
+ enable: PropTypes.array,
481
+ inline: PropTypes.bool,
482
+ invalid: PropTypes.bool,
483
+ invalidText: PropTypes.node,
484
+ light: deprecate(PropTypes.bool, "The `light` prop for `DatePicker` has been deprecated in favor of the new `Layer` component. It will be removed in the next major release."),
485
+ locale: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(SUPPORTED_LOCALES)]),
486
+ maxDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
487
+ minDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
488
+ onChange: PropTypes.func,
489
+ onClose: PropTypes.func,
490
+ onOpen: PropTypes.func,
491
+ parseDate: PropTypes.func,
492
+ readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]),
493
+ short: PropTypes.bool,
494
+ value: PropTypes.oneOfType([
495
+ PropTypes.string,
496
+ PropTypes.arrayOf(PropTypes.oneOfType([
497
+ PropTypes.string,
498
+ PropTypes.number,
499
+ PropTypes.object
500
+ ])),
501
+ PropTypes.object,
502
+ PropTypes.number
503
+ ]),
504
+ warn: PropTypes.bool,
505
+ warnText: PropTypes.node,
506
+ nextMonthAriaLabel: PropTypes.string,
507
+ prevMonthAriaLabel: PropTypes.string
773
508
  };
774
509
 
775
- export { DatePicker as default };
510
+ //#endregion
511
+ export { DatePicker as default };