@carbon/react 1.103.0-rc.0 → 1.104.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (777) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +950 -950
  2. package/es/_virtual/_rolldown/runtime.js +25 -0
  3. package/es/components/AILabel/index.d.ts +29 -2
  4. package/es/components/AILabel/index.js +114 -169
  5. package/es/components/AISkeleton/AISkeletonIcon.js +23 -27
  6. package/es/components/AISkeleton/AISkeletonPlaceholder.js +19 -27
  7. package/es/components/AISkeleton/AISkeletonText.js +26 -39
  8. package/es/components/Accordion/Accordion.Skeleton.js +55 -79
  9. package/es/components/Accordion/Accordion.js +43 -61
  10. package/es/components/Accordion/AccordionItem.js +102 -156
  11. package/es/components/Accordion/AccordionProvider.js +18 -15
  12. package/es/components/AspectRatio/AspectRatio.js +41 -47
  13. package/es/components/BadgeIndicator/index.js +28 -33
  14. package/es/components/Breadcrumb/Breadcrumb.Skeleton.js +39 -50
  15. package/es/components/Breadcrumb/Breadcrumb.js +39 -51
  16. package/es/components/Breadcrumb/BreadcrumbItem.js +80 -83
  17. package/es/components/Button/Button.Skeleton.js +49 -58
  18. package/es/components/Button/Button.d.ts +1 -1
  19. package/es/components/Button/Button.js +146 -240
  20. package/es/components/Button/ButtonBase.js +82 -104
  21. package/es/components/Button/index.js +13 -6
  22. package/es/components/ButtonSet/ButtonSet.js +74 -98
  23. package/es/components/ButtonSet/index.js +12 -4
  24. package/es/components/ChatButton/ChatButton.Skeleton.js +27 -27
  25. package/es/components/ChatButton/ChatButton.js +64 -79
  26. package/es/components/Checkbox/Checkbox.Skeleton.js +26 -25
  27. package/es/components/Checkbox/Checkbox.js +116 -195
  28. package/es/components/Checkbox/index.js +13 -5
  29. package/es/components/CheckboxGroup/CheckboxGroup.js +100 -148
  30. package/es/components/ClassPrefix/index.js +21 -17
  31. package/es/components/CodeSnippet/CodeSnippet.Skeleton.js +45 -42
  32. package/es/components/CodeSnippet/CodeSnippet.js +210 -299
  33. package/es/components/ComboBox/ComboBox.js +621 -970
  34. package/es/components/ComboBox/index.js +12 -4
  35. package/es/components/ComboButton/index.js +172 -208
  36. package/es/components/ComposedModal/ComposedModal.js +311 -450
  37. package/es/components/ComposedModal/ComposedModalPresence.js +47 -42
  38. package/es/components/ComposedModal/ModalFooter.js +127 -207
  39. package/es/components/ComposedModal/ModalHeader.js +71 -101
  40. package/es/components/ComposedModal/useComposedModalState.js +21 -15
  41. package/es/components/ContainedList/ContainedList.js +67 -102
  42. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +49 -67
  43. package/es/components/ContainedList/ContainedListItem/index.js +12 -4
  44. package/es/components/ContainedList/index.js +15 -12
  45. package/es/components/ContentSwitcher/ContentSwitcher.js +108 -140
  46. package/es/components/ContextMenu/useContextMenu.js +41 -36
  47. package/es/components/Copy/Copy.js +97 -117
  48. package/es/components/Copy/index.js +12 -4
  49. package/es/components/CopyButton/CopyButton.js +81 -94
  50. package/es/components/CopyButton/index.js +12 -4
  51. package/es/components/DangerButton/DangerButton.js +11 -9
  52. package/es/components/DataTable/DataTable.d.ts +11 -11
  53. package/es/components/DataTable/DataTable.js +448 -630
  54. package/es/components/DataTable/Table.js +111 -156
  55. package/es/components/DataTable/TableActionList.js +14 -6
  56. package/es/components/DataTable/TableBatchAction.js +25 -34
  57. package/es/components/DataTable/TableBatchActions.js +78 -113
  58. package/es/components/DataTable/TableBody.js +26 -19
  59. package/es/components/DataTable/TableCell.js +31 -46
  60. package/es/components/DataTable/TableContainer.js +75 -82
  61. package/es/components/DataTable/TableContext.js +14 -6
  62. package/es/components/DataTable/TableDecoratorRow.js +30 -36
  63. package/es/components/DataTable/TableExpandHeader.js +53 -90
  64. package/es/components/DataTable/TableExpandRow.js +82 -119
  65. package/es/components/DataTable/TableExpandedRow.js +45 -51
  66. package/es/components/DataTable/TableHead.js +7 -5
  67. package/es/components/DataTable/TableHeader.js +138 -181
  68. package/es/components/DataTable/TableRow.d.ts +1 -1
  69. package/es/components/DataTable/TableRow.js +42 -76
  70. package/es/components/DataTable/TableSelectAll.js +42 -70
  71. package/es/components/DataTable/TableSelectRow.js +63 -98
  72. package/es/components/DataTable/TableSlugRow.js +35 -43
  73. package/es/components/DataTable/TableToolbar.js +33 -45
  74. package/es/components/DataTable/TableToolbarAction.js +25 -20
  75. package/es/components/DataTable/TableToolbarContent.js +14 -6
  76. package/es/components/DataTable/TableToolbarMenu.js +35 -46
  77. package/es/components/DataTable/TableToolbarSearch.js +97 -187
  78. package/es/components/DataTable/state/getDerivedStateFromProps.js +38 -43
  79. package/es/components/DataTable/state/sortStates.js +11 -9
  80. package/es/components/DataTable/state/sorting.js +53 -72
  81. package/es/components/DataTable/tools/cells.js +15 -7
  82. package/es/components/DataTable/tools/denormalize.js +27 -19
  83. package/es/components/DataTable/tools/filter.js +21 -22
  84. package/es/components/DataTable/tools/normalize.js +57 -72
  85. package/es/components/DataTable/tools/sorting.js +50 -71
  86. package/es/components/DataTableSkeleton/DataTableSkeleton.js +66 -94
  87. package/es/components/DatePicker/DatePicker.Skeleton.js +44 -51
  88. package/es/components/DatePicker/DatePicker.d.ts +4 -2
  89. package/es/components/DatePicker/DatePicker.js +485 -749
  90. package/es/components/DatePicker/DatePickerLocales.js +75 -126
  91. package/es/components/DatePicker/index.js +13 -5
  92. package/es/components/DatePicker/plugins/appendToPlugin.js +31 -45
  93. package/es/components/DatePicker/plugins/fixEventsPlugin.js +127 -171
  94. package/es/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
  95. package/es/components/DatePicker/plugins/rangePlugin.js +40 -47
  96. package/es/components/DatePicker/utils.d.ts +7 -0
  97. package/es/components/DatePicker/utils.js +18 -0
  98. package/es/components/DatePickerInput/DatePickerInput.js +179 -289
  99. package/es/components/DatePickerInput/index.js +12 -4
  100. package/es/components/Dialog/Dialog.js +303 -574
  101. package/es/components/Dialog/index.js +18 -2
  102. package/es/components/Dropdown/Dropdown.Skeleton.js +26 -38
  103. package/es/components/Dropdown/Dropdown.js +344 -535
  104. package/es/components/Dropdown/index.js +13 -5
  105. package/es/components/ErrorBoundary/ErrorBoundary.js +36 -58
  106. package/es/components/ErrorBoundary/ErrorBoundaryContext.js +14 -9
  107. package/es/components/ExpandableSearch/ExpandableSearch.js +60 -69
  108. package/es/components/ExpandableSearch/index.js +12 -4
  109. package/es/components/FeatureFlags/index.d.ts +11 -2
  110. package/es/components/FeatureFlags/index.js +79 -77
  111. package/es/components/FileUploader/FileUploader.Skeleton.js +35 -30
  112. package/es/components/FileUploader/FileUploader.js +269 -343
  113. package/es/components/FileUploader/FileUploaderButton.js +110 -160
  114. package/es/components/FileUploader/FileUploaderDropContainer.js +144 -221
  115. package/es/components/FileUploader/FileUploaderItem.js +138 -157
  116. package/es/components/FileUploader/Filename.d.ts +1 -1
  117. package/es/components/FileUploader/Filename.js +53 -72
  118. package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +26 -28
  119. package/es/components/FluidComboBox/FluidComboBox.js +54 -105
  120. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +56 -53
  121. package/es/components/FluidDatePicker/FluidDatePicker.js +46 -68
  122. package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +23 -16
  123. package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +26 -28
  124. package/es/components/FluidDropdown/FluidDropdown.js +55 -111
  125. package/es/components/FluidForm/FluidForm.js +29 -31
  126. package/es/components/FluidForm/FormContext.js +12 -6
  127. package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +26 -28
  128. package/es/components/FluidMultiSelect/FluidMultiSelect.js +67 -197
  129. package/es/components/FluidNumberInput/FluidNumberInput.Skeleton.js +27 -30
  130. package/es/components/FluidNumberInput/FluidNumberInput.js +63 -147
  131. package/es/components/FluidSearch/FluidSearch.Skeleton.js +27 -30
  132. package/es/components/FluidSearch/FluidSearch.js +41 -84
  133. package/es/components/FluidSelect/FluidSelect.Skeleton.js +26 -28
  134. package/es/components/FluidSelect/FluidSelect.js +40 -76
  135. package/es/components/FluidSelect/index.js +13 -5
  136. package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +27 -30
  137. package/es/components/FluidTextArea/FluidTextArea.js +48 -112
  138. package/es/components/FluidTextInput/FluidPasswordInput.js +44 -99
  139. package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +27 -30
  140. package/es/components/FluidTextInput/FluidTextInput.js +49 -104
  141. package/es/components/FluidTextInput/index.js +14 -6
  142. package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +30 -33
  143. package/es/components/FluidTimePicker/FluidTimePicker.js +68 -115
  144. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +28 -47
  145. package/es/components/Form/Form.js +23 -25
  146. package/es/components/FormGroup/FormGroup.js +45 -67
  147. package/es/components/FormItem/FormItem.js +23 -25
  148. package/es/components/FormLabel/FormLabel.js +28 -34
  149. package/es/components/Grid/CSSGrid.d.ts +1 -1
  150. package/es/components/Grid/CSSGrid.js +85 -127
  151. package/es/components/Grid/Column.js +192 -324
  152. package/es/components/Grid/ColumnHang.js +28 -36
  153. package/es/components/Grid/FlexGrid.js +40 -60
  154. package/es/components/Grid/Grid.js +29 -42
  155. package/es/components/Grid/GridContext.js +36 -42
  156. package/es/components/Grid/Row.js +31 -49
  157. package/es/components/Heading/index.js +36 -51
  158. package/es/components/Icon/Icon.Skeleton.js +21 -21
  159. package/es/components/IconButton/index.js +117 -178
  160. package/es/components/IconIndicator/index.d.ts +1 -1
  161. package/es/components/IconIndicator/index.js +59 -60
  162. package/es/components/IdPrefix/index.js +21 -17
  163. package/es/components/InlineCheckbox/InlineCheckbox.js +69 -113
  164. package/es/components/InlineCheckbox/index.js +12 -4
  165. package/es/components/InlineLoading/InlineLoading.js +83 -100
  166. package/es/components/InlineLoading/index.js +12 -4
  167. package/es/components/Layer/LayerContext.js +12 -4
  168. package/es/components/Layer/LayerLevel.js +20 -4
  169. package/es/components/Layer/index.js +54 -66
  170. package/es/components/Layout/index.js +77 -109
  171. package/es/components/LayoutDirection/LayoutDirection.d.ts +1 -1
  172. package/es/components/LayoutDirection/LayoutDirection.js +33 -37
  173. package/es/components/LayoutDirection/LayoutDirectionContext.js +12 -6
  174. package/es/components/LayoutDirection/useLayoutDirection.js +15 -7
  175. package/es/components/Link/Link.js +63 -108
  176. package/es/components/Link/index.js +12 -4
  177. package/es/components/ListBox/ListBox.js +78 -126
  178. package/es/components/ListBox/ListBoxField.js +24 -43
  179. package/es/components/ListBox/ListBoxMenu.js +36 -42
  180. package/es/components/ListBox/ListBoxMenuIcon.js +39 -40
  181. package/es/components/ListBox/ListBoxMenuItem.js +67 -88
  182. package/es/components/ListBox/ListBoxPropTypes.js +17 -5
  183. package/es/components/ListBox/ListBoxSelection.js +71 -96
  184. package/es/components/ListBox/index.js +16 -14
  185. package/es/components/ListBox/next/ListBoxSelection.js +79 -117
  186. package/es/components/ListBox/next/ListBoxTrigger.js +44 -48
  187. package/es/components/ListItem/ListItem.js +25 -28
  188. package/es/components/Loading/Loading.js +64 -73
  189. package/es/components/Loading/index.js +12 -4
  190. package/es/components/Menu/Menu.js +220 -363
  191. package/es/components/Menu/MenuContext.d.ts +1 -1
  192. package/es/components/Menu/MenuContext.js +41 -38
  193. package/es/components/Menu/MenuItem.js +282 -413
  194. package/es/components/MenuButton/index.js +134 -195
  195. package/es/components/Modal/Modal.js +500 -660
  196. package/es/components/Modal/ModalPresence.js +39 -37
  197. package/es/components/Modal/index.js +13 -5
  198. package/es/components/ModalWrapper/ModalWrapper.d.ts +2 -2
  199. package/es/components/ModalWrapper/ModalWrapper.js +106 -130
  200. package/es/components/MultiSelect/FilterableMultiSelect.js +605 -918
  201. package/es/components/MultiSelect/MultiSelect.js +454 -716
  202. package/es/components/MultiSelect/MultiSelectPropTypes.js +13 -30
  203. package/es/components/MultiSelect/filter.js +14 -9
  204. package/es/components/MultiSelect/tools/sorting.js +21 -34
  205. package/es/components/Notification/Notification.js +508 -785
  206. package/es/components/NumberInput/NumberFormatPropTypes.js +69 -30
  207. package/es/components/NumberInput/NumberInput.Skeleton.js +29 -33
  208. package/es/components/NumberInput/NumberInput.js +567 -947
  209. package/es/components/OrderedList/OrderedList.js +31 -44
  210. package/es/components/OverflowMenu/OverflowMenu.js +335 -450
  211. package/es/components/OverflowMenu/index.js +25 -16
  212. package/es/components/OverflowMenu/next/index.js +154 -186
  213. package/es/components/OverflowMenuItem/OverflowMenuItem.js +100 -160
  214. package/es/components/OverflowMenuItem/index.js +12 -4
  215. package/es/components/OverflowMenuV2/index.js +15 -13
  216. package/es/components/PageHeader/PageHeader.js +297 -442
  217. package/es/components/PageHeader/index.js +24 -2
  218. package/es/components/Pagination/Pagination.Skeleton.js +34 -35
  219. package/es/components/Pagination/Pagination.d.ts +1 -1
  220. package/es/components/Pagination/Pagination.js +251 -356
  221. package/es/components/Pagination/experimental/PageSelector.js +38 -54
  222. package/es/components/Pagination/experimental/Pagination-story.d.ts +114 -0
  223. package/es/components/Pagination/experimental/Pagination.js +144 -196
  224. package/es/components/PaginationNav/PaginationNav.js +320 -426
  225. package/es/components/Popover/index.js +318 -437
  226. package/es/components/PrimaryButton/PrimaryButton.js +11 -9
  227. package/es/components/ProgressBar/ProgressBar.js +117 -143
  228. package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +42 -38
  229. package/es/components/ProgressIndicator/ProgressIndicator.js +146 -243
  230. package/es/components/RadioButton/RadioButton.Skeleton.js +23 -25
  231. package/es/components/RadioButton/RadioButton.js +101 -174
  232. package/es/components/RadioButton/index.js +12 -4
  233. package/es/components/RadioButtonGroup/RadioButtonGroup.js +135 -207
  234. package/es/components/RadioTile/RadioTile.js +104 -168
  235. package/es/components/RadioTile/index.js +12 -4
  236. package/es/components/Search/Search.Skeleton.js +28 -33
  237. package/es/components/Search/Search.js +182 -278
  238. package/es/components/Search/index.js +13 -5
  239. package/es/components/Search/utils.js +11 -3
  240. package/es/components/SecondaryButton/SecondaryButton.js +11 -9
  241. package/es/components/Select/Select.Skeleton.js +27 -30
  242. package/es/components/Select/Select.js +178 -257
  243. package/es/components/Select/index.js +13 -5
  244. package/es/components/SelectItem/SelectItem.js +33 -48
  245. package/es/components/SelectItem/index.js +12 -4
  246. package/es/components/SelectItemGroup/SelectItemGroup.js +27 -37
  247. package/es/components/ShapeIndicator/index.d.ts +1 -1
  248. package/es/components/ShapeIndicator/index.js +74 -80
  249. package/es/components/SkeletonIcon/SkeletonIcon.js +21 -24
  250. package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +15 -24
  251. package/es/components/SkeletonText/SkeletonText.js +67 -81
  252. package/es/components/SkeletonText/index.js +12 -4
  253. package/es/components/Slider/Slider.Skeleton.js +68 -91
  254. package/es/components/Slider/Slider.js +864 -1315
  255. package/es/components/Slider/SliderHandles.js +73 -66
  256. package/es/components/Stack/HStack.js +19 -11
  257. package/es/components/Stack/Stack.js +56 -80
  258. package/es/components/Stack/VStack.js +19 -11
  259. package/es/components/StructuredList/StructuredList.Skeleton.js +55 -48
  260. package/es/components/StructuredList/StructuredList.js +178 -317
  261. package/es/components/Switch/IconSwitch.js +99 -145
  262. package/es/components/Switch/Switch.js +66 -99
  263. package/es/components/TabContent/TabContent.js +28 -34
  264. package/es/components/Tabs/Tabs.Skeleton.js +41 -36
  265. package/es/components/Tabs/Tabs.js +732 -1147
  266. package/es/components/Tabs/usePressable.js +97 -112
  267. package/es/components/Tag/DismissibleTag.js +119 -156
  268. package/es/components/Tag/OperationalTag.js +91 -111
  269. package/es/components/Tag/SelectableTag.js +94 -129
  270. package/es/components/Tag/Tag.Skeleton.js +26 -30
  271. package/es/components/Tag/Tag.js +152 -200
  272. package/es/components/Tag/isEllipsisActive.js +13 -8
  273. package/es/components/Text/Text.js +66 -79
  274. package/es/components/Text/TextDirection.js +36 -37
  275. package/es/components/Text/TextDirectionContext.js +14 -8
  276. package/es/components/Text/createTextComponent.js +21 -20
  277. package/es/components/TextArea/TextArea.Skeleton.js +25 -29
  278. package/es/components/TextArea/TextArea.js +315 -422
  279. package/es/components/TextArea/index.js +13 -5
  280. package/es/components/TextInput/ControlledPasswordInput.js +133 -198
  281. package/es/components/TextInput/PasswordInput.js +196 -303
  282. package/es/components/TextInput/TextInput.Skeleton.js +24 -28
  283. package/es/components/TextInput/TextInput.js +219 -317
  284. package/es/components/TextInput/index.js +13 -5
  285. package/es/components/TextInput/util.js +21 -25
  286. package/es/components/Theme/index.js +79 -95
  287. package/es/components/Tile/Tile.d.ts +2 -2
  288. package/es/components/Tile/Tile.js +394 -588
  289. package/es/components/TileGroup/TileGroup.js +70 -111
  290. package/es/components/TimePicker/TimePicker.d.ts +1 -1
  291. package/es/components/TimePicker/TimePicker.js +148 -247
  292. package/es/components/TimePickerSelect/TimePickerSelect.js +43 -58
  293. package/es/components/Toggle/Toggle.Skeleton.js +24 -22
  294. package/es/components/Toggle/Toggle.js +102 -171
  295. package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +46 -51
  296. package/es/components/Toggletip/index.d.ts +2 -2
  297. package/es/components/Toggletip/index.js +170 -256
  298. package/es/components/Tooltip/DefinitionTooltip.js +98 -138
  299. package/es/components/Tooltip/Tooltip.js +188 -263
  300. package/es/components/TreeView/TreeContext.js +13 -5
  301. package/es/components/TreeView/TreeNode.js +361 -500
  302. package/es/components/TreeView/TreeView.js +164 -237
  303. package/es/components/UIShell/Content.js +23 -30
  304. package/es/components/UIShell/Header.js +25 -29
  305. package/es/components/UIShell/HeaderContainer.js +31 -40
  306. package/es/components/UIShell/HeaderGlobalAction.js +65 -90
  307. package/es/components/UIShell/HeaderGlobalBar.js +16 -9
  308. package/es/components/UIShell/HeaderMenu.js +141 -215
  309. package/es/components/UIShell/HeaderMenuButton.js +43 -66
  310. package/es/components/UIShell/HeaderMenuItem.js +49 -76
  311. package/es/components/UIShell/HeaderName.js +32 -44
  312. package/es/components/UIShell/HeaderNavigation.js +32 -37
  313. package/es/components/UIShell/HeaderPanel.js +74 -97
  314. package/es/components/UIShell/HeaderSideNavItems.js +27 -33
  315. package/es/components/UIShell/Link.js +29 -50
  316. package/es/components/UIShell/SideNav.js +132 -241
  317. package/es/components/UIShell/SideNavContext.js +21 -15
  318. package/es/components/UIShell/SideNavDetails.js +29 -34
  319. package/es/components/UIShell/SideNavDivider.js +21 -21
  320. package/es/components/UIShell/SideNavFooter.js +43 -52
  321. package/es/components/UIShell/SideNavHeader.js +26 -35
  322. package/es/components/UIShell/SideNavIcon.js +28 -33
  323. package/es/components/UIShell/SideNavItem.js +28 -33
  324. package/es/components/UIShell/SideNavItems.js +31 -40
  325. package/es/components/UIShell/SideNavLink.js +52 -79
  326. package/es/components/UIShell/SideNavLinkText.js +24 -25
  327. package/es/components/UIShell/SideNavMenu.js +102 -143
  328. package/es/components/UIShell/SideNavMenuItem.js +40 -52
  329. package/es/components/UIShell/SideNavSwitcher.js +59 -68
  330. package/es/components/UIShell/SkipToContent.js +28 -36
  331. package/es/components/UIShell/Switcher.js +69 -99
  332. package/es/components/UIShell/SwitcherDivider.js +16 -24
  333. package/es/components/UIShell/SwitcherItem.js +74 -114
  334. package/es/components/UnorderedList/UnorderedList.js +28 -37
  335. package/es/feature-flags.js +19 -10
  336. package/es/index.js +249 -242
  337. package/es/internal/FloatingMenu.js +246 -292
  338. package/es/internal/OptimizedResize.js +35 -46
  339. package/es/internal/Selection.js +99 -132
  340. package/es/internal/clamp.js +12 -4
  341. package/es/internal/defaultItemToString.js +15 -9
  342. package/es/internal/deprecateFieldOnObject.js +22 -14
  343. package/es/internal/environment.js +15 -7
  344. package/es/internal/getAnnouncement.js +16 -13
  345. package/es/internal/keyboard/keys.js +48 -48
  346. package/es/internal/keyboard/match.js +25 -42
  347. package/es/internal/keyboard/navigation.js +22 -27
  348. package/es/internal/noopFn.js +10 -2
  349. package/es/internal/useAttachedMenu.js +43 -51
  350. package/es/internal/useControllableState.js +43 -48
  351. package/es/internal/useDelayedState.js +30 -35
  352. package/es/internal/useEvent.js +39 -35
  353. package/es/internal/useId.js +51 -87
  354. package/es/internal/useIdPrefix.js +13 -5
  355. package/es/internal/useIsomorphicEffect.js +12 -4
  356. package/es/internal/useMatchMedia.js +29 -21
  357. package/es/internal/useMergedRefs.js +26 -22
  358. package/es/internal/useNoInteractiveChildren.js +70 -99
  359. package/es/internal/useNormalizedInputProps.js +47 -51
  360. package/es/internal/useOutsideClick.js +21 -24
  361. package/es/internal/useOverflowItems.js +89 -90
  362. package/es/internal/usePrefix.js +13 -5
  363. package/es/internal/usePresence.js +51 -54
  364. package/es/internal/usePresenceContext.js +35 -35
  365. package/es/internal/usePreviousValue.js +26 -18
  366. package/es/internal/useResizeObserver.js +57 -66
  367. package/es/internal/useSavedCallback.js +24 -17
  368. package/es/internal/utils.js +17 -9
  369. package/es/internal/warning.js +17 -22
  370. package/es/internal/wrapFocus.js +77 -98
  371. package/es/prop-types/AriaPropTypes.js +14 -6
  372. package/es/prop-types/deprecate.js +30 -27
  373. package/es/prop-types/deprecateComponent.js +17 -8
  374. package/es/prop-types/deprecateValuesWithin.js +18 -21
  375. package/es/prop-types/isRequiredOneOf.js +21 -24
  376. package/es/prop-types/requiredIfGivenPropIsTruthy.js +14 -14
  377. package/es/tools/events.js +17 -21
  378. package/es/tools/mapPopoverAlign.js +19 -18
  379. package/es/tools/mergeRefs.js +14 -17
  380. package/es/tools/setupGetInstanceId.js +16 -8
  381. package/es/tools/toggleClass.js +17 -9
  382. package/es/tools/wrapComponent.js +34 -39
  383. package/icons/index.d.ts +2 -1
  384. package/icons/index.esm.js +2 -2
  385. package/icons/index.js +7 -10
  386. package/lib/_virtual/_rolldown/runtime.js +50 -0
  387. package/lib/components/AILabel/index.d.ts +29 -2
  388. package/lib/components/AILabel/index.js +118 -171
  389. package/lib/components/AISkeleton/AISkeletonIcon.js +27 -31
  390. package/lib/components/AISkeleton/AISkeletonPlaceholder.js +29 -31
  391. package/lib/components/AISkeleton/AISkeletonText.js +30 -43
  392. package/lib/components/Accordion/Accordion.Skeleton.js +59 -84
  393. package/lib/components/Accordion/Accordion.js +47 -65
  394. package/lib/components/Accordion/AccordionItem.js +106 -160
  395. package/lib/components/Accordion/AccordionProvider.js +20 -17
  396. package/lib/components/AspectRatio/AspectRatio.js +45 -51
  397. package/lib/components/BadgeIndicator/index.js +33 -39
  398. package/lib/components/Breadcrumb/Breadcrumb.Skeleton.js +43 -55
  399. package/lib/components/Breadcrumb/Breadcrumb.js +43 -55
  400. package/lib/components/Breadcrumb/BreadcrumbItem.js +84 -87
  401. package/lib/components/Button/Button.Skeleton.js +53 -63
  402. package/lib/components/Button/Button.d.ts +1 -1
  403. package/lib/components/Button/Button.js +149 -244
  404. package/lib/components/Button/ButtonBase.js +85 -108
  405. package/lib/components/Button/index.js +13 -15
  406. package/lib/components/ButtonSet/ButtonSet.js +78 -102
  407. package/lib/components/ButtonSet/index.js +12 -9
  408. package/lib/components/ChatButton/ChatButton.Skeleton.js +31 -31
  409. package/lib/components/ChatButton/ChatButton.js +68 -83
  410. package/lib/components/Checkbox/Checkbox.Skeleton.js +30 -30
  411. package/lib/components/Checkbox/Checkbox.js +119 -198
  412. package/lib/components/Checkbox/index.js +13 -11
  413. package/lib/components/CheckboxGroup/CheckboxGroup.js +104 -152
  414. package/lib/components/ClassPrefix/index.js +24 -19
  415. package/lib/components/CodeSnippet/CodeSnippet.Skeleton.js +49 -47
  416. package/lib/components/CodeSnippet/CodeSnippet.js +215 -303
  417. package/lib/components/ComboBox/ComboBox.js +626 -974
  418. package/lib/components/ComboBox/index.js +12 -9
  419. package/lib/components/ComboButton/index.js +176 -210
  420. package/lib/components/ComposedModal/ComposedModal.js +315 -454
  421. package/lib/components/ComposedModal/ComposedModalPresence.js +49 -44
  422. package/lib/components/ComposedModal/ModalFooter.js +131 -209
  423. package/lib/components/ComposedModal/ModalHeader.js +75 -103
  424. package/lib/components/ComposedModal/useComposedModalState.js +22 -17
  425. package/lib/components/ContainedList/ContainedList.js +77 -106
  426. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +59 -71
  427. package/lib/components/ContainedList/ContainedListItem/index.js +12 -9
  428. package/lib/components/ContainedList/index.js +18 -15
  429. package/lib/components/ContentSwitcher/ContentSwitcher.js +112 -142
  430. package/lib/components/ContextMenu/useContextMenu.js +42 -40
  431. package/lib/components/Copy/Copy.js +101 -121
  432. package/lib/components/Copy/index.js +12 -9
  433. package/lib/components/CopyButton/CopyButton.js +85 -98
  434. package/lib/components/CopyButton/index.js +12 -9
  435. package/lib/components/DangerButton/DangerButton.js +19 -13
  436. package/lib/components/DataTable/DataTable.d.ts +11 -11
  437. package/lib/components/DataTable/DataTable.js +474 -655
  438. package/lib/components/DataTable/Table.js +115 -161
  439. package/lib/components/DataTable/TableActionList.js +15 -11
  440. package/lib/components/DataTable/TableBatchAction.js +28 -38
  441. package/lib/components/DataTable/TableBatchActions.js +82 -117
  442. package/lib/components/DataTable/TableBody.js +29 -23
  443. package/lib/components/DataTable/TableCell.js +35 -50
  444. package/lib/components/DataTable/TableContainer.js +79 -86
  445. package/lib/components/DataTable/TableContext.js +15 -8
  446. package/lib/components/DataTable/TableDecoratorRow.js +34 -40
  447. package/lib/components/DataTable/TableExpandHeader.js +57 -94
  448. package/lib/components/DataTable/TableExpandRow.js +86 -123
  449. package/lib/components/DataTable/TableExpandedRow.js +49 -55
  450. package/lib/components/DataTable/TableHead.js +8 -10
  451. package/lib/components/DataTable/TableHeader.js +142 -185
  452. package/lib/components/DataTable/TableRow.d.ts +1 -1
  453. package/lib/components/DataTable/TableRow.js +46 -80
  454. package/lib/components/DataTable/TableSelectAll.js +46 -74
  455. package/lib/components/DataTable/TableSelectRow.js +67 -102
  456. package/lib/components/DataTable/TableSlugRow.js +39 -47
  457. package/lib/components/DataTable/TableToolbar.js +37 -49
  458. package/lib/components/DataTable/TableToolbarAction.js +28 -24
  459. package/lib/components/DataTable/TableToolbarContent.js +15 -11
  460. package/lib/components/DataTable/TableToolbarMenu.js +39 -50
  461. package/lib/components/DataTable/TableToolbarSearch.js +101 -191
  462. package/lib/components/DataTable/state/getDerivedStateFromProps.js +38 -47
  463. package/lib/components/DataTable/state/sortStates.js +11 -10
  464. package/lib/components/DataTable/state/sorting.js +54 -76
  465. package/lib/components/DataTable/tools/cells.js +15 -8
  466. package/lib/components/DataTable/tools/denormalize.js +27 -22
  467. package/lib/components/DataTable/tools/filter.js +21 -23
  468. package/lib/components/DataTable/tools/normalize.js +57 -76
  469. package/lib/components/DataTable/tools/sorting.js +50 -75
  470. package/lib/components/DataTableSkeleton/DataTableSkeleton.js +70 -98
  471. package/lib/components/DatePicker/DatePicker.Skeleton.js +48 -56
  472. package/lib/components/DatePicker/DatePicker.d.ts +4 -2
  473. package/lib/components/DatePicker/DatePicker.js +491 -753
  474. package/lib/components/DatePicker/DatePickerLocales.js +75 -127
  475. package/lib/components/DatePicker/index.js +13 -11
  476. package/lib/components/DatePicker/plugins/appendToPlugin.js +31 -46
  477. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +127 -175
  478. package/lib/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
  479. package/lib/components/DatePicker/plugins/rangePlugin.js +42 -49
  480. package/lib/components/DatePicker/utils.d.ts +7 -0
  481. package/lib/components/DatePicker/utils.js +19 -0
  482. package/lib/components/DatePickerInput/DatePickerInput.js +183 -293
  483. package/lib/components/DatePickerInput/index.js +12 -9
  484. package/lib/components/Dialog/Dialog.js +307 -576
  485. package/lib/components/Dialog/index.js +21 -13
  486. package/lib/components/Dropdown/Dropdown.Skeleton.js +30 -43
  487. package/lib/components/Dropdown/Dropdown.js +348 -539
  488. package/lib/components/Dropdown/index.js +13 -11
  489. package/lib/components/ErrorBoundary/ErrorBoundary.js +39 -62
  490. package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +15 -11
  491. package/lib/components/ExpandableSearch/ExpandableSearch.js +63 -73
  492. package/lib/components/ExpandableSearch/index.js +12 -9
  493. package/lib/components/FeatureFlags/index.d.ts +11 -2
  494. package/lib/components/FeatureFlags/index.js +82 -79
  495. package/lib/components/FileUploader/FileUploader.Skeleton.js +39 -35
  496. package/lib/components/FileUploader/FileUploader.js +273 -347
  497. package/lib/components/FileUploader/FileUploaderButton.js +114 -164
  498. package/lib/components/FileUploader/FileUploaderDropContainer.js +148 -225
  499. package/lib/components/FileUploader/FileUploaderItem.js +142 -161
  500. package/lib/components/FileUploader/Filename.d.ts +1 -1
  501. package/lib/components/FileUploader/Filename.js +56 -76
  502. package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +30 -32
  503. package/lib/components/FluidComboBox/FluidComboBox.js +58 -109
  504. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +60 -57
  505. package/lib/components/FluidDatePicker/FluidDatePicker.js +50 -72
  506. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +25 -20
  507. package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +30 -32
  508. package/lib/components/FluidDropdown/FluidDropdown.js +59 -115
  509. package/lib/components/FluidForm/FluidForm.js +33 -35
  510. package/lib/components/FluidForm/FormContext.js +13 -8
  511. package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +30 -32
  512. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +71 -201
  513. package/lib/components/FluidNumberInput/FluidNumberInput.Skeleton.js +31 -34
  514. package/lib/components/FluidNumberInput/FluidNumberInput.js +67 -151
  515. package/lib/components/FluidSearch/FluidSearch.Skeleton.js +31 -34
  516. package/lib/components/FluidSearch/FluidSearch.js +45 -88
  517. package/lib/components/FluidSelect/FluidSelect.Skeleton.js +30 -32
  518. package/lib/components/FluidSelect/FluidSelect.js +44 -80
  519. package/lib/components/FluidSelect/index.js +13 -11
  520. package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +31 -34
  521. package/lib/components/FluidTextArea/FluidTextArea.js +52 -116
  522. package/lib/components/FluidTextInput/FluidPasswordInput.js +48 -103
  523. package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +31 -34
  524. package/lib/components/FluidTextInput/FluidTextInput.js +53 -108
  525. package/lib/components/FluidTextInput/index.js +14 -13
  526. package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +34 -37
  527. package/lib/components/FluidTimePicker/FluidTimePicker.js +72 -119
  528. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +31 -51
  529. package/lib/components/Form/Form.js +27 -29
  530. package/lib/components/FormGroup/FormGroup.js +49 -71
  531. package/lib/components/FormItem/FormItem.js +27 -29
  532. package/lib/components/FormLabel/FormLabel.js +32 -38
  533. package/lib/components/Grid/CSSGrid.d.ts +1 -1
  534. package/lib/components/Grid/CSSGrid.js +89 -129
  535. package/lib/components/Grid/Column.js +196 -328
  536. package/lib/components/Grid/ColumnHang.js +32 -38
  537. package/lib/components/Grid/FlexGrid.js +44 -62
  538. package/lib/components/Grid/Grid.js +32 -44
  539. package/lib/components/Grid/GridContext.js +39 -44
  540. package/lib/components/Grid/Row.js +35 -53
  541. package/lib/components/Heading/index.js +39 -53
  542. package/lib/components/Icon/Icon.Skeleton.js +25 -23
  543. package/lib/components/IconButton/index.js +121 -180
  544. package/lib/components/IconIndicator/index.d.ts +1 -1
  545. package/lib/components/IconIndicator/index.js +63 -63
  546. package/lib/components/IdPrefix/index.js +24 -19
  547. package/lib/components/InlineCheckbox/InlineCheckbox.js +72 -117
  548. package/lib/components/InlineCheckbox/index.js +12 -9
  549. package/lib/components/InlineLoading/InlineLoading.js +87 -104
  550. package/lib/components/InlineLoading/index.js +12 -9
  551. package/lib/components/Layer/LayerContext.js +14 -6
  552. package/lib/components/Layer/LayerLevel.js +20 -6
  553. package/lib/components/Layer/index.js +58 -68
  554. package/lib/components/Layout/index.js +81 -111
  555. package/lib/components/LayoutDirection/LayoutDirection.d.ts +1 -1
  556. package/lib/components/LayoutDirection/LayoutDirection.js +36 -40
  557. package/lib/components/LayoutDirection/LayoutDirectionContext.js +14 -8
  558. package/lib/components/LayoutDirection/useLayoutDirection.js +16 -9
  559. package/lib/components/Link/Link.js +67 -112
  560. package/lib/components/Link/index.js +12 -9
  561. package/lib/components/ListBox/ListBox.js +82 -130
  562. package/lib/components/ListBox/ListBoxField.js +33 -47
  563. package/lib/components/ListBox/ListBoxMenu.js +39 -46
  564. package/lib/components/ListBox/ListBoxMenuIcon.js +43 -44
  565. package/lib/components/ListBox/ListBoxMenuItem.js +71 -92
  566. package/lib/components/ListBox/ListBoxPropTypes.js +21 -9
  567. package/lib/components/ListBox/ListBoxSelection.js +75 -100
  568. package/lib/components/ListBox/index.js +17 -21
  569. package/lib/components/ListBox/next/ListBoxSelection.js +83 -121
  570. package/lib/components/ListBox/next/ListBoxTrigger.js +48 -52
  571. package/lib/components/ListItem/ListItem.js +29 -32
  572. package/lib/components/Loading/Loading.js +68 -77
  573. package/lib/components/Loading/index.js +12 -9
  574. package/lib/components/Menu/Menu.js +224 -365
  575. package/lib/components/Menu/MenuContext.d.ts +1 -1
  576. package/lib/components/Menu/MenuContext.js +42 -40
  577. package/lib/components/Menu/MenuItem.js +286 -415
  578. package/lib/components/MenuButton/index.js +138 -197
  579. package/lib/components/Modal/Modal.js +504 -665
  580. package/lib/components/Modal/ModalPresence.js +41 -39
  581. package/lib/components/Modal/index.js +13 -10
  582. package/lib/components/ModalWrapper/ModalWrapper.d.ts +2 -2
  583. package/lib/components/ModalWrapper/ModalWrapper.js +112 -134
  584. package/lib/components/MultiSelect/FilterableMultiSelect.js +611 -920
  585. package/lib/components/MultiSelect/MultiSelect.js +459 -718
  586. package/lib/components/MultiSelect/MultiSelectPropTypes.js +15 -32
  587. package/lib/components/MultiSelect/filter.js +14 -10
  588. package/lib/components/MultiSelect/tools/sorting.js +21 -35
  589. package/lib/components/Notification/Notification.js +514 -787
  590. package/lib/components/NumberInput/NumberFormatPropTypes.js +72 -33
  591. package/lib/components/NumberInput/NumberInput.Skeleton.js +33 -37
  592. package/lib/components/NumberInput/NumberInput.js +571 -950
  593. package/lib/components/OrderedList/OrderedList.js +35 -48
  594. package/lib/components/OverflowMenu/OverflowMenu.js +341 -454
  595. package/lib/components/OverflowMenu/index.js +27 -21
  596. package/lib/components/OverflowMenu/next/index.js +158 -188
  597. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +104 -164
  598. package/lib/components/OverflowMenuItem/index.js +12 -9
  599. package/lib/components/OverflowMenuV2/index.js +25 -15
  600. package/lib/components/PageHeader/PageHeader.js +301 -444
  601. package/lib/components/PageHeader/index.js +27 -19
  602. package/lib/components/Pagination/Pagination.Skeleton.js +38 -37
  603. package/lib/components/Pagination/Pagination.d.ts +1 -1
  604. package/lib/components/Pagination/Pagination.js +256 -360
  605. package/lib/components/Pagination/experimental/PageSelector.js +48 -58
  606. package/lib/components/Pagination/experimental/Pagination-story.d.ts +114 -0
  607. package/lib/components/Pagination/experimental/Pagination.js +148 -200
  608. package/lib/components/PaginationNav/PaginationNav.js +324 -430
  609. package/lib/components/Popover/index.js +323 -440
  610. package/lib/components/PrimaryButton/PrimaryButton.js +19 -13
  611. package/lib/components/ProgressBar/ProgressBar.js +121 -147
  612. package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +46 -43
  613. package/lib/components/ProgressIndicator/ProgressIndicator.js +150 -245
  614. package/lib/components/RadioButton/RadioButton.Skeleton.js +27 -27
  615. package/lib/components/RadioButton/RadioButton.js +105 -178
  616. package/lib/components/RadioButton/index.js +12 -9
  617. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +139 -211
  618. package/lib/components/RadioTile/RadioTile.js +108 -172
  619. package/lib/components/RadioTile/index.js +12 -9
  620. package/lib/components/Search/Search.Skeleton.js +32 -38
  621. package/lib/components/Search/Search.js +185 -281
  622. package/lib/components/Search/index.js +13 -11
  623. package/lib/components/Search/utils.js +11 -4
  624. package/lib/components/SecondaryButton/SecondaryButton.js +19 -13
  625. package/lib/components/Select/Select.Skeleton.js +31 -35
  626. package/lib/components/Select/Select.js +182 -261
  627. package/lib/components/Select/index.js +13 -11
  628. package/lib/components/SelectItem/SelectItem.js +37 -52
  629. package/lib/components/SelectItem/index.js +12 -9
  630. package/lib/components/SelectItemGroup/SelectItemGroup.js +31 -41
  631. package/lib/components/ShapeIndicator/index.d.ts +1 -1
  632. package/lib/components/ShapeIndicator/index.js +78 -83
  633. package/lib/components/SkeletonIcon/SkeletonIcon.js +25 -28
  634. package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +25 -28
  635. package/lib/components/SkeletonText/SkeletonText.js +71 -85
  636. package/lib/components/SkeletonText/index.js +12 -9
  637. package/lib/components/Slider/Slider.Skeleton.js +72 -95
  638. package/lib/components/Slider/Slider.js +868 -1319
  639. package/lib/components/Slider/SliderHandles.js +75 -68
  640. package/lib/components/Stack/HStack.js +22 -14
  641. package/lib/components/Stack/Stack.js +60 -82
  642. package/lib/components/Stack/VStack.js +22 -14
  643. package/lib/components/StructuredList/StructuredList.Skeleton.js +59 -52
  644. package/lib/components/StructuredList/StructuredList.js +182 -319
  645. package/lib/components/Switch/IconSwitch.js +103 -149
  646. package/lib/components/Switch/Switch.js +70 -103
  647. package/lib/components/TabContent/TabContent.js +32 -38
  648. package/lib/components/Tabs/Tabs.Skeleton.js +45 -41
  649. package/lib/components/Tabs/Tabs.js +738 -1151
  650. package/lib/components/Tabs/usePressable.js +98 -114
  651. package/lib/components/Tag/DismissibleTag.js +123 -160
  652. package/lib/components/Tag/OperationalTag.js +95 -115
  653. package/lib/components/Tag/SelectableTag.js +98 -133
  654. package/lib/components/Tag/Tag.Skeleton.js +30 -32
  655. package/lib/components/Tag/Tag.js +156 -204
  656. package/lib/components/Tag/isEllipsisActive.js +13 -9
  657. package/lib/components/Text/Text.js +69 -81
  658. package/lib/components/Text/TextDirection.js +39 -39
  659. package/lib/components/Text/TextDirectionContext.js +15 -10
  660. package/lib/components/Text/createTextComponent.js +29 -22
  661. package/lib/components/TextArea/TextArea.Skeleton.js +29 -34
  662. package/lib/components/TextArea/TextArea.js +319 -426
  663. package/lib/components/TextArea/index.js +13 -11
  664. package/lib/components/TextInput/ControlledPasswordInput.js +137 -202
  665. package/lib/components/TextInput/PasswordInput.js +200 -307
  666. package/lib/components/TextInput/TextInput.Skeleton.js +28 -33
  667. package/lib/components/TextInput/TextInput.js +223 -321
  668. package/lib/components/TextInput/index.js +13 -11
  669. package/lib/components/TextInput/util.js +21 -26
  670. package/lib/components/Theme/index.js +83 -97
  671. package/lib/components/Tile/Tile.d.ts +2 -2
  672. package/lib/components/Tile/Tile.js +398 -590
  673. package/lib/components/TileGroup/TileGroup.js +73 -113
  674. package/lib/components/TimePicker/TimePicker.d.ts +1 -1
  675. package/lib/components/TimePicker/TimePicker.js +152 -251
  676. package/lib/components/TimePickerSelect/TimePickerSelect.js +47 -62
  677. package/lib/components/Toggle/Toggle.Skeleton.js +28 -24
  678. package/lib/components/Toggle/Toggle.js +106 -176
  679. package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +50 -53
  680. package/lib/components/Toggletip/index.d.ts +2 -2
  681. package/lib/components/Toggletip/index.js +174 -258
  682. package/lib/components/Tooltip/DefinitionTooltip.js +102 -140
  683. package/lib/components/Tooltip/Tooltip.js +192 -265
  684. package/lib/components/TreeView/TreeContext.js +14 -7
  685. package/lib/components/TreeView/TreeNode.js +365 -504
  686. package/lib/components/TreeView/TreeView.js +169 -242
  687. package/lib/components/UIShell/Content.js +27 -34
  688. package/lib/components/UIShell/Header.js +29 -33
  689. package/lib/components/UIShell/HeaderContainer.js +34 -44
  690. package/lib/components/UIShell/HeaderGlobalAction.js +69 -94
  691. package/lib/components/UIShell/HeaderGlobalBar.js +17 -14
  692. package/lib/components/UIShell/HeaderMenu.js +146 -221
  693. package/lib/components/UIShell/HeaderMenuButton.js +47 -70
  694. package/lib/components/UIShell/HeaderMenuItem.js +53 -80
  695. package/lib/components/UIShell/HeaderName.js +36 -48
  696. package/lib/components/UIShell/HeaderNavigation.js +36 -41
  697. package/lib/components/UIShell/HeaderPanel.js +78 -101
  698. package/lib/components/UIShell/HeaderSideNavItems.js +31 -37
  699. package/lib/components/UIShell/Link.js +32 -54
  700. package/lib/components/UIShell/SideNav.js +136 -245
  701. package/lib/components/UIShell/SideNavContext.js +23 -17
  702. package/lib/components/UIShell/SideNavDetails.js +33 -38
  703. package/lib/components/UIShell/SideNavDivider.js +25 -25
  704. package/lib/components/UIShell/SideNavFooter.js +47 -56
  705. package/lib/components/UIShell/SideNavHeader.js +30 -39
  706. package/lib/components/UIShell/SideNavIcon.js +32 -37
  707. package/lib/components/UIShell/SideNavItem.js +32 -37
  708. package/lib/components/UIShell/SideNavItems.js +35 -44
  709. package/lib/components/UIShell/SideNavLink.js +56 -83
  710. package/lib/components/UIShell/SideNavLinkText.js +28 -29
  711. package/lib/components/UIShell/SideNavMenu.js +106 -148
  712. package/lib/components/UIShell/SideNavMenuItem.js +44 -56
  713. package/lib/components/UIShell/SideNavSwitcher.js +63 -72
  714. package/lib/components/UIShell/SkipToContent.js +32 -40
  715. package/lib/components/UIShell/Switcher.js +73 -103
  716. package/lib/components/UIShell/SwitcherDivider.js +26 -28
  717. package/lib/components/UIShell/SwitcherItem.js +78 -118
  718. package/lib/components/UnorderedList/UnorderedList.js +32 -41
  719. package/lib/feature-flags.js +21 -13
  720. package/lib/index.js +622 -602
  721. package/lib/internal/FloatingMenu.js +249 -296
  722. package/lib/internal/OptimizedResize.js +35 -47
  723. package/lib/internal/Selection.js +102 -134
  724. package/lib/internal/clamp.js +12 -5
  725. package/lib/internal/defaultItemToString.js +15 -10
  726. package/lib/internal/deprecateFieldOnObject.js +23 -16
  727. package/lib/internal/environment.js +15 -8
  728. package/lib/internal/getAnnouncement.js +16 -14
  729. package/lib/internal/keyboard/keys.js +48 -49
  730. package/lib/internal/keyboard/match.js +25 -43
  731. package/lib/internal/keyboard/navigation.js +22 -29
  732. package/lib/internal/noopFn.js +10 -3
  733. package/lib/internal/useAttachedMenu.js +44 -53
  734. package/lib/internal/useControllableState.js +44 -50
  735. package/lib/internal/useDelayedState.js +31 -37
  736. package/lib/internal/useEvent.js +40 -37
  737. package/lib/internal/useId.js +54 -91
  738. package/lib/internal/useIdPrefix.js +15 -7
  739. package/lib/internal/useIsomorphicEffect.js +13 -8
  740. package/lib/internal/useMatchMedia.js +30 -23
  741. package/lib/internal/useMergedRefs.js +27 -24
  742. package/lib/internal/useNoInteractiveChildren.js +73 -101
  743. package/lib/internal/useNormalizedInputProps.js +55 -53
  744. package/lib/internal/useOutsideClick.js +22 -26
  745. package/lib/internal/useOverflowItems.js +90 -94
  746. package/lib/internal/usePrefix.js +15 -7
  747. package/lib/internal/usePresence.js +52 -56
  748. package/lib/internal/usePresenceContext.js +36 -37
  749. package/lib/internal/usePreviousValue.js +27 -20
  750. package/lib/internal/useResizeObserver.js +58 -68
  751. package/lib/internal/useSavedCallback.js +25 -19
  752. package/lib/internal/utils.js +18 -11
  753. package/lib/internal/warning.js +24 -23
  754. package/lib/internal/wrapFocus.js +78 -100
  755. package/lib/prop-types/AriaPropTypes.js +17 -9
  756. package/lib/prop-types/deprecate.js +30 -29
  757. package/lib/prop-types/deprecateComponent.js +17 -10
  758. package/lib/prop-types/deprecateValuesWithin.js +18 -23
  759. package/lib/prop-types/isRequiredOneOf.js +21 -25
  760. package/lib/prop-types/requiredIfGivenPropIsTruthy.js +14 -15
  761. package/lib/tools/events.js +17 -22
  762. package/lib/tools/mapPopoverAlign.js +19 -19
  763. package/lib/tools/mergeRefs.js +14 -18
  764. package/lib/tools/setupGetInstanceId.js +16 -9
  765. package/lib/tools/toggleClass.js +17 -10
  766. package/lib/tools/wrapComponent.js +38 -43
  767. package/package.json +10 -16
  768. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -40
  769. package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
  770. package/es/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -55
  771. package/es/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -23
  772. package/es/node_modules/es-toolkit/dist/function/debounce.js +0 -70
  773. package/lib/_virtual/_rollupPluginBabelHelpers.js +0 -45
  774. package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +0 -54
  775. package/lib/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -57
  776. package/lib/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -25
  777. package/lib/node_modules/es-toolkit/dist/function/debounce.js +0 -72
