@carbon/react 1.103.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 (769) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +956 -956
  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.js +485 -752
  89. package/es/components/DatePicker/DatePickerLocales.js +75 -126
  90. package/es/components/DatePicker/index.js +13 -5
  91. package/es/components/DatePicker/plugins/appendToPlugin.js +31 -45
  92. package/es/components/DatePicker/plugins/fixEventsPlugin.js +127 -171
  93. package/es/components/DatePicker/plugins/rangePlugin.js +40 -48
  94. package/es/components/DatePicker/utils.js +11 -3
  95. package/es/components/DatePickerInput/DatePickerInput.js +179 -289
  96. package/es/components/DatePickerInput/index.js +12 -4
  97. package/es/components/Dialog/Dialog.js +303 -574
  98. package/es/components/Dialog/index.js +18 -2
  99. package/es/components/Dropdown/Dropdown.Skeleton.js +26 -38
  100. package/es/components/Dropdown/Dropdown.js +344 -535
  101. package/es/components/Dropdown/index.js +13 -5
  102. package/es/components/ErrorBoundary/ErrorBoundary.js +36 -58
  103. package/es/components/ErrorBoundary/ErrorBoundaryContext.js +14 -9
  104. package/es/components/ExpandableSearch/ExpandableSearch.js +60 -69
  105. package/es/components/ExpandableSearch/index.js +12 -4
  106. package/es/components/FeatureFlags/index.d.ts +11 -2
  107. package/es/components/FeatureFlags/index.js +79 -77
  108. package/es/components/FileUploader/FileUploader.Skeleton.js +35 -30
  109. package/es/components/FileUploader/FileUploader.js +269 -343
  110. package/es/components/FileUploader/FileUploaderButton.js +110 -160
  111. package/es/components/FileUploader/FileUploaderDropContainer.js +144 -221
  112. package/es/components/FileUploader/FileUploaderItem.js +138 -157
  113. package/es/components/FileUploader/Filename.d.ts +1 -1
  114. package/es/components/FileUploader/Filename.js +53 -72
  115. package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +26 -28
  116. package/es/components/FluidComboBox/FluidComboBox.js +54 -105
  117. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +56 -53
  118. package/es/components/FluidDatePicker/FluidDatePicker.js +46 -68
  119. package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +23 -16
  120. package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +26 -28
  121. package/es/components/FluidDropdown/FluidDropdown.js +55 -111
  122. package/es/components/FluidForm/FluidForm.js +29 -31
  123. package/es/components/FluidForm/FormContext.js +12 -6
  124. package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +26 -28
  125. package/es/components/FluidMultiSelect/FluidMultiSelect.js +67 -197
  126. package/es/components/FluidNumberInput/FluidNumberInput.Skeleton.js +27 -30
  127. package/es/components/FluidNumberInput/FluidNumberInput.js +63 -147
  128. package/es/components/FluidSearch/FluidSearch.Skeleton.js +27 -30
  129. package/es/components/FluidSearch/FluidSearch.js +41 -84
  130. package/es/components/FluidSelect/FluidSelect.Skeleton.js +26 -28
  131. package/es/components/FluidSelect/FluidSelect.js +40 -76
  132. package/es/components/FluidSelect/index.js +13 -5
  133. package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +27 -30
  134. package/es/components/FluidTextArea/FluidTextArea.js +48 -112
  135. package/es/components/FluidTextInput/FluidPasswordInput.js +44 -99
  136. package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +27 -30
  137. package/es/components/FluidTextInput/FluidTextInput.js +49 -104
  138. package/es/components/FluidTextInput/index.js +14 -6
  139. package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +30 -33
  140. package/es/components/FluidTimePicker/FluidTimePicker.js +68 -115
  141. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +28 -47
  142. package/es/components/Form/Form.js +23 -25
  143. package/es/components/FormGroup/FormGroup.js +45 -67
  144. package/es/components/FormItem/FormItem.js +23 -25
  145. package/es/components/FormLabel/FormLabel.js +28 -34
  146. package/es/components/Grid/CSSGrid.d.ts +1 -1
  147. package/es/components/Grid/CSSGrid.js +85 -127
  148. package/es/components/Grid/Column.js +192 -324
  149. package/es/components/Grid/ColumnHang.js +28 -36
  150. package/es/components/Grid/FlexGrid.js +40 -60
  151. package/es/components/Grid/Grid.js +29 -42
  152. package/es/components/Grid/GridContext.js +36 -42
  153. package/es/components/Grid/Row.js +31 -49
  154. package/es/components/Heading/index.js +36 -51
  155. package/es/components/Icon/Icon.Skeleton.js +21 -21
  156. package/es/components/IconButton/index.js +117 -178
  157. package/es/components/IconIndicator/index.d.ts +1 -1
  158. package/es/components/IconIndicator/index.js +59 -60
  159. package/es/components/IdPrefix/index.js +21 -17
  160. package/es/components/InlineCheckbox/InlineCheckbox.js +69 -113
  161. package/es/components/InlineCheckbox/index.js +12 -4
  162. package/es/components/InlineLoading/InlineLoading.js +83 -100
  163. package/es/components/InlineLoading/index.js +12 -4
  164. package/es/components/Layer/LayerContext.js +12 -4
  165. package/es/components/Layer/LayerLevel.js +20 -4
  166. package/es/components/Layer/index.js +54 -66
  167. package/es/components/Layout/index.js +77 -109
  168. package/es/components/LayoutDirection/LayoutDirection.d.ts +1 -1
  169. package/es/components/LayoutDirection/LayoutDirection.js +33 -37
  170. package/es/components/LayoutDirection/LayoutDirectionContext.js +12 -6
  171. package/es/components/LayoutDirection/useLayoutDirection.js +15 -7
  172. package/es/components/Link/Link.js +63 -108
  173. package/es/components/Link/index.js +12 -4
  174. package/es/components/ListBox/ListBox.js +78 -126
  175. package/es/components/ListBox/ListBoxField.js +24 -43
  176. package/es/components/ListBox/ListBoxMenu.js +36 -42
  177. package/es/components/ListBox/ListBoxMenuIcon.js +39 -40
  178. package/es/components/ListBox/ListBoxMenuItem.js +67 -88
  179. package/es/components/ListBox/ListBoxPropTypes.js +17 -5
  180. package/es/components/ListBox/ListBoxSelection.js +71 -96
  181. package/es/components/ListBox/index.js +16 -14
  182. package/es/components/ListBox/next/ListBoxSelection.js +79 -117
  183. package/es/components/ListBox/next/ListBoxTrigger.js +44 -48
  184. package/es/components/ListItem/ListItem.js +25 -28
  185. package/es/components/Loading/Loading.js +64 -73
  186. package/es/components/Loading/index.js +12 -4
  187. package/es/components/Menu/Menu.js +220 -363
  188. package/es/components/Menu/MenuContext.d.ts +1 -1
  189. package/es/components/Menu/MenuContext.js +41 -38
  190. package/es/components/Menu/MenuItem.js +282 -413
  191. package/es/components/MenuButton/index.js +134 -195
  192. package/es/components/Modal/Modal.js +500 -660
  193. package/es/components/Modal/ModalPresence.js +39 -37
  194. package/es/components/Modal/index.js +13 -5
  195. package/es/components/ModalWrapper/ModalWrapper.d.ts +2 -2
  196. package/es/components/ModalWrapper/ModalWrapper.js +106 -130
  197. package/es/components/MultiSelect/FilterableMultiSelect.js +605 -918
  198. package/es/components/MultiSelect/MultiSelect.js +454 -716
  199. package/es/components/MultiSelect/MultiSelectPropTypes.js +13 -30
  200. package/es/components/MultiSelect/filter.js +14 -9
  201. package/es/components/MultiSelect/tools/sorting.js +21 -34
  202. package/es/components/Notification/Notification.js +508 -785
  203. package/es/components/NumberInput/NumberFormatPropTypes.js +69 -30
  204. package/es/components/NumberInput/NumberInput.Skeleton.js +29 -33
  205. package/es/components/NumberInput/NumberInput.js +567 -947
  206. package/es/components/OrderedList/OrderedList.js +31 -44
  207. package/es/components/OverflowMenu/OverflowMenu.js +335 -450
  208. package/es/components/OverflowMenu/index.js +25 -16
  209. package/es/components/OverflowMenu/next/index.js +154 -186
  210. package/es/components/OverflowMenuItem/OverflowMenuItem.js +100 -160
  211. package/es/components/OverflowMenuItem/index.js +12 -4
  212. package/es/components/OverflowMenuV2/index.js +15 -13
  213. package/es/components/PageHeader/PageHeader.js +297 -442
  214. package/es/components/PageHeader/index.js +24 -2
  215. package/es/components/Pagination/Pagination.Skeleton.js +34 -35
  216. package/es/components/Pagination/Pagination.d.ts +1 -1
  217. package/es/components/Pagination/Pagination.js +251 -356
  218. package/es/components/Pagination/experimental/PageSelector.js +38 -54
  219. package/es/components/Pagination/experimental/Pagination-story.d.ts +114 -0
  220. package/es/components/Pagination/experimental/Pagination.js +144 -196
  221. package/es/components/PaginationNav/PaginationNav.js +320 -426
  222. package/es/components/Popover/index.js +318 -437
  223. package/es/components/PrimaryButton/PrimaryButton.js +11 -9
  224. package/es/components/ProgressBar/ProgressBar.js +117 -143
  225. package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +42 -38
  226. package/es/components/ProgressIndicator/ProgressIndicator.js +146 -243
  227. package/es/components/RadioButton/RadioButton.Skeleton.js +23 -25
  228. package/es/components/RadioButton/RadioButton.js +101 -174
  229. package/es/components/RadioButton/index.js +12 -4
  230. package/es/components/RadioButtonGroup/RadioButtonGroup.js +135 -207
  231. package/es/components/RadioTile/RadioTile.js +104 -168
  232. package/es/components/RadioTile/index.js +12 -4
  233. package/es/components/Search/Search.Skeleton.js +28 -33
  234. package/es/components/Search/Search.js +182 -278
  235. package/es/components/Search/index.js +13 -5
  236. package/es/components/Search/utils.js +11 -3
  237. package/es/components/SecondaryButton/SecondaryButton.js +11 -9
  238. package/es/components/Select/Select.Skeleton.js +27 -30
  239. package/es/components/Select/Select.js +178 -257
  240. package/es/components/Select/index.js +13 -5
  241. package/es/components/SelectItem/SelectItem.js +33 -48
  242. package/es/components/SelectItem/index.js +12 -4
  243. package/es/components/SelectItemGroup/SelectItemGroup.js +27 -37
  244. package/es/components/ShapeIndicator/index.d.ts +1 -1
  245. package/es/components/ShapeIndicator/index.js +74 -80
  246. package/es/components/SkeletonIcon/SkeletonIcon.js +21 -24
  247. package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +15 -24
  248. package/es/components/SkeletonText/SkeletonText.js +67 -81
  249. package/es/components/SkeletonText/index.js +12 -4
  250. package/es/components/Slider/Slider.Skeleton.js +68 -91
  251. package/es/components/Slider/Slider.js +864 -1315
  252. package/es/components/Slider/SliderHandles.js +73 -66
  253. package/es/components/Stack/HStack.js +19 -11
  254. package/es/components/Stack/Stack.js +56 -80
  255. package/es/components/Stack/VStack.js +19 -11
  256. package/es/components/StructuredList/StructuredList.Skeleton.js +55 -48
  257. package/es/components/StructuredList/StructuredList.js +178 -317
  258. package/es/components/Switch/IconSwitch.js +99 -145
  259. package/es/components/Switch/Switch.js +66 -99
  260. package/es/components/TabContent/TabContent.js +28 -34
  261. package/es/components/Tabs/Tabs.Skeleton.js +41 -36
  262. package/es/components/Tabs/Tabs.js +732 -1149
  263. package/es/components/Tabs/usePressable.js +97 -112
  264. package/es/components/Tag/DismissibleTag.js +119 -156
  265. package/es/components/Tag/OperationalTag.js +91 -111
  266. package/es/components/Tag/SelectableTag.js +94 -129
  267. package/es/components/Tag/Tag.Skeleton.js +26 -30
  268. package/es/components/Tag/Tag.js +152 -200
  269. package/es/components/Tag/isEllipsisActive.js +13 -8
  270. package/es/components/Text/Text.js +66 -79
  271. package/es/components/Text/TextDirection.js +36 -37
  272. package/es/components/Text/TextDirectionContext.js +14 -8
  273. package/es/components/Text/createTextComponent.js +21 -20
  274. package/es/components/TextArea/TextArea.Skeleton.js +25 -29
  275. package/es/components/TextArea/TextArea.js +315 -422
  276. package/es/components/TextArea/index.js +13 -5
  277. package/es/components/TextInput/ControlledPasswordInput.js +133 -198
  278. package/es/components/TextInput/PasswordInput.js +196 -303
  279. package/es/components/TextInput/TextInput.Skeleton.js +24 -28
  280. package/es/components/TextInput/TextInput.js +219 -317
  281. package/es/components/TextInput/index.js +13 -5
  282. package/es/components/TextInput/util.js +21 -25
  283. package/es/components/Theme/index.js +79 -95
  284. package/es/components/Tile/Tile.js +394 -593
  285. package/es/components/TileGroup/TileGroup.js +70 -111
  286. package/es/components/TimePicker/TimePicker.d.ts +1 -1
  287. package/es/components/TimePicker/TimePicker.js +148 -247
  288. package/es/components/TimePickerSelect/TimePickerSelect.js +43 -58
  289. package/es/components/Toggle/Toggle.Skeleton.js +24 -22
  290. package/es/components/Toggle/Toggle.js +102 -171
  291. package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +46 -51
  292. package/es/components/Toggletip/index.d.ts +2 -2
  293. package/es/components/Toggletip/index.js +170 -256
  294. package/es/components/Tooltip/DefinitionTooltip.js +98 -138
  295. package/es/components/Tooltip/Tooltip.js +188 -263
  296. package/es/components/TreeView/TreeContext.js +13 -5
  297. package/es/components/TreeView/TreeNode.js +361 -500
  298. package/es/components/TreeView/TreeView.js +164 -237
  299. package/es/components/UIShell/Content.js +23 -30
  300. package/es/components/UIShell/Header.js +25 -29
  301. package/es/components/UIShell/HeaderContainer.js +31 -40
  302. package/es/components/UIShell/HeaderGlobalAction.js +65 -90
  303. package/es/components/UIShell/HeaderGlobalBar.js +16 -9
  304. package/es/components/UIShell/HeaderMenu.js +141 -215
  305. package/es/components/UIShell/HeaderMenuButton.js +43 -66
  306. package/es/components/UIShell/HeaderMenuItem.js +49 -76
  307. package/es/components/UIShell/HeaderName.js +32 -44
  308. package/es/components/UIShell/HeaderNavigation.js +32 -37
  309. package/es/components/UIShell/HeaderPanel.js +74 -97
  310. package/es/components/UIShell/HeaderSideNavItems.js +27 -33
  311. package/es/components/UIShell/Link.js +29 -50
  312. package/es/components/UIShell/SideNav.js +132 -241
  313. package/es/components/UIShell/SideNavContext.js +21 -15
  314. package/es/components/UIShell/SideNavDetails.js +29 -34
  315. package/es/components/UIShell/SideNavDivider.js +21 -21
  316. package/es/components/UIShell/SideNavFooter.js +43 -52
  317. package/es/components/UIShell/SideNavHeader.js +26 -35
  318. package/es/components/UIShell/SideNavIcon.js +28 -33
  319. package/es/components/UIShell/SideNavItem.js +28 -33
  320. package/es/components/UIShell/SideNavItems.js +31 -40
  321. package/es/components/UIShell/SideNavLink.js +52 -79
  322. package/es/components/UIShell/SideNavLinkText.js +24 -25
  323. package/es/components/UIShell/SideNavMenu.js +102 -143
  324. package/es/components/UIShell/SideNavMenuItem.js +40 -52
  325. package/es/components/UIShell/SideNavSwitcher.js +59 -68
  326. package/es/components/UIShell/SkipToContent.js +28 -36
  327. package/es/components/UIShell/Switcher.js +69 -99
  328. package/es/components/UIShell/SwitcherDivider.js +16 -24
  329. package/es/components/UIShell/SwitcherItem.js +74 -114
  330. package/es/components/UnorderedList/UnorderedList.js +28 -37
  331. package/es/feature-flags.js +19 -10
  332. package/es/index.js +249 -242
  333. package/es/internal/FloatingMenu.js +246 -292
  334. package/es/internal/OptimizedResize.js +35 -46
  335. package/es/internal/Selection.js +99 -132
  336. package/es/internal/clamp.js +12 -4
  337. package/es/internal/defaultItemToString.js +15 -9
  338. package/es/internal/deprecateFieldOnObject.js +22 -14
  339. package/es/internal/environment.js +15 -7
  340. package/es/internal/getAnnouncement.js +16 -13
  341. package/es/internal/keyboard/keys.js +48 -48
  342. package/es/internal/keyboard/match.js +25 -42
  343. package/es/internal/keyboard/navigation.js +22 -27
  344. package/es/internal/noopFn.js +10 -2
  345. package/es/internal/useAttachedMenu.js +43 -51
  346. package/es/internal/useControllableState.js +43 -48
  347. package/es/internal/useDelayedState.js +30 -35
  348. package/es/internal/useEvent.js +39 -35
  349. package/es/internal/useId.js +51 -87
  350. package/es/internal/useIdPrefix.js +13 -5
  351. package/es/internal/useIsomorphicEffect.js +12 -4
  352. package/es/internal/useMatchMedia.js +29 -21
  353. package/es/internal/useMergedRefs.js +26 -22
  354. package/es/internal/useNoInteractiveChildren.js +70 -99
  355. package/es/internal/useNormalizedInputProps.js +47 -51
  356. package/es/internal/useOutsideClick.js +21 -24
  357. package/es/internal/useOverflowItems.js +89 -90
  358. package/es/internal/usePrefix.js +13 -5
  359. package/es/internal/usePresence.js +51 -54
  360. package/es/internal/usePresenceContext.js +35 -35
  361. package/es/internal/usePreviousValue.js +26 -18
  362. package/es/internal/useResizeObserver.js +57 -66
  363. package/es/internal/useSavedCallback.js +24 -17
  364. package/es/internal/utils.js +17 -9
  365. package/es/internal/warning.js +17 -22
  366. package/es/internal/wrapFocus.js +77 -98
  367. package/es/prop-types/AriaPropTypes.js +14 -6
  368. package/es/prop-types/deprecate.js +30 -27
  369. package/es/prop-types/deprecateComponent.js +17 -8
  370. package/es/prop-types/deprecateValuesWithin.js +18 -21
  371. package/es/prop-types/isRequiredOneOf.js +21 -24
  372. package/es/prop-types/requiredIfGivenPropIsTruthy.js +14 -14
  373. package/es/tools/events.js +17 -21
  374. package/es/tools/mapPopoverAlign.js +19 -18
  375. package/es/tools/mergeRefs.js +14 -17
  376. package/es/tools/setupGetInstanceId.js +16 -8
  377. package/es/tools/toggleClass.js +17 -9
  378. package/es/tools/wrapComponent.js +34 -39
  379. package/icons/index.d.ts +2 -1
  380. package/icons/index.esm.js +2 -2
  381. package/icons/index.js +7 -10
  382. package/lib/_virtual/_rolldown/runtime.js +50 -0
  383. package/lib/components/AILabel/index.d.ts +29 -2
  384. package/lib/components/AILabel/index.js +118 -171
  385. package/lib/components/AISkeleton/AISkeletonIcon.js +27 -31
  386. package/lib/components/AISkeleton/AISkeletonPlaceholder.js +29 -31
  387. package/lib/components/AISkeleton/AISkeletonText.js +30 -43
  388. package/lib/components/Accordion/Accordion.Skeleton.js +59 -84
  389. package/lib/components/Accordion/Accordion.js +47 -65
  390. package/lib/components/Accordion/AccordionItem.js +106 -160
  391. package/lib/components/Accordion/AccordionProvider.js +20 -17
  392. package/lib/components/AspectRatio/AspectRatio.js +45 -51
  393. package/lib/components/BadgeIndicator/index.js +33 -39
  394. package/lib/components/Breadcrumb/Breadcrumb.Skeleton.js +43 -55
  395. package/lib/components/Breadcrumb/Breadcrumb.js +43 -55
  396. package/lib/components/Breadcrumb/BreadcrumbItem.js +84 -87
  397. package/lib/components/Button/Button.Skeleton.js +53 -63
  398. package/lib/components/Button/Button.d.ts +1 -1
  399. package/lib/components/Button/Button.js +149 -244
  400. package/lib/components/Button/ButtonBase.js +85 -108
  401. package/lib/components/Button/index.js +13 -15
  402. package/lib/components/ButtonSet/ButtonSet.js +78 -102
  403. package/lib/components/ButtonSet/index.js +12 -9
  404. package/lib/components/ChatButton/ChatButton.Skeleton.js +31 -31
  405. package/lib/components/ChatButton/ChatButton.js +68 -83
  406. package/lib/components/Checkbox/Checkbox.Skeleton.js +30 -30
  407. package/lib/components/Checkbox/Checkbox.js +119 -198
  408. package/lib/components/Checkbox/index.js +13 -11
  409. package/lib/components/CheckboxGroup/CheckboxGroup.js +104 -152
  410. package/lib/components/ClassPrefix/index.js +24 -19
  411. package/lib/components/CodeSnippet/CodeSnippet.Skeleton.js +49 -47
  412. package/lib/components/CodeSnippet/CodeSnippet.js +215 -303
  413. package/lib/components/ComboBox/ComboBox.js +626 -974
  414. package/lib/components/ComboBox/index.js +12 -9
  415. package/lib/components/ComboButton/index.js +176 -210
  416. package/lib/components/ComposedModal/ComposedModal.js +315 -454
  417. package/lib/components/ComposedModal/ComposedModalPresence.js +49 -44
  418. package/lib/components/ComposedModal/ModalFooter.js +131 -209
  419. package/lib/components/ComposedModal/ModalHeader.js +75 -103
  420. package/lib/components/ComposedModal/useComposedModalState.js +22 -17
  421. package/lib/components/ContainedList/ContainedList.js +77 -106
  422. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +59 -71
  423. package/lib/components/ContainedList/ContainedListItem/index.js +12 -9
  424. package/lib/components/ContainedList/index.js +18 -15
  425. package/lib/components/ContentSwitcher/ContentSwitcher.js +112 -142
  426. package/lib/components/ContextMenu/useContextMenu.js +42 -40
  427. package/lib/components/Copy/Copy.js +101 -121
  428. package/lib/components/Copy/index.js +12 -9
  429. package/lib/components/CopyButton/CopyButton.js +85 -98
  430. package/lib/components/CopyButton/index.js +12 -9
  431. package/lib/components/DangerButton/DangerButton.js +19 -13
  432. package/lib/components/DataTable/DataTable.d.ts +11 -11
  433. package/lib/components/DataTable/DataTable.js +474 -655
  434. package/lib/components/DataTable/Table.js +115 -161
  435. package/lib/components/DataTable/TableActionList.js +15 -11
  436. package/lib/components/DataTable/TableBatchAction.js +28 -38
  437. package/lib/components/DataTable/TableBatchActions.js +82 -117
  438. package/lib/components/DataTable/TableBody.js +29 -23
  439. package/lib/components/DataTable/TableCell.js +35 -50
  440. package/lib/components/DataTable/TableContainer.js +79 -86
  441. package/lib/components/DataTable/TableContext.js +15 -8
  442. package/lib/components/DataTable/TableDecoratorRow.js +34 -40
  443. package/lib/components/DataTable/TableExpandHeader.js +57 -94
  444. package/lib/components/DataTable/TableExpandRow.js +86 -123
  445. package/lib/components/DataTable/TableExpandedRow.js +49 -55
  446. package/lib/components/DataTable/TableHead.js +8 -10
  447. package/lib/components/DataTable/TableHeader.js +142 -185
  448. package/lib/components/DataTable/TableRow.d.ts +1 -1
  449. package/lib/components/DataTable/TableRow.js +46 -80
  450. package/lib/components/DataTable/TableSelectAll.js +46 -74
  451. package/lib/components/DataTable/TableSelectRow.js +67 -102
  452. package/lib/components/DataTable/TableSlugRow.js +39 -47
  453. package/lib/components/DataTable/TableToolbar.js +37 -49
  454. package/lib/components/DataTable/TableToolbarAction.js +28 -24
  455. package/lib/components/DataTable/TableToolbarContent.js +15 -11
  456. package/lib/components/DataTable/TableToolbarMenu.js +39 -50
  457. package/lib/components/DataTable/TableToolbarSearch.js +101 -191
  458. package/lib/components/DataTable/state/getDerivedStateFromProps.js +38 -47
  459. package/lib/components/DataTable/state/sortStates.js +11 -10
  460. package/lib/components/DataTable/state/sorting.js +54 -76
  461. package/lib/components/DataTable/tools/cells.js +15 -8
  462. package/lib/components/DataTable/tools/denormalize.js +27 -22
  463. package/lib/components/DataTable/tools/filter.js +21 -23
  464. package/lib/components/DataTable/tools/normalize.js +57 -76
  465. package/lib/components/DataTable/tools/sorting.js +50 -75
  466. package/lib/components/DataTableSkeleton/DataTableSkeleton.js +70 -98
  467. package/lib/components/DatePicker/DatePicker.Skeleton.js +48 -56
  468. package/lib/components/DatePicker/DatePicker.js +491 -756
  469. package/lib/components/DatePicker/DatePickerLocales.js +75 -127
  470. package/lib/components/DatePicker/index.js +13 -11
  471. package/lib/components/DatePicker/plugins/appendToPlugin.js +31 -46
  472. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +127 -175
  473. package/lib/components/DatePicker/plugins/rangePlugin.js +42 -50
  474. package/lib/components/DatePicker/utils.js +11 -4
  475. package/lib/components/DatePickerInput/DatePickerInput.js +183 -293
  476. package/lib/components/DatePickerInput/index.js +12 -9
  477. package/lib/components/Dialog/Dialog.js +307 -576
  478. package/lib/components/Dialog/index.js +21 -13
  479. package/lib/components/Dropdown/Dropdown.Skeleton.js +30 -43
  480. package/lib/components/Dropdown/Dropdown.js +348 -539
  481. package/lib/components/Dropdown/index.js +13 -11
  482. package/lib/components/ErrorBoundary/ErrorBoundary.js +39 -62
  483. package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +15 -11
  484. package/lib/components/ExpandableSearch/ExpandableSearch.js +63 -73
  485. package/lib/components/ExpandableSearch/index.js +12 -9
  486. package/lib/components/FeatureFlags/index.d.ts +11 -2
  487. package/lib/components/FeatureFlags/index.js +82 -79
  488. package/lib/components/FileUploader/FileUploader.Skeleton.js +39 -35
  489. package/lib/components/FileUploader/FileUploader.js +273 -347
  490. package/lib/components/FileUploader/FileUploaderButton.js +114 -164
  491. package/lib/components/FileUploader/FileUploaderDropContainer.js +148 -225
  492. package/lib/components/FileUploader/FileUploaderItem.js +142 -161
  493. package/lib/components/FileUploader/Filename.d.ts +1 -1
  494. package/lib/components/FileUploader/Filename.js +56 -76
  495. package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +30 -32
  496. package/lib/components/FluidComboBox/FluidComboBox.js +58 -109
  497. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +60 -57
  498. package/lib/components/FluidDatePicker/FluidDatePicker.js +50 -72
  499. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +25 -20
  500. package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +30 -32
  501. package/lib/components/FluidDropdown/FluidDropdown.js +59 -115
  502. package/lib/components/FluidForm/FluidForm.js +33 -35
  503. package/lib/components/FluidForm/FormContext.js +13 -8
  504. package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +30 -32
  505. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +71 -201
  506. package/lib/components/FluidNumberInput/FluidNumberInput.Skeleton.js +31 -34
  507. package/lib/components/FluidNumberInput/FluidNumberInput.js +67 -151
  508. package/lib/components/FluidSearch/FluidSearch.Skeleton.js +31 -34
  509. package/lib/components/FluidSearch/FluidSearch.js +45 -88
  510. package/lib/components/FluidSelect/FluidSelect.Skeleton.js +30 -32
  511. package/lib/components/FluidSelect/FluidSelect.js +44 -80
  512. package/lib/components/FluidSelect/index.js +13 -11
  513. package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +31 -34
  514. package/lib/components/FluidTextArea/FluidTextArea.js +52 -116
  515. package/lib/components/FluidTextInput/FluidPasswordInput.js +48 -103
  516. package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +31 -34
  517. package/lib/components/FluidTextInput/FluidTextInput.js +53 -108
  518. package/lib/components/FluidTextInput/index.js +14 -13
  519. package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +34 -37
  520. package/lib/components/FluidTimePicker/FluidTimePicker.js +72 -119
  521. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +31 -51
  522. package/lib/components/Form/Form.js +27 -29
  523. package/lib/components/FormGroup/FormGroup.js +49 -71
  524. package/lib/components/FormItem/FormItem.js +27 -29
  525. package/lib/components/FormLabel/FormLabel.js +32 -38
  526. package/lib/components/Grid/CSSGrid.d.ts +1 -1
  527. package/lib/components/Grid/CSSGrid.js +89 -129
  528. package/lib/components/Grid/Column.js +196 -328
  529. package/lib/components/Grid/ColumnHang.js +32 -38
  530. package/lib/components/Grid/FlexGrid.js +44 -62
  531. package/lib/components/Grid/Grid.js +32 -44
  532. package/lib/components/Grid/GridContext.js +39 -44
  533. package/lib/components/Grid/Row.js +35 -53
  534. package/lib/components/Heading/index.js +39 -53
  535. package/lib/components/Icon/Icon.Skeleton.js +25 -23
  536. package/lib/components/IconButton/index.js +121 -180
  537. package/lib/components/IconIndicator/index.d.ts +1 -1
  538. package/lib/components/IconIndicator/index.js +63 -63
  539. package/lib/components/IdPrefix/index.js +24 -19
  540. package/lib/components/InlineCheckbox/InlineCheckbox.js +72 -117
  541. package/lib/components/InlineCheckbox/index.js +12 -9
  542. package/lib/components/InlineLoading/InlineLoading.js +87 -104
  543. package/lib/components/InlineLoading/index.js +12 -9
  544. package/lib/components/Layer/LayerContext.js +14 -6
  545. package/lib/components/Layer/LayerLevel.js +20 -6
  546. package/lib/components/Layer/index.js +58 -68
  547. package/lib/components/Layout/index.js +81 -111
  548. package/lib/components/LayoutDirection/LayoutDirection.d.ts +1 -1
  549. package/lib/components/LayoutDirection/LayoutDirection.js +36 -40
  550. package/lib/components/LayoutDirection/LayoutDirectionContext.js +14 -8
  551. package/lib/components/LayoutDirection/useLayoutDirection.js +16 -9
  552. package/lib/components/Link/Link.js +67 -112
  553. package/lib/components/Link/index.js +12 -9
  554. package/lib/components/ListBox/ListBox.js +82 -130
  555. package/lib/components/ListBox/ListBoxField.js +33 -47
  556. package/lib/components/ListBox/ListBoxMenu.js +39 -46
  557. package/lib/components/ListBox/ListBoxMenuIcon.js +43 -44
  558. package/lib/components/ListBox/ListBoxMenuItem.js +71 -92
  559. package/lib/components/ListBox/ListBoxPropTypes.js +21 -9
  560. package/lib/components/ListBox/ListBoxSelection.js +75 -100
  561. package/lib/components/ListBox/index.js +17 -21
  562. package/lib/components/ListBox/next/ListBoxSelection.js +83 -121
  563. package/lib/components/ListBox/next/ListBoxTrigger.js +48 -52
  564. package/lib/components/ListItem/ListItem.js +29 -32
  565. package/lib/components/Loading/Loading.js +68 -77
  566. package/lib/components/Loading/index.js +12 -9
  567. package/lib/components/Menu/Menu.js +224 -365
  568. package/lib/components/Menu/MenuContext.d.ts +1 -1
  569. package/lib/components/Menu/MenuContext.js +42 -40
  570. package/lib/components/Menu/MenuItem.js +286 -415
  571. package/lib/components/MenuButton/index.js +138 -197
  572. package/lib/components/Modal/Modal.js +504 -665
  573. package/lib/components/Modal/ModalPresence.js +41 -39
  574. package/lib/components/Modal/index.js +13 -10
  575. package/lib/components/ModalWrapper/ModalWrapper.d.ts +2 -2
  576. package/lib/components/ModalWrapper/ModalWrapper.js +112 -134
  577. package/lib/components/MultiSelect/FilterableMultiSelect.js +611 -920
  578. package/lib/components/MultiSelect/MultiSelect.js +459 -718
  579. package/lib/components/MultiSelect/MultiSelectPropTypes.js +15 -32
  580. package/lib/components/MultiSelect/filter.js +14 -10
  581. package/lib/components/MultiSelect/tools/sorting.js +21 -35
  582. package/lib/components/Notification/Notification.js +514 -787
  583. package/lib/components/NumberInput/NumberFormatPropTypes.js +72 -33
  584. package/lib/components/NumberInput/NumberInput.Skeleton.js +33 -37
  585. package/lib/components/NumberInput/NumberInput.js +571 -950
  586. package/lib/components/OrderedList/OrderedList.js +35 -48
  587. package/lib/components/OverflowMenu/OverflowMenu.js +341 -454
  588. package/lib/components/OverflowMenu/index.js +27 -21
  589. package/lib/components/OverflowMenu/next/index.js +158 -188
  590. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +104 -164
  591. package/lib/components/OverflowMenuItem/index.js +12 -9
  592. package/lib/components/OverflowMenuV2/index.js +25 -15
  593. package/lib/components/PageHeader/PageHeader.js +301 -444
  594. package/lib/components/PageHeader/index.js +27 -19
  595. package/lib/components/Pagination/Pagination.Skeleton.js +38 -37
  596. package/lib/components/Pagination/Pagination.d.ts +1 -1
  597. package/lib/components/Pagination/Pagination.js +256 -360
  598. package/lib/components/Pagination/experimental/PageSelector.js +48 -58
  599. package/lib/components/Pagination/experimental/Pagination-story.d.ts +114 -0
  600. package/lib/components/Pagination/experimental/Pagination.js +148 -200
  601. package/lib/components/PaginationNav/PaginationNav.js +324 -430
  602. package/lib/components/Popover/index.js +323 -440
  603. package/lib/components/PrimaryButton/PrimaryButton.js +19 -13
  604. package/lib/components/ProgressBar/ProgressBar.js +121 -147
  605. package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +46 -43
  606. package/lib/components/ProgressIndicator/ProgressIndicator.js +150 -245
  607. package/lib/components/RadioButton/RadioButton.Skeleton.js +27 -27
  608. package/lib/components/RadioButton/RadioButton.js +105 -178
  609. package/lib/components/RadioButton/index.js +12 -9
  610. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +139 -211
  611. package/lib/components/RadioTile/RadioTile.js +108 -172
  612. package/lib/components/RadioTile/index.js +12 -9
  613. package/lib/components/Search/Search.Skeleton.js +32 -38
  614. package/lib/components/Search/Search.js +185 -281
  615. package/lib/components/Search/index.js +13 -11
  616. package/lib/components/Search/utils.js +11 -4
  617. package/lib/components/SecondaryButton/SecondaryButton.js +19 -13
  618. package/lib/components/Select/Select.Skeleton.js +31 -35
  619. package/lib/components/Select/Select.js +182 -261
  620. package/lib/components/Select/index.js +13 -11
  621. package/lib/components/SelectItem/SelectItem.js +37 -52
  622. package/lib/components/SelectItem/index.js +12 -9
  623. package/lib/components/SelectItemGroup/SelectItemGroup.js +31 -41
  624. package/lib/components/ShapeIndicator/index.d.ts +1 -1
  625. package/lib/components/ShapeIndicator/index.js +78 -83
  626. package/lib/components/SkeletonIcon/SkeletonIcon.js +25 -28
  627. package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +25 -28
  628. package/lib/components/SkeletonText/SkeletonText.js +71 -85
  629. package/lib/components/SkeletonText/index.js +12 -9
  630. package/lib/components/Slider/Slider.Skeleton.js +72 -95
  631. package/lib/components/Slider/Slider.js +868 -1319
  632. package/lib/components/Slider/SliderHandles.js +75 -68
  633. package/lib/components/Stack/HStack.js +22 -14
  634. package/lib/components/Stack/Stack.js +60 -82
  635. package/lib/components/Stack/VStack.js +22 -14
  636. package/lib/components/StructuredList/StructuredList.Skeleton.js +59 -52
  637. package/lib/components/StructuredList/StructuredList.js +182 -319
  638. package/lib/components/Switch/IconSwitch.js +103 -149
  639. package/lib/components/Switch/Switch.js +70 -103
  640. package/lib/components/TabContent/TabContent.js +32 -38
  641. package/lib/components/Tabs/Tabs.Skeleton.js +45 -41
  642. package/lib/components/Tabs/Tabs.js +738 -1153
  643. package/lib/components/Tabs/usePressable.js +98 -114
  644. package/lib/components/Tag/DismissibleTag.js +123 -160
  645. package/lib/components/Tag/OperationalTag.js +95 -115
  646. package/lib/components/Tag/SelectableTag.js +98 -133
  647. package/lib/components/Tag/Tag.Skeleton.js +30 -32
  648. package/lib/components/Tag/Tag.js +156 -204
  649. package/lib/components/Tag/isEllipsisActive.js +13 -9
  650. package/lib/components/Text/Text.js +69 -81
  651. package/lib/components/Text/TextDirection.js +39 -39
  652. package/lib/components/Text/TextDirectionContext.js +15 -10
  653. package/lib/components/Text/createTextComponent.js +29 -22
  654. package/lib/components/TextArea/TextArea.Skeleton.js +29 -34
  655. package/lib/components/TextArea/TextArea.js +319 -426
  656. package/lib/components/TextArea/index.js +13 -11
  657. package/lib/components/TextInput/ControlledPasswordInput.js +137 -202
  658. package/lib/components/TextInput/PasswordInput.js +200 -307
  659. package/lib/components/TextInput/TextInput.Skeleton.js +28 -33
  660. package/lib/components/TextInput/TextInput.js +223 -321
  661. package/lib/components/TextInput/index.js +13 -11
  662. package/lib/components/TextInput/util.js +21 -26
  663. package/lib/components/Theme/index.js +83 -97
  664. package/lib/components/Tile/Tile.js +398 -595
  665. package/lib/components/TileGroup/TileGroup.js +73 -113
  666. package/lib/components/TimePicker/TimePicker.d.ts +1 -1
  667. package/lib/components/TimePicker/TimePicker.js +152 -251
  668. package/lib/components/TimePickerSelect/TimePickerSelect.js +47 -62
  669. package/lib/components/Toggle/Toggle.Skeleton.js +28 -24
  670. package/lib/components/Toggle/Toggle.js +106 -176
  671. package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +50 -53
  672. package/lib/components/Toggletip/index.d.ts +2 -2
  673. package/lib/components/Toggletip/index.js +174 -258
  674. package/lib/components/Tooltip/DefinitionTooltip.js +102 -140
  675. package/lib/components/Tooltip/Tooltip.js +192 -265
  676. package/lib/components/TreeView/TreeContext.js +14 -7
  677. package/lib/components/TreeView/TreeNode.js +365 -504
  678. package/lib/components/TreeView/TreeView.js +169 -242
  679. package/lib/components/UIShell/Content.js +27 -34
  680. package/lib/components/UIShell/Header.js +29 -33
  681. package/lib/components/UIShell/HeaderContainer.js +34 -44
  682. package/lib/components/UIShell/HeaderGlobalAction.js +69 -94
  683. package/lib/components/UIShell/HeaderGlobalBar.js +17 -14
  684. package/lib/components/UIShell/HeaderMenu.js +146 -221
  685. package/lib/components/UIShell/HeaderMenuButton.js +47 -70
  686. package/lib/components/UIShell/HeaderMenuItem.js +53 -80
  687. package/lib/components/UIShell/HeaderName.js +36 -48
  688. package/lib/components/UIShell/HeaderNavigation.js +36 -41
  689. package/lib/components/UIShell/HeaderPanel.js +78 -101
  690. package/lib/components/UIShell/HeaderSideNavItems.js +31 -37
  691. package/lib/components/UIShell/Link.js +32 -54
  692. package/lib/components/UIShell/SideNav.js +136 -245
  693. package/lib/components/UIShell/SideNavContext.js +23 -17
  694. package/lib/components/UIShell/SideNavDetails.js +33 -38
  695. package/lib/components/UIShell/SideNavDivider.js +25 -25
  696. package/lib/components/UIShell/SideNavFooter.js +47 -56
  697. package/lib/components/UIShell/SideNavHeader.js +30 -39
  698. package/lib/components/UIShell/SideNavIcon.js +32 -37
  699. package/lib/components/UIShell/SideNavItem.js +32 -37
  700. package/lib/components/UIShell/SideNavItems.js +35 -44
  701. package/lib/components/UIShell/SideNavLink.js +56 -83
  702. package/lib/components/UIShell/SideNavLinkText.js +28 -29
  703. package/lib/components/UIShell/SideNavMenu.js +106 -148
  704. package/lib/components/UIShell/SideNavMenuItem.js +44 -56
  705. package/lib/components/UIShell/SideNavSwitcher.js +63 -72
  706. package/lib/components/UIShell/SkipToContent.js +32 -40
  707. package/lib/components/UIShell/Switcher.js +73 -103
  708. package/lib/components/UIShell/SwitcherDivider.js +26 -28
  709. package/lib/components/UIShell/SwitcherItem.js +78 -118
  710. package/lib/components/UnorderedList/UnorderedList.js +32 -41
  711. package/lib/feature-flags.js +21 -13
  712. package/lib/index.js +622 -602
  713. package/lib/internal/FloatingMenu.js +249 -296
  714. package/lib/internal/OptimizedResize.js +35 -47
  715. package/lib/internal/Selection.js +102 -134
  716. package/lib/internal/clamp.js +12 -5
  717. package/lib/internal/defaultItemToString.js +15 -10
  718. package/lib/internal/deprecateFieldOnObject.js +23 -16
  719. package/lib/internal/environment.js +15 -8
  720. package/lib/internal/getAnnouncement.js +16 -14
  721. package/lib/internal/keyboard/keys.js +48 -49
  722. package/lib/internal/keyboard/match.js +25 -43
  723. package/lib/internal/keyboard/navigation.js +22 -29
  724. package/lib/internal/noopFn.js +10 -3
  725. package/lib/internal/useAttachedMenu.js +44 -53
  726. package/lib/internal/useControllableState.js +44 -50
  727. package/lib/internal/useDelayedState.js +31 -37
  728. package/lib/internal/useEvent.js +40 -37
  729. package/lib/internal/useId.js +54 -91
  730. package/lib/internal/useIdPrefix.js +15 -7
  731. package/lib/internal/useIsomorphicEffect.js +13 -8
  732. package/lib/internal/useMatchMedia.js +30 -23
  733. package/lib/internal/useMergedRefs.js +27 -24
  734. package/lib/internal/useNoInteractiveChildren.js +73 -101
  735. package/lib/internal/useNormalizedInputProps.js +55 -53
  736. package/lib/internal/useOutsideClick.js +22 -26
  737. package/lib/internal/useOverflowItems.js +90 -94
  738. package/lib/internal/usePrefix.js +15 -7
  739. package/lib/internal/usePresence.js +52 -56
  740. package/lib/internal/usePresenceContext.js +36 -37
  741. package/lib/internal/usePreviousValue.js +27 -20
  742. package/lib/internal/useResizeObserver.js +58 -68
  743. package/lib/internal/useSavedCallback.js +25 -19
  744. package/lib/internal/utils.js +18 -11
  745. package/lib/internal/warning.js +24 -23
  746. package/lib/internal/wrapFocus.js +78 -100
  747. package/lib/prop-types/AriaPropTypes.js +17 -9
  748. package/lib/prop-types/deprecate.js +30 -29
  749. package/lib/prop-types/deprecateComponent.js +17 -10
  750. package/lib/prop-types/deprecateValuesWithin.js +18 -23
  751. package/lib/prop-types/isRequiredOneOf.js +21 -25
  752. package/lib/prop-types/requiredIfGivenPropIsTruthy.js +14 -15
  753. package/lib/tools/events.js +17 -22
  754. package/lib/tools/mapPopoverAlign.js +19 -19
  755. package/lib/tools/mergeRefs.js +14 -18
  756. package/lib/tools/setupGetInstanceId.js +16 -9
  757. package/lib/tools/toggleClass.js +17 -10
  758. package/lib/tools/wrapComponent.js +38 -43
  759. package/package.json +10 -16
  760. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -40
  761. package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
  762. package/es/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -55
  763. package/es/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -23
  764. package/es/node_modules/es-toolkit/dist/function/debounce.js +0 -70
  765. package/lib/_virtual/_rollupPluginBabelHelpers.js +0 -45
  766. package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
  767. package/lib/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -57
  768. package/lib/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -25
  769. package/lib/node_modules/es-toolkit/dist/function/debounce.js +0 -72
