@economic/taco 2.54.0 → 2.55.0-settings.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 (81) hide show
  1. package/dist/components/Checkbox/Checkbox.d.ts +7 -2
  2. package/dist/components/List/List.d.ts +2 -2
  3. package/dist/components/List/components/Toggle.d.ts +2 -2
  4. package/dist/components/ModeSwitch/ModeSwitch.d.ts +6 -3
  5. package/dist/components/Provider/Provider.d.ts +7 -6
  6. package/dist/components/Provider/TacoContext.d.ts +7 -0
  7. package/dist/components/Provider/useTacoSettings.d.ts +8 -0
  8. package/dist/components/Report/Report.d.ts +1 -1
  9. package/dist/components/Switch/Switch.d.ts +6 -4
  10. package/dist/esm/index.css +76 -5
  11. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +41 -63
  12. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/List/components/Toggle.js +14 -4
  14. package/dist/esm/packages/taco/src/components/List/components/Toggle.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +6 -3
  16. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +34 -12
  18. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Provider/Provider.js +14 -7
  20. package/dist/esm/packages/taco/src/components/Provider/Provider.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Provider/TacoContext.js +6 -0
  22. package/dist/esm/packages/taco/src/components/Provider/TacoContext.js.map +1 -0
  23. package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js +39 -0
  24. package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js.map +1 -0
  25. package/dist/esm/packages/taco/src/components/Report/Report.js +8 -0
  26. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Switch/Switch.js +37 -35
  28. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Table3/Table3.js +8 -0
  30. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  32. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  33. package/dist/esm/packages/taco/src/hooks/useTaco.js +9 -0
  34. package/dist/esm/packages/taco/src/hooks/useTaco.js.map +1 -0
  35. package/dist/esm/packages/taco/src/index.js +1 -1
  36. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +1 -0
  37. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
  38. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js +6 -4
  39. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js.map +1 -1
  40. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +9 -5
  41. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  42. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  43. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  44. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js +18 -21
  45. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js.map +1 -1
  46. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +2 -2
  47. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
  48. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js +57 -9
  49. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
  50. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +7 -5
  51. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  52. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js +44 -0
  53. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js.map +1 -0
  54. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js +3 -1
  55. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
  56. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +5 -2
  57. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  58. package/dist/hooks/useTaco.d.ts +1 -0
  59. package/dist/index.css +76 -5
  60. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
  61. package/dist/primitives/Table/Core/useTable.d.ts +4 -4
  62. package/dist/primitives/Table/types.d.ts +16 -6
  63. package/dist/primitives/Table/useTableManager/features/useTablePrinting.d.ts +2 -8
  64. package/dist/primitives/Table/useTableManager/features/useTableRowActive.d.ts +2 -2
  65. package/dist/primitives/Table/useTableManager/listeners/useTableSettingsListener.d.ts +2 -2
  66. package/dist/primitives/Table/useTableManager/useTableSettingsPreloader.d.ts +3 -0
  67. package/dist/primitives/Table/useTableManager/util/settings.d.ts +2 -0
  68. package/dist/taco.cjs.development.js +328 -272
  69. package/dist/taco.cjs.development.js.map +1 -1
  70. package/dist/taco.cjs.production.min.js +1 -1
  71. package/dist/taco.cjs.production.min.js.map +1 -1
  72. package/package.json +3 -3
  73. package/dist/esm/packages/taco/src/hooks/useLocalStorage.js +0 -44
  74. package/dist/esm/packages/taco/src/hooks/useLocalStorage.js.map +0 -1
  75. package/dist/esm/packages/taco/src/hooks/useTacoSettings.js +0 -9
  76. package/dist/esm/packages/taco/src/hooks/useTacoSettings.js.map +0 -1
  77. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js +0 -69
  78. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +0 -1
  79. package/dist/hooks/useLocalStorage.d.ts +0 -2
  80. package/dist/hooks/useTacoSettings.d.ts +0 -1
  81. package/dist/primitives/Table/useTableManager/features/useTableSettings.d.ts +0 -3
@@ -11,9 +11,9 @@ var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
11
11
  var AccordionPrimitive = require('@radix-ui/react-accordion');
12
12
  var TooltipPrimitive = require('@radix-ui/react-tooltip');
13
13
  var reactDayPicker = require('react-day-picker');
14
- var CheckboxPrimitive = require('@radix-ui/react-checkbox');
15
- var uuid = require('uuid');
14
+ var reactAriaComponents = require('react-aria-components');
16
15
  var PopoverPrimitive = require('@radix-ui/react-popover');
16
+ var uuid = require('uuid');
17
17
  var debounce$1 = _interopDefault(require('lodash/debounce'));
18
18
  var dateFns = require('date-fns');
19
19
  var DialogPrimitive = require('@radix-ui/react-dialog');
@@ -24,10 +24,10 @@ var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
24
24
  var reactUseControllableState = require('@radix-ui/react-use-controllable-state');
25
25
  var HoverCardPrimitive = require('@radix-ui/react-hover-card');
26
26
  var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
27
- var PrimitiveSwitch = require('@radix-ui/react-switch');
28
27
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
29
28
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
30
29
  var ReactDOM = _interopDefault(require('react-dom'));
30
+ var lodash = require('lodash');
31
31
  var reactTable = require('@tanstack/react-table');
32
32
  var get = _interopDefault(require('lodash/get'));
33
33
  var reactVirtual = require('@tanstack/react-virtual');
@@ -5246,11 +5246,6 @@ const Card = /*#__PURE__*/React.forwardRef(function Card(props, ref) {
5246
5246
  });
5247
5247
  Card.Content = Content$2;
5248
5248
 
