@economic/taco 2.22.1 → 2.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/dist/components/OverflowGroup/OverflowGroup.d.ts +1 -1
  2. package/dist/components/Report/Report.d.ts +2 -0
  3. package/dist/components/Report/components/Body/EmptyStateBody.d.ts +7 -0
  4. package/dist/components/Report/components/Cell/util.d.ts +1 -1
  5. package/dist/components/Report/types.d.ts +2 -0
  6. package/dist/components/Report/useReport.d.ts +1 -0
  7. package/dist/components/Select2/components/Trigger.d.ts +1 -0
  8. package/dist/components/Truncate/Truncate.d.ts +2 -2
  9. package/dist/esm/index.css +73 -75
  10. package/dist/esm/packages/taco/src/components/Card/Card.js +6 -3
  11. package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
  12. package/dist/esm/packages/taco/src/components/Field/Field.js +4 -15
  13. package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
  14. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +2 -2
  15. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js +13 -6
  17. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
  18. package/dist/esm/packages/taco/src/components/Report/Report.js +9 -6
  19. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
  20. package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js +18 -0
  21. package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js.map +1 -0
  22. package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js +6 -2
  23. package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +3 -2
  25. package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -1
  26. package/dist/esm/packages/taco/src/components/Select2/Select2.js +1 -0
  27. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +9 -4
  29. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +2 -2
  31. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  32. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +1 -0
  33. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
  34. package/dist/esm/packages/taco/src/components/Toast/Toaster.js +4 -3
  35. package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +34 -0
  37. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +1 -0
  38. package/dist/esm/packages/taco/src/index.js +1 -0
  39. package/dist/esm/packages/taco/src/index.js.map +1 -1
  40. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  41. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +48 -6
  42. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -1
  43. package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +4 -1
  44. package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -1
  45. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js +5 -5
  46. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js.map +1 -1
  47. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js +14 -1
  48. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js.map +1 -1
  49. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +127 -3
  50. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  51. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +4 -4
  52. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -1
  53. package/dist/index.css +73 -75
  54. package/dist/index.d.ts +1 -0
  55. package/dist/primitives/Table/types.d.ts +13 -1
  56. package/dist/primitives/Table/useTable/features/useTableSettings.d.ts +2 -2
  57. package/dist/primitives/Table/useTable/useTable.d.ts +1 -0
  58. package/dist/taco.cjs.development.js +306 -71
  59. package/dist/taco.cjs.development.js.map +1 -1
  60. package/dist/taco.cjs.production.min.js +1 -1
  61. package/dist/taco.cjs.production.min.js.map +1 -1
  62. package/dist/utils/hooks/useTruncated.d.ts +1 -1
  63. package/package.json +2 -2
  64. package/types.json +8672 -8382
@@ -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');
@@ -4818,6 +4819,49 @@ const Calendar$1 = /*#__PURE__*/React.forwardRef(function Calendar(props, ref) {
4818
4819
  })));
4819
4820
  });
4820
4821
 