@@ -1,979 +1,600 @@
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
- 'use strict';
9
-
10
- var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
11
- var iconsReact = require('@carbon/icons-react');
12
- var cx = require('classnames');
13
- var PropTypes = require('prop-types');
14
- var React = require('react');
15
- var useMergedRefs = require('../../internal/useMergedRefs.js');
16
- var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
17
- var usePrefix = require('../../internal/usePrefix.js');
18
- var deprecate = require('../../prop-types/deprecate.js');
19
- require('../FluidForm/FluidForm.js');
20
- var FormContext = require('../FluidForm/FormContext.js');
21
- var Text = require('../Text/Text.js');
22
- require('../Text/TextDirection.js');
23
- var clamp = require('../../internal/clamp.js');
24
- var useControllableState = require('../../internal/useControllableState.js');
25
- var utilities = require('@carbon/utilities');
26
- var keys = require('../../internal/keyboard/keys.js');
27
- var match = require('../../internal/keyboard/match.js');
28
- var NumberFormatPropTypes = require('./NumberFormatPropTypes.js');
29
- var index = require('../AILabel/index.js');
30
- var utils = require('../../internal/utils.js');
31
-
32
- var _Subtract, _Add;
8
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
9
+ const require_usePrefix = require('../../internal/usePrefix.js');
10
+ const require_Text = require('../Text/Text.js');
11
+ const require_keys = require('../../internal/keyboard/keys.js');
12
+ const require_match = require('../../internal/keyboard/match.js');
13
+ const require_deprecate = require('../../prop-types/deprecate.js');
14
+ const require_useMergedRefs = require('../../internal/useMergedRefs.js');
15
+ const require_index = require('../AILabel/index.js');
16
+ const require_utils = require('../../internal/utils.js');
17
+ const require_FormContext = require('../FluidForm/FormContext.js');
18
+ const require_useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
19
+ const require_useControllableState = require('../../internal/useControllableState.js');
20
+ const require_clamp = require('../../internal/clamp.js');
21
+ const require_NumberFormatPropTypes = require('./NumberFormatPropTypes.js');
22
+ let classnames = require("classnames");
23
+ classnames = require_runtime.__toESM(classnames);
24
+ let react = require("react");
25
+ react = require_runtime.__toESM(react);
26
+ let prop_types = require("prop-types");
27
+ prop_types = require_runtime.__toESM(prop_types);
28
+ let react_jsx_runtime = require("react/jsx-runtime");
29
+ let _carbon_icons_react = require("@carbon/icons-react");
30
+ let _carbon_utilities = require("@carbon/utilities");
31
+
32
+ //#region src/components/NumberInput/NumberInput.tsx
33
+ /**
34
+ * Copyright IBM Corp. 2016, 2026
35
+ *
36
+ * This source code is licensed under the Apache-2.0 license found in the
37
+ * LICENSE file in the root directory of this source tree.
38
+ */
33
39
  const translationIds = {
34
- 'increment.number': 'increment.number',
35
- 'decrement.number': 'decrement.number'
40
+ "increment.number": "increment.number",
41
+ "decrement.number": "decrement.number"
36
42
  };