@@ -1,1191 +1,776 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2026
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import { Close, ChevronLeft, ChevronRight } from '@carbon/icons-react';
10
- import { breakpoints } from '@carbon/layout';
11
- import cx from 'classnames';
12
- import PropTypes from 'prop-types';
13
- import React, { forwardRef, useRef, useState, useMemo, isValidElement, createContext, Children, useCallback, useEffect, cloneElement } from 'react';
14
- import '../Grid/FlexGrid.js';
15
- import { Grid as GridAsGridComponent } from '../Grid/Grid.js';
16
- import '../Grid/Row.js';
17
- import '../Grid/Column.js';
18
- import '../Grid/ColumnHang.js';
19
- import '../Grid/GridContext.js';
20
- import '../Tooltip/DefinitionTooltip.js';
21
- import { Tooltip } from '../Tooltip/Tooltip.js';
22
- import { useControllableState } from '../../internal/useControllableState.js';
23
- import { useId } from '../../internal/useId.js';
24
- import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
25
- import { useMergedRefs } from '../../internal/useMergedRefs.js';
26
- import { usePrefix } from '../../internal/usePrefix.js';
27
- import { Delete, ArrowRight, ArrowLeft, Home, End, ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
28
- import { match, matches } from '../../internal/keyboard/match.js';
29
- import { usePressable } from './usePressable.js';
30
- import { deprecate } from '../../prop-types/deprecate.js';
31
- import { useEvent } from '../../internal/useEvent.js';
32
- import { useMatchMedia } from '../../internal/useMatchMedia.js';
33
- import { Text } from '../Text/Text.js';
34
- import '../Text/TextDirection.js';
35
- import { BadgeIndicator } from '../BadgeIndicator/index.js';
36
- import { isComponentElement } from '../../internal/utils.js';
37
- import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.js';
38
-
39
- var _ChevronLeft, _ChevronRight, _BadgeIndicator;
8
+ import { usePrefix } from "../../internal/usePrefix.js";
9
+ import { Text } from "../Text/Text.js";
10
+ import { ArrowDown, ArrowLeft, ArrowRight as ArrowRight$1, ArrowUp as ArrowUp$1, Delete, End, Home } from "../../internal/keyboard/keys.js";
11
+ import { match, matches } from "../../internal/keyboard/match.js";
12
+ import useIsomorphicEffect from "../../internal/useIsomorphicEffect.js";
13
+ import { useId } from "../../internal/useId.js";
14
+ import { deprecate } from "../../prop-types/deprecate.js";
15
+ import { useMergedRefs } from "../../internal/useMergedRefs.js";
16
+ import { useEvent } from "../../internal/useEvent.js";
17
+ import { Tooltip } from "../Tooltip/Tooltip.js";
18
+ import BadgeIndicator from "../BadgeIndicator/index.js";
19
+ import { isComponentElement } from "../../internal/utils.js";
20
+ import { useControllableState } from "../../internal/useControllableState.js";
21
+ import { GridAsGridComponent } from "../Grid/Grid.js";
22
+ import { useMatchMedia } from "../../internal/useMatchMedia.js";
23
+ import { usePressable } from "./usePressable.js";
24
+ import classNames from "classnames";
25
+ import React, { Children, cloneElement, createContext, forwardRef, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
26
+ import PropTypes from "prop-types";
27
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
+ import { ChevronLeft, ChevronRight, Close } from "@carbon/icons-react";
29
+ import { debounce } from "es-toolkit/compat";
30
+ import { breakpoints } from "@carbon/layout";
31
+
32
+ //#region src/components/Tabs/Tabs.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
+ */
40
39
  const verticalTabHeight = 64;
41
-
42
- // Used to manage the overall state of the Tabs
43
-
44
- const TabsContext = /*#__PURE__*/React.createContext({
45
- baseId: '',
46
- activeIndex: 0,
47
- defaultSelectedIndex: 0,
48
- dismissable: false,
49
- onTabCloseRequest() {},
50
- setActiveIndex() {},
51
- selectedIndex: 0,
52
- setSelectedIndex() {}
40
+ const TabsContext = React.createContext({
41
+ baseId: "",
42
+ activeIndex: 0,
43
+ defaultSelectedIndex: 0,
44
+ dismissable: false,
45
+ onTabCloseRequest() {},
46
+ setActiveIndex() {},
47
+ selectedIndex: 0,
48
+ setSelectedIndex() {}
53
49
  });
54
-
55
- // Used to keep track of position in a tablist
56
- const TabContext = /*#__PURE__*/React.createContext({
57
- index: 0,
58
- hasSecondaryLabel: false
50
+ const TabContext = React.createContext({
51
+ index: 0,
52
+ hasSecondaryLabel: false
59
53
  });
60
54
  const lgMediaQuery = `(min-width: ${breakpoints.lg.width})`;
61
55
  const smMediaQuery = `(max-width: ${breakpoints.md.width})`;
62
-
63
- // Used to keep track of position in a list of tab panels
64
- const TabPanelContext = /*#__PURE__*/React.createContext(0);
65
-
66
- /**
67
- * Tabs
68
- */
69
-
70
- function Tabs({
71
- children,
72
- defaultSelectedIndex = 0,
73
- onChange,
74
- selectedIndex: controlledSelectedIndex,
75
- dismissable,
76
- onTabCloseRequest
77
- }) {
78
- const baseId = useId('ccs');
79
- if (dismissable && !onTabCloseRequest) {
80
- // eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
81
- console.error('dismissable property specified without also providing an onTabCloseRequest property.');
82
- }
83
- // The active index is used to track the element which has focus in our tablist
84
- const [activeIndex, setActiveIndex] = useState(defaultSelectedIndex);
85
- // The selected index is used for the tab/panel pairing which is "visible"
86
- const [selectedIndex, setSelectedIndex] = useControllableState({
87
- value: controlledSelectedIndex,
88
- defaultValue: defaultSelectedIndex,
89
- onChange: value => onChange?.({
90
- selectedIndex: value
91
- })
92
- });
93
- const value = {
94
- baseId,
95
- activeIndex,
96
- defaultSelectedIndex,
97
- dismissable,
98
- onTabCloseRequest,
99
- setActiveIndex,
100
- selectedIndex,
101
- setSelectedIndex
102
- };
103
- return /*#__PURE__*/React.createElement(TabsContext.Provider, {
104
- value: value
105
- }, children);
56
+ const TabPanelContext = React.createContext(0);
57
+ function Tabs({ children, defaultSelectedIndex = 0, onChange, selectedIndex: controlledSelectedIndex, dismissable, onTabCloseRequest }) {
58
+ const baseId = useId("ccs");
59
+ if (dismissable && !onTabCloseRequest) console.error("dismissable property specified without also providing an onTabCloseRequest property.");
60
+ const [activeIndex, setActiveIndex] = useState(defaultSelectedIndex);
61
+ const [selectedIndex, setSelectedIndex] = useControllableState({
62
+ value: controlledSelectedIndex,
63
+ defaultValue: defaultSelectedIndex,
64
+ onChange: (value) => onChange?.({ selectedIndex: value })
65
+ });
66
+ const value = {
67
+ baseId,
68
+ activeIndex,
69
+ defaultSelectedIndex,
70
+ dismissable,
71
+ onTabCloseRequest,
72
+ setActiveIndex,
73
+ selectedIndex,
74
+ setSelectedIndex
75
+ };
76
+ return /* @__PURE__ */ jsx(TabsContext.Provider, {
77
+ value,
78
+ children
79
+ });
106
80
  }
107
81
  Tabs.propTypes = {
108
- /**
109
- * Provide child elements to be rendered inside the `Tabs`.
110
- * These elements should render either `TabsList` or `TabsPanels`
111
- */
112
- children: PropTypes.node,
113
- /**
114
- * Specify which content tab should be initially selected when the component
115
- * is first rendered
116
- */
117
- defaultSelectedIndex: PropTypes.number,
118
- /**
119
- * Whether the render Tab children should be dismissable.
120
- */
121
- dismissable: PropTypes.bool,
122
- /**
123
- * Provide an optional function which is called whenever the state of the
124
- * `Tabs` changes
125
- */
126
- onChange: PropTypes.func,
127
- /**
128
- * If specifying the `onTabCloseRequest` prop, provide a callback function
129
- * responsible for removing the tab when close button is pressed on one of the Tab elements
130
- */
131
- onTabCloseRequest: props => {
132
- if (props.dismissable && !props.onTabCloseRequest) {
133
- return new Error('dismissable property specified without also providing an onTabCloseRequest property.');
134
- }
135
- return undefined;
136
- },
137
- /**
138
- * Control which content panel is currently selected. This puts the component
139
- * in a controlled mode and should be used along with `onChange`
140
- */
141
- selectedIndex: PropTypes.number
82
+ children: PropTypes.node,
83
+ defaultSelectedIndex: PropTypes.number,
84
+ dismissable: PropTypes.bool,
85
+ onChange: PropTypes.func,
86
+ onTabCloseRequest: (props) => {
87
+ if (props.dismissable && !props.onTabCloseRequest) return /* @__PURE__ */ new Error("dismissable property specified without also providing an onTabCloseRequest property.");
88
+ },
89
+ selectedIndex: PropTypes.number
142
90
  };
143
- function TabsVertical({
144
- children,
145
- height,
146
- defaultSelectedIndex = 0,
147
- onChange,
148
- selectedIndex: controlledSelectedIndex,
149
- ...rest
150
- }) {
151
- const [selectedIndex, setSelectedIndex] = useControllableState({
152
- value: controlledSelectedIndex,
153
- defaultValue: defaultSelectedIndex,
154
- onChange: value => onChange?.({
155
- selectedIndex: value
156
- })
157
- });
158
- const props = {
159
- ...rest,
160
- selectedIndex,
161
- onChange: ({
162
- selectedIndex
163
- }) => setSelectedIndex(selectedIndex)
164
- };
165
- const isSm = useMatchMedia(smMediaQuery);
166
- if (!isSm) {
167
- return /*#__PURE__*/React.createElement(GridAsGridComponent, {
168
- style: {
169
- height: height
170
- }
171
- }, /*#__PURE__*/React.createElement(Tabs, props, children));
172
- }
173
- return /*#__PURE__*/React.createElement(Tabs, props, children);
91
+ function TabsVertical({ children, height, defaultSelectedIndex = 0, onChange, selectedIndex: controlledSelectedIndex, ...rest }) {
92
+ const [selectedIndex, setSelectedIndex] = useControllableState({
93
+ value: controlledSelectedIndex,
94
+ defaultValue: defaultSelectedIndex,
95
+ onChange: (value) => onChange?.({ selectedIndex: value })
96
+ });
97
+ const props = {
98
+ ...rest,
99
+ selectedIndex,
100
+ onChange: ({ selectedIndex }) => setSelectedIndex(selectedIndex)
101
+ };
102
+ if (!useMatchMedia(smMediaQuery)) return /* @__PURE__ */ jsx(GridAsGridComponent, {
103
+ style: { height },
104
+ children: /* @__PURE__ */ jsx(Tabs, {
105
+ ...props,
106
+ children
107
+ })
108
+ });
109
+ return /* @__PURE__ */ jsx(Tabs, {
110
+ ...props,
111
+ children
112
+ });
174
113
  }
175
114
  TabsVertical.propTypes = {
176
- /**
177
- * Provide child elements to be rendered inside the `TabsVertical`.
178
- * These elements should render either `TabsListVertical` or `TabsPanels`
179
- */
180
- children: PropTypes.node,
181
- /**
182
- * Specify which content tab should be initially selected when the component
183
- * is first rendered
184
- */
185
- defaultSelectedIndex: PropTypes.number,
186
- /**
187
- * Option to set a height style only if using vertical variation
188
- */
189
- height: PropTypes.string,
190
- /**
191
- * Provide an optional function which is called whenever the state of the
192
- * `Tabs` changes
193
- */
194
- onChange: PropTypes.func,
195
- /**
196
- * Control which content panel is currently selected. This puts the component
197
- * in a controlled mode and should be used along with `onChange`
198
- */
199
- selectedIndex: PropTypes.number
115
+ children: PropTypes.node,
116
+ defaultSelectedIndex: PropTypes.number,
117
+ height: PropTypes.string,
118
+ onChange: PropTypes.func,
119
+ selectedIndex: PropTypes.number
200
120
  };
201
-
202
121
  /**
203
- * Get the next index for a given keyboard event
204
- * given a count of the total items and the current index
205
- */
122
+ * Get the next index for a given keyboard event
123
+ * given a count of the total items and the current index
124
+ */
206
125
  function getNextIndex(event, total, index) {
207
- switch (true) {
208
- case match(event, ArrowRight):
209
- return (index + 1) % total;
210
- case match(event, ArrowLeft):
211
- return (total + index - 1) % total;
212
- case match(event, Home):
213
- return 0;
214
- case match(event, End):
215
- return total - 1;
216
- default:
217
- return index;
218
- }
126
+ switch (true) {
127
+ case match(event, ArrowRight$1): return (index + 1) % total;
128
+ case match(event, ArrowLeft): return (total + index - 1) % total;
129
+ case match(event, Home): return 0;
130
+ case match(event, End): return total - 1;
131
+ default: return index;
132
+ }
219
133
  }
220
-
221
134
  /**
222
- * Get the next index for a given keyboard event
223
- * given a count of the total items and the current index
224
- */
135
+ * Get the next index for a given keyboard event
136
+ * given a count of the total items and the current index
137
+ */
225
138
  function getNextIndexVertical(event, total, index) {
226
- switch (true) {
227
- case match(event, ArrowDown):
228
- return (index + 1) % total;
229
- case match(event, ArrowUp):
230
- return (total + index - 1) % total;
231
- case match(event, Home):
232
- return 0;
233
- case match(event, End):
234
- return total - 1;
235
- default:
236
- return index;
237
- }
139
+ switch (true) {
140
+ case match(event, ArrowDown): return (index + 1) % total;
141
+ case match(event, ArrowUp$1): return (total + index - 1) % total;
142
+ case match(event, Home): return 0;
143
+ case match(event, End): return total - 1;
144
+ default: return index;
145
+ }
238
146
  }
239
-
240
- /**
241
- * TabList
242
- */
243
-
244
- function TabList({
245
- activation = 'automatic',
246
- 'aria-label': label,
247
- children,
248
- className: customClassName,
249
- contained = false,
250
- fullWidth = false,
251
- iconSize,
252
- leftOverflowButtonProps,
253
- light,
254
- rightOverflowButtonProps,
255
- scrollDebounceWait = 200,
256
- scrollIntoView,
257
- ...rest
258
- }) {
259
- const {
260
- activeIndex,
261
- selectedIndex,
262
- setSelectedIndex,
263
- setActiveIndex,
264
- dismissable
265
- } = React.useContext(TabsContext);
266
- const prefix = usePrefix();
267
- const ref = useRef(null);
268
- const previousButton = useRef(null);
269
- const nextButton = useRef(null);
270
- const [isScrollable, setIsScrollable] = useState(false);
271
- const [scrollLeft, setScrollLeft] = useState(0);
272
- const hasSecondaryLabelTabs = contained && Children.toArray(children).some(child => isComponentElement(child, Tab) && typeof child.props.secondaryLabel !== 'undefined');
273
- const isLg = useMatchMedia(lgMediaQuery);
274
- const distributeWidth = fullWidth && contained && isLg && React.Children.toArray(children).length < 9;
275
- const className = cx(`${prefix}--tabs`, {
276
- [`${prefix}--tabs--contained`]: contained,
277
- [`${prefix}--tabs--light`]: light,
278
- [`${prefix}--tabs__icon--default`]: iconSize === 'default',
279
- [`${prefix}--tabs__icon--lg`]: iconSize === 'lg',
280
- // TODO: V12 - Remove this class
281
- [`${prefix}--layout--size-lg`]: iconSize === 'lg',
282
- [`${prefix}--tabs--tall`]: hasSecondaryLabelTabs,
283
- [`${prefix}--tabs--full-width`]: distributeWidth,
284
- [`${prefix}--tabs--dismissable`]: dismissable
285
- }, customClassName);
286
-
287
- // Previous Button
288
- // VISIBLE IF:
289
- // SCROLLABLE
290
- // AND SCROLL_LEFT > 0
291
- const buttonWidth = 44;
292
- // Next Button
293
- // VISIBLE IF:
294
- // SCROLLABLE
295
- // AND SCROLL_LEFT + CLIENT_WIDTH < SCROLL_WIDTH
296
- const [isNextButtonVisible, setIsNextButtonVisible] = useState(ref.current ? scrollLeft + buttonWidth + ref.current.clientWidth < ref.current.scrollWidth : false);
297
- const isPreviousButtonVisible = ref.current ? isScrollable && scrollLeft > 0 : false;
298
- const previousButtonClasses = cx(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--previous`, {
299
- [`${prefix}--tab--overflow-nav-button--hidden`]: !isPreviousButtonVisible
300
- });
301
- const nextButtonClasses = cx(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--next`, {
302
- [`${prefix}--tab--overflow-nav-button--hidden`]: !isNextButtonVisible
303
- });
304
- const tabs = useRef([]);
305
- const debouncedOnScroll = useCallback(() => {
306
- const updateScroll = debounce(() => {
307
- if (ref.current) {
308
- setScrollLeft(ref.current.scrollLeft);
309
- }
310
- }, scrollDebounceWait);
311
- updateScroll();
312
- }, [scrollDebounceWait]);
313
- function onKeyDown(event) {
314
- if (matches(event, [ArrowRight, ArrowLeft, Home, End])) {
315
- event.preventDefault();
316
- const filteredTabs = tabs.current.filter(tab => tab !== null);
317
- const activeTabs = filteredTabs.filter(tab => !tab.disabled);
318
- const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
319
- const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
320
- if (activation === 'automatic') {
321
- setSelectedIndex(nextIndex);
322
- } else if (activation === 'manual') {
323
- setActiveIndex(nextIndex);
324
- }
325
- tabs.current[nextIndex]?.focus();
326
- }
327
- }
328
- function handleBlur({
329
- relatedTarget: currentActiveNode
330
- }) {
331
- if (ref.current?.contains(currentActiveNode)) {
332
- return;
333
- }
334
- // reset active index to selected tab index for manual activation
335
- if (activation === 'manual') {
336
- setActiveIndex(selectedIndex);
337
- }
338
- }
339
-
340
- /**
341
- * Scroll the tab into view if it is not already visible
342
- * @param tab - The tab to scroll into view
343
- * @returns {void}
344
- */
345
- function scrollTabIntoView(tab) {
346
- if (!isScrollable || !ref.current) {
347
- return;
348
- }
349
- if (tab) {
350
- // The width of the "scroll buttons"
351
- const {
352
- width: tabWidth
353
- } = tab.getBoundingClientRect();
354
-
355
- // The start and end position of the selected tab
356
- const start = tab.offsetLeft;
357
- const end = tab.offsetLeft + tabWidth;
358
-
359
- // The start and end of the visible area for the tabs
360
- const visibleStart = ref.current.scrollLeft + buttonWidth;
361
- const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
362
-
363
- // The beginning of the tab is clipped and not visible
364
- if (start < visibleStart) {
365
- setScrollLeft(start - buttonWidth);
366
- }
367
-
368
- // The end of the tab is clipped and not visible
369
- if (end > visibleEnd) {
370
- setScrollLeft(end + buttonWidth - ref.current.clientWidth);
371
- }
372
- }
373
- }
374
- useEffect(() => {
375
- const tab = tabs.current[selectedIndex];
376
- if (scrollIntoView && tab) {
377
- tab.scrollIntoView({
378
- block: 'nearest',
379
- inline: 'nearest'
380
- });
381
- }
382
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
383
- }, []);
384
- useEffect(() => {
385
- //adding 1 in calculation for firefox support
386
- setIsNextButtonVisible(ref.current ? scrollLeft + buttonWidth + ref.current.clientWidth + 1 < ref.current.scrollWidth : false);
387
- if (dismissable) {
388
- if (ref.current) {
389
- setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth);
390
- }
391
- }
392
- }, [scrollLeft, children, dismissable, isScrollable]);
393
- useEffect(() => {
394
- if (tabs.current[selectedIndex]?.disabled) {
395
- const activeTabs = tabs.current.filter(tab => {
396
- return !tab.disabled;
397
- });
398
- if (activeTabs.length > 0) {
399
- const tab = activeTabs[0];
400
- setSelectedIndex(tabs.current.indexOf(tab));
401
- }
402
- }
403
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
404
- }, []);
405
- useIsomorphicEffect(() => {
406
- if (ref.current) {
407
- // adding 1 in calculation for firefox support
408
- setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
409
- }
410
- function handler() {
411
- if (ref.current) {
412
- // adding 1 in calculation for firefox support
413
- setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
414
- }
415
- }
416
- const debouncedHandler = debounce(handler, 200);
417
- window.addEventListener('resize', debouncedHandler);
418
- return () => {
419
- debouncedHandler.cancel();
420
- window.removeEventListener('resize', debouncedHandler);
421
- };
422
- }, []);
423
-
424
- // updates scroll location for all scroll behavior.
425
- useIsomorphicEffect(() => {
426
- if (scrollLeft !== null && ref.current) {
427
- ref.current.scrollLeft = scrollLeft;
428
- }
429
- }, [scrollLeft]);
430
-
431
- // scroll manual tabs when active index changes (focus outline movement)
432
- useIsomorphicEffect(() => {
433
- const tab = activation === 'manual' ? tabs.current[activeIndex] : tabs.current[selectedIndex];
434
- scrollTabIntoView(tab);
435
- }, [activation, activeIndex]);
436
-
437
- // scroll tabs when selected index changes
438
- useIsomorphicEffect(() => {
439
- const tab = tabs.current[selectedIndex];
440
- scrollTabIntoView(tab);
441
- }, [selectedIndex, isScrollable, children]);
442
- usePressable(previousButton, {
443
- onPress({
444
- longPress
445
- }) {
446
- if (!longPress && ref.current) {
447
- setScrollLeft(Math.max(scrollLeft - ref.current.scrollWidth / tabs.current.length * 1.5, 0));
448
- }
449
- },
450
- onLongPress() {
451
- return createLongPressBehavior(ref, 'backward', setScrollLeft);
452
- }
453
- });
454
- usePressable(nextButton, {
455
- onPress({
456
- longPress
457
- }) {
458
- if (!longPress && ref.current) {
459
- setScrollLeft(Math.min(scrollLeft + ref.current.scrollWidth / tabs.current.length * 1.5, ref.current.scrollWidth - ref.current.clientWidth));
460
- }
461
- },
462
- onLongPress() {
463
- return createLongPressBehavior(ref, 'forward', setScrollLeft);
464
- }
465
- });
466
- return /*#__PURE__*/React.createElement("div", {
467
- className: className
468
- }, /*#__PURE__*/React.createElement("button", _extends({
469
- "aria-hidden": "true",
470
- tabIndex: -1,
471
- "aria-label": "Scroll left",
472
- ref: previousButton,
473
- className: previousButtonClasses,
474
- type: "button"
475
- }, leftOverflowButtonProps), _ChevronLeft || (_ChevronLeft = /*#__PURE__*/React.createElement(ChevronLeft, null))), /*#__PURE__*/React.createElement("div", _extends({}, rest, {
476
- "aria-label": label,
477
- ref: ref,
478
- role: "tablist",
479
- className: `${prefix}--tab--list`,
480
- onScroll: debouncedOnScroll,
481
- onKeyDown: onKeyDown,
482
- onBlur: handleBlur
483
- }), Children.map(children, (child, index) => {
484
- return ! /*#__PURE__*/isValidElement(child) ? null : /*#__PURE__*/React.createElement(TabContext.Provider, {
485
- value: {
486
- index,
487
- hasSecondaryLabel: hasSecondaryLabelTabs,
488
- contained
489
- }
490
- }, /*#__PURE__*/cloneElement(child, {
491
- ref: node => {
492
- if (!node) return;
493
- tabs.current[index] = node;
494
- }
495
- }));
496
- })), /*#__PURE__*/React.createElement("button", _extends({
497
- "aria-hidden": "true",
498
- tabIndex: -1,
499
- "aria-label": "Scroll right",
500
- ref: nextButton,
501
- className: nextButtonClasses,
502
- type: "button"
503
- }, rightOverflowButtonProps), _ChevronRight || (_ChevronRight = /*#__PURE__*/React.createElement(ChevronRight, null))));
147
+ function TabList({ activation = "automatic", "aria-label": label, children, className: customClassName, contained = false, fullWidth = false, iconSize, leftOverflowButtonProps, light, rightOverflowButtonProps, scrollDebounceWait = 200, scrollIntoView, ...rest }) {
148
+ const { activeIndex, selectedIndex, setSelectedIndex, setActiveIndex, dismissable } = React.useContext(TabsContext);
149
+ const prefix = usePrefix();
150
+ const ref = useRef(null);
151
+ const previousButton = useRef(null);
152
+ const nextButton = useRef(null);
153
+ const [isScrollable, setIsScrollable] = useState(false);
154
+ const [scrollLeft, setScrollLeft] = useState(0);
155
+ const hasSecondaryLabelTabs = contained && Children.toArray(children).some((child) => isComponentElement(child, Tab) && typeof child.props.secondaryLabel !== "undefined");
156
+ const isLg = useMatchMedia(lgMediaQuery);
157
+ const distributeWidth = fullWidth && contained && isLg && React.Children.toArray(children).length < 9;
158
+ const className = classNames(`${prefix}--tabs`, {
159
+ [`${prefix}--tabs--contained`]: contained,
160
+ [`${prefix}--tabs--light`]: light,
161
+ [`${prefix}--tabs__icon--default`]: iconSize === "default",
162
+ [`${prefix}--tabs__icon--lg`]: iconSize === "lg",
163
+ [`${prefix}--layout--size-lg`]: iconSize === "lg",
164
+ [`${prefix}--tabs--tall`]: hasSecondaryLabelTabs,
165
+ [`${prefix}--tabs--full-width`]: distributeWidth,
166
+ [`${prefix}--tabs--dismissable`]: dismissable
167
+ }, customClassName);
168
+ const buttonWidth = 44;
169
+ const [isNextButtonVisible, setIsNextButtonVisible] = useState(ref.current ? scrollLeft + buttonWidth + ref.current.clientWidth < ref.current.scrollWidth : false);
170
+ const isPreviousButtonVisible = ref.current ? isScrollable && scrollLeft > 0 : false;
171
+ const previousButtonClasses = classNames(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--previous`, { [`${prefix}--tab--overflow-nav-button--hidden`]: !isPreviousButtonVisible });
172
+ const nextButtonClasses = classNames(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--next`, { [`${prefix}--tab--overflow-nav-button--hidden`]: !isNextButtonVisible });
173
+ const tabs = useRef([]);
174
+ const debouncedOnScroll = useCallback(() => {
175
+ debounce(() => {
176
+ if (ref.current) setScrollLeft(ref.current.scrollLeft);
177
+ }, scrollDebounceWait)();
178
+ }, [scrollDebounceWait]);
179
+ function onKeyDown(event) {
180
+ if (matches(event, [
181
+ ArrowRight$1,
182
+ ArrowLeft,
183
+ Home,
184
+ End
185
+ ])) {
186
+ event.preventDefault();
187
+ const activeTabs = tabs.current.filter((tab) => tab !== null).filter((tab) => !tab.disabled);
188
+ const currentIndex = activeTabs.indexOf(tabs.current[activation === "automatic" ? selectedIndex : activeIndex]);
189
+ const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
190
+ if (activation === "automatic") setSelectedIndex(nextIndex);
191
+ else if (activation === "manual") setActiveIndex(nextIndex);
192
+ tabs.current[nextIndex]?.focus();
193
+ }
194
+ }
195
+ function handleBlur({ relatedTarget: currentActiveNode }) {
196
+ if (ref.current?.contains(currentActiveNode)) return;
197
+ if (activation === "manual") setActiveIndex(selectedIndex);
198
+ }
199
+ /**
200
+ * Scroll the tab into view if it is not already visible
201
+ * @param tab - The tab to scroll into view
202
+ * @returns {void}
203
+ */
204
+ function scrollTabIntoView(tab) {
205
+ if (!isScrollable || !ref.current) return;
206
+ if (tab) {
207
+ const { width: tabWidth } = tab.getBoundingClientRect();
208
+ const start = tab.offsetLeft;
209
+ const end = tab.offsetLeft + tabWidth;
210
+ const visibleStart = ref.current.scrollLeft + buttonWidth;
211
+ const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
212
+ if (start < visibleStart) setScrollLeft(start - buttonWidth);
213
+ if (end > visibleEnd) setScrollLeft(end + buttonWidth - ref.current.clientWidth);
214
+ }
215
+ }
216
+ useEffect(() => {
217
+ const tab = tabs.current[selectedIndex];
218
+ if (scrollIntoView && tab) tab.scrollIntoView({
219
+ block: "nearest",
220
+ inline: "nearest"
221
+ });
222
+ }, []);
223
+ useEffect(() => {
224
+ setIsNextButtonVisible(ref.current ? scrollLeft + buttonWidth + ref.current.clientWidth + 1 < ref.current.scrollWidth : false);
225
+ if (dismissable && ref.current) setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
226
+ }, [
227
+ children,
228
+ dismissable,
229
+ scrollLeft
230
+ ]);
231
+ useEffect(() => {
232
+ if (tabs.current[selectedIndex]?.disabled) {
233
+ const activeTabs = tabs.current.filter((tab) => {
234
+ return !tab.disabled;
235
+ });
236
+ if (activeTabs.length > 0) {
237
+ const tab = activeTabs[0];
238
+ setSelectedIndex(tabs.current.indexOf(tab));
239
+ }
240
+ }
241
+ }, []);
242
+ useIsomorphicEffect(() => {
243
+ if (ref.current) setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
244
+ function handler() {
245
+ if (ref.current) setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
246
+ }
247
+ const debouncedHandler = debounce(handler, 200);
248
+ window.addEventListener("resize", debouncedHandler);
249
+ return () => {
250
+ debouncedHandler.cancel();
251
+ window.removeEventListener("resize", debouncedHandler);
252
+ };
253
+ }, []);
254
+ useIsomorphicEffect(() => {
255
+ if (scrollLeft !== null && ref.current) ref.current.scrollLeft = scrollLeft;
256
+ }, [scrollLeft]);
257
+ useIsomorphicEffect(() => {
258
+ scrollTabIntoView(activation === "manual" ? tabs.current[activeIndex] : tabs.current[selectedIndex]);
259
+ }, [activation, activeIndex]);
260
+ useIsomorphicEffect(() => {
261
+ const tab = tabs.current[selectedIndex];
262
+ scrollTabIntoView(tab);
263
+ }, [
264
+ selectedIndex,
265
+ isScrollable,
266
+ children
267
+ ]);
268
+ usePressable(previousButton, {
269
+ onPress({ longPress }) {
270
+ if (!longPress && ref.current) setScrollLeft(Math.max(scrollLeft - ref.current.scrollWidth / tabs.current.length * 1.5, 0));
271
+ },
272
+ onLongPress() {
273
+ return createLongPressBehavior(ref, "backward", setScrollLeft);
274
+ }
275
+ });
276
+ usePressable(nextButton, {
277
+ onPress({ longPress }) {
278
+ if (!longPress && ref.current) setScrollLeft(Math.min(scrollLeft + ref.current.scrollWidth / tabs.current.length * 1.5, ref.current.scrollWidth - ref.current.clientWidth));
279
+ },
280
+ onLongPress() {
281
+ return createLongPressBehavior(ref, "forward", setScrollLeft);
282
+ }
283
+ });
284
+ return /* @__PURE__ */ jsxs("div", {
285
+ className,
286
+ children: [
287
+ /* @__PURE__ */ jsx("button", {
288
+ "aria-hidden": "true",
289
+ tabIndex: -1,
290
+ "aria-label": "Scroll left",
291
+ ref: previousButton,
292
+ className: previousButtonClasses,
293
+ type: "button",
294
+ ...leftOverflowButtonProps,
295
+ children: /* @__PURE__ */ jsx(ChevronLeft, {})
296
+ }),
297
+ /* @__PURE__ */ jsx("div", {
298
+ ...rest,
299
+ "aria-label": label,
300
+ ref,
301
+ role: "tablist",
302
+ className: `${prefix}--tab--list`,
303
+ onScroll: debouncedOnScroll,
304
+ onKeyDown,
305
+ onBlur: handleBlur,
306
+ children: Children.map(children, (child, index) => {
307
+ return !isValidElement(child) ? null : /* @__PURE__ */ jsx(TabContext.Provider, {
308
+ value: {
309
+ index,
310
+ hasSecondaryLabel: hasSecondaryLabelTabs,
311
+ contained
312
+ },
313
+ children: cloneElement(child, { ref: (node) => {
314
+ if (!node) return;
315
+ tabs.current[index] = node;
316
+ } })
317
+ });
318
+ })
319
+ }),
320
+ /* @__PURE__ */ jsx("button", {
321
+ "aria-hidden": "true",
322
+ tabIndex: -1,
323
+ "aria-label": "Scroll right",
324
+ ref: nextButton,
325
+ className: nextButtonClasses,
326
+ type: "button",
327
+ ...rightOverflowButtonProps,
328
+ children: /* @__PURE__ */ jsx(ChevronRight, {})
329
+ })
330
+ ]
331
+ });
504
332
  }
505
333
  TabList.propTypes = {
506
- /**
507
- * Specify whether the content tab should be activated automatically or
508
- * manually
509
- */
510
- activation: PropTypes.oneOf(['automatic', 'manual']),
511
- /**
512
- * Provide an accessible label to be read when a user interacts with this
513
- * component
514
- */
515
- 'aria-label': PropTypes.string,
516
- /**
517
- * Provide child elements to be rendered inside `ContentTabs`.
518
- * These elements should render a `ContentTab`
519
- */
520
- children: PropTypes.node,
521
- /**
522
- * Specify an optional className to be added to the container node
523
- */
524
- className: PropTypes.string,
525
- /**
526
- * Specify whether component is contained type
527
- */
528
- contained: PropTypes.bool,
529
- /**
530
- * Used for tabs within a grid, this makes it so tabs span the full container width and have the same width. Only available on contained tabs with <9 children
531
- */
532
- fullWidth: PropTypes.bool,
533
- /**
534
- * If using `IconTab`, specify the size of the icon being used.
535
- */
536
- iconSize: PropTypes.oneOf(['default', 'lg']),
537
- /**
538
- * Provide the props that describe the left overflow button
539
- */
540
- leftOverflowButtonProps: PropTypes.object,
541
- /**
542
- * Specify whether to use the light component variant
543
- */
544
- light: deprecate(PropTypes.bool, 'The `light` prop for `TabList` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
545
- /**
546
- * Provide the props that describe the right overflow button
547
- */
548
- rightOverflowButtonProps: PropTypes.object,
549
- /**
550
- * Optionally provide a delay (in milliseconds) passed to the lodash
551
- * debounce of the onScroll handler. This will impact the responsiveness
552
- * of scroll arrow buttons rendering when scrolling to the first or last tab.
553
- */
554
- scrollDebounceWait: PropTypes.number,
555
- /**
556
- * Choose whether to automatically scroll
557
- * to newly selected tabs on component rerender
558
- */
559
- scrollIntoView: PropTypes.bool
334
+ activation: PropTypes.oneOf(["automatic", "manual"]),
335
+ "aria-label": PropTypes.string,
336
+ children: PropTypes.node,
337
+ className: PropTypes.string,
338
+ contained: PropTypes.bool,
339
+ fullWidth: PropTypes.bool,
340
+ iconSize: PropTypes.oneOf(["default", "lg"]),
341
+ leftOverflowButtonProps: PropTypes.object,
342
+ light: deprecate(PropTypes.bool, "The `light` prop for `TabList` has been deprecated in favor of the new `Layer` component. It will be removed in the next major release."),
343
+ rightOverflowButtonProps: PropTypes.object,
344
+ scrollDebounceWait: PropTypes.number,
345
+ scrollIntoView: PropTypes.bool
560
346
  };
561
-
562
- /**
563
- * TabListVertical
564
- */
565
-
566
- // type TabElement = HTMLElement & { disabled?: boolean };
567
-
568
- function TabListVertical({
569
- activation = 'automatic',
570
- 'aria-label': label,
571
- children,
572
- className: customClassName,
573
- scrollIntoView,
574
- ...rest
575
- }) {
576
- const {
577
- activeIndex,
578
- selectedIndex,
579
- setSelectedIndex,
580
- setActiveIndex
581
- } = React.useContext(TabsContext);
582
- const prefix = usePrefix();
583
- const ref = useRef(null);
584
- const [isOverflowingBottom, setIsOverflowingBottom] = useState(false);
585
- const [isOverflowingTop, setIsOverflowingTop] = useState(false);
586
- const isSm = useMatchMedia(smMediaQuery);
587
- const className = cx(`${prefix}--tabs`, `${prefix}--tabs--vertical`, `${prefix}--tabs--contained`, customClassName);
588
- const tabs = useRef([]);
589
- function onKeyDown(event) {
590
- if (matches(event, [ArrowDown, ArrowUp, Home, End])) {
591
- event.preventDefault();
592
- const filteredTabs = tabs.current.filter(tab => tab !== null);
593
- const activeTabs = filteredTabs.filter(tab => !tab.disabled);
594
- const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
595
- const nextIndex = tabs.current.indexOf(activeTabs[getNextIndexVertical(event, activeTabs.length, currentIndex)]);
596
- if (activation === 'automatic') {
597
- setSelectedIndex(nextIndex);
598
- } else if (activation === 'manual') {
599
- setActiveIndex(nextIndex);
600
- }
601
- tabs.current[nextIndex]?.focus();
602
- }
603
- }
604
- function handleBlur({
605
- relatedTarget: currentActiveNode
606
- }) {
607
- if (ref.current?.contains(currentActiveNode)) {
608
- return;
609
- }
610
- // reset active index to selected tab index for manual activation
611
- if (activation === 'manual') {
612
- setActiveIndex(selectedIndex);
613
- }
614
- }
615
- useEffect(() => {
616
- if (tabs.current[selectedIndex]?.disabled) {
617
- const activeTabs = tabs.current.filter(tab => {
618
- return !tab.disabled;
619
- });
620
- if (activeTabs.length > 0) {
621
- const tab = activeTabs[0];
622
- setSelectedIndex(tabs.current.indexOf(tab));
623
- }
624
- }
625
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
626
- }, []);
627
- useEffect(() => {
628
- function handler() {
629
- const containerHeight = ref.current?.offsetHeight;
630
- const containerTop = ref.current?.getBoundingClientRect().top;
631
- const selectedPositionTop = tabs.current[selectedIndex]?.getBoundingClientRect().top;
632
- const halfTabHeight = verticalTabHeight / 2;
633
- if (containerTop && containerHeight) {
634
- // scrolls so selected tab is in view
635
- if (selectedPositionTop - halfTabHeight < containerTop || selectedPositionTop - containerTop + verticalTabHeight + halfTabHeight > containerHeight) {
636
- ref.current?.scrollTo({
637
- top: (selectedIndex - 1) * verticalTabHeight,
638
- behavior: 'smooth'
639
- });
640
- }
641
- }
642
- }
643
- window.addEventListener('resize', handler);
644
- handler();
645
- return () => {
646
- window.removeEventListener('resize', handler);
647
- };
648
- }, [selectedIndex, scrollIntoView]);
649
- useEffect(() => {
650
- const element = ref.current;
651
- if (!element) {
652
- return;
653
- }
654
- const handler = () => {
655
- const halfTabHeight = verticalTabHeight / 2;
656
- setIsOverflowingBottom(element.scrollTop + element.clientHeight + halfTabHeight <= element.scrollHeight);
657
- setIsOverflowingTop(element.scrollTop > halfTabHeight);
658
- };
659
- const resizeObserver = new ResizeObserver(() => handler());
660
- resizeObserver.observe(element);
661
- element.addEventListener('scroll', handler);
662
- return () => {
663
- resizeObserver.disconnect();
664
- element.removeEventListener('scroll', handler);
665
- };
666
- });
667
- if (isSm) {
668
- return /*#__PURE__*/React.createElement(TabList, _extends({}, rest, {
669
- "aria-label": label,
670
- contained: true
671
- }), children);
672
- }
673
- return /*#__PURE__*/React.createElement("div", {
674
- className: className
675
- }, isOverflowingTop && /*#__PURE__*/React.createElement("div", {
676
- className: `${prefix}--tab--list-gradient_top`
677
- }), /*#__PURE__*/React.createElement("div", _extends({}, rest, {
678
- "aria-label": label,
679
- ref: ref,
680
- role: "tablist",
681
- className: `${prefix}--tab--list`,
682
- onKeyDown: onKeyDown,
683
- onBlur: handleBlur
684
- }), Children.map(children, (child, index) => {
685
- return ! /*#__PURE__*/isValidElement(child) ? null : /*#__PURE__*/React.createElement(TabContext.Provider, {
686
- value: {
687
- index,
688
- hasSecondaryLabel: false
689
- }
690
- }, /*#__PURE__*/cloneElement(child, {
691
- ref: node => {
692
- if (!node) return;
693
- tabs.current[index] = node;
694
- }
695
- }));
696
- })), isOverflowingBottom && /*#__PURE__*/React.createElement("div", {
697
- className: `${prefix}--tab--list-gradient_bottom`
698
- }));
347
+ function TabListVertical({ activation = "automatic", "aria-label": label, children, className: customClassName, scrollIntoView, ...rest }) {
348
+ const { activeIndex, selectedIndex, setSelectedIndex, setActiveIndex } = React.useContext(TabsContext);
349
+ const prefix = usePrefix();
350
+ const ref = useRef(null);
351
+ const [isOverflowingBottom, setIsOverflowingBottom] = useState(false);
352
+ const [isOverflowingTop, setIsOverflowingTop] = useState(false);
353
+ const isSm = useMatchMedia(smMediaQuery);
354
+ const className = classNames(`${prefix}--tabs`, `${prefix}--tabs--vertical`, `${prefix}--tabs--contained`, customClassName);
355
+ const tabs = useRef([]);
356
+ function onKeyDown(event) {
357
+ if (matches(event, [
358
+ ArrowDown,
359
+ ArrowUp$1,
360
+ Home,
361
+ End
362
+ ])) {
363
+ event.preventDefault();
364
+ const activeTabs = tabs.current.filter((tab) => tab !== null).filter((tab) => !tab.disabled);
365
+ const currentIndex = activeTabs.indexOf(tabs.current[activation === "automatic" ? selectedIndex : activeIndex]);
366
+ const nextIndex = tabs.current.indexOf(activeTabs[getNextIndexVertical(event, activeTabs.length, currentIndex)]);
367
+ if (activation === "automatic") setSelectedIndex(nextIndex);
368
+ else if (activation === "manual") setActiveIndex(nextIndex);
369
+ tabs.current[nextIndex]?.focus();
370
+ }
371
+ }
372
+ function handleBlur({ relatedTarget: currentActiveNode }) {
373
+ if (ref.current?.contains(currentActiveNode)) return;
374
+ if (activation === "manual") setActiveIndex(selectedIndex);
375
+ }
376
+ useEffect(() => {
377
+ if (tabs.current[selectedIndex]?.disabled) {
378
+ const activeTabs = tabs.current.filter((tab) => {
379
+ return !tab.disabled;
380
+ });
381
+ if (activeTabs.length > 0) {
382
+ const tab = activeTabs[0];
383
+ setSelectedIndex(tabs.current.indexOf(tab));
384
+ }
385
+ }
386
+ }, []);
387
+ useEffect(() => {
388
+ function handler() {
389
+ const containerHeight = ref.current?.offsetHeight;
390
+ const containerTop = ref.current?.getBoundingClientRect().top;
391
+ const selectedPositionTop = tabs.current[selectedIndex]?.getBoundingClientRect().top;
392
+ const halfTabHeight = verticalTabHeight / 2;
393
+ if (containerTop && containerHeight) {
394
+ if (selectedPositionTop - halfTabHeight < containerTop || selectedPositionTop - containerTop + verticalTabHeight + halfTabHeight > containerHeight) ref.current?.scrollTo({
395
+ top: (selectedIndex - 1) * verticalTabHeight,
396
+ behavior: "smooth"
397
+ });
398
+ }
399
+ }
400
+ window.addEventListener("resize", handler);
401
+ handler();
402
+ return () => {
403
+ window.removeEventListener("resize", handler);
404
+ };
405
+ }, [selectedIndex, scrollIntoView]);
406
+ useEffect(() => {
407
+ const element = ref.current;
408
+ if (!element) return;
409
+ const handler = () => {
410
+ const halfTabHeight = verticalTabHeight / 2;
411
+ setIsOverflowingBottom(element.scrollTop + element.clientHeight + halfTabHeight <= element.scrollHeight);
412
+ setIsOverflowingTop(element.scrollTop > halfTabHeight);
413
+ };
414
+ const resizeObserver = new ResizeObserver(() => handler());
415
+ resizeObserver.observe(element);
416
+ element.addEventListener("scroll", handler);
417
+ return () => {
418
+ resizeObserver.disconnect();
419
+ element.removeEventListener("scroll", handler);
420
+ };
421
+ });
422
+ if (isSm) return /* @__PURE__ */ jsx(TabList, {
423
+ ...rest,
424
+ "aria-label": label,
425
+ contained: true,
426
+ children
427
+ });
428
+ return /* @__PURE__ */ jsxs("div", {
429
+ className,
430
+ children: [
431
+ isOverflowingTop && /* @__PURE__ */ jsx("div", { className: `${prefix}--tab--list-gradient_top` }),
432
+ /* @__PURE__ */ jsx("div", {
433
+ ...rest,
434
+ "aria-label": label,
435
+ ref,
436
+ role: "tablist",
437
+ className: `${prefix}--tab--list`,
438
+ onKeyDown,
439
+ onBlur: handleBlur,
440
+ children: Children.map(children, (child, index) => {
441
+ return !isValidElement(child) ? null : /* @__PURE__ */ jsx(TabContext.Provider, {
442
+ value: {
443
+ index,
444
+ hasSecondaryLabel: false
445
+ },
446
+ children: cloneElement(child, { ref: (node) => {
447
+ if (!node) return;
448
+ tabs.current[index] = node;
449
+ } })
450
+ });
451
+ })
452
+ }),
453
+ isOverflowingBottom && /* @__PURE__ */ jsx("div", { className: `${prefix}--tab--list-gradient_bottom` })
454
+ ]
455
+ });
699
456
  }
700
457
  TabListVertical.propTypes = {
701
- /**
702
- * Specify whether the content tab should be activated automatically or
703
- * manually
704
- */
705
- activation: PropTypes.oneOf(['automatic', 'manual']),
706
- /**
707
- * Provide an accessible label to be read when a user interacts with this
708
- * component
709
- */
710
- 'aria-label': PropTypes.string,
711
- /**
712
- * Provide child elements to be rendered inside `ContentTabs`.
713
- * These elements should render a `ContentTab`
714
- */
715
- children: PropTypes.node,
716
- /**
717
- * Specify an optional className to be added to the container node
718
- */
719
- className: PropTypes.string
458
+ activation: PropTypes.oneOf(["automatic", "manual"]),
459
+ "aria-label": PropTypes.string,
460
+ children: PropTypes.node,
461
+ className: PropTypes.string
720
462
  };
721
-
722
463
  /**
723
- * Helper function to set up the behavior when a button is "long pressed".
724
- * This function will take a ref to the tablist, a direction, and a setter
725
- * for scrollLeft and will update the scroll position within a requestAnimationFrame.
726
- *
727
- * It returns a cleanup function to be run
728
- * when the long press is deactivated
729
- */
464
+ * Helper function to set up the behavior when a button is "long pressed".
465
+ * This function will take a ref to the tablist, a direction, and a setter
466
+ * for scrollLeft and will update the scroll position within a requestAnimationFrame.
467
+ *
468
+ * It returns a cleanup function to be run
469
+ * when the long press is deactivated
470
+ */
730
471
  function createLongPressBehavior(ref, direction, setScrollLeft) {
731
- const node = ref.current;
732
- if (!node) {
733
- return () => {};
734
- }
735
-
736
- // We manually override the scroll behavior to be "auto".
737
- // If it is set as smooth, this animation does not update correctly
738
- const defaultScrollBehavior = node?.style['scroll-behavior'];
739
- node.style['scroll-behavior'] = 'auto';
740
- const scrollDelta = direction === 'forward' ? 5 : -5;
741
- let frameId = null;
742
- function tick() {
743
- if (!node) {
744
- return;
745
- }
746
- node.scrollLeft = node.scrollLeft + scrollDelta;
747
- frameId = requestAnimationFrame(tick);
748
- }
749
- frameId = requestAnimationFrame(tick);
750
- return () => {
751
- // Restore the previous scroll behavior
752
- node.style['scroll-behavior'] = defaultScrollBehavior;
753
-
754
- // Make sure that our `scrollLeft` value is in sync with the existing
755
- // `ref` after our requestAnimationFrame loop above
756
- setScrollLeft(node.scrollLeft);
757
- if (frameId) {
758
- cancelAnimationFrame(frameId);
759
- }
760
- };
472
+ const node = ref.current;
473
+ if (!node) return () => {};
474
+ const defaultScrollBehavior = node?.style["scroll-behavior"];
475
+ node.style["scroll-behavior"] = "auto";
476
+ const scrollDelta = direction === "forward" ? 5 : -5;
477
+ let frameId = null;
478
+ function tick() {
479
+ if (!node) return;
480
+ node.scrollLeft = node.scrollLeft + scrollDelta;
481
+ frameId = requestAnimationFrame(tick);
482
+ }
483
+ frameId = requestAnimationFrame(tick);
484
+ return () => {
485
+ node.style["scroll-behavior"] = defaultScrollBehavior;
486
+ setScrollLeft(node.scrollLeft);
487
+ if (frameId) cancelAnimationFrame(frameId);
488
+ };
761
489
  }
762
-
763
- /**
764
- * Tab
765
- */
766
-
767
- // eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
768
- const Tab = /*#__PURE__*/forwardRef(({
769
- as = 'button',
770
- children,
771
- className: customClassName,
772
- disabled,
773
- onClick,
774
- onKeyDown,
775
- secondaryLabel,
776
- renderIcon: Icon,
777
- ...rest
778
- }, forwardRef) => {
779
- const prefix = usePrefix();
780
- const {
781
- selectedIndex,
782
- setSelectedIndex,
783
- baseId,
784
- dismissable,
785
- onTabCloseRequest
786
- } = React.useContext(TabsContext);
787
- const {
788
- index,
789
- hasSecondaryLabel,
790
- contained
791
- } = React.useContext(TabContext);
792
- const {
793
- badgeIndicator
794
- } = React.useContext(IconTabContext) || {};
795
- const dismissIconRef = useRef(null);
796
- const tabRef = useRef(null);
797
- const ref = useMergedRefs([forwardRef, tabRef]);
798
- const [ignoreHover, setIgnoreHover] = useState(false);
799
- const id = `${baseId}-tab-${index}`;
800
- const panelId = `${baseId}-tabpanel-${index}`;
801
- const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
802
-
803
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
804
- const isEllipsisActive = element => {
805
- setIsEllipsisApplied(element.offsetHeight < element.scrollHeight);
806
- return element.offsetHeight < element.scrollHeight;
807
- };
808
- const className = cx(`${prefix}--tabs__nav-item`, `${prefix}--tabs__nav-link`, {
809
- [`${prefix}--tabs__nav-item--selected`]: selectedIndex === index,
810
- [`${prefix}--tabs__nav-item--disabled`]: disabled,
811
- [`${prefix}--tabs__nav-item--hover-off`]: ignoreHover
812
- }, customClassName);
813
- const BaseComponent = as;
814
- const onDismissIconMouseEnter = evt => {
815
- if (contained && tabRef.current) {
816
- evt.stopPropagation();
817
- setIgnoreHover(true);
818
- tabRef.current.classList.add(`${prefix}--tabs__nav-item--hover-off`);
819
- }
820
- };
821
- const onDismissIconMouseLeave = () => {
822
- if (contained && tabRef.current) {
823
- tabRef.current.classList.remove(`${prefix}--tabs__nav-item--hover-off`);
824
- setIgnoreHover(false);
825
- }
826
- };
827
- useEvent(dismissIconRef, 'mouseover', onDismissIconMouseEnter);
828
- useEvent(dismissIconRef, 'mouseleave', onDismissIconMouseLeave);
829
- useIsomorphicEffect(() => {
830
- function handler() {
831
- const elementTabId = document.getElementById(`${id}`) || tabRef.current;
832
- if (elementTabId?.closest(`.${prefix}--tabs--vertical`)) {
833
- const newElement = elementTabId?.getElementsByClassName(`${prefix}--tabs__nav-item-label`)[0];
834
- isEllipsisActive(newElement);
835
- }
836
- }
837
- handler();
838
- window.addEventListener('resize', handler);
839
- return () => {
840
- window.removeEventListener('resize', handler);
841
- };
842
- }, [prefix, id]);
843
- const handleClose = evt => {
844
- evt.stopPropagation();
845
- onTabCloseRequest?.(index);
846
-
847
- // set focus after removing tab
848
- if (tabRef.current && tabRef.current.parentElement) {
849
- // determine number of tabs, excluding disabled
850
- const tabCount = Array.from(tabRef.current.parentElement.childNodes).filter(node => {
851
- if (!(node instanceof HTMLElement)) return false;
852
- return node.classList.contains(`${prefix}--tabs__nav-link`) && !node.classList.contains(`${prefix}--tabs__nav-item--disabled`);
853
- }).length;
854
-
855
- // if not removing last tab focus on next tab
856
- if (tabRef.current && index + 1 !== tabCount) {
857
- tabRef.current.focus();
858
- }
859
- // if removing last tab focus on previous tab
860
- else {
861
- const prevTabIndex = (tabCount - 2) * 2;
862
- const previousTab = tabRef.current.parentElement.childNodes[prevTabIndex];
863
- if (previousTab instanceof HTMLElement) {
864
- previousTab.focus();
865
- }
866
- }
867
- }
868
- };
869
- const handleKeyDown = event => {
870
- if (dismissable && match(event, Delete)) {
871
- handleClose(event);
872
- }
873
- onKeyDown?.(event);
874
- };
875
- const DismissIcon = /*#__PURE__*/React.createElement("div", {
876
- className: cx({
877
- [`${prefix}--tabs__nav-item--close`]: dismissable,
878
- [`${prefix}--tabs__nav-item--close--hidden`]: !dismissable
879
- })
880
- }, /*#__PURE__*/React.createElement("button", {
881
- type: "button",
882
- tabIndex: -1,
883
- "aria-disabled": disabled,
884
- "aria-hidden": selectedIndex === index && dismissable ? 'false' : 'true',
885
- disabled: disabled,
886
- className: cx({
887
- [`${prefix}--tabs__nav-item--close-icon`]: dismissable,
888
- [`${prefix}--visually-hidden`]: !dismissable,
889
- [`${prefix}--tabs__nav-item--close-icon--selected`]: selectedIndex === index,
890
- [`${prefix}--tabs__nav-item--close-icon--disabled`]: disabled
891
- }),
892
- onClick: handleClose,
893
- title: `Remove ${typeof children === 'string' ? children : ''} tab`,
894
- ref: dismissIconRef
895
- }, /*#__PURE__*/React.createElement(Close, {
896
- "aria-hidden": selectedIndex === index && dismissable ? 'false' : 'true',
897
- "aria-label": `Press delete to remove ${typeof children === 'string' ? children : ''} tab`
898
- })));
899
- const hasIcon = Icon ?? dismissable;
900
-
901
- // should only happen for vertical variation, so no dismissable icon is needed here
902
- if (isEllipsisApplied) {
903
- return /*#__PURE__*/React.createElement(Tooltip, {
904
- label: children,
905
- align: "top",
906
- leaveDelayMs: 0,
907
- autoAlign: true,
908
- onMouseEnter: () => false,
909
- closeOnActivation: true
910
- }, /*#__PURE__*/React.createElement(BaseComponent, _extends({}, rest, {
911
- "aria-controls": panelId,
912
- "aria-disabled": disabled,
913
- "aria-selected": selectedIndex === index,
914
- ref: ref,
915
- id: id,
916
- role: "tab",
917
- className: className,
918
- disabled: disabled,
919
- title: children,
920
- onClick: evt => {
921
- if (disabled) {
922
- return;
923
- }
924
- setSelectedIndex(index);
925
- onClick?.(evt);
926
- },
927
- onKeyDown: handleKeyDown,
928
- tabIndex: selectedIndex === index ? '0' : '-1',
929
- type: "button"
930
- }), /*#__PURE__*/React.createElement("div", {
931
- className: `${prefix}--tabs__nav-item-label-wrapper`
932
- }, /*#__PURE__*/React.createElement(Text, {
933
- className: `${prefix}--tabs__nav-item-label`
934
- }, children)), hasSecondaryLabel && secondaryLabel && /*#__PURE__*/React.createElement(Text, {
935
- as: "div",
936
- className: `${prefix}--tabs__nav-item-secondary-label`,
937
- title: secondaryLabel
938
- }, secondaryLabel)));
939
- }
940
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BaseComponent, _extends({}, rest, {
941
- "aria-controls": panelId,
942
- "aria-disabled": disabled,
943
- "aria-selected": selectedIndex === index,
944
- ref: ref,
945
- id: id,
946
- role: "tab",
947
- className: className,
948
- disabled: disabled,
949
- onClick: evt => {
950
- if (disabled) {
951
- return;
952
- }
953
- setSelectedIndex(index);
954
- onClick?.(evt);
955
- },
956
- onKeyDown: handleKeyDown,
957
- tabIndex: selectedIndex === index ? '0' : '-1',
958
- type: "button"
959
- }), /*#__PURE__*/React.createElement("div", {
960
- className: `${prefix}--tabs__nav-item-label-wrapper`
961
- }, dismissable && Icon && /*#__PURE__*/React.createElement("div", {
962
- className: `${prefix}--tabs__nav-item--icon-left`
963
- }, /*#__PURE__*/React.createElement(Icon, {
964
- size: 16
965
- })), /*#__PURE__*/React.createElement(Text, {
966
- className: `${prefix}--tabs__nav-item-label`
967
- }, children), !dismissable && Icon && /*#__PURE__*/React.createElement("div", {
968
- className: cx(`${prefix}--tabs__nav-item--icon`, {
969
- [`${prefix}--visually-hidden`]: !hasIcon
970
- })
971
- }, !dismissable && Icon && /*#__PURE__*/React.createElement(Icon, {
972
- size: 16
973
- }))), hasSecondaryLabel && secondaryLabel && /*#__PURE__*/React.createElement(Text, {
974
- as: "div",
975
- className: `${prefix}--tabs__nav-item-secondary-label`,
976
- title: secondaryLabel
977
- }, secondaryLabel), !disabled && badgeIndicator && (_BadgeIndicator || (_BadgeIndicator = /*#__PURE__*/React.createElement(BadgeIndicator, null)))), DismissIcon);
490
+ const Tab = forwardRef(({ as = "button", children, className: customClassName, disabled, onClick, onKeyDown, secondaryLabel, renderIcon: Icon, ...rest }, forwardRef) => {
491
+ const prefix = usePrefix();
492
+ const { selectedIndex, setSelectedIndex, baseId, dismissable, onTabCloseRequest } = React.useContext(TabsContext);
493
+ const { index, hasSecondaryLabel, contained } = React.useContext(TabContext);
494
+ const { badgeIndicator } = React.useContext(IconTabContext) || {};
495
+ const dismissIconRef = useRef(null);
496
+ const tabRef = useRef(null);
497
+ const ref = useMergedRefs([forwardRef, tabRef]);
498
+ const [ignoreHover, setIgnoreHover] = useState(false);
499
+ const id = `${baseId}-tab-${index}`;
500
+ const panelId = `${baseId}-tabpanel-${index}`;
501
+ const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
502
+ const isEllipsisActive = (element) => {
503
+ setIsEllipsisApplied(element.offsetHeight < element.scrollHeight);
504
+ return element.offsetHeight < element.scrollHeight;
505
+ };
506
+ const className = classNames(`${prefix}--tabs__nav-item`, `${prefix}--tabs__nav-link`, {
507
+ [`${prefix}--tabs__nav-item--selected`]: selectedIndex === index,
508
+ [`${prefix}--tabs__nav-item--disabled`]: disabled,
509
+ [`${prefix}--tabs__nav-item--hover-off`]: ignoreHover
510
+ }, customClassName);
511
+ const BaseComponent = as;
512
+ const onDismissIconMouseEnter = (evt) => {
513
+ if (contained && tabRef.current) {
514
+ evt.stopPropagation();
515
+ setIgnoreHover(true);
516
+ tabRef.current.classList.add(`${prefix}--tabs__nav-item--hover-off`);
517
+ }
518
+ };
519
+ const onDismissIconMouseLeave = () => {
520
+ if (contained && tabRef.current) {
521
+ tabRef.current.classList.remove(`${prefix}--tabs__nav-item--hover-off`);
522
+ setIgnoreHover(false);
523
+ }
524
+ };
525
+ useEvent(dismissIconRef, "mouseover", onDismissIconMouseEnter);
526
+ useEvent(dismissIconRef, "mouseleave", onDismissIconMouseLeave);
527
+ useIsomorphicEffect(() => {
528
+ function handler() {
529
+ const elementTabId = document.getElementById(`${id}`) || tabRef.current;
530
+ if (elementTabId?.closest(`.${prefix}--tabs--vertical`)) {
531
+ const newElement = elementTabId?.getElementsByClassName(`${prefix}--tabs__nav-item-label`)[0];
532
+ isEllipsisActive(newElement);
533
+ }
534
+ }
535
+ handler();
536
+ window.addEventListener("resize", handler);
537
+ return () => {
538
+ window.removeEventListener("resize", handler);
539
+ };
540
+ }, [prefix, id]);
541
+ const handleClose = (evt) => {
542
+ evt.stopPropagation();
543
+ onTabCloseRequest?.(index);
544
+ if (tabRef.current && tabRef.current.parentElement) {
545
+ const tabCount = Array.from(tabRef.current.parentElement.childNodes).filter((node) => {
546
+ if (!(node instanceof HTMLElement)) return false;
547
+ return node.classList.contains(`${prefix}--tabs__nav-link`) && !node.classList.contains(`${prefix}--tabs__nav-item--disabled`);
548
+ }).length;
549
+ if (tabRef.current && index + 1 !== tabCount) tabRef.current.focus();
550
+ else {
551
+ const prevTabIndex = (tabCount - 2) * 2;
552
+ const previousTab = tabRef.current.parentElement.childNodes[prevTabIndex];
553
+ if (previousTab instanceof HTMLElement) previousTab.focus();
554
+ }
555
+ }
556
+ };
557
+ const handleKeyDown = (event) => {
558
+ if (dismissable && match(event, Delete)) handleClose(event);
559
+ onKeyDown?.(event);
560
+ };
561
+ const DismissIcon = /* @__PURE__ */ jsx("div", {
562
+ className: classNames({
563
+ [`${prefix}--tabs__nav-item--close`]: dismissable,
564
+ [`${prefix}--tabs__nav-item--close--hidden`]: !dismissable
565
+ }),
566
+ children: /* @__PURE__ */ jsx("button", {
567
+ type: "button",
568
+ tabIndex: -1,
569
+ "aria-disabled": disabled,
570
+ "aria-hidden": selectedIndex === index && dismissable ? "false" : "true",
571
+ disabled,
572
+ className: classNames({
573
+ [`${prefix}--tabs__nav-item--close-icon`]: dismissable,
574
+ [`${prefix}--visually-hidden`]: !dismissable,
575
+ [`${prefix}--tabs__nav-item--close-icon--selected`]: selectedIndex === index,
576
+ [`${prefix}--tabs__nav-item--close-icon--disabled`]: disabled
577
+ }),
578
+ onClick: handleClose,
579
+ title: `Remove ${typeof children === "string" ? children : ""} tab`,
580
+ ref: dismissIconRef,
581
+ children: /* @__PURE__ */ jsx(Close, {
582
+ "aria-hidden": selectedIndex === index && dismissable ? "false" : "true",
583
+ "aria-label": `Press delete to remove ${typeof children === "string" ? children : ""} tab`
584
+ })
585
+ })
586
+ });
587
+ const hasIcon = Icon ?? dismissable;
588
+ if (isEllipsisApplied) return /* @__PURE__ */ jsx(Tooltip, {
589
+ label: children,
590
+ align: "top",
591
+ leaveDelayMs: 0,
592
+ autoAlign: true,
593
+ onMouseEnter: () => false,
594
+ closeOnActivation: true,
595
+ children: /* @__PURE__ */ jsxs(BaseComponent, {
596
+ ...rest,
597
+ "aria-controls": panelId,
598
+ "aria-disabled": disabled,
599
+ "aria-selected": selectedIndex === index,
600
+ ref,
601
+ id,
602
+ role: "tab",
603
+ className,
604
+ disabled,
605
+ title: children,
606
+ onClick: (evt) => {
607
+ if (disabled) return;
608
+ setSelectedIndex(index);
609
+ onClick?.(evt);
610
+ },
611
+ onKeyDown: handleKeyDown,
612
+ tabIndex: selectedIndex === index ? "0" : "-1",
613
+ type: "button",
614
+ children: [/* @__PURE__ */ jsx("div", {
615
+ className: `${prefix}--tabs__nav-item-label-wrapper`,
616
+ children: /* @__PURE__ */ jsx(Text, {
617
+ className: `${prefix}--tabs__nav-item-label`,
618
+ children
619
+ })
620
+ }), hasSecondaryLabel && secondaryLabel && /* @__PURE__ */ jsx(Text, {
621
+ as: "div",
622
+ className: `${prefix}--tabs__nav-item-secondary-label`,
623
+ title: secondaryLabel,
624
+ children: secondaryLabel
625
+ })]
626
+ })
627
+ });
628
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(BaseComponent, {
629
+ ...rest,
630
+ "aria-controls": panelId,
631
+ "aria-disabled": disabled,
632
+ "aria-selected": selectedIndex === index,
633
+ ref,
634
+ id,
635
+ role: "tab",
636
+ className,
637
+ disabled,
638
+ onClick: (evt) => {
639
+ if (disabled) return;
640
+ setSelectedIndex(index);
641
+ onClick?.(evt);
642
+ },
643
+ onKeyDown: handleKeyDown,
644
+ tabIndex: selectedIndex === index ? "0" : "-1",
645
+ type: "button",
646
+ children: [
647
+ /* @__PURE__ */ jsxs("div", {
648
+ className: `${prefix}--tabs__nav-item-label-wrapper`,
649
+ children: [
650
+ dismissable && Icon && /* @__PURE__ */ jsx("div", {
651
+ className: `${prefix}--tabs__nav-item--icon-left`,
652
+ children: /* @__PURE__ */ jsx(Icon, { size: 16 })
653
+ }),
654
+ /* @__PURE__ */ jsx(Text, {
655
+ className: `${prefix}--tabs__nav-item-label`,
656
+ children
657
+ }),
658
+ !dismissable && Icon && /* @__PURE__ */ jsx("div", {
659
+ className: classNames(`${prefix}--tabs__nav-item--icon`, { [`${prefix}--visually-hidden`]: !hasIcon }),
660
+ children: !dismissable && Icon && /* @__PURE__ */ jsx(Icon, { size: 16 })
661
+ })
662
+ ]
663
+ }),
664
+ hasSecondaryLabel && secondaryLabel && /* @__PURE__ */ jsx(Text, {
665
+ as: "div",
666
+ className: `${prefix}--tabs__nav-item-secondary-label`,
667
+ title: secondaryLabel,
668
+ children: secondaryLabel
669
+ }),
670
+ !disabled && badgeIndicator && /* @__PURE__ */ jsx(BadgeIndicator, {})
671
+ ]
672
+ }), DismissIcon] });
978
673
  });
979
674
  Tab.propTypes = {
980
- /**
981
- * Provide a custom element to render instead of the default button
982
- */
983
- as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
984
- /**
985
- * Provide child elements to be rendered inside `Tab`.
986
- */
987
- children: PropTypes.node,
988
- /**
989
- * Specify an optional className to be added to your Tab
990
- */
991
- className: PropTypes.string,
992
- /**
993
- * Whether your Tab is disabled.
994
- */
995
- disabled: PropTypes.bool,
996
- /**
997
- * Provide a handler that is invoked when a user clicks on the control
998
- */
999
- onClick: PropTypes.func,
1000
- /**
1001
- * Provide a handler that is invoked on the key down event for the control
1002
- */
1003
- onKeyDown: PropTypes.func,
1004
- /**
1005
- * An optional parameter to allow overriding the anchor rendering.
1006
- * Useful for using Tab along with react-router or other client
1007
- * side router libraries.
1008
- */
1009
- renderButton: PropTypes.func,
1010
- /**
1011
- * A component used to render an icon.
1012
- */
1013
- renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1014
- /**
1015
- * An optional label to render under the primary tab label.
1016
- * Only useful for contained tabs.
1017
- */
1018
- secondaryLabel: PropTypes.string
675
+ as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
676
+ children: PropTypes.node,
677
+ className: PropTypes.string,
678
+ disabled: PropTypes.bool,
679
+ onClick: PropTypes.func,
680
+ onKeyDown: PropTypes.func,
681
+ renderButton: PropTypes.func,
682
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
683
+ secondaryLabel: PropTypes.string
1019
684
  };
1020
-
1021
685
  /**
1022
- * IconTab
1023
- */
1024
-
1025
- const IconTabContext = /*#__PURE__*/createContext(false);
1026
- // eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
1027
- const IconTab = /*#__PURE__*/React.forwardRef(({
1028
- badgeIndicator,
1029
- children,
1030
- className: customClassName,
1031
- defaultOpen = false,
1032
- enterDelayMs,
1033
- leaveDelayMs,
1034
- label,
1035
- ...rest
1036
- }, ref) => {
1037
- const prefix = usePrefix();
1038
- const value = useMemo(() => ({
1039
- badgeIndicator
1040
- }), [badgeIndicator]);
1041
- const hasSize20 = /*#__PURE__*/isValidElement(children) && (children.props.size === 20 || children.props.size === '20');
1042
- const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName, {
1043
- [`${prefix}--tabs__nav-item--icon-only__20`]: hasSize20
1044
- });
1045
- return /*#__PURE__*/React.createElement(IconTabContext.Provider, {
1046
- value: value
1047
- }, /*#__PURE__*/React.createElement(Tooltip, {
1048
- align: "bottom",
1049
- defaultOpen: defaultOpen,
1050
- className: `${prefix}--icon-tooltip`,
1051
- enterDelayMs: enterDelayMs,
1052
- label: label,
1053
- leaveDelayMs: leaveDelayMs
1054
- }, /*#__PURE__*/React.createElement(Tab, _extends({
1055
- className: classNames,
1056
- ref: ref
1057
- }, rest), children)));
686
+ * IconTab
687
+ */
688
+ const IconTabContext = createContext(false);
689
+ const IconTab = React.forwardRef(({ badgeIndicator, children, className: customClassName, defaultOpen = false, enterDelayMs, leaveDelayMs, label, ...rest }, ref) => {
690
+ const prefix = usePrefix();
691
+ const value = useMemo(() => ({ badgeIndicator }), [badgeIndicator]);
692
+ const hasSize20 = isValidElement(children) && (children.props.size === 20 || children.props.size === "20");
693
+ const classNames$1 = classNames(`${prefix}--tabs__nav-item--icon-only`, customClassName, { [`${prefix}--tabs__nav-item--icon-only__20`]: hasSize20 });
694
+ return /* @__PURE__ */ jsx(IconTabContext.Provider, {
695
+ value,
696
+ children: /* @__PURE__ */ jsx(Tooltip, {
697
+ align: "bottom",
698
+ defaultOpen,
699
+ className: `${prefix}--icon-tooltip`,
700
+ enterDelayMs,
701
+ label,
702
+ leaveDelayMs,
703
+ children: /* @__PURE__ */ jsx(Tab, {
704
+ className: classNames$1,
705
+ ref,
706
+ ...rest,
707
+ children
708
+ })
709
+ })
710
+ });
1058
711
  });
1059
712
  IconTab.propTypes = {
1060
- /**
1061
- * **Experimental**: Display an empty dot badge on the Tab.
1062
- */
1063
- badgeIndicator: PropTypes.bool,
1064
- /**
1065
- * Provide an icon to be rendered inside `IconTab` as the visual label for Tab.
1066
- */
1067
- children: PropTypes.node,
1068
- /**
1069
- * Specify an optional className to be added to your Tab
1070
- */
1071
- className: PropTypes.string,
1072
- /**
1073
- * Specify whether the tooltip for the icon should be open when it first renders
1074
- */
1075
- defaultOpen: PropTypes.bool,
1076
- /**
1077
- * Specify the duration in milliseconds to delay before displaying the tooltip for the icon.
1078
- */
1079
- enterDelayMs: PropTypes.number,
1080
- /**
1081
- * Provide the label to be rendered inside the Tooltip. The label will use
1082
- * `aria-labelledby` and will fully describe the child node that is provided.
1083
- * This means that if you have text in the child node it will not be
1084
- * announced to the screen reader. If using the badgeIndicator then provide a
1085
- * label with describing that there is a new notification.
1086
- */
1087
- label: PropTypes.node.isRequired,
1088
- /**
1089
- * Specify the duration in milliseconds to delay before hiding the tooltip
1090
- */
1091
- leaveDelayMs: PropTypes.number
713
+ badgeIndicator: PropTypes.bool,
714
+ children: PropTypes.node,
715
+ className: PropTypes.string,
716
+ defaultOpen: PropTypes.bool,
717
+ enterDelayMs: PropTypes.number,
718
+ label: PropTypes.node.isRequired,
719
+ leaveDelayMs: PropTypes.number
1092
720
  };
1093
-
1094
- /**
1095
- * TabPanel
1096
- */
1097
-
1098
- // eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
1099
- const TabPanel = /*#__PURE__*/React.forwardRef(({
1100
- children,
1101
- className: customClassName,
1102
- ...rest
1103
- }, forwardRef) => {
1104
- const prefix = usePrefix();
1105
- const {
1106
- selectedIndex,
1107
- baseId
1108
- } = React.useContext(TabsContext);
1109
- const index = React.useContext(TabPanelContext);
1110
- const id = `${baseId}-tabpanel-${index}`;
1111
- const tabId = `${baseId}-tab-${index}`;
1112
- const className = cx(`${prefix}--tab-content`, customClassName);
1113
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
1114
- "aria-labelledby": tabId,
1115
- id: id,
1116
- className: className,
1117
- ref: forwardRef,
1118
- role: "tabpanel",
1119
- hidden: selectedIndex !== index
1120
- }), children);
721
+ const TabPanel = React.forwardRef(({ children, className: customClassName, ...rest }, forwardRef) => {
722
+ const prefix = usePrefix();
723
+ const { selectedIndex, baseId } = React.useContext(TabsContext);
724
+ const index = React.useContext(TabPanelContext);
725
+ const id = `${baseId}-tabpanel-${index}`;
726
+ const tabId = `${baseId}-tab-${index}`;
727
+ const className = classNames(`${prefix}--tab-content`, customClassName);
728
+ return /* @__PURE__ */ jsx("div", {
729
+ ...rest,
730
+ "aria-labelledby": tabId,
731
+ id,
732
+ className,
733
+ ref: forwardRef,
734
+ role: "tabpanel",
735
+ hidden: selectedIndex !== index,
736
+ children
737
+ });
1121
738
  });
1122
739
  TabPanel.propTypes = {
1123
- /**
1124
- * Provide child elements to be rendered inside `TabPanel`.
1125
- */
1126
- children: PropTypes.node,
1127
- /**
1128
- * Specify an optional className to be added to TabPanel.
1129
- */
1130
- className: PropTypes.string
740
+ children: PropTypes.node,
741
+ className: PropTypes.string
1131
742
  };
1132
-
1133
- /**
1134
- * TabPanels
1135
- */
1136
-
1137
- function TabPanels({
1138
- children
1139
- }) {
1140
- const prefix = usePrefix();
1141
- const refs = useRef([]);
1142
- const hiddenStates = useRef([]);
1143
- useIsomorphicEffect(() => {
1144
- const tabContainer = refs.current[0]?.previousElementSibling;
1145
- const isVertical = tabContainer?.classList.contains(`${prefix}--tabs--vertical`);
1146
- const parentHasHeight = tabContainer?.parentElement?.style.height;
1147
-
1148
- // Should only apply same height to vertical Tab Panels without a given height
1149
- if (isVertical && !parentHasHeight) {
1150
- hiddenStates.current = refs.current.map(ref => ref?.hidden || false);
1151
-
1152
- // un-hide hidden Tab Panels to get heights
1153
- refs.current.forEach(ref => {
1154
- if (ref) {
1155
- ref.hidden = false;
1156
- }
1157
- });
1158
-
1159
- // set max height to TabList
1160
- const heights = refs.current.map(ref => ref?.offsetHeight || 0);
1161
- const max = Math.max(...heights);
1162
- if (tabContainer instanceof HTMLElement) {
1163
- tabContainer.style.height = max + 'px';
1164
- }
1165
-
1166
- // re-hide hidden Tab Panels
1167
- refs.current.forEach((ref, index) => {
1168
- if (ref) {
1169
- ref.hidden = hiddenStates.current[index];
1170
- }
1171
- });
1172
- }
1173
- });
1174
- return /*#__PURE__*/React.createElement(React.Fragment, null, Children.map(children, (child, index) => {
1175
- return ! /*#__PURE__*/isValidElement(child) ? null : /*#__PURE__*/React.createElement(TabPanelContext.Provider, {
1176
- value: index
1177
- }, /*#__PURE__*/cloneElement(child, {
1178
- ref: element => {
1179
- refs.current[index] = element;
1180
- }
1181
- }));
1182
- }));
743
+ function TabPanels({ children }) {
744
+ const prefix = usePrefix();
745
+ const refs = useRef([]);
746
+ const hiddenStates = useRef([]);
747
+ useIsomorphicEffect(() => {
748
+ const tabContainer = refs.current[0]?.previousElementSibling;
749
+ const isVertical = tabContainer?.classList.contains(`${prefix}--tabs--vertical`);
750
+ const parentHasHeight = tabContainer?.parentElement?.style.height;
751
+ if (isVertical && !parentHasHeight) {
752
+ hiddenStates.current = refs.current.map((ref) => ref?.hidden || false);
753
+ refs.current.forEach((ref) => {
754
+ if (ref) ref.hidden = false;
755
+ });
756
+ const heights = refs.current.map((ref) => ref?.offsetHeight || 0);
757
+ const max = Math.max(...heights);
758
+ if (tabContainer instanceof HTMLElement) tabContainer.style.height = max + "px";
759
+ refs.current.forEach((ref, index) => {
760
+ if (ref) ref.hidden = hiddenStates.current[index];
761
+ });
762
+ }
763
+ });
764
+ return /* @__PURE__ */ jsx(Fragment, { children: Children.map(children, (child, index) => {
765
+ return !isValidElement(child) ? null : /* @__PURE__ */ jsx(TabPanelContext.Provider, {
766
+ value: index,
767
+ children: cloneElement(child, { ref: (element) => {
768
+ refs.current[index] = element;
769
+ } })
770
+ });
771
+ }) });
1183
772
  }
1184
- TabPanels.propTypes = {
1185
- /**
1186
- * Provide child elements to be rendered inside `TabPanels`.
1187
- */
1188
- children: PropTypes.node
1189
- };
773
+ TabPanels.propTypes = { children: PropTypes.node };
1190
774
 
1191
- export { IconTab, Tab, TabList, TabListVertical, TabPanel, TabPanels, Tabs, TabsVertical };
775
+ //#endregion
776
+ export { IconTab, Tab, TabList, TabListVertical, TabPanel, TabPanels, Tabs, TabsVertical };