5249
- // React 18 has this built-in, when we upgrade this hook should be removed and the uuid dependency should be removed
5250
- const useId = nativeId => {
5251
- return React__default.useMemo(() => nativeId !== null && nativeId !== void 0 ? nativeId : uuid.v4(), []);
5252
- };
5253
-
5254
5249
  const Spinner = /*#__PURE__*/React__default.forwardRef(function Spinner(props, ref) {
5255
5250
  const {
5256
5251
  delay = 350,
@@ -5293,75 +5288,53 @@ const Spinner = /*#__PURE__*/React__default.forwardRef(function Spinner(props, r
5293
5288
  const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
5294
5289
  const {
5295
5290
  checked,
5291
+ className,
5292
+ defaultChecked,
5296
5293
  indeterminate,
5294
+ readOnly,
5297
5295
  invalid,
5298
- label,
5299
- loading,
5296
+ disabled,
5297
+ required,
5300
5298
  onChange,
5299
+ loading,
5300
+ label,
5301
+ onClick,
5301
5302
  ...otherProps
5302
5303
  } = props;
5303
- const id = useId(props.id);
5304
- const className = cn('bg-white h-5 w-5 border rounded text-sm flex-shrink-0 focus-visible:yt-focus disabled:cursor-not-allowed text-white', {
5304
+ // Converts the forwarded ref to an object ref, as required by RAC Checkbox.
5305
+ const inputRef = useMergedRef(ref);
5306
+ const checkboxContainerClassName = cn('group flex justify-center gap-2 data-[disabled]:text-grey-300 data-[disabled]:cursor-not-allowed');
5307
+ // Styling for other complex, state-driven scenarios is managed directly within the styles.css file.
5308
+ const checkboxClassName = cn('bg-white h-5 w-5 border rounded text-sm flex flex-shrink-0 text-white cursor-pointer', {
5305
5309
  'self-start': !!label,
5306
5310
  'mt-[0.1rem]': !label
5307
- }, invalid ? {
5308
- 'border-red-500 hover:border-red-700 aria-checked:border-red-500 aria-checked-mixed:border-red-500 aria-checked:bg-red-500 aria-checked-mixed:bg-red-500 aria-checked:hover:border-red-700 aria-checked-mixed:hover:border-red-700 aria-checked:hover:bg-red-700 aria-checked-mixed:hover:bg-red-700': !props.disabled,
5309
- 'border-red-500/50 aria-checked:wcag-red-500/50 aria-checked-mixed:wcag-red-500/50': props.disabled
5310
- } : {
5311
- 'border-grey-500 hover:border-grey-700 aria-checked:border-blue-500 aria-checked-mixed:border-blue-500 aria-checked:bg-blue-500 aria-checked-mixed:bg-blue-500 aria-checked:hover:border-blue-700 aria-checked-mixed:hover:border-blue-700 aria-checked:hover:bg-blue-700 aria-checked-mixed:hover:bg-blue-700': !props.disabled,
5312
- 'border-grey-500/50 aria-checked:bg-blue-500/50 aria-checked-mixed:bg-blue-500/50': props.disabled
5313
- }, props.className);
5314
- let handleChange;
5315
- if (onChange) {
5316
- handleChange = checked => onChange(checked === 'indeterminate' ? false : checked);
5317
- }
5318
- let labelledByProps = null;
5319
- if (label) {
5320
- labelledByProps = {
5321
- 'aria-labelledby': `${id}-label`,
5322
- id
5323
- };
5324
- }
5325
- // the enter keyboard shortcut isn't supported by default, but we want it
5326
- const handleKeyDown = event => {
5327
- if (event.key === 'Enter') {
5328
- event.currentTarget.click();
5329
- }
5330
- };
5331
- const spinnerClassname = cn(
5332
- //Spinner is slightly bigger then 'line' and 'tick' icons, so making it 2px smaller from each side
5333
- "m-0.5 !h-[calc(100%-theme('spacing.1'))] !w-[calc(100%-theme('spacing.1'))]", {
5334
- 'text-blue-500': !checked && !indeterminate
5335
- });
5336
- const element = /*#__PURE__*/React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, labelledByProps, {
5337
- "aria-invalid": invalid ? 'true' : undefined,
5311
+ }, className);
5312
+ return /*#__PURE__*/React.createElement(reactAriaComponents.Checkbox, Object.assign({}, otherProps, {
5313
+ className: checkboxContainerClassName,
5314
+ "data-taco": "checkbox-container",
5315
+ defaultSelected: defaultChecked,
5316
+ isDisabled: disabled,
5317
+ isIndeterminate: indeterminate,
5318
+ isInvalid: invalid,
5319
+ isRequired: required,
5320
+ isReadOnly: readOnly,
5321
+ isSelected: checked,
5322
+ inputRef: inputRef,
5323
+ onChange: onChange
5324
+ }), ({
5325
+ isIndeterminate,
5326
+ isSelected
5327
+ }) => (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
5328
+ className: checkboxClassName,
5338
5329
  "data-taco": "checkbox",
5339
- checked: indeterminate ? 'indeterminate' : checked,
5340
- className: className,
5341
- onCheckedChange: handleChange,
5342
- onKeyDown: handleKeyDown,
5343
- ref: ref
5344
- }), loading ? (/*#__PURE__*/React.createElement(Spinner, {
5345
- className: spinnerClassname
5346
- })) : (/*#__PURE__*/React.createElement(CheckboxPrimitive.Indicator, {
5347
- className: "flex h-full w-full"
5348
- }, /*#__PURE__*/React.createElement(Icon, {
5349
- name: indeterminate ? 'line' : 'tick',
5330
+ onClick: onClick
5331
+ }, loading ? (/*#__PURE__*/React.createElement(Spinner, {
5332
+ className: "m-0.5 !h-[calc(100%-theme('spacing.1'))] !w-[calc(100%-theme('spacing.1'))] text-blue-500 group-data-[indeterminate]:text-white group-data-[selected]:text-white"
5333
+ })) : (isIndeterminate || isSelected) && (/*#__PURE__*/React.createElement(Icon, {
5334
+ "aria-hidden": true,
5335
+ name: isIndeterminate ? 'line' : 'tick',
5350
5336
  className: "!h-full !w-full"
5351
- }))));
5352
- if (label) {
5353
- const labelContainerClassName = cn('flex items-center cursor-pointer gap-2', {
5354
- 'cursor-not-allowed text-grey-300': props.disabled
5355
- });
5356
- return /*#__PURE__*/React.createElement("span", {
5357
- className: labelContainerClassName,
5358
- "data-taco": "checkbox-container"
5359
- }, element, /*#__PURE__*/React.createElement("label", {
5360
- htmlFor: id,
5361
- id: `${id}-label`
5362
- }, label));
5363
- }
5364
- return element;
5337
+ }))), label)));
5365
5338
  });
5366
5339
  Checkbox.displayName = 'Checkbox';
5367
5340
 