37
43
  const defaultTranslations = {
38
- [translationIds['increment.number']]: 'Increment number',
39
- [translationIds['decrement.number']]: 'Decrement number'
44
+ [translationIds["increment.number"]]: "Increment number",
45
+ [translationIds["decrement.number"]]: "Decrement number"
40
46
  };
41
- const defaultTranslateWithId = messageId => {
42
- return defaultTranslations[messageId];
47
+ const defaultTranslateWithId = (messageId) => {
48
+ return defaultTranslations[messageId];
43
49
  };
44
- const getSeparators = locale => {
45
- const numberWithGroupAndDecimal = 1234567.89;
46
- const formatted = new Intl.NumberFormat(locale).format(numberWithGroupAndDecimal);
47
-
48
- // Comprehensive Unicode digit pattern that includes all common numeral systems
49
- // supported by Intl.NumberFormat across different locales
50
- const digitPattern = '[' + '\\u0030-\\u0039' +
51
- // Western
52
- '\\u0660-\\u0669' +
53
- // Eastern Arabic
54
- '\\u0966-\\u096F' +
55
- // Devanagari
56
- '\\u09E6-\\u09EF' +
57
- // Bengali
58
- '\\uFF10-\\uFF19' +
59
- // Fullwidth Japanese 0-9
60
- '一二三四五六七八九〇零' +
61
- // Kanji digits
62
- ']';
63
-
64
- // Non-digit pattern that excludes ALL digit types (not just ASCII 0-9)
65
- const nonDigitPattern = '[^' + '\\u0030-\\u0039' +
66
- // Western
67
- '\\u0660-\\u0669' +
68
- // Eastern Arabic
69
- '\\u0966-\\u096F' +
70
- // Devanagari
71
- '\\u09E6-\\u09EF' +
72
- // Bengali
73
- '\\uFF10-\\uFF19' +
74
- // Fullwidth Japanese 0-9
75
- '一二三四五六七八九〇零' +
76
- // Kanji digits
77
- ']+';
78
-
79
- // Extract separators using regex that handles all numeral systems
80
- // Use nonDigitPattern instead of \D+ to correctly identify separators
81
- const regex = new RegExp(`(${nonDigitPattern})${digitPattern}{3}(${nonDigitPattern})${digitPattern}{2}$`);
82
- const match = formatted.match(regex);
83
- if (match) {
84
- const groupSeparator = match[1];
85
- const decimalSeparator = match[2];
86
- return {
87
- groupSeparator,
88
- decimalSeparator
89
- };
90
- } else {
91
- return {
92
- groupSeparator: null,
93
- decimalSeparator: null
94
- };
95
- }
50
+ const getSeparators = (locale) => {
51
+ const formatted = new Intl.NumberFormat(locale).format(1234567.89);
52
+ const digitPattern = "[\\u0030-\\u0039\\u0660-\\u0669\\u0966-\\u096F\\u09E6-\\u09EF\\uFF10-\\uFF19一二三四五六七八九〇零]";
53
+ const nonDigitPattern = "[^\\u0030-\\u0039\\u0660-\\u0669\\u0966-\\u096F\\u09E6-\\u09EF\\uFF10-\\uFF19一二三四五六七八九〇零]+";
54
+ const regex = new RegExp(`(${nonDigitPattern})${digitPattern}{3}(${nonDigitPattern})${digitPattern}{2}$`);
55
+ const match = formatted.match(regex);
56
+ if (match) return {
57
+ groupSeparator: match[1],
58
+ decimalSeparator: match[2]
59
+ };
60
+ else return {
61
+ groupSeparator: null,
62
+ decimalSeparator: null
63
+ };
96
64
  };
97
-
98
- // Normalizes all Unicode minus variants to ASCII hyphen-minus (-)
99
- const normalizeMinus = value => value.replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, '-');
100
- const normalizeNumericInput = value => value
101
- // Remove bidi / direction control characters (Arabic keyboards)
102
- .replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, '')
103
- // Normalize Unicode minus variants to ASCII "-"
104
- .replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, '-');
65
+ const normalizeMinus = (value) => value.replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, "-");
66
+ const normalizeNumericInput = (value) => value.replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "").replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, "-");
105
67
  /**
106
- * Converts a string with any Unicode numeral system to a JavaScript number.
107
- * Handles all numeral systems supported by Intl.NumberFormat.
108
- *
109
- * @param {string} input - The input string with numerals in any Unicode system
110
- * @param {string} locale - The locale for parsing separators
111
- * @returns {number} The parsed number, or NaN if invalid
112
- */
68
+ * Converts a string with any Unicode numeral system to a JavaScript number.
69
+ * Handles all numeral systems supported by Intl.NumberFormat.
70
+ *
71
+ * @param {string} input - The input string with numerals in any Unicode system
72
+ * @param {string} locale - The locale for parsing separators
73
+ * @returns {number} The parsed number, or NaN if invalid
74
+ */
113
75
  const parseNumberWithLocale = (input, locale) => {
114
- // Handle empty, null, or undefined inputs
115
- if (input === '' || input === undefined || input === null) {
116
- return NaN;
117
- }
118
- input = normalizeNumericInput(input);
119
- const {
120
- groupSeparator,
121
- decimalSeparator
122
- } = getSeparators(locale);
123
-
124
- // Kanji digit map
125
- const kanjiMap = {
126
- 零: '0',
127
- 〇: '0',
128
- 一: '1',
129
- 二: '2',
130
- 三: '3',
131
- 四: '4',
132
- 五: '5',
133
- 六: '6',
134
- 七: '7',
135
- 八: '8',
136
- 九: '9'
137
- };
138
- const digitRanges = [{
139
- start: 0x0030,
140
- end: 0x0039,
141
- base: 0x0030
142
- }, {
143
- start: 0x0660,
144
- end: 0x0669,
145
- base: 0x0660
146
- }, {
147
- start: 0x0966,
148
- end: 0x096f,
149
- base: 0x0966
150
- }, {
151
- start: 0x09e6,
152
- end: 0x09ef,
153
- base: 0x09e6
154
- }, {
155
- start: 0xff10,
156
- end: 0xff19,
157
- base: 0xff10
158
- }];
159
- let normalized = Array.from(input).map(char => {
160
- // Preserve scientific notation characters
161
- if (char === 'e' || char === 'E' || char === '+' || char === '-') {
162
- return char;
163
- }
164
-
165
- // Check Kanji first
166
- if (kanjiMap[char] !== undefined) {
167
- return kanjiMap[char];
168
- }
169
- const code = char.charCodeAt(0);
170
- for (const range of digitRanges) {
171
- if (code >= range.start && code <= range.end) {
172
- return String(code - range.start);
173
- }
174
- }
175
- return char;
176
- }).join('');
177
-
178
- // Remove grouping separators
179
- if (groupSeparator) {
180
- if (groupSeparator?.trim() === '') {
181
- normalized = normalized?.replace(/[\u00A0\u202F\s]/g, '');
182
- } else {
183
- if (decimalSeparator !== ',' && decimalSeparator !== '٬') {
184
- normalized = normalized?.replace(/[,٬]/g, '');
185
- }
186
- if (groupSeparator !== ',' && groupSeparator !== '٬') {
187
- const escaped = groupSeparator?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
188
- normalized = normalized?.replace(new RegExp(escaped, 'g'), '');
189
- }
190
- }
191
- }
192
- normalized = normalized.replace(/٫/g, '.');
193
- if (decimalSeparator && decimalSeparator !== '.' && decimalSeparator !== '٫') {
194
- const escaped = decimalSeparator.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
195
- normalized = normalized.replace(new RegExp(escaped, 'g'), '.');
196
- }
197
- normalized = normalizeMinus(normalized);
198
- return Number(normalized);
76
+ if (input === "" || input === void 0 || input === null) return NaN;
77
+ input = normalizeNumericInput(input);
78
+ const { groupSeparator, decimalSeparator } = getSeparators(locale);
79
+ const kanjiMap = {
80
+ 零: "0",
81
+ 〇: "0",
82
+ 一: "1",
83
+ 二: "2",
84
+ 三: "3",
85
+ 四: "4",
86
+ 五: "5",
87
+ 六: "6",
88
+ 七: "7",
89
+ 八: "8",
90
+ 九: "9"
91
+ };
92
+ const digitRanges = [
93
+ {
94
+ start: 48,
95
+ end: 57,
96
+ base: 48
97
+ },
98
+ {
99
+ start: 1632,
100
+ end: 1641,
101
+ base: 1632
102
+ },
103
+ {
104
+ start: 2406,
105
+ end: 2415,
106
+ base: 2406
107
+ },
108
+ {
109
+ start: 2534,
110
+ end: 2543,
111
+ base: 2534
112
+ },
113
+ {
114
+ start: 65296,
115
+ end: 65305,
116
+ base: 65296
117
+ }
118
+ ];
119
+ let normalized = Array.from(input).map((char) => {
120
+ if (char === "e" || char === "E" || char === "+" || char === "-") return char;
121
+ if (kanjiMap[char] !== void 0) return kanjiMap[char];
122
+ const code = char.charCodeAt(0);
123
+ for (const range of digitRanges) if (code >= range.start && code <= range.end) return String(code - range.start);
124
+ return char;
125
+ }).join("");
126
+ if (groupSeparator) if (groupSeparator?.trim() === "") normalized = normalized?.replace(/[\u00A0\u202F\s]/g, "");
127
+ else {
128
+ if (decimalSeparator !== "," && decimalSeparator !== "٬") normalized = normalized?.replace(/[,٬]/g, "");
129
+ if (groupSeparator !== "," && groupSeparator !== "٬") {
130
+ const escaped = groupSeparator?.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
131
+ normalized = normalized?.replace(new RegExp(escaped, "g"), "");
132
+ }
133
+ }
134
+ normalized = normalized.replace(/٫/g, ".");
135
+ if (decimalSeparator && decimalSeparator !== "." && decimalSeparator !== "٫") {
136
+ const escaped = decimalSeparator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
137
+ normalized = normalized.replace(new RegExp(escaped, "g"), ".");
138
+ }
139
+ normalized = normalizeMinus(normalized);
140
+ return Number(normalized);
199
141
  };
