@economic/taco 1.19.1 → 1.21.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 (183) hide show
  1. package/dist/components/AlertDialog/components/Content.d.ts +1 -1
  2. package/dist/components/Calendar/Calendar.d.ts +1 -1
  3. package/dist/components/Calendar/Calendar.stories.d.ts +1 -1
  4. package/dist/components/Datepicker/Datepicker.d.ts +1 -1
  5. package/dist/components/Datepicker/Datepicker.stories.d.ts +1 -1
  6. package/dist/components/Dialog/components/Content.d.ts +1 -1
  7. package/dist/components/Dialog/components/Drawer.d.ts +1 -1
  8. package/dist/components/IconButton/IconButton.d.ts +2 -2
  9. package/dist/components/Input/Input.d.ts +1 -1
  10. package/dist/components/Listbox/Listbox.d.ts +2 -2
  11. package/dist/components/Listbox/Listbox.stories.d.ts +1 -1
  12. package/dist/components/Listbox/ScrollableList.d.ts +1 -1
  13. package/dist/components/Menu/components/Checkbox.d.ts +1 -1
  14. package/dist/components/Menu/components/Content.d.ts +1 -1
  15. package/dist/components/Menu/components/Item.d.ts +1 -1
  16. package/dist/components/Menu/components/Link.d.ts +1 -1
  17. package/dist/components/Menu/components/Trigger.d.ts +1 -1
  18. package/dist/components/Provider/Localization.d.ts +26 -0
  19. package/dist/components/SearchInput/SearchInput.d.ts +1 -1
  20. package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -1
  21. package/dist/components/Select/Select.d.ts +1 -1
  22. package/dist/components/Select/Select.stories.d.ts +1 -1
  23. package/dist/components/Select2/components/Option.d.ts +1 -1
  24. package/dist/components/Select2/components/Search.d.ts +1 -1
  25. package/dist/components/Select2/components/Trigger.d.ts +1 -1
  26. package/dist/components/Shortcut/Shortcut.d.ts +5 -0
  27. package/dist/components/Table2/Table2.d.ts +33 -0
  28. package/dist/components/Table2/Table2.stories.d.ts +50 -0
  29. package/dist/components/Table2/components/BatchActionsMenu.d.ts +10 -0
  30. package/dist/components/Table2/components/ColumnSettingsButton.d.ts +7 -0
  31. package/dist/components/Table2/components/EditModeButton.d.ts +7 -0
  32. package/dist/components/Table2/components/RowDensityButton.d.ts +7 -0
  33. package/dist/components/Table2/components/Search.d.ts +3 -0
  34. package/dist/components/Table2/components/ShortcutsGuideButton.d.ts +7 -0
  35. package/dist/components/Table2/components/column/Base.d.ts +12 -0
  36. package/dist/components/Table2/components/column/Cell.d.ts +15 -0
  37. package/dist/components/Table2/components/column/Footer.d.ts +9 -0
  38. package/dist/components/Table2/components/column/Header.d.ts +11 -0
  39. package/dist/components/Table2/components/column/Indicator.d.ts +16 -0
  40. package/dist/components/Table2/components/column/ValidationError.d.ts +5 -0
  41. package/dist/components/Table2/components/column/utils.d.ts +2 -0
  42. package/dist/components/Table2/components/filters/FiltersButton.d.ts +7 -0
  43. package/dist/components/Table2/components/filters/components/Column.d.ts +11 -0
  44. package/dist/components/Table2/components/filters/components/ColumnFilter.d.ts +9 -0
  45. package/dist/components/Table2/components/filters/components/Comparator.d.ts +11 -0
  46. package/dist/components/Table2/components/filters/components/InferredControl.d.ts +10 -0
  47. package/dist/components/Table2/components/row/Context.d.ts +16 -0
  48. package/dist/components/Table2/components/row/ExpandedRow.d.ts +6 -0
  49. package/dist/components/Table2/components/row/Row.d.ts +7 -0
  50. package/dist/components/Table2/hooks/listeners/useActiveCellStateListener.d.ts +3 -0
  51. package/dist/components/Table2/hooks/listeners/useActiveRowStateListener.d.ts +3 -0
  52. package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +4 -0
  53. package/dist/components/Table2/hooks/listeners/useRowSelectionListener.d.ts +3 -0
  54. package/dist/components/Table2/hooks/listeners/useSettingsStateListener.d.ts +3 -0
  55. package/dist/components/Table2/hooks/useActiveCell.d.ts +26 -0
  56. package/dist/components/Table2/hooks/useActiveRow.d.ts +10 -0
  57. package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +36 -0
  58. package/dist/components/Table2/hooks/useEditMode.d.ts +28 -0
  59. package/dist/components/Table2/hooks/useGridTemplate.d.ts +2 -0
  60. package/dist/components/Table2/hooks/useSeparatedChildren.d.ts +1 -0
  61. package/dist/components/Table2/hooks/useTable.d.ts +41 -0
  62. package/dist/components/Table2/hooks/useVirtualiser.d.ts +23 -0
  63. package/dist/components/Table2/types.d.ts +139 -0
  64. package/dist/components/Table2/utilities/cell.d.ts +13 -0
  65. package/dist/components/Table2/utilities/columns.d.ts +13 -0
  66. package/dist/components/Table2/utilities/filterFn.d.ts +3 -0
  67. package/dist/components/Tag/Tag.d.ts +1 -1
  68. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  69. package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -1
  70. package/dist/esm/index.css +1 -1
  71. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js +14 -1
  72. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js.map +1 -1
  73. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +13 -5
  74. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  75. package/dist/esm/packages/taco/src/components/Provider/Localization.js +23 -0
  76. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  77. package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js +18 -0
  78. package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js.map +1 -0
  79. package/dist/esm/packages/taco/src/components/Table2/Table2.js +374 -0
  80. package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +1 -0
  81. package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js +83 -0
  82. package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js.map +1 -0
  83. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +238 -0
  84. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +1 -0
  85. package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +58 -0
  86. package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js.map +1 -0
  87. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +31 -0
  88. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +1 -0
  89. package/dist/esm/packages/taco/src/components/Table2/components/Search.js +55 -0
  90. package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +1 -0
  91. package/dist/esm/packages/taco/src/components/Table2/components/ShortcutsGuideButton.js +94 -0
  92. package/dist/esm/packages/taco/src/components/Table2/components/ShortcutsGuideButton.js.map +1 -0
  93. package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js +32 -0
  94. package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js.map +1 -0
  95. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +516 -0
  96. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +1 -0
  97. package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js +27 -0
  98. package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js.map +1 -0
  99. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +159 -0
  100. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +1 -0
  101. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +78 -0
  102. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +1 -0
  103. package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js +30 -0
  104. package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js.map +1 -0
  105. package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +38 -0
  106. package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +1 -0
  107. package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +89 -0
  108. package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js.map +1 -0
  109. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js +31 -0
  110. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js.map +1 -0
  111. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js +121 -0
  112. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js.map +1 -0
  113. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js +60 -0
  114. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js.map +1 -0
  115. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js +96 -0
  116. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js.map +1 -0
  117. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +26 -0
  118. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +1 -0
  119. package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js +33 -0
  120. package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js.map +1 -0
  121. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +58 -0
  122. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +1 -0
  123. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js +19 -0
  124. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js.map +1 -0
  125. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +44 -0
  126. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +1 -0
  127. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js +17 -0
  128. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js.map +1 -0
  129. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js +25 -0
  130. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js.map +1 -0
  131. package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js +33 -0
  132. package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js.map +1 -0
  133. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +109 -0
  134. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +1 -0
  135. package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js +112 -0
  136. package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js.map +1 -0
  137. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +36 -0
  138. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +1 -0
  139. package/dist/esm/packages/taco/src/components/Table2/hooks/useSeparatedChildren.js +21 -0
  140. package/dist/esm/packages/taco/src/components/Table2/hooks/useSeparatedChildren.js.map +1 -0
  141. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +202 -0
  142. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +1 -0
  143. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +49 -0
  144. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +1 -0
  145. package/dist/esm/packages/taco/src/components/Table2/types.js +16 -0
  146. package/dist/esm/packages/taco/src/components/Table2/types.js.map +1 -0
  147. package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +41 -0
  148. package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +1 -0
  149. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +311 -0
  150. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +1 -0
  151. package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js +96 -0
  152. package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js.map +1 -0
  153. package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js +16 -0
  154. package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js.map +1 -0
  155. package/dist/esm/packages/taco/src/hooks/useGlobalKeyboardShortcut.js +13 -0
  156. package/dist/esm/packages/taco/src/hooks/useGlobalKeyboardShortcut.js.map +1 -0
  157. package/dist/esm/packages/taco/src/index.js +4 -2
  158. package/dist/esm/packages/taco/src/index.js.map +1 -1
  159. package/dist/esm/packages/taco/src/primitives/Sortable/components/Container.js +59 -0
  160. package/dist/esm/packages/taco/src/primitives/Sortable/components/Container.js.map +1 -0
  161. package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js +47 -0
  162. package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -0
  163. package/dist/esm/packages/taco/src/primitives/Sortable/components/List.js +28 -0
  164. package/dist/esm/packages/taco/src/primitives/Sortable/components/List.js.map +1 -0
  165. package/dist/esm/packages/taco/src/utils/date.js +4 -1
  166. package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
  167. package/dist/esm/packages/taco/src/utils/dom.js +2 -1
  168. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  169. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +20 -0
  170. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -0
  171. package/dist/hooks/useGlobalKeyboardShortcut.d.ts +1 -0
  172. package/dist/index.css +1 -1
  173. package/dist/index.d.ts +2 -0
  174. package/dist/primitives/Sortable/Sortable.d.ts +2 -2
  175. package/dist/taco.cjs.development.js +3489 -90
  176. package/dist/taco.cjs.development.js.map +1 -1
  177. package/dist/taco.cjs.production.min.js +1 -1
  178. package/dist/taco.cjs.production.min.js.map +1 -1
  179. package/dist/utils/date.d.ts +1 -0
  180. package/dist/utils/hooks/useTruncated.d.ts +3 -0
  181. package/package.json +4 -2
  182. package/tailwind.config.js +11 -1
  183. package/types.json +1368 -2
@@ -34,8 +34,14 @@ var unset = _interopDefault(require('lodash/unset'));
34
34
  var get = _interopDefault(require('lodash/get'));
35
35
  var compact = _interopDefault(require('lodash/compact'));
36
36
  var pullAt = _interopDefault(require('lodash/pullAt'));
37
- var TabsPrimitive = require('@radix-ui/react-tabs');
37
+ var reactTable$1 = require('@tanstack/react-table');
38
38
  var PrimitiveSwitch = require('@radix-ui/react-switch');
39
+ var ReactDOM = _interopDefault(require('react-dom'));
40
+ var reactVirtual = require('react-virtual');
41
+ var core = require('@dnd-kit/core');
42
+ var sortable = require('@dnd-kit/sortable');
43
+ var utilities = require('@dnd-kit/utilities');
44
+ var TabsPrimitive = require('@radix-ui/react-tabs');
39
45
  var Joyride = require('react-joyride');
40
46
  var Joyride__default = _interopDefault(Joyride);
41
47
 
@@ -3628,6 +3634,29 @@ const defaultLocalisationTexts = {
3628
3634
  newSubRow: 'New row (shift + n)',
3629
3635
  loading: 'Loading...'
3630
3636
  },
3637
+ table2: {
3638
+ shortcuts: {
3639
+ search: 'Search',
3640
+ filter: 'Filter',
3641
+ previousRow: 'Previous row',
3642
+ nextRow: 'Next row',
3643
+ editCell: 'Edit cell',
3644
+ previousColumn: 'Previous column',
3645
+ nextColumn: 'Next column',
3646
+ rowClick: 'Activate current row',
3647
+ selectRow: 'Select current row',
3648
+ selectAllRows: 'Select all rows',
3649
+ expandRow: 'Expand current row',
3650
+ collapseRow: 'Collapse current row'
3651
+ },
3652
+ rowIndicator: {
3653
+ rowWillMove: 'Row will move due to sorting',
3654
+ rowWillBeFiltered: 'Row will hide due to filtering',
3655
+ searchFilterMovementReason: 'Due to a search filter applied to this table, this row will be hidden as soon as you select another row',
3656
+ tableFilterMovementReason: "Due to a filter applied to the column '[COLUMN]', this row will be hidden as soon as you select another row",
3657
+ sortingMovementReason: "Due to sorting applied to the column '[COLUMN]', this row will move position as soon as you select another row"
3658
+ }
3659
+ },
3631
3660
  select: {
3632
3661
  allOptionsSelected: 'All'
3633
3662
  },
@@ -3915,14 +3944,15 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
3915
3944
  ...otherProps
3916
3945
  } = props;
3917
3946
  const id = useId(props.id);
3918
- const className = cn('bg-white h-5 w-5 border rounded text-sm flex-shrink-0 self-start mt-[0.1rem] focus:yt-focus',
3947
+ const className = cn('bg-white h-5 w-5 border rounded text-sm flex-shrink-0 mt-[0.1rem] focus:yt-focus',
3919
3948
  //hover:shadow-[0_0_0_1px_rgba(235,235,235,1)]
3920
- props.className, {
3949
+ {
3921
3950
  'border-grey-300 text-blue-500 hover:text-blue-300 focus:border-blue-500 focus:hover:border-blue-300': !props.disabled && !invalid,
3922
3951
  'border-grey-200 text-blue-300 cursor-not-allowed': props.disabled,
3923
3952
  'bg-[rgba(255,255,0,0.2)] disabled:bg-[rgba(255,255,0,0.075)]': highlighted,
3924
- 'border-red-500 text-red-500 hover:text-red-300 hover:border-red-300 focus:border-red-500 focus:hover:border-red-300': invalid && !props.disabled
3925
- });
3953
+ 'border-red-500 text-red-500 hover:text-red-300 hover:border-red-300 focus:border-red-500 focus:hover:border-red-300': invalid && !props.disabled,
3954
+ 'self-start': !!label
3955
+ }, props.className);
3926
3956
  let handleChange;
3927
3957
  if (onChange) {
3928
3958
  handleChange = checked => onChange(checked === 'indeterminate' ? false : checked);
@@ -3934,11 +3964,18 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
3934
3964
  id
3935
3965
  };
3936
3966
  }
3967
+ // the enter keyboard shortcut isn't supported by default, but we want it
3968
+ const handleKeyDown = event => {
3969
+ if (event.key === 'Enter') {
3970
+ event.currentTarget.click();
3971
+ }
3972
+ };
3937
3973
  const element = /*#__PURE__*/React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, labelledByProps, {
3938
3974
  "data-taco": "checkbox",
3939
3975
  checked: indeterminate ? 'indeterminate' : checked,
3940
3976
  className: className,
3941
3977
  onCheckedChange: handleChange,
3978
+ onKeyDown: handleKeyDown,
3942
3979
  ref: ref
3943
3980
  }), /*#__PURE__*/React.createElement(CheckboxPrimitive.Indicator, {
3944
3981
  className: "flex h-full w-full"
@@ -3949,7 +3986,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
3949
3986
  if (label) {
3950
3987
  const labelContainerClassName = cn('flex items-center cursor-pointer gap-2', {
3951
3988
  'cursor-not-allowed text-grey-300': props.disabled
3952
- }, props.className);
3989
+ });
3953
3990
  return /*#__PURE__*/React.createElement("span", {
3954
3991
  className: labelContainerClassName
3955
3992
  }, element, /*#__PURE__*/React.createElement("label", {
@@ -4899,6 +4936,9 @@ const Combobox = /*#__PURE__*/React.forwardRef(function Combobox(props, ref) {
4899
4936
  }))))));
4900
4937
  });
4901
4938
 