4822
+ const isElementTruncated = targetElement => {
4823
+ if (targetElement !== null) {
4824
+ return targetElement.offsetWidth < targetElement.scrollWidth;
4825
+ }
4826
+ return false;
4827
+ };
4828
+ const useTruncated = (element, deps = []) => {
4829
+ const [isTruncated, setIsTruncated] = React__default.useState(isElementTruncated(element));
4830
+ React__default.useEffect(() => {
4831
+ setIsTruncated(isElementTruncated(element));
4832
+ }, [element, ...deps]);
4833
+ return {
4834
+ isTruncated
4835
+ };
4836
+ };
4837
+
4838
+ const Truncate = ({
4839
+ children,
4840
+ tooltip
4841
+ }) => {
4842
+ const ref = React__default.useRef(null);
4843
+ const [mounted, setMounted] = React__default.useState(false);
4844
+ const {
4845
+ isTruncated
4846
+ } = useTruncated(ref.current, [mounted]);
4847
+ React__default.useEffect(() => {
4848
+ setMounted(true);
4849
+ return () => setMounted(false);
4850
+ }, []);
4851
+ const clonedChildrenWithRef = /*#__PURE__*/React__default.cloneElement(React__default.Children.only(children), {
4852
+ ref,
4853
+ className: cn(children.props.className, 'truncate', {
4854
+ 'hover:cursor-pointer': isTruncated
4855
+ })
4856
+ });
4857
+ if (isTruncated) {
4858
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
4859
+ title: tooltip
4860
+ }, clonedChildrenWithRef);
4861
+ }
4862
+ return clonedChildrenWithRef;
4863
+ };
4864
+
4821
4865
  const Content$2 = /*#__PURE__*/React.forwardRef(function CardContent(externalProps, ref) {
4822
4866
  const {
4823
4867
  noPadding,
@@ -4844,9 +4888,11 @@ const Card = /*#__PURE__*/React.forwardRef(function Card(props, ref) {
4844
4888
  ref: ref
4845
4889
  }, /*#__PURE__*/React.createElement("div", {
4846
4890
  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, {
4891
+ }, title && ( /*#__PURE__*/React.createElement(Truncate, {
4892
+ tooltip: title
4893
+ }, /*#__PURE__*/React.createElement("h4", {
4894
+ className: "mb-0 flex-grow truncate text-left"
4895
+ }, title))), menu ? /*#__PURE__*/React.createElement(IconButton, {
4850
4896
  icon: "ellipsis-horizontal",
4851
4897
  appearance: "discrete",
4852
4898
  menu: menu,
@@ -7001,30 +7047,8 @@ Drawer.Close = Close$3;
7001
7047
  Drawer.Actions = Actions;
7002
7048
  Drawer.Outlet = Outlet;
7003
7049
 
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
7050
  const Field = /*#__PURE__*/React.forwardRef(function Field(props, ref) {
7021
- const [showTooltip, setShowTooltip] = React.useState(false);
7022
7051
  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
7052
  const {
7029
7053
  disabled,
7030
7054
  children,
@@ -7042,16 +7066,12 @@ const Field = /*#__PURE__*/React.forwardRef(function Field(props, ref) {
7042
7066
  'text-yellow-700': warning && !invalid,
7043
7067
  'opacity-50': disabled
7044
7068
  });
7045
- const {
7046
- truncated: isMessageTrucated
7047
- } = useTruncated(messageRef.current, [message, showTooltip]);
7048
7069
  return /*#__PURE__*/React.createElement("label", Object.assign({}, otherProps, {
7049
7070
  className: className,
7050
7071
  "data-taco": "label",
7051
7072
  ref: ref
7052
- }), children, message && ( /*#__PURE__*/React.createElement(Tooltip, {
7053
- title: message,
7054
- hide: !isMessageTrucated
7073
+ }), children, message && ( /*#__PURE__*/React.createElement(Truncate, {
7074
+ tooltip: message
7055
7075
  }, /*#__PURE__*/React.createElement("span", {
7056
7076
  className: messageClassName,
7057
7077
  ref: messageRef,
@@ -8421,8 +8441,9 @@ const sanitizeButtonPropsForMenuItem = (button, index) => {
8421
8441
  };
8422
8442
  const DEFAULT_OFFSET = 32 + 8;
8423
8443
  const OverflowGroup = /*#__PURE__*/React__default.forwardRef(function OverflowGroup(props, ref) {
8444
+ var _moreButton;
8424
8445
  const {
8425
- moreButton: MoreButton,
8446
+ moreButton,
8426
8447
  ...attributes
8427
8448
  } = props;
8428
8449
  const internalRef = useMergedRef(ref);
@@ -8432,12 +8453,17 @@ const OverflowGroup = /*#__PURE__*/React__default.forwardRef(function OverflowGr
8432
8453
  var _el$getBoundingClient;
8433
8454
  return setButtonWidth(el === null || el === void 0 ? void 0 : (_el$getBoundingClient = el.getBoundingClientRect()) === null || _el$getBoundingClient === void 0 ? void 0 : _el$getBoundingClient.width);
8434
8455
  }, []);
8435
- const button = MoreButton !== null && MoreButton !== void 0 ? MoreButton : /*#__PURE__*/React__default.createElement(IconButton, {
8436
- icon: "more"
8437
- });
8456
+ const {
8457
+ texts
8458
+ } = useLocalization();
8438
8459
  const intersectedChildIndex = useIntersectionObserver(internalRef, buttonWidth);
8439
8460
  const children = React__default.Children.toArray(props.children);
8440
8461
  const hiddenChildren = intersectedChildIndex !== undefined ? children.slice(intersectedChildIndex) : [];
8462
+ const hiddenChildrenCount = hiddenChildren.length;
8463
+ const moreButtonText = hiddenChildrenCount ? `${hiddenChildrenCount} ${texts.header.more}` : '';
8464
+ const MoreButton = (_moreButton = moreButton === null || moreButton === void 0 ? void 0 : moreButton(moreButtonText)) !== null && _moreButton !== void 0 ? _moreButton : /*#__PURE__*/React__default.createElement(IconButton, {
8465
+ icon: "more"
8466
+ });
8441
8467
  const className = cn('flex overflow-hidden', props.className);
8442
8468
  return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
8443
8469
  className: className,
@@ -8448,8 +8474,8 @@ const OverflowGroup = /*#__PURE__*/React__default.forwardRef(function OverflowGr
8448
8474
  visible: intersectedChildIndex === undefined || index < intersectedChildIndex,
8449
8475
  'invisible order-[100] pointer-events-none': intersectedChildIndex !== undefined && index >= intersectedChildIndex
8450
8476
  })
8451
- })), hiddenChildren.length ? /*#__PURE__*/React__default.cloneElement(button, {
8452
- className: cn('sticky right-0 order-[99]', button.props.className),
8477
+ })), hiddenChildren.length ? /*#__PURE__*/React__default.cloneElement(MoreButton, {
8478
+ className: cn('sticky right-0 order-[99]', MoreButton.props.className),
8453
8479
  'data-observer-ignore': true,
8454
8480
  menu: menuProps => ( /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, null, hiddenChildren.map(sanitizeButtonPropsForMenuItem)))),
8455
8481
  ref: buttonRefCallback
@@ -9141,9 +9167,9 @@ const ToastProvider = ({
9141
9167
  }, []);
9142
9168
  return /*#__PURE__*/React.createElement(ToastContext.Provider, Object.assign({}, props, {
9143
9169
  value: toaster
9144
- }), children, /*#__PURE__*/React.createElement("div", {
9170
+ }), children, /*#__PURE__*/React.createElement(reactPortal.Portal, null, /*#__PURE__*/React.createElement("div", {
9145
9171
  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",
9172
+ 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
9173
  role: "log"
9148
9174
  }, /*#__PURE__*/React.createElement(framerMotion.AnimatePresence, {
9149
9175
  initial: false
@@ -9173,7 +9199,7 @@ const ToastProvider = ({
9173
9199
  }
9174
9200
  }, /*#__PURE__*/React.createElement(Toast, Object.assign({}, toast, {
9175
9201
  onClose: () => handleClose(toast.id)
9176
- }))))))));
9202
+ })))))))));
9177
9203
  };
9178
9204
  const useToast = () => React.useContext(ToastContext);
9179
9205
 
@@ -9726,7 +9752,7 @@ const DEFAULT_PRESET = {
9726
9752
  enableRowClick: false,
9727
9753
  enableRowGoto: false,
9728
9754
  enableRowHeight: false,
9729
- enableSettings: false
9755
+ enableSaveSettings: false
9730
9756
  };
9731
9757
  const presets = {
9732
9758
  lite: {
@@ -9750,7 +9776,7 @@ const presets = {
9750
9776
  enableRowClick: true,
9751
9777
  enableRowGoto: true,
9752
9778
  enableRowHeight: false,
9753
- enableSettings: true
9779
+ enableSaveSettings: true
9754
9780
  },
9755
9781
  complex: {
9756
9782
  // react-table built-in
@@ -9773,11 +9799,11 @@ const presets = {
9773
9799
  enableRowClick: true,
9774
9800
  enableRowGoto: true,
9775
9801
  enableRowHeight: true,
9776
- enableSettings: true
9802
+ enableSaveSettings: true
9777
9803
  }
9778
9804
  };
9779
9805
  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;
9806
+ 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
9807
  const presetOptions = props.preset ? presets[props.preset] : DEFAULT_PRESET;
9782
9808
  const enableRowActions = (_props$enableRowActio = props.enableRowActions) !== null && _props$enableRowActio !== void 0 ? _props$enableRowActio : presetOptions.enableRowActions;
9783
9809
  const enableRowClick = (_props$enableRowClick = props.enableRowClick) !== null && _props$enableRowClick !== void 0 ? _props$enableRowClick : presetOptions.enableRowClick;
@@ -9828,7 +9854,7 @@ function useTableFeaturePreset(props) {
9828
9854
  enableRowClick: enableRowClick && !!props.onRowClick,
9829
9855
  enableRowGoto: enableRowGoto && !!props.onRowGoto,
9830
9856
  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
9857
+ enableSaveSettings: (_props$enableSaveSett = props.enableSaveSettings) !== null && _props$enableSaveSett !== void 0 ? _props$enableSaveSett : presetOptions.enableSaveSettings
9832
9858
  };
9833
9859
  }
9834
9860
 
@@ -10140,6 +10166,130 @@ function _finallyRethrows(body, finalizer) {
10140
10166
  }
10141
10167
 
10142
10168
  const DEFAULT_PAGE_SIZE = 100;
10169
+ function useTableDataLoader(fetch, fetchAll, options = {
10170
+ pageSize: DEFAULT_PAGE_SIZE
10171
+ }) {
10172
+ const {
10173
+ pageSize
10174
+ } = options;
10175
+ // track the data length, we don't know it until the first request
10176
+ const length = React__default.useRef(undefined);
10177
+ // data will be filled after the first request, then we'll update values in place
10178
+ const [data, setData] = React__default.useState([]);
10179
+ // track which pages have been loaded to dedupe requests
10180
+ const _pendingPageRequests = React__default.useRef({});
10181
+ const _lastUsedSorting = React__default.useRef([]);
10182
+ const _lastUsedFilters = React__default.useRef([]);
10183
+ const _lastUsedSearch = React__default.useRef();
10184
+ const _forceReset = React__default.useRef(false);
10185
+ const loadPage = function (pageIndex, sorting, filters, search) {
10186
+ try {
10187
+ let reset = false;
10188
+ // sorting or filters changed, reset everything
10189
+ if (_forceReset.current || search !== _lastUsedSearch.current || JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)) {
10190
+ _pendingPageRequests.current = {};
10191
+ // nuke the dataset so that we "start again" after sorting
10192
+ reset = true;
10193
+ }
10194
+ if (_pendingPageRequests.current[pageIndex]) {
10195
+ // if page is already loaded/loading, abort, otherwise mark it as loading
10196
+ return Promise.resolve();
10197
+ } else {
10198
+ _pendingPageRequests.current[pageIndex] = true;
10199
+ }
10200
+ _forceReset.current = false;
10201
+ // set the sorting so we can track if it changed between loads
10202
+ _lastUsedSorting.current = sorting;
10203
+ // set the filters so we can track if it changed between loads
10204
+ _lastUsedFilters.current = filters;
10205
+ // set the search so we can track if it changed between loads
10206
+ _lastUsedSearch.current = search;
10207
+ const _temp = _finallyRethrows(function () {
10208
+ return _catch(function () {
10209
+ return Promise.resolve(fetch(pageIndex, pageSize, sorting, filters, search)).then(function (response) {
10210
+ // update state, here we do some "magic" to support "load in place"
10211
+ setData(currentData => {
10212
+ let nextData;
10213
+ // reset table state if:
10214
+ // - the length isn't set at all (first load)
10215
+ // - the client length and server length are different (the data changed)
10216
+ if (reset || length.current !== response.length) {
10217
+ length.current = response.length;
10218
+ nextData = Array(length.current).fill(undefined);
10219
+ } else {
10220
+ nextData = [...currentData];
10221
+ }
10222
+ const startIndex = pageIndex * pageSize;
10223
+ nextData.splice(startIndex, pageSize, ...response.data);
10224
+ return nextData;
10225
+ });
10226
+ });
10227
+ }, function () {});
10228
+ }, function (_wasThrown, _result) {
10229
+ _pendingPageRequests.current[pageIndex] = false;
10230
+ if (_wasThrown) throw _result;
10231
+ return _result;
10232
+ });
10233
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
10234
+ } catch (e) {
10235
+ return Promise.reject(e);
10236
+ }
10237
+ };
10238
+ const loadAll = function (sorting, filters, search) {
10239
+ try {
10240
+ const _temp2 = _catch(function () {
10241
+ return Promise.resolve(fetchAll(sorting, filters, search)).then(function (response) {
10242
+ length.current = response.length;
10243
+ setData(() => {
10244
+ let nextData;
10245
+ if (response.data.length !== response.length) {
10246
+ nextData = Array(response.length).fill(undefined);
10247
+ nextData.splice(0, response.data.length, ...response.data);
10248
+ } else {
10249
+ nextData = [...response.data];
10250
+ }
10251
+ return nextData;
10252
+ });
10253
+ });
10254
+ }, function () {});
10255
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
10256
+ } catch (e) {
10257
+ return Promise.reject(e);
10258
+ }
10259
+ };
10260
+ const invalidate = function () {
10261
+ try {
10262
+ _forceReset.current = true;
10263
+ return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, _lastUsedSearch.current);
10264
+ } catch (e) {
10265
+ return Promise.reject(e);
10266
+ }
10267
+ };
10268
+ // we reset the page to 0 whenever sorting, filtering or search changes
10269
+ const handleSort = function (sorting) {
10270
+ try {
10271
+ return loadPage(0, sorting, _lastUsedFilters.current, _lastUsedSearch.current);
10272
+ } catch (e) {
10273
+ return Promise.reject(e);
10274
+ }
10275
+ };
10276
+ const handleFilter = function (filters) {
10277
+ try {
10278
+ return loadPage(0, _lastUsedSorting.current, filters, _lastUsedSearch.current);
10279
+ } catch (e) {
10280
+ return Promise.reject(e);
10281
+ }
10282
+ };
10283
+ return [{
10284
+ data,
10285
+ length: length.current,
10286
+ loadAll,
10287
+ loadPage,
10288
+ onChangeFilter: handleFilter,
10289
+ onChangeSort: handleSort,
10290
+ pageSize
10291
+ }, invalidate];
10292
+ }
10143
10293
 
