@qualtrics/ui-react 2.19.0 → 2.20.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 (263) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/__shared/cjs/{index-bf07471d.js → index-579c4690.js} +10 -7
  3. package/dist/__shared/cjs/{index-4e4cc354.js → index-90d4069b.js} +999 -1875
  4. package/dist/components/Accordion/Accordion.js +1 -5
  5. package/dist/components/Accordion/Accordion2.js +3 -3
  6. package/dist/components/Accordion/AccordionHeader.js +8 -10
  7. package/dist/components/Accordion/AccordionPanel.js +3 -3
  8. package/dist/components/BreakpointSwitch/Breakpoint.js +0 -2
  9. package/dist/components/BreakpointSwitch/BreakpointSwitch.js +0 -3
  10. package/dist/components/Button/Button.js +3 -3
  11. package/dist/components/Button/Button2.js +2 -7
  12. package/dist/components/ButtonGroup/ButtonGroup.js +1 -2
  13. package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
  14. package/dist/components/Checkbox/Checkbox.js +11 -11
  15. package/dist/components/Checkbox/Checkbox2.js +3 -3
  16. package/dist/components/Checkbox/VisualCheckbox.js +1 -1
  17. package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
  18. package/dist/components/ColorPicker/Alpha.js +9 -30
  19. package/dist/components/ColorPicker/ColorPicker.js +33 -42
  20. package/dist/components/ColorPicker/ColorPicker2.js +3 -3
  21. package/dist/components/ColorPicker/ColorPickerFlyout.js +2 -1
  22. package/dist/components/ColorPicker/ColorPickerFlyoutInputs.js +20 -23
  23. package/dist/components/ColorPicker/Hue.js +2 -19
  24. package/dist/components/ColorPicker/Palette.js +7 -27
  25. package/dist/components/ColorPicker/Saturation.js +8 -29
  26. package/dist/components/ColorPicker/utils/calculateTargetId.js +10 -20
  27. package/dist/components/ColorPicker/utils/getMousePosition.js +4 -3
  28. package/dist/components/ColorPicker/utils/hexToHsv.js +0 -5
  29. package/dist/components/ColorPicker/utils/hexToRgbaString.js +2 -4
  30. package/dist/components/ColorPicker/utils/hsvToHex.js +0 -3
  31. package/dist/components/ColorPicker/utils/rgbToHex.js +1 -1
  32. package/dist/components/ColorPicker/utils/validateHex.js +12 -19
  33. package/dist/components/Combobox/Combobox.js +57 -127
  34. package/dist/components/Combobox/Combobox2.js +3 -3
  35. package/dist/components/Combobox/ComboboxHeader.js +1 -1
  36. package/dist/components/Combobox/ComboboxIcon.js +2 -4
  37. package/dist/components/Combobox/ComboboxInput.js +4 -5
  38. package/dist/components/Combobox/ComboboxList.js +2 -2
  39. package/dist/components/ConfigPane/ConfigPane.js +0 -7
  40. package/dist/components/ConfigPane/ConfigPane2.js +3 -3
  41. package/dist/components/Divider/Divider2.js +3 -3
  42. package/dist/components/Dropdown/ChildIndexContext/index.js +0 -1
  43. package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +34 -30
  44. package/dist/components/Dropdown/Dropdown.js +17 -68
  45. package/dist/components/Dropdown/Dropdown2.js +3 -3
  46. package/dist/components/Dropdown/DropdownButton.js +23 -33
  47. package/dist/components/Dropdown/DropdownHeader.js +2 -1
  48. package/dist/components/Dropdown/DropdownList.js +8 -7
  49. package/dist/components/Dropdown/DropdownOption.js +3 -10
  50. package/dist/components/Dropdown/DropdownSearch.js +6 -24
  51. package/dist/components/FilePicker/FilePicker.js +15 -26
  52. package/dist/components/FilePicker/FilePicker2.js +3 -3
  53. package/dist/components/FormField/Caption.js +3 -3
  54. package/dist/components/FormField/FormField.js +2 -2
  55. package/dist/components/FormField/FormField2.js +3 -3
  56. package/dist/components/FormField/FormFieldContext.js +3 -6
  57. package/dist/components/FormField/ReadOnlyText.js +2 -1
  58. package/dist/components/FullScreenTakeover/FullScreenTakeover.js +5 -11
  59. package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
  60. package/dist/components/Icon/Icon.js +3 -6
  61. package/dist/components/Icon/IconTypes.js +1 -0
  62. package/dist/components/IconButton/IconButton.js +1 -6
  63. package/dist/components/IconButton/IconButton2.js +3 -3
  64. package/dist/components/InlineInput/InlineInput.js +16 -33
  65. package/dist/components/InlineInput/InlineInput2.js +3 -3
  66. package/dist/components/Input/Input.js +3 -2
  67. package/dist/components/Input/Input2.js +3 -3
  68. package/dist/components/Input/InputField.js +2 -5
  69. package/dist/components/InputGroup/InputGroup2.js +3 -3
  70. package/dist/components/InputGroup/InputGroupProvider.js +0 -2
  71. package/dist/components/Label/Label2.js +3 -3
  72. package/dist/components/Link/Link2.js +3 -3
  73. package/dist/components/LoadingSpinner/LoadingSpinner.js +1 -1
  74. package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
  75. package/dist/components/LogicEditor/ConditionContainer.js +0 -2
  76. package/dist/components/LogicEditor/ConditionSet.js +8 -25
  77. package/dist/components/LogicEditor/Controls.js +2 -2
  78. package/dist/components/LogicEditor/LogicEditor.js +3 -12
  79. package/dist/components/LogicEditor/LogicEditor2.js +3 -3
  80. package/dist/components/LogicEditor/utils.js +9 -34
  81. package/dist/components/Modal/Modal.js +22 -35
  82. package/dist/components/Modal/Modal2.js +3 -3
  83. package/dist/components/NewMenu/BaseMenu.js +43 -108
  84. package/dist/components/NewMenu/NewMenu.js +3 -3
  85. package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -3
  86. package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +20 -32
  87. package/dist/components/NewMenu/parts/MenuItem.js +2 -3
  88. package/dist/components/NewMenu/parts/MenuSearchBox.js +2 -1
  89. package/dist/components/NumberStepper/NumberStepper.js +29 -44
  90. package/dist/components/NumberStepper/NumberStepper2.js +3 -3
  91. package/dist/components/NumberStepper/NumberStepperDecrement.js +6 -5
  92. package/dist/components/NumberStepper/NumberStepperIncrement.js +6 -5
  93. package/dist/components/NumberStepper/NumberStepperInput.js +10 -12
  94. package/dist/components/PageLayout/PageLayout.js +3 -3
  95. package/dist/components/Pagination/Pagination.js +10 -6
  96. package/dist/components/Pagination/Pagination2.js +3 -3
  97. package/dist/components/Pagination/PaginationNextButton.js +8 -8
  98. package/dist/components/Pagination/PaginationPageInput.js +17 -22
  99. package/dist/components/Pagination/PaginationPreviousButton.js +8 -8
  100. package/dist/components/Popover/Popover.js +9 -18
  101. package/dist/components/Popover/Popover2.js +3 -3
  102. package/dist/components/QuickSearch/QuickSearch.js +3 -5
  103. package/dist/components/QuickSearch/QuickSearch2.js +3 -3
  104. package/dist/components/QuickSearch/QuickSearchInput.js +6 -23
  105. package/dist/components/Radio/Radio.js +11 -13
  106. package/dist/components/Radio/Radio2.js +3 -3
  107. package/dist/components/SearchInput/SearchInput.js +5 -11
  108. package/dist/components/SearchInput/SearchInput2.js +3 -3
  109. package/dist/components/SidebarNav/ExpandCollapseButton.js +0 -2
  110. package/dist/components/SidebarNav/SidebarNav.js +5 -4
  111. package/dist/components/SidebarNav/SidebarNav2.js +3 -3
  112. package/dist/components/SidebarNav/SidebarNavLink.js +1 -4
  113. package/dist/components/Slider/RangeSlider.js +8 -22
  114. package/dist/components/Slider/Slider.js +7 -26
  115. package/dist/components/Slider/Slider2.js +3 -3
  116. package/dist/components/Slider/SliderButton.js +7 -9
  117. package/dist/components/Switch/Switch.js +11 -11
  118. package/dist/components/Switch/Switch2.js +3 -3
  119. package/dist/components/Table/Table2.js +3 -3
  120. package/dist/components/Tabs/Tab.js +3 -3
  121. package/dist/components/Tabs/TabContextProvider.js +1 -1
  122. package/dist/components/Tabs/TabList.js +9 -17
  123. package/dist/components/Tabs/TabPanel.js +3 -3
  124. package/dist/components/Tabs/TabPanels.js +0 -2
  125. package/dist/components/Tabs/Tabs2.js +3 -3
  126. package/dist/components/Tooltip/Tooltip.js +13 -42
  127. package/dist/components/Tooltip/Tooltip2.js +3 -3
  128. package/dist/components/UIProvider/PortalTargetContext.js +0 -1
  129. package/dist/components/UIProvider/UIProvider.js +2 -2
  130. package/dist/components/deprecated_ColorPicker/Alpha.js +4 -11
  131. package/dist/components/deprecated_ColorPicker/Color.js +9 -66
  132. package/dist/components/deprecated_ColorPicker/ColorPicker.js +2 -8
  133. package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
  134. package/dist/components/deprecated_ColorPicker/HexInput.js +1 -7
  135. package/dist/components/deprecated_ColorPicker/Hue.js +3 -10
  136. package/dist/components/deprecated_ColorPicker/Saturation.js +7 -14
  137. package/dist/components/deprecated_ColorPicker/Swatch.js +2 -6
  138. package/dist/components/deprecated_ColorPicker/useMouseDrag.js +0 -3
  139. package/dist/components/deprecated_NumberStepper/NumberStepper.js +14 -20
  140. package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
  141. package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +7 -6
  142. package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +7 -6
  143. package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +16 -17
  144. package/dist/components/deprecated_Tabs/Tabs.js +9 -25
  145. package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
  146. package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
  147. package/dist/components/deprecated_Toolbar/ToolbarPanel.js +3 -3
  148. package/dist/components/deprecated_Toolbar/ToolbarPanels.js +3 -17
  149. package/dist/components/deprecated_Toolbar/ToolbarTab.js +10 -26
  150. package/dist/components/deprecated_Toolbar/ToolbarTabs.js +6 -18
  151. package/dist/hooks/useBreakpoints/useBreakpoints.js +3 -4
  152. package/dist/hooks/useClickOutside/useClickOutside.js +2 -7
  153. package/dist/hooks/useClickOutsidePortals/useClickOutsidePortals.js +3 -6
  154. package/dist/hooks/useControllableState/useControllableState.js +5 -10
  155. package/dist/hooks/useDidUpdate/useDidUpdate.js +2 -4
  156. package/dist/hooks/useEventCallback/useEventCallback.js +2 -1
  157. package/dist/hooks/useEventListener/useEventListener.js +1 -4
  158. package/dist/hooks/useFocusSequence/useFocusSequence.js +10 -17
  159. package/dist/hooks/useId/useId.js +1 -2
  160. package/dist/hooks/useIsFocused/useIsFocused.js +0 -1
  161. package/dist/hooks/useIsHovered/useIsHovered.js +0 -1
  162. package/dist/hooks/useIsTruncated/useIsTruncated.js +4 -3
  163. package/dist/hooks/useLatest/useLatest.js +0 -1
  164. package/dist/hooks/useMounted/useMounted.js +0 -1
  165. package/dist/hooks/useMouseDrag/useMouseDrag.js +0 -4
  166. package/dist/hooks/useOverlay/useOverlay.js +4 -10
  167. package/dist/hooks/useOverlay/useOverlay2.js +3 -3
  168. package/dist/hooks/usePrevious/usePrevious.js +0 -1
  169. package/dist/hooks/useResponsiveValue/useResponsiveValue.js +1 -4
  170. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +11 -16
  171. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
  172. package/dist/icons/Icon.js +3 -3
  173. package/dist/icons/components/HeadsetIcon.js +6 -0
  174. package/dist/icons/components/PauseCircleIcon.js +1 -1
  175. package/dist/icons/createIconComponent.js +2 -3
  176. package/dist/icons/index.d.ts +2 -0
  177. package/dist/icons/index.es.js +1 -0
  178. package/dist/icons/index.js +2 -1
  179. package/dist/index.d.ts +4 -3
  180. package/dist/index.es.js +4 -3
  181. package/dist/index.js +6 -5
  182. package/dist/next/AdvancedTable/AdvancedTable.js +82 -188
  183. package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
  184. package/dist/next/AdvancedTable/AdvancedTableCell.js +4 -14
  185. package/dist/next/AdvancedTable/AdvancedTableCheckbox.js +0 -1
  186. package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +11 -41
  187. package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +8 -14
  188. package/dist/next/AdvancedTable/AdvancedTableDragPreview.js +4 -6
  189. package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -4
  190. package/dist/next/AdvancedTable/AdvancedTableRowExpandButton.js +0 -1
  191. package/dist/next/AdvancedTable/AdvancedTableTypes.js +1 -3
  192. package/dist/next/AdvancedTable/useAdvancedTableDragAndDrop.js +8 -13
  193. package/dist/next/AdvancedTable/useComputedWidth.js +1 -1
  194. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +5 -20
  195. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
  196. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInputIconButton.js +1 -1
  197. package/dist/next/Combobox/Combobox2.js +3 -3
  198. package/dist/next/Combobox/ComboboxFlyout.js +3 -3
  199. package/dist/next/Combobox/ComboboxGroup.js +1 -1
  200. package/dist/next/Combobox/ComboboxInput.js +7 -20
  201. package/dist/next/Combobox/ComboboxOption.js +5 -6
  202. package/dist/next/Combobox/hooks/useComboboxFilteredGroup/useComboboxFilteredGroup.js +4 -5
  203. package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +37 -54
  204. package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +4 -5
  205. package/dist/next/Combobox/hooks/useComboboxValue/useComboboxValue.js +5 -3
  206. package/dist/next/Combobox/hooks/useListboxFlyoutDimensions/useListboxFlyoutDimensions.js +10 -10
  207. package/dist/next/Combobox/hooks/useSelectedOptionScroll/useSelectedOptionScroll.js +1 -6
  208. package/dist/next/Combobox/hooks/useShouldRenderGroupHeader/useShouldRenderGroupHeader.js +6 -6
  209. package/dist/next/Combobox/utils/nodeRegistration/nodeRegistration.js +4 -6
  210. package/dist/next/Drawer/Drawer.js +5 -16
  211. package/dist/next/Drawer/Drawer2.js +3 -3
  212. package/dist/next/FilterAnchor/FilterAnchor.js +7 -5
  213. package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
  214. package/dist/next/Input/Input.js +5 -8
  215. package/dist/next/Input/Input2.js +3 -3
  216. package/dist/next/Menu/Menu.js +10 -23
  217. package/dist/next/Menu/Menu2.js +3 -3
  218. package/dist/next/Menu/MenuButton.js +13 -6
  219. package/dist/next/Menu/MenuContext.js +0 -2
  220. package/dist/next/Menu/MenuItem.js +11 -15
  221. package/dist/next/Menu/MenuPane.js +11 -25
  222. package/dist/next/Menu/MenuSearch.js +15 -22
  223. package/dist/next/Menu/SubMenu.js +10 -27
  224. package/dist/next/Menu/usePaneSearch.js +2 -1
  225. package/dist/next/PhoneNumberInput/PhoneNumberInput.js +12 -19
  226. package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
  227. package/dist/next/SplitButton/SplitButton.js +6 -12
  228. package/dist/next/SplitButton/SplitButton2.js +3 -3
  229. package/dist/next/Stack/Stack.js +0 -3
  230. package/dist/next/TimePicker/TimeDropdown.js +4 -5
  231. package/dist/next/TimePicker/TimeInput.js +4 -5
  232. package/dist/next/TimePicker/TimePicker.js +12 -30
  233. package/dist/next/TimePicker/TimePicker2.js +3 -3
  234. package/dist/next/TimePicker/TimePickerIcon.js +1 -3
  235. package/dist/next/TimePicker/utils.js +12 -52
  236. package/dist/next/ToggleButton/ToggleButton.js +0 -5
  237. package/dist/next/ToggleButton/ToggleButtonGroup.js +2 -1
  238. package/dist/next/ToggleButton/styles.js +3 -3
  239. package/dist/next/index.d.ts +5 -4
  240. package/dist/next/index.js +389 -754
  241. package/dist/utils/Flyout/Flyout.js +4 -5
  242. package/dist/utils/Flyout/Flyout2.js +3 -3
  243. package/dist/utils/Popper/Popper.js +18 -25
  244. package/dist/utils/Portal/Portal.js +2 -1
  245. package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +4 -4
  246. package/dist/utils/Translation/Translate.js +0 -4
  247. package/dist/utils/Translation/TranslationProvider.js +0 -1
  248. package/dist/utils/Translation/containsComponentOrElement.js +1 -5
  249. package/dist/utils/Translation/insertPlaceholders.js +0 -1
  250. package/dist/utils/Translation/useTranslation.js +7 -14
  251. package/dist/utils/concatIds/concatIds.js +0 -1
  252. package/dist/utils/constants.js +2 -2
  253. package/dist/utils/createContextUtilities/createContextUtilities.js +0 -4
  254. package/dist/utils/filterChildren/filterChildren.js +8 -17
  255. package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -2
  256. package/dist/utils/keyboardUser/keyboardUser.js +0 -1
  257. package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -12
  258. package/dist/utils/mergeRefs/mergeRefs.js +1 -2
  259. package/dist/utils/wrapAround/wrapAround.js +1 -2
  260. package/dist/utils/wrapEvent/wrapEvent.js +2 -4
  261. package/icons/package.json +2 -1
  262. package/next/package.json +5 -1
  263. package/package.json +9 -4
