@economic/taco 2.22.2 → 2.24.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 (150) hide show
  1. package/dist/components/Card/Card.d.ts +1 -0
  2. package/dist/components/Checkbox/Checkbox.d.ts +2 -0
  3. package/dist/components/OverflowGroup/OverflowGroup.d.ts +1 -1
  4. package/dist/components/Provider/Localization.d.ts +4 -0
  5. package/dist/components/Report/Report.d.ts +2 -0
  6. package/dist/components/Report/components/Body/Body.d.ts +0 -1
  7. package/dist/components/Report/components/Body/EmptyStateBody.d.ts +7 -0
  8. package/dist/components/Report/components/Cell/util.d.ts +1 -1
  9. package/dist/components/Report/components/Footer/Summary.d.ts +0 -1
  10. package/dist/components/Report/components/Toolbar/components/Filters/components/Filter.d.ts +2 -2
  11. package/dist/components/Report/components/Toolbar/components/Filters/components/FilterColumn.d.ts +5 -2
  12. package/dist/components/Report/types.d.ts +2 -0
  13. package/dist/components/Report/useReport.d.ts +1 -1
  14. package/dist/components/Select2/Select2.d.ts +4 -0
  15. package/dist/components/Select2/components/Trigger.d.ts +1 -0
  16. package/dist/components/Select2/hooks/useChildren.d.ts +1 -0
  17. package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +2 -2
  18. package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +5 -2
  19. package/dist/components/Truncate/Truncate.d.ts +2 -2
  20. package/dist/esm/index.css +128 -121
  21. package/dist/esm/packages/taco/src/components/Button/util.js +8 -8
  22. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/Card/Card.js +8 -4
  24. package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +11 -2
  26. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Field/Field.js +4 -15
  28. package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +2 -2
  30. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +1 -1
  32. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js +13 -6
  33. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
  34. package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -1
  35. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Report/Report.js +11 -13
  37. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
  38. package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js +1 -2
  39. package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js.map +1 -1
  40. package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js +18 -0
  41. package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js.map +1 -0
  42. package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js +6 -2
  43. package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js.map +1 -1
  44. package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js +14 -2
  45. package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js.map +1 -1
  46. package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js +2 -2
  47. package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js.map +1 -1
  48. package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js +47 -11
  49. package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js.map +1 -1
  50. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js +28 -43
  51. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
  52. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js +14 -7
  53. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js.map +1 -1
  54. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js +4 -3
  55. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
  56. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js +10 -8
  57. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js.map +1 -1
  58. package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js +2 -2
  59. package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js.map +1 -1
  60. package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +10 -6
  61. package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -1
  62. package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js +3 -10
  63. package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js.map +1 -1
  64. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +2 -1
  65. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  66. package/dist/esm/packages/taco/src/components/Select2/Select2.js +44 -4
  67. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  68. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +9 -4
  69. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  70. package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js +1 -1
  71. package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js.map +1 -1
  72. package/dist/esm/packages/taco/src/components/Table3/Table3.js +4 -6
  73. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  74. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +2 -2
  75. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  76. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +66 -14
  77. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
  78. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +27 -44
  79. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
  80. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +14 -7
  81. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
  82. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +4 -3
  83. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
  84. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +1 -1
  85. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
  86. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +2 -0
  87. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
  88. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +2 -1
  89. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
  90. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +1 -1
  91. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +3 -1
  92. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
  93. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +10 -3
  94. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  95. package/dist/esm/packages/taco/src/components/Toast/Toaster.js +4 -3
  96. package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
  97. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +34 -0
  98. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +1 -0
  99. package/dist/esm/packages/taco/src/hooks/useLocalStorage.js.map +1 -1
  100. package/dist/esm/packages/taco/src/index.js +2 -1
  101. package/dist/esm/packages/taco/src/index.js.map +1 -1
  102. package/dist/esm/packages/taco/src/primitives/Button.js +1 -0
  103. package/dist/esm/packages/taco/src/primitives/Button.js.map +1 -1
  104. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  105. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js +24 -4
  106. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js.map +1 -1
  107. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +48 -7
  108. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -1
  109. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js +1 -1
  110. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js.map +1 -1
  111. package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +11 -6
  112. package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -1
  113. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js +33 -7
  114. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js.map +1 -1
  115. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js +5 -5
  116. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js.map +1 -1
  117. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js +14 -1
  118. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js.map +1 -1
  119. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js +0 -1
  120. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js.map +1 -1
  121. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +127 -3
  122. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  123. package/dist/esm/packages/taco/src/utils/dom.js +12 -3
  124. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  125. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +4 -4
  126. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -1
  127. package/dist/esm/packages/taco/src/utils/keyboard.js +2 -2
  128. package/dist/esm/packages/taco/src/utils/keyboard.js.map +1 -1
  129. package/dist/hooks/useLocalStorage.d.ts +2 -1
  130. package/dist/index.css +128 -121
  131. package/dist/index.d.ts +1 -0
  132. package/dist/primitives/Table/types.d.ts +12 -2
  133. package/dist/primitives/Table/useTable/features/useTablePrinting.d.ts +10 -3
  134. package/dist/primitives/Table/useTable/features/useTableSettings.d.ts +2 -2
  135. package/dist/primitives/Table/useTable/useTable.d.ts +2 -1
  136. package/dist/primitives/Table/useTable/util/settings.d.ts +0 -1
  137. package/dist/taco.cjs.development.js +814 -455
  138. package/dist/taco.cjs.development.js.map +1 -1
  139. package/dist/taco.cjs.production.min.js +1 -1
  140. package/dist/taco.cjs.production.min.js.map +1 -1
  141. package/dist/utils/dom.d.ts +3 -1
  142. package/dist/utils/hooks/useTruncated.d.ts +1 -1
  143. package/package.json +2 -2
  144. package/types.json +9339 -9261
  145. package/dist/components/Report/components/Toolbar/components/Filters/components/Placeholder.d.ts +0 -12
  146. package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +0 -12
  147. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js +0 -41
  148. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js.map +0 -1
  149. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +0 -41
  150. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +0 -1
@@ -26,6 +26,7 @@ var HoverCardPrimitive = require('@radix-ui/react-hover-card');
26
26
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
27
27
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
28
28
  var PrimitiveSwitch = require('@radix-ui/react-switch');
29
+ var reactPortal = require('@radix-ui/react-portal');
29
30
  var reactTable = require('@tanstack/react-table');
30
31
  var core = require('@dnd-kit/core');
31
32
  var SortablePrimitive = require('@dnd-kit/sortable');
@@ -4060,8 +4061,17 @@ function isElementInsideOrTriggeredFromContainer(element, container) {
4060
4061
  }
4061
4062
  return !!(container !== null && container !== void 0 && container.contains(element));
4062
4063
  }
4063
- function isEventTriggeredOnInteractiveElement(eventTarget) {
4064
- const element = eventTarget;
4064
+ function isElementInsideOverlay(element) {
4065
+ return !!(element !== null && element !== void 0 && element.closest('[role=dialog],[role=menu]'));
4066
+ }
4067
+ function isSiblingElementInsideSameParentOverlay(element, sibling) {
4068
+ var _element$closest2;
4069
+ return !!(element !== null && element !== void 0 && (_element$closest2 = element.closest('[role=dialog],[role=menu]')) !== null && _element$closest2 !== void 0 && _element$closest2.contains(sibling));
4070
+ }
4071
+ function isElementInteractive(element) {
4072
+ if (!element) {
4073
+ return false;
4074
+ }
4065
4075
  return ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'LABEL', 'OPTION'].includes(element.tagName) && !element.hidden && !element.disabled && !element.readOnly;
4066
4076
  }
4067
4077
 
@@ -4084,7 +4094,7 @@ function shouldTriggerShortcut(event, key) {
4084
4094
  }