10144
10294
  function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
10145
10295
  const isEnabled = !!loadPage && !!loadAll;
@@ -10230,27 +10380,69 @@ function useTacoSettings() {
10230
10380
  return React__default.useContext(TacoContext);
10231
10381
  }
10232
10382
 
10383
+ const DEFAULT_ENABLED_OPTIONS = {
10384
+ columnOrder: true,
10385
+ columnPinning: true,
10386
+ columnSizing: true,
10387
+ columnVisibility: true,
10388
+ excludeUnmatchedRecordsInSearch: true,
10389
+ fontSize: true,
10390
+ grouping: true,
10391
+ rowHeight: true,
10392
+ showWarningWhenPrintingLargeDataset: true,
10393
+ sorting: true
10394
+ };
10233
10395
  function useUniqueTableId(tableId) {
10234
10396
  const tacoSettings = useTacoSettings();
10235
10397
  return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;
10236
10398
  }
10399
+ function useEnabledSettings(isEnabled) {
10400
+ return React__default.useMemo(() => {
10401
+ if (isEnabled === false) {
10402
+ return [Object.keys(DEFAULT_ENABLED_OPTIONS).reduce((o, key) => ({
10403
+ ...o,
10404
+ [key]: false
10405
+ }), {}), false];
10406
+ } else if (isEnabled === true) {
10407
+ return [DEFAULT_ENABLED_OPTIONS, true];
10408
+ }
10409
+ const options = {
10410
+ ...DEFAULT_ENABLED_OPTIONS,
10411
+ ...isEnabled
10412
+ };
10413
+ return [options, Object.values(options).some(o => o === true)];
10414
+ }, [isEnabled]);
10415
+ }
10237
10416
  function useTableSettings(isEnabled = false, id, defaultSettings = {}, onChangeSettings) {
10238
10417
  const uniqueId = useUniqueTableId(id);
10239
- const [persistedSettings, _setPersistedSettings] = useLocalStorage(isEnabled ? uniqueId : undefined, defaultSettings);
10418
+ const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
10419
+ const [persistedSettings, _setPersistedSettings] = useLocalStorage(hasSomeEnabledSettings ? uniqueId : undefined, removeDisabledSettings(defaultSettings, enabledSettings));
10240
10420
  const setPersistedSettings = React__default.useCallback(value => {
10241
- if (!isEnabled) {
10421
+ if (!hasSomeEnabledSettings) {
10242
10422
  return;
10243
10423
  }
10244
- _setPersistedSettings(value);
10424
+ const sanitizedSettings = removeDisabledSettings(value, enabledSettings);
10425
+ _setPersistedSettings(sanitizedSettings);
10245
10426
  if (typeof onChangeSettings === 'function') {
10246
- onChangeSettings(value);
10427
+ onChangeSettings(sanitizedSettings);
10247
10428
  }
10248
- }, [isEnabled, onChangeSettings]);
10249
- if (!isEnabled) {
10429
+ }, [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]);
10430
+ if (!hasSomeEnabledSettings) {
10250
10431
  return [defaultSettings, () => undefined];
10251
10432
  }
10252
10433
  return [persistedSettings, setPersistedSettings];
10253
10434
  }