@@ -38,8 +38,6 @@ import useLatest from '../../hooks/useLatest/useLatest.js';
38
38
  import wrapAround from '../../utils/wrapAround/wrapAround.js';
39
39
 
40
40
  const AdvancedTable = _ref => {
41
- var _ref5;
42
-
43
41
  let {
44
42
  columnConfigs: externalColumnConfigs,
45
43
  rows: rowsPropExternal,
@@ -81,21 +79,22 @@ const AdvancedTable = _ref => {
81
79
  // This handles an edge case where no rows are passed in
82
80
  // and the internal row transforms cause infinite state updates using a standard default assignment
83
81
  const stableDefaultArray = useMemo(() => [], []);
84
- const rowsProp = rowsPropExternal !== null && rowsPropExternal !== void 0 ? rowsPropExternal : stableDefaultArray;
82
+ const rowsProp = rowsPropExternal ?? stableDefaultArray;
85
83
  const [rows, setRows] = useState();
86
84
  const rowActionsColumnConfigId = useId();
87
85
  let rowActionsColumnConfig;
88
- const columnConfigs = useMemo(() => [...externalColumnConfigs], // eslint-disable-next-line react-hooks/exhaustive-deps
86
+ const columnConfigs = useMemo(() => [...externalColumnConfigs],
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
89
88
  [externalColumnConfigs, rows] // columnConfigs has an implicit dependency on rows because it is initially computed using rows data
90
89
  );
91
- const [currentPage, setCurrentPage] = useState(initialPage !== null && initialPage !== void 0 ? initialPage : 1);
90
+
91
+ const [currentPage, setCurrentPage] = useState(initialPage ?? 1);
92
92
  const [tableHeight, setTableHeight] = useState();
93
93
  const getPaginatedRowIndex = useCallback(universalRowIndex => rowsPerPage ? universalRowIndex + rowsPerPage * (currentPage - 1) : universalRowIndex, [rowsPerPage, currentPage]);
94
94
  const paginatedRows = useMemo(() => {
95
95
  if (!rows || !rowsPerPage || !currentPage) {
96
96
  return null;
97
97
  }
98
-
99
98
  const startingRowIndex = (currentPage - 1) * rowsPerPage;
100
99
  const endingRowIndex = startingRowIndex + rowsPerPage;
101
100
  return rows.slice(startingRowIndex, endingRowIndex);
@@ -106,7 +105,6 @@ const AdvancedTable = _ref => {
106
105
  if (currentPage > pageCount) setCurrentPage(Math.max(pageCount, 1));
107
106
  }
108
107
  }, [rows, rowsPerPage, paginatedRows, currentPage]);
109
-
110
108
  if (rowActions && columnConfigs[columnConfigs.length - 1].id !== rowActionsColumnConfigId) {
111
109
  rowActionsColumnConfig = {
112
110
  id: rowActionsColumnConfigId,
@@ -132,28 +130,26 @@ const AdvancedTable = _ref => {
132
130
  }
133
131
  }, /*#__PURE__*/React__default.createElement(EllipsisHorizontalIcon, null))), /*#__PURE__*/React__default.createElement(DropdownList, {
134
132
  className: styles.rowActionMenuPane
135
- }, !rows ? [] : rowActions === null || rowActions === void 0 ? void 0 : rowActions.map((actionGroup, groupIndex) => {
136
- var _actionGroup$actions;
137
-
133
+ }, !rows ? [] : rowActions?.map((actionGroup, groupIndex) => {
138
134
  const row = rows[rowIndex];
139
- const actions = !row ? [] : (_actionGroup$actions = actionGroup.actions) === null || _actionGroup$actions === void 0 ? void 0 : _actionGroup$actions.map((action, actionIndex) => /*#__PURE__*/React__default.createElement(DropdownOption // React Docs: "We don't recommend using indexes for keys if the order of items may change." These will not change; the alternative is to require an id from the consumer.
135
+ const actions = !row ? [] : actionGroup.actions?.map((action, actionIndex) => /*#__PURE__*/React__default.createElement(DropdownOption
136
+ // React Docs: "We don't recommend using indexes for keys if the order of items may change." These will not change; the alternative is to require an id from the consumer.
140
137
  // eslint-disable-next-line react/no-array-index-key
141
138
  , {
142
- key: "".concat(groupIndex, "-").concat(actionIndex),
139
+ key: `${groupIndex}-${actionIndex}`,
143
140
  disabled: typeof action.isDisabled === 'function' ? action.isDisabled(row && row.rowPropReference) : action.isDisabled,
144
141
  onSelect: () => action.action(row && row.rowPropReference),
145
142
  value: "",
146
143
  label: ""
147
144
  }, typeof action.label === 'function' ? action.label(row.rowPropReference) : action.label));
148
-
149
145
  if (actionGroup.header) {
150
- return /*#__PURE__*/React__default.createElement(DropdownHeader // eslint-disable-next-line react/no-array-index-key
146
+ return /*#__PURE__*/React__default.createElement(DropdownHeader
147
+ // eslint-disable-next-line react/no-array-index-key
151
148
  , {
152
149
  key: groupIndex,
153
150
  title: actionGroup.header
154
151
  }, actions);
155
152
  }
156
-
157
153
  return actions;
158
154
  })));
159
155
  },
@@ -161,33 +157,28 @@ const AdvancedTable = _ref => {
161
157
  };
162
158
  columnConfigs.push(rowActionsColumnConfig);
163
159
  }
164
-
165
160
  const tableRef = useRef(null);
166
161
  const hasOnRowSelect = typeof onRowSelect === 'function';
167
162
  const hasCheckboxColumn = typeof onCheckedRowIdsChange === 'function';
168
163
  const hasFocusableRows = hasOnRowSelect || hasCheckboxColumn;
169
164
  const headerRowIndex = -1; // The header row (the first row in the table) gets an index of -1 so that the data rows can be zero-indexed
170
-
171
165
  const minRowIndex = useMemo(() => rowsPerPage ? rowsPerPage * (currentPage - 1) : 0, [rowsPerPage, currentPage]);
172
166
  const maxRowIndex = useMemo(() => !rows ? 0 : rowsPerPage ? Math.min(rowsPerPage + rowsPerPage * (currentPage - 1) - 1, rows.length - 1) : rows.length - 1, [rowsPerPage, currentPage, rows]);
173
167
  const maxRowDepth = useMemo(() => !rows ? 0 : Math.max(...rows.map(r => r.depth)), [rows]);
174
168
  const widthBufferWidth = 36;
175
169
  const columnWidthBuffers = useMemo(() => {
176
170
  const buffers = [0];
177
-
178
171
  for (let i = 0; i < maxRowDepth + 1; i += 1) {
179
172
  buffers[i] = widthBufferWidth * (maxRowDepth - i);
180
173
  }
181
-
182
174
  return buffers;
183
175
  }, [maxRowDepth]);
184
176
  const minColumnIndex = hasFocusableRows ? -1 : 0; // When entire rows are focusable, they get an index of -1 so that the columns can be zero-indexed
185
-
186
177
  const maxColumnIndex = columnConfigs.length - 1;
187
178
  const tableId = useId(externalTableId);
188
- const arrowKeyDescriptionId = "".concat(tableId, "-arrowKeyDescription");
189
- const rowActionDescriptionId = "".concat(tableId, "-rowActionDescription");
190
- const rowCheckboxDescriptionId = "".concat(tableId, "-rowCheckboxDescription");
179
+ const arrowKeyDescriptionId = `${tableId}-arrowKeyDescription`;
180
+ const rowActionDescriptionId = `${tableId}-rowActionDescription`;
181
+ const rowCheckboxDescriptionId = `${tableId}-rowCheckboxDescription`;
191
182
  useResizeObserver(tableRef, entry => {
192
183
  setTableHeight(entry.contentRect.height);
193
184
  });
@@ -195,16 +186,17 @@ const AdvancedTable = _ref => {
195
186
  const [pinnedColumns, setPinnedColumns] = useControllableState(initialPinnedColumns, onPinnedColumnsChange, exteralPinnedColumns);
196
187
  const [columnWidths, setColumnWidths] = useControllableState({}, onColumnWidthsChange, externalColumnWidths);
197
188
  const columnConfigsOrder = useMemo(() => columnConfigs.map(c => c.id), [columnConfigs]);
198
- const [internalColumnOrder, setInternalColumnOrder] = useState(columnConfigsOrder); // If columnConfigs changes, the internal column order may need to be updated (this is why useControllableState isn't being used).
189
+ const [internalColumnOrder, setInternalColumnOrder] = useState(columnConfigsOrder);
199
190
 
191
+ // If columnConfigs changes, the internal column order may need to be updated (this is why useControllableState isn't being used).
200
192
  useDidUpdate(() => {
201
193
  setInternalColumnOrder(columnConfigsOrder);
202
194
  }, [JSON.stringify(columnConfigsOrder)]);
203
- const columnOrder = externalColumnOrder !== null && externalColumnOrder !== void 0 ? externalColumnOrder : internalColumnOrder;
195
+ const columnOrder = externalColumnOrder ?? internalColumnOrder;
204
196
  const setColumnOrder = useEventCallback(value => {
205
197
  const newColumnOrder = typeof value === 'function' ? value(columnOrder) : value;
206
198
  setInternalColumnOrder(newColumnOrder);
207
- onColumnOrderChange === null || onColumnOrderChange === void 0 ? void 0 : onColumnOrderChange(newColumnOrder);
199
+ onColumnOrderChange?.(newColumnOrder);
208
200
  });
209
201
  const {
210
202
  pinnedColumnConfigs,
@@ -233,10 +225,11 @@ const AdvancedTable = _ref => {
233
225
  const [dragSource, setDragSource] = useState('');
234
226
  const [dropTarget, setDropTarget] = useState('');
235
227
  const [dropTargetSide, setDropTargetSide] = useState();
236
- const [lastToggledRowId, setLastToggledRowId] = useState(''); // Enables disabling row hover styles when hovering on the checkbox. Needed since a CSS parent selector doesn't exist.
237
-
238
- const [isCheckboxHovered, setIsCheckboxHovered] = useState(false); // Enables using Set.prototype.has() vs Array.prototype.includes() for better performance at scale
228
+ const [lastToggledRowId, setLastToggledRowId] = useState('');
229
+ // Enables disabling row hover styles when hovering on the checkbox. Needed since a CSS parent selector doesn't exist.
230
+ const [isCheckboxHovered, setIsCheckboxHovered] = useState(false);
239
231
 
232
+ // Enables using Set.prototype.has() vs Array.prototype.includes() for better performance at scale
240
233
  const [checkedRowIdsSet, setCheckedRowIdsSet] = useState(new Set(checkedRowIds));
241
234
  useSortedRows({
242
235
  columnConfigs,
@@ -260,13 +253,11 @@ const AdvancedTable = _ref => {
260
253
  rowProps: row.unsafe_rowProps,
261
254
  rowPropReference: row
262
255
  });
263
-
264
256
  if (row.isExpanded && row.childRows !== undefined && hasChildRows) {
265
257
  row.childRows.forEach((child, i) => {
266
258
  mappedRows = mappedRows.concat(mapExternalRowToInternalRows(child, row.childRows !== undefined ? row.childRows.length : 0, i, row.id, depth + 1));
267
259
  });
268
260
  }
269
-
270
261
  return mappedRows;
271
262
  }, []);
272
263
  useEffect(() => {
@@ -275,6 +266,7 @@ const AdvancedTable = _ref => {
275
266
  filteredRows = filteredRows.concat(mapExternalRowToInternalRows(row, rowsProp.length + 1, i + 1) // add 1 to account for table header
276
267
  );
277
268
  });
269
+
278
270
  setRows(filteredRows);
279
271
  }, [rowsProp, mapExternalRowToInternalRows]);
280
272
  useEffect(() => {
@@ -304,7 +296,6 @@ const AdvancedTable = _ref => {
304
296
  let ids = [];
305
297
  rowsToScan.forEach(row => {
306
298
  ids.push(row.id);
307
-
308
299
  if (row.childRows && row.childRows.length) {
309
300
  ids = ids.concat(getAllRowIds(row.childRows));
310
301
  }
@@ -312,34 +303,29 @@ const AdvancedTable = _ref => {
312
303
  return ids;
313
304
  }, [rowsProp]);
314
305
  const totalRowsCountWithExpansion = useMemo(() => getAllRowIds().length, [getAllRowIds]);
315
- const hasExpandableRows = useMemo(() => rows === null || rows === void 0 ? void 0 : rows.some(_ref3 => {
306
+ const hasExpandableRows = useMemo(() => rows?.some(_ref3 => {
316
307
  let {
317
308
  hasChildRows
318
309
  } = _ref3;
319
310
  return hasChildRows;
320
311
  }), [rows]);
321
-
322
312
  const updateExpandedRowIds = (index, expand) => {
323
313
  if (!rows || !rows[index]) {
324
314
  return;
325
315
  }
326
-
327
316
  const {
328
317
  isExpanded,
329
318
  rowPropReference
330
319
  } = rows[index];
331
-
332
320
  if (isExpanded && expand !== true) {
333
321
  rowPropReference.isExpanded = false;
334
322
  } else if (expand !== false) {
335
323
  rowPropReference.isExpanded = true;
336
324
  }
337
-
338
- onRowsChange === null || onRowsChange === void 0 ? void 0 : onRowsChange([...rowsProp]);
325
+ onRowsChange?.([...rowsProp]);
339
326
  };
340
-
341
327
  const getLastToggledRowIndex = () => {
342
- const index = rows === null || rows === void 0 ? void 0 : rows.findIndex(_ref4 => {
328
+ const index = rows?.findIndex(_ref4 => {
343
329
  let {
344
330
  id
345
331
  } = _ref4;
@@ -347,220 +333,163 @@ const AdvancedTable = _ref => {
347
333
  });
348
334
  return index === -1 ? 0 : index;
349
335
  };
350
-
351
336
  const getCheckboxStateForRow = row => {
352
337
  if (checkedRowIdsSet.has(row.id)) {
353
338
  return 'true';
354
339
  }
355
-
356
340
  if (row.hasChildRows && getAllRowIds(row.rowPropReference.childRows).some(id => checkedRowIdsSet.has(id))) {
357
341
  return 'mixed';
358
342
  }
359
-
360
343
  return 'false';
361
344
  };
362
-
363
345
  const handleColumnHeaderCheckboxToggle = () => {
364
346
  setLastToggledRowId('');
365
-
366
347
  if (checkedRowIds.length === totalRowsCountWithExpansion) {
367
348
  setCheckedRowIds([]);
368
349
  } else {
369
350
  setCheckedRowIds(getAllRowIds());
370
351
  }
371
352
  };
372
-
373
353
  const multiUpdateCheckedRowIds = (startIndex, endIndex) => {
374
- var _rows$endIndex;
375
-
376
354
  if (!rows || startIndex === headerRowIndex || endIndex === headerRowIndex) {
377
355
  return;
378
356
  }
379
-
380
- const endRowId = rows === null || rows === void 0 ? void 0 : (_rows$endIndex = rows[endIndex]) === null || _rows$endIndex === void 0 ? void 0 : _rows$endIndex.id;
357
+ const endRowId = rows?.[endIndex]?.id;
381
358
  const isEndIndexChecked = checkedRowIdsSet.has(endRowId);
382
359
  let newCheckedRowIds = [...checkedRowIds];
383
360
  const increment = startIndex < endIndex ? 1 : -1;
384
-
385
361
  for (let i = startIndex; i !== endIndex + increment; i += increment) {
386
362
  const {
387
363
  id: rowId,
388
364
  hasChildRows,
389
365
  rowPropReference
390
366
  } = rows[i];
391
-
392
367
  if (isEndIndexChecked) {
393
368
  let idsToUncheck = [rowId];
394
-
395
369
  if (hasChildRows) {
396
370
  idsToUncheck = idsToUncheck.concat(getAllRowIds(rowPropReference.childRows));
397
371
  }
398
-
399
372
  if (hasChildRows) {
400
373
  idsToUncheck = idsToUncheck.concat(getAllRowIds(rowPropReference.childRows));
401
374
  }
402
-
403
375
  newCheckedRowIds = newCheckedRowIds.filter(id => !_includesInstanceProperty(idsToUncheck).call(idsToUncheck, id));
404
376
  } else if (!checkedRowIdsSet.has(rowId)) {
405
377
  let idsToCheck = [rowId];
406
-
407
378
  if (hasChildRows) {
408
379
  idsToCheck = idsToCheck.concat(getAllRowIds(rowPropReference.childRows));
409
380
  }
410
-
411
381
  newCheckedRowIds = newCheckedRowIds.concat(idsToCheck);
412
382
  }
413
383
  }
414
-
415
384
  setLastToggledRowId(endRowId);
416
385
  setCheckedRowIds(newCheckedRowIds);
417
386
  };
418
-
419
387
  const singleUpdateCheckedRowIds = index => {
420
388
  if (!rows) {
421
389
  return;
422
390
  }
423
-
424
391
  const {
425
392
  id: rowId,
426
393
  rowPropReference,
427
394
  hasChildRows
428
395
  } = rows[index];
429
396
  setLastToggledRowId(rowId);
430
-
431
397
  if (checkedRowIdsSet.has(rowId)) {
432
398
  let idsToUncheck = [rowId];
433
-
434
399
  if (hasChildRows) {
435
400
  idsToUncheck = idsToUncheck.concat(getAllRowIds(rowPropReference.childRows));
436
401
  }
437
-
438
402
  setCheckedRowIds(checkedRowIds.filter(id => !_includesInstanceProperty(idsToUncheck).call(idsToUncheck, id)));
439
403
  } else {
440
404
  let idsToCheck = [rowId];
441
-
442
405
  if (hasChildRows) {
443
406
  idsToCheck = idsToCheck.concat(getAllRowIds(rowPropReference.childRows).filter(r => !checkedRowIdsSet.has(r)));
444
407
  }
445
-
446
408
  setCheckedRowIds([...checkedRowIds, ...idsToCheck]);
447
409
  }
448
410
  };
449
-
450
411
  const onCellFocus = (rowIndex, columnIndex) => () => {
451
412
  updateRowFocusIndex(rowIndex);
452
413
  updateColumnFocusIndex(columnIndex);
453
414
  };
454
-
455
415
  const onRowFocus = (rowIndex, columnIndex) => e => {
456
416
  if (e.target !== e.currentTarget) return;
457
417
  updateRowFocusIndex(rowIndex);
458
418
  updateColumnFocusIndex(columnIndex);
459
419
  };
460
-
461
420
  const onKeyDown = rowIndex => e => {
462
421
  if (!rows || e.target !== e.currentTarget) return; // Ensures only rows/cells trigger grid navigation
463
-
464
422
  let newFocusedRowIndex;
465
423
  const currentRow = rows[rowIndex];
466
424
  const rowOrFirstColumnIsFocused = focusedColumnIndex <= 0;
467
- const rowCanExpand = (currentRow === null || currentRow === void 0 ? void 0 : currentRow.hasChildRows) && !(currentRow !== null && currentRow !== void 0 && currentRow.isExpanded);
468
- const rowCanCollapse = (currentRow === null || currentRow === void 0 ? void 0 : currentRow.hasChildRows) && (currentRow === null || currentRow === void 0 ? void 0 : currentRow.isExpanded);
469
-
425
+ const rowCanExpand = currentRow?.hasChildRows && !currentRow?.isExpanded;
426
+ const rowCanCollapse = currentRow?.hasChildRows && currentRow?.isExpanded;
470
427
  switch (e.key) {
471
428
  case 'ArrowUp':
472
429
  e.preventDefault(); // prevent scroll
473
-
474
430
  setIsKeyboardUser(true);
475
431
  newFocusedRowIndex = updateRowFocusIndex(rowIndex === minRowIndex ? headerRowIndex : rowIndex - 1);
476
-
477
432
  if (e.shiftKey) {
478
433
  multiUpdateCheckedRowIds(rowIndex, newFocusedRowIndex);
479
434
  }
480
-
481
435
  break;
482
-
483
436
  case 'ArrowDown':
484
437
  e.preventDefault(); // prevent scroll
485
-
486
438
  setIsKeyboardUser(true);
487
439
  newFocusedRowIndex = updateRowFocusIndex(rowIndex === headerRowIndex ? minRowIndex : rowIndex + 1);
488
-
489
440
  if (e.shiftKey) {
490
441
  multiUpdateCheckedRowIds(rowIndex, newFocusedRowIndex);
491
442
  }
492
-
493
443
  break;
494
-
495
444
  case 'ArrowLeft':
496
445
  e.preventDefault(); // prevent scroll
497
-
498
- setIsKeyboardUser(true); // If the row is expanded and on the first cell, collapse the row
499
-
446
+ setIsKeyboardUser(true);
447
+ // If the row is expanded and on the first cell, collapse the row
500
448
  if (e.shiftKey || rowOrFirstColumnIsFocused && rowCanCollapse) {
501
449
  updateExpandedRowIds(rowIndex, false);
502
450
  break;
503
451
  }
504
-
505
452
  updateColumnFocusIndex(focusedColumnIndex - 1);
506
453
  break;
507
-
508
454
  case 'ArrowRight':
509
455
  e.preventDefault(); // prevent scroll
510
-
511
- setIsKeyboardUser(true); // If the row is collapsed and on the first cell, expand the row
512
-
456
+ setIsKeyboardUser(true);
457
+ // If the row is collapsed and on the first cell, expand the row
513
458
  if (e.shiftKey || rowOrFirstColumnIsFocused && rowCanExpand) {
514
459
  updateExpandedRowIds(rowIndex, true);
515
460
  break;
516
461
  }
517
-
518
462
  updateColumnFocusIndex(focusedColumnIndex + 1);
519
463
  break;
520
-
521
464
  case 'PageUp':
522
465
  e.preventDefault(); // prevent scroll
523
-
524
466
  setIsKeyboardUser(true);
525
467
  updateRowFocusIndex(headerRowIndex);
526
468
  break;
527
-
528
469
  case 'PageDown':
529
470
  e.preventDefault(); // prevent scroll
530
-
531
471
  setIsKeyboardUser(true);
532
472
  updateRowFocusIndex(maxRowIndex);
533
473
  break;
534
-
535
474
  case 'Home':
536
475
  e.preventDefault(); // prevent scroll
537
-
538
476
  setIsKeyboardUser(true);
539
477
  updateColumnFocusIndex(minColumnIndex);
540
-
541
478
  if (e.ctrlKey) {
542
479
  updateRowFocusIndex(headerRowIndex);
543
480
  }
544
-
545
481
  break;
546
-
547
482
  case 'End':
548
483
  e.preventDefault(); // prevent scroll
549
-
550
484
  setIsKeyboardUser(true);
551
485
  updateColumnFocusIndex(maxColumnIndex);
552
-
553
486
  if (e.ctrlKey) {
554
487
  updateRowFocusIndex(maxRowIndex);
555
488
  }
556
-
557
489
  break;
558
-
559
490
  case ' ':
560
491
  e.preventDefault(); // prevent scroll
561
-
562
492
  setIsKeyboardUser(true);
563
-
564
493
  if (rowIndex === headerRowIndex) {
565
494
  handleColumnHeaderCheckboxToggle();
566
495
  } else if (e.shiftKey) {
@@ -568,17 +497,12 @@ const AdvancedTable = _ref => {
568
497
  } else {
569
498
  singleUpdateCheckedRowIds(rowIndex);
570
499
  }
571
-
572
500
  break;
573
-
574
501
  default:
575
502
  break;
576
503
  }
577
504
  };
578
-
579
505
  const getColumnHeaderProps = (columnConfig, columnIndex, isPinned) => {
580
- var _columnWidths$id;
581
-
582
506
  const rowIndex = headerRowIndex;
583
507
  const {
584
508
  id,
@@ -591,9 +515,9 @@ const AdvancedTable = _ref => {
591
515
  return {
592
516
  id,
593
517
  isRowActionMenuColumn,
594
- 'data-testid': dataTestId && id ? "".concat(dataTestId, "-").concat(id) : undefined,
518
+ 'data-testid': dataTestId && id ? `${dataTestId}-${id}` : undefined,
595
519
  label: headerLabel,
596
- width: (_columnWidths$id = columnWidths[id]) !== null && _columnWidths$id !== void 0 ? _columnWidths$id : width,
520
+ width: columnWidths[id] ?? width,
597
521
  widthBuffer: columnIndex === 0 && maxRowDepth > 0 ? columnWidthBuffers[0] : undefined,
598
522
  onWidthChange: disableUserResizableColumns || isRowActionMenuColumn ? undefined : newWidth => {
599
523
  setColumnWidths(currentColumnWidths => {
@@ -603,12 +527,9 @@ const AdvancedTable = _ref => {
603
527
  } else if (currentColumnWidths[colId]) {
604
528
  map[colId] = currentColumnWidths[colId];
605
529
  } else {
606
- var _cellRefs$current, _cellRefs$current$hea;
607
-
608
- const colRef = (_cellRefs$current = cellRefs.current) === null || _cellRefs$current === void 0 ? void 0 : (_cellRefs$current$hea = _cellRefs$current[headerRowIndex]) === null || _cellRefs$current$hea === void 0 ? void 0 : _cellRefs$current$hea[index];
609
- map[colId] = colRef === null || colRef === void 0 ? void 0 : colRef.getBoundingClientRect().width;
530
+ const colRef = cellRefs.current?.[headerRowIndex]?.[index];
531
+ map[colId] = colRef?.getBoundingClientRect().width;
610
532
  }
611
-
612
533
  return map;
613
534
  }, {});
614
535
  return newColumnsWidths;
@@ -642,19 +563,16 @@ const AdvancedTable = _ref => {
642
563
  headerMaxLines
643
564
  };
644
565
  };
645
-
646
566
  const getAdvancedTableRowExpandButton = (rowId, isExpanded, rowIndex) => /*#__PURE__*/React__default.createElement(AdvancedTableRowExpandButton, {
647
- "data-testid": dataTestId && rowId ? "".concat(dataTestId, "-row-").concat(rowId, "-expand-button") : undefined,
567
+ "data-testid": dataTestId && rowId ? `${dataTestId}-row-${rowId}-expand-button` : undefined,
648
568
  isRowExpanded: !!isExpanded,
649
569
  onClick: e => {
650
570
  e.stopPropagation(); // prevent onRowSelect
651
-
652
571
  e.preventDefault();
653
572
  updateExpandedRowIds(rowIndex);
654
573
  },
655
574
  onFocus: onRowFocus(rowIndex, minColumnIndex)
656
575
  });
657
-
658
576
  const getExpandableRowsSpacer = function (width, inHeader) {
659
577
  let children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
660
578
  return /*#__PURE__*/React__default.createElement("div", {
@@ -666,10 +584,7 @@ const AdvancedTable = _ref => {
666
584
  }
667
585
  }, children);
668
586
  };
669
-
670
587
  const getCellProps = (columnConfig, columnIndex, data, rowIndex, rowId, depth) => {
671
- var _columnWidths$columnI;
672
-
673
588
  const {
674
589
  id: columnId,
675
590
  width,
@@ -683,18 +598,18 @@ const AdvancedTable = _ref => {
683
598
  setValue: newValue => {
684
599
  const newRows = [...rowsProp];
685
600
  newRows[rowIndex].data[columnId] = newValue;
686
- onRowsChange === null || onRowsChange === void 0 ? void 0 : onRowsChange(newRows);
601
+ onRowsChange?.(newRows);
687
602
  },
688
603
  renderCellContent,
689
604
  isCellContentInteractive,
690
- width: (_columnWidths$columnI = columnWidths[columnId]) !== null && _columnWidths$columnI !== void 0 ? _columnWidths$columnI : width,
605
+ width: columnWidths[columnId] ?? width,
691
606
  widthBuffer: columnIndex === 0 && maxRowDepth > 0 ? columnWidthBuffers[depth] : undefined,
692
607
  alignment,
693
608
  rowId,
694
609
  columnId,
695
610
  rowIndex,
696
611
  columnIndex,
697
- 'data-testid': dataTestId && rowId && columnId ? "".concat(dataTestId, "-cell-").concat(rowId, "-").concat(columnId) : undefined,
612
+ 'data-testid': dataTestId && rowId && columnId ? `${dataTestId}-cell-${rowId}-${columnId}` : undefined,
698
613
  isFocused: rowIndex === focusedRowIndex && columnIndex === focusedColumnIndex,
699
614
  onFocus: onCellFocus(rowIndex, columnIndex),
700
615
  onKeyDown: onKeyDown(rowIndex),
@@ -703,7 +618,6 @@ const AdvancedTable = _ref => {
703
618
  ref: createRef(rowIndex, columnIndex)
704
619
  };
705
620
  };
706
-
707
621
  return /*#__PURE__*/React__default.createElement(DndProvider, {
708
622
  backend: HTML5Backend
709
623
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -736,6 +650,7 @@ const AdvancedTable = _ref => {
736
650
  "aria-rowindex": hasExpandableRows ? undefined : 1,
737
651
  "aria-level": hasExpandableRows ? 1 : undefined // aria-level is one-indexed
738
652
  ,
653
+
739
654
  "aria-setsize": hasExpandableRows ? rowsProp.length + 1 : undefined,
740
655
  "aria-posinset": hasExpandableRows ? 1 : undefined // aria-posinset is one-indexed
741
656
  ,
@@ -754,16 +669,16 @@ const AdvancedTable = _ref => {
754
669
  onClick: handleColumnHeaderCheckboxToggle,
755
670
  onFocus: onRowFocus(headerRowIndex, minColumnIndex),
756
671
  variant: "header"
757
- }), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer("".concat(widthBufferWidth, "px"), true) : undefined, pinnedColumnConfigs.map((columnConfigs, i) => {
672
+ }), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth}px`, true) : undefined, pinnedColumnConfigs.map((columnConfigs, i) => {
758
673
  const props = getColumnHeaderProps(columnConfigs, i, true);
759
674
  return /*#__PURE__*/React__default.createElement(AdvancedTableColumnHeader, props);
760
- })) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer("".concat(widthBufferWidth, "px"), true) : undefined, unpinnedColumnConfigs.map((columnConfigs, i) => {
675
+ })) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth}px`, true) : undefined, unpinnedColumnConfigs.map((columnConfigs, i) => {
761
676
  const props = getColumnHeaderProps(columnConfigs, i + pinnedColumnConfigs.length, false);
762
677
  return /*#__PURE__*/React__default.createElement(AdvancedTableColumnHeader, props);
763
678
  }))), /*#__PURE__*/React__default.createElement("div", {
764
679
  role: "rowgroup",
765
680
  className: styles.advancedTableRowGroup
766
- }, ((_ref5 = paginatedRows !== null && paginatedRows !== void 0 ? paginatedRows : rows) !== null && _ref5 !== void 0 ? _ref5 : []).map((row, rowIndex) => {
681
+ }, (paginatedRows ?? rows ?? []).map((row, rowIndex) => {
767
682
  const {
768
683
  id: rowId,
769
684
  data,
@@ -777,29 +692,25 @@ const AdvancedTable = _ref => {
777
692
  } = row;
778
693
  const hasChildRows = rowPropReference.childRows && rowPropReference.childRows.length > 0;
779
694
  const paginatedRowIndex = getPaginatedRowIndex(rowIndex);
780
-
781
695
  const onSelect = e => {
782
696
  e.preventDefault(); // stops event from triggering on new target when focus is changed during onSelect
783
-
784
697
  if (hasOnRowSelect) {
785
- onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(row.rowPropReference);
698
+ onRowSelect?.(row.rowPropReference);
786
699
  setSelectedRowId(rowId);
787
700
  }
788
701
  };
789
-
790
702
  const onRowKeyDown = e => {
791
703
  if (e.target !== e.currentTarget) return;
792
704
  onKeyDown(paginatedRowIndex)(e);
793
-
794
705
  if (e.key === 'Enter') {
795
706
  onSelect(e);
796
707
  }
797
708
  };
798
-
799
709
  return /*#__PURE__*/React__default.createElement(AdvancedTableRow, _extends({}, rowProps, {
800
710
  "aria-rowindex": hasExpandableRows ? undefined : paginatedRowIndex + 2 // aria-rowindex is one-indexed + the column headers row is the first row in the table
801
711
  ,
802
- "data-testid": dataTestId && rowId ? "".concat(dataTestId, "-row-").concat(rowId) : undefined,
712
+
713
+ "data-testid": dataTestId && rowId ? `${dataTestId}-row-${rowId}` : undefined,
803
714
  hasOnRowSelect: hasOnRowSelect,
804
715
  isFocusable: hasFocusableRows,
805
716
  isFocused: paginatedRowIndex === focusedRowIndex && minColumnIndex === focusedColumnIndex,
@@ -808,13 +719,13 @@ const AdvancedTable = _ref => {
808
719
  onKeyDown: onRowKeyDown,
809
720
  onFocus: onRowFocus(paginatedRowIndex, minColumnIndex),
810
721
  onClick: e => onSelect(e),
811
- key: "".concat(rowId).concat(depth).concat(parentId),
722
+ key: `${rowId}${depth}${parentId}`,
812
723
  ref: createRef(paginatedRowIndex, minColumnIndex),
813
724
  "aria-level": hasExpandableRows ? depth + 1 : undefined // aria-level is one-indexed
814
725
  ,
726
+
815
727
  "aria-setsize": hasExpandableRows ? depthSize : undefined,
816
728
  "aria-posinset": hasExpandableRows ? depthIndex + 1 : undefined // aria-posinset is one-indexed
817
-
818
729
  }), hasCheckboxColumn || pinnedColumnConfigs.length ? /*#__PURE__*/React__default.createElement("div", {
819
730
  className: classNames(styles.pinnedContainer, styles.advancedTableRowChild),
820
731
  ref: createPinnedContainerRef(paginatedRowIndex)
@@ -823,7 +734,6 @@ const AdvancedTable = _ref => {
823
734
  isRowFocused: paginatedRowIndex === focusedRowIndex,
824
735
  onClick: e => {
825
736
  e.stopPropagation(); // prevent onRowSelect
826
-
827
737
  if (e.shiftKey) {
828
738
  multiUpdateCheckedRowIds(getLastToggledRowIndex(), paginatedRowIndex);
829
739
  } else {
@@ -833,22 +743,20 @@ const AdvancedTable = _ref => {
833
743
  onMouseEnter: () => setIsCheckboxHovered(true),
834
744
  onMouseLeave: () => setIsCheckboxHovered(false),
835
745
  onFocus: onRowFocus(paginatedRowIndex, minColumnIndex)
836
- }), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer("".concat(widthBufferWidth * (depth + 1), "px"), false, hasChildRows ? getAdvancedTableRowExpandButton(rowId, isExpanded, rowIndex) : undefined) : undefined, pinnedColumnConfigs.map((c, i) => {
746
+ }), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth * (depth + 1)}px`, false, hasChildRows ? getAdvancedTableRowExpandButton(rowId, isExpanded, rowIndex) : undefined) : undefined, pinnedColumnConfigs.map((c, i) => {
837
747
  const props = getCellProps(c, i, data, paginatedRowIndex, rowId, depth);
838
748
  return /*#__PURE__*/React__default.createElement(AdvancedTableCell, _extends({}, props, {
839
749
  "aria-rowindex": hasExpandableRows ? undefined : rowIndex + 2 // aria-rowindex is one-indexed + the column headers row is the first row in the table
840
750
  ,
841
751
  "aria-colindex": i + 1 // aria-colindex is one-indexed
842
-
843
752
  }));
844
- })) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer("".concat(widthBufferWidth * (depth + 1), "px"), false, hasChildRows ? getAdvancedTableRowExpandButton(rowId, isExpanded, rowIndex) : undefined) : undefined, unpinnedColumnConfigs.map((c, i) => {
753
+ })) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth * (depth + 1)}px`, false, hasChildRows ? getAdvancedTableRowExpandButton(rowId, isExpanded, rowIndex) : undefined) : undefined, unpinnedColumnConfigs.map((c, i) => {
845
754
  const props = getCellProps(c, i + pinnedColumnConfigs.length, data, paginatedRowIndex, rowId, depth);
846
755
  return /*#__PURE__*/React__default.createElement(AdvancedTableCell, _extends({}, props, {
847
756
  className: styles.advancedTableRowChild,
848
757
  "aria-rowindex": hasExpandableRows ? undefined : rowIndex + 2 // aria-rowindex is one-indexed + the column headers row is the first row in the table
849
758
  ,
850
759
  "aria-colindex": i + 1 // aria-colindex is one-indexed
851
-
852
760
  }));
853
761
  }));
854
762
  })), rowsPerPage ? /*#__PURE__*/React__default.createElement(AdvancedTablePagination, {
@@ -860,40 +768,38 @@ const AdvancedTable = _ref => {
860
768
  setCurrentPage: setCurrentPage,
861
769
  "data-testid": getSubDataTestId(dataTestId, 'TablePagination')
862
770
  }) : null));
863
- }; // TODO: move hook to separate file
771
+ };
864
772
 
865
- function useSortedRows(_ref6) {
773
+ // TODO: move hook to separate file
774
+ function useSortedRows(_ref5) {
866
775
  let {
867
776
  columnConfigs,
868
777
  onRowsChange,
869
778
  selectedSortOption,
870
779
  setCurrentPage
871
- } = _ref6;
780
+ } = _ref5;
872
781
  const columnConfigsRef = useLatest(columnConfigs);
873
782
  const onRowsChangeRef = useLatest(onRowsChange);
874
783
  useDidUpdate(() => {
875
- var _columnConfigsRef$cur, _columnConfigsRef$cur2, _columnConfigsRef$cur3;
876
-
877
784
  const {
878
785
  columnId,
879
786
  index
880
787
  } = selectedSortOption;
881
- const sort = (_columnConfigsRef$cur = columnConfigsRef.current.find(_ref7 => {
788
+ const sort = columnConfigsRef.current.find(_ref6 => {
882
789
  let {
883
790
  id
884
- } = _ref7;
791
+ } = _ref6;
885
792
  return id === columnId;
886
- })) === null || _columnConfigsRef$cur === void 0 ? void 0 : (_columnConfigsRef$cur2 = _columnConfigsRef$cur.sortOptions) === null || _columnConfigsRef$cur2 === void 0 ? void 0 : (_columnConfigsRef$cur3 = _columnConfigsRef$cur2[index]) === null || _columnConfigsRef$cur3 === void 0 ? void 0 : _columnConfigsRef$cur3.sort;
887
-
793
+ })?.sortOptions?.[index]?.sort;
888
794
  if (typeof sort === 'function' && onRowsChangeRef.current) {
889
795
  onRowsChangeRef.current(sort(selectedSortOption));
890
796
  setCurrentPage(1);
891
797
  }
892
798
  }, [columnConfigsRef, onRowsChangeRef, selectedSortOption]);
893
- } // TODO: move hook to separate file
894
-
799
+ }
895
800
 
896
- function useFocusState(_ref8) {
801
+ // TODO: move hook to separate file
802
+ function useFocusState(_ref7) {
897
803
  let {
898
804
  headerRowIndex,
899
805
  maxRowIndex,
@@ -903,47 +809,40 @@ function useFocusState(_ref8) {
903
809
  pinnedUnpinnedColumnOrder,
904
810
  tableRef,
905
811
  currentPage
906
- } = _ref8;
812
+ } = _ref7;
907
813
  const cellRefs = useRef({});
908
814
  const pinnedContainersRef = useRef({});
909
815
  const [focusedRowIndex, setFocusedRowIndex] = useState(headerRowIndex);
910
816
  const [focusedColumnIndex, setFocusedColumnIndex] = useState(minColumnIndex);
911
817
  const [focusedColumnId, setFocusedColumnId] = useState();
912
-
913
818
  const createRef = (rowIndex, columnIndex) => node => {
914
819
  if (!cellRefs.current[rowIndex]) {
915
820
  cellRefs.current[rowIndex] = {};
916
821
  }
917
-
918
822
  cellRefs.current[rowIndex][columnIndex] = node;
919
823
  };
920
-
921
824
  const createPinnedContainerRef = rowIndex => node => {
922
825
  pinnedContainersRef.current[rowIndex] = node;
923
826
  };
924
-
925
827
  const updateRowFocusIndex = index => {
926
828
  const newIndex = wrapAround(index, headerRowIndex, maxRowIndex);
927
829
  setFocusedRowIndex(newIndex);
928
830
  return newIndex;
929
831
  };
930
-
931
832
  const updateColumnFocusIndex = index => {
932
833
  const newIndex = wrapAround(index, minColumnIndex, maxColumnIndex);
933
834
  setFocusedColumnIndex(newIndex);
934
835
  return newIndex;
935
836
  };
936
-
937
837
  const focusCell = useEventCallback(cell => {
938
838
  // Manually scroll cells/rows into view if needed
939
839
  if (getIsKeyboardUser()) {
940
- var _tableRef$current, _cellRefs$current2, _cellRefs$current2$he;
941
-
942
- const tablePos = (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.getBoundingClientRect();
943
- const header = (_cellRefs$current2 = cellRefs.current) === null || _cellRefs$current2 === void 0 ? void 0 : (_cellRefs$current2$he = _cellRefs$current2[headerRowIndex]) === null || _cellRefs$current2$he === void 0 ? void 0 : _cellRefs$current2$he[-1];
944
- const headerPos = header === null || header === void 0 ? void 0 : header.getBoundingClientRect();
945
- let cellPos = cell === null || cell === void 0 ? void 0 : cell.getBoundingClientRect(); // Vertical scroll
840
+ const tablePos = tableRef.current?.getBoundingClientRect();
841
+ const header = cellRefs.current?.[headerRowIndex]?.[-1];
842
+ const headerPos = header?.getBoundingClientRect();
843
+ let cellPos = cell?.getBoundingClientRect();
946
844
 
845
+ // Vertical scroll
947
846
  if (cell !== header && !header.contains(cell)) {
948
847
  if (cellPos.top < headerPos.top + headerPos.height) {
949
848
  // Scroll down if cell covered by header
@@ -955,15 +854,13 @@ function useFocusState(_ref8) {
955
854
  // Scroll up if cell out of view below table
956
855
  tableRef.current.scrollTop += cellPos.bottom - tablePos.bottom;
957
856
  }
958
- } // Horizontal scroll
959
- // Scroll left if an entire row is focused
960
-
857
+ }
961
858
 
859
+ // Horizontal scroll
860
+ // Scroll left if an entire row is focused
962
861
  if (minColumnIndex === -1 && focusedColumnIndex === minColumnIndex) {
963
862
  tableRef.current.scrollLeft -= tablePos.left - cellPos.left;
964
863
  } else {
965
- var _pinnedContainersRef$;
966
-
967
864
  if (cellPos.left < tablePos.left) {
968
865
  // Scroll right if cell out of view to the left of the table
969
866
  tableRef.current.scrollLeft -= tablePos.left - cellPos.left;
@@ -971,39 +868,36 @@ function useFocusState(_ref8) {
971
868
  // Scroll left if cell out of view to the right of the table
972
869
  tableRef.current.scrollLeft += cellPos.right - tablePos.right;
973
870
  }
871
+ const pinnedContainer = pinnedContainersRef.current?.[focusedRowIndex];
872
+ const pinnedContainerPos = pinnedContainer?.getBoundingClientRect();
873
+ cellPos = cell?.getBoundingClientRect();
974
874
 
975
- const pinnedContainer = (_pinnedContainersRef$ = pinnedContainersRef.current) === null || _pinnedContainersRef$ === void 0 ? void 0 : _pinnedContainersRef$[focusedRowIndex];
976
- const pinnedContainerPos = pinnedContainer === null || pinnedContainer === void 0 ? void 0 : pinnedContainer.getBoundingClientRect();
977
- cellPos = cell === null || cell === void 0 ? void 0 : cell.getBoundingClientRect(); // Scroll right if cell covered by pinned columns
978
-
875
+ // Scroll right if cell covered by pinned columns
979
876
  if (pinnedContainer && cellPos.left < pinnedContainerPos.left + pinnedContainerPos.width && !pinnedContainer.contains(cell)) {
980
877
  tableRef.current.scrollLeft -= pinnedContainerPos.left + pinnedContainerPos.width - cellPos.left;
981
878
  }
982
879
  }
983
880
  }
881
+ cell?.focus();
882
+ });
984
883
 
985
- cell === null || cell === void 0 ? void 0 : cell.focus();
986
- }); // Focus header cell when the focused column id changes. Used when pinning/unpinning columns since a new DOM element is created.
987
-
884
+ // Focus header cell when the focused column id changes. Used when pinning/unpinning columns since a new DOM element is created.
988
885
  useDidUpdate(() => {
989
886
  if (focusedColumnId) {
990
- var _cellRefs$current3, _cellRefs$current3$fo;
991
-
992
887
  const columnIndex = pinnedUnpinnedColumnOrder.indexOf(focusedColumnId);
993
- focusCell((_cellRefs$current3 = cellRefs.current) === null || _cellRefs$current3 === void 0 ? void 0 : (_cellRefs$current3$fo = _cellRefs$current3[focusedRowIndex]) === null || _cellRefs$current3$fo === void 0 ? void 0 : _cellRefs$current3$fo[columnIndex]);
888
+ focusCell(cellRefs.current?.[focusedRowIndex]?.[columnIndex]);
994
889
  setFocusedColumnIndex(columnIndex);
995
890
  setFocusedColumnId(undefined);
996
891
  }
997
- }, [focusedColumnId, pinnedUnpinnedColumnOrder]); // Focus cell when the focused indices change
892
+ }, [focusedColumnId, pinnedUnpinnedColumnOrder]);
998
893
 
894
+ // Focus cell when the focused indices change
999
895
  useDidUpdate(() => {
1000
- var _cellRefs$current4, _cellRefs$current4$fo;
896
+ const newFocusedCell = cellRefs.current?.[focusedRowIndex]?.[focusedColumnIndex];
1001
897
 
1002
- const newFocusedCell = (_cellRefs$current4 = cellRefs.current) === null || _cellRefs$current4 === void 0 ? void 0 : (_cellRefs$current4$fo = _cellRefs$current4[focusedRowIndex]) === null || _cellRefs$current4$fo === void 0 ? void 0 : _cellRefs$current4$fo[focusedColumnIndex];
1003
898
  /* Prevent cells from stealing focus from their children when they
1004
899
  * receive focus, but still allow focus to move from a cell to a row.
1005
900
  */
1006
-
1007
901
  if (!newFocusedCell.contains(document.activeElement) || hasFocusableRows && focusedColumnIndex === minColumnIndex) {
1008
902
  focusCell(newFocusedCell);
1009
903
  }