200
142
  const validateNumberSeparators = (input, locale) => {
201
- if (input === '') {
202
- return true;
203
- }
204
-
205
- // Normalize bidi marks + minus signs FIRST
206
- input = normalizeNumericInput(input);
207
- const {
208
- groupSeparator,
209
- decimalSeparator
210
- } = getSeparators(locale);
211
- if (!decimalSeparator) {
212
- return !isNaN(Number(input));
213
- }
214
- const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
215
- const digit = '[' + '\\u0030-\\u0039' + '\\u0660-\\u0669' + '\\u0966-\\u096F' + '\\u09E6-\\u09EF' + '\\uFF10-\\uFF19' + '一二三四五六七八九〇零' + ']';
216
-
217
- // Group separator regex
218
- let group = '';
219
- if (groupSeparator) {
220
- if (groupSeparator?.trim() === '') {
221
- group = '[\\u00A0\\u202F\\s]';
222
- } else if (groupSeparator === ',' || groupSeparator === '٬') {
223
- group = '[,٬]';
224
- } else {
225
- group = esc(groupSeparator);
226
- }
227
- }
228
-
229
- // Decimal separator regex
230
- let decimal = esc(decimalSeparator);
231
- if (decimalSeparator === '.' || decimalSeparator === '٫') {
232
- decimal = '[.٫]';
233
- }
234
- const sign = '[\\-\\u2212]?';
235
- const scientific = `([eE][+-]?${digit}+)?`;
236
-
237
- // Detect if grouping is used AT ALL
238
- const usesGrouping = group && (groupSeparator?.trim() === '' ? /[\u00A0\u202F\s]/.test(input) : groupSeparator === ',' || groupSeparator === '٬' ? /[,٬]/.test(input) : groupSeparator ? input.includes(groupSeparator) : false);
239
- const scientificMatch = input?.match(/^([^eE]+)([eE][+-]?.*)?$/);
240
- const baseNumber = scientificMatch ? scientificMatch[1] : input;
241
-
242
- // Split integer part from the base number - handle both decimal separator variants
243
- let integerPart;
244
- if (decimalSeparator === '.' || decimalSeparator === '٫') {
245
- // Split by either . or ٫
246
- integerPart = baseNumber?.split(/[.,]/)[0];
247
- } else {
248
- integerPart = baseNumber?.split(decimalSeparator)[0];
249
- }
250
-
251
- // STEP 1: strict integer validation
252
- // When grouping is used, we need to handle two cases:
253
- // 1. Numbers with 1-3 digits (no separator required): 1, 12, 123
254
- // 2. Numbers with 4+ digits (separator required): 1,234 or 12,345 or 123,456
255
- const integerRegex = usesGrouping ? new RegExp(`^${sign}(${digit}{1,3}|${digit}{1,3}(${group}${digit}{3})+)$`) : new RegExp(`^${sign}${digit}+$`);
256
- if (!integerRegex.test(integerPart)) {
257
- return false;
258
- }
259
-
260
- // STEP 2: full number validation
261
- const fullRegex = new RegExp(`^${sign}${digit}+` + (usesGrouping ? `(${group}${digit}{3})*` : '') + `(${decimal}${digit}+)?${scientific}$`);
262
- return fullRegex.test(input);
143
+ if (input === "") return true;
144
+ input = normalizeNumericInput(input);
145
+ const { groupSeparator, decimalSeparator } = getSeparators(locale);
146
+ if (!decimalSeparator) return !isNaN(Number(input));
147
+ const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
148
+ const digit = "[\\u0030-\\u0039\\u0660-\\u0669\\u0966-\\u096F\\u09E6-\\u09EF\\uFF10-\\uFF19一二三四五六七八九〇零]";
149
+ let group = "";
150
+ if (groupSeparator) if (groupSeparator?.trim() === "") group = "[\\u00A0\\u202F\\s]";
151
+ else if (groupSeparator === "," || groupSeparator === "٬") group = "[,٬]";
152
+ else group = esc(groupSeparator);
153
+ let decimal = esc(decimalSeparator);
154
+ if (decimalSeparator === "." || decimalSeparator === "٫") decimal = "[.٫]";
155
+ const sign = "[\\-\\u2212]?";
156
+ const scientific = `([eE][+-]?${digit}+)?`;
157
+ const usesGrouping = group && (groupSeparator?.trim() === "" ? /[\u00A0\u202F\s]/.test(input) : groupSeparator === "," || groupSeparator === "٬" ? /[,٬]/.test(input) : groupSeparator ? input.includes(groupSeparator) : false);
158
+ const scientificMatch = input?.match(/^([^eE]+)([eE][+-]?.*)?$/);
159
+ const baseNumber = scientificMatch ? scientificMatch[1] : input;
160
+ let integerPart;
161
+ if (decimalSeparator === "." || decimalSeparator === "٫") integerPart = baseNumber?.split(/[.,]/)[0];
162
+ else integerPart = baseNumber?.split(decimalSeparator)[0];
163
+ if (!(usesGrouping ? new RegExp(`^${sign}(${digit}{1,3}|${digit}{1,3}(${group}${digit}{3})+)$`) : new RegExp(`^${sign}${digit}+$`)).test(integerPart)) return false;
164
+ return new RegExp(`^${sign}${digit}+` + (usesGrouping ? `(${group}${digit}{3})*` : "") + `(${decimal}${digit}+)?${scientific}$`).test(input);
263
165
  };