@@ -5799,10 +5772,13 @@ const ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(pro
5799
5772
  // so need to be taken out of screen reader scope.
5800
5773
  , {
5801
5774
  "aria-hidden": true,
5802
- tabIndex: -1,
5775
+ excludeFromTabOrder: true,
5803
5776
  checked: optionProps['aria-selected'],
5804
- onChange: () => null,
5805
- className: "pointer-events-none ml-2 self-center p-px"
5777
+ onChange: () => {
5778
+ var _optionProps$ref, _optionProps$ref$curr;
5779
+ (_optionProps$ref = optionProps.ref) === null || _optionProps$ref === void 0 ? void 0 : (_optionProps$ref$curr = _optionProps$ref.current) === null || _optionProps$ref$curr === void 0 ? void 0 : _optionProps$ref$curr.click();
5780
+ },
5781
+ className: "ml-2 self-center p-px"
5806
5782
  }))))) : (/*#__PURE__*/React.createElement("li", {
5807
5783
  className: "yt-list__empty"
5808
5784
  }, /*#__PURE__*/React.createElement("span", null, texts.listbox.empty))));
@@ -7773,44 +7749,46 @@ const Collapsible = /*#__PURE__*/React__default.forwardRef(function Accordion(pr
7773
7749
 
7774
7750
  const Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
7775
7751
  const {
7752
+ checked,
7753
+ defaultChecked,
7754
+ readOnly,
7776
7755
  label,
7777
7756
  onChange,
7757
+ disabled,
7758
+ onClick,
7759
+ className,
7778
7760
  ...otherProps
7779
7761
  } = props;
7780
- const id = useId(props.id);
7781
- const className = cn('group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus', {
7782
- 'mr-2': !!label,
7783
- 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,
7784
- 'bg-grey-500/50 aria-checked:bg-blue-500/50 cursor-not-allowed': props.disabled
7785
- }, props.className);
7786
- let labelledByProps = null;
7787
- if (label) {
7788
- labelledByProps = {
7789
- 'aria-labelledby': `${id}-label`,
7790
- id
7791
- };
7792
- }
7793
- const element = /*#__PURE__*/React.createElement(PrimitiveSwitch.Root, Object.assign({}, otherProps, labelledByProps, {
7794
- className: className,
7762
+ const inputRef = useMergedRef(ref);
7763
+ const switchContainerClassName = cn('group flex self-start', 'data-[disabled]:text-grey-300 data-[disabled]:cursor-not-allowed');
7764
+ const switchClassName = cn('h-5 w-9 flex flex-shrink-0 rounded-full inline-flex cursor-pointer bg-grey-500', 'group-data-[focus-visible]:yt-focus', {
7765
+ 'mr-2': !!label
7766
+ }, 'group-hover:bg-grey-700',
7767
+ // When switch is selected
7768
+ 'group-data-[selected]:bg-blue-500',
7769
+ // When switch is selected and hovered
7770
+ 'group-hover:group-data-[selected]:bg-blue-700',
7771
+ // When switch is disabled
7772
+ 'group-data-[disabled]:!bg-grey-500/50 group-data-[disabled]:cursor-not-allowed',
7773
+ // When switch is disabled and selected
7774
+ 'group-data-[disabled]:group-data-[selected]:!bg-blue-500/50', className);
7775
+ const switchThumbClassName = cn('pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform', 'group-data-[disabled]:opacity-50', 'group-data-[selected]:translate-x-[1.1rem]');
7776
+ return /*#__PURE__*/React.createElement(reactAriaComponents.Switch, Object.assign({}, otherProps, {
7777
+ className: switchContainerClassName,
7778
+ "data-taco": "switch-container",
7779
+ inputRef: inputRef,
7780
+ isDisabled: disabled,
7781
+ isReadOnly: readOnly,
7782
+ isSelected: checked,
7783
+ defaultSelected: defaultChecked,
7784
+ onChange: onChange
7785
+ }), /*#__PURE__*/React.createElement("span", {
7786
+ className: switchClassName,
7795
7787
  "data-taco": "switch",
7796
- onCheckedChange: onChange,
7797
- ref: ref
7798
- }), /*#__PURE__*/React.createElement(PrimitiveSwitch.Thumb, {
7799
- className: "pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]"
7800
- }));
7801
- if (label) {
7802
- const labelContainerClassName = cn('flex self-start cursor-pointer', {
7803
- 'cursor-not-allowed text-grey-300': props.disabled
7804
- });
7805
- return /*#__PURE__*/React.createElement("span", {
7806
- className: labelContainerClassName,
7807
- "data-taco": "switch-container"
7808
- }, element, /*#__PURE__*/React.createElement("label", {
7809
- htmlFor: id,
7810
- id: `${id}-label`
7811
- }, label));
7812
- }
7813
- return element;
7788
+ onClick: onClick
7789
+ }, /*#__PURE__*/React.createElement("span", {
7790
+ className: switchThumbClassName
7791
+ })), label);
7814
7792
  });
7815
7793
  Switch.displayName = 'Switch';
7816
7794
 
@@ -7868,13 +7846,18 @@ const Switch$1 = /*#__PURE__*/React__default.forwardRef(function Switch$1(props,
7868
7846
  setChecked(!checked);
7869
7847
  onChange(!checked);
7870
7848
  }, [checked, onChange]);
7849
+ const controlClassName = cn(
7850
+ // When ToggleItem is hovered
7851
+ 'group-hover/toggle:bg-grey-700',
7852
+ // When ToggleItem is hovered and switch inside it is selected
7853
+ 'group-hover/toggle:group-data-[selected]:bg-blue-700');
7871
7854
  const control = /*#__PURE__*/React__default.createElement(Switch, {
7872
7855
  checked: checked,
7873
- className: "group-hover/toggle:[&[aria-checked=false]]:bg-grey-700 group-hover/toggle:[&[aria-checked=true]]:bg-blue-700",
7856
+ className: controlClassName,
7874
7857
  disabled: props.disabled,
7875
7858
  onChange: toggle,
7876
7859
  ref: switchRef,
7877
- tabIndex: -1
7860
+ excludeFromTabOrder: true
7878
7861
  });