10435
+ function removeDisabledSettings(settings, enabledSettings) {
10436
+ const sanitizedSettings = {
10437
+ ...settings
10438
+ };
10439
+ Object.keys(enabledSettings).forEach(setting => {
10440
+ if (!enabledSettings[setting]) {
10441
+ delete sanitizedSettings[setting];
10442
+ }
10443
+ });
10444
+ return sanitizedSettings;
10445
+ }
10254
10446
 
10255
10447
  // augments useEffect to not run on the initial mount
10256
10448
  function useLazyEffect(effect, deps) {
@@ -10357,12 +10549,25 @@ function resetHighlightedColumnIndexes(value, table) {
10357
10549
  if (value) {
10358
10550
  const indexes = [];
10359
10551
  const columns = table.getVisibleLeafColumns();
10552
+ const rowGrouping = table.getState().grouping;
10360
10553
  table.getRowModel().rows.forEach((row, rowIndex) => {
10361
10554
  columns.forEach((column, columnIndex) => {
10362
10555
  try {
10363
- if (column.getIsVisible() && column.columnDef.enableGlobalFilter) {
10556
+ let allowSearch = true;
10557
+ if (rowGrouping !== null && rowGrouping !== void 0 && rowGrouping.length) {
10558
+ // if it's the grouped row, only allow search of the grouped column - because that's all that's visible
10559
+ if (row.getIsGrouped()) {
10560
+ allowSearch = column.getIsGrouped();
10561
+ }
10562
+ // otherwise for other rows, don't search the grouped column - because it isn't visible
10563
+ else if (rowGrouping.includes(column.id)) {
10564
+ allowSearch = false;
10565
+ }
10566
+ }
10567
+ if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {
10364
10568
  var _row$original, _column$columnDef$met;
10365
10569
  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);
10570
+ // indexes don't map to sorted data
10366
10571
  if (cellValue !== undefined && isWeakContains(cellValue, value)) {
10367
10572
  indexes.push([rowIndex, columnIndex]);
10368
10573
  }
@@ -10526,10 +10731,12 @@ function useTableRef(table, ref) {
10526
10731
 
10527
10732
  function useTable(props, ref, meta, internalColumns) {
10528
10733
  var _props$length, _instance$options$met;
10734
+ // CSS.escape would be best here, but it doesn't seem to work very well
10735
+ const safeId = props.id.replace('.', '_');
10529
10736
  // configure table options, merging props with presets
10530
10737
  const options = useTableFeaturePreset(props);
10531
10738
  // load any persisted table settings and merge them with any defaults
10532
- const [settings, setSettings] = useTableSettings(options.enableSettings, props.id, props.defaultSettings, props.onChangeSettings);
10739
+ const [settings, setSettings] = useTableSettings(options.enableSaveSettings, safeId, props.defaultSettings, props.onChangeSettings);
10533
10740
  // configure common custom features
10534
10741
  const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);
10535
10742
  const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);
@@ -10601,6 +10808,7 @@ function useTable(props, ref, meta, internalColumns) {
10601
10808
  // configure ref with reset functions
10602
10809
  useTableRef(instance, ref);
10603
10810
  return {
10811
+ id: safeId,
10604
10812
  instance,
10605
10813
  length: (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : props.data.length,
10606
10814
  meta: (_instance$options$met = instance.options.meta) !== null && _instance$options$met !== void 0 ? _instance$options$met : {},
@@ -12865,6 +13073,7 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
12865
13073
  children,
12866
13074
  onClick,
12867
13075
  tabIndex = 0,
13076
+ fontSize,
12868
13077
  ...otherProps
12869
13078
  } = props;
12870
13079
  const {
@@ -12874,14 +13083,17 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
12874
13083
  open,
12875
13084
  readOnly
12876
13085
  } = useSelect2Context();
12877
- const className = cn('cursor-pointer !px-1 h-fit', getInputClasses({
13086
+ const className = cn('cursor-pointer px-1.5 h-fit', getInputClasses({
12878
13087
  ...props,
12879
13088
  disabled,
12880
13089
  highlighted,
12881
13090
  invalid,
12882
13091
  readOnly
12883
- }).replace('w-full', ''), {
12884
- 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-'))
13092
+ }).replace('w-full', '').replace('px-2', ''), {
13093
+ 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-')),
13094
+ 'text-xs': fontSize === exports.FontSizes.small,
13095
+ 'text-sm': fontSize === exports.FontSizes.medium,
13096
+ 'text-base': fontSize === exports.FontSizes.large
12885
13097
  }, props.className);
12886
13098
  const handleClick = event => {
12887
13099
  if (disabled || readOnly) {
@@ -12975,7 +13187,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
12975
13187
  className
12976
13188
  } = buttonProps;
12977
13189
  if (open) {
12978
- className = cn('!absolute z-20', buttonProps.className);
13190
+ className = cn('!absolute z-20 !h-fit', buttonProps.className);
12979
13191
  content = /*#__PURE__*/React__default.createElement(ScrollArea, {
12980
13192
  className: "my-1 flex max-h-[5.5rem] flex-col"
12981
13193
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -13542,6 +13754,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
13542
13754
  onBlur: handleBlur,
13543
13755
  onKeyDown: handleKeyDown,
13544
13756
  ref: internalRef,
13757
+ fontSize: fontSize,
13545
13758
  placeholder: placeholder
13546
13759
  }), flattenedChildren)), /*#__PURE__*/React__default.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Content, {
13547
13760
  asChild: true,
@@ -14420,7 +14633,8 @@ function useCssGridStylesheet(tableId, table, fontSize) {
14420
14633
  const allVisibleColumns = table.getVisibleLeafColumns();
14421
14634
  const columnSizing = table.getState().columnSizing;
14422
14635
  const globalMinSize = getCellMinWidth(fontSize);
14423
- const gridTemplateRows = 'min-content 1fr min-content'; // header body footer;
14636
+ // header body ?footer
14637
+ const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';
14424
14638
  return React__default.useMemo(() => {
14425
14639
  let printGridTemplateColumns = '';
14426
14640
  const printHiddenColumns = [];
@@ -14460,7 +14674,7 @@ function useCssGridStylesheet(tableId, table, fontSize) {
14460
14674
  // we have to be specific so that nested tables don't inherit the same css
14461
14675
  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
14676
  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; } }`;
14677
+ @media print { table[data-taco='report']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''} }`;
14464
14678
  }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);
14465
14679
  }
14466
14680
 
@@ -14658,7 +14872,10 @@ function getCellAttributes(cell, isHighlighted) {
14658
14872
  }
14659
14873
  return attributes;
14660
14874
  }
14661
- function useSearchHighlighting(cell, index, ref) {
14875
+ function useSearchHighlighting(cell, cellIndex, ref) {
14876
+ const {
14877
+ rowIndex
14878
+ } = React__default.useContext(RowContext);
14662
14879
  const context = cell.getContext();
14663
14880
  const tableMeta = context.table.options.meta;
14664
14881
  const columnMeta = cell.column.columnDef.meta;
@@ -14674,7 +14891,7 @@ function useSearchHighlighting(cell, index, ref) {
14674
14891
  return undefined;
14675
14892
  }
14676
14893
  const [rowActiveIndex, currentColumnIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];
14677
- if (rowActiveIndex === cell.row.index && currentColumnIndex === index) {
14894
+ if (rowActiveIndex === rowIndex && currentColumnIndex === cellIndex) {
14678
14895
  return 'current';
14679
14896
  }
14680
14897
  return true;
@@ -15097,6 +15314,20 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
15097
15314
  [tableRef.current, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
15098
15315
  }
15099
15316
 
15317
+ function EmptyStateBody(props) {
15318
+ const {
15319
+ emptyState: Placeholder = null,
15320
+ ...attributes
15321
+ } = props;
15322
+ return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
15323
+ className: "!auto-rows-fr"
15324
+ }), /*#__PURE__*/React__default.createElement("tr", {
15325
+ className: "!auto-rows-fr"
15326
+ }, /*#__PURE__*/React__default.createElement("td", {
15327
+ className: "col-span-full !border-0 !p-0 hover:!bg-white"
15328
+ }, Placeholder ? /*#__PURE__*/React__default.createElement(Placeholder, null) : null)));
15329
+ }
15330
+
15100
15331
  function Column$1(_) {
15101
15332
  return null;
15102
15333
  }
@@ -15104,11 +15335,11 @@ function Group$3(_) {
15104
15335
  return null;
15105
15336
  }
15106
15337
  const Report$1 = /*#__PURE__*/fixedForwardRef(function Report(props, ref) {
15107
- var _report$state$groupin;
15338
+ var _report$state$groupin, _renderer$rows;
15108
15339
  const tableRef = useMergedRef(ref);
15109
15340
  const report = useReport(props, tableRef);
15110
15341
  const renderer = useTableRenderer(report.instance, tableRef, props.defaultRowActiveIndex);
15111
- const stylesheet = useStylesheet(props.id, report.instance);
15342
+ const stylesheet = useStylesheet(report.id, report.instance);
15112
15343
  useTableGlobalShortcuts(report.instance, tableRef, renderer.scrollToIndex);
15113
15344
  const handleFocus = report.meta.rowActive.rowActiveIndex === undefined ? event => {
15114
15345
  report.meta.rowActive.handleFocus(event, report.length, renderer.scrollToIndex);
@@ -15120,12 +15351,12 @@ const Report$1 = /*#__PURE__*/fixedForwardRef(function Report(props, ref) {
15120
15351
  right: props.toolbarRight,
15121
15352
  scrollToIndex: renderer.scrollToIndex,
15122
15353
  table: report.instance,
15123
- tableId: props.id,
15354
+ tableId: report.id,
15124
15355
  tableRef: tableRef
15125
15356
  }), props.toolbarPanel ? /*#__PURE__*/React__default.createElement("div", {
15126
15357
  className: "mb-4"
15127
15358
  }, props.toolbarPanel) : undefined, /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", {
15128
- id: props.id,
15359
+ id: report.id,
15129
15360
  "data-taco": "report",
15130
15361
  "data-table-font-size": report.meta.fontSize.size,
15131
15362
  "data-table-horizontally-scrolled": report.meta.columnFreezing.isHorizontallyScrolled ? true : undefined,
@@ -15139,11 +15370,13 @@ const Report$1 = /*#__PURE__*/fixedForwardRef(function Report(props, ref) {
15139
15370
  tabIndex: -1
15140
15371
  }, /*#__PURE__*/React__default.createElement("thead", null, report.instance.getHeaderGroups().map(headerGroup => ( /*#__PURE__*/React__default.createElement("tr", {
15141
15372
  key: headerGroup.id
15142
- }, headerGroup.headers.map(Header$4))))), /*#__PURE__*/React__default.createElement(Body, {
15373
+ }, 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, {
15143
15374
  length: report.length,
15144
15375
  table: report.instance,
15145
15376
  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, {
15377
+ }, 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, {
15378
+ emptyState: props.emptyState
15379
+ }))), report.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Summary, {
15147
15380
  length: report.length,
15148
15381
  table: report.instance
15149
15382
  }) : null));
@@ -19172,7 +19405,7 @@ function EditingCell(props) {
19172
19405
  }));
19173
19406
  }
19174
19407
  const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
19175
- var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$rowAc, _column$columnDef$met;
19408
+ var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$rowAc, _column$columnDef$met, _column$columnDef$met2;
19176
19409
  const {
19177
19410
  cell,
19178
19411
  column,
@@ -19307,7 +19540,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
19307
19540
  }));
19308
19541
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && !error ? ( /*#__PURE__*/React__default.createElement(Indicator, {
19309
19542
  reason: moveReason,
19310
- columnName: String(cell.column.columnDef.header),
19543
+ columnName: String((_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.header),
19311
19544
  mountNode: mountNode,
19312
19545
  validationErrors: []
19313
19546
  })) : null, /*#__PURE__*/React__default.createElement("div", {
@@ -23039,9 +23272,9 @@ const PrimaryNavigation = /*#__PURE__*/React__default.forwardRef(function Primar
23039
23272
  } = useLocalization();
23040
23273
  const internalRef = useMergedRef(ref);
23041
23274
  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, {
23275
+ const moreButton = () => ( /*#__PURE__*/React__default.createElement(Button$1, {
23043
23276
  className: cn(getLinkClasses(), '!bg-transparent aria-expanded:!bg-white/[.08]')
23044
- }, texts.header.more);
23277
+ }, texts.header.more));
23045
23278
  return /*#__PURE__*/React__default.createElement("nav", Object.assign({}, props, {
23046
23279
  className: className,
23047
23280
  ref: internalRef
@@ -23651,6 +23884,7 @@ exports.Card = Card;
23651
23884
  exports.Checkbox = Checkbox;
23652
23885
  exports.CollectionPrimitive = Collection;
23653
23886
  exports.Combobox = Combobox;
23887
+ exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
23654
23888
  exports.Datepicker = Datepicker;
23655
23889
  exports.Dialog = Dialog;
23656
23890
  exports.Drawer = Drawer;
@@ -23739,6 +23973,7 @@ exports.useOnClickOutside = useOnClickOutside;
23739
23973
  exports.usePagination = usePagination;
23740
23974
  exports.useRadioGroup = useRadioGroup;
23741
23975
  exports.useTable3DataLoader = useTable3DataLoader;
23976
+ exports.useTableDataLoader = useTableDataLoader;
23742
23977
  exports.useTableRowCreation = useTableRowCreation;
23743
23978
  exports.useToast = useToast;
23744
23979
  //# sourceMappingURL=taco.cjs.development.js.map