264
-
265
- // eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
266
- const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
267
- const {
268
- allowEmpty = false,
269
- className: customClassName,
270
- decorator,
271
- disabled = false,
272
- disableWheel: disableWheelProp = false,
273
- formatOptions,
274
- helperText = '',
275
- hideLabel = false,
276
- hideSteppers,
277
- iconDescription,
278
- id,
279
- inputMode = 'decimal',
280
- invalid = false,
281
- invalidText,
282
- label,
283
- light,
284
- locale = 'en-US',
285
- max,
286
- min,
287
- onBlur,
288
- onStepperBlur,
289
- onChange,
290
- onClick,
291
- onKeyUp,
292
- pattern = '[0-9]*',
293
- readOnly,
294
- size = 'md',
295
- slug,
296
- step = 1,
297
- translateWithId: t = defaultTranslateWithId,
298
- type = 'number',
299
- defaultValue = type === 'number' ? 0 : NaN,
300
- validate,
301
- warn = false,
302
- warnText = '',
303
- stepStartValue = 0,
304
- value: controlledValue,
305
- ...rest
306
- } = props;
307
- const prefix = usePrefix.usePrefix();
308
- const {
309
- isFluid
310
- } = React.useContext(FormContext.FormContext);
311
- const [isFocused, setIsFocused] = React.useState(false);
312
-
313
- /**
314
- * The input value, only used when type=number
315
- */
316
- const [value, setValue] = React.useState(() => {
317
- if (controlledValue !== undefined) {
318
- return controlledValue;
319
- }
320
- if (defaultValue !== undefined) {
321
- return defaultValue;
322
- }
323
- if (allowEmpty) {
324
- return '';
325
- }
326
- return 0;
327
- });
328
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
329
- const [prevControlledValue, setPrevControlledValue] = React.useState(controlledValue);
330
- const numberParser = React.useMemo(() => new utilities.NumberParser(locale, formatOptions), [locale, formatOptions]);
331
- /**
332
- * The currently parsed number value.
333
- * Only used when type=text
334
- * Updated based on the `value` as the user types.
335
- */
336
- const [numberValue, setNumberValue, isControlled] = useControllableState.useControllableState({
337
- name: 'NumberInput',
338
- defaultValue: typeof defaultValue === 'string' ? numberParser.parse(defaultValue) : defaultValue,
339
- value: typeof controlledValue === 'string' ? numberParser.parse(controlledValue) : controlledValue
340
- });
341
-
342
- /**
343
- * The number value that was previously "committed" to the input on blur
344
- * Only used when type="text"
345
- */
346
- const previousNumberValue = React.useRef(numberValue);
347
- /**
348
- * The current text value of the input.
349
- * Only used when type=text
350
- * Updated as the user types and formatted on blur.
351
- */
352
- const [inputValue, setInputValue] = React.useState(() => isNaN(numberValue) ? '' : new utilities.NumberFormatter(locale, formatOptions).format(numberValue));
353
- const numberingSystem = React.useMemo(() => numberParser.getNumberingSystem(inputValue), [numberParser, inputValue]);
354
- const numberFormatter = React.useMemo(() => new utilities.NumberFormatter(locale, {
355
- ...formatOptions,
356
- numberingSystem
357
- }), [locale, formatOptions, numberingSystem]);
358
- const format = React.useCallback(value => isNaN(value) || value === null ? '' : numberFormatter.format(value), [numberFormatter]);
359
- React.useEffect(() => {
360
- if (isControlled && !(isNaN(previousNumberValue.current) && isNaN(numberValue)) && previousNumberValue.current !== numberValue) {
361
- setInputValue(format(numberValue));
362
- previousNumberValue.current = numberValue;
363
- }
364
- }, [isControlled, numberValue, format]);
365
- const inputRef = React.useRef(null);
366
- const ref = useMergedRefs.useMergedRefs([forwardRef, inputRef]);
367
- const numberInputClasses = cx({
368
- [`${prefix}--number`]: true,
369
- [`${prefix}--number--helpertext`]: true,
370
- [`${prefix}--number--readonly`]: readOnly,
371
- [`${prefix}--number--light`]: light,
372
- [`${prefix}--number--nolabel`]: hideLabel,
373
- [`${prefix}--number--nosteppers`]: hideSteppers,
374
- [`${prefix}--number--${size}`]: size
375
- });
376
- const isInputValid = getInputValidity({
377
- allowEmpty,
378
- invalid,
379
- value: validate ? inputValue : type === 'number' ? value : numberValue,
380
- max,
381
- min,
382
- validate,
383
- locale
384
- });
385
- const normalizedProps = useNormalizedInputProps.useNormalizedInputProps({
386
- id,
387
- readOnly,
388
- disabled,
389
- invalid: !isInputValid,
390
- invalidText,
391
- warn,
392
- warnText
393
- });
394
- const [incrementNumLabel, decrementNumLabel] = [t('increment.number'), t('decrement.number')];
395
- const wrapperClasses = cx(`${prefix}--number__input-wrapper`, {
396
- [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
397
- [`${prefix}--number__input-wrapper--slug`]: slug,
398
- [`${prefix}--number__input-wrapper--decorator`]: decorator
399
- });
400
- const iconClasses = cx({
401
- [`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
402
- [`${prefix}--number__invalid--warning`]: normalizedProps.warn
403
- });
404
- React.useEffect(() => {
405
- if (type === 'number' && controlledValue !== undefined) {
406
- if (allowEmpty && controlledValue === '') {
407
- setValue('');
408
- } else {
409
- setValue(controlledValue);
410
- }
411
- setPrevControlledValue(controlledValue);
412
- }
413
- }, [controlledValue, type, allowEmpty]);
414
- let ariaDescribedBy = undefined;
415
- if (normalizedProps.invalid) {
416
- ariaDescribedBy = normalizedProps.invalidId;
417
- }
418
- if (normalizedProps.warn) {
419
- ariaDescribedBy = normalizedProps.warnId;
420
- }
421
- if (!normalizedProps.validation) {
422
- ariaDescribedBy = helperText ? normalizedProps.helperId : undefined;
423
- }
424
- function handleOnChange(event) {
425
- if (disabled) {
426
- return;
427
- }
428
- if (type === 'number') {
429
- const state = {
430
- value: allowEmpty && event.target.value === '' ? '' : Number(event.target.value),
431
- direction: value < event.target.value ? 'up' : 'down'
432
- };
433
- setValue(state.value);
434
- if (onChange) {
435
- onChange(event, state);
436
- }
437
- return;
438
- }
439
- if (type === 'text') {
440
- const _value = allowEmpty && event.target.value === '' ? '' : event.target.value;
441
- setNumberValue(numberParser.parse(_value));
442
- setInputValue(_value);
443
- // The onChange prop isn't called here because it will be called on blur
444
- // or on click of a stepper, after the number is parsed and formatted
445
- // according to the locale.
446
- }
447
- }
448
- const handleFocus = evt => {
449
- if ('type' in evt.target && evt.target.type === 'button') {
450
- setIsFocused(false);
451
- } else {
452
- setIsFocused(evt.type === 'focus');
453
- }
454
- };
455
- const outerElementClasses = cx(`${prefix}--form-item`, {
456
- ...(customClassName ? {
457
- [customClassName]: true
458
- } : {}),
459
- [`${prefix}--number-input--fluid--invalid`]: isFluid && normalizedProps.invalid,
460
- [`${prefix}--number-input--fluid--focus`]: isFluid && isFocused,
461
- [`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
462
- });
463
-
464
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
465
- const Icon = normalizedProps.icon;
466
- const getDecimalPlaces = num => {
467
- const parts = num.toString().split('.');
468
- return parts[1] ? parts[1].length : 0;
469
- };
470
- const handleStep = (event, direction) => {
471
- if (inputRef.current) {
472
- const currentValue = type === 'number' ? Number(inputRef.current.value) : numberValue;
473
- let rawValue;
474
- if (Number.isNaN(currentValue) || !currentValue) {
475
- if (typeof stepStartValue === 'number' && stepStartValue) {
476
- rawValue = stepStartValue;
477
- } else if (min && min < 0 && max && max > 0 || !max && !min || max) {
478
- if (direction === `up`) rawValue = 1;
479
- if (direction === `down`) rawValue = -1;
480
- } else if (min && min > 0 && max && max > 0 || min) {
481
- rawValue = min;
482
- } else {
483
- rawValue = 0;
484
- }
485
- } else if (direction === 'up') {
486
- rawValue = currentValue + step;
487
- } else {
488
- rawValue = currentValue - step;
489
- }
490
- const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
491
- const floatValue = parseFloat(Number(rawValue).toFixed(precision));
492
- const newValue = clamp.clamp(floatValue, min ?? -Infinity, max ?? Infinity);
493
- const state = {
494
- value: newValue,
495
- direction
496
- };
497
- if (type === 'number') {
498
- setValue(state.value);
499
- }
500
- if (type === 'text') {
501
- // Calling format() can alter the number (such as rounding it) causing
502
- // the numberValue to mismatch the formatted value in the input.
503
- // To avoid this, the newValue is re-parsed after formatting.
504
- const formattedNewValue = format(newValue);
505
- const parsedFormattedNewValue = numberParser.parse(formattedNewValue);
506
-
507
- // When isControlled, setNumberValue will not actually update
508
- // numberValue in useControllableState.
509
- setNumberValue(parsedFormattedNewValue);
510
- setInputValue(formattedNewValue);
511
- previousNumberValue.current = parsedFormattedNewValue;
512
- }
513
- if (onChange) {
514
- onChange(event, state);
515
- }
516
- return state;
517
- }
518
- };
519
- const handleStepperClick = (event, direction) => {
520
- if (inputRef.current) {
521
- const state = handleStep(event, direction);
522
- if (onClick) {
523
- onClick(event, state);
524
- }
525
- }
526
- };
527
-
528
- // AILabel always size `mini`
529
- const candidate = slug ?? decorator;
530
- const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
531
- const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
532
- size: 'mini'
533
- }) : candidate;
534
-
535
- // Need to update the internal value when the revert button is clicked
536
- const isRevertActive = utils.isComponentElement(normalizedDecorator, index.AILabel) ? normalizedDecorator.props.revertActive : undefined;
537
- React.useEffect(() => {
538
- if (!isRevertActive && slug && defaultValue) {
539
- setValue(defaultValue);
540
- }
541
- }, [defaultValue, isRevertActive, slug]);
542
- return /*#__PURE__*/React.createElement("div", {
543
- className: outerElementClasses,
544
- onFocus: isFluid ? handleFocus : undefined,
545
- onBlur: isFluid ? handleFocus : undefined
546
- }, /*#__PURE__*/React.createElement("div", {
547
- className: numberInputClasses,
548
- "data-invalid": normalizedProps.invalid ? true : undefined
549
- }, /*#__PURE__*/React.createElement(Label, {
550
- disabled: normalizedProps.disabled,
551
- hideLabel: hideLabel,
552
- id: id,
553
- label: label
554
- }), /*#__PURE__*/React.createElement("div", {
555
- className: wrapperClasses
556
- }, /*#__PURE__*/React.createElement("input", _rollupPluginBabelHelpers.extends({}, rest, {
557
- "data-invalid": normalizedProps.invalid ? true : undefined,
558
- "aria-invalid": normalizedProps.invalid,
559
- "aria-describedby": ariaDescribedBy,
560
- "aria-readonly": readOnly,
561
- disabled: normalizedProps.disabled,
562
- ref: ref,
563
- id: id,
564
- max: max,
565
- min: min,
566
- onClick: onClick,
567
- onChange: handleOnChange,
568
- onKeyUp: onKeyUp,
569
- onKeyDown: e => {
570
- if (type === 'text') {
571
- if (match.match(e, keys.ArrowUp)) {
572
- handleStep(e, 'up');
573
- } else if (match.match(e, keys.ArrowDown)) {
574
- handleStep(e, 'down');
575
- }
576
- }
577
- if (rest?.onKeyDown) {
578
- rest?.onKeyDown(e);
579
- }
580
- },
581
- onFocus: e => {
582
- if (disableWheelProp) {
583
- e.target.addEventListener('wheel', disableWheel);
584
- }
585
- if (rest.onFocus) {
586
- rest.onFocus(e);
587
- }
588
- },
589
- onBlur: e => {
590
- if (disableWheelProp) {
591
- e.target.removeEventListener('wheel', disableWheel);
592
- }
593
- let parsedValueForBlur;
594
- if (type === 'text') {
595
- // When isControlled, the current inputValue needs re-parsed
596
- // because the consumer's onChange hasn't been called yet and
597
- // the `numberValue` we have in state is the (stale) value
598
- // they've passed in.
599
- const _numberValue = isControlled ? numberParser.parse(inputValue) : numberValue;
600
- const formattedValue = isNaN(_numberValue) ? '' : format(_numberValue);
601
- const rawValue = e.target.value;
602
- // Validate raw input
603
- const isValid = validate ? validate(rawValue, locale) : true;
604
- setInputValue(isValid ? formattedValue : rawValue);
605
- // Calling format() can alter the number (such as rounding it)
606
- // causing the _numberValue to mismatch the formatted value in
607
- // the input. To avoid this, formattedValue is re-parsed.
608
- const parsedFormattedNewValue = numberParser.parse(formattedValue);
609
- parsedValueForBlur = parsedFormattedNewValue;
610
- if (onChange && isValid) {
611
- const state = {
612
- value: parsedFormattedNewValue,
613
- direction: previousNumberValue.current < parsedFormattedNewValue ? 'up' : 'down'
614
- };
615
-
616
- // If the old and new values are NaN, don't call onChange
617
- // to avoid an unnecessary re-render and potential infinite
618
- // loop when isControlled.
619
- if (!(isNaN(previousNumberValue.current) && isNaN(parsedFormattedNewValue))) {
620
- onChange(e, state);
621
- }
622
- }
623
-
624
- // If the old and new values are NaN, don't set state to avoid
625
- // an unnecessary re-render and potential infinite loop when
626
- // isControlled.
627
- if (!(isNaN(previousNumberValue.current) && isNaN(numberValue))) {
628
- previousNumberValue.current = numberValue;
629
- }
630
- if (!(isNaN(numberValue) && isNaN(parsedFormattedNewValue))) {
631
- setNumberValue(parsedFormattedNewValue);
632
- }
633
- }
634
- if (onBlur) {
635
- if (type === 'number') {
636
- onBlur(e, value);
637
- return;
638
- }
639
- const parsedTextValue = parsedValueForBlur ?? (isControlled ? numberParser.parse(inputValue) : numberValue);
640
- onBlur(e, parsedTextValue);
641
- }
642
- },
643
- pattern: pattern,
644
- inputMode: inputMode,
645
- readOnly: readOnly,
646
- step: step,
647
- type: type,
648
- value: type === 'number' ? value : inputValue
649
- })), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
650
- className: `${prefix}--number__input-inner-wrapper--decorator`
651
- }, normalizedDecorator) : '', Icon ? /*#__PURE__*/React.createElement(Icon, {
652
- className: iconClasses
653
- }) : null, !hideSteppers && /*#__PURE__*/React.createElement("div", {
654
- className: `${prefix}--number__controls`
655
- }, /*#__PURE__*/React.createElement("button", {
656
- "aria-label": decrementNumLabel || iconDescription,
657
- className: `${prefix}--number__control-btn down-icon`,
658
- disabled: disabled || readOnly,
659
- onClick: event => handleStepperClick(event, 'down'),
660
- onBlur: onStepperBlur,
661
- tabIndex: -1,
662
- title: decrementNumLabel || iconDescription,
663
- type: "button"
664
- }, _Subtract || (_Subtract = /*#__PURE__*/React.createElement(iconsReact.Subtract, {
665
- className: "down-icon"
666
- }))), /*#__PURE__*/React.createElement("div", {
667
- className: `${prefix}--number__rule-divider`
668
- }), /*#__PURE__*/React.createElement("button", {
669
- "aria-label": incrementNumLabel || iconDescription,
670
- className: `${prefix}--number__control-btn up-icon`,
671
- disabled: disabled || readOnly,
672
- onClick: event => handleStepperClick(event, 'up'),
673
- onBlur: onStepperBlur,
674
- tabIndex: -1,
675
- title: incrementNumLabel || iconDescription,
676
- type: "button"
677
- }, _Add || (_Add = /*#__PURE__*/React.createElement(iconsReact.Add, {
678
- className: "up-icon"
679
- }))), /*#__PURE__*/React.createElement("div", {
680
- className: `${prefix}--number__rule-divider`
681
- }))), isFluid && /*#__PURE__*/React.createElement("hr", {
682
- className: `${prefix}--number-input__divider`
683
- }), normalizedProps.validation ? normalizedProps.validation : /*#__PURE__*/React.createElement(HelperText, {
684
- id: normalizedProps.helperId,
685
- disabled: disabled,
686
- description: helperText
687
- })));
166
+ const NumberInput = react.default.forwardRef((props, forwardRef) => {
167
+ const { allowEmpty = false, className: customClassName, decorator, disabled = false, disableWheel: disableWheelProp = false, formatOptions, helperText = "", hideLabel = false, hideSteppers, iconDescription, id, inputMode = "decimal", invalid = false, invalidText, label, light, locale = "en-US", max, min, onBlur, onStepperBlur, onChange, onClick, onKeyUp, pattern = "[0-9]*", readOnly, size = "md", slug, step = 1, translateWithId: t = defaultTranslateWithId, type = "number", defaultValue = type === "number" ? 0 : NaN, validate, warn = false, warnText = "", stepStartValue = 0, value: controlledValue, ...rest } = props;
168
+ const prefix = require_usePrefix.usePrefix();
169
+ const { isFluid } = (0, react.useContext)(require_FormContext.FormContext);
170
+ const [isFocused, setIsFocused] = (0, react.useState)(false);
171
+ /**
172
+ * The input value, only used when type=number
173
+ */
174
+ const [value, setValue] = (0, react.useState)(() => {
175
+ if (controlledValue !== void 0) return controlledValue;
176
+ if (defaultValue !== void 0) return defaultValue;
177
+ if (allowEmpty) return "";
178
+ return 0;
179
+ });
180
+ const numberParser = (0, react.useMemo)(() => new _carbon_utilities.NumberParser(locale, formatOptions), [locale, formatOptions]);
181
+ /**
182
+ * The currently parsed number value.
183
+ * Only used when type=text
184
+ * Updated based on the `value` as the user types.
185
+ */
186
+ const [numberValue, setNumberValue, isControlled] = require_useControllableState.useControllableState({
187
+ name: "NumberInput",
188
+ defaultValue: typeof defaultValue === "string" ? numberParser.parse(defaultValue) : defaultValue,
189
+ value: typeof controlledValue === "string" ? numberParser.parse(controlledValue) : controlledValue
190
+ });
191
+ /**
192
+ * The number value that was previously "committed" to the input on blur
193
+ * Only used when type="text"
194
+ */
195
+ const previousNumberValue = (0, react.useRef)(numberValue);
196
+ /**
197
+ * The current text value of the input.
198
+ * Only used when type=text
199
+ * Updated as the user types and formatted on blur.
200
+ */
201
+ const [inputValue, setInputValue] = react.default.useState(() => isNaN(numberValue) ? "" : new _carbon_utilities.NumberFormatter(locale, formatOptions).format(numberValue));
202
+ const numberingSystem = (0, react.useMemo)(() => numberParser.getNumberingSystem(inputValue), [numberParser, inputValue]);
203
+ const numberFormatter = (0, react.useMemo)(() => new _carbon_utilities.NumberFormatter(locale, {
204
+ ...formatOptions,
205
+ numberingSystem
206
+ }), [
207
+ locale,
208
+ formatOptions,
209
+ numberingSystem
210
+ ]);
211
+ const format = (0, react.useCallback)((value) => isNaN(value) || value === null ? "" : numberFormatter.format(value), [numberFormatter]);
212
+ (0, react.useEffect)(() => {
213
+ if (isControlled && !(isNaN(previousNumberValue.current) && isNaN(numberValue)) && previousNumberValue.current !== numberValue) {
214
+ setInputValue(format(numberValue));
215
+ previousNumberValue.current = numberValue;
216
+ }
217
+ }, [
218
+ isControlled,
219
+ numberValue,
220
+ format
221
+ ]);
222
+ const inputRef = (0, react.useRef)(null);
223
+ const ref = require_useMergedRefs.useMergedRefs([forwardRef, inputRef]);
224
+ const numberInputClasses = (0, classnames.default)({
225
+ [`${prefix}--number`]: true,
226
+ [`${prefix}--number--helpertext`]: true,
227
+ [`${prefix}--number--readonly`]: readOnly,
228
+ [`${prefix}--number--light`]: light,
229
+ [`${prefix}--number--nolabel`]: hideLabel,
230
+ [`${prefix}--number--nosteppers`]: hideSteppers,
231
+ [`${prefix}--number--${size}`]: size
232
+ });
233
+ const normalizedProps = require_useNormalizedInputProps.useNormalizedInputProps({
234
+ id,
235
+ readOnly,
236
+ disabled,
237
+ invalid: !getInputValidity({
238
+ allowEmpty,
239
+ invalid,
240
+ value: validate ? inputValue : type === "number" ? value : numberValue,
241
+ max,
242
+ min,
243
+ validate,
244
+ locale
245
+ }),
246
+ invalidText,
247
+ warn,
248
+ warnText
249
+ });
250
+ const [incrementNumLabel, decrementNumLabel] = [t("increment.number"), t("decrement.number")];
251
+ const wrapperClasses = (0, classnames.default)(`${prefix}--number__input-wrapper`, {
252
+ [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
253
+ [`${prefix}--number__input-wrapper--slug`]: slug,
254
+ [`${prefix}--number__input-wrapper--decorator`]: decorator
255
+ });
256
+ const iconClasses = (0, classnames.default)({
257
+ [`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
258
+ [`${prefix}--number__invalid--warning`]: normalizedProps.warn
259
+ });
260
+ (0, react.useEffect)(() => {
261
+ if (type === "number" && controlledValue !== void 0) if (allowEmpty && controlledValue === "") setValue("");
262
+ else setValue(controlledValue);
263
+ }, [
264
+ controlledValue,
265
+ type,
266
+ allowEmpty
267
+ ]);
268
+ let ariaDescribedBy = void 0;
269
+ if (normalizedProps.invalid) ariaDescribedBy = normalizedProps.invalidId;
270
+ if (normalizedProps.warn) ariaDescribedBy = normalizedProps.warnId;
271
+ if (!normalizedProps.validation) ariaDescribedBy = helperText ? normalizedProps.helperId : void 0;
272
+ function handleOnChange(event) {
273
+ if (disabled) return;
274
+ if (type === "number") {
275
+ const state = {
276
+ value: allowEmpty && event.target.value === "" ? "" : Number(event.target.value),
277
+ direction: value < event.target.value ? "up" : "down"
278
+ };
279
+ setValue(state.value);
280
+ if (onChange) onChange(event, state);
281
+ return;
282
+ }
283
+ if (type === "text") {
284
+ const _value = allowEmpty && event.target.value === "" ? "" : event.target.value;
285
+ setNumberValue(numberParser.parse(_value));
286
+ setInputValue(_value);
287
+ }
288
+ }
289
+ const handleFocus = (evt) => {
290
+ if ("type" in evt.target && evt.target.type === "button") setIsFocused(false);
291
+ else setIsFocused(evt.type === "focus");
292
+ };
293
+ const outerElementClasses = (0, classnames.default)(`${prefix}--form-item`, {
294
+ ...customClassName ? { [customClassName]: true } : {},
295
+ [`${prefix}--number-input--fluid--invalid`]: isFluid && normalizedProps.invalid,
296
+ [`${prefix}--number-input--fluid--focus`]: isFluid && isFocused,
297
+ [`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
298
+ });
299
+ const Icon = normalizedProps.icon;
300
+ const getDecimalPlaces = (num) => {
301
+ const parts = num.toString().split(".");
302
+ return parts[1] ? parts[1].length : 0;
303
+ };
304
+ const handleStep = (event, direction) => {
305
+ if (inputRef.current) {
306
+ const currentValue = type === "number" ? Number(inputRef.current.value) : numberValue;
307
+ let rawValue;
308
+ if (Number.isNaN(currentValue) || !currentValue) if (typeof stepStartValue === "number" && stepStartValue) rawValue = stepStartValue;
309
+ else if (min && min < 0 && max && max > 0 || !max && !min || max) {
310
+ if (direction === `up`) rawValue = 1;
311
+ if (direction === `down`) rawValue = -1;
312
+ } else if (min && min > 0 && max && max > 0 || min) rawValue = min;
313
+ else rawValue = 0;
314
+ else if (direction === "up") rawValue = currentValue + step;
315
+ else rawValue = currentValue - step;
316
+ const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
317
+ const newValue = require_clamp.clamp(parseFloat(Number(rawValue).toFixed(precision)), min ?? -Infinity, max ?? Infinity);
318
+ const state = {
319
+ value: newValue,
320
+ direction
321
+ };
322
+ if (type === "number") setValue(state.value);
323
+ if (type === "text") {
324
+ const formattedNewValue = format(newValue);
325
+ const parsedFormattedNewValue = numberParser.parse(formattedNewValue);
326
+ setNumberValue(parsedFormattedNewValue);
327
+ setInputValue(formattedNewValue);
328
+ previousNumberValue.current = parsedFormattedNewValue;
329
+ }
330
+ if (onChange) onChange(event, state);
331
+ return state;
332
+ }
333
+ };
334
+ const handleStepperClick = (event, direction) => {
335
+ if (inputRef.current) {
336
+ const state = handleStep(event, direction);
337
+ if (onClick) onClick(event, state);
338
+ }
339
+ };
340
+ const candidate = slug ?? decorator;
341
+ const normalizedDecorator = require_utils.isComponentElement(candidate, require_index.AILabel) ? (0, react.cloneElement)(candidate, { size: "mini" }) : candidate;
342
+ const isRevertActive = require_utils.isComponentElement(normalizedDecorator, require_index.AILabel) ? normalizedDecorator.props.revertActive : void 0;
343
+ (0, react.useEffect)(() => {
344
+ if (!isRevertActive && slug && defaultValue) setValue(defaultValue);
345
+ }, [
346
+ defaultValue,
347
+ isRevertActive,
348
+ slug
349
+ ]);
350
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
351
+ className: outerElementClasses,
352
+ onFocus: isFluid ? handleFocus : void 0,
353
+ onBlur: isFluid ? handleFocus : void 0,
354
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
355
+ className: numberInputClasses,
356
+ "data-invalid": normalizedProps.invalid ? true : void 0,
357
+ children: [
358
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
359
+ disabled: normalizedProps.disabled,
360
+ hideLabel,
361
+ id,
362
+ label
363
+ }),
364
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
365
+ className: wrapperClasses,
366
+ children: [
367
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
368
+ ...rest,
369
+ "data-invalid": normalizedProps.invalid ? true : void 0,
370
+ "aria-invalid": normalizedProps.invalid,
371
+ "aria-describedby": ariaDescribedBy,
372
+ "aria-readonly": readOnly,
373
+ disabled: normalizedProps.disabled,
374
+ ref,
375
+ id,
376
+ max,
377
+ min,
378
+ onClick,
379
+ onChange: handleOnChange,
380
+ onKeyUp,
381
+ onKeyDown: (e) => {
382
+ if (type === "text") {
383
+ if (require_match.match(e, require_keys.ArrowUp)) handleStep(e, "up");
384
+ else if (require_match.match(e, require_keys.ArrowDown)) handleStep(e, "down");
385
+ }
386
+ if (rest?.onKeyDown) rest?.onKeyDown(e);
387
+ },
388
+ onFocus: (e) => {
389
+ if (disableWheelProp) e.target.addEventListener("wheel", disableWheel);
390
+ if (rest.onFocus) rest.onFocus(e);
391
+ },
392
+ onBlur: (e) => {
393
+ if (disableWheelProp) e.target.removeEventListener("wheel", disableWheel);
394
+ let parsedValueForBlur;
395
+ if (type === "text") {
396
+ const _numberValue = isControlled ? numberParser.parse(inputValue) : numberValue;
397
+ const formattedValue = isNaN(_numberValue) ? "" : format(_numberValue);
398
+ const rawValue = e.target.value;
399
+ const isValid = validate ? validate(rawValue, locale) : true;
400
+ setInputValue(isValid ? formattedValue : rawValue);
401
+ const parsedFormattedNewValue = numberParser.parse(formattedValue);
402
+ parsedValueForBlur = parsedFormattedNewValue;
403
+ if (onChange && isValid) {
404
+ const state = {
405
+ value: parsedFormattedNewValue,
406
+ direction: previousNumberValue.current < parsedFormattedNewValue ? "up" : "down"
407
+ };
408
+ if (!(isNaN(previousNumberValue.current) && isNaN(parsedFormattedNewValue))) onChange(e, state);
409
+ }
410
+ if (!(isNaN(previousNumberValue.current) && isNaN(numberValue))) previousNumberValue.current = numberValue;
411
+ if (!(isNaN(numberValue) && isNaN(parsedFormattedNewValue))) setNumberValue(parsedFormattedNewValue);
412
+ }
413
+ if (onBlur) {
414
+ if (type === "number") {
415
+ onBlur(e, value);
416
+ return;
417
+ }
418
+ onBlur(e, parsedValueForBlur ?? (isControlled ? numberParser.parse(inputValue) : numberValue));
419
+ }
420
+ },
421
+ pattern,
422
+ inputMode,
423
+ readOnly,
424
+ step,
425
+ type,
426
+ value: type === "number" ? value : inputValue
427
+ }),
428
+ slug ? normalizedDecorator : decorator ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
429
+ className: `${prefix}--number__input-inner-wrapper--decorator`,
430
+ children: normalizedDecorator
431
+ }) : "",
432
+ Icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { className: iconClasses }) : null,
433
+ !hideSteppers && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
434
+ className: `${prefix}--number__controls`,
435
+ children: [
436
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
437
+ "aria-label": decrementNumLabel || iconDescription,
438
+ className: `${prefix}--number__control-btn down-icon`,
439
+ disabled: disabled || readOnly,
440
+ onClick: (event) => handleStepperClick(event, "down"),
441
+ onBlur: onStepperBlur,
442
+ tabIndex: -1,
443
+ title: decrementNumLabel || iconDescription,
444
+ type: "button",
445
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.Subtract, { className: "down-icon" })
446
+ }),
447
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `${prefix}--number__rule-divider` }),
448
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
449
+ "aria-label": incrementNumLabel || iconDescription,
450
+ className: `${prefix}--number__control-btn up-icon`,
451
+ disabled: disabled || readOnly,
452
+ onClick: (event) => handleStepperClick(event, "up"),
453
+ onBlur: onStepperBlur,
454
+ tabIndex: -1,
455
+ title: incrementNumLabel || iconDescription,
456
+ type: "button",
457
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.Add, { className: "up-icon" })
458
+ }),
459
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `${prefix}--number__rule-divider` })
460
+ ]
461
+ })
462
+ ]
463
+ }),
464
+ isFluid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: `${prefix}--number-input__divider` }),
465
+ normalizedProps.validation ? normalizedProps.validation : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HelperText, {
466
+ id: normalizedProps.helperId,
467
+ disabled,
468
+ description: helperText
469
+ })
470
+ ]
471
+ })
472
+ });
688
473
  });