7879
7862
  return /*#__PURE__*/React__default.createElement(ToggleItem, Object.assign({}, attributes, {
7880
7863
  control: control,
@@ -7895,13 +7878,18 @@ const Checkbox$1 = /*#__PURE__*/React__default.forwardRef(function Switch(props,
7895
7878
  setChecked(!checked);
7896
7879
  onChange(!checked);
7897
7880
  }, [checked, onChange]);
7881
+ const controlClassName = cn(
7882
+ // When ToggleItem is hovered
7883
+ 'group-hover/toggle:border-grey-700',
7884
+ // When ToggleItem is hovered and checkbox inside it is selected
7885
+ 'group-hover/toggle:group-data-[selected]:border-blue-700 group-hover/toggle:group-data-[selected]:bg-blue-700');
7898
7886
  const control = /*#__PURE__*/React__default.createElement(Checkbox, {
7899
7887
  checked: checked,
7900
- className: "group-hover/toggle:[&[aria-checked=false]]:border-grey-700 group-hover/toggle:[&[aria-checked=true]]:border-blue-700 group-hover/checkbox:[&[aria-checked=true]]:bg-blue-700",
7888
+ className: controlClassName,
7901
7889
  disabled: props.disabled,
7902
7890
  onChange: toggle,
7903
7891
  ref: checkboxRef,
7904
- tabIndex: -1
7892
+ excludeFromTabOrder: true
7905
7893
  });
7906
7894
  return /*#__PURE__*/React__default.createElement(ToggleItem, Object.assign({}, attributes, {
7907
7895
  control: control,
@@ -8848,20 +8836,41 @@ Menu$1.SubMenu = SubMenu;
8848
8836
 
8849
8837
  const ModeSwitch = /*#__PURE__*/React.forwardRef(function ModeSwitch(props, ref) {
8850
8838
  const {
8839
+ checked,
8840
+ defaultChecked,
8841
+ readOnly,
8851
8842
  onChange,
8843
+ disabled,
8844
+ className,
8852
8845
  ...otherProps
8853
8846
  } = props;
8854
- const className = cn('group w-14 h-8 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus p-1', {
8855
- 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,
8856
- 'bg-grey-500 aria-checked:bg-blue-500 cursor-not-allowed opacity-50': props.disabled
8857
- }, props.className);
8858
- return /*#__PURE__*/React.createElement(PrimitiveSwitch.Root, Object.assign({}, otherProps, {
8859
- className: className,
8860
- "data-taco": "mode",
8861
- onCheckedChange: onChange,
8862
- ref: ref
8863
- }), /*#__PURE__*/React.createElement(PrimitiveSwitch.Thumb, {
8864
- className: "pointer-events-none flex h-6 w-6 items-center justify-center rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[100%]"
8847
+ const inputRef = useMergedRef(ref);
8848
+ const switchClassName = cn('group w-14 h-8 flex flex-shrink-0 rounded-full inline-flex p-1 cursor-pointer bg-grey-500', 'data-[focus-visible]:yt-focus', 'hover:bg-grey-700',
8849
+ // When modeswitch is selected
8850
+ 'data-[selected]:bg-blue-500',
8851
+ // When modeswitch is selected and hovered
8852
+ 'hover:data-[selected]:bg-blue-700',
8853
+ // When modeswitch is disabled
8854
+ 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[disabled]:bg-grey-500 ',
8855
+ // When modeswitch is disabled and selected
8856
+ 'data-[disabled]:data-[selected]:!bg-blue-500', className);
8857
+ const switchThumbClassName = cn('pointer-events-none flex h-6 w-6 items-center justify-center rounded-full bg-white transition-transform will-change-transform',
8858
+ // When modeswitch is disabled
8859
+ 'group-data-[disabled]:opacity-50',
8860
+ // When modeswitch is selected
8861
+ 'group-data-[selected]:translate-x-full');
8862
+ return /*#__PURE__*/React.createElement(reactAriaComponents.Switch, Object.assign({}, otherProps, {
8863
+ className: switchClassName,
8864
+ defaultSelected: defaultChecked,
8865
+ id: otherProps.id,
8866
+ inputRef: inputRef,
8867
+ isDisabled: disabled,
8868
+ isReadOnly: readOnly,
8869
+ isSelected: checked,
8870
+ onChange: onChange
8871
+ }), /*#__PURE__*/React.createElement("span", {
8872
+ className: switchThumbClassName,
8873
+ "data-taco": "mode"
8865
8874
  }, /*#__PURE__*/React.createElement(Icon, {
8866
8875
  name: "edit-simple",
8867
8876
  className: "pointer-events-none !h-5 !w-5"
@@ -9950,16 +9959,57 @@ const ToastProvider = ({
9950
9959
  };
9951
9960
  const useToast = () => React.useContext(ToastContext);
9952
9961
 
9953
- const TacoContext = /*#__PURE__*/React.createContext({
9954
- uniqueUserIdentifier: ''
9955
- });
9962
+ const TacoContext = /*#__PURE__*/React.createContext({});
9963
+
9964
+ function useTacoSettings(load, save) {
9965
+ const saveSetting = function (path, value) {
9966
+ try {
9967
+ setState(currentState => lodash.setWith(currentState, path, value, Object));
9968
+ return Promise.resolve(save(path, value)); // don't block, since we have local state
9969
+ } catch (e) {
9970
+ return Promise.reject(e);
9971
+ }
9972
+ };
9973
+ const loadSetting = function (path) {
9974
+ try {
9975
+ const currentValue = lodash.get(state, path);
9976
+ if (currentValue) {
9977
+ return Promise.resolve(currentValue);
9978
+ }
9979
+ return Promise.resolve(load(path)).then(function (value) {
9980
+ setState(currentState => lodash.setWith(currentState, path, value, Object));
9981
+ return value;
9982
+ });
9983
+ } catch (e) {
9984
+ return Promise.reject(e);
9985
+ }
9986
+ };
9987
+ const [state, setState] = React.useState({});
9988
+ function getSetting(path) {
9989
+ return lodash.get(state, path);
9990
+ }
9991
+ return {
9992
+ getSetting,
9993
+ loadSetting,
9994
+ saveSetting
9995
+ };
9996
+ }
9997
+
9956
9998
  const Provider = props => {
9957
9999
  const {
9958
10000
  children,
9959
10001
  localization,
9960
- settings
10002
+ loadSetting,
10003
+ saveSetting,
10004
+ userId
9961
10005
  } = props;
9962
- const context = React.useMemo(() => settings, [JSON.stringify(settings)]);
10006
+ const settings = useTacoSettings(loadSetting, saveSetting);
10007
+ const context = React.useMemo(() => {
10008
+ return {
10009
+ settings,
10010
+ userId
10011
+ };
10012
+ }, []);
9963
10013
  return /*#__PURE__*/React.createElement(LocalizationProvider, {
9964
10014
  localization: localization
9965
10015
  }, /*#__PURE__*/React.createElement(TacoContext.Provider, {
@@ -10373,6 +10423,7 @@ function getHiddenColumns(columnVisibility = {}) {
10373
10423
  return Object.keys(columnVisibility).filter(c => columnVisibility[c] === false);
10374
10424
  }
10375
10425
 
10426
+ const getSettingsId = tableId => `table.${tableId.replace('.', '_')}`;
10376
10427
  function getSettings(table) {
10377
10428
  const meta = table.options.meta;
10378
10429
  const state = table.getState();
@@ -10386,6 +10437,7 @@ function getSettings(table) {
10386
10437
  excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,
10387
10438
  fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,
10388
10439
  //grouping: table.options.enableGrouping ? state.grouping : undefined,
10440
+ print: meta.printing.settings,
10389
10441
  rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,
10390
10442
  //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,
10391
10443
  sorting: state.sorting
@@ -10692,8 +10744,11 @@ function useReactTableInitialState(props, columns, persistedSettings, defaults)
10692
10744
  if (columnPinning !== null && columnPinning !== void 0 && (_columnPinning$left = columnPinning.left) !== null && _columnPinning$left !== void 0 && _columnPinning$left.length) {
10693
10745
  columnPinning.left = freezeUptoExternalColumn(columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]), columnOrder);
10694
10746
  } else {
10695
- if (props.defaultColumnFreezingIndex) {
10696
- columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);
10747
+ if (props.defaultColumnFreezingIndex !== undefined) {
10748
+ const index = typeof props.defaultColumnFreezingIndex === 'function' ? props.defaultColumnFreezingIndex(persistedSettings) : props.defaultColumnFreezingIndex;
10749
+ if (index !== undefined) {
10750
+ columnPinning.left = freezeUptoExternalColumn(index, columnOrder);
10751
+ }
10697
10752
  } else {
10698
10753
  columnPinning.left = unfreezeAllExternalColumns(columnOrder);
10699
10754
  }
@@ -10899,53 +10954,28 @@ function useTableFontSize(isEnabled = false, defaultFontSize = 'medium') {
10899
10954
  };
10900
10955
  }
10901
10956
 
10902
- function useTacoSettings() {
10957
+ function useTaco() {
10903
10958
  return React__default.useContext(TacoContext);
10904
10959
  }
10905
10960
 
10906
- const useLocalStorage = (key, initialValue) => {
10907
- const [state, setState] = React__default.useState(() => {
10908
- if (!key) {
10909
- return initialValue;
10910
- }
10911
- try {
10912
- const localStorageValue = localStorage.getItem(key);
10913
- if (typeof localStorageValue !== 'string') {
10914
- localStorage.setItem(key, JSON.stringify(initialValue));
10915
- return initialValue;
10916
- } else {
10917
- return JSON.parse(localStorageValue || 'null');
10918
- }
10919
- } catch {
10920
- // If user is in private mode or has storage restriction
10921
- // localStorage can throw. JSON.parse and JSON.stringify
10922
- // can throw, too.
10923
- return initialValue;
10924
- }
10925
- });
10926
- React__default.useEffect(() => {
10927
- if (!key) {
10928
- return;
10929
- }
10930
- try {
10931
- const serializedState = JSON.stringify(state);
10932
- localStorage.setItem(key, serializedState);
10933
- } catch {
10934
- // If user is in private mode or has storage restriction
10935
- // localStorage can throw. Also JSON.stringify can throw.
10936
- }
10937
- }, [key, state]);
10938
- const clear = () => {
10939
- if (key) {
10940
- localStorage.removeItem(key);
10941
- }
10942
- };
10943
- return [state, setState, clear];
10961
+ const DEFAULT_PRINT_SETTINGS = {
10962
+ size: 'A4',
10963
+ orientation: 'portrait',
10964
+ allRows: true,
10965
+ splitGroups: true
10944
10966
  };
10945
-
10946
10967
  function useTablePrinting(isEnabled = false, tableId) {
10968
+ var _taco$settings$getSet, _taco$settings$getSet2;
10947
10969
  const [isPrinting, setIsPrinting] = React__default.useState(false);
10948
- const [settings, setSetting] = useTablePrintingSettings(tableId);
10970
+ const taco = useTaco();
10971
+ const key = getSettingsId(tableId);
10972
+ const [settings, _setSettings] = React__default.useState((_taco$settings$getSet = (_taco$settings$getSet2 = taco.settings.getSetting(key)) === null || _taco$settings$getSet2 === void 0 ? void 0 : _taco$settings$getSet2.print) !== null && _taco$settings$getSet !== void 0 ? _taco$settings$getSet : DEFAULT_PRINT_SETTINGS);
10973
+ function setSetting(path, value) {
10974
+ _setSettings(currentSettings => ({
10975
+ ...currentSettings,
10976
+ [path]: value
10977
+ }));
10978
+ }
10949
10979
  return {
10950
10980
  isEnabled,
10951
10981
  isPrinting,
@@ -10954,24 +10984,6 @@ function useTablePrinting(isEnabled = false, tableId) {
10954
10984
  setSetting
10955
10985
  };
10956
10986
  }
10957
- const DEFAULT_PRINT_SETTINGS = {
10958
- size: 'A4',
10959
- orientation: 'portrait',
10960
- allRows: true,
10961
- splitGroups: true
10962
- };
10963
- function useTablePrintingSettings(tableId) {
10964
- const tacoSettings = useTacoSettings();
10965
- const uniqueId = `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.print.settings`;
10966
- const [persistedSettings, setPersistedSettings] = useLocalStorage(uniqueId, DEFAULT_PRINT_SETTINGS);
10967
- function setSetting(key, value) {
10968
- setPersistedSettings(currentSettings => ({
10969
- ...currentSettings,
10970
- [key]: value
10971
- }));
10972
- }
10973
- return [persistedSettings, setSetting];
10974
- }
10975
10987
 
10976
10988
  const DEFAULT_ROW_ACTIONS_LENGTH = 4;
10977
10989
  function useTableRowActions(isEnabled = false, rowActions, rowActionsLength = DEFAULT_ROW_ACTIONS_LENGTH) {
@@ -11006,8 +11018,8 @@ const useIsHoverStatePaused = () => {
11006
11018
  return [shouldPauseHoverState, setShouldPauseHoverState];
11007
11019
  };
11008
11020
 
11009
- function useTableRowActive(isEnabled = false, initialRowActiveIndex) {
11010
- const [rowActiveIndex, setRowActiveIndex] = React__default.useState(initialRowActiveIndex);
11021
+ function useTableRowActive(isEnabled = false, tableSettings, initialRowActiveIndex) {
11022
+ const [rowActiveIndex, setRowActiveIndex] = React__default.useState(typeof initialRowActiveIndex === 'function' ? initialRowActiveIndex(tableSettings) : initialRowActiveIndex);
11011
11023
  const [rowHoverIndex, setRowHoverIndex] = React__default.useState(undefined);
11012
11024
  const [isHoverStatePaused, setHoverStatePaused] = useIsHoverStatePaused();
11013
11025
  const move = (direction, length, scrollToIndex) => {
@@ -11641,69 +11653,6 @@ function useTableServerLoading(length, data, loadPage, loadAll, pages, pageSize
11641
11653
  };
11642
11654
  }
11643
11655
 
11644
- const DEFAULT_ENABLED_OPTIONS = {
11645
- columnOrder: true,
11646
- columnPinning: true,
11647
- columnSizing: true,
11648
- columnVisibility: true,
11649
- excludeUnmatchedRecordsInSearch: true,
11650
- fontSize: true,
11651
- grouping: true,
11652
- rowHeight: true,
11653
- sorting: true
11654
- };
11655
- function useUniqueTableId(tableId) {
11656
- const tacoSettings = useTacoSettings();
11657
- return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;
11658
- }
11659
- function useEnabledSettings(isEnabled) {
11660
- return React__default.useMemo(() => {
11661
- if (isEnabled === false) {
11662
- return [Object.keys(DEFAULT_ENABLED_OPTIONS).reduce((o, key) => ({
11663
- ...o,
11664
- [key]: false
11665
- }), {}), false];
11666
- } else if (isEnabled === true) {
11667
- return [DEFAULT_ENABLED_OPTIONS, true];
11668
- }
11669
- const options = {
11670
- ...DEFAULT_ENABLED_OPTIONS,
11671
- ...isEnabled
11672
- };
11673
- return [options, Object.values(options).some(o => o === true)];
11674
- }, [isEnabled]);
11675
- }
11676
- function useTableSettings(isEnabled = false, id, defaultSettings = {}, onChangeSettings) {
11677
- const uniqueId = useUniqueTableId(id);
11678
- const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
11679
- const [persistedSettings, _setPersistedSettings] = useLocalStorage(hasSomeEnabledSettings ? uniqueId : undefined, removeDisabledSettings(defaultSettings, enabledSettings));
11680
- const setPersistedSettings = React__default.useCallback(value => {
11681
- if (!hasSomeEnabledSettings) {
11682
- return;
11683
- }
11684
- const sanitizedSettings = removeDisabledSettings(value, enabledSettings);
11685
- _setPersistedSettings(sanitizedSettings);
11686
- if (typeof onChangeSettings === 'function') {
11687
- onChangeSettings(sanitizedSettings);
11688
- }
11689
- }, [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]);
11690
- if (!hasSomeEnabledSettings) {
11691
- return [defaultSettings, () => undefined];
11692
- }
11693
- return [persistedSettings, setPersistedSettings];
11694
- }
11695
- function removeDisabledSettings(settings, enabledSettings) {
11696
- const sanitizedSettings = {
11697
- ...settings
11698
- };
11699
- Object.keys(enabledSettings).forEach(setting => {
11700
- if (!enabledSettings[setting]) {
11701
- delete sanitizedSettings[setting];
11702
- }
11703
- });
11704
- return sanitizedSettings;
11705
- }
11706
-
11707
11656
  // augments useEffect to not run on the initial mount
11708
11657
  function useLazyEffect(effect, deps) {
11709
11658
  const readyRef = React__default.useRef(false);
@@ -11835,26 +11784,73 @@ function useTableSearchListener(table) {
11835
11784
  }, [meta.server.loading, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, query, JSON.stringify(table.getState().sorting)]);
11836
11785
  }
11837
11786
 
11838
- function useTableSettingsListener(table, onChangeSettings) {
11787
+ function useTableSettingsListener(table, tableId, onChangeSettings, isEnabled = false) {
11788
+ const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
11789
+ const taco = useTaco();
11839
11790
  const meta = table.options.meta;
11840
11791
  const state = table.getState();
11841
11792
  React__default.useEffect(() => {
11842
- let handler;
11843
- if (typeof onChangeSettings === 'function') {
11844
- handler = setTimeout(() => {
11793
+ const handler = setTimeout(() => {
11794
+ if (!hasSomeEnabledSettings) {
11795
+ return;
11796
+ }
11797
+ const settings = removeDisabledSettings(getSettings(table), enabledSettings);
11798
+ if (Object.keys(settings).length) {
11845
11799
  // some settings shouldn't be persisted, but we comment them out here to highlight the intention
11846
- onChangeSettings(getSettings(table));
11847
- }, 250);
11848
- }
11800
+ taco.settings.saveSetting(getSettingsId(tableId), settings);
11801
+ if (onChangeSettings) {
11802
+ onChangeSettings(getSettings(table));
11803
+ }
11804
+ }
11805
+ }, 250);
11849
11806
  return () => clearTimeout(handler);
11850
11807
  }, [
11851
11808
  //state.columnFilters,
11852
11809
  state.columnOrder, state.columnPinning, state.columnSizing, state.columnVisibility, table.options.enableGlobalFilter, meta.fontSize.size,
11853
11810
  //state.grouping,
11854
- meta.rowHeight.height,
11811
+ meta.printing.settings, meta.rowHeight.height,
11855
11812
  //state.globalFilter,
11856
11813
  state.sorting]);
11857
11814
  }
11815
+ const DEFAULT_ENABLED_OPTIONS = {
11816
+ columnOrder: true,
11817
+ columnPinning: true,
11818
+ columnSizing: true,
11819
+ columnVisibility: true,
11820
+ excludeUnmatchedRecordsInSearch: true,
11821
+ fontSize: true,
11822
+ grouping: true,
11823
+ rowHeight: true,
11824
+ sorting: true
11825
+ };
11826
+ function useEnabledSettings(isEnabled) {
11827
+ return React__default.useMemo(() => {
11828
+ if (isEnabled === false) {
11829
+ return [Object.keys(DEFAULT_ENABLED_OPTIONS).reduce((o, key) => ({
11830
+ ...o,
11831
+ [key]: false
11832
+ }), {}), false];
11833
+ } else if (isEnabled === true) {
11834
+ return [DEFAULT_ENABLED_OPTIONS, true];
11835
+ }
11836
+ const options = {
11837
+ ...DEFAULT_ENABLED_OPTIONS,
11838
+ ...isEnabled
11839
+ };
11840
+ return [options, Object.values(options).some(o => o === true)];
11841
+ }, [isEnabled]);
11842
+ }
11843
+ function removeDisabledSettings(settings, enabledSettings) {
11844
+ const sanitizedSettings = {
11845
+ ...settings
11846
+ };
11847
+ Object.keys(enabledSettings).forEach(setting => {
11848
+ if (!enabledSettings[setting]) {
11849
+ delete sanitizedSettings[setting];
11850
+ }
11851
+ });
11852
+ return sanitizedSettings;
11853
+ }
11858
11854
 
11859
11855
  function useTableShortcutsListener(table, shortcuts) {
11860
11856
  const meta = table.options.meta;
@@ -11949,14 +11945,15 @@ function useTableRowDrop(isEnabled = false, onRowDrop) {
11949
11945
  // Placed this array outside the hook to avoid creating a new array reference on each hook re-render
11950
11946
  const DEFAULT_EMPTY_ARRAY = [];
11951
11947
  function useTableManager(props, meta, internalColumns) {
11952
- var _props$data, _props$length, _meta$editing, _instance$options$met;
11948
+ var _ref, _taco$settings$getSet, _props$data, _props$length, _meta$editing, _instance$options$met;
11949
+ const taco = useTaco();
11953
11950
  const localization = useLocalization();
11954
11951
  // CSS.escape would be best here, but it doesn't seem to work very well
11955
11952
  const safeId = props.id.replace('.', '_');
11956
11953
  // configure table options, merging props with presets
11957
11954
  const options = getTableFeaturePreset(props);
11958
11955
  // load any persisted table settings and merge them with any defaults
11959
- const [settings, setSettings] = useTableSettings(options.enableSaveSettings, safeId, props.defaultSettings, props.onChangeSettings);
11956
+ const settings = (_ref = (_taco$settings$getSet = taco.settings.getSetting(getSettingsId(safeId))) !== null && _taco$settings$getSet !== void 0 ? _taco$settings$getSet : props.defaultSettings) !== null && _ref !== void 0 ? _ref : {};
11960
11957
  // ensure data is always valid
11961
11958
  const data = (_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : DEFAULT_EMPTY_ARRAY;
11962
11959
  const length = (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : data.length;
@@ -11966,7 +11963,7 @@ function useTableManager(props, meta, internalColumns) {
11966
11963
  const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);
11967
11964
  const footer = useTableFooter(options.enableFooter);
11968
11965
  const printing = useTablePrinting(options.enablePrinting, safeId);
11969
- const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);
11966
+ const rowActive = useTableRowActive(options.enableRowActive, settings, props.defaultRowActiveIndex);
11970
11967
  const rowActions = useTableRowActions(options.enableRowActions, props.rowActions, props.rowActionsLength);
11971
11968
  const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
11972
11969
  const rowDrag = useTableRowDrag(options.enableRowDrag && !(meta !== null && meta !== void 0 && (_meta$editing = meta.editing) !== null && _meta$editing !== void 0 && _meta$editing.isEditing), props.onRowDrag);
@@ -12031,7 +12028,7 @@ function useTableManager(props, meta, internalColumns) {
12031
12028
  useTableRowSelectionListener(instance, props.onRowSelect);
12032
12029
  useTableSearchListener(instance);
12033
12030
  useTableServerLoadingListener(instance, server.loadPage);
12034
- useTableSettingsListener(instance, setSettings);
12031
+ useTableSettingsListener(instance, safeId, props._DEPRECATED_DO_NOT_USE_onChangeSettings, options.enableSaveSettings);
12035
12032
  useTableShortcutsListener(instance, props.shortcuts);
12036
12033
  useTableSortingListener(instance, props.onChangeSort);
12037
12034
  return {
@@ -12504,11 +12501,14 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
12504
12501
  const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, startValue !== null && startValue !== void 0 ? startValue : 0), Math.max(0, totalSize - ((_virtualItems$end = (_virtualItems = virtualItems[virtualItems.length - 1]) === null || _virtualItems === void 0 ? void 0 : _virtualItems.end) !== null && _virtualItems$end !== void 0 ? _virtualItems$end : 0))] : [0, 0];
12505
12502
  // ensure default active rows are scrolled to
12506
12503
  React__default.useEffect(() => {
12507
- if (defaultRowActiveIndex) {
12508
- scrollToIndex(defaultRowActiveIndex, {
12509
- align: 'center',
12510
- behavior: 'auto'
12511
- });
12504
+ if (defaultRowActiveIndex !== undefined) {
12505
+ const index = typeof defaultRowActiveIndex === 'function' ? defaultRowActiveIndex(getSettings(table)) : defaultRowActiveIndex;
12506
+ if (index !== undefined) {
12507
+ scrollToIndex(index, {
12508
+ align: 'center',
12509
+ behavior: 'auto'
12510
+ });
12511
+ }
12512
12512
  }
12513
12513
  }, []);
12514
12514
  // rendered output
@@ -13872,6 +13872,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
13872
13872
  "data-cell-align": isGroup ? 'center' : align,
13873
13873
  "data-cell-id": id,
13874
13874
  "data-cell-pinned": isPinned ? isPinned : undefined,
13875
+ "data-taco": isGroup ? 'grouped-column-header' : 'column-header',
13875
13876
  style: style,
13876
13877
  ref: setRef
13877
13878
  }), !isPlaceholder ? (/*#__PURE__*/React__default.createElement(HeaderContent, {
@@ -14793,6 +14794,11 @@ function RowHeightMenuItem({
14793
14794
  }, texts.table.rowHeight.sizes.extraTall)));
14794
14795
  }
14795
14796
 
14797
+ // React 18 has this built-in, when we upgrade this hook should be removed and the uuid dependency should be removed
14798
+ const useId = nativeId => {
14799
+ return React__default.useMemo(() => nativeId !== null && nativeId !== void 0 ? nativeId : uuid.v4(), []);
14800
+ };
14801
+
14796
14802
  const isAriaSelectionKey = event => {
14797
14803
  if (event.key === 'Enter' || event.key === ' ' || event.key === 'Tab') {
14798
14804
  return true;
@@ -17184,15 +17190,16 @@ function TableToolbar(props) {
17184
17190
  const canPrint = table.meta.printing.isEnabled;
17185
17191
  const canSettings = canChangeSettings(table.instance, table.props.customSettings);
17186
17192
  const canSearch = table.meta.search.isEnabled;
17193
+ const settings = getSettings(table.instance);
17187
17194
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
17188
17195
  className: "mb-4 flex flex-shrink flex-grow-0 flex-wrap gap-2 print:hidden",
17189
17196
  "data-taco": "table-toolbar"
17190
- }), table.props.toolbarLeft, /*#__PURE__*/React__default.createElement(Group, {
17197
+ }), typeof table.props.toolbarLeft === 'function' ? table.props.toolbarLeft(settings) : table.props.toolbarLeft, /*#__PURE__*/React__default.createElement(Group, {
17191
17198
  className: "ml-auto flex-shrink-0 items-center print:hidden"
17192
17199
  }, customTools, canFilter ? /*#__PURE__*/React__default.createElement(Filters, {
17193
17200
  length: table.meta.length,
17194
17201
  table: table.instance
17195
- }) : null, table.props.toolbarRight, canPrint ? /*#__PURE__*/React__default.createElement(Print$1, {
17202
+ }) : null, typeof table.props.toolbarRight === 'function' ? table.props.toolbarRight(settings) : table.props.toolbarRight, canPrint ? /*#__PURE__*/React__default.createElement(Print$1, {
17196
17203
  table: table.instance,
17197
17204
  tableId: table.id,
17198
17205
  tableRef: table.ref
@@ -17203,9 +17210,9 @@ function TableToolbar(props) {
17203
17210
  scrollToIndex: table.renderer.scrollToIndex,
17204
17211
  table: table.instance,
17205
17212
  tableRef: table.ref
17206
- })) : null)), table.props.toolbarPanel ? /*#__PURE__*/React__default.createElement("div", {
17213
+ })) : null)), table.props.toolbarPanel ? (/*#__PURE__*/React__default.createElement("div", {
17207
17214
  className: "mb-4"
17208
- }, table.props.toolbarPanel) : undefined);
17215
+ }, typeof table.props.toolbarPanel === 'function' ? table.props.toolbarPanel(settings) : table.props.toolbarPanel)) : undefined);
17209
17216
  }
17210
17217
  function canChangeSettings(table, customSettings) {
17211
17218
  const tableMeta = table.options.meta;
@@ -17284,6 +17291,44 @@ function TableGrid(props) {
17284
17291
  }, footerRows) : null)))));
17285
17292
  }
17286
17293
 
17294
+ function getLegacySetting(currentKey) {
17295
+ try {
17296
+ const localStorageValue = localStorage.getItem(currentKey);
17297
+ if (localStorageValue) {
17298
+ const value = JSON.parse(localStorageValue || 'null');
17299
+ if (value !== null) {
17300
+ localStorage.removeItem(currentKey);
17301
+ return value;
17302
+ }
17303
+ }
17304
+ } catch {
17305
+ // If user is in private mode or has storage restriction
17306
+ // localStorage can throw. JSON.parse can throw, too.
17307
+ }
17308
+ return undefined;
17309
+ }
17310
+ function useTableSettingsPreloader(tableId) {
17311
+ const taco = useTaco();
17312
+ const [loading, setLoading] = React__default.useState(true);
17313
+ React__default.useLayoutEffect(() => {
17314
+ const key = getSettingsId(tableId);
17315
+ // migrate legacy settings if they exist, can be removed in the future
17316
+ const legacySettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.settings`);
17317
+ if (legacySettings) {
17318
+ const legacyPrintSettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.print.settings`);
17319
+ taco.settings.saveSetting(key, {
17320
+ ...legacySettings,
17321
+ print: legacyPrintSettings !== null && legacyPrintSettings !== void 0 ? legacyPrintSettings : {}
17322
+ }).finally(() => setLoading(false));
17323
+ } else {
17324
+ taco.settings.loadSetting(key).finally(() => setLoading(false));
17325
+ }
17326
+ }, []);
17327
+ return {
17328
+ loading
17329
+ };
17330
+ }
17331
+
17287
17332
  const Column$1 = () => null;
17288
17333
  Column$1.displayName = 'Table3Column';
17289
17334
  function Group$4(_) {
@@ -17303,6 +17348,12 @@ const Report$1 = /*#__PURE__*/fixedForwardRef(function Report(props, ref) {
17303
17348
  // we force a remount (using key) when the child columns change because there are too many places to add children as an effect
17304
17349
  // this is cheaper from a complexity perspective, and probably performance wise as well
17305
17350
  const key = React__default.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);
17351
+ const {
17352
+ loading
17353
+ } = useTableSettingsPreloader(props.id);
17354
+ if (loading) {
17355
+ return /*#__PURE__*/React__default.createElement(Spinner, null);
17356
+ }
17306
17357
  return /*#__PURE__*/React__default.createElement(BaseReport, Object.assign({}, props, {
17307
17358
  key: key,
17308
17359
  ref: ref
@@ -20684,6 +20735,12 @@ const Table3 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
20684
20735
  // we force a remount (using key) when the child columns change because there are too many places to add children as an effect
20685
20736
  // this is cheaper from a complexity perspective, and probably performance wise as well
20686
20737
  const key = React__default.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);
20738
+ const {
20739
+ loading
20740
+ } = useTableSettingsPreloader(props.id);
20741
+ if (loading) {
20742
+ return /*#__PURE__*/React__default.createElement(Spinner, null);
20743
+ }
20687
20744
  return /*#__PURE__*/React__default.createElement(BaseTable3, Object.assign({}, props, {
20688
20745
  key: key,
20689
20746
  ref: ref
@@ -22720,7 +22777,6 @@ exports.Switch = Switch;
22720
22777
  exports.Table = Table$1;
22721
22778
  exports.Table3 = Table3;
22722
22779
  exports.Tabs = Tabs;
22723
- exports.TacoContext = TacoContext;
22724
22780
  exports.Tag = Tag$1;
22725
22781
  exports.Textarea = Textarea;
22726
22782
  exports.Title = Title$3;