4085
4095
  function createShortcutKeyDownHandler(key, handler, stopPropagation = true) {
4086
4096
  return function (event) {
4087
- if (event.target !== event.currentTarget && isEventTriggeredOnInteractiveElement(event.target) && !isPressingMetaKey(event)) {
4097
+ if (event.target !== event.currentTarget && isElementInteractive(event.target) && !isPressingMetaKey(event)) {
4088
4098
  return;
4089
4099
  }
4090
4100
  const condition = shouldTriggerShortcut(event, key);
@@ -4141,6 +4151,7 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
4141
4151
  });
4142
4152
  const Tag = props.href ? 'a' : 'button';
4143
4153
  return /*#__PURE__*/React.createElement(Tag, Object.assign({}, otherProps, {
4154
+ href: disabled ? undefined : props.href,
4144
4155
  "aria-disabled": disabled ? 'true' : undefined,
4145
4156
  disabled: disabled,
4146
4157
  target: Tag === 'a' ? target : undefined,
@@ -4183,29 +4194,29 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(props, ref) {
4183
4194
  });
4184
4195
 
4185
4196
  const getButtonClasses = () => {
4186
- return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center focus-visible:yt-focus disabled:cursor-not-allowed';
4197
+ return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center focus-visible:yt-focus aria-disabled:cursor-not-allowed';
4187
4198
  };
4188
4199
  const getAppearanceClasses = (value, icon = false) => {
4189
4200
  switch (value) {
4190
4201
  case 'primary':
4191
- return `wcag-blue-500 enabled:hover:wcag-blue-700 enabled:hover:active:wcag-blue-500 disabled:bg-blue-500/50`;
4202
+ return `wcag-blue-500 visited:wcag-blue-500 hover:wcag-blue-700 hover:active:wcag-blue-500 aria-disabled:bg-blue-500/50 aria-disabled:active:bg-blue-500/50`;
4192
4203
  case 'danger':
4193
- return `wcag-red-500 enabled:hover:wcag-red-700 enabled:hover:active:wcag-red-500 disabled:bg-red-500/50`;
4204
+ return `wcag-red-500 visited:wcag-red-500 hover:wcag-red-700 hover:active:wcag-red-500 aria-disabled:bg-red-500/50 aria-disabled:active:bg-red-500/50`;
4194
4205
  case 'ghost':
4195
- return `bg-white border border-blue-500 text-blue-500 enabled:hover:bg-blue-100 enabled:hover:text-blue-700 disabled:border-blue-500/50 disabled:text-blue-500/50`;
4206
+ return `bg-white border border-blue-500 text-blue-500 visited:text-blue-500 hover:bg-blue-100 hover:text-blue-700 aria-disabled:border-blue-500/50 aria-disabled:text-blue-500/50 aria-disabled:bg-white`;
4196
4207
  case 'discrete':
4197
4208
  {
4198
4209
  if (icon) {
4199
- return `bg-transparent text-black enabled:hover:bg-[#000]/[0.08] disabled:text-black/30`;
4210
+ return `bg-transparent text-black visited:text-black hover:bg-[#000]/[0.08] aria-disabled:text-black/30`;
4200
4211
  }
4201
- return `bg-transparent text-blue-500 enabled:hover:text-blue-700 disabled:text-blue-500/50`;
4212
+ return `bg-transparent text-blue-500 visited:text-blue-500 hover:text-blue-700 aria-disabled:text-blue-500/50`;
4202
4213
  }
4203
4214
  case 'transparent':
4204
4215
  {
4205
- return `bg-transparent text-black enabled:hover:text-black enabled:hover:bg-[#000]/[0.08] disabled:text-black/30`;
4216
+ return `bg-transparent text-black visited:text-black hover:text-black hover:bg-[#000]/[0.08] aria-disabled:text-black/30 aria-disabled:bg-transparent`;
4206
4217
  }
4207
4218
  default:
4208
- return `wcag-grey-200 enabled:hover:wcag-grey-300 disabled:bg-grey-200/50 disabled:text-black/30`;
4219
+ return `wcag-grey-200 visited:wcag-grey-200 hover:wcag-grey-300 aria-disabled:bg-grey-200/50 aria-disabled:text-black/30`;
4209
4220
  }
4210
4221
  };
4211
4222
  const createButtonWithTooltip = (props, className, ref) => {
@@ -4591,7 +4602,11 @@ const defaultLocalisationTexts = {
4591
4602
  delete: 'Delete',
4592
4603
  save: 'Save',
4593
4604
  search: 'Search...',
4594
- searchOrCreate: 'Search or create...'
4605
+ searchOrCreate: 'Search or create...',
4606
+ selectAll: 'Select all',
4607
+ selectAllResults: 'Select all results',
4608
+ deselectAll: 'Deselect all',
4609
+ deselectAllResults: 'Deselect all results'
4595
4610
  },
4596
4611
  toasts: {
4597
4612
  dismiss: 'Dismiss'
@@ -4818,6 +4833,49 @@ const Calendar$1 = /*#__PURE__*/React.forwardRef(function Calendar(props, ref) {
4818
4833
  })));
4819
4834
  });
4820
4835
 
4836
+ const isElementTruncated = targetElement => {
4837
+ if (targetElement !== null) {
4838
+ return targetElement.offsetWidth < targetElement.scrollWidth;
4839
+ }
4840
+ return false;
4841
+ };
4842
+ const useTruncated = (element, deps = []) => {
4843
+ const [isTruncated, setIsTruncated] = React__default.useState(isElementTruncated(element));
4844
+ React__default.useEffect(() => {
4845
+ setIsTruncated(isElementTruncated(element));
4846
+ }, [element, ...deps]);
4847
+ return {
4848
+ isTruncated
4849
+ };
4850
+ };
4851
+
4852
+ const Truncate = ({
4853
+ children,
4854
+ tooltip
4855
+ }) => {
4856
+ const ref = React__default.useRef(null);
4857
+ const [mounted, setMounted] = React__default.useState(false);
4858
+ const {
4859
+ isTruncated
4860
+ } = useTruncated(ref.current, [mounted]);
4861
+ React__default.useEffect(() => {
4862
+ setMounted(true);
4863
+ return () => setMounted(false);
4864
+ }, []);
4865
+ const clonedChildrenWithRef = /*#__PURE__*/React__default.cloneElement(React__default.Children.only(children), {
4866
+ ref,
4867
+ className: cn(children.props.className, 'truncate', {
4868
+ 'hover:cursor-pointer': isTruncated
4869
+ })
4870
+ });
4871
+ if (isTruncated) {
4872
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
4873
+ title: tooltip
4874
+ }, clonedChildrenWithRef);
4875
+ }
4876
+ return clonedChildrenWithRef;
4877
+ };
4878
+
4821
4879
  const Content$2 = /*#__PURE__*/React.forwardRef(function CardContent(externalProps, ref) {
4822
4880
  const {
4823
4881
  noPadding,
@@ -4828,6 +4886,7 @@ const Content$2 = /*#__PURE__*/React.forwardRef(function CardContent(externalPro
4828
4886
  }, props.className);
4829
4887
  return /*#__PURE__*/React.createElement("div", Object.assign({}, props, {
4830
4888
  className: className,
4889
+ "data-taco": "card-content",
4831
4890
  ref: ref
4832
4891
  }));
4833
4892
  });
@@ -4837,16 +4896,18 @@ const Card = /*#__PURE__*/React.forwardRef(function Card(props, ref) {
4837
4896
  menu,
4838
4897
  children
4839
4898
  } = props;
4840
- const className = cn('bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500 [&_[data-taco="table2"]]:!border-0', props.className);
4899
+ const className = cn('bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500', props.className);
4841
4900
  return /*#__PURE__*/React.createElement("div", {
4842
4901
  className: className,
4843
4902
  "data-taco": "card",
4844
4903
  ref: ref
4845
4904
  }, /*#__PURE__*/React.createElement("div", {
4846
4905
  className: "mx-4 mb-2 mt-4 flex"
4847
- }, title && /*#__PURE__*/React.createElement("h4", {
4848
- className: "mb-0 flex-grow text-left"
4849
- }, title), menu ? /*#__PURE__*/React.createElement(IconButton, {
4906
+ }, title && ( /*#__PURE__*/React.createElement(Truncate, {
4907
+ tooltip: title
4908
+ }, /*#__PURE__*/React.createElement("h4", {
4909
+ className: "mb-0 flex-grow truncate text-left"
4910
+ }, title))), menu ? /*#__PURE__*/React.createElement(IconButton, {
4850
4911
  icon: "ellipsis-horizontal",
4851
4912
  appearance: "discrete",
4852
4913
  menu: menu,
@@ -4860,12 +4921,52 @@ const useId = nativeId => {
4860
4921
  return React__default.useMemo(() => nativeId !== null && nativeId !== void 0 ? nativeId : uuid.v4(), []);
4861
4922
  };
4862
4923
 
4924
+ const Spinner = /*#__PURE__*/React__default.forwardRef(function Spinner(props, ref) {
4925
+ const {
4926
+ delay = 350,
4927
+ label,
4928
+ ...otherProps
4929
+ } = props;
4930
+ const [visible, setVisibility] = React__default.useState(!delay);
4931
+ React__default.useEffect(() => {
4932
+ let timeout;
4933
+ if (delay) {
4934
+ timeout = window.setTimeout(() => setVisibility(true), delay);
4935
+ }
4936
+ return () => {
4937
+ if (timeout) {
4938
+ clearTimeout(timeout);
4939
+ }
4940
+ };
4941
+ }, [delay]);
4942
+ if (!visible) {
4943
+ return null;
4944
+ }
4945
+ const className = cn('inline-flex flex-col relative items-center', otherProps.className);
4946
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, otherProps, {
4947
+ className: className,
4948
+ "data-taco": "spinner",
4949
+ ref: ref
4950
+ }), /*#__PURE__*/React__default.createElement("svg", {
4951
+ className: "h-10 w-10 animate-[spinnerRotation_2s_linear_infinite]",
4952
+ viewBox: "0 0 100 100",
4953
+ xmlns: "http://www.w3.org/2000/svg"
4954
+ }, /*#__PURE__*/React__default.createElement("circle", {
4955
+ cx: "50",
4956
+ cy: "50",
4957
+ r: "45"
4958
+ })), label && /*#__PURE__*/React__default.createElement("span", {
4959
+ className: "mt-4"
4960
+ }, label));
4961
+ });
4962
+
4863
4963
  const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4864
4964
  const {
4865
4965
  checked,
4866
4966
  indeterminate,
4867
4967
  invalid,
4868
4968
  label,
4969
+ loading,
4869
4970
  onChange,
4870
4971
  ...otherProps
4871
4972
  } = props;
@@ -4896,6 +4997,11 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4896
4997
  event.currentTarget.click();
4897
4998
  }
4898
4999
  };
5000
+ const spinnerClassname = cn(
5001
+ //Spinner is slightly bigger then 'line' and 'tick' icons, so making it 2px smaller from each side
5002
+ "m-0.5 !h-[calc(100%-theme('spacing.1'))] !w-[calc(100%-theme('spacing.1'))]", {
5003
+ 'text-blue-500': !checked && !indeterminate
5004
+ });
4899
5005
  const element = /*#__PURE__*/React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, labelledByProps, {
4900
5006
  "aria-invalid": invalid ? 'true' : undefined,
4901
5007
  "data-taco": "checkbox",
@@ -4904,12 +5010,14 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4904
5010
  onCheckedChange: handleChange,
4905
5011
  onKeyDown: handleKeyDown,
4906
5012
  ref: ref
4907
- }), /*#__PURE__*/React.createElement(CheckboxPrimitive.Indicator, {
5013
+ }), loading ? ( /*#__PURE__*/React.createElement(Spinner, {
5014
+ className: spinnerClassname
5015
+ })) : ( /*#__PURE__*/React.createElement(CheckboxPrimitive.Indicator, {
4908
5016
  className: "flex h-full w-full"
4909
5017
  }, /*#__PURE__*/React.createElement(Icon, {
4910
5018
  name: indeterminate ? 'line' : 'tick',
4911
5019
  className: "!h-full !w-full"
4912
- })));
5020
+ }))));
4913
5021
  if (label) {
4914
5022
  const labelContainerClassName = cn('flex items-center cursor-pointer gap-2', {
4915
5023
  'cursor-not-allowed text-grey-300': props.disabled
@@ -5208,45 +5316,6 @@ const useListScrollTo = (internalRef, itemRefs) => {
5208
5316
  };
5209
5317
  };
5210
5318
 
5211
- const Spinner = /*#__PURE__*/React__default.forwardRef(function Spinner(props, ref) {
5212
- const {
5213
- delay = 350,
5214
- label,
5215
- ...otherProps
5216
- } = props;
5217
- const [visible, setVisibility] = React__default.useState(!delay);
5218
- React__default.useEffect(() => {
5219
- let timeout;
5220
- if (delay) {
5221
- timeout = window.setTimeout(() => setVisibility(true), delay);
5222
- }
5223
- return () => {
5224
- if (timeout) {
5225
- clearTimeout(timeout);
5226
- }
5227
- };
5228
- }, [delay]);
5229
- if (!visible) {
5230
- return null;
5231
- }
5232
- const className = cn('inline-flex flex-col relative items-center', otherProps.className);
5233
- return /*#__PURE__*/React__default.createElement("div", Object.assign({}, otherProps, {
5234
- className: className,
5235
- "data-taco": "spinner",
5236
- ref: ref
5237
- }), /*#__PURE__*/React__default.createElement("svg", {
5238
- className: "h-10 w-10 animate-[spinnerRotation_2s_linear_infinite]",
5239
- viewBox: "0 0 100 100",
5240
- xmlns: "http://www.w3.org/2000/svg"
5241
- }, /*#__PURE__*/React__default.createElement("circle", {
5242
- cx: "50",
5243
- cy: "50",
5244
- r: "45"
5245
- })), label && /*#__PURE__*/React__default.createElement("span", {
5246
- className: "mt-4"
5247
- }, label));
5248
- });
5249
-
5250
5319
  const getId = (id, value) => `${id}_${value}`;
5251
5320
  const getNextEnabledItem = (event, data, index) => {
5252
5321
  const nextIndex = getNextIndexFromKey(event.key, data.length, index);
@@ -7001,30 +7070,8 @@ Drawer.Close = Close$3;
7001
7070
  Drawer.Actions = Actions;
7002
7071
  Drawer.Outlet = Outlet;
7003
7072
 
7004
- const isTruncated = targetElement => {
7005
- if (targetElement !== null) {
7006
- return targetElement.offsetWidth < targetElement.scrollWidth;
7007
- }
7008
- return false;
7009
- };
7010
- const useTruncated = (element, deps = []) => {
7011
- const [truncated, setTruncated] = React__default.useState(isTruncated(element));
7012
- React__default.useEffect(() => {
7013
- setTruncated(isTruncated(element));
7014
- }, [element, ...deps]);
7015
- return {
7016
- truncated
7017
- };
7018
- };
7019
-
7020
7073
  const Field = /*#__PURE__*/React.forwardRef(function Field(props, ref) {
7021
- const [showTooltip, setShowTooltip] = React.useState(false);
7022
7074
  const messageRef = React.useRef(null);
7023
- React.useEffect(() => {
7024
- // refs are null on the first render so setting showTooltip state forces the rerender to see if message is
7025
- // truncated or not
7026
- setShowTooltip(true);
7027
- }, []);
7028
7075
  const {
7029
7076
  disabled,
7030
7077
  children,
@@ -7042,16 +7089,12 @@ const Field = /*#__PURE__*/React.forwardRef(function Field(props, ref) {
7042
7089
  'text-yellow-700': warning && !invalid,
7043
7090
  'opacity-50': disabled
7044
7091
  });
7045
- const {
7046
- truncated: isMessageTrucated
7047
- } = useTruncated(messageRef.current, [message, showTooltip]);
7048
7092
  return /*#__PURE__*/React.createElement("label", Object.assign({}, otherProps, {
7049
7093
  className: className,
7050
7094
  "data-taco": "label",
7051
7095
  ref: ref
7052
- }), children, message && ( /*#__PURE__*/React.createElement(Tooltip, {
7053
- title: message,
7054
- hide: !isMessageTrucated
7096
+ }), children, message && ( /*#__PURE__*/React.createElement(Truncate, {
7097
+ tooltip: message
7055
7098
  }, /*#__PURE__*/React.createElement("span", {
7056
7099
  className: messageClassName,
7057
7100
  ref: messageRef,
@@ -8421,8 +8464,9 @@ const sanitizeButtonPropsForMenuItem = (button, index) => {
8421
8464
  };
8422
8465
  const DEFAULT_OFFSET = 32 + 8;
8423
8466
  const OverflowGroup = /*#__PURE__*/React__default.forwardRef(function OverflowGroup(props, ref) {
8467
+ var _moreButton;
8424
8468
  const {
8425
- moreButton: MoreButton,
8469
+ moreButton,
8426
8470
  ...attributes
8427
8471
  } = props;
8428
8472
  const internalRef = useMergedRef(ref);
@@ -8432,12 +8476,17 @@ const OverflowGroup = /*#__PURE__*/React__default.forwardRef(function OverflowGr
8432
8476
  var _el$getBoundingClient;
8433
8477
  return setButtonWidth(el === null || el === void 0 ? void 0 : (_el$getBoundingClient = el.getBoundingClientRect()) === null || _el$getBoundingClient === void 0 ? void 0 : _el$getBoundingClient.width);
8434
8478
  }, []);
8435
- const button = MoreButton !== null && MoreButton !== void 0 ? MoreButton : /*#__PURE__*/React__default.createElement(IconButton, {
8436
- icon: "more"
8437
- });
8479
+ const {
8480
+ texts
8481
+ } = useLocalization();
8438
8482
  const intersectedChildIndex = useIntersectionObserver(internalRef, buttonWidth);
8439
8483
  const children = React__default.Children.toArray(props.children);
8440
8484
  const hiddenChildren = intersectedChildIndex !== undefined ? children.slice(intersectedChildIndex) : [];
8485
+ const hiddenChildrenCount = hiddenChildren.length;
8486
+ const moreButtonText = hiddenChildrenCount ? `${hiddenChildrenCount} ${texts.header.more}` : '';
8487
+ const MoreButton = (_moreButton = moreButton === null || moreButton === void 0 ? void 0 : moreButton(moreButtonText)) !== null && _moreButton !== void 0 ? _moreButton : /*#__PURE__*/React__default.createElement(IconButton, {
8488
+ icon: "more"
8489
+ });
8441
8490
  const className = cn('flex overflow-hidden', props.className);
8442
8491
  return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
8443
8492
  className: className,
@@ -8448,8 +8497,8 @@ const OverflowGroup = /*#__PURE__*/React__default.forwardRef(function OverflowGr
8448
8497
  visible: intersectedChildIndex === undefined || index < intersectedChildIndex,
8449
8498
  'invisible order-[100] pointer-events-none': intersectedChildIndex !== undefined && index >= intersectedChildIndex
8450
8499
  })
8451
- })), hiddenChildren.length ? /*#__PURE__*/React__default.cloneElement(button, {
8452
- className: cn('sticky right-0 order-[99]', button.props.className),
8500
+ })), hiddenChildren.length ? /*#__PURE__*/React__default.cloneElement(MoreButton, {
8501
+ className: cn('sticky right-0 order-[99]', MoreButton.props.className),
8453
8502
  'data-observer-ignore': true,
8454
8503
  menu: menuProps => ( /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, null, hiddenChildren.map(sanitizeButtonPropsForMenuItem)))),
8455
8504
  ref: buttonRefCallback
@@ -9141,9 +9190,9 @@ const ToastProvider = ({
9141
9190
  }, []);
9142
9191
  return /*#__PURE__*/React.createElement(ToastContext.Provider, Object.assign({}, props, {
9143
9192
  value: toaster
9144
- }), children, /*#__PURE__*/React.createElement("div", {
9193
+ }), children, /*#__PURE__*/React.createElement(reactPortal.Portal, null, /*#__PURE__*/React.createElement("div", {
9145
9194
  id: "yt-toast__container",
9146
- className: "pointer-events-all absolute bottom-0 right-0 !left-auto z-[1000] mb-4 mr-4 flex max-w-md flex-col items-end justify-end",
9195
+ className: "pointer-events-all absolute !left-auto bottom-0 right-0 z-[1000] mb-4 mr-4 flex max-w-md flex-col items-end justify-end",
9147
9196
  role: "log"
9148
9197
  }, /*#__PURE__*/React.createElement(framerMotion.AnimatePresence, {
9149
9198
  initial: false
@@ -9173,7 +9222,7 @@ const ToastProvider = ({
9173
9222
  }
9174
9223
  }, /*#__PURE__*/React.createElement(Toast, Object.assign({}, toast, {
9175
9224
  onClose: () => handleClose(toast.id)
9176
- }))))))));
9225
+ })))))))));
9177
9226
  };
9178
9227
  const useToast = () => React.useContext(ToastContext);
9179
9228
 
@@ -9251,13 +9300,32 @@ function getCellValueAsString(value, dataType) {
9251
9300
  }
9252
9301
  return String(value);
9253
9302
  }
9303
+ function orderColumn(column, {
9304
+ orderingDisabled,
9305
+ orderingEnabled
9306
+ }) {
9307
+ const groupedColumn = column;
9308
+ if (Array.isArray(groupedColumn.columns) && groupedColumn.columns.length > 0) {
9309
+ groupedColumn.columns.forEach(subcolumn => orderColumn(subcolumn, {
9310
+ orderingDisabled,
9311
+ orderingEnabled
9312
+ }));
9313
+ } else {
9314
+ var _column$meta;
9315
+ if ((_column$meta = column.meta) !== null && _column$meta !== void 0 && _column$meta.enableOrdering) {
9316
+ orderingEnabled.push(column.id);
9317
+ } else {
9318
+ orderingDisabled.push(column.id);
9319
+ }
9320
+ }
9321
+ }
9254
9322
  // ordering