4939
+ const isWeakEqual = (leftDate, rightDate) => {
4940
+ return leftDate.getFullYear() === rightDate.getFullYear() && leftDate.getMonth() === rightDate.getMonth() && leftDate.getDay() === rightDate.getDay();
4941
+ };
4902
4942
  const format = (date, mask = 'dd.mm.yy') => {
4903
4943
  if (!date) {
4904
4944
  return undefined;
@@ -7826,6 +7866,19 @@ function _catch(body, recover) {
7826
7866
  return result;
7827
7867
  }
7828
7868
 
7869
+ // Asynchronously await a promise and pass the result to a finally continuation
7870
+ function _finallyRethrows(body, finalizer) {
7871
+ try {
7872
+ var result = body();
7873
+ } catch (e) {
7874
+ return finalizer(true, e);
7875
+ }
7876
+ if (result && result.then) {
7877
+ return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
7878
+ }
7879
+ return finalizer(false, result);
7880
+ }
7881
+
7829
7882
  const AVAILABLE_COLORS = /*#__PURE__*/Object.keys(TAG_COLORS);
7830
7883
  const EditPopover = props => {
7831
7884
  const {
@@ -8094,6 +8147,7 @@ const Title$4 = /*#__PURE__*/React__default.forwardRef(function Select2Title(pro
8094
8147
  }));
8095
8148
  });
8096
8149
 
8150
+ const isOverflowing = element => element !== null ? element.scrollWidth > element.offsetWidth : false;
8097
8151
  const getIndexOfFirstChildOverflowingParent = (element, overscan = 0) => {
8098
8152
  let index = 0;
8099
8153
  let boundaryChildIndex = null;
@@ -8829,6 +8883,19 @@ const ControlledHiddenField = props => {
8829
8883
  };
8830
8884
  Select2.displayName = 'Select2';
8831
8885
 
8886
+ const Shortcut$1 = ({
8887
+ keys,
8888
+ ...props
8889
+ }) => {
8890
+ const className = cn('inline-flex gap-0.5', props.className);
8891
+ return /*#__PURE__*/React__default.createElement("span", Object.assign({}, props, {
8892
+ className: className
8893
+ }), keys.map(key => /*#__PURE__*/React__default.createElement("kbd", {
8894
+ key: key,
8895
+ className: "wcag-blue-900 inline-flex h-4 items-center rounded px-1 font-mono text-xs font-normal"
8896
+ }, key)));
8897
+ };
8898
+
8832
8899
  const sanitizeRowProps = (row, rowExpansionRenderer) => {
8833
8900
  var _row$subRows;
8834
8901
  const props = {
@@ -10299,96 +10366,364 @@ const useTableRowCreation = (data, tableRef) => {
10299
10366
  };
10300
10367
  };
10301
10368
 
10302
- const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(props, ref) {
10303
- const {
10304
- id,
10305
- defaultId,
10306
- children,
10307
- onChange,
10308
- orientation = 'horizontal',
10309
- ...otherProps
10310
- } = props;
10311
- const className = cn('yt-tabs', `yt-tabs--${orientation}`, {
10312
- 'flex w-full': orientation === 'vertical'
10313
- }, props.className);
10314
- return /*#__PURE__*/React.createElement(TabsPrimitive.Root, Object.assign({}, otherProps, {
10315
- className: className,
10316
- "data-taco": "tabs",
10317
- defaultValue: defaultId,
10318
- dir: "ltr",
10319
- onValueChange: onChange,
10320
- orientation: orientation,
10321
- ref: ref,
10322
- value: id
10323
- }), children);
10324
- });
10325
- const TabList = /*#__PURE__*/React.forwardRef(function Tab(props, ref) {
10326
- const className = cn('yt-tab__list border-b border-grey-300 flex flex-row m-0 mb-4', props.className);
10327
- return /*#__PURE__*/React.createElement(TabsPrimitive.List, Object.assign({}, props, {
10328
- className: className,
10329
- ref: ref
10330
- }));
10331
- });
10332
- const TabTrigger = /*#__PURE__*/React.forwardRef(function Tab(props, ref) {
10333
- const {
10334
- id,
10335
- disabled,
10336
- ...otherProps
10337
- } = props;
10338
- const className = cn('yt-tab bg-transparent border-b-2 border-transparent text-grey-700 m-0 py-2 px-4', disabled ? 'cursor-not-allowed !text-grey-500' : 'cursor-pointer rounded-t hover:border-grey-300 aria-selected:border-blue-500 aria-selected:text-black aria-selected:hover:border-blue-300 hover:text-black active:yt-focus active:border-blue-500 focus:yt-focus focus:border-blue-500', props.className);
10339
- return /*#__PURE__*/React.createElement(TabsPrimitive.Trigger, Object.assign({}, otherProps, {
10340
- className: className,
10341
- disabled: disabled,
10342
- ref: ref,
10369
+ const COLUMN_ID_FOR_DRAGGABLE = '__draggable';
10370
+ const COLUMN_ID_FOR_SELECTION = '__select';
10371
+ const COLUMN_ID_FOR_EXPANSION = '__expansion';
10372
+ const COLUMN_ID_FOR_ACTIONS = '__actions';
10373
+ const isInternalColumn = id => id === COLUMN_ID_FOR_SELECTION || id === COLUMN_ID_FOR_EXPANSION || id === COLUMN_ID_FOR_ACTIONS || id === COLUMN_ID_FOR_DRAGGABLE;
10374
+ const MIN_COLUMN_SIZE = 80; // accounts for padding and sort controls
10375
+ const toggleBetween$1 = (fromRowIndex, toRowIndex) => {
10376
+ const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;
10377
+ const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;
10378
+ return [fromIndex, toIndex];
10379
+ };
10380
+ function createRowDraggableColumn(onRowDrag) {
10381
+ return {
10382
+ id: COLUMN_ID_FOR_DRAGGABLE,
10383
+ cell: ({
10384
+ row,
10385
+ table
10386
+ }) => {
10387
+ const meta = table.options.meta;
10388
+ const GHOST_ELEMENT_ID = 'taco_table_dragging';
10389
+ const onDragStart = event => {
10390
+ const rows = row.getIsSelected() ? table.getSelectedRowModel().rows : [row, ...table.getSelectedRowModel().rows];
10391
+ meta.setDragging(rows.reduce((dragging, rowBeingDragged) => ({
10392
+ ...dragging,
10393
+ [rowBeingDragged.id]: true
10394
+ }), {}));
10395
+ const data = rows.map(row => row.original);
10396
+ // set a default data value so that the consumer doesn't have to
10397
+ event.dataTransfer.setData('text', JSON.stringify(data));
10398
+ const showPlaceholder = text => {
10399
+ const ghost = document.createElement('div');
10400
+ ghost.id = GHOST_ELEMENT_ID;
10401
+ ghost.className = 'wcag-blue rounded flex w-48 p-4 absolute -ml-[100vw]';
10402
+ ghost.innerText = text;
10403
+ document.body.appendChild(ghost);
10404
+ event.dataTransfer.setDragImage(ghost, 0, 0);
10405
+ };
10406
+ const setDataTransfer = text => event.dataTransfer.setData('text', text);
10407
+ onRowDrag(data, showPlaceholder, setDataTransfer);
10408
+ };
10409
+ const onDragEnd = () => {
10410
+ var _document$getElementB;
10411
+ (_document$getElementB = document.getElementById(GHOST_ELEMENT_ID)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
10412
+ meta.setDragging({});
10413
+ };
10414
+ return /*#__PURE__*/React__default.createElement("div", {
10415
+ draggable: true,
10416
+ onDragStart: onDragStart,
10417
+ onDragEnd: onDragEnd
10418
+ }, /*#__PURE__*/React__default.createElement(Icon, {
10419
+ "aria-label": "Drag row",
10420
+ name: "drag",
10421
+ className: "text-grey-darkest invisible w-[20px] cursor-grab active:cursor-grabbing group-hover/row:visible group-[[aria-grabbed]]/row:text-white"
10422
+ }));
10423
+ },
10424
+ meta: {
10425
+ align: 'center',
10426
+ className: 'items-center !px-0',
10427
+ disableTruncation: true,
10428
+ headerClassName: 'items-center !px-0'
10429
+ },
10430
+ // sizing
10431
+ enableResizing: false,
10432
+ size: 10
10433
+ };
10434
+ }
10435
+ function createRowSelectionColumn(enableMultipleRowSelection, lastSelectedRowIndex, onRowDrag, tableRef) {
10436
+ let header;
10437
+ let cell;
10438
+ if (enableMultipleRowSelection) {
10439
+ header = ({
10440
+ table
10441
+ }) => /*#__PURE__*/React__default.createElement(Tooltip, {
10442
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, table.getIsAllPageRowsSelected() ? 'Deselect all' : 'Select all', /*#__PURE__*/React__default.createElement(Shortcut$1, {
10443
+ className: "ml-2",
10444
+ keys: ['Ctrl', 'A']
10445
+ }))
10446
+ }, /*#__PURE__*/React__default.createElement(Checkbox, {
10447
+ "aria-label": table.getIsAllPageRowsSelected() ? 'Deselect all rows' : 'Select all rows',
10448
+ className: "hover:border-blue !mt-0",
10449
+ checked: table.getIsAllPageRowsSelected(),
10450
+ indeterminate: table.getIsSomePageRowsSelected(),
10451
+ onChange: checked => table.toggleAllPageRowsSelected(checked),
10452
+ onClick: () => {
10453
+ var _tableRef$current;
10454
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.focus();
10455
+ },
10456
+ tabIndex: -1
10457
+ }));
10458
+ cell = ({
10459
+ row,
10460
+ table
10461
+ }) => {
10462
+ const meta = table.options.meta;
10463
+ const handleClick = event => {
10464
+ var _tableRef$current2;
10465
+ event.stopPropagation();
10466
+ if (event.shiftKey) {
10467
+ const [fromIndex, toIndex] = toggleBetween$1((lastSelectedRowIndex === null || lastSelectedRowIndex === void 0 ? void 0 : lastSelectedRowIndex.current) || 0, row.index);
10468
+ table.getRowModel().rows.slice(fromIndex, toIndex + 1).forEach(row => row.toggleSelected(true));
10469
+ } else {
10470
+ row.toggleSelected();
10471
+ }
10472
+ lastSelectedRowIndex.current = row.index;
10473
+ meta.setActiveRowIndex(row.index);
10474
+ (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.focus();
10475
+ };
10476
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
10477
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, table.getIsAllPageRowsSelected() ? 'Deselect' : 'Select', /*#__PURE__*/React__default.createElement(Shortcut$1, {
10478
+ className: "ml-2",
10479
+ keys: ['Space']
10480
+ }))
10481
+ }, /*#__PURE__*/React__default.createElement(Checkbox, {
10482
+ "aria-label": row.getIsSelected() ? 'Deselect row' : 'Select row',
10483
+ className: "hover:border-blue !mt-[0.45rem]",
10484
+ checked: row.getIsSelected(),
10485
+ onClick: handleClick,
10486
+ // this is necessary to remove console spam from eslint
10487
+ onChange: () => false,
10488
+ tabIndex: -1
10489
+ }));
10490
+ };
10491
+ } else {
10492
+ cell = ({
10493
+ row,
10494
+ table
10495
+ }) => {
10496
+ const meta = table.options.meta;
10497
+ const className = 'border-grey-300 focus:yt-focus flex h-5 w-5 mt-[0.45rem] flex-shrink-0 items-center justify-center self-start rounded-full border-2 bg-white hover:border-[5px] aria-checked:border-blue-500 aria-checked:bg-blue-500 hover:aria-checked:border-blue-300';
10498
+ const handleClick = event => {
10499
+ var _tableRef$current3;
10500
+ event.stopPropagation();
10501
+ row.toggleSelected();
10502
+ meta.setActiveRowIndex(row.index);
10503
+ (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : _tableRef$current3.focus();
10504
+ };
10505
+ return /*#__PURE__*/React__default.createElement("button", {
10506
+ className: className,
10507
+ "aria-checked": row.getIsSelected(),
10508
+ onClick: handleClick,
10509
+ role: "radio",
10510
+ tabIndex: -1,
10511
+ type: "button"
10512
+ }, row.getIsSelected() ? /*#__PURE__*/React__default.createElement("span", {
10513
+ className: "h-2.5 w-2.5 rounded-full bg-white"
10514
+ }) : null);
10515
+ };
10516
+ }
10517
+ return {
10518
+ id: COLUMN_ID_FOR_SELECTION,
10519
+ header,
10520
+ cell,
10521
+ meta: {
10522
+ align: 'center',
10523
+ className: onRowDrag ? '!pl-0 !pr-3' : '!px-3',
10524
+ disableTruncation: true,
10525
+ headerClassName: onRowDrag ? '!pl-0 !pr-3' : '!px-3'
10526
+ },
10527
+ // sizing
10528
+ enableResizing: false,
10529
+ size: 46
10530
+ };
10531
+ }
10532
+ function createRowExpansionColumn() {
10533
+ return {
10534
+ id: COLUMN_ID_FOR_EXPANSION,
10535
+ header: ({
10536
+ table
10537
+ }) => /*#__PURE__*/React__default.createElement(Tooltip, {
10538
+ title: table.getIsSomeRowsExpanded() ? 'Collapse all' : 'Expand all'
10539
+ }, /*#__PURE__*/React__default.createElement(IconButton, {
10540
+ title: table.getIsSomeRowsExpanded() ? 'Collapse all rows' : 'Expand all rows',
10541
+ appearance: "discrete",
10542
+ className: "-mb-2 -mt-1.5",
10543
+ icon: table.getIsSomeRowsExpanded() ? 'chevron-down-double' : 'chevron-right-double',
10544
+ onClick: event => {
10545
+ event.stopPropagation();
10546
+ table.toggleAllRowsExpanded(table.getIsSomeRowsExpanded() ? false : true);
10547
+ },
10548
+ tabIndex: -1
10549
+ })),
10550
+ cell: ({
10551
+ row
10552
+ }) => /*#__PURE__*/React__default.createElement(Tooltip, {
10553
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, row.getIsExpanded() ? 'Collapse' : 'Expand', /*#__PURE__*/React__default.createElement(Shortcut$1, {
10554
+ className: "ml-2",
10555
+ keys: ['Ctrl', row.getIsExpanded() ? '←' : '→']
10556
+ }))
10557
+ }, /*#__PURE__*/React__default.createElement(IconButton, {
10558
+ title: row.getIsExpanded() ? 'Collapse row' : 'Expand row',
10559
+ appearance: "discrete",
10560
+ icon: row.getIsExpanded() ? 'chevron-down' : 'chevron-right',
10561
+ onClick: event => {
10562
+ event.stopPropagation();
10563
+ row.toggleExpanded();
10564
+ },
10565
+ tabIndex: -1
10566
+ })),
10567
+ meta: {
10568
+ align: 'center',
10569
+ className: 'items-center !p-0',
10570
+ disableTruncation: true,
10571
+ headerClassName: 'items-center hover:!bg-white !p-0'
10572
+ },
10573
+ // sizing
10574
+ enableResizing: false,
10575
+ size: 36
10576
+ };
10577
+ }
10578
+ const getActionPropertyValue = (property, row) => typeof property === 'function' ? property(row) : property;
10579
+ function RowActionCell({
10580
+ row,
10581
+ actions,
10582
+ moreActions
10583
+ }) {
10584
+ const isVisible = action => typeof action.visible !== 'undefined' ? typeof action.visible === 'function' ? action.visible(row.original) : action.visible : true;
10585
+ const visibleActions = actions.filter(isVisible);
10586
+ const visibleMoreActions = moreActions.filter(isVisible);
10587
+ const rowActionCellWidth = React__default.useMemo(() => {
10588
+ const totalButtons = visibleActions.length + (visibleMoreActions.length ? 1 : 0);
10589
+ // this is necessary because row actions is has this mount hover delay, which makes the
10590
+ // size calculation in the header get set before rendering - meaning the size doesn't include the buttons
10591
+ // when we cache icons this can go
10592
+ const paddingSize = 8;
10593
+ const buttonSize = 32;
10594
+ return paddingSize + totalButtons * buttonSize;
10595
+ }, [visibleActions.length, visibleMoreActions.length]);
10596
+ // Instead of relying on row.index to figure out whether the row is being hovered or is active. We should rely on a
10597
+ // CSS fix. The reason behind this is that row data or index is the initial data or index that is passed to the
10598
+ // table on the first render, the indexes of row changes when sorting or filtering is applied.
10599
+ // If the row is not the active row or the hovered row then actions are hidden.
10600
+ const actionClassName = 'group-hover/row:flex group-[[aria-current]]/row:flex hidden';
10601
+ return /*#__PURE__*/React__default.createElement("span", {
10602
+ className: "-mb-2 -mt-1.5 flex justify-end text-right",
10343
10603
  style: {
10344
- transition: 'border 0.2s ease-in'
10604
+ width: rowActionCellWidth
10605
+ }
10606
+ }, visibleActions.map((action, i) => /*#__PURE__*/React__default.createElement(IconButton, {
10607
+ key: i,
10608
+ className: actionClassName,
10609
+ "aria-label": getActionPropertyValue(action.ariaLabel, row.original),
10610
+ appearance: "discrete",
10611
+ dialog: action.dialog ? action.dialog(row.original) : undefined,
10612
+ disabled: getActionPropertyValue(action.disabled, row.original),
10613
+ icon: getActionPropertyValue(action.icon, row.original),
10614
+ onClick: event => {
10615
+ event.stopPropagation();
10616
+ if (action.onClick) {
10617
+ action.onClick(row.original);
10618
+ }
10345
10619
  },
10346
- value: id
10347
- }));
10348
- });
10349
- const TabContent = /*#__PURE__*/React.forwardRef(function Tab(props, ref) {
10350
- const {
10351
- id,
10352
- ...otherProps
10353
- } = props;
10354
- const className = cn('yt-tab__panel outline-none', props.className);
10355
- return /*#__PURE__*/React.createElement(TabsPrimitive.Content, Object.assign({}, otherProps, {
10356
- className: className,
10357
- ref: ref,
10358
- value: id
10359
- }));
10620
+ tooltip: getActionPropertyValue(action.text, row.original)
10621
+ })), visibleMoreActions.length ? /*#__PURE__*/React__default.createElement(IconButton, {
10622
+ className: actionClassName,
10623
+ "aria-label": "View other actions",
10624
+ appearance: "discrete",
10625
+ icon: "more",
10626
+ onClick: event => {
10627
+ event.preventDefault();
10628
+ },
10629
+ menu: menuProps => /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, null, visibleMoreActions.map((action, i) => /*#__PURE__*/React__default.createElement(Menu$1.Item, {
10630
+ key: i,
10631
+ dialog: action.dialog ? action.dialog(row.original) : undefined,
10632
+ disabled: getActionPropertyValue(action.disabled, row.original),
10633
+ icon: getActionPropertyValue(action.icon, row.original),
10634
+ onClick: () => {
10635
+ if (action.onClick) {
10636
+ action.onClick(row.original);
10637
+ }
10638
+ }
10639
+ }, getActionPropertyValue(action.text, row.original))))),
10640
+ tooltip: "Other actions..."
10641
+ }) : null);
10642
+ }
10643
+ function createRowActionsColumn(rowActions) {
10644
+ const actions = rowActions.slice(0, 3);
10645
+ const moreActions = rowActions.slice(3);
10646
+ return {
10647
+ id: COLUMN_ID_FOR_ACTIONS,
10648
+ cell: ({
10649
+ row
10650
+ }) => /*#__PURE__*/React__default.createElement(RowActionCell, {
10651
+ row: row,
10652
+ actions: actions,
10653
+ moreActions: moreActions
10654
+ }),
10655
+ meta: {
10656
+ align: 'right',
10657
+ className: row => cn('items-center print:opacity-0 group-[[aria-current]]/row:sticky group-hover/row:sticky right-0 bg-transparent !px-1', {
10658
+ 'group-hover/row:!shadow-[-6px_0px_6px_theme(colors.grey.100)] group-[[aria-current]]/row:!shadow-[-6px_0px_6px_theme(colors.grey.100)]': !row.getIsSelected(),
10659
+ 'shadow-[-6px_0px_6px_theme(colors.blue.100)]': row.getIsSelected()
10660
+ }),
10661
+ disableTruncation: true,
10662
+ headerClassName: 'hover:!bg-white !px-1'
10663
+ },
10664
+ // sizing
10665
+ enableResizing: false
10666
+ };
10667
+ }
10668
+
10669
+ const getDensityPadding = (density, editing = false) => {
10670
+ switch (density) {
10671
+ case 'compact':
10672
+ return editing ? 'py-0' : 'py-1.5';
10673
+ case 'comfortable':
10674
+ return editing ? 'py-2' : 'py-3.5';
10675
+ case 'spacious':
10676
+ return editing ? 'py-3' : 'py-5';
10677
+ default:
10678
+ return editing ? 'py-1' : 'py-2.5';
10679
+ }
10680
+ };
10681
+ const getCellSizingClasses = (density = 'normal', editing = false) => {
10682
+ return cn('flex items-center', getDensityPadding(density, editing), editing ? 'px-[7px]' : 'px-4');
10683
+ };
10684
+ const getCellAlignmentClasses = (alignment = 'left') => ({
10685
+ 'justify-start text-left': alignment === 'left',
10686
+ 'justify-end text-right': alignment === 'right',
10687
+ 'justify-center text-center': alignment === 'center'
10360
10688
  });
10361
- Tabs.List = TabList;
10362
- Tabs.Trigger = TabTrigger;
10363
- Tabs.Content = TabContent;
10689
+ const getPinnedShadowClasses = (column, columnPinning, isHorizontallyOffset) => {
10690
+ const pinned = !!column.getIsPinned();
10691
+ // react-table has column.getPinnedIndex() but it does not exclude hidden columns, so the number is wrong
10692
+ const pinnedIndex = columnPinning.indexOf(column.id);
10693
+ const isLastPinned = pinned && pinnedIndex === columnPinning.length - 1;
10694
+ const hidePinnedShadow = !isHorizontallyOffset && (column.id === COLUMN_ID_FOR_EXPANSION || column.id === COLUMN_ID_FOR_SELECTION);
10695
+ return {
10696
+ 'shadow-[6px_0px_6px_rgb(0_0_0/8%),1px_0px_0px_theme(colors.grey.300)]': isLastPinned && isHorizontallyOffset,
10697
+ 'shadow-[1px_0px_0px_theme(colors.grey.300)]': isLastPinned && !isHorizontallyOffset && !hidePinnedShadow
10698
+ };
10699
+ };
10700
+ const isKeyboardFocusableElement = element => {
10701
+ const focussableNodeNames = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS'];
10702
+ return focussableNodeNames.includes(element.nodeName) && !element.hasAttribute('disabled') && !element.hasAttribute('readonly') && !element.getAttribute('aria-hidden');
10703
+ };
10364
10704
 
