@carbon/react 1.103.0 → 1.104.0

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