9255
9323
  function ensureOrdering(columns, settingsOrder, internalColumnsPinnedToTheRight = ['__actions']) {
9256
9324
  // internal columns come with a defined order
9257
9325
  const internalColumns = columns.filter(column => isInternalColumn(column.id) && !internalColumnsPinnedToTheRight.includes(String(column.id))).map(column => column.id);
9258
9326
  // columns with ordering disabled should be moved to the front
9259
9327
  const orderingDisabled = [];
9260
- const orderingEnabled = [];
9328
+ let orderingEnabled = [];
9261
9329
  let orderedColumns = columns;
9262
9330
  // if settings is defined, make sure the columns that are actual children are sorted by it
9263
9331
  if (Array.isArray(settingsOrder)) {
@@ -9266,16 +9334,23 @@ function ensureOrdering(columns, settingsOrder, internalColumnsPinnedToTheRight
9266
9334
  (a, b) => (settingsOrder.indexOf(a.id) >>> 0) - (settingsOrder.indexOf(b.id) >>> 0));
9267
9335
  }
9268
9336
  orderedColumns.forEach(column => {
9269
- var _column$meta;
9270
9337
  if (isInternalColumn(column.id)) {
9271
9338
  return;
9272
9339
  }
9273
- if ((_column$meta = column.meta) !== null && _column$meta !== void 0 && _column$meta.enableOrdering) {
9274
- orderingEnabled.push(column.id);
9275
- } else {
9276
- orderingDisabled.push(column.id);
9277
- }
9340
+ orderColumn(column, {
9341
+ orderingDisabled,
9342
+ orderingEnabled
9343
+ });
9278
9344
  });
9345
+ if (settingsOrder && settingsOrder.length > 0) {
9346
+ orderingEnabled = orderingEnabled.reduce((acc, column) => {
9347
+ const index = settingsOrder.indexOf(column);
9348
+ if (index > -1) {
9349
+ acc[index] = column;
9350
+ }
9351
+ return acc;
9352
+ }, []).filter(column => !!column);
9353
+ }
9279
9354
  const order = [...internalColumns, ...orderingDisabled, ...orderingEnabled];
9280
9355
  // actions should always be last, enforce that
9281
9356
  internalColumnsPinnedToTheRight.forEach(id => {
@@ -9726,7 +9801,7 @@ const DEFAULT_PRESET = {
9726
9801
  enableRowClick: false,
9727
9802
  enableRowGoto: false,
9728
9803
  enableRowHeight: false,
9729
- enableSettings: false
9804
+ enableSaveSettings: false
9730
9805
  };
9731
9806
  const presets = {
9732
9807
  lite: {
@@ -9750,7 +9825,7 @@ const presets = {
9750
9825
  enableRowClick: true,
9751
9826
  enableRowGoto: true,
9752
9827
  enableRowHeight: false,
9753
- enableSettings: true
9828
+ enableSaveSettings: true
9754
9829
  },
9755
9830
  complex: {
9756
9831
  // react-table built-in
@@ -9773,11 +9848,11 @@ const presets = {
9773
9848
  enableRowClick: true,
9774
9849
  enableRowGoto: true,
9775
9850
  enableRowHeight: true,
9776
- enableSettings: true
9851
+ enableSaveSettings: true
9777
9852
  }
9778
9853
  };
9779
9854
  function useTableFeaturePreset(props) {
9780
- var _props$enableRowActio, _props$enableRowClick, _props$enableRowGoto, _props$enableRowExpan, _props$enableRowSelec, _props$enableRowSelec2, _props$enableFilterin, _props$enableSearch, _props$enableSorting, _props$enableColumnFr, _props$enableColumnHi, _props$enableColumnRe, _props$enableColumnOr, _props$enableFontSize, _props$enableFooter, _props$enablePrinting, _props$enableRowActiv, _props$rowActions2, _props$enableRowHeigh, _props$enableSettings;
9855
+ var _props$enableRowActio, _props$enableRowClick, _props$enableRowGoto, _props$enableRowExpan, _props$enableRowSelec, _props$enableRowSelec2, _props$enableFilterin, _props$enableSearch, _props$enableSorting, _props$enableColumnFr, _props$enableColumnHi, _props$enableColumnRe, _props$enableColumnOr, _props$enableFontSize, _props$enableFooter, _props$enablePrinting, _props$enableRowActiv, _props$rowActions2, _props$enableRowHeigh, _props$enableSaveSett;
9781
9856
  const presetOptions = props.preset ? presets[props.preset] : DEFAULT_PRESET;
9782
9857
  const enableRowActions = (_props$enableRowActio = props.enableRowActions) !== null && _props$enableRowActio !== void 0 ? _props$enableRowActio : presetOptions.enableRowActions;
9783
9858
  const enableRowClick = (_props$enableRowClick = props.enableRowClick) !== null && _props$enableRowClick !== void 0 ? _props$enableRowClick : presetOptions.enableRowClick;
@@ -9828,7 +9903,7 @@ function useTableFeaturePreset(props) {
9828
9903
  enableRowClick: enableRowClick && !!props.onRowClick,
9829
9904
  enableRowGoto: enableRowGoto && !!props.onRowGoto,
9830
9905
  enableRowHeight: (_props$enableRowHeigh = props.enableRowHeight) !== null && _props$enableRowHeigh !== void 0 ? _props$enableRowHeigh : presetOptions.enableRowHeight,
9831
- enableSettings: (_props$enableSettings = props.enableSettings) !== null && _props$enableSettings !== void 0 ? _props$enableSettings : presetOptions.enableSettings
9906
+ enableSaveSettings: (_props$enableSaveSett = props.enableSaveSettings) !== null && _props$enableSaveSett !== void 0 ? _props$enableSaveSett : presetOptions.enableSaveSettings
9832
9907
  };
9833
9908
  }
9834
9909
 
@@ -9870,17 +9945,79 @@ function useTableFontSize(isEnabled = false, defaultFontSize = 'medium') {
9870
9945
  };
9871
9946
  }
9872
9947
 
9873
- function useTablePrinting(isEnabled = false, defaultIsWarningVisible = true) {
9948
+ function useTacoSettings() {
9949
+ return React__default.useContext(TacoContext);
9950
+ }
9951
+
9952
+ const useLocalStorage = (key, initialValue) => {
9953
+ const [state, setState] = React__default.useState(() => {
9954
+ if (!key) {
9955
+ return initialValue;
9956
+ }
9957
+ try {
9958
+ const localStorageValue = localStorage.getItem(key);
9959
+ if (typeof localStorageValue !== 'string') {
9960
+ localStorage.setItem(key, JSON.stringify(initialValue));
9961
+ return initialValue;
9962
+ } else {
9963
+ return JSON.parse(localStorageValue || 'null');
9964
+ }
9965
+ } catch {
9966
+ // If user is in private mode or has storage restriction
9967
+ // localStorage can throw. JSON.parse and JSON.stringify
9968
+ // can throw, too.
9969
+ return initialValue;
9970
+ }
9971
+ });
9972
+ React__default.useEffect(() => {
9973
+ if (!key) {
9974
+ return;
9975
+ }
9976
+ try {
9977
+ const serializedState = JSON.stringify(state);
9978
+ localStorage.setItem(key, serializedState);
9979
+ } catch {
9980
+ // If user is in private mode or has storage restriction
9981
+ // localStorage can throw. Also JSON.stringify can throw.
9982
+ }
9983
+ }, [key, state]);
9984
+ const clear = () => {
9985
+ if (key) {
9986
+ localStorage.removeItem(key);
9987
+ }
9988
+ };
9989
+ return [state, setState, clear];
9990
+ };
9991
+
9992
+ function useTablePrinting(isEnabled = false, tableId) {
9874
9993
  const [isPrinting, setIsPrinting] = React__default.useState(false);
9875
- const [isWarningVisibleForLargeDatasets, setIsWarningVisibleForLargeDatasets] = React__default.useState(defaultIsWarningVisible);
9994
+ const [settings, setSetting] = useTablePrintingSettings(tableId);
9876
9995
  return {
9877
9996
  isEnabled,
9878
9997
  isPrinting,
9879
9998
  setIsPrinting,
9880
- isWarningVisibleForLargeDatasets,
9881
- setIsWarningVisibleForLargeDatasets: isEnabled ? setIsWarningVisibleForLargeDatasets : () => undefined
9999
+ settings,
10000
+ setSetting
9882
10001
  };
9883
10002
  }
10003
+ const DEFAULT_PRINT_SETTINGS = {
10004
+ size: 'A4',
10005
+ orientation: 'portrait',
10006
+ allRows: true,
10007
+ splitGroups: true
10008
+ };
10009
+ function useTablePrintingSettings(tableId) {
10010
+ const tacoSettings = useTacoSettings();
10011
+ const uniqueId = `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.print.settings`;
10012
+ const [persistedSettings, setPersistedSettings] = useLocalStorage(uniqueId, DEFAULT_PRINT_SETTINGS);
10013
+ function setSetting(key, value) {
10014
+ setPersistedSettings(currentSettings => ({
10015
+ ...currentSettings,
10016
+ [key]: value
10017
+ }));
10018
+ }
10019
+ return [persistedSettings, setSetting];
10020
+ }
9884
10021
 
9885
10022
  const DEFAULT_ROW_ACTIONS_LENGTH = 4;
9886
10023
  function useTableRowActions(isEnabled = false, rowActions, rowActionsLength = DEFAULT_ROW_ACTIONS_LENGTH) {
@@ -10140,6 +10277,130 @@ function _finallyRethrows(body, finalizer) {
10140
10277
  }
10141
10278
 
10142
10279
  const DEFAULT_PAGE_SIZE = 100;
10280
+ function useTableDataLoader(fetch, fetchAll, options = {
10281
+ pageSize: DEFAULT_PAGE_SIZE
10282
+ }) {
10283
+ const {
10284
+ pageSize
10285
+ } = options;
10286
+ // track the data length, we don't know it until the first request
10287
+ const length = React__default.useRef(undefined);
10288
+ // data will be filled after the first request, then we'll update values in place
10289
+ const [data, setData] = React__default.useState([]);
10290
+ // track which pages have been loaded to dedupe requests
10291
+ const _pendingPageRequests = React__default.useRef({});
10292
+ const _lastUsedSorting = React__default.useRef([]);
10293
+ const _lastUsedFilters = React__default.useRef([]);
10294
+ const _lastUsedSearch = React__default.useRef();
10295
+ const _forceReset = React__default.useRef(false);
10296
+ const loadPage = function (pageIndex, sorting, filters, search) {
10297
+ try {
10298
+ let reset = false;
10299
+ // sorting or filters changed, reset everything
10300
+ if (_forceReset.current || search !== _lastUsedSearch.current || JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)) {
10301
+ _pendingPageRequests.current = {};
10302
+ // nuke the dataset so that we "start again" after sorting
10303
+ reset = true;
10304
+ }
10305
+ if (_pendingPageRequests.current[pageIndex]) {
10306
+ // if page is already loaded/loading, abort, otherwise mark it as loading
10307
+ return Promise.resolve();
10308
+ } else {
10309
+ _pendingPageRequests.current[pageIndex] = true;
10310
+ }
10311
+ _forceReset.current = false;
10312
+ // set the sorting so we can track if it changed between loads
10313
+ _lastUsedSorting.current = sorting;
10314
+ // set the filters so we can track if it changed between loads
10315
+ _lastUsedFilters.current = filters;
10316
+ // set the search so we can track if it changed between loads
10317
+ _lastUsedSearch.current = search;
10318
+ const _temp = _finallyRethrows(function () {
10319
+ return _catch(function () {
10320
+ return Promise.resolve(fetch(pageIndex, pageSize, sorting, filters, search)).then(function (response) {
10321
+ // update state, here we do some "magic" to support "load in place"
10322
+ setData(currentData => {
10323
+ let nextData;
10324
+ // reset table state if:
10325
+ // - the length isn't set at all (first load)
10326
+ // - the client length and server length are different (the data changed)
10327
+ if (reset || length.current !== response.length) {
10328
+ length.current = response.length;
10329
+ nextData = Array(length.current).fill(undefined);
10330
+ } else {
10331
+ nextData = [...currentData];
10332
+ }
10333
+ const startIndex = pageIndex * pageSize;
10334
+ nextData.splice(startIndex, pageSize, ...response.data);
10335
+ return nextData;
10336
+ });
10337
+ });
10338
+ }, function () {});
10339
+ }, function (_wasThrown, _result) {
10340
+ _pendingPageRequests.current[pageIndex] = false;
10341
+ if (_wasThrown) throw _result;
10342
+ return _result;
10343
+ });
10344
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
10345
+ } catch (e) {
10346
+ return Promise.reject(e);
10347
+ }
10348
+ };
10349
+ const loadAll = function (sorting, filters, search) {
10350
+ try {
10351
+ const _temp2 = _catch(function () {
10352
+ return Promise.resolve(fetchAll(sorting, filters, search)).then(function (response) {
10353
+ length.current = response.length;
10354
+ setData(() => {
10355
+ let nextData;
10356
+ if (response.data.length !== response.length) {
10357
+ nextData = Array(response.length).fill(undefined);
10358
+ nextData.splice(0, response.data.length, ...response.data);
10359
+ } else {
10360
+ nextData = [...response.data];
10361
+ }
10362
+ return nextData;
10363
+ });
10364
+ });
10365
+ }, function () {});
10366
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
10367
+ } catch (e) {
10368
+ return Promise.reject(e);
10369
+ }
10370
+ };
10371
+ const invalidate = function () {
10372
+ try {
10373
+ _forceReset.current = true;
10374
+ return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, _lastUsedSearch.current);
10375
+ } catch (e) {
10376
+ return Promise.reject(e);
10377
+ }
10378
+ };
10379
+ // we reset the page to 0 whenever sorting, filtering or search changes
10380
+ const handleSort = function (sorting) {
10381
+ try {
10382
+ return loadPage(0, sorting, _lastUsedFilters.current, _lastUsedSearch.current);
10383
+ } catch (e) {
10384
+ return Promise.reject(e);
10385
+ }
10386
+ };
10387
+ const handleFilter = function (filters) {
10388
+ try {
10389
+ return loadPage(0, _lastUsedSorting.current, filters, _lastUsedSearch.current);
10390
+ } catch (e) {
10391
+ return Promise.reject(e);
10392
+ }
10393
+ };
10394
+ return [{
10395
+ data,
10396
+ length: length.current,
10397
+ loadAll,
10398
+ loadPage,
10399
+ onChangeFilter: handleFilter,
10400
+ onChangeSort: handleSort,
10401
+ pageSize
10402
+ }, invalidate];
10403
+ }
10143
10404
 
10144
10405
  function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
10145
10406
  const isEnabled = !!loadPage && !!loadAll;
@@ -10186,71 +10447,68 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
10186
10447
  };
10187
10448
  }
10188
10449
 
10189
- const useLocalStorage = (key, initialValue) => {
10190
- const [state, setState] = React__default.useState(() => {
10191
- if (!key) {
10192
- return initialValue;
10193
- }
10194
- try {
10195
- const localStorageValue = localStorage.getItem(key);
10196
- if (typeof localStorageValue !== 'string') {
10197
- localStorage.setItem(key, JSON.stringify(initialValue));
10198
- return initialValue;
10199
- } else {
10200
- return JSON.parse(localStorageValue || 'null');
10201
- }
10202
- } catch {
10203
- // If user is in private mode or has storage restriction
10204
- // localStorage can throw. JSON.parse and JSON.stringify
10205
- // can throw, too.
10206
- return initialValue;
10207
- }
10208
- });
10209
- React__default.useEffect(() => {
10210
- if (!key) {
10211
- return;
10212
- }
10213
- try {
10214
- const serializedState = JSON.stringify(state);
10215
- localStorage.setItem(key, serializedState);
10216
- } catch {
10217
- // If user is in private mode or has storage restriction
10218
- // localStorage can throw. Also JSON.stringify can throw.
10219
- }
10220
- }, [key, state]);
10221
- const clear = () => {
10222
- if (key) {
10223
- localStorage.removeItem(key);
10224
- }
10225
- };
10226
- return [state, setState, clear];
10450
+ const DEFAULT_ENABLED_OPTIONS = {
10451
+ columnOrder: true,
10452
+ columnPinning: true,
10453
+ columnSizing: true,
10454
+ columnVisibility: true,
10455
+ excludeUnmatchedRecordsInSearch: true,
10456
+ fontSize: true,
10457
+ grouping: true,
10458
+ rowHeight: true,
10459
+ sorting: true
10227
10460
  };
10228
-
10229
- function useTacoSettings() {
10230
- return React__default.useContext(TacoContext);
10231
- }
10232
-
10233
10461
  function useUniqueTableId(tableId) {
10234
10462
  const tacoSettings = useTacoSettings();
10235
10463
  return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;
10236
10464
  }
10465
+ function useEnabledSettings(isEnabled) {
10466
+ return React__default.useMemo(() => {
10467
+ if (isEnabled === false) {
10468
+ return [Object.keys(DEFAULT_ENABLED_OPTIONS).reduce((o, key) => ({
10469
+ ...o,
10470
+ [key]: false
10471
+ }), {}), false];
10472
+ } else if (isEnabled === true) {
10473
+ return [DEFAULT_ENABLED_OPTIONS, true];
10474
+ }
10475
+ const options = {
10476
+ ...DEFAULT_ENABLED_OPTIONS,
10477
+ ...isEnabled
10478
+ };
10479
+ return [options, Object.values(options).some(o => o === true)];
10480
+ }, [isEnabled]);
10481
+ }
10237
10482
  function useTableSettings(isEnabled = false, id, defaultSettings = {}, onChangeSettings) {
10238
10483
  const uniqueId = useUniqueTableId(id);
10239
- const [persistedSettings, _setPersistedSettings] = useLocalStorage(isEnabled ? uniqueId : undefined, defaultSettings);
10484
+ const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
10485
+ const [persistedSettings, _setPersistedSettings] = useLocalStorage(hasSomeEnabledSettings ? uniqueId : undefined, removeDisabledSettings(defaultSettings, enabledSettings));
10240
10486
  const setPersistedSettings = React__default.useCallback(value => {
10241
- if (!isEnabled) {
10487
+ if (!hasSomeEnabledSettings) {
10242
10488
  return;
10243
10489
  }
10244
- _setPersistedSettings(value);
10490
+ const sanitizedSettings = removeDisabledSettings(value, enabledSettings);
10491
+ _setPersistedSettings(sanitizedSettings);
10245
10492
  if (typeof onChangeSettings === 'function') {
10246
- onChangeSettings(value);
10493
+ onChangeSettings(sanitizedSettings);
10247
10494
  }
10248
- }, [isEnabled, onChangeSettings]);
10249
- if (!isEnabled) {
10495
+ }, [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]);
10496
+ if (!hasSomeEnabledSettings) {
10250
10497
  return [defaultSettings, () => undefined];
10251
10498
  }
10252
10499
  return [persistedSettings, setPersistedSettings];
10253
10500
  }
10501
+ function removeDisabledSettings(settings, enabledSettings) {
10502
+ const sanitizedSettings = {
10503
+ ...settings
10504
+ };
10505
+ Object.keys(enabledSettings).forEach(setting => {
10506
+ if (!enabledSettings[setting]) {
10507
+ delete sanitizedSettings[setting];
10508
+ }
10509
+ });
10510
+ return sanitizedSettings;
10511
+ }
10254
10512
 
10255
10513
  // augments useEffect to not run on the initial mount
10256
10514
  function useLazyEffect(effect, deps) {
@@ -10357,12 +10615,25 @@ function resetHighlightedColumnIndexes(value, table) {
10357
10615
  if (value) {
10358
10616
  const indexes = [];
10359
10617
  const columns = table.getVisibleLeafColumns();
10618
+ const rowGrouping = table.getState().grouping;
10360
10619
  table.getRowModel().rows.forEach((row, rowIndex) => {
10361
10620
  columns.forEach((column, columnIndex) => {
10362
10621
  try {
10363
- if (column.getIsVisible() && column.columnDef.enableGlobalFilter) {
10622
+ let allowSearch = true;
10623
+ if (rowGrouping !== null && rowGrouping !== void 0 && rowGrouping.length) {
10624
+ // if it's the grouped row, only allow search of the grouped column - because that's all that's visible
10625
+ if (row.getIsGrouped()) {
10626
+ allowSearch = column.getIsGrouped();
10627
+ }
10628
+ // otherwise for other rows, don't search the grouped column - because it isn't visible
10629
+ else if (rowGrouping.includes(column.id)) {
10630
+ allowSearch = false;
10631
+ }
10632
+ }
10633
+ if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {
10364
10634
  var _row$original, _column$columnDef$met;
10365
10635
  const cellValue = getCellValueAsString((_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original[column.id], (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.dataType);
10636
+ // indexes don't map to sorted data
10366
10637
  if (cellValue !== undefined && isWeakContains(cellValue, value)) {
10367
10638
  indexes.push([rowIndex, columnIndex]);
10368
10639
  }
@@ -10413,7 +10684,6 @@ function getSettings(table) {
10413
10684
  fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,
10414
10685
  grouping: table.options.enableGrouping ? state.grouping : undefined,
10415
10686
  rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,
10416
- showWarningWhenPrintingLargeDataset: meta.printing.isWarningVisibleForLargeDatasets,
10417
10687
  //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,
10418
10688
  sorting: state.sorting
10419
10689
  };
@@ -10435,7 +10705,7 @@ function useTableSettingsListener(table, onChangeSettings) {
10435
10705
  //state.columnFilters,
10436
10706
  state.columnOrder, state.columnPinning, state.columnSizing, state.columnVisibility,
10437
10707
  // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
10438
- meta.search.excludeUnmatchedResults, meta.fontSize.size, state.grouping, meta.rowHeight.height, meta.printing.isWarningVisibleForLargeDatasets,
10708
+ meta.search.excludeUnmatchedResults, meta.fontSize.size, state.grouping, meta.rowHeight.height,
10439
10709
  //state.globalFilter,
10440
10710
  state.sorting]);
10441
10711
  }
@@ -10525,17 +10795,19 @@ function useTableRef(table, ref) {
10525
10795
  }
10526
10796
 
10527
10797
  function useTable(props, ref, meta, internalColumns) {
10528
- var _props$length, _instance$options$met;
10798
+ var _props$data, _props$length, _instance$options$met;
10799
+ // CSS.escape would be best here, but it doesn't seem to work very well
10800
+ const safeId = props.id.replace('.', '_');
10529
10801
  // configure table options, merging props with presets
10530
10802
  const options = useTableFeaturePreset(props);
10531
10803
  // load any persisted table settings and merge them with any defaults
10532
- const [settings, setSettings] = useTableSettings(options.enableSettings, props.id, props.defaultSettings, props.onChangeSettings);
10804
+ const [settings, setSettings] = useTableSettings(options.enableSaveSettings, safeId, props.defaultSettings, props.onChangeSettings);
10533
10805
  // configure common custom features
10534
10806
  const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);
10535
10807
  const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);
10536
10808
  const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);
10537
10809
  const footer = useTableFooter(options.enableFooter);
10538
- const printing = useTablePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset);
10810
+ const printing = useTablePrinting(options.enablePrinting, safeId);
10539
10811
  const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);
10540
10812
  const rowActions = useTableRowActions(options.enableRowActions, props.rowActions, props.rowActionsLength);
10541
10813
  const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
@@ -10554,10 +10826,13 @@ function useTable(props, ref, meta, internalColumns) {
10554
10826
  } = mapTableChildrenToColumns(props, settings, options, internalColumns);
10555
10827
  // configure initial table state
10556
10828
  const initialState = useReactTableInitialState(props, columns, settings, defaultState);
10829
+ // ensure data is always valid
10830
+ const data = (_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : [];
10831
+ const length = (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : data.length;
10557
10832
  // create a react-table instance
10558
10833
  // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
10559
10834
  const instance = reactTable.useReactTable({
10560
- data: props.data,
10835
+ data,
10561
10836
  columns,
10562
10837
  // configure initial table state
10563
10838
  initialState,
@@ -10573,7 +10848,7 @@ function useTable(props, ref, meta, internalColumns) {
10573
10848
  columnOrdering,
10574
10849
  fontSize,
10575
10850
  footer,
10576
- //getSettings
10851
+ length,
10577
10852
  printing,
10578
10853
  rowActions,
10579
10854
  rowActive,
@@ -10601,8 +10876,8 @@ function useTable(props, ref, meta, internalColumns) {
10601
10876
  // configure ref with reset functions
10602
10877
  useTableRef(instance, ref);
10603
10878
  return {
10879
+ id: safeId,
10604
10880
  instance,
10605
- length: (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : props.data.length,
10606
10881
  meta: (_instance$options$met = instance.options.meta) !== null && _instance$options$met !== void 0 ? _instance$options$met : {},
10607
10882
  state: instance.getState()
10608
10883
  };
@@ -10782,6 +11057,7 @@ function Header$3(context) {
10782
11057
  key: String(`${isAllRowsSelected}_${isSomeRowsSelected}`),
10783
11058
  checked: isAllRowsSelected,
10784
11059
  indeterminate: isSomeRowsSelected,
11060
+ loading: tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading,
10785
11061
  onChange: handleChange
10786
11062
  }));
10787
11063
  }
@@ -10801,6 +11077,9 @@ function Cell$2(context) {
10801
11077
  row,
10802
11078
  table
10803
11079
  } = context;
11080
+ const {
11081
+ rowIndex
11082
+ } = React__default.useContext(RowContext);
10804
11083
  const tableMeta = table.options.meta;
10805
11084
  if (table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
10806
11085
  return null;
@@ -10808,18 +11087,48 @@ function Cell$2(context) {
10808
11087
  const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();
10809
11088
  const title = isSelected ? texts.table3.columns.select.deselect : texts.table3.columns.select.select;
10810
11089
  if (table.options.enableMultiRowSelection) {
10811
- const handleClick = event => {
10812
- event.stopPropagation();
10813
- if (row.getIsGrouped()) {
10814
- row.subRows.forEach(row => row.toggleSelected());
10815
- } else if (event.shiftKey) {
10816
- var _tableMeta$rowSelecti;
10817
- const [fromIndex, toIndex] = toggleBetween((_tableMeta$rowSelecti = tableMeta.rowSelection.lastSelectedRowIndex.current) !== null && _tableMeta$rowSelecti !== void 0 ? _tableMeta$rowSelecti : 0, row.index);
10818
- table.getRowModel().rows.slice(fromIndex, toIndex + 1).forEach(row => row.toggleSelected(true));
10819
- } else {
10820
- row.toggleSelected();
11090
+ const handleClick = function (event) {
11091
+ try {
11092
+ function _temp7() {
11093
+ tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;
11094
+ }
11095
+ event.stopPropagation();
11096
+ const _temp6 = function () {
11097
+ if (row.getIsGrouped()) {
11098
+ row.subRows.forEach(row => row.toggleSelected());
11099
+ } else {
11100
+ const _temp5 = function () {
11101
+ if (event.shiftKey) {
11102
+ var _tableMeta$rowSelecti;
11103
+ function _temp4() {
11104
+ table.setRowSelection(currentRowSelection => ({
11105
+ ...currentRowSelection,
11106
+ ...selectedRows.reduce((state, row) => ({
11107
+ ...state,
11108
+ [row.id]: true
11109
+ }), {})
11110
+ }));
11111
+ }
11112
+ const [fromIndex, toIndex] = toggleBetween((_tableMeta$rowSelecti = tableMeta.rowSelection.lastSelectedRowIndex.current) !== null && _tableMeta$rowSelecti !== void 0 ? _tableMeta$rowSelecti : 0, rowIndex);
11113
+ const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);
11114
+ const _temp3 = function () {
11115
+ if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {
11116
+ // don't pass the search query because we need all data - not filtered data
11117
+ return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, undefined)).then(function () {});
11118
+ }
11119
+ }();
11120
+ return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
11121
+ } else {
11122
+ row.toggleSelected();
11123
+ }
11124
+ }();
11125
+ if (_temp5 && _temp5.then) return _temp5.then(function () {});
11126
+ }
11127
+ }();
11128
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6));
11129
+ } catch (e) {
11130
+ return Promise.reject(e);
10821
11131
  }
10822
- tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;
10823
11132
  };
10824
11133
  return /*#__PURE__*/React__default.createElement(Tooltip, {
10825
11134
  title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, title, /*#__PURE__*/React__default.createElement(Shortcut, {
@@ -10862,7 +11171,7 @@ function useTableRowActiveListener(table, tableRef) {
10862
11171
  const activeRow = (_tableRef$current$que = (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.querySelector('tbody tr[data-row-active="true"]')) !== null && _tableRef$current$que !== void 0 ? _tableRef$current$que : null;
10863
11172
  // if the focused element, or it's parent if it's portalled, aren't in the row, then focus the row
10864
11173
  // this ensures the next tab press starts at the row
10865
- if (!isElementInsideOrTriggeredFromContainer(document.activeElement, activeRow) && !isEventTriggeredOnInteractiveElement(document.activeElement)) {
11174
+ if (!isElementInsideOrTriggeredFromContainer(document.activeElement, activeRow) && !isElementInteractive(document.activeElement)) {
10866
11175
  var _activeRow$focus;
10867
11176
  activeRow === null || activeRow === void 0 ? void 0 : (_activeRow$focus = activeRow.focus) === null || _activeRow$focus === void 0 ? void 0 : _activeRow$focus.call(activeRow, {
10868
11177
  preventScroll: true
@@ -11444,7 +11753,6 @@ function useAugmentedFocusManager() {
11444
11753
  function Body(props) {
11445
11754
  const {
11446
11755
  enableArrowKeyFocusing = false,
11447
- length,
11448
11756
  table,
11449
11757
  ...attributes
11450
11758
  } = props;
@@ -11459,7 +11767,7 @@ function Body(props) {
11459
11767
  }
11460
11768
  if (tableMeta.rowActive.rowActiveIndex !== undefined) {
11461
11769
  const isFirstRow = tableMeta.rowActive.rowActiveIndex === 0;
11462
- const isLastRow = tableMeta.rowActive.rowActiveIndex === length - 1;
11770
+ const isLastRow = tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1;
11463
11771
  if (event.key === 'Tab' || enableArrowKeyFocusing && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
11464
11772
  tableMeta.rowActive.setHoverStatePaused(true);
11465
11773
  const focusedElement = event.shiftKey || event.key === 'ArrowLeft' ? focusManager.focusPrevious() : focusManager.focusNext();
@@ -11497,45 +11805,16 @@ function Body(props) {
11497
11805
  }));
11498
11806
  }
11499
11807
 
11500
- function Footer$3(header) {
11501
- return /*#__PURE__*/React__default.createElement(MemoedFooter, {
11502
- key: header.id,
11503
- footer: header
11504
- });
11505
- }
11506
- const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(props) {
11507
- var _footer$subHeaders, _footer$subHeaders$fi;
11508
- const {
11509
- footer
11510
- } = props;
11511
- const columnMeta = footer.column.columnDef.meta;
11512
- // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers
11513
- const isHeaderGroup = !!((_footer$subHeaders = footer.subHeaders) !== null && _footer$subHeaders !== void 0 && _footer$subHeaders.length);
11514
- const isPinned = isHeaderGroup ? (_footer$subHeaders$fi = footer.subHeaders.find(x => x.column.getIsPinned())) === null || _footer$subHeaders$fi === void 0 ? void 0 : _footer$subHeaders$fi.column.getIsPinned() : footer.column.getIsPinned();
11515
- const style = {};
11516
- if (isPinned) {
11517
- // pinned columns should be offset from either the left or right
11518
- style[isPinned] = `${footer.column.getStart(isPinned) - 1}px`;
11519
- }
11520
- return /*#__PURE__*/React__default.createElement("td", {
11521
- key: footer.id,
11522
- "data-cell-align": columnMeta.align,
11523
- "data-cell-id": footer.id,
11524
- "data-cell-pinned": isPinned ? isPinned : undefined,
11525
- style: style
11526
- }, footer.isPlaceholder ? null : reactTable.flexRender(footer.column.columnDef.footer, footer.getContext()));
11527
- });
11528
-
11529
11808
  function Summary(props) {
11530
11809
  var _table$getState$colum;
11531
11810
  const {
11532
- length,
11533
11811
  table
11534
11812
  } = props;
11535
11813
  const {
11536
11814
  locale,
11537
11815
  texts
11538
11816
  } = useLocalization();
11817
+ const length = table.options.meta.length;
11539
11818
  const currentLength = table.getRowModel().rows.length;
11540
11819
  let label;
11541
11820
  let count;
@@ -11555,11 +11834,51 @@ function Summary(props) {
11555
11834
  count = /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length));
11556
11835
  }
11557
11836
  return /*#__PURE__*/React__default.createElement("div", {
11558
- className: "border-grey-300 sticky z-20 -mt-[2.63rem] ml-px flex h-10 w-fit items-center whitespace-nowrap rounded-bl border-t-2 bg-white px-4 !pr-3",
11837
+ className: "sticky left-0 z-20 flex h-full w-fit items-center whitespace-nowrap bg-white pr-1 shadow-[12px_0px_6px_white]",
11559
11838
  "data-taco": "table2-footer-summary"
11560
11839
  }, label, "\u00A0", count);
11561
11840
  }
11562
11841
 
11842
+ function Footer$3(header) {
11843
+ return /*#__PURE__*/React__default.createElement(MemoedFooter, {
11844
+ key: header.id,
11845
+ footer: header
11846
+ });
11847
+ }
11848
+ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(props) {
11849
+ var _footer$subHeaders, _footer$subHeaders$fi;
11850
+ const {
11851
+ footer
11852
+ } = props;
11853
+ const columnMeta = footer.column.columnDef.meta;
11854
+ // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers
11855
+ const isHeaderGroup = !!((_footer$subHeaders = footer.subHeaders) !== null && _footer$subHeaders !== void 0 && _footer$subHeaders.length);
11856
+ const isPinned = isHeaderGroup ? (_footer$subHeaders$fi = footer.subHeaders.find(x => x.column.getIsPinned())) === null || _footer$subHeaders$fi === void 0 ? void 0 : _footer$subHeaders$fi.column.getIsPinned() : footer.column.getIsPinned();
11857
+ const style = {};
11858
+ if (isPinned) {
11859
+ // pinned columns should be offset from either the left or right
11860
+ style[isPinned] = `${footer.column.getStart(isPinned) - 1}px`;
11861
+ }
11862
+ let content;
11863
+ let align;
11864
+ if (footer.index === 0) {
11865
+ align = 'left';
11866
+ content = /*#__PURE__*/React__default.createElement(Summary, {
11867
+ table: footer.getContext().table
11868
+ });
11869
+ } else {
11870
+ align = columnMeta.align;
11871
+ content = footer.isPlaceholder ? null : reactTable.flexRender(footer.column.columnDef.footer, footer.getContext());
11872
+ }
11873
+ return /*#__PURE__*/React__default.createElement("td", {
11874
+ key: footer.id,
11875
+ "data-cell-align": align,
11876
+ "data-cell-id": footer.id,
11877
+ "data-cell-pinned": isPinned ? isPinned : undefined,
11878
+ style: style
11879
+ }, content);
11880
+ });
11881
+
11563
11882
  const SearchInput2 = /*#__PURE__*/React__default.forwardRef(function SearchInput2(props, ref) {
11564
11883
  var _attributes$ariaLabe, _attributes$placehold;
11565
11884
  const {
@@ -11630,6 +11949,7 @@ const SearchInput2 = /*#__PURE__*/React__default.forwardRef(function SearchInput
11630
11949
  }
11631
11950
  if (event.key === 'Escape') {
11632
11951
  handleClear();
11952
+ event.stopPropagation();
11633
11953
  return;
11634
11954
  }
11635
11955
  };
@@ -12865,6 +13185,7 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
12865
13185
  children,
12866
13186
  onClick,
12867
13187
  tabIndex = 0,
13188
+ fontSize,
12868
13189
  ...otherProps
12869
13190
  } = props;
12870
13191
  const {
@@ -12874,14 +13195,17 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
12874
13195
  open,
12875
13196
  readOnly
12876
13197
  } = useSelect2Context();
12877
- const className = cn('cursor-pointer !px-1 h-fit', getInputClasses({
13198
+ const className = cn('cursor-pointer px-1.5 h-fit', getInputClasses({
12878
13199
  ...props,
12879
13200
  disabled,
12880
13201
  highlighted,
12881
13202
  invalid,
12882
13203
  readOnly
12883
- }).replace('w-full', ''), {
12884
- 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-'))
13204
+ }).replace('w-full', '').replace('px-2', ''), {
13205
+ 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-')),
13206
+ 'text-xs': fontSize === exports.FontSizes.small,
13207
+ 'text-sm': fontSize === exports.FontSizes.medium,
13208
+ 'text-base': fontSize === exports.FontSizes.large
12885
13209
  }, props.className);
12886
13210
  const handleClick = event => {
12887
13211
  if (disabled || readOnly) {
@@ -12975,7 +13299,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
12975
13299
  className
12976
13300
  } = buttonProps;
12977
13301
  if (open) {
12978
- className = cn('!absolute z-20', buttonProps.className);
13302
+ className = cn('!absolute z-20 !h-fit', buttonProps.className);
12979
13303
  content = /*#__PURE__*/React__default.createElement(ScrollArea, {
12980
13304
  className: "my-1 flex max-h-[5.5rem] flex-col"
12981
13305
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -13519,7 +13843,39 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
13519
13843
  (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
13520
13844
  }
13521
13845
  };
13522
- const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none', createCollectionClassName());
13846
+ const selectOptions = searchQuery === '' ? flattenedChildren.map(child => child.key) : filteredChildren.map(child => isGroup(child) ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.key) : child.key).flatMap(c => c) || [];
13847
+ const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option));
13848
+ const selectAllText = React__default.useMemo(() => {
13849
+ if (searchQuery === '') {
13850
+ if (areAllSelected) {
13851
+ return texts.select2.deselectAll;
13852
+ } else {
13853
+ return texts.select2.selectAll;
13854
+ }
13855
+ } else if (areAllSelected) {
13856
+ return texts.select2.deselectAllResults;
13857
+ } else {
13858
+ return texts.select2.selectAllResults;
13859
+ }
13860
+ }, [areAllSelected, searchQuery]);
13861
+ const selectAll = () => {
13862
+ if (!Array.isArray(value) || value.length === 0) {
13863
+ setValue(selectOptions);
13864
+ } else {
13865
+ selectOptions.forEach(child => {
13866
+ !value.includes(child) && setValue(child);
13867
+ });
13868
+ }
13869
+ };
13870
+ const deselectAll = () => {
13871
+ if (searchQuery === '') {
13872
+ setValue([]);
13873
+ } else {
13874
+ const nextValue = Array.isArray(value) && value.filter(subValue => !selectOptions.includes(subValue));
13875
+ setValue(nextValue);
13876
+ }
13877
+ };
13878
+ const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none"', createCollectionClassName());
13523
13879
  return /*#__PURE__*/React__default.createElement(Select2Context.Provider, {
13524
13880
  value: context
13525
13881
  }, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Root, {
@@ -13542,6 +13898,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
13542
13898
  onBlur: handleBlur,
13543
13899
  onKeyDown: handleKeyDown,
13544
13900
  ref: internalRef,
13901
+ fontSize: fontSize,
13545
13902
  placeholder: placeholder
13546
13903
  }), flattenedChildren)), /*#__PURE__*/React__default.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Content, {
13547
13904
  asChild: true,
@@ -13558,11 +13915,17 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
13558
13915
  style: {
13559
13916
  minWidth: dimensions !== null && dimensions !== void 0 && dimensions.width ? `${dimensions.width}px` : undefined
13560
13917
  }
13561
- }, flattenedChildren.length > 0 || onCreate ? ( /*#__PURE__*/React__default.createElement(Search$2, {
13918
+ }, flattenedChildren.length > 0 || onCreate ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Search$2, {
13562
13919
  placeholder: onCreate ? texts.select2.searchOrCreate : texts.select2.search,
13563
13920
  ref: searchRef,
13564
13921
  onTabKeyPress: () => setTabTriggeredClose(true)
13565
- })) : null, flattenedChildren.length <= 0 ? ( /*#__PURE__*/React__default.createElement("div", {
13922
+ }), multiple && selectOptions.length > 1 && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button$1, {
13923
+ className: "!justify-start",
13924
+ appearance: "discrete",
13925
+ onClick: areAllSelected ? deselectAll : selectAll
13926
+ }, selectAllText), /*#__PURE__*/React__default.createElement("div", {
13927
+ className: "border-grey-300 mx-3 rounded border-t"
13928
+ }))))) : null, flattenedChildren.length <= 0 ? ( /*#__PURE__*/React__default.createElement("div", {
13566
13929
  className: "text-grey-700 -mt-0.5 flex h-8 items-center px-2",
13567
13930
  role: "presentation"
13568
13931
  }, "No results found...")) : ( /*#__PURE__*/React__default.createElement(Root$1, {
@@ -13709,6 +14072,12 @@ function Print$1(props) {
13709
14072
  const lastScrollTopRef = React__default.useRef();
13710
14073
  const toast = useToast();
13711
14074
  const tableMeta = table.options.meta;
14075
+ const {
14076
+ allRows,
14077
+ orientation,
14078
+ size,
14079
+ splitGroups
14080
+ } = tableMeta.printing.settings;
13712
14081
  const togglePrinting = React__default.useCallback(enabled => {
13713
14082
  tableMeta.printing.setIsPrinting(enabled);
13714
14083
  if (tableRef.current) {
@@ -13766,10 +14135,6 @@ function Print$1(props) {
13766
14135
  return Promise.reject(e);
13767
14136
  }
13768
14137
  };
13769
- const [orientation, setOrientation] = React__default.useState('portrait');
13770
- const [size, setSize] = React__default.useState('A4');
13771
- const [allRows, setAllRows] = React__default.useState(true);
13772
- const [splitGroups, setSplitGroups] = React__default.useState(true);
13773
14138
  const printStyle = [`@page { size: ${size} ${orientation}; }`];
13774
14139
  if (!allRows) {
13775
14140
  printStyle.push(`table[data-taco='report']#${tableId} tr:not([data-row-selected="true"]) { display: none; }`);
@@ -13795,13 +14160,13 @@ function Print$1(props) {
13795
14160
  table: table,
13796
14161
  onAccept: print,
13797
14162
  orientation: orientation,
13798
- setOrientation: setOrientation,
14163
+ setOrientation: value => tableMeta.printing.setSetting('orientation', value),
13799
14164
  size: size,
13800
- setSize: setSize,
14165
+ setSize: value => tableMeta.printing.setSetting('size', value),
13801
14166
  allRows: allRows,
13802
- setAllRows: setAllRows,
14167
+ setAllRows: value => tableMeta.printing.setSetting('allRows', value),
13803
14168
  splitGroups: splitGroups,
13804
- setSplitGroups: setSplitGroups
14169
+ setSplitGroups: value => tableMeta.printing.setSetting('splitGroups', value)
13805
14170
  }))),
13806
14171
  ref: ref,
13807
14172
  shortcut: shortcut,
@@ -13830,7 +14195,7 @@ function sortByHeader(a, b) {
13830
14195
  return (_a$columnDef$meta = a.columnDef.meta) === null || _a$columnDef$meta === void 0 ? void 0 : (_a$columnDef$meta$hea = _a$columnDef$meta.header) === null || _a$columnDef$meta$hea === void 0 ? void 0 : (_a$columnDef$meta$hea2 = _a$columnDef$meta$hea.localeCompare) === null || _a$columnDef$meta$hea2 === void 0 ? void 0 : _a$columnDef$meta$hea2.call(_a$columnDef$meta$hea, (_b$columnDef$meta = b.columnDef.meta) === null || _b$columnDef$meta === void 0 ? void 0 : _b$columnDef$meta.header);
13831
14196
  }
13832
14197
 
13833
- function FilterColumn(props) {
14198
+ const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
13834
14199
  const {
13835
14200
  allColumns,
13836
14201
  filters,
@@ -13850,7 +14215,8 @@ function FilterColumn(props) {
13850
14215
  warning: warning,
13851
14216
  className: "min-h-[theme(spacing.8)]"
13852
14217
  }, /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
13853
- className: "!w-32 flex-shrink-0",
14218
+ ref: ref,
14219
+ className: "focus:yt-focus !w-32 flex-shrink-0 ",
13854
14220
  emptyValue: null,
13855
14221
  onChange: handleChange,
13856
14222
  value: value
@@ -13868,7 +14234,7 @@ function FilterColumn(props) {
13868
14234
  disabled: column.id !== value && (!column.getCanFilter() || !!filters.find(f => f.id === column.id))
13869
14235
  }, ((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header) + (column.parent ? ` (${(_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : (_column$parent$column = _column$parent.columnDef.meta) === null || _column$parent$column === void 0 ? void 0 : _column$parent$column.header})` : ''));
13870
14236
  }))));
13871
- }
14237
+ });
13872
14238
 
13873
14239
  function FilterComparator(props) {
13874
14240
  const {
@@ -14095,6 +14461,7 @@ function Filter$1(props) {
14095
14461
  texts
14096
14462
  } = useLocalization();
14097
14463
  const column = allColumns.find(c => c.id === filter.id);
14464
+ const ref = React__default.useRef(null);
14098
14465
  const {
14099
14466
  id,
14100
14467
  value: {
@@ -14113,7 +14480,7 @@ function Filter$1(props) {
14113
14480
  comparator: TableFilterComparator.Contains,
14114
14481
  value: undefined
14115
14482
  };
14116
- handleChange(id, {
14483
+ handleChange(position, {
14117
14484
  id: columnId,
14118
14485
  value
14119
14486
  });
@@ -14123,7 +14490,7 @@ function Filter$1(props) {
14123
14490
  if (comparator === TableFilterComparator.IsEmpty || comparator === TableFilterComparator.IsNotEmpty) {
14124
14491
  nextValue = undefined;
14125
14492
  }
14126
- handleChange(id, {
14493
+ handleChange(position, {
14127
14494
  id,
14128
14495
  value: {
14129
14496
  comparator,
@@ -14132,7 +14499,7 @@ function Filter$1(props) {
14132
14499
  });
14133
14500
  };
14134
14501
  const handleChangeValue = value => {
14135
- handleChange(id, {
14502
+ handleChange(position, {
14136
14503
  id,
14137
14504
  value: {
14138
14505
  ...filter.value,
@@ -14140,7 +14507,12 @@ function Filter$1(props) {
14140
14507
  }
14141
14508
  });
14142
14509
  };
14143
- const handleRemove = () => onRemove(id);
14510
+ const handleRemove = () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(position);
14511
+ React__default.useEffect(() => {
14512
+ if (ref.current && !id) {
14513
+ ref.current.focus(); // after adding a new filter placeholder, we want to focus it right way.
14514
+ }
14515
+ }, [id]);
14144
14516
  return /*#__PURE__*/React__default.createElement("div", {
14145
14517
  className: "flex items-start gap-2"
14146
14518
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -14149,7 +14521,8 @@ function Filter$1(props) {
14149
14521
  allColumns: allColumns,
14150
14522
  filters: filters,
14151
14523
  onChange: handleChangeColumn,
14152
- value: id
14524
+ value: id,
14525
+ ref: ref
14153
14526
  }), /*#__PURE__*/React__default.createElement(FilterComparator, {
14154
14527
  column: column,
14155
14528
  onChange: handleChangeComparator,
@@ -14159,46 +14532,21 @@ function Filter$1(props) {
14159
14532
  comparator: comparator,
14160
14533
  onChange: handleChangeValue,
14161
14534
  value: value
14162
- }), /*#__PURE__*/React__default.createElement(IconButton, {
14535
+ }), onRemove ? /*#__PURE__*/React__default.createElement(IconButton, {
14163
14536
  appearance: "discrete",
14164
14537
  className: "ml-auto",
14165
14538
  icon: "close",
14166
14539
  onClick: handleRemove
14167
- }));
14168
- }
14169
-
14170
- function Placeholder(props) {
14171
- const {
14172
- allColumns,
14173
- filters,
14174
- onCreate: handleCreate,
14175
- onRemove: handleRemove,
14176
- position
14177
- } = props;
14178
- const {
14179
- texts
14180
- } = useLocalization();
14181
- return /*#__PURE__*/React__default.createElement("div", {
14182
- className: "flex items-start gap-2"
14183
- }, /*#__PURE__*/React__default.createElement("div", {
14184
- className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
14185
- }, position > 0 ? texts.table3.filters.conditions.and : texts.table3.filters.conditions.where), /*#__PURE__*/React__default.createElement(FilterColumn, {
14186
- allColumns: allColumns,
14187
- filters: filters,
14188
- onChange: handleCreate,
14189
- value: null
14190
- }), /*#__PURE__*/React__default.createElement(FilterComparator, null), /*#__PURE__*/React__default.createElement(Input, {
14191
- "aria-label": texts.table3.filters.emptyFilter.value,
14192
- className: "flex-grow",
14193
- disabled: true,
14194
- value: texts.table3.filters.emptyFilter.value
14195
- }), handleRemove ? /*#__PURE__*/React__default.createElement(IconButton, {
14196
- appearance: "discrete",
14197
- icon: "close",
14198
- onClick: handleRemove
14199
14540
  }) : null);
14200
14541
  }
14201
14542
 
14543
+ const placeholderFilter = {
14544
+ id: '',
14545
+ value: {
14546
+ comparator: TableFilterComparator.Contains,
14547
+ value: undefined
14548
+ }
14549
+ };
14202
14550
  function ManageFiltersPopover(props) {
14203
14551
  const {
14204
14552
  length,
@@ -14212,52 +14560,40 @@ function ManageFiltersPopover(props) {
14212
14560
  const allColumns = table.getAllLeafColumns().filter(column => !isInternalColumn(column.id)).sort(sortByHeader);
14213
14561
  const appliedFilters = table.getState().columnFilters;
14214
14562
  // state, since we "apply" filters - our filter values have a special shape, so we force to our type
14215
- const [filters, setFilters] = React__default.useState(table.getState().columnFilters);
14216
- const [placeholderCount, setPlaceholderCount] = React__default.useState(1);
14563
+ const [filters, setFilters] = React__default.useState(appliedFilters.length ? appliedFilters : [placeholderFilter]);
14217
14564
  // filters might reset from the outside
14218
14565
  React__default.useEffect(() => {
14219
14566
  if (appliedFilters.length === 0) {
14220
- setFilters([]);
14221
- setPlaceholderCount(1);
14567
+ setFilters([placeholderFilter]);
14222
14568
  }
14223
14569
  }, [appliedFilters]);
14224
14570
  // filters
14225
- const handleChangeFilter = (currentId, filter) => {
14571
+ const handleChangeFilter = (position, filter) => {
14226
14572
  setFilters(currentFilters => {
14227
- const nextFilters = [...currentFilters];
14228
- nextFilters[nextFilters.findIndex(f => f.id === currentId)] = filter;
14229
- return nextFilters;
14573
+ return currentFilters.map((current, index) => {
14574
+ if (index === position) {
14575
+ return filter;
14576
+ }
14577
+ return current;
14578
+ });
14230
14579
  });
14231
14580
  };
14232
- const handleRemoveFilter = columnId => {
14233
- if (filters.length === 1 && placeholderCount === 0) {
14234
- setPlaceholderCount(count => count + 1);
14581
+ const handleRemoveFilter = position => {
14582
+ if (filters.length === 1) {
14583
+ setFilters([placeholderFilter]);
14584
+ return;
14235
14585
  }
14236
- setFilters(currentFilters => currentFilters.filter(f => f.id !== columnId));
14237
- };
14238
- // placeholders
14239
- const handleCreateFilterFromPlaceholder = columnId => {
14240
- setFilters(currentFilters => [...currentFilters, {
14241
- id: columnId,
14242
- value: {
14243
- comparator: TableFilterComparator.Contains,
14244
- value: undefined
14245
- }
14246
- }]);
14247
- handleRemovePlaceholder();
14586
+ setFilters(currentFilters => currentFilters.filter((_, index) => index !== position));
14248
14587
  };
14249
- const handleCreatePlaceholder = () => {
14250
- setPlaceholderCount(count => count + 1);
14251
- };
14252
- const handleRemovePlaceholder = () => {
14253
- setPlaceholderCount(count => count - 1);
14588
+ const handleCreate = () => {
14589
+ setFilters(filters.concat(placeholderFilter));
14254
14590
  };
14255
14591
  //
14256
14592
  const handleApply = () => {
14257
14593
  table.setColumnFilters(() => {
14258
14594
  const newFilters = filters.filter(f => {
14259
14595
  var _allColumns$find, _allColumns$find$colu;
14260
- if (f.id === null) {
14596
+ if (f.id === null || f.id === '') {
14261
14597
  return false;
14262
14598
  }
14263
14599
  const controlRenderer = (_allColumns$find = allColumns.find(c => c.id === f.id)) === null || _allColumns$find === void 0 ? void 0 : (_allColumns$find$colu = _allColumns$find.columnDef.meta) === null || _allColumns$find$colu === void 0 ? void 0 : _allColumns$find$colu.control;
@@ -14271,12 +14607,10 @@ function ManageFiltersPopover(props) {
14271
14607
  };
14272
14608
  const handleClear = () => {
14273
14609
  table.resetColumnFilters();
14274
- setFilters([]);
14275
- setPlaceholderCount(1);
14610
+ setFilters([placeholderFilter]);
14276
14611
  };
14277
14612
  const handleClose = () => {
14278
- setFilters(appliedFilters);
14279
- setPlaceholderCount(appliedFilters.length ? 0 : 1);
14613
+ setFilters(appliedFilters.length === 0 ? [placeholderFilter] : appliedFilters);
14280
14614
  };
14281
14615
  return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
14282
14616
  onChange: handleClose
@@ -14299,19 +14633,12 @@ function ManageFiltersPopover(props) {
14299
14633
  filters: filters,
14300
14634
  position: index,
14301
14635
  onChange: handleChangeFilter,
14302
- onRemove: handleRemoveFilter
14303
- }))), [...Array(placeholderCount)].map((_, index) => ( /*#__PURE__*/React__default.createElement(Placeholder, {
14304
- key: `placeholder_${index}`,
14305
- allColumns: allColumns,
14306
- filters: filters,
14307
- position: filters.length + index,
14308
- onCreate: handleCreateFilterFromPlaceholder,
14309
- onRemove: placeholderCount > 1 || filters.length > 0 ? handleRemovePlaceholder : undefined
14636
+ onRemove: filters.length > 0 && filters.some(f => f.id) || filters.length > 1 ? handleRemoveFilter : undefined
14310
14637
  }))), /*#__PURE__*/React__default.createElement("div", {
14311
14638
  className: "justify-start"
14312
14639
  }, /*#__PURE__*/React__default.createElement(Button$1, {
14313
14640
  appearance: "discrete",
14314
- onClick: handleCreatePlaceholder
14641
+ onClick: handleCreate
14315
14642
  }, "+ ", texts.table3.filters.buttons.addFilter))), /*#__PURE__*/React__default.createElement(Group, {
14316
14643
  className: "ml-auto"
14317
14644
  }, /*#__PURE__*/React__default.createElement(Popover.Close, null, /*#__PURE__*/React__default.createElement(Button$1, null, "Cancel")), /*#__PURE__*/React__default.createElement(Button$1, {
@@ -14420,7 +14747,8 @@ function useCssGridStylesheet(tableId, table, fontSize) {
14420
14747
  const allVisibleColumns = table.getVisibleLeafColumns();
14421
14748
  const columnSizing = table.getState().columnSizing;
14422
14749
  const globalMinSize = getCellMinWidth(fontSize);
14423
- const gridTemplateRows = 'min-content 1fr min-content'; // header body footer;
14750
+ // header body ?footer
14751
+ const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';
14424
14752
  return React__default.useMemo(() => {
14425
14753
  let printGridTemplateColumns = '';
14426
14754
  const printHiddenColumns = [];
@@ -14438,12 +14766,15 @@ function useCssGridStylesheet(tableId, table, fontSize) {
14438
14766
  size = `minmax(${minWidth}px, auto)`;
14439
14767
  } else if (width !== undefined) {
14440
14768
  const isLastColumn = index === allVisibleColumns.length - 1;
14441
- if (isLastColumn) {
14442
- size = `minmax(${minSize}px, auto)`;
14443
- } else if (width === 'grow' || Number.isNaN(width)) {
14769
+ if (width === 'grow' || Number.isNaN(width) && !isLastColumn) {
14444
14770
  size = `minmax(${minSize}px, 1fr)`;
14445
14771
  } else {
14446
- size = `${width < minSize ? minSize : width}px`;
14772
+ const minWidth = width < minSize ? minSize : width;
14773
+ if (isLastColumn) {
14774
+ size = `minmax(${minWidth}px, auto)`;
14775
+ } else {
14776
+ size = `${minWidth}px`;
14777
+ }
14447
14778
  }
14448
14779
  } else {
14449
14780
  size = `minmax(${minSize}px, auto)`;
@@ -14460,7 +14791,7 @@ function useCssGridStylesheet(tableId, table, fontSize) {
14460
14791
  // we have to be specific so that nested tables don't inherit the same css
14461
14792
  const hiddenColumns = printHiddenColumns.map(id => `table[data-taco='report']#${tableId} > thead > tr > th[data-cell-id='${id}']\n,table[data-taco='report']#${tableId} > tbody > tr > td[data-cell-id='${id}']\n`).join(',');
14462
14793
  return `table[data-taco='report']#${tableId} { grid-template-columns: ${gridTemplateColumns}; grid-template-rows: ${gridTemplateRows}; }
14463
- @media print { table[data-taco='report']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns} { display: none; } }`;
14794
+ @media print { table[data-taco='report']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''} }`;
14464
14795
  }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);
14465
14796
  }
14466
14797
 
@@ -14658,7 +14989,10 @@ function getCellAttributes(cell, isHighlighted) {
14658
14989
  }
14659
14990
  return attributes;
14660
14991
  }
14661
- function useSearchHighlighting(cell, index, ref) {
14992
+ function useSearchHighlighting(cell, cellIndex, ref) {
14993
+ const {
14994
+ rowIndex
14995
+ } = React__default.useContext(RowContext);
14662
14996
  const context = cell.getContext();
14663
14997
  const tableMeta = context.table.options.meta;
14664
14998
  const columnMeta = cell.column.columnDef.meta;
@@ -14674,7 +15008,7 @@ function useSearchHighlighting(cell, index, ref) {
14674
15008
  return undefined;
14675
15009
  }
14676
15010
  const [rowActiveIndex, currentColumnIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];
14677
- if (rowActiveIndex === cell.row.index && currentColumnIndex === index) {
15011
+ if (rowActiveIndex === rowIndex && currentColumnIndex === cellIndex) {
14678
15012
  return 'current';
14679
15013
  }
14680
15014
  return true;
@@ -15067,16 +15401,8 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
15067
15401
  const rows = table.getRowModel().rows;
15068
15402
  React__default.useEffect(() => {
15069
15403
  const handleKeyDown = event => {
15070
- const target = event.target;
15071
- const dialog = target.closest('[role="dialog"]');
15072
- //const eventOriginatedFromCombobox = !!target.closest('[role="combobox"]');
15073
- // Don't trigger global shortcuts on the table if event originated from a combobox or if table is
15074
- // outside the dialog
15075
- if (
15076
- //eventOriginatedFromCombobox ||
15077
- dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(tableRef.current))
15078
- // || tableMeta.shortcutsState.isPaused
15079
- ) {
15404
+ const trigger = event.target;
15405
+ if (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current) || isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current)) {
15080
15406
  return;
15081
15407
  }
15082
15408
  tableMeta.rowActive.handleKeyDown(event, rows.length, scrollToIndex, tableRef);
@@ -15097,6 +15423,20 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
15097
15423
  [tableRef.current, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
15098
15424
  }
15099
15425
 
15426
+ function EmptyStateBody(props) {
15427
+ const {
15428
+ emptyState: Placeholder = null,
15429
+ ...attributes
15430
+ } = props;
15431
+ return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
15432
+ className: "!auto-rows-fr"
15433
+ }), /*#__PURE__*/React__default.createElement("tr", {
15434
+ className: "!auto-rows-fr"
15435
+ }, /*#__PURE__*/React__default.createElement("td", {
15436
+ className: "col-span-full !border-0 !p-0 hover:!bg-white"
15437
+ }, Placeholder ? /*#__PURE__*/React__default.createElement(Placeholder, null) : null)));
15438
+ }
15439
+
15100
15440
  function Column$1(_) {
15101
15441
  return null;
15102
15442
  }
@@ -15104,28 +15444,28 @@ function Group$3(_) {
15104
15444
  return null;
15105
15445
  }
15106
15446
  const Report$1 = /*#__PURE__*/fixedForwardRef(function Report(props, ref) {
15107
- var _report$state$groupin;
15447
+ var _report$state$groupin, _renderer$rows;
15108
15448
  const tableRef = useMergedRef(ref);
15109
15449
  const report = useReport(props, tableRef);
15110
15450
  const renderer = useTableRenderer(report.instance, tableRef, props.defaultRowActiveIndex);
15111
- const stylesheet = useStylesheet(props.id, report.instance);
15451
+ const stylesheet = useStylesheet(report.id, report.instance);
15112
15452
  useTableGlobalShortcuts(report.instance, tableRef, renderer.scrollToIndex);
15113
15453
  const handleFocus = report.meta.rowActive.rowActiveIndex === undefined ? event => {
15114
- report.meta.rowActive.handleFocus(event, report.length, renderer.scrollToIndex);
15454
+ report.meta.rowActive.handleFocus(event, report.meta.length, renderer.scrollToIndex);
15115
15455
  } : undefined;
15116
15456
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, stylesheet, /*#__PURE__*/React__default.createElement(Toolbar, {
15117
15457
  customSettings: props.customSettings,
15118
15458
  left: props.toolbarLeft,
15119
- length: report.length,
15459
+ length: report.meta.length,
15120
15460
  right: props.toolbarRight,
15121
15461
  scrollToIndex: renderer.scrollToIndex,
15122
15462
  table: report.instance,
15123
- tableId: props.id,
15463
+ tableId: report.id,
15124
15464
  tableRef: tableRef
15125
15465
  }), props.toolbarPanel ? /*#__PURE__*/React__default.createElement("div", {
15126
15466
  className: "mb-4"
15127
15467
  }, props.toolbarPanel) : undefined, /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", {
15128
- id: props.id,
15468
+ id: report.id,
15129
15469
  "data-taco": "report",
15130
15470
  "data-table-font-size": report.meta.fontSize.size,
15131
15471
  "data-table-horizontally-scrolled": report.meta.columnFreezing.isHorizontallyScrolled ? true : undefined,
@@ -15139,14 +15479,12 @@ const Report$1 = /*#__PURE__*/fixedForwardRef(function Report(props, ref) {
15139
15479
  tabIndex: -1
15140
15480
  }, /*#__PURE__*/React__default.createElement("thead", null, report.instance.getHeaderGroups().map(headerGroup => ( /*#__PURE__*/React__default.createElement("tr", {
15141
15481
  key: headerGroup.id
15142
- }, headerGroup.headers.map(Header$4))))), /*#__PURE__*/React__default.createElement(Body, {
15143
- length: report.length,
15482
+ }, headerGroup.headers.map(Header$4))))), (_renderer$rows = renderer.rows) !== null && _renderer$rows !== void 0 && _renderer$rows.length ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
15144
15483
  table: report.instance,
15145
15484
  style: renderer.style
15146
- }, renderer.rows), report.meta.footer.isEnabled ? ( /*#__PURE__*/React__default.createElement("tfoot", null, /*#__PURE__*/React__default.createElement("tr", null, report.instance.getFooterGroups()[0].headers.map(Footer$3)))) : null), report.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Summary, {
15147
- length: report.length,
15148
- table: report.instance
15149
- }) : null));
15485
+ }, renderer.rows), report.meta.footer.isEnabled ? ( /*#__PURE__*/React__default.createElement("tfoot", null, /*#__PURE__*/React__default.createElement("tr", null, report.instance.getFooterGroups()[0].headers.map(Footer$3)))) : null)) : ( /*#__PURE__*/React__default.createElement(EmptyStateBody, {
15486
+ emptyState: props.emptyState
15487
+ })))));
15150
15488
  });
15151
15489
  Report$1.Column = Column$1;
15152
15490
  Report$1.Group = Group$3;
@@ -17757,7 +18095,9 @@ function useSettingsStateListener(table, onChangeSettings) {
17757
18095
  // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
17758
18096
  meta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility,
17759
18097
  // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
17760
- meta.search.excludeUnmatchedResults, meta.fontSize.size, meta.rowHeight.height, meta.printing.isWarningVisibleForLargeDatasets, state.sorting]);
18098
+ meta.search.excludeUnmatchedResults, meta.fontSize.size, meta.rowHeight.height,
18099
+ // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
18100
+ meta.printing.isWarningVisibleForLargeDatasets, state.sorting]);
17761
18101
  }
17762
18102
 
17763
18103
  var Table3FilterComparator;
@@ -19172,7 +19512,7 @@ function EditingCell(props) {
19172
19512
  }));
19173
19513
  }
19174
19514
  const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
19175
- var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$rowAc, _column$columnDef$met;
19515
+ var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$rowAc, _column$columnDef$met, _column$columnDef$met2;
19176
19516
  const {
19177
19517
  cell,
19178
19518
  column,
@@ -19307,7 +19647,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
19307
19647
  }));
19308
19648
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && !error ? ( /*#__PURE__*/React__default.createElement(Indicator, {
19309
19649
  reason: moveReason,
19310
- columnName: String(cell.column.columnDef.header),
19650
+ columnName: String((_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.header),
19311
19651
  mountNode: mountNode,
19312
19652
  validationErrors: []
19313
19653
  })) : null, /*#__PURE__*/React__default.createElement("div", {
@@ -19436,6 +19776,25 @@ function Header$6(context) {
19436
19776
  const isAllRowsSelected = context.table.getIsAllRowsSelected();
19437
19777
  const isSomeRowsSelected = context.table.getIsSomeRowsSelected();
19438
19778
  const title = isAllRowsSelected ? texts.table3.columns.select.deselectAll : texts.table3.columns.select.selectAll;
19779
+ const tableMeta = context.table.options.meta;
19780
+ const isServerloading = tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading;
19781
+ const isLoadingAll = isAllRowsSelected && isServerloading;
19782
+ const isLoadingPreviousRows = tableMeta.rowSelection.lastSelectedRowIndex !== undefined && isServerloading;
19783
+ const toggleSelectAll = function () {
19784
+ try {
19785
+ const _temp = function () {
19786
+ if (!isServerloading) {
19787
+ var _tableMeta$server, _tableMeta$server$loa;
19788
+ return Promise.resolve((_tableMeta$server = tableMeta.server) === null || _tableMeta$server === void 0 ? void 0 : (_tableMeta$server$loa = _tableMeta$server.loadAllIfNeeded) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, context.table.getState().sorting, context.table.getState().columnFilters, undefined)).then(function () {
19789
+ context.table.toggleAllRowsSelected(!isAllRowsSelected);
19790
+ });
19791
+ }
19792
+ }();
19793
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
19794
+ } catch (e) {
19795
+ return Promise.reject(e);
19796
+ }
19797
+ };
19439
19798
  return /*#__PURE__*/React__default.createElement(Header$5, Object.assign({}, context), /*#__PURE__*/React__default.createElement(Tooltip, {
19440
19799
  title: title
19441
19800
  }, /*#__PURE__*/React__default.createElement(Checkbox, {
@@ -19444,8 +19803,9 @@ function Header$6(context) {
19444
19803
  key: String(`${isAllRowsSelected}_${isSomeRowsSelected}`),
19445
19804
  checked: isAllRowsSelected,
19446
19805
  indeterminate: isSomeRowsSelected,
19447
- onChange: context.table.toggleAllRowsSelected,
19448
- tabIndex: -1
19806
+ onChange: toggleSelectAll,
19807
+ tabIndex: -1,
19808
+ loading: isLoadingAll || isLoadingPreviousRows
19449
19809
  })));
19450
19810
  } else {
19451
19811
  return /*#__PURE__*/React__default.createElement(Header$5, Object.assign({}, context));
@@ -19467,18 +19827,49 @@ const Cell$7 = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
19467
19827
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
19468
19828
  const isSelected = context.row.getIsSelected();
19469
19829
  const title = isSelected ? texts.table3.columns.select.deselect : texts.table3.columns.select.select;
19470
- if (context.table.options.enableMultiRowSelection) {
19471
- const handleClick = event => {
19472
- event.stopPropagation();
19473
- if (event.shiftKey) {
19474
- var _tableMeta$rowSelecti;
19475
- const [fromIndex, toIndex] = toggleBetween$2((_tableMeta$rowSelecti = tableMeta.rowSelection.lastSelectedRowIndex.current) !== null && _tableMeta$rowSelecti !== void 0 ? _tableMeta$rowSelecti : 0, rowIndex);
19476
- context.table.getRowModel().rows.slice(fromIndex, toIndex + 1).forEach(row => row.toggleSelected(true));
19477
- } else {
19478
- context.row.toggleSelected();
19830
+ const handleCheckboxClick = function (event) {
19831
+ try {
19832
+ function _temp5() {
19833
+ tableMeta.rowSelection.lastSelectedRowIndex.current = rowIndex;
19479
19834
  }
19480
- tableMeta.rowSelection.lastSelectedRowIndex.current = rowIndex;
19481
- };
19835
+ event.stopPropagation();
19836
+ const _temp4 = function () {
19837
+ if (event.shiftKey) {
19838
+ var _tableMeta$rowSelecti;
19839
+ function _temp3() {
19840
+ const currentlySelected = context.table.getSelectedRowModel().rows;
19841
+ // concat currently selected with selection range and get rid of duplicates using "Set".
19842
+ // converting allSelected array into updater object: {[row.id]: true}
19843
+ const allSelected = [...new Set(currentlySelected.concat(selectionRangeRows))];
19844
+ const updater = allSelected.reduce((obj, row) => Object.assign(obj, {
19845
+ [row.id]: true
19846
+ }), {});
19847
+ context.table.setRowSelection(updater);
19848
+ }
19849
+ const [fromIndex, toIndex] = toggleBetween$2((_tableMeta$rowSelecti = tableMeta.rowSelection.lastSelectedRowIndex.current) !== null && _tableMeta$rowSelecti !== void 0 ? _tableMeta$rowSelecti : 0, rowIndex);
19850
+ const selectionRangeRows = context.table.getRowModel().rows.slice(fromIndex, toIndex + 1);
19851
+ // Table data loader filling-in all the rest of unloaded items with the undefined values,
19852
+ // so we can easily check if at least one of the rows in the selection range is undefined,
19853
+ // then it means that we need to call load all.
19854
+ const hasUndefinedRows = selectionRangeRows.some(row => row.original === undefined);
19855
+ const _temp2 = function () {
19856
+ if (hasUndefinedRows) {
19857
+ var _tableMeta$server2, _tableMeta$server2$lo;
19858
+ // We don't need to await and freeze UI
19859
+ return Promise.resolve((_tableMeta$server2 = tableMeta.server) === null || _tableMeta$server2 === void 0 ? void 0 : (_tableMeta$server2$lo = _tableMeta$server2.loadAllIfNeeded) === null || _tableMeta$server2$lo === void 0 ? void 0 : _tableMeta$server2$lo.call(_tableMeta$server2, context.table.getState().sorting, context.table.getState().columnFilters, undefined)).then(function () {});
19860
+ }
19861
+ }();
19862
+ return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
19863
+ } else {
19864
+ context.row.toggleSelected();
19865
+ }
19866
+ }();
19867
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
19868
+ } catch (e) {
19869
+ return Promise.reject(e);
19870
+ }
19871
+ };
19872
+ if (context.table.options.enableMultiRowSelection) {
19482
19873
  return /*#__PURE__*/React__default.createElement(DisplayCell$1, Object.assign({}, context), /*#__PURE__*/React__default.createElement(Tooltip, {
19483
19874
  title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, title, /*#__PURE__*/React__default.createElement(Shortcut, {
19484
19875
  className: "ml-2",
@@ -19488,7 +19879,7 @@ const Cell$7 = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
19488
19879
  "aria-label": title,
19489
19880
  className: "!mt-0",
19490
19881
  checked: isSelected,
19491
- onClick: handleClick,
19882
+ onClick: handleCheckboxClick,
19492
19883
  // this is necessary to remove console spam from eslint
19493
19884
  onChange: () => false,
19494
19885
  tabIndex: isActiveRow ? 0 : -1
@@ -20180,7 +20571,7 @@ function usePauseShortcuts() {
20180
20571
  }
20181
20572
 
20182
20573
  function useTable$2(props, ref) {
20183
- var _settings$columnFreez, _props$length;
20574
+ var _settings$columnFreez, _props$data, _ref, _props$length, _props$data2;
20184
20575
  // load any persisted table settings and merge them with any defaults
20185
20576
  const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);
20186
20577
  // configure table3 options
@@ -20204,6 +20595,12 @@ function useTable$2(props, ref) {
20204
20595
  // haven't migrated load all/server loading yet
20205
20596
  const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
20206
20597
  const shortcutsState = usePauseShortcuts();
20598
+ React__default.useEffect(() => {
20599
+ // Needed for DataDog
20600
+ if (!Array.isArray(props.data)) {
20601
+ console.error('Table3 data value is not an array');
20602
+ }
20603
+ }, []);
20207
20604
  // custom features - shared/migrated
20208
20605
  const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);
20209
20606
  const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);
@@ -20256,7 +20653,8 @@ function useTable$2(props, ref) {
20256
20653
  };
20257
20654
  };
20258
20655
  const table = reactTable.useReactTable({
20259
- data: props.data,
20656
+ // We need to fallback to an empty array, to avoid table crash in the client
20657
+ data: (_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : [],
20260
20658
  columns,
20261
20659
  getCoreRowModel: reactTable.getCoreRowModel(),
20262
20660
  initialState,
@@ -20300,7 +20698,7 @@ function useTable$2(props, ref) {
20300
20698
  useTableSortingListener(table, props.onSort);
20301
20699
  return {
20302
20700
  table,
20303
- length: (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : props.data.length
20701
+ length: (_ref = (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : (_props$data2 = props.data) === null || _props$data2 === void 0 ? void 0 : _props$data2.length) !== null && _ref !== void 0 ? _ref : 0
20304
20702
  };
20305
20703
  }
20306
20704
  function configureReactTableOptions$1(props, options) {
@@ -20784,7 +21182,7 @@ function resetHighlightedColumnIndexes$1(enabled, value, table) {
20784
21182
  return firstRowIndex;
20785
21183
  }
20786
21184
 
20787
- function FilterColumn$1(props) {
21185
+ const FilterColumn$1 = /*#__PURE__*/React__default.forwardRef((props, ref) => {
20788
21186
  const {
20789
21187
  allColumns,
20790
21188
  filters,
@@ -20804,7 +21202,8 @@ function FilterColumn$1(props) {
20804
21202
  warning: warning,
20805
21203
  className: "min-h-[theme(spacing.8)]"
20806
21204
  }, /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
20807
- className: "!w-32 flex-shrink-0",
21205
+ ref: ref,
21206
+ className: "focus:yt-focus !w-32 flex-shrink-0",
20808
21207
  emptyValue: null,
20809
21208
  onChange: handleChange,
20810
21209
  value: value
@@ -20822,7 +21221,7 @@ function FilterColumn$1(props) {
20822
21221
  disabled: column.id !== value && (!column.getCanFilter() || !!filters.find(f => f.id === column.id))
20823
21222
  }, ((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header) + (column.parent ? ` (${(_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : (_column$parent$column = _column$parent.columnDef.meta) === null || _column$parent$column === void 0 ? void 0 : _column$parent$column.header})` : ''));
20824
21223
  }))));
20825
- }
21224
+ });
20826
21225
 
20827
21226
  function FilterComparator$1(props) {
20828
21227
  const {
@@ -20841,7 +21240,7 @@ function FilterComparator$1(props) {
20841
21240
  }
20842
21241
  }, [validComparators]);
20843
21242
  return /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
20844
- className: "!w-32 flex-shrink-0",
21243
+ className: "focus:yt-focus !w-32 flex-shrink-0",
20845
21244
  disabled: !column,
20846
21245
  onChange: handleChange,
20847
21246
  value: value
@@ -20928,38 +21327,6 @@ function getComparatorText$1(comparator, texts, column) {
20928
21327
  }
20929
21328
  }
20930
21329
 
20931
- function Placeholder$1(props) {
20932
- const {
20933
- allColumns,
20934
- filters,
20935
- onCreate: handleCreate,
20936
- onRemove: handleRemove,
20937
- position
20938
- } = props;
20939
- const {
20940
- texts
20941
- } = useLocalization();
20942
- return /*#__PURE__*/React__default.createElement("div", {
20943
- className: "flex items-start gap-2"
20944
- }, /*#__PURE__*/React__default.createElement("div", {
20945
- className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
20946
- }, position > 0 ? texts.table3.filters.conditions.and : texts.table3.filters.conditions.where), /*#__PURE__*/React__default.createElement(FilterColumn$1, {
20947
- allColumns: allColumns,
20948
- filters: filters,
20949
- onChange: handleCreate,
20950
- value: null
20951
- }), /*#__PURE__*/React__default.createElement(FilterComparator$1, null), /*#__PURE__*/React__default.createElement(Input, {
20952
- "aria-label": texts.table3.filters.emptyFilter.value,
20953
- className: "flex-grow",
20954
- disabled: true,
20955
- value: texts.table3.filters.emptyFilter.value
20956
- }), handleRemove ? /*#__PURE__*/React__default.createElement(IconButton, {
20957
- appearance: "discrete",
20958
- icon: "close",
20959
- onClick: handleRemove
20960
- }) : null);
20961
- }
20962
-
20963
21330
  function FilterValue$1(props) {
20964
21331
  const {
20965
21332
  column,
@@ -21080,6 +21447,7 @@ function Filter$2(props) {
21080
21447
  texts
21081
21448
  } = useLocalization();
21082
21449
  const column = allColumns.find(c => c.id === filter.id);
21450
+ const ref = React__default.useRef(null);
21083
21451
  const {
21084
21452
  id,
21085
21453
  value: {
@@ -21098,7 +21466,7 @@ function Filter$2(props) {
21098
21466
  comparator: null,
21099
21467
  value: null
21100
21468
  };
21101
- handleChange(id, {
21469
+ handleChange(position, {
21102
21470
  id: columnId,
21103
21471
  value
21104
21472
  });
@@ -21108,7 +21476,7 @@ function Filter$2(props) {
21108
21476
  if (comparator === Table3FilterComparator.IsEmpty || comparator === Table3FilterComparator.IsNotEmpty) {
21109
21477
  nextValue = undefined;
21110
21478
  }
21111
- handleChange(id, {
21479
+ handleChange(position, {
21112
21480
  id,
21113
21481
  value: {
21114
21482
  comparator,
@@ -21117,7 +21485,7 @@ function Filter$2(props) {
21117
21485
  });
21118
21486
  };
21119
21487
  const handleChangeValue = value => {
21120
- handleChange(id, {
21488
+ handleChange(position, {
21121
21489
  id,
21122
21490
  value: {
21123
21491
  ...filter.value,
@@ -21125,7 +21493,12 @@ function Filter$2(props) {
21125
21493
  }
21126
21494
  });
21127
21495
  };
21128
- const handleRemove = () => onRemove(id);
21496
+ const handleRemove = () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(position);
21497
+ React__default.useEffect(() => {
21498
+ if (ref.current && !id) {
21499
+ ref.current.focus(); // after adding a new filter placeholder, we want to focus it right way.
21500
+ }
21501
+ }, [id]);
21129
21502
  return /*#__PURE__*/React__default.createElement("div", {
21130
21503
  className: "flex items-start gap-2"
21131
21504
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -21134,7 +21507,8 @@ function Filter$2(props) {
21134
21507
  allColumns: allColumns,
21135
21508
  filters: filters,
21136
21509
  onChange: handleChangeColumn,
21137
- value: id
21510
+ value: id,
21511
+ ref: ref
21138
21512
  }), /*#__PURE__*/React__default.createElement(FilterComparator$1, {
21139
21513
  column: column,
21140
21514
  onChange: handleChangeComparator,
@@ -21144,18 +21518,25 @@ function Filter$2(props) {
21144
21518
  comparator: comparator,
21145
21519
  onChange: handleChangeValue,
21146
21520
  value: value
21147
- }), /*#__PURE__*/React__default.createElement(IconButton, {
21521
+ }), onRemove ? /*#__PURE__*/React__default.createElement(IconButton, {
21148
21522
  appearance: "discrete",
21149
21523
  className: "ml-auto",
21150
21524
  icon: "close",
21151
21525
  onClick: handleRemove
21152
- }));
21526
+ }) : null);
21153
21527
  }
21154
21528
 
21155
21529
  function sortByHeader$1(a, b) {
21156
21530
  var _a$columnDef$meta, _a$columnDef$meta$hea, _a$columnDef$meta$hea2, _b$columnDef$meta;
21157
21531
  return (_a$columnDef$meta = a.columnDef.meta) === null || _a$columnDef$meta === void 0 ? void 0 : (_a$columnDef$meta$hea = _a$columnDef$meta.header) === null || _a$columnDef$meta$hea === void 0 ? void 0 : (_a$columnDef$meta$hea2 = _a$columnDef$meta$hea.localeCompare) === null || _a$columnDef$meta$hea2 === void 0 ? void 0 : _a$columnDef$meta$hea2.call(_a$columnDef$meta$hea, (_b$columnDef$meta = b.columnDef.meta) === null || _b$columnDef$meta === void 0 ? void 0 : _b$columnDef$meta.header);
21158
21532
  }
21533
+ const placeholderFilter$1 = {
21534
+ id: null,
21535
+ value: {
21536
+ comparator: Table3FilterComparator.Contains,
21537
+ value: undefined
21538
+ }
21539
+ };
21159
21540
  function FiltersButton(props) {
21160
21541
  const {
21161
21542
  total,
@@ -21175,41 +21556,28 @@ function FiltersButton(props) {
21175
21556
  shift: true
21176
21557
  };
21177
21558
  // state, since we "apply" filters
21178
- const [filters, setFilters] = React__default.useState(appliedFilters);
21179
- const [placeholderCount, setPlaceholderCount] = React__default.useState(1);
21559
+ const [filters, setFilters] = React__default.useState(appliedFilters.length ? appliedFilters : [placeholderFilter$1]);
21180
21560
  // filters
21181
- const handleChangeFilter = (currentId, filter) => {
21561
+ const handleChangeFilter = (position, filter) => {
21182
21562
  setFilters(currentFilters => {
21183
- const nextFilters = [...currentFilters];
21184
- const index = nextFilters.findIndex(f => f.id === currentId);
21185
- nextFilters[index] = filter;
21186
- return nextFilters;
21563
+ return currentFilters.map((current, index) => {
21564
+ if (index === position) {
21565
+ return filter;
21566
+ }
21567
+ return current;
21568
+ });
21187
21569
  });
21188
21570
  };
21189
- const handleRemoveFilter = columnId => {
21190
- if (filters.length === 1 && placeholderCount === 0) {
21191
- setPlaceholderCount(count => count + 1);
21571
+ const handleRemoveFilter = position => {
21572
+ if (filters.length === 1) {
21573
+ setFilters([placeholderFilter$1]);
21574
+ return;
21192
21575
  }
21193
- setFilters(currentFilters => currentFilters.filter(f => f.id !== columnId));
21194
- };
21195
- // placeholders
21196
- const handleCreateFilterFromPlaceholder = columnId => {
21197
- setFilters(currentFilters => [...currentFilters, {
21198
- id: columnId,
21199
- value: {
21200
- comparator: Table3FilterComparator.Contains,
21201
- value: undefined
21202
- }
21203
- }]);
21204
- handleRemovePlaceholder();
21205
- };
21206
- const handleCreatePlaceholder = () => {
21207
- setPlaceholderCount(count => count + 1);
21576
+ setFilters(currentFilters => currentFilters.filter((_, index) => index !== position));
21208
21577
  };
21209
- const handleRemovePlaceholder = () => {
21210
- setPlaceholderCount(count => count - 1);
21578
+ const handleCreateNew = () => {
21579
+ setFilters(filters.concat(placeholderFilter$1));
21211
21580
  };
21212
- //
21213
21581
  const handleApply = () => {
21214
21582
  table.setColumnFilters(() => {
21215
21583
  const newFilters = filters.filter(f => {
@@ -21229,20 +21597,17 @@ function FiltersButton(props) {
21229
21597
  };
21230
21598
  const handleClear = () => {
21231
21599
  table.resetColumnFilters();
21232
- setFilters([]);
21233
- setPlaceholderCount(1);
21600
+ setFilters([placeholderFilter$1]);
21234
21601
  };
21235
21602
  const handleClose = React__default.useCallback(open => {
21236
21603
  if (!open) {
21237
- setFilters(appliedFilters);
21238
- setPlaceholderCount(appliedFilters.length === 0 ? 1 : 0);
21604
+ setFilters(appliedFilters.length === 0 ? [placeholderFilter$1] : appliedFilters);
21239
21605
  }
21240
21606
  }, [appliedFilters]);
21241
21607
  // Because filters can be reset from outside
21242
21608
  React__default.useEffect(() => {
21243
21609
  if (appliedFilters.length === 0) {
21244
- setFilters([]);
21245
- setPlaceholderCount(1);
21610
+ setFilters([placeholderFilter$1]);
21246
21611
  }
21247
21612
  }, [appliedFilters]);
21248
21613
  const buttonProps = {
@@ -21272,19 +21637,12 @@ function FiltersButton(props) {
21272
21637
  filters: filters,
21273
21638
  position: index,
21274
21639
  onChange: handleChangeFilter,
21275
- onRemove: handleRemoveFilter
21276
- }))), [...Array(placeholderCount)].map((_, index) => ( /*#__PURE__*/React__default.createElement(Placeholder$1, {
21277
- key: `placeholder_${index}`,
21278
- allColumns: allColumns,
21279
- filters: filters,
21280
- position: filters.length + index,
21281
- onCreate: handleCreateFilterFromPlaceholder,
21282
- onRemove: placeholderCount > 1 || filters.length > 0 ? handleRemovePlaceholder : undefined
21640
+ onRemove: filters.length > 0 && filters.some(f => f.id) || filters.length > 1 ? handleRemoveFilter : undefined
21283
21641
  }))), /*#__PURE__*/React__default.createElement("div", {
21284
21642
  className: "justify-start"
21285
21643
  }, /*#__PURE__*/React__default.createElement(Button$1, {
21286
21644
  appearance: "discrete",
21287
- onClick: handleCreatePlaceholder
21645
+ onClick: handleCreateNew
21288
21646
  }, "+ ", texts.table3.filters.buttons.addFilter))), /*#__PURE__*/React__default.createElement(Group, {
21289
21647
  className: "ml-auto"
21290
21648
  }, /*#__PURE__*/React__default.createElement(Popover.Close, null, /*#__PURE__*/React__default.createElement(Button$1, null, "Cancel")), /*#__PURE__*/React__default.createElement(Button$1, {
@@ -21634,6 +21992,7 @@ function PrintButton(props) {
21634
21992
  const buttonRef = React__default.useRef(null);
21635
21993
  const tableMeta = table.options.meta;
21636
21994
  const state = table.getState();
21995
+ // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
21637
21996
  const {
21638
21997
  isWarningVisibleForLargeDatasets
21639
21998
  } = tableMeta.printing;
@@ -21812,6 +22171,7 @@ function PrintButton(props) {
21812
22171
  onAccept: handleWarningDialogAccept,
21813
22172
  onClose: handleWarningDialogClose,
21814
22173
  onCancel: handleWarningDialogCancel,
22174
+ // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
21815
22175
  onVisibilityChange: tableMeta.printing.setIsWarningVisibleForLargeDatasets
21816
22176
  }));
21817
22177
  }
@@ -22521,13 +22881,10 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
22521
22881
  }, []);
22522
22882
  React__default.useEffect(() => {
22523
22883
  const handleKeyDown = event => {
22524
- const target = event.target;
22525
- const dialog = target.closest('[role="dialog"]');
22884
+ const trigger = event.target;
22526
22885
  // Select2 also have combobox role to align with W3C guidelines
22527
- const eventOriginatedFromCombobox = !!target.closest('[role="combobox"]:not([data-taco="Select2"])');
22528
- // Don't trigger global shortcuts on the table if event originated from a combobox or if table is
22529
- // outside the dialog
22530
- if (eventOriginatedFromCombobox || dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(internalRef.current)) || tableMeta.shortcutsState.isPaused) {
22886
+ const eventOriginatedFromCombobox = !!trigger.closest('[role="combobox"]:not([data-taco="Select2"])');
22887
+ if (tableMeta.shortcutsState.isPaused || isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, internalRef.current) || isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, internalRef.current) || eventOriginatedFromCombobox) {
22531
22888
  return;
22532
22889
  }
22533
22890
  const rows = table.getRowModel().rows;
@@ -23039,9 +23396,9 @@ const PrimaryNavigation = /*#__PURE__*/React__default.forwardRef(function Primar
23039
23396
  } = useLocalization();
23040
23397
  const internalRef = useMergedRef(ref);
23041
23398
  const className = cn('flex h-full w-full flex-grow items-center overflow-hidden active:outline-none relative', props.className);
23042
- const moreButton = /*#__PURE__*/React__default.createElement(Button$1, {
23399
+ const moreButton = () => ( /*#__PURE__*/React__default.createElement(Button$1, {
23043
23400
  className: cn(getLinkClasses(), '!bg-transparent aria-expanded:!bg-white/[.08]')
23044
- }, texts.header.more);
23401
+ }, texts.header.more));
23045
23402
  return /*#__PURE__*/React__default.createElement("nav", Object.assign({}, props, {
23046
23403
  className: className,
23047
23404
  ref: internalRef
@@ -23651,6 +24008,7 @@ exports.Card = Card;
23651
24008
  exports.Checkbox = Checkbox;
23652
24009
  exports.CollectionPrimitive = Collection;
23653
24010
  exports.Combobox = Combobox;
24011
+ exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
23654
24012
  exports.Datepicker = Datepicker;
23655
24013
  exports.Dialog = Dialog;
23656
24014
  exports.Drawer = Drawer;
@@ -23739,6 +24097,7 @@ exports.useOnClickOutside = useOnClickOutside;
23739
24097
  exports.usePagination = usePagination;
23740
24098
  exports.useRadioGroup = useRadioGroup;
23741
24099
  exports.useTable3DataLoader = useTable3DataLoader;
24100
+ exports.useTableDataLoader = useTableDataLoader;
23742
24101
  exports.useTableRowCreation = useTableRowCreation;
23743
24102
  exports.useToast = useToast;
23744
24103
  //# sourceMappingURL=taco.cjs.development.js.map