689
474
  NumberInput.propTypes = {
690
- /**
691
- * `true` to allow empty string.
692
- */
693
- allowEmpty: PropTypes.bool,
694
- /**
695
- * Specify an optional className to be applied to the wrapper node
696
- */
697
- className: PropTypes.string,
698
- /**
699
- * **Experimental**: Provide a `decorator` component to be rendered inside the `NumberInput` component
700
- */
701
- decorator: PropTypes.node,
702
- /**
703
- * Optional starting value for uncontrolled state
704
- */
705
- defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
706
- /**
707
- * Specify if the wheel functionality for the input should be disabled, or no t
708
- */
709
- disableWheel: PropTypes.bool,
710
- /**
711
- * Specify if the control should be disabled, or not
712
- */
713
- disabled: PropTypes.bool,
714
- /**
715
- * **Experimental:** Specify Intl.NumberFormat options applied to internal
716
- * number parsing and formatting. Use with `type="text"`, has no effect when
717
- * `type="number"`.
718
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
719
- */
720
- formatOptions: NumberFormatPropTypes.NumberFormatOptionsPropType,
721
- /**
722
- * Provide text that is used alongside the control label for additional help
723
- */
724
- helperText: PropTypes.node,
725
- /**
726
- * Specify whether you want the underlying label to be visually hidden
727
- */
728
- hideLabel: PropTypes.bool,
729
- /**
730
- * Specify whether you want the steppers to be hidden
731
- */
732
- hideSteppers: PropTypes.bool,
733
- /**
734
- * Provide a description for up/down icons that can be read by screen readers
735
- */
736
- iconDescription: PropTypes.string,
737
- /**
738
- * Specify a custom `id` for the input
739
- */
740
- id: PropTypes.string.isRequired,
741
- /**
742
- * Instruct the browser which keyboard to display on mobile devices. Defaults
743
- * to `decimal`, but note that standard numeric keyboards vary across devices
744
- * and operating systems.
745
- * @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
746
- */
747
- inputMode: PropTypes.oneOf(['none', 'text', 'tel', 'url', 'email', 'numeric', 'decimal', 'search']),
748
- /**
749
- * Specify if the currently value is invalid.
750
- */
751
- invalid: PropTypes.bool,
752
- /**
753
- * Message which is displayed if the value is invalid.
754
- */
755
- invalidText: PropTypes.node,
756
- /**
757
- * Generic `label` that will be used as the textual representation of what
758
- * this field is for
759
- */
760
- label: PropTypes.node,
761
- /**
762
- * `true` to use the light version.
763
- */
764
- light: deprecate.deprecate(PropTypes.bool, 'The `light` prop for `NumberInput` is no longer needed and has ' + 'been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release.'),
765
- /**
766
- * **Experimental:** Specify a [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt)
767
- * language code for parsing and formatting. Use with `type="text"`, has no
768
- * effect when `type="number"`.
769
- */
770
- locale: PropTypes.string,
771
- /**
772
- * The maximum value.
773
- */
774
- max: PropTypes.number,
775
- /**
776
- * The minimum value.
777
- */
778
- min: PropTypes.number,
779
- /**
780
- * Provide the value stepping should begin at when the input is empty
781
- */
782
- stepStartValue: PropTypes.number,
783
- /**
784
- * Provide an optional handler that is called when the input is blurred.
785
- */
786
- onBlur: PropTypes.func,
787
- /**
788
- * Provide an optional handler that is called when the stepper
789
- * buttons are blurred.
790
- */
791
- onStepperBlur: PropTypes.func,
792
- /**
793
- * Provide an optional handler that is called when the internal state of
794
- * NumberInput changes. This handler is called with event and state info.
795
- * When type="number", this is called on every change of the input.
796
- * When type="text", this is only called on blur after the number has been
797
- * parsed and formatted.
798
- * `(event, { value, direction }) => void`
799
- */
800
- onChange: PropTypes.func,
801
- /**
802
- * Provide an optional function to be called when the up/down button is clicked
803
- */
804
- onClick: PropTypes.func,
805
- /**
806
- * Provide an optional function to be called when a key is pressed in the number input
807
- */
808
- onKeyUp: PropTypes.func,
809
- /**
810
- * When type="text", provide an optional pattern to restrict user input. Has
811
- * no effect when type="number".
812
- */
813
- pattern: PropTypes.string,
814
- /**
815
- * Specify if the component should be read-only
816
- */
817
- readOnly: PropTypes.bool,
818
- /**
819
- * Specify the size of the Number Input.
820
- */
821
- size: PropTypes.oneOf(['sm', 'md', 'lg']),
822
- /**
823
- * **Experimental**: Provide a `Slug` component to be rendered inside the
824
- * `NumberInput` component
825
- */
826
- slug: deprecate.deprecate(PropTypes.node, 'The `slug` prop for `NumberInput` is no longer needed and has ' + 'been deprecated in v11 in favor of the new `decorator` prop. It will be moved in the next major release.'),
827
- /**
828
- * Specify how much the values should increase/decrease upon clicking on
829
- * up/down button
830
- */
831
- step: PropTypes.number,
832
- /**
833
- * Translates component strings using your i18n tool.
834
- */
835
- translateWithId: PropTypes.func,
836
- /**
837
- * **Experimental**: Specify if the input should be of type text or number.
838
- * Use type="text" with `locale`, `formatOptions`, and guide user input with
839
- * `pattern` and `inputMode`.
840
- */
841
- type: PropTypes.oneOf(['number', 'text']),
842
- /**
843
- * Specify the value of the input
844
- */
845
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
846
- /**
847
- * Specify whether the control is currently in warning state
848
- */
849
- warn: PropTypes.bool,
850
- /**
851
- * Provide the text that is displayed when the control is in warning state
852
- */
853
- warnText: PropTypes.node,
854
- /**
855
- * Optional validation function that is called with the input value and locale.
856
- *
857
- * - Return `false` to immediately fail validation.
858
- * - Return `true` to pass this validation, but still run other checks (min, max, required, etc.).
859
- * - Return `undefined` to defer entirely to built-in validation logic.
860
- *
861
- * This is called before other validations, giving consumers the ability
862
- * to short-circuit or extend validation without replacing built-in rules.
863
- */
864
- validate: PropTypes.func
475
+ allowEmpty: prop_types.default.bool,
476
+ className: prop_types.default.string,
477
+ decorator: prop_types.default.node,
478
+ defaultValue: prop_types.default.oneOfType([prop_types.default.number, prop_types.default.string]),
479
+ disableWheel: prop_types.default.bool,
480
+ disabled: prop_types.default.bool,
481
+ formatOptions: require_NumberFormatPropTypes.NumberFormatOptionsPropType,
482
+ helperText: prop_types.default.node,
483
+ hideLabel: prop_types.default.bool,
484
+ hideSteppers: prop_types.default.bool,
485
+ iconDescription: prop_types.default.string,
486
+ id: prop_types.default.string.isRequired,
487
+ inputMode: prop_types.default.oneOf([
488
+ "none",
489
+ "text",
490
+ "tel",
491
+ "url",
492
+ "email",
493
+ "numeric",
494
+ "decimal",
495
+ "search"
496
+ ]),
497
+ invalid: prop_types.default.bool,
498
+ invalidText: prop_types.default.node,
499
+ label: prop_types.default.node,
500
+ light: require_deprecate.deprecate(prop_types.default.bool, "The `light` prop for `NumberInput` is no longer needed and has been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release."),
501
+ locale: prop_types.default.string,
502
+ max: prop_types.default.number,
503
+ min: prop_types.default.number,
504
+ stepStartValue: prop_types.default.number,
505
+ onBlur: prop_types.default.func,
506
+ onStepperBlur: prop_types.default.func,
507
+ onChange: prop_types.default.func,
508
+ onClick: prop_types.default.func,
509
+ onKeyUp: prop_types.default.func,
510
+ pattern: prop_types.default.string,
511
+ readOnly: prop_types.default.bool,
512
+ size: prop_types.default.oneOf([
513
+ "sm",
514
+ "md",
515
+ "lg"
516
+ ]),
517
+ slug: require_deprecate.deprecate(prop_types.default.node, "The `slug` prop for `NumberInput` is no longer needed and has been deprecated in v11 in favor of the new `decorator` prop. It will be moved in the next major release."),
518
+ step: prop_types.default.number,
519
+ translateWithId: prop_types.default.func,
520
+ type: prop_types.default.oneOf(["number", "text"]),
521
+ value: prop_types.default.oneOfType([prop_types.default.number, prop_types.default.string]),
522
+ warn: prop_types.default.bool,
523
+ warnText: prop_types.default.node,
524
+ validate: prop_types.default.func
865
525
  };