10365
- const Textarea = /*#__PURE__*/React.forwardRef(function Textarea(props, ref) {
10705
+ const ColumnBase = /*#__PURE__*/React__default.forwardRef(function Table2ColumnBase(props, ref) {
10706
+ var _column$columnDef$met;
10366
10707
  const {
10367
- defaultValue: _,
10368
- highlighted,
10369
- invalid,
10370
- onKeyDown,
10371
- ...otherProps
10708
+ column,
10709
+ scrolled,
10710
+ style,
10711
+ table,
10712
+ ...attributes
10372
10713
  } = props;
10373
- const classNames = cn(getInputClasses(props), 'py-1 min-h-[75px] disabled:resize-none', props.className);
10374
- // home and end keys only navigate to the start/end of textarea value if the textarea container does not scroll
10375
- // if it has scroll height then the browser reverts to native scrolling behaviour only
10376
- // so we manually override it to ensure _our_ desired behaviour remains intact
10377
- const handleKeyDown = event => {
10378
- if (event.key === 'Home' || event.key === 'End') {
10379
- event.preventDefault();
10380
- const position = event.key === 'End' ? event.currentTarget.value.length : 0;
10381
- event.currentTarget.setSelectionRange(position, position);
10382
- event.currentTarget.scrollTop = event.key === 'End' ? event.currentTarget.scrollHeight : 0;
10383
- }
10384
- if (onKeyDown) {
10385
- onKeyDown(event);
10386
- }
10387
- };
10388
- return /*#__PURE__*/React.createElement("textarea", Object.assign({}, otherProps, {
10389
- className: classNames,
10390
- "data-taco": "textarea",
10391
- onKeyDown: handleKeyDown,
10714
+ const pinned = !!column.getIsPinned();
10715
+ const meta = table.options.meta;
10716
+ const left = meta.columnOffsets[column.id];
10717
+ const columnPinning = table.getLeftVisibleLeafColumns().map(c => c.id);
10718
+ const className = cn('border-grey-300', getPinnedShadowClasses(column, columnPinning, scrolled), getCellAlignmentClasses((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.align), {
10719
+ 'cursor-pointer': !!attributes.onClick
10720
+ }, attributes.className);
10721
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
10722
+ className: className,
10723
+ style: {
10724
+ ...style,
10725
+ left: pinned && Number.isInteger(left) ? left : undefined
10726
+ },
10392
10727
  ref: ref
10393
10728
  }));
10394
10729
  });
@@ -10434,6 +10769,3067 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
10434
10769
  });
10435
10770
  Switch.displayName = 'Switch';
10436
10771
 
10772
+ var Table2FilterComparator;
10773
+ (function (Table2FilterComparator) {
10774
+ Table2FilterComparator[Table2FilterComparator["Contains"] = 0] = "Contains";
10775
+ Table2FilterComparator[Table2FilterComparator["DoesNotContain"] = 1] = "DoesNotContain";
10776
+ Table2FilterComparator[Table2FilterComparator["IsEqualTo"] = 2] = "IsEqualTo";
10777
+ Table2FilterComparator[Table2FilterComparator["IsNotEqualTo"] = 3] = "IsNotEqualTo";
10778
+ Table2FilterComparator[Table2FilterComparator["IsGreaterThan"] = 4] = "IsGreaterThan";
10779
+ Table2FilterComparator[Table2FilterComparator["IsLessThan"] = 5] = "IsLessThan";
10780
+ Table2FilterComparator[Table2FilterComparator["IsBetween"] = 6] = "IsBetween";
10781
+ Table2FilterComparator[Table2FilterComparator["IsOneOf"] = 7] = "IsOneOf";
10782
+ Table2FilterComparator[Table2FilterComparator["IsNoneOf"] = 8] = "IsNoneOf";
10783
+ Table2FilterComparator[Table2FilterComparator["IsAllOf"] = 9] = "IsAllOf";
10784
+ })(Table2FilterComparator || (Table2FilterComparator = {}));
10785
+
10786
+ const toLowerCase = value => String(value !== null && value !== void 0 ? value : '').toLocaleLowerCase();
10787
+ const isWeakContains = (left, right) => toLowerCase(left).includes(toLowerCase(right));
10788
+ const isWeakEqual$1 = (left, right) => toLowerCase(left) === toLowerCase(right);
10789
+ const globalFilterFn = (value, query) => isWeakContains(value, query);
10790
+ // the filter type is only settable on the column definition, which would re-render all columns
10791
+ // so instead we store it in the filter value, but that means we also have to destructure that
10792
+ // before we filter - that's why this custom filter function exists
10793
+ const columnFilterFn = (value, filter) => {
10794
+ try {
10795
+ if (filter.value === undefined || filter.value === null || filter.value === '') {
10796
+ return true;
10797
+ }
10798
+ switch (filter.comparator) {
10799
+ case Table2FilterComparator.Contains:
10800
+ return isWeakContains(value, filter.value);
10801
+ case Table2FilterComparator.DoesNotContain:
10802
+ return !isWeakContains(value, filter.value);
10803
+ case Table2FilterComparator.IsEqualTo:
10804
+ {
10805
+ if (dateFns.isDate(value)) {
10806
+ return dateFns.isDate(filter.value) && isWeakEqual(value, filter.value);
10807
+ } else if (typeof filter.value === 'boolean') {
10808
+ return value === filter.value;
10809
+ }
10810
+ return isWeakEqual$1(value, filter.value);
10811
+ }
10812
+ case Table2FilterComparator.IsNotEqualTo:
10813
+ {
10814
+ if (dateFns.isDate(value)) {
10815
+ return dateFns.isDate(filter.value) && isWeakEqual(value, filter.value) === false;
10816
+ } else if (typeof filter.value === 'boolean') {
10817
+ return value !== filter.value;
10818
+ }
10819
+ return !isWeakEqual$1(value, filter.value);
10820
+ }
10821
+ case Table2FilterComparator.IsGreaterThan:
10822
+ {
10823
+ if (dateFns.isDate(value)) {
10824
+ return dateFns.isDate(filter.value) && dateFns.isAfter(value, filter.value);
10825
+ } else {
10826
+ const valueAsNumber = parseInt(value);
10827
+ return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber > filter.value;
10828
+ }
10829
+ }
10830
+ case Table2FilterComparator.IsLessThan:
10831
+ {
10832
+ if (dateFns.isDate(value)) {
10833
+ return dateFns.isDate(filter.value) && dateFns.isBefore(value, filter.value);
10834
+ } else {
10835
+ const valueAsNumber = parseInt(value);
10836
+ return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber < filter.value;
10837
+ }
10838
+ }
10839
+ case Table2FilterComparator.IsBetween:
10840
+ {
10841
+ const [fromValue, toValue] = filter.value;
10842
+ if (dateFns.isDate(value)) {
10843
+ if (dateFns.isDate(fromValue) && dateFns.isBefore(value, fromValue)) {
10844
+ return false;
10845
+ } else if (dateFns.isDate(toValue) && dateFns.isAfter(value, toValue)) {
10846
+ return false;
10847
+ }
10848
+ return true;
10849
+ } else {
10850
+ const valueAsNumber = parseInt(value);
10851
+ if (isNaN(valueAsNumber)) {
10852
+ return false;
10853
+ }
10854
+ if (fromValue !== undefined && valueAsNumber < fromValue) {
10855
+ return false;
10856
+ } else if (toValue !== undefined && valueAsNumber > toValue) {
10857
+ return false;
10858
+ }
10859
+ return true;
10860
+ }
10861
+ }
10862
+ case Table2FilterComparator.IsOneOf:
10863
+ return Array.isArray(filter.value) ? filter.value.includes(value) : false;
10864
+ case Table2FilterComparator.IsNoneOf:
10865
+ return Array.isArray(filter.value) ? filter.value.includes(value) === false : false;
10866
+ case Table2FilterComparator.IsAllOf:
10867
+ return Array.isArray(filter.value) && Array.isArray(value) ? filter.value.filter(v => value.includes(v)).length === filter.value.length : false;
10868
+ }
10869
+ return false;
10870
+ } catch (e) {
10871
+ console.error(e);
10872
+ return true;
10873
+ }
10874
+ };
10875
+
10876
+ var MOVE_DIR;
10877
+ (function (MOVE_DIR) {
10878
+ MOVE_DIR[MOVE_DIR["FIRST"] = 0] = "FIRST";
10879
+ MOVE_DIR[MOVE_DIR["LAST"] = 1] = "LAST";
10880
+ MOVE_DIR[MOVE_DIR["PREV"] = 2] = "PREV";
10881
+ MOVE_DIR[MOVE_DIR["NEXT"] = 3] = "NEXT";
10882
+ })(MOVE_DIR || (MOVE_DIR = {}));
10883
+ const useEditMode = handleSave => {
10884
+ const enableEditMode = !!handleSave;
10885
+ const [editMode, setEditMode] = React__default.useState({
10886
+ enableEditMode,
10887
+ isEditing: false,
10888
+ columnIndex: 0
10889
+ });
10890
+ React__default.useEffect(() => {
10891
+ setEditMode(editMode => ({
10892
+ ...editMode,
10893
+ enableEditMode
10894
+ }));
10895
+ }, [enableEditMode]);
10896
+ const _moveActiveColumn = (moveDirection, focussableColumnIndexes, moveRow) => {
10897
+ var _focussableColumnInde, _focussableColumnInde2;
10898
+ const firstDataColumnIndex = (_focussableColumnInde = focussableColumnIndexes.at(0)) !== null && _focussableColumnInde !== void 0 ? _focussableColumnInde : 0;
10899
+ const lastDataColumnIndex = (_focussableColumnInde2 = focussableColumnIndexes.at(-1)) !== null && _focussableColumnInde2 !== void 0 ? _focussableColumnInde2 : 0;
10900
+ if (!editMode.enableEditMode) {
10901
+ return;
10902
+ }
10903
+ setEditMode(({
10904
+ columnIndex: currentColumnIndex,
10905
+ ...currentEditMode
10906
+ }) => {
10907
+ let nextCellIndex;
10908
+ switch (moveDirection) {
10909
+ case MOVE_DIR.FIRST:
10910
+ nextCellIndex = firstDataColumnIndex;
10911
+ break;
10912
+ case MOVE_DIR.LAST:
10913
+ nextCellIndex = lastDataColumnIndex;
10914
+ break;
10915
+ case MOVE_DIR.PREV:
10916
+ // moves to the last data column of the previous row, if the current column is the first column
10917
+ if (currentColumnIndex === firstDataColumnIndex) {
10918
+ moveRow === null || moveRow === void 0 ? void 0 : moveRow(MOVE_DIR.PREV);
10919
+ nextCellIndex = lastDataColumnIndex;
10920
+ } else {
10921
+ nextCellIndex = focussableColumnIndexes[getNextIndex(-1, currentColumnIndex, focussableColumnIndexes)];
10922
+ }
10923
+ break;
10924
+ case MOVE_DIR.NEXT:
10925
+ // moves to the first data column of the next row, if the current column is the last column
10926
+ if (currentColumnIndex === lastDataColumnIndex) {
10927
+ moveRow === null || moveRow === void 0 ? void 0 : moveRow(MOVE_DIR.NEXT);
10928
+ nextCellIndex = firstDataColumnIndex;
10929
+ } else {
10930
+ nextCellIndex = focussableColumnIndexes[getNextIndex(1, currentColumnIndex, focussableColumnIndexes)];
10931
+ }
10932
+ break;
10933
+ }
10934
+ return {
10935
+ ...currentEditMode,
10936
+ columnIndex: nextCellIndex
10937
+ };
10938
+ });
10939
+ };
10940
+ // output
10941
+ const toggleEditing = (isEditing, columnIndex = 0) => {
10942
+ if (!editMode.enableEditMode) {
10943
+ return;
10944
+ }
10945
+ setEditMode(editMode => ({
10946
+ ...editMode,
10947
+ isEditing: isEditing !== null && isEditing !== void 0 ? isEditing : !editMode.isEditing,
10948
+ columnIndex
10949
+ }));
10950
+ };
10951
+ const moveToPreviousColumn = (focussableColumnIndexes, moveRow) => _moveActiveColumn(MOVE_DIR.PREV, focussableColumnIndexes, moveRow);
10952
+ const moveToNextColumn = (focussableColumnIndexes, moveRow) => _moveActiveColumn(MOVE_DIR.NEXT, focussableColumnIndexes, moveRow);
10953
+ const moveToFirstColumn = focussableColumnIndexes => _moveActiveColumn(MOVE_DIR.FIRST, focussableColumnIndexes);
10954
+ const moveToLastColumn = focussableColumnIndexes => _moveActiveColumn(MOVE_DIR.LAST, focussableColumnIndexes);
10955
+ const setColumn = columnIndex => {
10956
+ if (!editMode.enableEditMode) {
10957
+ return;
10958
+ }
10959
+ setEditMode(currentEditMode => ({
10960
+ ...currentEditMode,
10961
+ columnIndex
10962
+ }));
10963
+ };
10964
+ return {
10965
+ ...editMode,
10966
+ onSave: handleSave,
10967
+ toggleEditing,
10968
+ moveToPreviousColumn,
10969
+ moveToNextColumn,
10970
+ moveToFirstColumn,
10971
+ moveToLastColumn,
10972
+ setColumn
10973
+ };
10974
+ };
10975
+ const getNextIndex = (direction, currentIndex, focussableColumnIndexes) => {
10976
+ const currentIndexPosition = focussableColumnIndexes.indexOf(currentIndex);
10977
+ const length = focussableColumnIndexes.length;
10978
+ if (direction === -1) {
10979
+ return currentIndexPosition - 1 > 0 ? currentIndexPosition - 1 : 0;
10980
+ }
10981
+ return currentIndexPosition + 1 < length ? currentIndexPosition + 1 : currentIndexPosition;
10982
+ };
10983
+
10984
+ const RowContext = /*#__PURE__*/React__default.createContext({
10985
+ validationErrors: null,
10986
+ setValidationErrors: () => undefined,
10987
+ rowMoveReason: {},
10988
+ setRowMoveReason: () => undefined
10989
+ });
10990
+ const useRowContext = () => {
10991
+ const context = React__default.useContext(RowContext);
10992
+ if (context === undefined) {
10993
+ throw new Error('useRowContext must be used within a RowProvider');
10994
+ }
10995
+ return context;
10996
+ };
10997
+ const RowProvider = ({
10998
+ children,
10999
+ ...providerProps
11000
+ }) => {
11001
+ return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
11002
+ value: providerProps
11003
+ }, children);
11004
+ };
11005
+
11006
+ var IndicatorReason;
11007
+ (function (IndicatorReason) {
11008
+ IndicatorReason["SEARCH"] = "SEARCH";
11009
+ IndicatorReason["SORTING"] = "SORTING";
11010
+ IndicatorReason["FILTER"] = "FILTER";
11011
+ })(IndicatorReason || (IndicatorReason = {}));
11012
+ const useIndicatorText = reason => {
11013
+ let title = '';
11014
+ let description = '';
11015
+ const {
11016
+ texts: {
11017
+ table2: tableTexts
11018
+ }
11019
+ } = useLocalization();
11020
+ switch (reason) {
11021
+ case IndicatorReason.SEARCH:
11022
+ title = tableTexts.rowIndicator.rowWillBeFiltered;
11023
+ description = tableTexts.rowIndicator.searchFilterMovementReason;
11024
+ break;
11025
+ case IndicatorReason.SORTING:
11026
+ title = tableTexts.rowIndicator.rowWillMove;
11027
+ description = tableTexts.rowIndicator.sortingMovementReason;
11028
+ break;
11029
+ case IndicatorReason.FILTER:
11030
+ title = tableTexts.rowIndicator.rowWillBeFiltered;
11031
+ description = tableTexts.rowIndicator.tableFilterMovementReason;
11032
+ break;
11033
+ }
11034
+ return {
11035
+ title,
11036
+ description
11037
+ };
11038
+ };
11039
+ const Indicator = ({
11040
+ reason,
11041
+ columnName,
11042
+ mountNode
11043
+ }) => {
11044
+ const container = React__default.useMemo(() => {
11045
+ const element = document.createElement('div');
11046
+ element.className += '-translate-y-1/2 z-[3] rounded-full items-center wcag-blue-500 absolute left-0 top-full ml-1 whitespace-nowrap px-1 py-0.5 text-xs font-bold shadow-sm';
11047
+ return element;
11048
+ }, []);
11049
+ const indicatorText = useIndicatorText(reason);
11050
+ const {
11051
+ validationErrors
11052
+ } = useRowContext();
11053
+ const hasValidationErrorsInRow = !!validationErrors;
11054
+ React__default.useEffect(() => {
11055
+ // mountNode could be null when rows are filtered
11056
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.add('relative');
11057
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.appendChild(container);
11058
+ return () => {
11059
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.remove('relative');
11060
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.removeChild(container);
11061
+ };
11062
+ }, [hasValidationErrorsInRow]);
11063
+ // Using react portal inside a react tree component is an unorthodox way, but in order to avoid much code refactoring
11064
+ // and being able to use Taco Tooltip component in side the visual indicator, portal is used.
11065
+ return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(Tooltip, {
11066
+ title: indicatorText.description.replace('[COLUMN]', columnName)
11067
+ }, /*#__PURE__*/React__default.createElement("span", {
11068
+ className: "flex gap-1 hover:cursor-pointer"
11069
+ }, /*#__PURE__*/React__default.createElement(Icon, {
11070
+ name: "info",
11071
+ className: "!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
11072
+ }), indicatorText.title)), container);
11073
+ };
11074
+
11075
+ const useTruncated = (element, deps = []) => {
11076
+ const isTruncated = targetElement => {
11077
+ if (targetElement !== null) {
11078
+ return targetElement.offsetWidth < targetElement.scrollWidth;
11079
+ }
11080
+ return false;
11081
+ };
11082
+ const [truncated, setTruncated] = React__default.useState(isTruncated(element));
11083
+ React__default.useEffect(() => {
11084
+ setTruncated(isTruncated(element));
11085
+ }, [element, ...deps]);
11086
+ return {
11087
+ truncated
11088
+ };
11089
+ };
11090
+
11091
+ const ValidationError = ({
11092
+ className,
11093
+ ...props
11094
+ }) => {
11095
+ const ref = React__default.useRef(null);
11096
+ const {
11097
+ truncated
11098
+ } = useTruncated(ref.current);
11099
+ const error = /*#__PURE__*/React__default.createElement("span", Object.assign({
11100
+ className: cn('truncate px-px text-xs font-normal leading-normal text-red-500', {
11101
+ 'hover:cursor-pointer': truncated
11102
+ }, className),
11103
+ ref: ref,
11104
+ role: "alert"
11105
+ }, props));
11106
+ if (truncated) {
11107
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
11108
+ title: props.children
11109
+ }, error);
11110
+ }
11111
+ return error;
11112
+ };
11113
+
11114
+ const hasChanged = (value, newValue) => {
11115
+ if (dateFns.isDate(value) && dateFns.isDate(newValue)) {
11116
+ return !isWeakEqual(value, newValue);
11117
+ } else if (Array.isArray(value)) {
11118
+ return JSON.stringify(value) !== JSON.stringify(newValue);
11119
+ }
11120
+ return value !== newValue;
11121
+ };
11122
+ const willRowMoveAfterSorting = (value, cell, rowIndex, rows, desc) => {
11123
+ const miniSortRows = [{
11124
+ ...cell.row,
11125
+ original: {
11126
+ ...cell.row.original,
11127
+ [cell.column.id]: value
11128
+ }
11129
+ }];
11130
+ // getValue is used by the built-in sort functons, so we need to make sure it returns the changed value
11131
+ miniSortRows[0].getValue = () => value;
11132
+ let index = 0;
11133
+ if (rowIndex > 0) {
11134
+ miniSortRows.unshift(rows[rowIndex - 1]);
11135
+ index = 1;
11136
+ }
11137
+ if (rowIndex < rows.length - 1) {
11138
+ miniSortRows.push(rows[rowIndex + 1]);
11139
+ }
11140
+ let resortedRows = [...miniSortRows].sort((a, b) => cell.column.getSortingFn()(a, b, cell.column.id));
11141
+ if (desc) {
11142
+ resortedRows = resortedRows.reverse();
11143
+ }
11144
+ return resortedRows[index].id !== cell.row.id;
11145
+ };
11146
+
11147
+ const Cell = function Cell(props) {
11148
+ var _cell$column$columnDe, _cell$column$columnDe2, _cell$column$columnDe3, _table$options$meta;
11149
+ const {
11150
+ cell,
11151
+ index,
11152
+ isLastRow,
11153
+ rowIndex,
11154
+ rows,
11155
+ scrollToIndex,
11156
+ scrollToOffset,
11157
+ table,
11158
+ tableRef,
11159
+ ...columnProps
11160
+ } = props;
11161
+ const meta = table.options.meta;
11162
+ const {
11163
+ addFocussableColumnIndex,
11164
+ focussableColumnIndexes: allFocussableColumnIndexes
11165
+ } = meta;
11166
+ const {
11167
+ validationErrors,
11168
+ rowMoveReason
11169
+ } = useRowContext();
11170
+ const hasValidationErrorsInRow = !!validationErrors;
11171
+ const internalRef = React__default.useRef(null);
11172
+ const controlRef = React__default.useRef(null);
11173
+ const disableTruncation = (_cell$column$columnDe = cell.column.columnDef.meta) === null || _cell$column$columnDe === void 0 ? void 0 : _cell$column$columnDe.disableTruncation;
11174
+ const cellClassName = (_cell$column$columnDe2 = cell.column.columnDef.meta) === null || _cell$column$columnDe2 === void 0 ? void 0 : _cell$column$columnDe2.className;
11175
+ const isActiveRow = meta.activeRowIndex === rowIndex;
11176
+ const isHoveredRow = meta.hoveredRowIndex === rowIndex;
11177
+ const isPinned = !!cell.column.getIsPinned();
11178
+ const isDragging = meta.dragging[cell.row.id];
11179
+ const isSelected = cell.row.getIsSelected();
11180
+ const isDataColumn = !isInternalColumn(cell.column.id);
11181
+ const hasCellControl = !!((_cell$column$columnDe3 = cell.column.columnDef.meta) !== null && _cell$column$columnDe3 !== void 0 && _cell$column$columnDe3.control);
11182
+ const allVisibleColumns = table.getVisibleLeafColumns();
11183
+ const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
11184
+ // editing
11185
+ const isEditingThisRow = meta.editMode.isEditing && isActiveRow;
11186
+ const canEditThisCell = isEditingThisRow && isDataColumn;
11187
+ const isEditingThisCell = canEditThisCell && meta.editMode.columnIndex === index;
11188
+ const isHoveringThisRowWhileEditing = meta.editMode.isEditing && isHoveredRow;
11189
+ const isIndicatorVisible = Object.keys(rowMoveReason).length > 0;
11190
+ React__default.useEffect(() => {
11191
+ // Adds padding to the table so that indicator doesn't get cropped
11192
+ if (isIndicatorVisible && isLastRow) {
11193
+ var _tableRef$current;
11194
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.classList.add('pb-4');
11195
+ }
11196
+ return () => {
11197
+ var _tableRef$current2;
11198
+ return (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.classList.remove('pb-4');
11199
+ };
11200
+ }, [isIndicatorVisible, isLastRow]);
11201
+ const className = cn({
11202
+ 'border-b': !isLastRow,
11203
+ 'sticky z-[1]': isPinned,
11204
+ // use isHoveredRow rather than css group-hover/row because we want to hide hover state when keyboard navigating
11205
+ 'bg-white': !isActiveRow && !isSelected && !isHoveredRow,
11206
+ 'bg-grey-100': !isActiveRow && !isSelected && isHoveredRow,
11207
+ 'bg-grey-200 group-hover/row:bg-grey-200': isActiveRow && !isSelected,
11208
+ 'bg-blue-100': isSelected,
11209
+ '!wcag-blue-500': isDragging,
11210
+ '[&>*]:!grayscale [&_.bg-white]:!bg-grey-100': !isEditingThisRow && isHoveringThisRowWhileEditing,
11211
+ '!bg-red-100': hasValidationErrorsInRow,
11212
+ 'z-[1]': isPinned && isActiveRow,
11213
+ // First column should have higher z-index so that row indicator always show on top of the cell
11214
+ // control components.
11215
+ 'z-[2]': isPinned && isActiveRow && index === 0,
11216
+ 'border-blue !border-y-2 border-x-0': isIndicatorVisible,
11217
+ 'border-l-2 rounded-l': isIndicatorVisible && index === 0,
11218
+ 'border-r-2 rounded-r': isIndicatorVisible && index === lastColumnIndex
11219
+ }, getCellSizingClasses((_table$options$meta = table.options.meta) === null || _table$options$meta === void 0 ? void 0 : _table$options$meta.rowDensity, (isEditingThisRow || isHoveringThisRowWhileEditing) && hasCellControl), typeof cellClassName === 'function' ? cellClassName(cell.row) : cellClassName);
11220
+ const handleMouseDown = event => {
11221
+ // only detect left clicks
11222
+ if (event.button === 0) {
11223
+ const activeElement = document.activeElement;
11224
+ const isActiveElementControl = activeElement === null || activeElement === void 0 ? void 0 : activeElement.closest('[role="cell"]');
11225
+ const hasActiveRowChanged = meta.activeRowIndex !== rowIndex;
11226
+ // When user clicks on a cell that is not in the active row, for some reason blur event is not called on the cell
11227
+ // previous cell control element so we need to manually call it in order to save the changes in that cell
11228
+ if (isActiveElementControl && hasActiveRowChanged) {
11229
+ activeElement.blur();
11230
+ }
11231
+ meta.setActiveRowIndex(rowIndex);
11232
+ if (meta.editMode.isEditing) {
11233
+ if (allFocussableColumnIndexes.includes(index)) {
11234
+ meta.editMode.setColumn(index);
11235
+ } else {
11236
+ meta.editMode.setColumn(allFocussableColumnIndexes[0]);
11237
+ }
11238
+ }
11239
+ }
11240
+ };
11241
+ const attributes = {
11242
+ ...columnProps,
11243
+ // base props,
11244
+ column: cell.column,
11245
+ table,
11246
+ // dom attributes
11247
+ className,
11248
+ 'data-column-index': index,
11249
+ 'data-row-index': rowIndex,
11250
+ onMouseDown: handleMouseDown,
11251
+ ref: internalRef,
11252
+ role: 'cell'
11253
+ };
11254
+ const [detailModeEditing, setDetailModeEditing] = React__default.useState(false);
11255
+ const detailModeClassName = cn({
11256
+ '!shadow-[0_0_0_4px_rgba(0,99,255,0.25)]': detailModeEditing
11257
+ });
11258
+ // reset the editing state when we move column
11259
+ React__default.useEffect(() => {
11260
+ if (meta.editMode.columnIndex !== index) {
11261
+ setDetailModeEditing(false);
11262
+ }
11263
+ }, [meta.editMode.columnIndex]);
11264
+ React__default.useEffect(() => {
11265
+ if (isEditingThisRow && controlRef.current && isKeyboardFocusableElement(controlRef.current)) {
11266
+ addFocussableColumnIndex(index);
11267
+ }
11268
+ }, [isEditingThisRow, allFocussableColumnIndexes, addFocussableColumnIndex, index]);
11269
+ const moveRow = moveDirection => {
11270
+ if (moveDirection === MOVE_DIR.PREV) {
11271
+ meta.moveToPreviousRow(rows, nextIndex => scrollToIndex(nextIndex - 1));
11272
+ } else if (moveDirection === MOVE_DIR.NEXT) {
11273
+ meta.moveToNextRow(rows, nextIndex => scrollToIndex(nextIndex + 2));
11274
+ }
11275
+ };
11276
+ if (meta.editMode.onSave && hasCellControl && (canEditThisCell || isHoveringThisRowWhileEditing && isDataColumn)) {
11277
+ attributes.onMouseDown = event => {
11278
+ handleMouseDown(event);
11279
+ const target = event.target;
11280
+ const isTargetInput = target !== null && target.nodeName === 'INPUT';
11281
+ // event.target?.select is only truthy for input elements
11282
+ // if event.target is active element, then that means we should select the text
11283
+ if (isTargetInput && target !== document.activeElement) {
11284
+ event.preventDefault();
11285
+ setTimeout(() => {
11286
+ target.select();
11287
+ }, 1);
11288
+ } else if (isTargetInput && target === document.activeElement) {
11289
+ // if user left clicks on the input then we are into edit mode
11290
+ // only detect left clicks
11291
+ if (event.button === 0) {
11292
+ setDetailModeEditing(true);
11293
+ }
11294
+ }
11295
+ };
11296
+ if (canEditThisCell) {
11297
+ var _allFocussableColumnI, _allFocussableColumnI2;
11298
+ const firstDataColumnIndex = (_allFocussableColumnI = allFocussableColumnIndexes.at(0)) !== null && _allFocussableColumnI !== void 0 ? _allFocussableColumnI : 0;
11299
+ const lastDataColumnIndex = (_allFocussableColumnI2 = allFocussableColumnIndexes.at(-1)) !== null && _allFocussableColumnI2 !== void 0 ? _allFocussableColumnI2 : 0;
11300
+ attributes.onKeyDown = event => {
11301
+ const control = event.target;
11302
+ const isControlInput = control.nodeName === 'INPUT' && (control === null || control === void 0 ? void 0 : control.getAttribute('data-inline-editing-component')) === 'true';
11303
+ // For some reason, Taco Input keyboard event always return true when "event.isDefaultPrevented()" is
11304
+ // called. So we need to check if the control is input or not so that we don't return early.
11305
+ if (!isControlInput && (event.isDefaultPrevented() || event.isPropagationStopped())) {
11306
+ return;
11307
+ }
11308
+ if (control.tagName === 'INPUT') {
11309
+ if (event.key === 'Enter') {
11310
+ event.preventDefault();
11311
+ const input = control;
11312
+ if (!detailModeEditing) {
11313
+ var _input$setSelectionRa, _input$value, _input$value2;
11314
+ (_input$setSelectionRa = input.setSelectionRange) === null || _input$setSelectionRa === void 0 ? void 0 : _input$setSelectionRa.call(input, (_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.length, (_input$value2 = input.value) === null || _input$value2 === void 0 ? void 0 : _input$value2.length);
11315
+ setDetailModeEditing(true);
11316
+ }
11317
+ return;
11318
+ }
11319
+ }
11320
+ // Don't exit edit mode if the target of the escape isn't a child of the cell (e.g. if its a popover).
11321
+ if (event.key === 'Escape' && event.currentTarget.contains(control)) {
11322
+ event.preventDefault();
11323
+ const input = control;
11324
+ if (detailModeEditing) {
11325
+ var _input$select;
11326
+ input === null || input === void 0 ? void 0 : (_input$select = input.select) === null || _input$select === void 0 ? void 0 : _input$select.call(input);
11327
+ setDetailModeEditing(false);
11328
+ } else {
11329
+ var _tableRef$current3;
11330
+ meta.editMode.toggleEditing(false);
11331
+ (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : _tableRef$current3.focus();
11332
+ }
11333
+ return;
11334
+ }
11335
+ if (!detailModeEditing && event.key === 'ArrowLeft' || event.key === 'Tab' && event.shiftKey) {
11336
+ event.preventDefault();
11337
+ const isFirstRow = rowIndex === 0;
11338
+ const isFirstColumn = index === firstDataColumnIndex;
11339
+ if (event.ctrlKey || event.metaKey) {
11340
+ // If the current active column is the first column then we don't do any thing so that focus
11341
+ // remains on the first column.
11342
+ if (!isFirstColumn) {
11343
+ control.blur();
11344
+ meta.editMode.moveToFirstColumn(allFocussableColumnIndexes);
11345
+ }
11346
+ } else {
11347
+ // If it is first row and first column, then don't move column.
11348
+ if (!isFirstRow || !isFirstColumn) {
11349
+ control.blur();
11350
+ meta.editMode.moveToPreviousColumn(allFocussableColumnIndexes, moveRow);
11351
+ }
11352
+ }
11353
+ return;
11354
+ }
11355
+ if (!detailModeEditing && event.key === 'ArrowRight' || event.key === 'Tab' && !event.shiftKey) {
11356
+ event.preventDefault();
11357
+ const isLastColumn = index === lastDataColumnIndex;
11358
+ if (event.ctrlKey || event.metaKey) {
11359
+ // If the current active column is the last column then we don't do any thing so that focus
11360
+ // remains on the last column.
11361
+ if (!isLastColumn) {
11362
+ control.blur();
11363
+ meta.editMode.moveToLastColumn(allFocussableColumnIndexes);
11364
+ }
11365
+ } else {
11366
+ // If it is last row and last column, then don't move column.
11367
+ if (!isLastRow || !isLastColumn) {
11368
+ control.blur();
11369
+ meta.editMode.moveToNextColumn(allFocussableColumnIndexes, moveRow);
11370
+ }
11371
+ }
11372
+ return;
11373
+ }
11374
+ if (!detailModeEditing && event.key === 'ArrowUp') {
11375
+ event.preventDefault();
11376
+ // if it is the first row then return early, so that focus on the cell is not lost
11377
+ if (rowIndex === 0) {
11378
+ return;
11379
+ }
11380
+ control.blur();
11381
+ if (event.ctrlKey || event.metaKey) {
11382
+ meta.setActiveRowIndex(0);
11383
+ scrollToOffset(0);
11384
+ } else {
11385
+ moveRow(MOVE_DIR.PREV);
11386
+ }
11387
+ meta.setHoveredRowIndex(undefined);
11388
+ return;
11389
+ }
11390
+ if (!detailModeEditing && event.key === 'ArrowDown') {
11391
+ event.preventDefault();
11392
+ // if it is the last row then return early, so that focus on the cell is not lost
11393
+ if (rowIndex === rows.length - 1) {
11394
+ return;
11395
+ }
11396
+ control.blur();
11397
+ if (event.ctrlKey || event.metaKey) {
11398
+ meta.setActiveRowIndex(rows.length - 1);
11399
+ scrollToIndex(rows.length + 20);
11400
+ } else {
11401
+ moveRow(MOVE_DIR.NEXT);
11402
+ }
11403
+ meta.setHoveredRowIndex(undefined);
11404
+ return;
11405
+ }
11406
+ };
11407
+ }
11408
+ return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, attributes), /*#__PURE__*/React__default.createElement(EditingCell, {
11409
+ detailModeClassName: detailModeClassName,
11410
+ cell: cell,
11411
+ cellRef: internalRef,
11412
+ columnIndex: index,
11413
+ isEditingThisCell: isEditingThisCell,
11414
+ onSave: meta.editMode.onSave,
11415
+ rowIndex: rowIndex,
11416
+ table: table,
11417
+ ref: controlRef,
11418
+ rowValues: rows[rowIndex].original,
11419
+ rowsLength: rows.length
11420
+ }));
11421
+ } else {
11422
+ if (meta.onRowClick) {
11423
+ attributes.onClick = () => {
11424
+ var _meta$onRowClick;
11425
+ (_meta$onRowClick = meta.onRowClick) === null || _meta$onRowClick === void 0 ? void 0 : _meta$onRowClick.call(meta, cell.row.original);
11426
+ };
11427
+ }
11428
+ }
11429
+ return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, attributes), /*#__PURE__*/React__default.createElement("div", {
11430
+ className: disableTruncation ? '-my-[0.45rem]' : 'truncate'
11431
+ }, reactTable$1.flexRender(cell.column.columnDef.cell, cell.getContext())));
11432
+ };
11433
+ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__default.forwardRef((props, ref) => {
11434
+ var _cell$column$columnDe4, _cell$column$columnDe5, _cellRef$current, _cellRef$current$pare, _rowMoveReason$cellId;
11435
+ const {
11436
+ cell,
11437
+ cellRef,
11438
+ columnIndex,
11439
+ detailModeClassName,
11440
+ isEditingThisCell = false,
11441
+ onSave: handleSave,
11442
+ rowIndex,
11443
+ rowValues,
11444
+ table
11445
+ } = props;
11446
+ const {
11447
+ validationErrors,
11448
+ setValidationErrors,
11449
+ rowMoveReason,
11450
+ setRowMoveReason
11451
+ } = useRowContext();
11452
+ const controlRef = useMergedRef(ref);
11453
+ const cellId = cell.column.id;
11454
+ const cellValidationError = validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[cellId];
11455
+ const value = cell.getValue();
11456
+ const ariaLabel = cell.column.columnDef.header;
11457
+ const meta = table.options.meta;
11458
+ const {
11459
+ globalFilter
11460
+ } = table.getState();
11461
+ const [state, setState] = React__default.useState(value);
11462
+ const isHoveringAnotherRowWhileEditing = meta.editMode.isEditing && meta.activeRowIndex !== rowIndex && meta.hoveredRowIndex === rowIndex;
11463
+ const showValidationError = !isHoveringAnotherRowWhileEditing && !!cellValidationError;
11464
+ // On each save, the initialValue will be set to the new value of the cell
11465
+ const initialValue = React__default.useRef(value);
11466
+ // It is important that we let consumers pass a newValue as an argument because when setState is called before
11467
+ // onBlur then saveIfChanged method gets the stale state value. This happens because the rerender hasn't happened
11468
+ // before the saveIfChanged method is called.
11469
+ const saveIfChanged = function (eventOrNewValue) {
11470
+ try {
11471
+ let newValue = state;
11472
+ // if eventOrNewValue is not an event object
11473
+ if (!eventOrNewValue.target) {
11474
+ newValue = eventOrNewValue;
11475
+ }
11476
+ const _temp2 = function () {
11477
+ if (hasChanged(value, newValue)) {
11478
+ const _temp = _catch(function () {
11479
+ const updatedRow = {
11480
+ ...cell.row.original,
11481
+ [cellId]: newValue
11482
+ };
11483
+ return Promise.resolve(handleSave(updatedRow, cellId)).then(function () {
11484
+ // If sorting is paused then update the last sorted or filtered rows to store the newly updated row
11485
+ if (meta.shouldPauseSortingAndFiltering) {
11486
+ meta.lastSortedOrFilteredRows.current = meta.lastSortedOrFilteredRows.current.map(row => {
11487
+ if (row.id === cell.row.id) {
11488
+ row.original = updatedRow;
11489
+ }
11490
+ return row;
11491
+ });
11492
+ }
11493
+ // Reset error if save was successful
11494
+ setValidationErrors(null);
11495
+ });
11496
+ }, function (error) {
11497
+ setValidationErrors(error);
11498
+ });
11499
+ if (_temp && _temp.then) return _temp.then(function () {});
11500
+ }
11501
+ }();
11502
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
11503
+ } catch (e) {
11504
+ return Promise.reject(e);
11505
+ }
11506
+ };
11507
+ // Ensures we "auto focus" the field if the cell is being edited.
11508
+ React__default.useEffect(() => {
11509
+ var _meta$tableRef$curren;
11510
+ const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
11511
+ // When control is blurred then body gets the focus that's why we have to make sure if activeElement
11512
+ // is body then we focus the cell if it is being edited.
11513
+ const isBodyFocussed = document.body === document.activeElement;
11514
+ // Don't focus cell if any table popup(filter popup, column settings popup) is open.
11515
+ if (isEditingThisCell && (isFocusInsideTable || isBodyFocussed)) {
11516
+ var _controlRef$current, _controlRef$current$f;
11517
+ (_controlRef$current = controlRef.current) === null || _controlRef$current === void 0 ? void 0 : (_controlRef$current$f = _controlRef$current.focus) === null || _controlRef$current$f === void 0 ? void 0 : _controlRef$current$f.call(_controlRef$current);
11518
+ }
11519
+ }, [isEditingThisCell, controlRef.current]);
11520
+ // make sure the cell becomes active if the field is focused
11521
+ const handleFocus = event => {
11522
+ var _event$target;
11523
+ meta.editMode.setColumn(columnIndex);
11524
+ if ((_event$target = event.target) !== null && _event$target !== void 0 && _event$target.select) {
11525
+ var _event$target2;
11526
+ (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.select();
11527
+ }
11528
+ };
11529
+ React__default.useEffect(() => {
11530
+ if (hasChanged(initialValue.current, state)) {
11531
+ showIndicator();
11532
+ } else {
11533
+ hideIndicator();
11534
+ }
11535
+ return hideIndicator;
11536
+ }, [state]);
11537
+ const showIndicator = () => {
11538
+ var _table$getState$sorti;
11539
+ let willRowMoveReason = null;
11540
+ const isFilteredByGlobalFilter = Object.values({
11541
+ ...rowValues,
11542
+ [cellId]: state
11543
+ }).some(cellValue =>
11544
+ // Global filter can be undefined when there is no text being searched so we pass an empty string to
11545
+ // globalFilterFn as query in that case.
11546
+ globalFilterFn(String(cellValue), globalFilter ? String(globalFilter) : ''));
11547
+ if (!isFilteredByGlobalFilter) {
11548
+ willRowMoveReason = IndicatorReason.SEARCH;
11549
+ } else if (cell.column.getIsFiltered() && !columnFilterFn(state, cell.column.getFilterValue())) {
11550
+ willRowMoveReason = IndicatorReason.FILTER;
11551
+ } else if (!willRowMoveReason && cell.column.getIsSorted() && willRowMoveAfterSorting(state, cell, rowIndex, table.getRowModel().rows, !!((_table$getState$sorti = table.getState().sorting.find(s => s.id === cell.column.id)) !== null && _table$getState$sorti !== void 0 && _table$getState$sorti.desc))) {
11552
+ willRowMoveReason = IndicatorReason.SORTING;
11553
+ }
11554
+ if (willRowMoveReason !== null) {
11555
+ meta.setShouldPauseSortingAndFiltering(true);
11556
+ setRowMoveReason({
11557
+ [cellId]: willRowMoveReason
11558
+ });
11559
+ }
11560
+ };
11561
+ const hideIndicator = () => {
11562
+ setRowMoveReason(prevState => {
11563
+ const newState = {
11564
+ ...prevState
11565
+ };
11566
+ delete newState[cellId];
11567
+ return newState;
11568
+ });
11569
+ };
11570
+ const cellControl = (_cell$column$columnDe4 = cell.column.columnDef.meta) === null || _cell$column$columnDe4 === void 0 ? void 0 : _cell$column$columnDe4.control;
11571
+ const attributes = {
11572
+ 'aria-label': ariaLabel,
11573
+ onBlur: saveIfChanged,
11574
+ onFocus: handleFocus,
11575
+ ref,
11576
+ // This is a temporary fix to enable up/down arrow key shortcuts on input in quick mode. For some reason,
11577
+ // the preventDefault is true on Taco Input, so the keyboard shortcuts doesn't work. By adding this
11578
+ // data attribute we make sure the event is coming from a control component, and then we can make sure
11579
+ // keyboard shortcut works as expected.
11580
+ 'data-inline-editing-component': 'true'
11581
+ };
11582
+ const className = cn(getCellAlignmentClasses((_cell$column$columnDe5 = cell.column.columnDef.meta) === null || _cell$column$columnDe5 === void 0 ? void 0 : _cell$column$columnDe5.align));
11583
+ const indicatorMountNode = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : (_cellRef$current$pare = _cellRef$current.parentElement) === null || _cellRef$current$pare === void 0 ? void 0 : _cellRef$current$pare.querySelector(':first-child');
11584
+ let controlComponent;
11585
+ if (cellControl) {
11586
+ if (typeof cellControl === 'function') {
11587
+ controlComponent = cellControl({
11588
+ onBlur: saveIfChanged,
11589
+ onFocus: handleFocus,
11590
+ ref: controlRef,
11591
+ setValue: setState,
11592
+ value: state,
11593
+ 'data-inline-editing-component': 'true',
11594
+ className: detailModeClassName
11595
+ }, cell.row.original);
11596
+ } else {
11597
+ switch (cellControl) {
11598
+ case 'datepicker':
11599
+ controlComponent = /*#__PURE__*/React__default.createElement(Datepicker, Object.assign({}, attributes, {
11600
+ className: detailModeClassName,
11601
+ onBlur: event => {
11602
+ const newDate = event.detail;
11603
+ saveIfChanged(newDate);
11604
+ },
11605
+ onChange: event => {
11606
+ setState(event.detail);
11607
+ },
11608
+ ref: controlRef,
11609
+ value: state
11610
+ }));
11611
+ break;
11612
+ case 'switch':
11613
+ controlComponent = /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, attributes, {
11614
+ className: cn('mx-2', detailModeClassName),
11615
+ checked: Boolean(state),
11616
+ onChange: setState,
11617
+ ref: controlRef
11618
+ }));
11619
+ break;
11620
+ default:
11621
+ controlComponent = /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
11622
+ className: cn(className, detailModeClassName),
11623
+ onChange: event => {
11624
+ setState(event.target.value);
11625
+ },
11626
+ ref: controlRef,
11627
+ value: String(state !== null && state !== void 0 ? state : '')
11628
+ }));
11629
+ break;
11630
+ }
11631
+ }
11632
+ }
11633
+ const indicatorReason = (_rowMoveReason$cellId = rowMoveReason[cellId]) !== null && _rowMoveReason$cellId !== void 0 ? _rowMoveReason$cellId : null;
11634
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, indicatorReason !== null && /*#__PURE__*/React__default.createElement(Indicator, {
11635
+ reason: indicatorReason,
11636
+ columnName: String(cell.column.columnDef.header),
11637
+ mountNode: indicatorMountNode
11638
+ }), /*#__PURE__*/React__default.createElement("span", {
11639
+ className: "relative flex-grow"
11640
+ }, controlComponent, showValidationError && /*#__PURE__*/React__default.createElement(ValidationError, null, String(cellValidationError))));
11641
+ }));
11642
+
11643
+ const Header$1 = function Header(props) {
11644
+ var _header$column$column, _header$column$column2, _asc$desc$header$colu, _header$column$column4, _header$column$column5, _header$column$column6, _header$column$column7, _asc$desc$header$colu2, _header$column$column8;
11645
+ const {
11646
+ header,
11647
+ index,
11648
+ isLastColumn,
11649
+ table,
11650
+ tableRef,
11651
+ ...columnProps
11652
+ } = props;
11653
+ const textRef = React__default.useRef(null);
11654
+ const pinned = !!header.column.getIsPinned();
11655
+ const isOtherColumnBeingResized = table.getState().columnSizingInfo.isResizingColumn && table.getState().columnSizingInfo.isResizingColumn !== header.id;
11656
+ const className = cn('group/header sticky top-0 bg-white border-b-2 relative font-bold z-[5] hover:z-[6]', {
11657
+ 'z-[6]': header.column.getIsResizing(),
11658
+ 'z-[7]': pinned,
11659
+ 'cursor-pointer select-none': header.column.getCanSort(),
11660
+ 'hover:bg-grey-100': header.column.getCanSort() || header.column.getCanResize() || ((_header$column$column = header.column.columnDef.meta) === null || _header$column$column === void 0 ? void 0 : _header$column$column.menu),
11661
+ 'pointer-events-none': isOtherColumnBeingResized
11662
+ }, getCellSizingClasses('normal'), (_header$column$column2 = header.column.columnDef.meta) === null || _header$column$column2 === void 0 ? void 0 : _header$column$column2.headerClassName, props.className);
11663
+ // set the column size after the first render (after auto layout with 'max-content') has run
11664
+ // this way columns default to fit their content, then we save that size for resizing
11665
+ const refCallback = node => {
11666
+ if (node && !table.getState().columnSizing[header.id]) {
11667
+ const size = Math.ceil(node.getBoundingClientRect().width);
11668
+ table.setColumnSizing(sizes => ({
11669
+ ...sizes,
11670
+ [header.id]: !isInternalColumn(header.id) && size < MIN_COLUMN_SIZE ? MIN_COLUMN_SIZE : size
11671
+ }));
11672
+ }
11673
+ };
11674
+ // we use mousedown because clicking and dragging resize and then letting go over the
11675
+ // column, results in sorting being applied
11676
+ const handleMouseDown = header.column.getCanSort() ? event => {
11677
+ // only detect left clicks
11678
+ if (event.button === 0) {
11679
+ var _tableRef$current;
11680
+ event.preventDefault();
11681
+ table.resetRowSelection();
11682
+ header.column.toggleSorting();
11683
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.focus();
11684
+ }
11685
+ } : undefined;
11686
+ const handleResizerDoubleClick = () => {
11687
+ var _header$column$column3;
11688
+ const size = (_header$column$column3 = header.column.columnDef.meta) === null || _header$column$column3 === void 0 ? void 0 : _header$column$column3.defaultWidth;
11689
+ table.setColumnSizing(sizes => {
11690
+ const nextSizes = {
11691
+ ...sizes
11692
+ };
11693
+ if (size) {
11694
+ nextSizes[header.id] = !isInternalColumn(header.id) && size < MIN_COLUMN_SIZE ? MIN_COLUMN_SIZE : size;
11695
+ } else {
11696
+ delete nextSizes[header.id];
11697
+ }
11698
+ return nextSizes;
11699
+ });
11700
+ };
11701
+ const handleResizerClick = event => {
11702
+ event.stopPropagation();
11703
+ event.preventDefault();
11704
+ };
11705
+ const handleResize = event => {
11706
+ // prevent the parent onMouseDown propagating
11707
+ event.stopPropagation();
11708
+ header.getResizeHandler()(event);
11709
+ };
11710
+ const content = /*#__PURE__*/React__default.createElement("div", {
11711
+ className: "truncate",
11712
+ ref: textRef
11713
+ }, reactTable$1.flexRender(header.column.columnDef.header, header.getContext()));
11714
+ return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, columnProps, {
11715
+ // base props
11716
+ column: header.column,
11717
+ table: table,
11718
+ "aria-sort": (_asc$desc$header$colu = {
11719
+ asc: 'ascending',
11720
+ desc: 'descending'
11721
+ }[header.column.getIsSorted()]) !== null && _asc$desc$header$colu !== void 0 ? _asc$desc$header$colu : 'none',
11722
+ className: className,
11723
+ onMouseDown: handleMouseDown,
11724
+ ref: refCallback,
11725
+ role: "columnheader",
11726
+ "data-column-index": index
11727
+ }), isInternalColumn(header.id) ? reactTable$1.flexRender(header.column.columnDef.header, header.getContext()) : /*#__PURE__*/React__default.createElement("div", {
11728
+ className: cn('flex flex-grow overflow-hidden', {
11729
+ 'group-hover/header:-ml-2': !!header.column.getIsSorted() && !!((_header$column$column4 = header.column.columnDef.meta) !== null && _header$column$column4 !== void 0 && _header$column$column4.menu)
11730
+ }, getCellAlignmentClasses((_header$column$column5 = header.column.columnDef.meta) === null || _header$column$column5 === void 0 ? void 0 : _header$column$column5.align))
11731
+ }, isOverflowing(textRef.current) ? /*#__PURE__*/React__default.createElement(Tooltip, {
11732
+ title: (_header$column$column6 = (_header$column$column7 = header.column.columnDef.meta) === null || _header$column$column7 === void 0 ? void 0 : _header$column$column7.tooltip) !== null && _header$column$column6 !== void 0 ? _header$column$column6 : content,
11733
+ placement: "top"
11734
+ }, content) : content, (_asc$desc$header$colu2 = {
11735
+ asc: /*#__PURE__*/React__default.createElement(Icon, {
11736
+ name: "chevron-up-solid",
11737
+ className: "pointer-events-none -my-0.5"
11738
+ }),
11739
+ desc: /*#__PURE__*/React__default.createElement(Icon, {
11740
+ name: "chevron-down-solid",
11741
+ className: "pointer-events-none -my-0.5"
11742
+ })
11743
+ }[header.column.getIsSorted()]) !== null && _asc$desc$header$colu2 !== void 0 ? _asc$desc$header$colu2 : null), (_header$column$column8 = header.column.columnDef.meta) !== null && _header$column$column8 !== void 0 && _header$column$column8.menu ? /*#__PURE__*/React__default.createElement(HeaderMenu, {
11744
+ header: header
11745
+ }) : null, header.column.getCanResize() ? /*#__PURE__*/React__default.createElement(Tooltip, {
11746
+ placement: "top",
11747
+ title: "Resize column"
11748
+ }, /*#__PURE__*/React__default.createElement("div", {
11749
+ className: cn('invisible absolute right-0 top-0 flex h-full cursor-col-resize touch-none select-none rounded py-0.5 group-hover/header:visible', {
11750
+ '-mr-2.5 w-5 justify-center': !isLastColumn,
11751
+ 'w-2': isLastColumn,
11752
+ '!visible': header.column.getIsResizing()
11753
+ }),
11754
+ onDoubleClick: handleResizerDoubleClick,
11755
+ onMouseDown: handleResize,
11756
+ onTouchStart: handleResize,
11757
+ // this prevents sort handlers being activated
11758
+ onClick: handleResizerClick
11759
+ }, /*#__PURE__*/React__default.createElement("div", {
11760
+ className: cn('h-full w-1 rounded', {
11761
+ '!bg-blue-500': header.column.getIsResizing(),
11762
+ 'bg-grey-500 hover:bg-grey-700': !header.column.getIsResizing()
11763
+ })
11764
+ }))) : null);
11765
+ };
11766
+ const HeaderMenu = ({
11767
+ header
11768
+ }) => {
11769
+ const [open, setOpen] = React__default.useState(false);
11770
+ const className = cn('-my-0.5 -mr-1 -ml-0.5 hidden !h-6 !min-h-[theme(spacing.6)] !w-6 !min-w-[theme(spacing.6)] flex-shrink-0 justify-end group-hover/header:flex', {
11771
+ '!flex': open
11772
+ });
11773
+ return header.column.columnDef.meta ?
11774
+ /*#__PURE__*/
11775
+ // This div catches the mousedown events from menu item and menu trigger and prevents
11776
+ // mousedown event from bubbling up to the Header component to prevent toggling sorting
11777
+ React__default.createElement("div", {
11778
+ onMouseDown: event => event.stopPropagation()
11779
+ }, header.column.columnDef.meta.menu({
11780
+ trigger: /*#__PURE__*/React__default.createElement(IconButton, {
11781
+ className: className,
11782
+ icon: "more"
11783
+ }),
11784
+ open: open,
11785
+ onChange: setOpen
11786
+ })) : null;
11787
+ };
11788
+
11789
+ const Footer$2 = function Footer(props) {
11790
+ const {
11791
+ footer,
11792
+ index,
11793
+ table,
11794
+ ...columnProps
11795
+ } = props;
11796
+ const isPinned = !!footer.column.getIsPinned();
11797
+ const className = cn('group/header sticky bottom-0 bg-white border-t-2 relative ', {
11798
+ 'z-[1]': isPinned
11799
+ }, props.className);
11800
+ return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, columnProps, {
11801
+ // base props
11802
+ column: footer.column,
11803
+ table: table,
11804
+ className: className,
11805
+ role: "cell",
11806
+ "data-column-index": index
11807
+ }));
11808
+ };
11809
+
11810
+ function useColumnDefinitions(children, options, tableRef) {
11811
+ const lastSelectedRowIndex = React__default.useRef();
11812
+ const columnHelper = reactTable$1.createColumnHelper();
11813
+ return React__default.useMemo(() => {
11814
+ var _options$actionsForRo;
11815
+ // cannot be typed correctly until https://github.com/TanStack/table/discussions/4530 is resolved
11816
+ const columns = [];
11817
+ const defaultColumnPinning = [];
11818
+ const defaultColumnSizing = {};
11819
+ const defaultColumnVisibility = {};
11820
+ const defaultSorting = [];
11821
+ const footers = {};
11822
+ React__default.Children.toArray(children).forEach(child => {
11823
+ if ( /*#__PURE__*/React__default.isValidElement(child)) {
11824
+ var _child$props$minWidth;
11825
+ if (child.props.defaultPinned && options.enableColumnPinning) {
11826
+ defaultColumnPinning.push(child.props.accessor);
11827
+ }
11828
+ if (child.props.defaultWidth) {
11829
+ defaultColumnSizing[child.props.accessor] = child.props.defaultWidth;
11830
+ }
11831
+ if (child.props.defaultHidden && options.enableColumnHiding) {
11832
+ defaultColumnVisibility[child.props.accessor] = false;
11833
+ }
11834
+ if (child.props.sort !== undefined) {
11835
+ defaultSorting.push({
11836
+ id: child.props.accessor,
11837
+ desc: child.props.sort === 'desc'
11838
+ });
11839
+ }
11840
+ if (child.props.footer) {
11841
+ footers[child.props.accessor] = child.props.footer;
11842
+ }
11843
+ columns.push({
11844
+ accessorKey: child.props.accessor,
11845
+ id: child.props.accessor,
11846
+ cell: props => {
11847
+ var _props$getValue;
11848
+ if (typeof child.props.renderer === 'function') {
11849
+ return child.props.renderer(props.getValue(), props.row.original);
11850
+ }
11851
+ // If value is undefined then return null because cell is a react component, and undefined is not
11852
+ // a valid child value.
11853
+ return (_props$getValue = props.getValue()) !== null && _props$getValue !== void 0 ? _props$getValue : null;
11854
+ },
11855
+ header: child.props.header,
11856
+ meta: {
11857
+ align: child.props.align,
11858
+ className: child.props.className,
11859
+ control: child.props.control,
11860
+ dataType: child.props.dataType,
11861
+ defaultWidth: child.props.defaultWidth,
11862
+ disableReordering: child.props.disableReordering,
11863
+ disableTruncation: child.props.disableTruncation,
11864
+ menu: child.props.menu,
11865
+ tooltip: child.props.tooltip
11866
+ },
11867
+ enableHiding: !child.props.disableHiding,
11868
+ // filtering
11869
+ enableColumnFilter: !child.props.disableFiltering,
11870
+ filterFn: options.enableColumnFiltering && !child.props.disableFiltering ? 'tacoFilter' : undefined,
11871
+ // sizing
11872
+ enableResizing: !child.props.disableResizing,
11873
+ minSize: (_child$props$minWidth = child.props.minWidth) !== null && _child$props$minWidth !== void 0 ? _child$props$minWidth : MIN_COLUMN_SIZE,
11874
+ size: child.props.defaultWidth,
11875
+ // sorting
11876
+ enableSorting: !child.props.disableSorting,
11877
+ sortingFn: getSortingFn(child.props.dataType)
11878
+ });
11879
+ }
11880
+ });
11881
+ if (options.enableRowExpansion) {
11882
+ columns.unshift(columnHelper.display(createRowExpansionColumn()));
11883
+ defaultColumnPinning.unshift(COLUMN_ID_FOR_EXPANSION);
11884
+ }
11885
+ if (options.enableRowSelection) {
11886
+ columns.unshift(columnHelper.display(createRowSelectionColumn(options.enableMultipleRowSelection, lastSelectedRowIndex, options.onRowDrag, tableRef)));
11887
+ defaultColumnPinning.unshift(COLUMN_ID_FOR_SELECTION);
11888
+ }
11889
+ if (options.onRowDrag) {
11890
+ columns.unshift(columnHelper.display(createRowDraggableColumn(options.onRowDrag)));
11891
+ defaultColumnPinning.unshift(COLUMN_ID_FOR_DRAGGABLE);
11892
+ }
11893
+ if ((_options$actionsForRo = options.actionsForRow) !== null && _options$actionsForRo !== void 0 && _options$actionsForRo.length) {
11894
+ columns.push(columnHelper.display(createRowActionsColumn(options.actionsForRow)));
11895
+ }
11896
+ return {
11897
+ columns,
11898
+ defaultColumnPinning,
11899
+ defaultColumnSizing,
11900
+ defaultColumnVisibility,
11901
+ defaultSorting,
11902
+ footers
11903
+ };
11904
+ }, [children]);
11905
+ }
11906
+ const getSortingFn = dataType => {
11907
+ if (dataType && dataType !== 'boolean') {
11908
+ return dataType;
11909
+ }
11910
+ return 'auto';
11911
+ };
11912
+
11913
+ const isResizingPinnedColumn = (columnId, table) => {
11914
+ var _table$getState$colum, _table$getState$colum2;
11915
+ return !!columnId && ((_table$getState$colum = table.getState().columnPinning.left) === null || _table$getState$colum === void 0 ? void 0 : _table$getState$colum.includes((_table$getState$colum2 = table.getState().columnSizingInfo) === null || _table$getState$colum2 === void 0 ? void 0 : _table$getState$colum2.isResizingColumn));
11916
+ };
11917
+ const getOffsetsFromSize = (pinning, visibility, sizing) => {
11918
+ const pinned = pinning.left.filter(c => visibility[c] !== false);
11919
+ const offsets = {};
11920
+ let leftOffset = 0;
11921
+ for (const k of pinned) {
11922
+ if (!Number.isInteger(sizing[k])) {
11923
+ break;
11924
+ }
11925
+ offsets[k] = leftOffset;
11926
+ leftOffset += sizing[k];
11927
+ }
11928
+ return offsets;
11929
+ };
11930
+ // pinned columns have position sticky, and because we support more than one of them
11931
+ // we must set a 'left' css value. this hook listens to changes on state that will
11932
+ // affect the left offset (resize, visibility, pinning) and updates offsets based on width
11933
+ const useColumnOffsetStateListener = (table, setColumnOffsets) => {
11934
+ const {
11935
+ columnPinning,
11936
+ columnSizing,
11937
+ columnSizingInfo,
11938
+ columnVisibility
11939
+ } = table.getState();
11940
+ React__default.useEffect(() => {
11941
+ if (isResizingPinnedColumn(columnSizingInfo.isResizingColumn, table)) {
11942
+ setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
11943
+ }
11944
+ }, [columnSizingInfo]);
11945
+ React__default.useEffect(() => {
11946
+ setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
11947
+ }, [columnVisibility]);
11948
+ React__default.useEffect(() => {
11949
+ setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
11950
+ }, [columnPinning.left]);
11951
+ };
11952
+
11953
+ const useRowSelectionListener = (table, onRowSelect) => {
11954
+ React__default.useEffect(() => {
11955
+ if (onRowSelect) {
11956
+ if (table.options.enableMultiRowSelection) {
11957
+ onRowSelect(table.getSelectedRowModel().rows.map(row => row.original));
11958
+ } else {
11959
+ var _table$getSelectedRow, _table$getSelectedRow2;
11960
+ onRowSelect((_table$getSelectedRow = (_table$getSelectedRow2 = table.getSelectedRowModel().rows[0]) === null || _table$getSelectedRow2 === void 0 ? void 0 : _table$getSelectedRow2.original) !== null && _table$getSelectedRow !== void 0 ? _table$getSelectedRow : undefined);
11961
+ }
11962
+ }
11963
+ }, [table.getState().rowSelection]);
11964
+ };
11965
+
11966
+ const useSettingsStateListener = (table, onChangeSettings) => {
11967
+ const meta = table.options.meta;
11968
+ const state = table.getState();
11969
+ React__default.useEffect(() => {
11970
+ let handler;
11971
+ if (typeof onChangeSettings === 'function') {
11972
+ handler = setTimeout(() => onChangeSettings({
11973
+ columnFilters: state.columnFilters,
11974
+ columnOrder: state.columnOrder,
11975
+ columnPinning: state.columnPinning,
11976
+ columnSizing: state.columnSizing,
11977
+ columnVisibility: state.columnVisibility,
11978
+ globalFilter: state.globalFilter,
11979
+ rowDensity: meta.rowDensity,
11980
+ sorting: state.sorting
11981
+ }), 250);
11982
+ }
11983
+ return () => clearTimeout(handler);
11984
+ }, [state.columnFilters, state.columnOrder, state.columnPinning, state.columnSizing, state.columnVisibility, state.globalFilter, meta.rowDensity, state.sorting]);
11985
+ };
11986
+
11987
+ const useActiveRow = (defaultActiveRowIndex = 0) => {
11988
+ const [activeRowIndex, _setActiveRow] = React__default.useState(defaultActiveRowIndex);
11989
+ const moveActiveRow = (direction, rows, callback) => {
11990
+ _setActiveRow(rowIndex => {
11991
+ const nextRowIndex = getNextIndex$1(direction, rowIndex, rows.length);
11992
+ if (callback) {
11993
+ callback(nextRowIndex);
11994
+ }
11995
+ return nextRowIndex;
11996
+ });
11997
+ };
11998
+ // output
11999
+ const moveToPreviousRow = (rows, callback) => moveActiveRow(-1, rows, callback);
12000
+ const moveToNextRow = (rows, callback) => moveActiveRow(1, rows, callback);
12001
+ const setActiveRowIndex = rowIndex => _setActiveRow(rowIndex);
12002
+ return {
12003
+ activeRowIndex,
12004
+ setActiveRowIndex,
12005
+ moveToPreviousRow,
12006
+ moveToNextRow
12007
+ };
12008
+ };
12009
+ const getNextIndex$1 = (direction, currentIndex, length) => {
12010
+ if (direction === -1) {
12011
+ return currentIndex - 1 > 0 ? currentIndex - 1 : 0;
12012
+ }
12013
+ return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;
12014
+ };
12015
+
12016
+ const useActiveRowStateListener = (table, rows, activeRowIndex) => {
12017
+ const meta = table.options.meta;
12018
+ React__default.useEffect(() => {
12019
+ if (meta.editMode.isEditing && meta.shouldPauseSortingAndFiltering) {
12020
+ meta.setShouldPauseSortingAndFiltering(false);
12021
+ }
12022
+ }, [activeRowIndex.activeRowIndex]);
12023
+ // if a filter would exclude the active row, reset it to 0
12024
+ React__default.useEffect(() => {
12025
+ if (activeRowIndex.activeRowIndex > rows.length - 1) {
12026
+ meta.setActiveRowIndex(rows.length ? rows.length - 1 : 0);
12027
+ }
12028
+ }, [table.getState().columnFilters, rows.length]);
12029
+ };
12030
+
12031
+ function useTable$1(children, props, ref) {
12032
+ var _settings$columnOrder, _ref, _settings$columnPinni, _settings$columnPinni2, _settings$columnSizin, _settings$columnVisib, _settings$rowDensity;
12033
+ const {
12034
+ actionsForRow = [],
12035
+ data,
12036
+ defaultActiveRowIndex,
12037
+ disableColumnFiltering = false,
12038
+ disableColumnHiding = false,
12039
+ disableColumnPinning = false,
12040
+ disableColumnReordering = false,
12041
+ disableColumnResizing = false,
12042
+ disableRowDensity = false,
12043
+ disableRowExpansion = false,
12044
+ disableRowSelection = false,
12045
+ disableMultipleRowSelection = false,
12046
+ disableSearch = false,
12047
+ disableSorting = false,
12048
+ expandedRowRenderer,
12049
+ manualColumnFiltering = false,
12050
+ manualSearch = false,
12051
+ manualSorting = false,
12052
+ onChangeSettings,
12053
+ onRowClick,
12054
+ onRowDrag,
12055
+ onRowSelect,
12056
+ onSave,
12057
+ settings = {},
12058
+ // experimental
12059
+ _experimentalActionsForTable
12060
+ } = props;
12061
+ const enableRowExpansion = !disableRowExpansion && !!expandedRowRenderer;
12062
+ const enableRowSelection = !disableRowSelection && (!!onRowSelect || !!(_experimentalActionsForTable !== null && _experimentalActionsForTable !== void 0 && _experimentalActionsForTable.length));
12063
+ const enableMultipleRowSelection = !disableMultipleRowSelection && enableRowSelection;
12064
+ const {
12065
+ columns,
12066
+ defaultColumnPinning,
12067
+ defaultColumnSizing,
12068
+ defaultSorting,
12069
+ defaultColumnVisibility,
12070
+ footers
12071
+ } = useColumnDefinitions(children, {
12072
+ actionsForRow,
12073
+ enableColumnFiltering: !disableColumnFiltering,
12074
+ enableColumnHiding: !disableColumnHiding,
12075
+ enableColumnPinning: !disableColumnPinning,
12076
+ enableRowExpansion,
12077
+ enableRowSelection,
12078
+ enableMultipleRowSelection,
12079
+ onRowDrag
12080
+ }, ref);
12081
+ const lastSortedOrFilteredRows = React__default.useRef(null);
12082
+ // defaults
12083
+ const initialState = {
12084
+ columnOrder: (_settings$columnOrder = settings === null || settings === void 0 ? void 0 : settings.columnOrder) !== null && _settings$columnOrder !== void 0 ? _settings$columnOrder : columns.map(column => column.id),
12085
+ columnPinning: {
12086
+ left: (_ref = (_settings$columnPinni = settings === null || settings === void 0 ? void 0 : (_settings$columnPinni2 = settings.columnPinning) === null || _settings$columnPinni2 === void 0 ? void 0 : _settings$columnPinni2.left) !== null && _settings$columnPinni !== void 0 ? _settings$columnPinni : defaultColumnPinning) !== null && _ref !== void 0 ? _ref : [],
12087
+ right: []
12088
+ },
12089
+ columnSizing: (_settings$columnSizin = settings === null || settings === void 0 ? void 0 : settings.columnSizing) !== null && _settings$columnSizin !== void 0 ? _settings$columnSizin : defaultColumnSizing,
12090
+ columnVisibility: (_settings$columnVisib = settings === null || settings === void 0 ? void 0 : settings.columnVisibility) !== null && _settings$columnVisib !== void 0 ? _settings$columnVisib : defaultColumnVisibility
12091
+ };
12092
+ // Data column index - these are needed to make sure left and right arrow key shortcuts focuses only the data columns
12093
+ const dataColumnStartOffset = [!!onRowDrag, !!enableRowExpansion, !!enableRowSelection].reduce((t, e) => t + (e ? 1 : 0), 0);
12094
+ const dataColumnEndOffset = actionsForRow.length ? 1 : 0;
12095
+ // custom
12096
+ const activeRow = useActiveRow(defaultActiveRowIndex);
12097
+ const [hoveredRowIndex, setHoveredRowIndex] = React__default.useState(undefined);
12098
+ const editMode = useEditMode(onSave);
12099
+ const [columnOffsets, setColumnOffsets] = React__default.useState(getOffsetsFromSize(initialState.columnPinning, initialState.columnVisibility, initialState.columnSizing));
12100
+ const [rowDensity, setRowDensity] = React__default.useState((_settings$rowDensity = settings === null || settings === void 0 ? void 0 : settings.rowDensity) !== null && _settings$rowDensity !== void 0 ? _settings$rowDensity : 'normal');
12101
+ const [dragging, setDragging] = React__default.useState({});
12102
+ const [shouldPauseSortingAndFiltering, setShouldPauseSortingAndFiltering] = React__default.useState(false);
12103
+ const [shouldDisableTableActions, setShouldDisableTableActions] = React__default.useState(false);
12104
+ // For some reason, using state instead of ref didn't work as expected, that's why ref is used
12105
+ const focussableColumnIndexes = React__default.useRef([]);
12106
+ // some options get set even if they are undefined, so we have to do it conditionally
12107
+ const options = {
12108
+ enableExpanding: enableRowExpansion,
12109
+ enableColumnFilters: !disableColumnFiltering,
12110
+ enableColumnResizing: !disableColumnResizing,
12111
+ enableGlobalFilter: !disableSearch,
12112
+ enableHiding: !disableColumnHiding,
12113
+ enablePinning: !disableColumnPinning,
12114
+ enableRowSelection: enableRowSelection,
12115
+ enableMultiRowSelection: enableMultipleRowSelection,
12116
+ enableSorting: !disableSorting
12117
+ };
12118
+ // resizing
12119
+ if (options.enableColumnResizing) {
12120
+ options.columnResizeMode = 'onChange';
12121
+ }
12122
+ // sorting
12123
+ if (options.enableSorting) {
12124
+ var _settings$sorting;
12125
+ initialState.sorting = (_settings$sorting = settings === null || settings === void 0 ? void 0 : settings.sorting) !== null && _settings$sorting !== void 0 ? _settings$sorting : defaultSorting;
12126
+ if (manualSorting) {
12127
+ options.manualSorting = true;
12128
+ } else {
12129
+ options.getSortedRowModel = reactTable$1.getSortedRowModel();
12130
+ }
12131
+ }
12132
+ // filtering
12133
+ if (options.enableColumnFilters) {
12134
+ var _settings$columnFilte;
12135
+ initialState.columnFilters = (_settings$columnFilte = settings === null || settings === void 0 ? void 0 : settings.columnFilters) !== null && _settings$columnFilte !== void 0 ? _settings$columnFilte : [];
12136
+ if (manualColumnFiltering) {
12137
+ options.manualFiltering = true;
12138
+ } else {
12139
+ options.filterFns = {
12140
+ tacoFilter: (row, columnId, filter) => columnFilterFn(row.getValue(columnId), filter)
12141
+ };
12142
+ options.getFilteredRowModel = reactTable$1.getFilteredRowModel();
12143
+ }
12144
+ }
12145
+ // search
12146
+ if (options.enableGlobalFilter) {
12147
+ if (manualSearch) {
12148
+ options.manualFiltering = true;
12149
+ } else {
12150
+ options.globalFilterFn = (row, columnId, query) => globalFilterFn(row.getValue(columnId), query);
12151
+ options.getFilteredRowModel = reactTable$1.getFilteredRowModel();
12152
+ }
12153
+ }
12154
+ const table = reactTable$1.useReactTable({
12155
+ data,
12156
+ columns: columns,
12157
+ getCoreRowModel: reactTable$1.getCoreRowModel(),
12158
+ initialState,
12159
+ ...options,
12160
+ meta: {
12161
+ ...activeRow,
12162
+ editMode,
12163
+ // offsets
12164
+ columnOffsets,
12165
+ // density
12166
+ enableRowDensity: !disableRowDensity,
12167
+ rowDensity,
12168
+ setRowDensity,
12169
+ // dragging
12170
+ dragging,
12171
+ setDragging,
12172
+ // computed
12173
+ enableColumnReordering: !disableColumnReordering,
12174
+ // resorting
12175
+ shouldPauseSortingAndFiltering,
12176
+ setShouldPauseSortingAndFiltering,
12177
+ // other
12178
+ onRowClick,
12179
+ hoveredRowIndex,
12180
+ setHoveredRowIndex,
12181
+ // data column positions
12182
+ dataColumnStartOffset,
12183
+ dataColumnEndOffset,
12184
+ // disable table actions
12185
+ shouldDisableTableActions,
12186
+ setShouldDisableTableActions,
12187
+ // active row column indexes
12188
+ focussableColumnIndexes: focussableColumnIndexes.current,
12189
+ addFocussableColumnIndex: index => {
12190
+ if (!focussableColumnIndexes.current.includes(index)) {
12191
+ focussableColumnIndexes.current = [...focussableColumnIndexes.current, index].sort((a, b) => a - b);
12192
+ }
12193
+ },
12194
+ resetFocussableColumnIndexes: () => {
12195
+ focussableColumnIndexes.current = [];
12196
+ },
12197
+ // table ref
12198
+ tableRef: ref,
12199
+ // last sorted or filtered rows
12200
+ lastSortedOrFilteredRows
12201
+ }
12202
+ });
12203
+ const tableRows = table.getRowModel().rows;
12204
+ if (!shouldPauseSortingAndFiltering) {
12205
+ lastSortedOrFilteredRows.current = tableRows;
12206
+ }
12207
+ const rows = shouldPauseSortingAndFiltering ? lastSortedOrFilteredRows.current : tableRows;
12208
+ // state listeners
12209
+ useActiveRowStateListener(table, rows, activeRow);
12210
+ useColumnOffsetStateListener(table, setColumnOffsets);
12211
+ useRowSelectionListener(table, onRowSelect);
12212
+ useSettingsStateListener(table, onChangeSettings);
12213
+ return {
12214
+ rows,
12215
+ table,
12216
+ footers
12217
+ };
12218
+ }
12219
+
12220
+ const densitySizeEstimates = {
12221
+ compact: 33,
12222
+ normal: 41,
12223
+ comfortable: 49,
12224
+ spacious: 57
12225
+ };
12226
+ const useVirtualiser = ({
12227
+ rows,
12228
+ table
12229
+ }, tableRef) => {
12230
+ var _virtualiser$virtualI, _virtualiser$virtualI2, _virtualiser$virtualI3, _virtualiser$virtualI4;
12231
+ const [expandedRowSizes, setExpandedRowSizes] = React__default.useState({});
12232
+ const firstAvailableExpandedRowHeight = React__default.useMemo(() => {
12233
+ const values = Object.values(expandedRowSizes);
12234
+ return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;
12235
+ }, [expandedRowSizes]);
12236
+ const meta = table.options.meta;
12237
+ const estimateSize = React__default.useCallback(index => {
12238
+ var _table$getState$expan;
12239
+ const rowHeight = meta.rowDensity ? densitySizeEstimates[meta.rowDensity] : densitySizeEstimates.normal;
12240
+ if (table.getState().expanded === true || (_table$getState$expan = table.getState().expanded) !== null && _table$getState$expan !== void 0 && _table$getState$expan[index]) {
12241
+ var _ref, _expandedRowSizes$ind;
12242
+ return rowHeight + ((_ref = (_expandedRowSizes$ind = expandedRowSizes[index]) !== null && _expandedRowSizes$ind !== void 0 ? _expandedRowSizes$ind : firstAvailableExpandedRowHeight) !== null && _ref !== void 0 ? _ref : 0);
12243
+ }
12244
+ return rowHeight;
12245
+ }, [meta.rowDensity, expandedRowSizes, table.getState().expanded]);
12246
+ const virtualiser = reactVirtual.useVirtual({
12247
+ parentRef: tableRef,
12248
+ size: rows.length,
12249
+ estimateSize,
12250
+ overscan: 10
12251
+ });
12252
+ const paddingTop = virtualiser.virtualItems.length > 0 ? ((_virtualiser$virtualI = virtualiser.virtualItems) === null || _virtualiser$virtualI === void 0 ? void 0 : (_virtualiser$virtualI2 = _virtualiser$virtualI[0]) === null || _virtualiser$virtualI2 === void 0 ? void 0 : _virtualiser$virtualI2.start) || 0 : 0;
12253
+ const paddingBottom = virtualiser.virtualItems.length > 0 ? virtualiser.totalSize - (((_virtualiser$virtualI3 = virtualiser.virtualItems) === null || _virtualiser$virtualI3 === void 0 ? void 0 : (_virtualiser$virtualI4 = _virtualiser$virtualI3[virtualiser.virtualItems.length - 1]) === null || _virtualiser$virtualI4 === void 0 ? void 0 : _virtualiser$virtualI4.end) || 0) : 0;
12254
+ return {
12255
+ virtualiser,
12256
+ virtualiserOffsets: {
12257
+ top: paddingTop,
12258
+ bottom: paddingBottom
12259
+ },
12260
+ setExpandedRowSizes
12261
+ };
12262
+ };
12263
+
12264
+ const useGridTemplate = table => {
12265
+ var _table$options$meta$t, _table$options$meta, _table$options$meta$t2, _table$options$meta$t3, _table$options$meta2, _table$options$meta2$;
12266
+ const allVisibleColumns = table.getVisibleLeafColumns();
12267
+ let scrollbarWidth = ((_table$options$meta$t = (_table$options$meta = table.options.meta) === null || _table$options$meta === void 0 ? void 0 : (_table$options$meta$t2 = _table$options$meta.tableRef.current) === null || _table$options$meta$t2 === void 0 ? void 0 : _table$options$meta$t2.offsetWidth) !== null && _table$options$meta$t !== void 0 ? _table$options$meta$t : 0) - ((_table$options$meta$t3 = (_table$options$meta2 = table.options.meta) === null || _table$options$meta2 === void 0 ? void 0 : (_table$options$meta2$ = _table$options$meta2.tableRef.current) === null || _table$options$meta2$ === void 0 ? void 0 : _table$options$meta2$.clientWidth) !== null && _table$options$meta$t3 !== void 0 ? _table$options$meta$t3 : 0);
12268
+ scrollbarWidth = scrollbarWidth < 0 ? 0 : scrollbarWidth;
12269
+ return allVisibleColumns.reduce((accum, column, index) => {
12270
+ let size;
12271
+ const isLastColumn = index === allVisibleColumns.length - 1;
12272
+ const width = table.getState().columnSizing[column.id];
12273
+ if (column.id === COLUMN_ID_FOR_ACTIONS) {
12274
+ size = `minmax(max-content, auto)`;
12275
+ } else if (isInternalColumn(column.id)) {
12276
+ size = `${column.getSize()}px`;
12277
+ } else if (width) {
12278
+ if (isLastColumn) {
12279
+ // Remove the scrollbar width from the last column
12280
+ size = `minmax(${width - scrollbarWidth}px, auto)`;
12281
+ } else if (column.columnDef.minSize && width < column.columnDef.minSize) {
12282
+ // react-table is supposed to handle minSize itself but it is really buggy
12283
+ size = `${column.columnDef.minSize}px`;
12284
+ } else {
12285
+ size = `${width}px`;
12286
+ }
12287
+ } else if (column.getCanResize()) {
12288
+ size = 'minmax(max-content, auto)';
12289
+ } else {
12290
+ size = 'max-content';
12291
+ }
12292
+ return `${accum} ${size}`;
12293
+ }, '');
12294
+ };
12295
+
12296
+ const RowDensityButton = ({
12297
+ table
12298
+ }) => {
12299
+ const meta = table.options.meta;
12300
+ return /*#__PURE__*/React__default.createElement(IconButton, {
12301
+ "aria-label": "Change row density",
12302
+ icon: `density-${meta.rowDensity}`,
12303
+ menu: menuProps => /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, {
12304
+ align: "end"
12305
+ }, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup, {
12306
+ onChange: rowDensity => meta.setRowDensity(rowDensity),
12307
+ value: meta.rowDensity
12308
+ }, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
12309
+ value: "compact"
12310
+ }, "Compact"), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
12311
+ value: "normal"
12312
+ }, "Normal"), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
12313
+ value: "comfortable"
12314
+ }, "Comfortable"), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
12315
+ value: "spacious"
12316
+ }, "Spacious")))),
12317
+ tooltip: "Row density"
12318
+ });
12319
+ };
12320
+
12321
+ function getContainerById(children, id) {
12322
+ var _lists$find;
12323
+ const lists = React__default.Children.toArray(children).filter(child => child.type.displayName === 'SortableList');
12324
+ const list = lists.find(list => list.props.id === id);
12325
+ if (list) {
12326
+ return list === null || list === void 0 ? void 0 : list.props;
12327
+ }
12328
+ return (_lists$find = lists.find(l => React__default.Children.toArray(l.props.children).findIndex(child => child.props.id === id) > -1)) === null || _lists$find === void 0 ? void 0 : _lists$find.props;
12329
+ }
12330
+ function Container(externalProps) {
12331
+ const {
12332
+ children,
12333
+ reorder,
12334
+ move
12335
+ } = externalProps;
12336
+ function handleDragOver(event) {
12337
+ const {
12338
+ active,
12339
+ over
12340
+ } = event;
12341
+ if (!(active !== null && active !== void 0 && active.id) || !(over !== null && over !== void 0 && over.id)) {
12342
+ return;
12343
+ }
12344
+ const activeList = getContainerById(children, active.id);
12345
+ const overList = getContainerById(children, over.id);
12346
+ if (!(activeList !== null && activeList !== void 0 && activeList.id) || !(overList !== null && overList !== void 0 && overList.id) || activeList.id === overList.id) {
12347
+ return;
12348
+ }
12349
+ move(active.id, activeList === null || activeList === void 0 ? void 0 : activeList.id, overList.id);
12350
+ }
12351
+ function handleDragEnd(event) {
12352
+ const {
12353
+ active,
12354
+ over
12355
+ } = event;
12356
+ if (!(active !== null && active !== void 0 && active.id) || !(over !== null && over !== void 0 && over.id)) {
12357
+ return;
12358
+ }
12359
+ const activeList = getContainerById(children, active.id);
12360
+ const overList = getContainerById(children, over.id);
12361
+ if (!(activeList !== null && activeList !== void 0 && activeList.id) || !(overList !== null && overList !== void 0 && overList.id) || activeList.id !== overList.id) {
12362
+ return;
12363
+ }
12364
+ reorder(active.id, over.id, overList.id);
12365
+ }
12366
+ return /*#__PURE__*/React__default.createElement(core.DndContext, Object.assign({
12367
+ collisionDetection: core.closestCenter
12368
+ }, externalProps, {
12369
+ onDragOver: handleDragOver,
12370
+ onDragEnd: handleDragEnd
12371
+ }), children);
12372
+ }
12373
+ Container.displayName = 'SortableContainer';
12374
+
12375
+ function Item$3(props) {
12376
+ const {
12377
+ asChild,
12378
+ children,
12379
+ disabled = false,
12380
+ id
12381
+ } = props;
12382
+ const {
12383
+ attributes,
12384
+ listeners,
12385
+ setNodeRef,
12386
+ transform,
12387
+ transition
12388
+ } = sortable.useSortable({
12389
+ disabled,
12390
+ id
12391
+ });
12392
+ const style = {
12393
+ transform: utilities.CSS.Transform.toString(transform),
12394
+ transition
12395
+ };
12396
+ const onPointerDown = event => {
12397
+ // allow form components, like checkboxes, to be active
12398
+ if (event.target === event.currentTarget) {
12399
+ listeners === null || listeners === void 0 ? void 0 : listeners.onPointerDown(event);
12400
+ }
12401
+ };
12402
+ const elProps = {
12403
+ ...attributes,
12404
+ ...listeners,
12405
+ onPointerDown,
12406
+ ref: setNodeRef,
12407
+ style
12408
+ };
12409
+ if (asChild) {
12410
+ return /*#__PURE__*/React__default.cloneElement(children, elProps);
12411
+ }
12412
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, elProps), children);
12413
+ }
12414
+ Item$3.displayName = 'SortableListItem';
12415
+
12416
+ function List$1(externalProps) {
12417
+ const {
12418
+ children,
12419
+ id,
12420
+ ...props
12421
+ } = externalProps;
12422
+ const {
12423
+ setNodeRef
12424
+ } = core.useDroppable({
12425
+ id
12426
+ });
12427
+ const items = React__default.Children.toArray(children).map(child => child.props);
12428
+ return /*#__PURE__*/React__default.createElement(sortable.SortableContext, {
12429
+ id: id,
12430
+ items: items,
12431
+ strategy: sortable.verticalListSortingStrategy
12432
+ }, /*#__PURE__*/React__default.createElement("div", Object.assign({}, props, {
12433
+ ref: id ? setNodeRef : undefined
12434
+ }), children));
12435
+ }
12436
+ List$1.displayName = 'SortableList';
12437
+
12438
+ const OrderableColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
12439
+ var _column$columnDef$hea;
12440
+ const {
12441
+ canBeReordered,
12442
+ column,
12443
+ isReorderingAllowed,
12444
+ ...attributes
12445
+ } = props;
12446
+ let icon;
12447
+ if (canBeReordered) {
12448
+ icon = /*#__PURE__*/React__default.createElement(Icon, {
12449
+ name: "drag",
12450
+ className: "text-grey-500 hover:text-grey-700 mr-0.5 -ml-2 -mt-px cursor-move"
12451
+ });
12452
+ } else if (isReorderingAllowed) {
12453
+ icon = /*#__PURE__*/React__default.createElement("span", {
12454
+ className: "mr-0.5 inline-flex w-4"
12455
+ });
12456
+ }
12457
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
12458
+ className: "hover:bg-grey-100 aria-pressed:bg-grey-200 flex w-full items-center justify-between gap-x-2 rounded py-1 px-2 aria-pressed:z-10",
12459
+ ref: ref
12460
+ }), /*#__PURE__*/React__default.createElement("span", {
12461
+ className: "pointer-events-none"
12462
+ }, icon, (_column$columnDef$hea = column.columnDef.header) !== null && _column$columnDef$hea !== void 0 ? _column$columnDef$hea : column.columnDef.id), column.getCanHide() ? /*#__PURE__*/React__default.createElement(Checkbox, {
12463
+ checked: column.getIsVisible(),
12464
+ onChange: column.toggleVisibility
12465
+ }) : null);
12466
+ });
12467
+ const isOrderingAllowed = (table, column) => {
12468
+ var _column$columnDef$met;
12469
+ const meta = table.options.meta;
12470
+ if (table.options.enablePinning) {
12471
+ return true;
12472
+ }
12473
+ return meta.enableColumnReordering ? !((_column$columnDef$met = column.columnDef.meta) !== null && _column$columnDef$met !== void 0 && _column$columnDef$met.disableReordering) : false;
12474
+ };
12475
+ const SortableColumnContainer = ({
12476
+ state,
12477
+ moveColumn,
12478
+ reorderColumn,
12479
+ table
12480
+ }) => {
12481
+ var _ref;
12482
+ const meta = table.options.meta;
12483
+ const reorder = (activeId, overId, listId) => {
12484
+ const draggedColumn = state[listId].find(c => c.id === activeId);
12485
+ const targetColumn = state[listId].find(c => c.id === overId);
12486
+ if (draggedColumn && targetColumn) {
12487
+ reorderColumn(draggedColumn.id, targetColumn.id, listId === 'pinned');
12488
+ }
12489
+ };
12490
+ const move = (activeId, oldListId) => {
12491
+ const column = state[oldListId].find(c => c.id === activeId);
12492
+ if (column) {
12493
+ moveColumn(column);
12494
+ }
12495
+ };
12496
+ const isReorderingAllowed = (_ref = meta.enableColumnReordering || table.options.enablePinning) !== null && _ref !== void 0 ? _ref : false;
12497
+ if (!table.options.enablePinning) {
12498
+ return /*#__PURE__*/React__default.createElement(Container, {
12499
+ reorder: reorder,
12500
+ move: move
12501
+ }, /*#__PURE__*/React__default.createElement(List$1, {
12502
+ id: "other",
12503
+ className: "flex min-h-[theme(spacing.8)] flex-col gap-y-px px-2"
12504
+ }, state.other.map(column => {
12505
+ var _column$columnDef$met2;
12506
+ const canBeReordered = isOrderingAllowed(table, column);
12507
+ return /*#__PURE__*/React__default.createElement(Item$3, {
12508
+ key: column.id,
12509
+ disabled: (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.disableReordering,
12510
+ id: column.id,
12511
+ asChild: true
12512
+ }, /*#__PURE__*/React__default.createElement(OrderableColumn, {
12513
+ canBeReordered: canBeReordered,
12514
+ column: column,
12515
+ isReorderingAllowed: isReorderingAllowed,
12516
+ onDoubleClick: event => {
12517
+ event.stopPropagation();
12518
+ move(column.id, 'other');
12519
+ }
12520
+ }));
12521
+ })));
12522
+ }
12523
+ return /*#__PURE__*/React__default.createElement(Container, {
12524
+ reorder: reorder,
12525
+ move: move
12526
+ }, /*#__PURE__*/React__default.createElement("h5", {
12527
+ className: "mx-4"
12528
+ }, "Pinned columns"), /*#__PURE__*/React__default.createElement(List$1, {
12529
+ id: "pinned",
12530
+ className: "flex min-h-[theme(spacing.8)] flex-col gap-y-px px-2"
12531
+ }, state.pinned.length ? state.pinned.map(column => {
12532
+ var _column$columnDef$met3;
12533
+ const canBeReordered = isOrderingAllowed(table, column);
12534
+ return /*#__PURE__*/React__default.createElement(Item$3, {
12535
+ key: column.id,
12536
+ disabled: (_column$columnDef$met3 = column.columnDef.meta) === null || _column$columnDef$met3 === void 0 ? void 0 : _column$columnDef$met3.disableReordering,
12537
+ id: column.id,
12538
+ asChild: true
12539
+ }, /*#__PURE__*/React__default.createElement(OrderableColumn, {
12540
+ canBeReordered: canBeReordered,
12541
+ column: column,
12542
+ isReorderingAllowed: isReorderingAllowed,
12543
+ onDoubleClick: event => {
12544
+ event.stopPropagation();
12545
+ move(column.id, 'pinned');
12546
+ }
12547
+ }));
12548
+ }) : /*#__PURE__*/React__default.createElement("p", {
12549
+ className: "text-grey-500 mb-0 flex h-8 items-center px-2"
12550
+ }, "Drop column here to pin")), /*#__PURE__*/React__default.createElement("h5", {
12551
+ className: "mx-4"
12552
+ }, "Other columns"), /*#__PURE__*/React__default.createElement(List$1, {
12553
+ id: "other",
12554
+ className: "flex min-h-[theme(spacing.8)] flex-col gap-y-px px-2"
12555
+ }, state.other.length ? state.other.map(column => {
12556
+ var _column$columnDef$met4;
12557
+ const canBeReordered = isOrderingAllowed(table, column);
12558
+ return /*#__PURE__*/React__default.createElement(Item$3, {
12559
+ key: column.id,
12560
+ disabled: (_column$columnDef$met4 = column.columnDef.meta) === null || _column$columnDef$met4 === void 0 ? void 0 : _column$columnDef$met4.disableReordering,
12561
+ id: column.id,
12562
+ asChild: true
12563
+ }, /*#__PURE__*/React__default.createElement(OrderableColumn, {
12564
+ canBeReordered: canBeReordered,
12565
+ column: column,
12566
+ isReorderingAllowed: isReorderingAllowed,
12567
+ onDoubleClick: event => {
12568
+ event.stopPropagation();
12569
+ move(column.id, 'other');
12570
+ }
12571
+ }));
12572
+ }) : /*#__PURE__*/React__default.createElement("p", {
12573
+ className: "text-grey-500 mb-0 flex h-8 items-center px-2"
12574
+ }, "Drop column here to unpin")));
12575
+ };
12576
+ const reorder = (draggedColumnId, targetColumnId, list = []) => {
12577
+ const nextColumnOrder = [...list];
12578
+ nextColumnOrder.splice(nextColumnOrder.findIndex(c => c.id === targetColumnId), 0, nextColumnOrder.splice(nextColumnOrder.findIndex(c => c.id === draggedColumnId), 1)[0]);
12579
+ return nextColumnOrder;
12580
+ };
12581
+ const ColumnSettingsButton = ({
12582
+ table
12583
+ }) => {
12584
+ const [query, setQuery] = React__default.useState('');
12585
+ const columns = table.getAllLeafColumns().filter(column => !isInternalColumn(column.id));
12586
+ const [state, setState] = React__default.useState({
12587
+ pinned: columns.filter(column => column.getIsPinned()),
12588
+ other: columns.filter(column => !column.getIsPinned())
12589
+ });
12590
+ const pinColumn = column => {
12591
+ if (state.pinned.find(c => c.id === column.id)) {
12592
+ setState(currentState => ({
12593
+ pinned: currentState.pinned.filter(c => c.id !== column.id),
12594
+ other: [column].concat(...currentState.other)
12595
+ }));
12596
+ } else {
12597
+ setState(currentState => ({
12598
+ pinned: currentState.pinned.concat(column),
12599
+ other: currentState.other.filter(c => c.id !== column.id)
12600
+ }));
12601
+ }
12602
+ };
12603
+ const reorderColumn = (draggedColumnId, targetColumnId, pinned) => {
12604
+ if (pinned) {
12605
+ setState(currentState => ({
12606
+ ...currentState,
12607
+ pinned: reorder(draggedColumnId, targetColumnId, currentState.pinned)
12608
+ }));
12609
+ } else {
12610
+ setState(currentState => ({
12611
+ ...currentState,
12612
+ other: reorder(draggedColumnId, targetColumnId, currentState.other)
12613
+ }));
12614
+ }
12615
+ };
12616
+ // probably a more elegant way to do this without local state but had
12617
+ // a range of issues using the native apis directly
12618
+ React__default.useEffect(() => {
12619
+ const internals = [];
12620
+ if (table.options.enableRowSelection) {
12621
+ internals.push(COLUMN_ID_FOR_SELECTION);
12622
+ }
12623
+ if (table.options.enableExpanding) {
12624
+ internals.push(COLUMN_ID_FOR_EXPANSION);
12625
+ }
12626
+ table.setColumnPinning({
12627
+ left: internals.concat(...state.pinned.map(c => c.id))
12628
+ });
12629
+ table.setColumnOrder(internals.concat([...state.pinned, ...state.other].map(c => c.id)));
12630
+ }, [state]);
12631
+ return /*#__PURE__*/React__default.createElement(IconButton, {
12632
+ "aria-label": "Change column settings",
12633
+ icon: "columns",
12634
+ popover: popoverProps => /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps), /*#__PURE__*/React__default.createElement(Popover.Content, {
12635
+ align: "end"
12636
+ }, /*#__PURE__*/React__default.createElement("div", {
12637
+ className: "flex w-60 flex-col gap-2"
12638
+ }, /*#__PURE__*/React__default.createElement(Input, {
12639
+ onChange: event => setQuery(event.target.value),
12640
+ placeholder: "Search column...",
12641
+ value: query
12642
+ }), /*#__PURE__*/React__default.createElement("div", {
12643
+ className: "-ml-4 -mb-2 max-h-64 w-[calc(100%_+_theme(spacing.8))] overflow-auto"
12644
+ }, query ? columns.filter(column => {
12645
+ var _column$columnDef$hea2;
12646
+ return (_column$columnDef$hea2 = column.columnDef.header) === null || _column$columnDef$hea2 === void 0 ? void 0 : _column$columnDef$hea2.toString().includes(query);
12647
+ }).map(column => /*#__PURE__*/React__default.createElement(OrderableColumn, {
12648
+ key: column.id,
12649
+ canBeReordered: false,
12650
+ column: column,
12651
+ isReorderingAllowed: false
12652
+ })) : /*#__PURE__*/React__default.createElement(SortableColumnContainer, {
12653
+ state: state,
12654
+ moveColumn: pinColumn,
12655
+ reorderColumn: reorderColumn,
12656
+ table: table
12657
+ }))))),
12658
+ tooltip: "Column settings"
12659
+ });
12660
+ };
12661
+
12662
+ const ExpandedRow = ({
12663
+ index,
12664
+ setSize,
12665
+ ...props
12666
+ }) => {
12667
+ const ref = React__default.useRef(null);
12668
+ React__default.useEffect(() => {
12669
+ if (ref.current) {
12670
+ var _ref$current;
12671
+ const height = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect().height;
12672
+ setSize(sizes => {
12673
+ if (height !== sizes[index]) {
12674
+ var _ref$current2;
12675
+ return {
12676
+ ...sizes,
12677
+ [index]: (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.getBoundingClientRect().height
12678
+ };
12679
+ }
12680
+ return sizes;
12681
+ });
12682
+ }
12683
+ }, []);
12684
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({
12685
+ className: "border-grey-300 bg-grey-50 col-span-full border-b p-4"
12686
+ }, props, {
12687
+ ref: ref
12688
+ }));
12689
+ };
12690
+
12691
+ const useSeparatedChildren$1 = initialChildren => {
12692
+ return React__default.useMemo(() => {
12693
+ const columns = [];
12694
+ let toolbar;
12695
+ React__default.Children.toArray(initialChildren).filter(child => !!child) // skip falsey columns
12696
+ .forEach(child => {
12697
+ var _child$type, _child$type2;
12698
+ if (((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) === 'Table2Column') {
12699
+ columns.push(child);
12700
+ } else if (((_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.displayName) === 'Table2Toolbar') {
12701
+ toolbar = child;
12702
+ }
12703
+ });
12704
+ return [columns, toolbar];
12705
+ }, [initialChildren]);
12706
+ };
12707
+
12708
+ const useBoundaryOverflowDetection = (ref, dependencies = []) => {
12709
+ const [boundaryIndex, setBoundaryIndex] = React__default.useState();
12710
+ React__default.useEffect(() => {
12711
+ if (ref.current) {
12712
+ const boundaryChildIndex = getIndexOfFirstChildOverflowingParent(ref.current);
12713
+ setBoundaryIndex(boundaryChildIndex);
12714
+ }
12715
+ }, [ref, ...dependencies]);
12716
+ return boundaryIndex;
12717
+ };
12718
+
12719
+ const BUTTON_CLASSES = /*#__PURE__*/cn( /*#__PURE__*/getButtonClasses(), 'hover:bg-white/[0.08] disabled:opacity-50 disabled:cursor-not-allowed flex-shrink-0 rounded px-2');
12720
+ function unwrapActionProperty(property, rowsData) {
12721
+ return typeof property === 'function' ? property(rowsData) : property;
12722
+ }
12723
+ function createActionButton(actions, rowsData, onReset) {
12724
+ return actions.map((action, index) => {
12725
+ const button = /*#__PURE__*/React__default.createElement("button", {
12726
+ className: BUTTON_CLASSES,
12727
+ disabled: unwrapActionProperty(action.disabled, rowsData),
12728
+ onClick: action.onClick ? () => action.onClick ? action.onClick(rowsData, onReset) : undefined : undefined
12729
+ }, action.icon ? /*#__PURE__*/React__default.createElement(Icon, {
12730
+ name: unwrapActionProperty(action.icon, rowsData)
12731
+ }) : null, unwrapActionProperty(action.text, rowsData));
12732
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
12733
+ key: index
12734
+ }, typeof action.dialog === 'function' ? action.dialog(rowsData, onReset)({
12735
+ trigger: button
12736
+ }) : button);
12737
+ });
12738
+ }
12739
+ function BatchActionsMenu({
12740
+ actionsForTable = [],
12741
+ summary,
12742
+ table,
12743
+ ...props
12744
+ }) {
12745
+ const className = cn('bg-blue-900 yt-shadow flex w-96 flex-col gap-2 divide-y divide-white/25 rounded p-2 text-white', props.className);
12746
+ const ref = React__default.useRef(null);
12747
+ const boundaryIndex = useBoundaryOverflowDetection(ref, actionsForTable);
12748
+ const rows = table.getSelectedRowModel().rows;
12749
+ const rowsData = rows.map(row => row.original);
12750
+ const handleReset = () => table.toggleAllRowsSelected(false);
12751
+ const isVisible = action => typeof action.visible !== 'undefined' ? typeof action.visible === 'function' ? action.visible(rowsData) : action.visible : true;
12752
+ const visibleActions = actionsForTable.filter(isVisible);
12753
+ let content;
12754
+ if (boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < actionsForTable.length) {
12755
+ const actions = visibleActions.slice(0, boundaryIndex);
12756
+ const moreActions = visibleActions.slice(boundaryIndex);
12757
+ content = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, createActionButton(actions, rowsData, handleReset), moreActions.length ? /*#__PURE__*/React__default.createElement(Menu$1, null, /*#__PURE__*/React__default.createElement(Menu$1.Trigger, null, /*#__PURE__*/React__default.createElement("button", {
12758
+ className: cn(BUTTON_CLASSES, 'ml-auto w-8')
12759
+ }, /*#__PURE__*/React__default.createElement(Icon, {
12760
+ name: "more",
12761
+ className: "m-0 p-0"
12762
+ }))), /*#__PURE__*/React__default.createElement(Menu$1.Content, null, moreActions.map((action, index) => /*#__PURE__*/React__default.createElement(Menu$1.Item, {
12763
+ key: index,
12764
+ dialog: action.dialog ? action.dialog(rowsData, handleReset) : undefined,
12765
+ disabled: unwrapActionProperty(action.disabled, rowsData),
12766
+ icon: unwrapActionProperty(action.icon, rowsData),
12767
+ onClick: action.onClick ? () => action.onClick ? action.onClick(rowsData, handleReset) : undefined : undefined
12768
+ }, unwrapActionProperty(action.text, rowsData))))) : null);
12769
+ } else {
12770
+ content = createActionButton(visibleActions, rowsData, handleReset);
12771
+ }
12772
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, props, {
12773
+ className: className,
12774
+ tabIndex: 0
12775
+ }), /*#__PURE__*/React__default.createElement("div", {
12776
+ className: "flex items-center justify-between gap-2 px-2"
12777
+ }, rows.length, " items selected ", summary ? ` - ${summary(rowsData)}` : undefined, /*#__PURE__*/React__default.createElement(Tooltip, {
12778
+ title: "Reset selected",
12779
+ placement: "top"
12780
+ }, /*#__PURE__*/React__default.createElement("button", {
12781
+ "aria-label": "Reset selected",
12782
+ className: "rounded hover:bg-white/[0.08]",
12783
+ onClick: handleReset
12784
+ }, /*#__PURE__*/React__default.createElement(Icon, {
12785
+ name: "close"
12786
+ })))), /*#__PURE__*/React__default.createElement("div", {
12787
+ className: "flex w-full gap-px overflow-hidden px-1 pt-2",
12788
+ ref: ref
12789
+ }, content));
12790
+ }
12791
+
12792
+ const HOVER_THRESHOLD_MS = 50;
12793
+ const Row$1 = ({
12794
+ row,
12795
+ rowIndex,
12796
+ table,
12797
+ ...props
12798
+ }) => {
12799
+ const meta = table.options.meta;
12800
+ const isActiveRow = meta.activeRowIndex === rowIndex;
12801
+ const isDragging = meta.dragging[row.id];
12802
+ const [validationErrors, setValidationErrors] = React__default.useState(null);
12803
+ const [rowMoveReason, setRowMoveReason] = React__default.useState({});
12804
+ // This effect aims to focus the first focussable cell when edit mode is turned on.
12805
+ React__default.useEffect(() => {
12806
+ var _meta$tableRef$curren;
12807
+ const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
12808
+ // If the foucs is outside the table i.e., table action popups, search etc., then don't focus the first cell.
12809
+ if (meta.editMode.isEditing && isActiveRow && isFocusInsideTable) {
12810
+ meta.editMode.moveToFirstColumn(meta.focussableColumnIndexes);
12811
+ }
12812
+ // We are intentionally not adding activeRow to the depency variable so that everytime active row is changed,
12813
+ // first focussable cell is not focussed.
12814
+ }, [meta.editMode.isEditing, meta.focussableColumnIndexes]);
12815
+ const handleSetValidationErrors = errors => {
12816
+ if (errors !== null) {
12817
+ meta.setShouldDisableTableActions(true);
12818
+ }
12819
+ setValidationErrors(errors);
12820
+ };
12821
+ const hoverTimerRef = React__default.useRef();
12822
+ const handleEnter = () => {
12823
+ hoverTimerRef.current = setTimeout(() => meta.setHoveredRowIndex(rowIndex), HOVER_THRESHOLD_MS);
12824
+ };
12825
+ const handleLeave = () => {
12826
+ clearTimeout(hoverTimerRef.current);
12827
+ hoverTimerRef.current = undefined;
12828
+ meta.setHoveredRowIndex(undefined);
12829
+ };
12830
+ return /*#__PURE__*/React__default.createElement(RowProvider, {
12831
+ validationErrors: validationErrors,
12832
+ setValidationErrors: handleSetValidationErrors,
12833
+ rowMoveReason: rowMoveReason,
12834
+ setRowMoveReason: setRowMoveReason
12835
+ }, /*#__PURE__*/React__default.createElement("div", Object.assign({}, props, {
12836
+ role: "row",
12837
+ draggable: true,
12838
+ "aria-current": isActiveRow ? 'true' : undefined,
12839
+ "aria-grabbed": isDragging ? 'true' : undefined,
12840
+ onMouseEnter: handleEnter,
12841
+ onMouseLeave: handleLeave
12842
+ })));
12843
+ };
12844
+
12845
+ const Column$1 = ({
12846
+ allColumns,
12847
+ column,
12848
+ index,
12849
+ table,
12850
+ ...props
12851
+ }) => {
12852
+ const handleChange = id => {
12853
+ table.setColumnFilters(currentColumnFilters => {
12854
+ const nextColumnFilters = [...currentColumnFilters];
12855
+ nextColumnFilters[index].id = id;
12856
+ nextColumnFilters[index].value = {};
12857
+ return nextColumnFilters;
12858
+ });
12859
+ };
12860
+ return /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, props, {
12861
+ autoFocus: true,
12862
+ onChange: handleChange,
12863
+ value: column.id
12864
+ }), allColumns.map(c => /*#__PURE__*/React__default.createElement(Select2.Option, {
12865
+ key: c.id,
12866
+ disabled: !c.getCanFilter() || c.id !== column.id && !!table.getState().columnFilters.find(f => f.id === c.id),
12867
+ value: c.id
12868
+ }, String(c.columnDef.header))));
12869
+ };
12870
+
12871
+ const Comparator = ({
12872
+ column,
12873
+ comparator,
12874
+ validComparators,
12875
+ ...props
12876
+ }) => {
12877
+ const handleChange = comparator => {
12878
+ column.setFilterValue(currentFilterValue => ({
12879
+ comparator,
12880
+ value: comparator === Table2FilterComparator.IsBetween ? [] : currentFilterValue.value
12881
+ }));
12882
+ };
12883
+ React__default.useEffect(() => {
12884
+ if (comparator === undefined) {
12885
+ const initialComparator = validComparators[0];
12886
+ column.setFilterValue(currentFilterValue => ({
12887
+ comparator: initialComparator,
12888
+ value: initialComparator === Table2FilterComparator.IsBetween && !Array.isArray(currentFilterValue.value) ? [] : currentFilterValue.value
12889
+ }));
12890
+ }
12891
+ }, []);
12892
+ return /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, props, {
12893
+ onChange: handleChange,
12894
+ value: comparator
12895
+ }), validComparators.map(comp => /*#__PURE__*/React__default.createElement(Select2.Option, {
12896
+ key: comp,
12897
+ value: comp
12898
+ }, getComparatorText(comp))));
12899
+ };
12900
+ const getComparatorText = comparator => {
12901
+ switch (comparator) {
12902
+ case Table2FilterComparator.Contains:
12903
+ return 'Contains';
12904
+ case Table2FilterComparator.DoesNotContain:
12905
+ return 'Does not contain';
12906
+ case Table2FilterComparator.IsEqualTo:
12907
+ return 'Is';
12908
+ case Table2FilterComparator.IsNotEqualTo:
12909
+ return 'Is not';
12910
+ case Table2FilterComparator.IsGreaterThan:
12911
+ return 'Is greater than';
12912
+ case Table2FilterComparator.IsLessThan:
12913
+ return 'Is less than';
12914
+ case Table2FilterComparator.IsBetween:
12915
+ return 'Is between';
12916
+ case Table2FilterComparator.IsOneOf:
12917
+ return 'Is one of';
12918
+ case Table2FilterComparator.IsNoneOf:
12919
+ return 'Is none of';
12920
+ case Table2FilterComparator.IsAllOf:
12921
+ return 'Is all of';
12922
+ }
12923
+ };
12924
+
12925
+ const InferredControl = ({
12926
+ column,
12927
+ comparator,
12928
+ value
12929
+ }) => {
12930
+ var _column$columnDef$met2, _column$columnDef$met3;
12931
+ const ariaLabel = column.columnDef.header;
12932
+ if (comparator === Table2FilterComparator.IsBetween) {
12933
+ var _column$columnDef$met;
12934
+ const fromValue = Array.isArray(value) ? value[0] : undefined;
12935
+ const toValue = Array.isArray(value) ? value[1] : undefined;
12936
+ if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.dataType) === 'datetime') {
12937
+ return /*#__PURE__*/React__default.createElement("div", {
12938
+ className: "flex flex-grow items-center gap-2"
12939
+ }, /*#__PURE__*/React__default.createElement(Datepicker, {
12940
+ "aria-label": ariaLabel,
12941
+ onChange: event => column.setFilterValue(currentValue => ({
12942
+ ...currentValue,
12943
+ value: [event.detail, toValue]
12944
+ })),
12945
+ value: fromValue
12946
+ }), /*#__PURE__*/React__default.createElement(Datepicker, {
12947
+ "aria-label": ariaLabel,
12948
+ onChange: event => column.setFilterValue(currentValue => ({
12949
+ ...currentValue,
12950
+ value: [fromValue, event.detail]
12951
+ })),
12952
+ value: toValue
12953
+ }));
12954
+ }
12955
+ return /*#__PURE__*/React__default.createElement("div", {
12956
+ className: "flex flex-grow items-center gap-2"
12957
+ }, /*#__PURE__*/React__default.createElement(Input, {
12958
+ "aria-label": ariaLabel,
12959
+ className: "flex-grow",
12960
+ placeholder: "from",
12961
+ onChange: event => {
12962
+ const value = parseInt(event.target.value);
12963
+ column.setFilterValue(currentValue => ({
12964
+ ...currentValue,
12965
+ value: [isNaN(value) ? undefined : value, toValue]
12966
+ }));
12967
+ },
12968
+ value: fromValue !== null && fromValue !== void 0 ? fromValue : ''
12969
+ }), /*#__PURE__*/React__default.createElement(Input, {
12970
+ className: "flex-grow",
12971
+ placeholder: "to",
12972
+ onChange: event => {
12973
+ const value = parseInt(event.target.value);
12974
+ column.setFilterValue(currentValue => ({
12975
+ ...currentValue,
12976
+ value: [fromValue, isNaN(value) ? undefined : value]
12977
+ }));
12978
+ },
12979
+ value: toValue !== null && toValue !== void 0 ? toValue : ''
12980
+ }));
12981
+ }
12982
+ if (((_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.dataType) === 'datetime') {
12983
+ return /*#__PURE__*/React__default.createElement(Datepicker, {
12984
+ "aria-label": ariaLabel,
12985
+ onChange: event => column.setFilterValue(currentValue => ({
12986
+ ...currentValue,
12987
+ value: event.detail
12988
+ })),
12989
+ value: value
12990
+ });
12991
+ } else if (((_column$columnDef$met3 = column.columnDef.meta) === null || _column$columnDef$met3 === void 0 ? void 0 : _column$columnDef$met3.dataType) === 'boolean') {
12992
+ return /*#__PURE__*/React__default.createElement(Switch, {
12993
+ "aria-label": ariaLabel,
12994
+ onChange: checked => column.setFilterValue(currentValue => ({
12995
+ ...currentValue,
12996
+ value: checked
12997
+ })),
12998
+ checked: value
12999
+ });
13000
+ }
13001
+ return /*#__PURE__*/React__default.createElement(Input, {
13002
+ "aria-label": ariaLabel,
13003
+ className: "flex-grow",
13004
+ onChange: event => column.setFilterValue(currentValue => ({
13005
+ ...currentValue,
13006
+ value: event.target.value
13007
+ })),
13008
+ required: true,
13009
+ value: value !== null && value !== void 0 ? value : ''
13010
+ });
13011
+ };
13012
+
13013
+ const ColumnFilter = props => {
13014
+ var _column$columnDef$hea, _column$columnDef$met, _column$columnDef$met2, _control;
13015
+ const {
13016
+ allColumns,
13017
+ column,
13018
+ index,
13019
+ table
13020
+ } = props;
13021
+ const {
13022
+ comparator,
13023
+ value
13024
+ } = column.getFilterValue();
13025
+ const ariaLabel = String((_column$columnDef$hea = column.columnDef.header) !== null && _column$columnDef$hea !== void 0 ? _column$columnDef$hea : '');
13026
+ const ref = React__default.useRef(null);
13027
+ let control;
13028
+ const controlType = (_column$columnDef$met = (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.control) !== null && _column$columnDef$met !== void 0 ? _column$columnDef$met : 'input';
13029
+ if (typeof controlType === 'function') {
13030
+ control = controlType({
13031
+ onBlur: () => Promise.resolve(),
13032
+ onFocus: () => Promise.resolve(),
13033
+ ref,
13034
+ setValue: value => column.setFilterValue(currentValue => ({
13035
+ ...currentValue,
13036
+ value
13037
+ })),
13038
+ value,
13039
+ disabled: false,
13040
+ readOnly: false
13041
+ });
13042
+ } else if (controlType === 'input') {
13043
+ control = /*#__PURE__*/React__default.createElement(Input, {
13044
+ "aria-label": ariaLabel,
13045
+ onChange: event => column.setFilterValue(currentValue => ({
13046
+ ...currentValue,
13047
+ value: event.target.value
13048
+ })),
13049
+ value: String(value !== null && value !== void 0 ? value : '')
13050
+ });
13051
+ } else if (controlType === 'datepicker') {
13052
+ control = /*#__PURE__*/React__default.createElement(Datepicker, {
13053
+ "aria-label": ariaLabel,
13054
+ onChange: event => column.setFilterValue(currentValue => ({
13055
+ ...currentValue,
13056
+ value: event.detail
13057
+ })),
13058
+ value: value
13059
+ });
13060
+ } else if (controlType === 'switch') {
13061
+ control = /*#__PURE__*/React__default.createElement(Switch, {
13062
+ "aria-label": ariaLabel,
13063
+ checked: Boolean(value),
13064
+ onChange: checked => column.setFilterValue(currentValue => ({
13065
+ ...currentValue,
13066
+ value: checked
13067
+ }))
13068
+ });
13069
+ }
13070
+ const handleRemove = () => column.setFilterValue(undefined);
13071
+ const comparators = guessComparatorsBasedOnControl(controlType, control);
13072
+ return /*#__PURE__*/React__default.createElement("div", {
13073
+ className: "mb-2 flex gap-2"
13074
+ }, /*#__PURE__*/React__default.createElement("div", {
13075
+ className: "flex w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
13076
+ }, index === 0 ? 'Where' : 'And'), /*#__PURE__*/React__default.createElement(Column$1, {
13077
+ className: "!w-32 flex-shrink-0",
13078
+ allColumns: allColumns,
13079
+ column: column,
13080
+ index: index,
13081
+ table: table
13082
+ }), /*#__PURE__*/React__default.createElement(Comparator, {
13083
+ className: "!w-32 flex-shrink-0",
13084
+ column: column,
13085
+ comparator: comparator,
13086
+ validComparators: comparators
13087
+ }), comparator !== undefined ? /*#__PURE__*/React__default.createElement("div", {
13088
+ className: "flex flex-grow items-center"
13089
+ }, (_control = control) !== null && _control !== void 0 ? _control : /*#__PURE__*/React__default.createElement(InferredControl, {
13090
+ column: column,
13091
+ comparator: comparator,
13092
+ value: value
13093
+ })) : null, /*#__PURE__*/React__default.createElement(IconButton, {
13094
+ appearance: "discrete",
13095
+ icon: "close",
13096
+ onClick: handleRemove
13097
+ }));
13098
+ };
13099
+ const guessComparatorsBasedOnControl = (control, instance) => {
13100
+ if ( /*#__PURE__*/React__default.isValidElement(instance)) {
13101
+ const {
13102
+ props,
13103
+ type
13104
+ } = instance;
13105
+ if (type.displayName === 'Select2') {
13106
+ if (props.multiple) {
13107
+ return [Table2FilterComparator.IsOneOf, Table2FilterComparator.IsNoneOf, Table2FilterComparator.IsAllOf];
13108
+ }
13109
+ return [Table2FilterComparator.IsEqualTo, Table2FilterComparator.IsNotEqualTo];
13110
+ }
13111
+ }
13112
+ switch (control) {
13113
+ case 'datepicker':
13114
+ return [Table2FilterComparator.IsEqualTo, Table2FilterComparator.IsNotEqualTo, Table2FilterComparator.IsGreaterThan, Table2FilterComparator.IsLessThan, Table2FilterComparator.IsBetween];
13115
+ case 'switch':
13116
+ return [Table2FilterComparator.IsEqualTo];
13117
+ default:
13118
+ return [Table2FilterComparator.Contains, Table2FilterComparator.DoesNotContain, Table2FilterComparator.IsEqualTo, Table2FilterComparator.IsNotEqualTo, Table2FilterComparator.IsGreaterThan, Table2FilterComparator.IsLessThan, Table2FilterComparator.IsBetween];
13119
+ }
13120
+ };
13121
+
13122
+ const useGlobalKeyboardShortcut = handler => {
13123
+ React__default.useEffect(() => {
13124
+ document.addEventListener('keydown', handler);
13125
+ return () => {
13126
+ document.removeEventListener('keydown', handler);
13127
+ };
13128
+ }, [handler]);
13129
+ };
13130
+
13131
+ const FiltersButton = ({
13132
+ length,
13133
+ table
13134
+ }) => {
13135
+ const ref = React__default.useRef(null);
13136
+ const allColumns = table.getAllLeafColumns().filter(column => !isInternalColumn(column.id));
13137
+ const {
13138
+ shouldDisableTableActions
13139
+ } = table.options.meta;
13140
+ const columnFilters = table.getState().columnFilters;
13141
+ const filteredColumns = columnFilters.reduce((columns, columnFilter) => {
13142
+ const column = allColumns.find(c => c.id === columnFilter.id);
13143
+ if (column) {
13144
+ return [...columns, column];
13145
+ }
13146
+ return columns;
13147
+ }, []);
13148
+ const handleAdd = () => {
13149
+ const firstFilterableColumn = allColumns.find(c => c.getCanFilter() && !columnFilters.find(f => f.id === c.id));
13150
+ if (firstFilterableColumn) {
13151
+ firstFilterableColumn.setFilterValue({
13152
+ comparator: undefined,
13153
+ value: undefined
13154
+ });
13155
+ }
13156
+ };
13157
+ const handleReset = () => {
13158
+ table.resetColumnFilters();
13159
+ };
13160
+ useGlobalKeyboardShortcut(event => {
13161
+ if (event.key === 'f' && (event.ctrlKey || event.metaKey) && event.shiftKey) {
13162
+ var _ref$current;
13163
+ event.preventDefault();
13164
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.click();
13165
+ }
13166
+ });
13167
+ return /*#__PURE__*/React__default.createElement(Button$1, {
13168
+ appearance: columnFilters.length ? 'primary' : 'default',
13169
+ className: cn({
13170
+ '!wcag-blue-100': columnFilters.length
13171
+ }),
13172
+ disabled: shouldDisableTableActions,
13173
+ popover: popoverProps => /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement("div", {
13174
+ className: "flex w-[40rem] flex-col gap-4"
13175
+ }, /*#__PURE__*/React__default.createElement("div", {
13176
+ className: "flex w-full items-center gap-2"
13177
+ }, /*#__PURE__*/React__default.createElement("h4", {
13178
+ className: "mb-0 inline-flex"
13179
+ }, "Filter"), /*#__PURE__*/React__default.createElement("p", {
13180
+ className: "text-grey-700 mb-0 mr-auto mt-px inline-flex"
13181
+ }, "Viewing ", table.getFilteredRowModel().rows.length, " of ", length)), /*#__PURE__*/React__default.createElement("div", {
13182
+ className: "flex flex-col gap-2"
13183
+ }, filteredColumns.map((column, index) => /*#__PURE__*/React__default.createElement(ColumnFilter, {
13184
+ key: `${column.id}_${index}`,
13185
+ allColumns: allColumns,
13186
+ index: index,
13187
+ column: column,
13188
+ table: table
13189
+ }))), /*#__PURE__*/React__default.createElement(Group, {
13190
+ className: "justify-between"
13191
+ }, /*#__PURE__*/React__default.createElement(Button$1, {
13192
+ appearance: "discrete",
13193
+ onClick: handleAdd
13194
+ }, "+ Add filter"), columnFilters.length ? /*#__PURE__*/React__default.createElement(Button$1, {
13195
+ onClick: handleReset
13196
+ }, "Clear all filters") : null)))),
13197
+ ref: ref,
13198
+ tooltip: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, columnFilters.length ? 'Change filters' : 'Apply filters', /*#__PURE__*/React__default.createElement(Shortcut$1, {
13199
+ className: "ml-2",
13200
+ keys: ['Ctrl', 'Shift', 'F']
13201
+ }))
13202
+ }, /*#__PURE__*/React__default.createElement(Icon, {
13203
+ name: columnFilters.length ? 'filter-solid' : 'filter'
13204
+ }), columnFilters.length ? `Filters (${columnFilters.length})` : 'Filters');
13205
+ };
13206
+
13207
+ const Search$2 = props => {
13208
+ const {
13209
+ value,
13210
+ ...attributes
13211
+ } = props;
13212
+ const ref = React__default.useRef(null);
13213
+ const handleKeyDown = event => {
13214
+ if (event.key === 'Escape') {
13215
+ var _props$onSearch;
13216
+ (_props$onSearch = props.onSearch) === null || _props$onSearch === void 0 ? void 0 : _props$onSearch.call(props, '');
13217
+ }
13218
+ };
13219
+ // gets called when the "clear" button is clicked
13220
+ const handleInput = event => {
13221
+ if (props.onInput) {
13222
+ props.onInput(event);
13223
+ }
13224
+ if (!event.isDefaultPrevented() && !event.currentTarget.value) {
13225
+ var _props$onSearch2;
13226
+ (_props$onSearch2 = props.onSearch) === null || _props$onSearch2 === void 0 ? void 0 : _props$onSearch2.call(props, '');
13227
+ }
13228
+ };
13229
+ const handleBlur = event => {
13230
+ var _props$onSearch3;
13231
+ const value = event.target.value;
13232
+ (_props$onSearch3 = props.onSearch) === null || _props$onSearch3 === void 0 ? void 0 : _props$onSearch3.call(props, value);
13233
+ };
13234
+ useGlobalKeyboardShortcut(event => {
13235
+ if (event.key === 'f' && (event.ctrlKey || event.metaKey)) {
13236
+ if (document.activeElement !== ref.current) {
13237
+ var _ref$current;
13238
+ event.preventDefault();
13239
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
13240
+ }
13241
+ }
13242
+ });
13243
+ const className = cn('w-48', {
13244
+ '!wcag-blue-100': !!value
13245
+ });
13246
+ return /*#__PURE__*/React__default.createElement(SearchInput, Object.assign({}, attributes, {
13247
+ className: className,
13248
+ onBlur: handleBlur,
13249
+ onInput: handleInput,
13250
+ onKeyDown: handleKeyDown,
13251
+ ref: ref
13252
+ }));
13253
+ };
13254
+
13255
+ const ShortcutsGuideButton = ({
13256
+ table
13257
+ }) => {
13258
+ const meta = table.options.meta;
13259
+ const {
13260
+ texts: {
13261
+ table2: tableTexts
13262
+ }
13263
+ } = useLocalization();
13264
+ const shortcuts = [];
13265
+ if (table.options.enableGlobalFilter) {
13266
+ shortcuts.push({
13267
+ feature: tableTexts.shortcuts.search,
13268
+ keys: ['Ctrl', 'F']
13269
+ });
13270
+ }
13271
+ if (table.options.enableColumnFilters) {
13272
+ shortcuts.push({
13273
+ feature: tableTexts.shortcuts.filter,
13274
+ keys: ['Ctrl', 'Shift', 'F']
13275
+ });
13276
+ }
13277
+ shortcuts.push({
13278
+ feature: tableTexts.shortcuts.previousRow,
13279
+ keys: ['Up']
13280
+ });
13281
+ shortcuts.push({
13282
+ feature: tableTexts.shortcuts.nextRow,
13283
+ keys: ['Down']
13284
+ });
13285
+ if (meta.editMode.enableEditMode) {
13286
+ shortcuts.push({
13287
+ feature: tableTexts.shortcuts.editCell,
13288
+ keys: ['Enter']
13289
+ });
13290
+ shortcuts.push({
13291
+ feature: tableTexts.shortcuts.previousColumn,
13292
+ keys: ['Arrow-Left']
13293
+ });
13294
+ shortcuts.push({
13295
+ feature: tableTexts.shortcuts.nextColumn,
13296
+ keys: ['Arrow-Right']
13297
+ });
13298
+ } else if (meta.onRowClick) {
13299
+ shortcuts.push({
13300
+ feature: tableTexts.shortcuts.rowClick,
13301
+ keys: ['Enter']
13302
+ });
13303
+ }
13304
+ if (table.options.enableRowSelection) {
13305
+ shortcuts.push({
13306
+ feature: tableTexts.shortcuts.selectRow,
13307
+ keys: ['Space']
13308
+ });
13309
+ shortcuts.push({
13310
+ feature: tableTexts.shortcuts.selectAllRows,
13311
+ keys: ['Ctrl', 'A']
13312
+ });
13313
+ }
13314
+ if (table.options.enableExpanding) {
13315
+ shortcuts.push({
13316
+ feature: tableTexts.shortcuts.expandRow,
13317
+ keys: ['Ctrl', 'Right']
13318
+ });
13319
+ shortcuts.push({
13320
+ feature: tableTexts.shortcuts.collapseRow,
13321
+ keys: ['Ctrl', 'Left']
13322
+ });
13323
+ }
13324
+ return /*#__PURE__*/React__default.createElement(IconButton, {
13325
+ "aria-label": "View keyboard shortcuts",
13326
+ icon: "shortcuts",
13327
+ popover: popoverProps => /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps), /*#__PURE__*/React__default.createElement(Popover.Content, {
13328
+ align: "end"
13329
+ }, /*#__PURE__*/React__default.createElement("div", {
13330
+ className: "flex flex-col gap-y-1"
13331
+ }, shortcuts.map(shortcut => /*#__PURE__*/React__default.createElement("span", {
13332
+ className: "flex items-center justify-between gap-x-8",
13333
+ key: shortcut.feature
13334
+ }, /*#__PURE__*/React__default.createElement("span", null, shortcut.feature), /*#__PURE__*/React__default.createElement(Shortcut$1, {
13335
+ keys: shortcut.keys
13336
+ })))))),
13337
+ rounded: true
13338
+ });
13339
+ };
13340
+
13341
+ const EditModeButton = /*#__PURE__*/React__default.forwardRef(function EditModeButton(props, ref) {
13342
+ const {
13343
+ table,
13344
+ tableRef
13345
+ } = props;
13346
+ const internalRef = useMergedRef(ref);
13347
+ const meta = table.options.meta;
13348
+ const {
13349
+ isEditing
13350
+ } = meta.editMode;
13351
+ const showWarning = React__default.useCallback(event => {
13352
+ if (isEditing) {
13353
+ event.returnValue = true;
13354
+ return true;
13355
+ }
13356
+ return false;
13357
+ }, [isEditing]);
13358
+ useGlobalKeyboardShortcut(event => {
13359
+ if (event.key === 'e' && (event.ctrlKey || event.metaKey)) {
13360
+ var _internalRef$current;
13361
+ event.preventDefault();
13362
+ (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.click();
13363
+ }
13364
+ });
13365
+ React__default.useEffect(() => {
13366
+ window.addEventListener('beforeunload', showWarning);
13367
+ return () => window.removeEventListener('beforeunload', showWarning);
13368
+ }, [showWarning]);
13369
+ const handleClick = () => {
13370
+ var _tableRef$current;
13371
+ meta.editMode.toggleEditing();
13372
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.focus();
13373
+ };
13374
+ return /*#__PURE__*/React__default.createElement(Button$1, {
13375
+ onClick: handleClick,
13376
+ className: cn({
13377
+ '!wcag-blue-100': meta.editMode.isEditing
13378
+ }),
13379
+ ref: internalRef,
13380
+ tooltip: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "Edit", /*#__PURE__*/React__default.createElement(Shortcut$1, {
13381
+ className: "ml-2",
13382
+ keys: ['Ctrl', 'E']
13383
+ }))
13384
+ }, /*#__PURE__*/React__default.createElement(Icon, {
13385
+ name: "edit"
13386
+ }), "Edit");
13387
+ });
13388
+
13389
+ function Column$2(_) {
13390
+ return null;
13391
+ }
13392
+ Column$2.displayName = 'Table2Column';
13393
+ function Toolbar(props) {
13394
+ const className = cn('flex-grow', props.className);
13395
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, props, {
13396
+ className: className
13397
+ }));
13398
+ }
13399
+ Toolbar.displayName = 'Table2Toolbar';
13400
+ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref) {
13401
+ // dom
13402
+ const {
13403
+ emptyState: EmptyState,
13404
+ expandedRowRenderer,
13405
+ length = props.data.length,
13406
+ loadMore,
13407
+ onRowClick,
13408
+ _experimentalActionsForTable,
13409
+ _experimentalActionsForTableSummary
13410
+ } = props;
13411
+ const tableRef = useMergedRef(ref);
13412
+ const timeoutIdRef = React__default.useRef();
13413
+ // react-table
13414
+ const [columns, toolbar] = useSeparatedChildren$1(props.children);
13415
+ const {
13416
+ rows,
13417
+ table,
13418
+ footers
13419
+ } = useTable$1(columns, props, tableRef);
13420
+ const meta = table.options.meta;
13421
+ const {
13422
+ columnVisibility,
13423
+ columnOrder,
13424
+ globalFilter
13425
+ } = table.getState();
13426
+ // If column visibility or order changes then we turn off the edit mode so that control indexes gets computed
13427
+ // when user turns on the editing mode again. This is a temporary solution to make sure the keyboard navigation
13428
+ // still keeps working on changes in column visibility, order, or both
13429
+ React__default.useEffect(() => {
13430
+ meta.resetFocussableColumnIndexes();
13431
+ }, [columnVisibility, columnOrder]);
13432
+ React__default.useEffect(() => {
13433
+ // Whenever edit mode is turned off we reset the focussableColumnIndexes ref to an empty array so that
13434
+ // we don't have stale values, in case column visibility or ordering changes
13435
+ if (!meta.editMode.isEditing) {
13436
+ meta.resetFocussableColumnIndexes();
13437
+ }
13438
+ }, [meta.editMode.isEditing]);
13439
+ React__default.useEffect(() => {
13440
+ return () => clearTimeout(timeoutIdRef.current);
13441
+ }, []);
13442
+ // virtualiser
13443
+ const {
13444
+ virtualiser,
13445
+ virtualiserOffsets,
13446
+ setExpandedRowSizes
13447
+ } = useVirtualiser({
13448
+ rows,
13449
+ table
13450
+ }, tableRef);
13451
+ // css grid
13452
+ const gridTemplateColumns = useGridTemplate(table);
13453
+ // handlers
13454
+ const editButtonRef = React__default.useRef(null);
13455
+ // support grid like keyboard navigation between cells
13456
+ const handleKeyDown = event => {
13457
+ if (document.activeElement === tableRef.current) {
13458
+ if (event.key === 'ArrowUp') {
13459
+ event.preventDefault();
13460
+ if (event.ctrlKey || event.metaKey) {
13461
+ meta.setActiveRowIndex(0);
13462
+ virtualiser.scrollToOffset(0);
13463
+ } else {
13464
+ meta.moveToPreviousRow(rows, nextIndex => virtualiser.scrollToIndex(nextIndex - 1));
13465
+ }
13466
+ return;
13467
+ } else if (event.key === 'ArrowDown') {
13468
+ event.preventDefault();
13469
+ if (event.ctrlKey || event.metaKey) {
13470
+ meta.setActiveRowIndex(rows.length - 1);
13471
+ virtualiser.scrollToOffset(virtualiser.totalSize + 1);
13472
+ } else {
13473
+ meta.moveToNextRow(rows, nextIndex => virtualiser.scrollToIndex(nextIndex + 2));
13474
+ }
13475
+ return;
13476
+ }
13477
+ const canToggleRowExpansion = table.options.enableExpanding;
13478
+ if (event.key === 'ArrowLeft') {
13479
+ event.preventDefault();
13480
+ if (event.ctrlKey || event.metaKey) {
13481
+ if (canToggleRowExpansion) {
13482
+ var _rows$meta$activeRowI;
13483
+ (_rows$meta$activeRowI = rows[meta.activeRowIndex]) === null || _rows$meta$activeRowI === void 0 ? void 0 : _rows$meta$activeRowI.toggleExpanded(false);
13484
+ }
13485
+ }
13486
+ return;
13487
+ }
13488
+ if (event.key === 'ArrowRight') {
13489
+ event.preventDefault();
13490
+ if (event.ctrlKey || event.metaKey) {
13491
+ if (canToggleRowExpansion) {
13492
+ var _rows$meta$activeRowI2;
13493
+ (_rows$meta$activeRowI2 = rows[meta === null || meta === void 0 ? void 0 : meta.activeRowIndex]) === null || _rows$meta$activeRowI2 === void 0 ? void 0 : _rows$meta$activeRowI2.toggleExpanded(true);
13494
+ }
13495
+ }
13496
+ return;
13497
+ }
13498
+ if (event.key === 'Enter') {
13499
+ event.preventDefault();
13500
+ if (onRowClick) {
13501
+ onRowClick(rows[meta === null || meta === void 0 ? void 0 : meta.activeRowIndex].original);
13502
+ }
13503
+ return;
13504
+ }
13505
+ if (event.key === ' ') {
13506
+ event.preventDefault();
13507
+ if (table.options.enableRowSelection) {
13508
+ var _rows$meta$activeRowI3;
13509
+ (_rows$meta$activeRowI3 = rows[meta.activeRowIndex]) === null || _rows$meta$activeRowI3 === void 0 ? void 0 : _rows$meta$activeRowI3.toggleSelected();
13510
+ }
13511
+ return;
13512
+ }
13513
+ if (event.ctrlKey || event.metaKey) {
13514
+ event.preventDefault();
13515
+ if (event.key === 'a') {
13516
+ if (table.options.enableRowSelection) {
13517
+ table.toggleAllRowsSelected();
13518
+ }
13519
+ }
13520
+ return;
13521
+ }
13522
+ }
13523
+ };
13524
+ let handleBlur;
13525
+ if (meta.editMode.isEditing) {
13526
+ handleBlur = event => {
13527
+ var _elementGainingFocus, _elementGainingFocus$, _event$currentTarget;
13528
+ let elementGainingFocus = event.relatedTarget;
13529
+ if (elementGainingFocus === undefined) {
13530
+ return;
13531
+ }
13532
+ // we might be focusing on a select or a popover that was triggered from inside the table
13533
+ // so see if the element gaining focus is inside a portal and look up its controller
13534
+ const portalId = (_elementGainingFocus = elementGainingFocus) === null || _elementGainingFocus === void 0 ? void 0 : (_elementGainingFocus$ = _elementGainingFocus.closest('[data-radix-popper-content-wrapper] > :first-child')) === null || _elementGainingFocus$ === void 0 ? void 0 : _elementGainingFocus$.id;
13535
+ if (portalId) {
13536
+ var _event$currentTarget$;
13537
+ elementGainingFocus = (_event$currentTarget$ = event.currentTarget.querySelector(`[aria-controls="${portalId}"]`)) !== null && _event$currentTarget$ !== void 0 ? _event$currentTarget$ : event.relatedTarget;
13538
+ }
13539
+ if (!((_event$currentTarget = event.currentTarget) !== null && _event$currentTarget !== void 0 && _event$currentTarget.contains(elementGainingFocus)) && elementGainingFocus !== editButtonRef.current) {
13540
+ // When we call manually blur on control component while navigating to the next cell, then when this
13541
+ // handler is run, the related target is not the next control component and active element is null,
13542
+ // that's why we explictly need to check what's the next focussed element in order to figure out whether
13543
+ // we should disabled the sorting or not.
13544
+ timeoutIdRef.current = setTimeout(() => {
13545
+ const parentRow = event.target.closest('[role="row"]');
13546
+ const isNewFocussedElementInSameRow = parentRow === null || parentRow === void 0 ? void 0 : parentRow.contains(document.activeElement);
13547
+ // When we manually call blur on control component and focus another component then
13548
+ // we have to make sure we
13549
+ if (meta.shouldPauseSortingAndFiltering && !isNewFocussedElementInSameRow) {
13550
+ // if client side - unpause sorting
13551
+ meta.setShouldPauseSortingAndFiltering(false);
13552
+ }
13553
+ });
13554
+ }
13555
+ };
13556
+ }
13557
+ // extract - infinite loading
13558
+ // TODO: this can probably be extracted into a hook
13559
+ // we only show the pinned shadow on display columns when scrolling is active
13560
+ const [scrolled, setScrolled] = React__default.useState(false);
13561
+ // extract - infinite loading
13562
+ const loadingRef = React__default.useRef(false);
13563
+ const handleScroll = function (event) {
13564
+ try {
13565
+ const _temp5 = function () {
13566
+ if (event.currentTarget.scrollLeft > 0 && !scrolled) {
13567
+ setScrolled(true);
13568
+ } else {
13569
+ const _temp4 = function () {
13570
+ if (event.currentTarget.scrollLeft === 0 && scrolled) {
13571
+ setScrolled(false);
13572
+ } else {
13573
+ const _temp3 = function () {
13574
+ if (typeof loadMore === 'function') {
13575
+ const _temp2 = function () {
13576
+ if (event.currentTarget.scrollHeight - event.currentTarget.scrollTop - event.currentTarget.clientHeight < 600 && !loadingRef.current) {
13577
+ const _temp = _finallyRethrows(function () {
13578
+ const isAllRowsSelected = table.getIsAllRowsSelected();
13579
+ loadingRef.current = true;
13580
+ return Promise.resolve(loadMore()).then(function () {
13581
+ if (isAllRowsSelected) {
13582
+ table.toggleAllRowsSelected(true);
13583
+ }
13584
+ });
13585
+ }, function (_wasThrown, _result) {
13586
+ loadingRef.current = false;
13587
+ if (_wasThrown) throw _result;
13588
+ return _result;
13589
+ });
13590
+ if (_temp && _temp.then) return _temp.then(function () {});
13591
+ }
13592
+ }();
13593
+ if (_temp2 && _temp2.then) return _temp2.then(function () {});
13594
+ }
13595
+ }();
13596
+ if (_temp3 && _temp3.then) return _temp3.then(function () {});
13597
+ }
13598
+ }();
13599
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
13600
+ }
13601
+ }();
13602
+ return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(function () {}) : void 0);
13603
+ } catch (e) {
13604
+ return Promise.reject(e);
13605
+ }
13606
+ };
13607
+ let handleMouseLeave;
13608
+ if (meta.hoveredRowIndex !== undefined) {
13609
+ // sometimes the row's onMouseLeave doesn't trigger, this adds some extra redundancy
13610
+ handleMouseLeave = () => meta.setHoveredRowIndex(undefined);
13611
+ }
13612
+ const className = cn('bg-white border border-grey-300 focus:yt-focus focus:border-blue-500 grid overflow-auto relative rounded group', props.className);
13613
+ const enableSettingsButton = table.options.enablePinning || table.options.enableHiding || meta.enableColumnReordering;
13614
+ const hasInternalToolbar = enableSettingsButton || meta.editMode.enableEditMode || table.options.enableColumnFilters || meta.enableRowDensity || table.options.enableGlobalFilter;
13615
+ const hasToolbar = !!toolbar || hasInternalToolbar;
13616
+ const hasFooters = React__default.useMemo(() => {
13617
+ const summaryIds = Object.keys(footers);
13618
+ const visibleIds = Object.keys(columnVisibility).filter(c => !columnVisibility[c]);
13619
+ return summaryIds.length && summaryIds.some(v => !visibleIds.includes(v));
13620
+ }, [footers, columnVisibility]);
13621
+ return /*#__PURE__*/React__default.createElement("div", {
13622
+ className: "flex h-full w-full flex-col gap-4"
13623
+ }, hasToolbar ? /*#__PURE__*/React__default.createElement("div", {
13624
+ className: "flex flex-wrap gap-2"
13625
+ }, toolbar, hasInternalToolbar ? /*#__PURE__*/React__default.createElement(Group, {
13626
+ className: "ml-auto flex-shrink-0 print:hidden"
13627
+ }, meta.editMode.enableEditMode ? /*#__PURE__*/React__default.createElement(EditModeButton, {
13628
+ ref: editButtonRef,
13629
+ table: table,
13630
+ tableRef: tableRef
13631
+ }) : null, table.options.enableColumnFilters ? /*#__PURE__*/React__default.createElement(FiltersButton, {
13632
+ length: length,
13633
+ table: table
13634
+ }) : null, meta.enableRowDensity ? /*#__PURE__*/React__default.createElement(RowDensityButton, {
13635
+ table: table
13636
+ }) : null, enableSettingsButton ? /*#__PURE__*/React__default.createElement(ColumnSettingsButton, {
13637
+ table: table
13638
+ }) : null, table.options.enableGlobalFilter ? /*#__PURE__*/React__default.createElement(Search$2, {
13639
+ disabled: meta.shouldDisableTableActions,
13640
+ onSearch: table.setGlobalFilter,
13641
+ placeholder: "Search...",
13642
+ value: globalFilter
13643
+ }) : null) : null, /*#__PURE__*/React__default.createElement(ShortcutsGuideButton, {
13644
+ table: table
13645
+ })) : null, /*#__PURE__*/React__default.createElement("div", {
13646
+ className: className,
13647
+ onBlur: handleBlur,
13648
+ onKeyDown: handleKeyDown,
13649
+ onMouseLeave: handleMouseLeave,
13650
+ onScroll: handleScroll,
13651
+ ref: tableRef,
13652
+ role: "table",
13653
+ style: {
13654
+ gridTemplateColumns,
13655
+ gridTemplateRows: rows.length ? undefined : '40px',
13656
+ // create a new stacking context so our internal z-indexes don't effect external components
13657
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
13658
+ opacity: 0.999
13659
+ },
13660
+ tabIndex: 0
13661
+ }, /*#__PURE__*/React__default.createElement("div", {
13662
+ className: "contents",
13663
+ role: "rowgroup"
13664
+ }, table.getHeaderGroups().map(headerGroup => /*#__PURE__*/React__default.createElement("div", {
13665
+ className: "contents",
13666
+ key: headerGroup.id,
13667
+ role: "row"
13668
+ }, headerGroup.headers.map((header, columnIndex) => /*#__PURE__*/React__default.createElement(Header$1, {
13669
+ key: header.id,
13670
+ header: header,
13671
+ index: columnIndex,
13672
+ isLastColumn: columnIndex === headerGroup.headers.length - 1,
13673
+ scrolled: scrolled,
13674
+ table: table,
13675
+ tableRef: tableRef
13676
+ }))))), rows.length ? /*#__PURE__*/React__default.createElement("div", {
13677
+ className: "contents",
13678
+ role: "rowgroup"
13679
+ }, virtualiserOffsets.top ? /*#__PURE__*/React__default.createElement("div", {
13680
+ style: {
13681
+ height: virtualiserOffsets.top
13682
+ },
13683
+ className: "col-span-full"
13684
+ }) : null, virtualiser.virtualItems.map(virtualRow => {
13685
+ const row = rows[virtualRow.index];
13686
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
13687
+ key: row.id
13688
+ }, /*#__PURE__*/React__default.createElement(Row$1, {
13689
+ className: "group/row contents",
13690
+ row: row,
13691
+ rowIndex: virtualRow.index,
13692
+ table: table
13693
+ }, row.getVisibleCells().map((cell, columnIndex) => /*#__PURE__*/React__default.createElement(Cell, {
13694
+ cell: cell,
13695
+ key: `${cell.id}_${cell.getValue()}`,
13696
+ index: columnIndex,
13697
+ isLastRow: virtualRow.index === rows.length - 1,
13698
+ rows: rows,
13699
+ rowIndex: virtualRow.index,
13700
+ scrolled: scrolled,
13701
+ scrollToIndex: virtualiser.scrollToIndex,
13702
+ scrollToOffset: virtualiser.scrollToOffset,
13703
+ table: table,
13704
+ tableRef: tableRef
13705
+ }))), row.getIsExpanded() && expandedRowRenderer ? /*#__PURE__*/React__default.createElement(ExpandedRow, {
13706
+ index: virtualRow.index,
13707
+ setSize: setExpandedRowSizes
13708
+ }, expandedRowRenderer(row.original)) : null);
13709
+ }), virtualiserOffsets.bottom ? /*#__PURE__*/React__default.createElement("div", {
13710
+ style: {
13711
+ height: virtualiserOffsets.bottom
13712
+ },
13713
+ className: "col-span-full"
13714
+ }) : null) : /*#__PURE__*/React__default.createElement("div", {
13715
+ className: "col-span-full min-h-[theme(spacing.8)]"
13716
+ }, EmptyState ? /*#__PURE__*/React__default.createElement(EmptyState, null) : null), hasFooters ? /*#__PURE__*/React__default.createElement("div", {
13717
+ role: "rowgroup",
13718
+ className: "contents"
13719
+ }, table.getFooterGroups().map(footerGroup => /*#__PURE__*/React__default.createElement("div", {
13720
+ key: footerGroup.id,
13721
+ role: "row",
13722
+ className: "contents"
13723
+ }, footerGroup.headers.map((footer, cellIndex) => /*#__PURE__*/React__default.createElement(Footer$2, {
13724
+ key: footer.id,
13725
+ footer: footer,
13726
+ index: cellIndex,
13727
+ scrolled: scrolled,
13728
+ table: table
13729
+ }, footers[footer.id] ? footers[footer.id](rows.map(row => row.original[footer.id])) : null))))) : null), !!_experimentalActionsForTable && table.options.enableRowSelection && (table.getIsSomeRowsSelected() || table.getIsAllRowsSelected()) ? /*#__PURE__*/React__default.createElement(BatchActionsMenu, {
13730
+ className: "fixed-center-x bottom-0 z-50 mb-4 print:hidden",
13731
+ actionsForTable: _experimentalActionsForTable,
13732
+ summary: _experimentalActionsForTableSummary,
13733
+ table: table
13734
+ }) : null);
13735
+ });
13736
+ Table2.Column = Column$2;
13737
+ Table2.Toolbar = Toolbar;
13738
+
13739
+ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(props, ref) {
13740
+ const {
13741
+ id,
13742
+ defaultId,
13743
+ children,
13744
+ onChange,
13745
+ orientation = 'horizontal',
13746
+ ...otherProps
13747
+ } = props;
13748
+ const className = cn('yt-tabs', `yt-tabs--${orientation}`, {
13749
+ 'flex w-full': orientation === 'vertical'
13750
+ }, props.className);
13751
+ return /*#__PURE__*/React.createElement(TabsPrimitive.Root, Object.assign({}, otherProps, {
13752
+ className: className,
13753
+ "data-taco": "tabs",
13754
+ defaultValue: defaultId,
13755
+ dir: "ltr",
13756
+ onValueChange: onChange,
13757
+ orientation: orientation,
13758
+ ref: ref,
13759
+ value: id
13760
+ }), children);
13761
+ });
13762
+ const TabList = /*#__PURE__*/React.forwardRef(function Tab(props, ref) {
13763
+ const className = cn('yt-tab__list border-b border-grey-300 flex flex-row m-0 mb-4', props.className);
13764
+ return /*#__PURE__*/React.createElement(TabsPrimitive.List, Object.assign({}, props, {
13765
+ className: className,
13766
+ ref: ref
13767
+ }));
13768
+ });
13769
+ const TabTrigger = /*#__PURE__*/React.forwardRef(function Tab(props, ref) {
13770
+ const {
13771
+ id,
13772
+ disabled,
13773
+ ...otherProps
13774
+ } = props;
13775
+ const className = cn('yt-tab bg-transparent border-b-2 border-transparent text-grey-700 m-0 py-2 px-4', disabled ? 'cursor-not-allowed !text-grey-500' : 'cursor-pointer rounded-t hover:border-grey-300 aria-selected:border-blue-500 aria-selected:text-black aria-selected:hover:border-blue-300 hover:text-black active:yt-focus active:border-blue-500 focus:yt-focus focus:border-blue-500', props.className);
13776
+ return /*#__PURE__*/React.createElement(TabsPrimitive.Trigger, Object.assign({}, otherProps, {
13777
+ className: className,
13778
+ disabled: disabled,
13779
+ ref: ref,
13780
+ style: {
13781
+ transition: 'border 0.2s ease-in'
13782
+ },
13783
+ value: id
13784
+ }));
13785
+ });
13786
+ const TabContent = /*#__PURE__*/React.forwardRef(function Tab(props, ref) {
13787
+ const {
13788
+ id,
13789
+ ...otherProps
13790
+ } = props;
13791
+ const className = cn('yt-tab__panel outline-none', props.className);
13792
+ return /*#__PURE__*/React.createElement(TabsPrimitive.Content, Object.assign({}, otherProps, {
13793
+ className: className,
13794
+ ref: ref,
13795
+ value: id
13796
+ }));
13797
+ });
13798
+ Tabs.List = TabList;
13799
+ Tabs.Trigger = TabTrigger;
13800
+ Tabs.Content = TabContent;
13801
+
13802
+ const Textarea = /*#__PURE__*/React.forwardRef(function Textarea(props, ref) {
13803
+ const {
13804
+ defaultValue: _,
13805
+ highlighted,
13806
+ invalid,
13807
+ onKeyDown,
13808
+ ...otherProps
13809
+ } = props;
13810
+ const classNames = cn(getInputClasses(props), 'py-1 min-h-[75px] disabled:resize-none', props.className);
13811
+ // home and end keys only navigate to the start/end of textarea value if the textarea container does not scroll
13812
+ // if it has scroll height then the browser reverts to native scrolling behaviour only
13813
+ // so we manually override it to ensure _our_ desired behaviour remains intact
13814
+ const handleKeyDown = event => {
13815
+ if (event.key === 'Home' || event.key === 'End') {
13816
+ event.preventDefault();
13817
+ const position = event.key === 'End' ? event.currentTarget.value.length : 0;
13818
+ event.currentTarget.setSelectionRange(position, position);
13819
+ event.currentTarget.scrollTop = event.key === 'End' ? event.currentTarget.scrollHeight : 0;
13820
+ }
13821
+ if (onKeyDown) {
13822
+ onKeyDown(event);
13823
+ }
13824
+ };
13825
+ return /*#__PURE__*/React.createElement("textarea", Object.assign({}, otherProps, {
13826
+ className: classNames,
13827
+ "data-taco": "textarea",
13828
+ onKeyDown: handleKeyDown,
13829
+ ref: ref
13830
+ }));
13831
+ });
13832
+
10437
13833
  const Tooltip$1 = ({
10438
13834
  continuous,
10439
13835
  index,
@@ -10615,10 +14011,12 @@ exports.RadioGroup = RadioGroup;
10615
14011
  exports.SearchInput = SearchInput;
10616
14012
  exports.Select = Select;
10617
14013
  exports.Select2 = Select2;
14014
+ exports.Shortcut = Shortcut$1;
10618
14015
  exports.Spinner = Spinner;
10619
14016
  exports.Switch = Switch;
10620
14017
  exports.TAG_COLORS = TAG_COLORS;
10621
14018
  exports.Table = Table;
14019
+ exports.Table2 = Table2;
10622
14020
  exports.Tabs = Tabs;
10623
14021
  exports.Tag = Tag$1;
10624
14022
  exports.Textarea = Textarea;
@@ -10640,6 +14038,7 @@ exports.getParentRowIndexPath = getParentRowIndexPath;
10640
14038
  exports.getRadioGroupItemValueAsString = getRadioGroupItemValueAsString;
10641
14039
  exports.icons = icons;
10642
14040
  exports.insertChildTableRow = insertChildTableRow;
14041
+ exports.isWeakEqual = isWeakEqual;
10643
14042
  exports.mergeRefs = mergeRefs;
10644
14043
  exports.parseFromCustomString = parseFromCustomString;
10645
14044
  exports.parseFromISOString = parseFromISOString;