866
- const Label = ({
867
- disabled,
868
- id,
869
- hideLabel,
870
- label
871
- }) => {
872
- const prefix = usePrefix.usePrefix();
873
- const className = cx({
874
- [`${prefix}--label`]: true,
875
- [`${prefix}--label--disabled`]: disabled,
876
- [`${prefix}--visually-hidden`]: hideLabel
877
- });
878
- if (label) {
879
- return /*#__PURE__*/React.createElement(Text.Text, {
880
- as: "label",
881
- htmlFor: id,
882
- className: className
883
- }, label);
884
- }
885
- return null;
526
+ const Label = ({ disabled, id, hideLabel, label }) => {
527
+ const prefix = require_usePrefix.usePrefix();
528
+ const className = (0, classnames.default)({
529
+ [`${prefix}--label`]: true,
530
+ [`${prefix}--label--disabled`]: disabled,
531
+ [`${prefix}--visually-hidden`]: hideLabel
532
+ });
533
+ if (label) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text.Text, {
534
+ as: "label",
535
+ htmlFor: id,
536
+ className,
537
+ children: label
538
+ });
539
+ return null;
886
540
  };
887
- const HelperText = ({
888
- disabled,
889
- description,
890
- id
891
- }) => {
892
- const prefix = usePrefix.usePrefix();
893
- const className = cx(`${prefix}--form__helper-text`, {
894
- [`${prefix}--form__helper-text--disabled`]: disabled
895
- });
896
- if (description) {
897
- return /*#__PURE__*/React.createElement(Text.Text, {
898
- as: "div",
899
- id: id,
900
- className: className
901
- }, description);
902
- }
903
- return null;
541
+ const HelperText = ({ disabled, description, id }) => {
542
+ const prefix = require_usePrefix.usePrefix();
543
+ const className = (0, classnames.default)(`${prefix}--form__helper-text`, { [`${prefix}--form__helper-text--disabled`]: disabled });
544
+ if (description) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text.Text, {
545
+ as: "div",
546
+ id,
547
+ className,
548
+ children: description
549
+ });
550
+ return null;
904
551
  };
905
-
906
552
  /**
907
- * Determine if the given value is invalid based on the given max, min and
908
- * conditions like `allowEmpty`. If `invalid` is passed through, it will default
909
- * to false.
910
- *
911
- * @param {object} config
912
- * @param {boolean} config.allowEmpty
913
- * @param {boolean} config.invalid
914
- * @param {number} config.value
915
- * @param {number} config.max
916
- * @param {number} config.min
917
- * @param {Function} config.validate
918
- * @param {string} config.locale
919
- * @returns {boolean}
920
- */
921
- function getInputValidity({
922
- allowEmpty,
923
- invalid,
924
- value,
925
- max,
926
- min,
927
- validate,
928
- locale
929
- }) {
930
- if (invalid) {
931
- return false;
932
- }
933
-
934
- // Skip validation if value is empty and allowEmpty
935
- if (value === '') return allowEmpty;
936
-
937
- // Normalize the value
938
- let numericValue;
939
- if (typeof value === 'string') {
940
- numericValue = parseNumberWithLocale(value, locale); // safe: handles Arabic, Kanji, etc.
941
- } else {
942
- numericValue = value;
943
- }
944
-
945
- // Use custom validate ONLY for formatting, not numeric comparison
946
- if (validate && typeof value === 'string') {
947
- const isFormatValid = validate(value, locale);
948
- if (isFormatValid === false) {
949
- return false; // invalid format
950
- }
951
- }
952
-
953
- // Check min/max bounds
954
- if (max !== undefined && numericValue > max) return false;
955
- if (min !== undefined && numericValue < min) return false;
956
- return true; // valid
553
+ * Determine if the given value is invalid based on the given max, min and
554
+ * conditions like `allowEmpty`. If `invalid` is passed through, it will default
555
+ * to false.
556
+ *
557
+ * @param {object} config
558
+ * @param {boolean} config.allowEmpty
559
+ * @param {boolean} config.invalid
560
+ * @param {number} config.value
561
+ * @param {number} config.max
562
+ * @param {number} config.min
563
+ * @param {Function} config.validate
564
+ * @param {string} config.locale
565
+ * @returns {boolean}
566
+ */
567
+ function getInputValidity({ allowEmpty, invalid, value, max, min, validate, locale }) {
568
+ if (invalid) return false;
569
+ if (value === "") return allowEmpty;
570
+ let numericValue;
571
+ if (typeof value === "string") numericValue = parseNumberWithLocale(value, locale);
572
+ else numericValue = value;
573
+ if (validate && typeof value === "string") {
574
+ if (validate(value, locale) === false) return false;
575
+ }
576
+ if (max !== void 0 && numericValue > max) return false;
577
+ if (min !== void 0 && numericValue < min) return false;
578
+ return true;
957
579
  }
958
-
959
580
  /**
960
- * It prevents any wheel event from emitting.
961
- *
962
- * We want to prevent this input field from changing by the user accidentally
963
- * when the user scrolling up or down in a long form. So we prevent the default
964
- * behavior of wheel events when it is focused.
965
- *
966
- * Because React uses passive event handler by default, we can't just call
967
- * `preventDefault` in the `onWheel` event handler. So we have to get the input
968
- * ref and add our event handler manually.
969
- *
970
- * @see https://github.com/facebook/react/pull/19654
971
- * @param {WheelEvent} e A wheel event.
972
- */
581
+ * It prevents any wheel event from emitting.
582
+ *
583
+ * We want to prevent this input field from changing by the user accidentally
584
+ * when the user scrolling up or down in a long form. So we prevent the default
585
+ * behavior of wheel events when it is focused.
586
+ *
587
+ * Because React uses passive event handler by default, we can't just call
588
+ * `preventDefault` in the `onWheel` event handler. So we have to get the input
589
+ * ref and add our event handler manually.
590
+ *
591
+ * @see https://github.com/facebook/react/pull/19654
592
+ * @param {WheelEvent} e A wheel event.
593
+ */
973
594
  function disableWheel(e) {
974
- e.preventDefault();
595
+ e.preventDefault();
975
596
  }
976
597
 
598
+ //#endregion
977
599
  exports.NumberInput = NumberInput;
978
- exports.parseNumberWithLocale = parseNumberWithLocale;
979
- exports.validateNumberSeparators = validateNumberSeparators;
600
+ exports.validateNumberSeparators = validateNumberSeparators;