@economic/taco 2.66.1-test.0 → 2.67.1-alpha.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.
package/dist/taco.cjs CHANGED
@@ -26978,7 +26978,7 @@ const Content$4 = React__namespace.forwardRef(function HangerContent(props, ref)
26978
26978
  const context = React__namespace.useContext(HangerContext);
26979
26979
  const { texts } = useLocalization();
26980
26980
  const className = clsx(
26981
- "wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm",
26981
+ "wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden",
26982
26982
  props.className
26983
26983
  );
26984
26984
  const handleInteractOutside = (event) => {
@@ -35651,7 +35651,7 @@ function useReactTableInitialState(props, columns, persistedSettings, defaults2)
35651
35651
  columnOrder
35652
35652
  );
35653
35653
  } else {
35654
- if (props.defaultColumnFreezingIndex) {
35654
+ if (props.defaultColumnFreezingIndex !== void 0) {
35655
35655
  columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);
35656
35656
  } else {
35657
35657
  columnPinning.left = unfreezeAllExternalColumns(columnOrder);
@@ -37852,12 +37852,12 @@ function getScrollPaddingEndOffset(table) {
37852
37852
  }
37853
37853
  return height;
37854
37854
  }
37855
- function getPaddingEndOffset(table, options) {
37855
+ function getPaddingEndOffset(table) {
37856
37856
  const bottomRows = table.getBottomRows() ?? [];
37857
- return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length + ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ?? 0);
37857
+ return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length;
37858
37858
  }
37859
37859
  const OVERSCAN_ROW_COUNT = 8;
37860
- function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
37860
+ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex) {
37861
37861
  var _a, _b, _c, _d, _e;
37862
37862
  const tableMeta = table.options.meta;
37863
37863
  const isTableRowGrouped = !!((_a = table.getState().grouping) == null ? void 0 : _a.length);
@@ -37876,10 +37876,12 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
37876
37876
  // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list
37877
37877
  scrollPaddingStart,
37878
37878
  scrollPaddingEnd: getScrollPaddingEndOffset(table),
37879
- paddingEnd: getPaddingEndOffset(table, options)
37879
+ paddingEnd: getPaddingEndOffset(table)
37880
37880
  });
37881
37881
  const expandedState = table.getState().expanded;
37882
37882
  const previousExpandedStateRef = React.useRef(false);
37883
+ const sortingState = table.getState().sorting;
37884
+ const previousSortingStateRef = React.useRef(JSON.stringify(sortingState));
37883
37885
  React.useEffect(() => {
37884
37886
  const isEmpty = JSON.stringify(expandedState) === "{}";
37885
37887
  if (expandedState === true || isEmpty && previousExpandedStateRef.current === true) {
@@ -37887,18 +37889,25 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
37887
37889
  virtualiser.measure();
37888
37890
  }
37889
37891
  }, [expandedState]);
37892
+ React.useEffect(() => {
37893
+ const currentSortingString = JSON.stringify(sortingState);
37894
+ if (currentSortingString !== previousSortingStateRef.current) {
37895
+ previousSortingStateRef.current = currentSortingString;
37896
+ virtualiser.measure();
37897
+ }
37898
+ }, [sortingState]);
37890
37899
  const totalSize = virtualiser.getTotalSize();
37891
37900
  const virtualItems = virtualiser.getVirtualItems();
37892
37901
  const scrollToIndex = React.useCallback(
37893
- (index2, options2 = { align: "auto", behavior: "smooth" }) => {
37894
- const notSmooth = { ...options2, behavior: "auto" };
37902
+ (index2, options = { align: "auto", behavior: "smooth" }) => {
37903
+ const notSmooth = { ...options, behavior: "auto" };
37895
37904
  if (tableRef.current) {
37896
37905
  if (index2 === 0) {
37897
37906
  virtualiser.scrollToOffset(0, notSmooth);
37898
37907
  } else if (index2 === count2 - 1) {
37899
37908
  tableRef.current.scrollTop = tableRef.current.scrollHeight;
37900
37909
  } else {
37901
- virtualiser.scrollToIndex(index2, options2);
37910
+ virtualiser.scrollToIndex(index2, options);
37902
37911
  }
37903
37912
  }
37904
37913
  },
@@ -37939,10 +37948,11 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
37939
37948
  row = rows[virtualRow.index];
37940
37949
  }
37941
37950
  if (!(row == null ? void 0 : row.original)) {
37951
+ const skeletonKey = `skeleton-${virtualRow.index}-${JSON.stringify(table.getState().sorting).slice(0, 8)}`;
37942
37952
  return /* @__PURE__ */ React.createElement(
37943
37953
  SkeletonRow,
37944
37954
  {
37945
- key: virtualRow.index,
37955
+ key: skeletonKey,
37946
37956
  index: virtualRow.index,
37947
37957
  scrollDirection: virtualiser.scrollDirection ?? void 0,
37948
37958
  table
@@ -38336,17 +38346,10 @@ const INTERNAL_RENDERERS = {
38336
38346
  rowExpansion: renderer$1,
38337
38347
  rowSelection: renderer
38338
38348
  };
38339
- function useTable$1(props, externalRef, renderers, meta, options) {
38349
+ function useTable$1(props, externalRef, renderers, meta) {
38340
38350
  const ref = useMergedRef(externalRef);
38341
38351
  const manager = useTableManager(props, ref, meta, INTERNAL_RENDERERS);
38342
- const renderer2 = useTableRenderer(
38343
- renderers,
38344
- manager.instance,
38345
- ref,
38346
- manager.meta.length,
38347
- props.defaultRowActiveIndex,
38348
- options
38349
- );
38352
+ const renderer2 = useTableRenderer(renderers, manager.instance, ref, manager.meta.length, props.defaultRowActiveIndex);
38350
38353
  const { style, stylesheet } = useTableStyle(manager.id, manager.instance);
38351
38354
  useTableGlobalShortcuts(manager.instance, ref, renderer2.scrollToIndex, props.enableLocalKeyboardShortcuts);
38352
38355
  useTableRef(manager.instance, ref);
@@ -39037,6 +39040,9 @@ function Header$1(props) {
39037
39040
  if (canHide) {
39038
39041
  memoedProps.onHide = header.column.getToggleVisibilityHandler();
39039
39042
  }
39043
+ if (header.id === "__expansion") {
39044
+ memoedProps.isExpanded = table.getIsSomeRowsExpanded();
39045
+ }
39040
39046
  if (canPin) {
39041
39047
  memoedProps.onPin = (index2) => {
39042
39048
  table.setColumnPinning((pinningState) => {
@@ -39087,6 +39093,7 @@ const MemoedHeader = React.memo(function MemoedHeader2(props) {
39087
39093
  hasMenu,
39088
39094
  id: id2,
39089
39095
  index: index2,
39096
+ isExpanded,
39090
39097
  isFiltered,
39091
39098
  isGroup: isGroup2,
39092
39099
  isPinned,
@@ -39126,6 +39133,7 @@ const MemoedHeader = React.memo(function MemoedHeader2(props) {
39126
39133
  "data-cell-id": id2,
39127
39134
  "data-cell-pinned": isPinned ? isPinned : void 0,
39128
39135
  "data-taco": isGroup2 ? "grouped-column-header" : "column-header",
39136
+ "data-rows-expanded": isExpanded ? isExpanded : void 0,
39129
39137
  style,
39130
39138
  ref: setRef
39131
39139
  },
@@ -39320,10 +39328,10 @@ function Summary(props) {
39320
39328
  } else if (!tableMeta.server.isEnabled && (((_a = table.getState().columnFilters) == null ? void 0 : _a.length) || // filtered data
39321
39329
  !!table.getState().globalFilter && table.options.enableGlobalFilter)) {
39322
39330
  label = texts.table.footer.summary.records;
39323
- count2 = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("strong", null, new Intl.NumberFormat(locale2).format(currentLength)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React.createElement("strong", null, new Intl.NumberFormat(locale2).format(length)));
39331
+ count2 = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-current-count" }, new Intl.NumberFormat(locale2).format(currentLength)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale2).format(length)));
39324
39332
  } else {
39325
39333
  label = texts.table.footer.summary.records;
39326
- count2 = /* @__PURE__ */ React.createElement("strong", null, new Intl.NumberFormat(locale2).format(length));
39334
+ count2 = /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale2).format(length));
39327
39335
  }
39328
39336
  return /* @__PURE__ */ React.createElement(
39329
39337
  "div",
@@ -39482,7 +39490,7 @@ const SearchInput22 = React.forwardRef(function SearchInput222(props, ref) {
39482
39490
  );
39483
39491
  }
39484
39492
  if (hasFind && isActive) {
39485
- postfix = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { className: "text-grey-700 flex h-4 items-center" }, loading ? /* @__PURE__ */ React.createElement(Spinner, { className: "h-4 w-4" }) : showTotal ? /* @__PURE__ */ React.createElement("span", { className: "border-r border-black/[0.25] pr-2" }, `${findCurrent ?? 0}/${findTotal ?? 0}`) : null), findCurrent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
39493
+ postfix = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { className: "text-grey-700 flex h-4 items-center" }, loading ? /* @__PURE__ */ React.createElement(Spinner, { className: "h-4 w-4" }) : showTotal ? /* @__PURE__ */ React.createElement("span", { className: "border-r border-black/[0.25] pr-2", "data-taco": "search-matches-counter" }, `${findCurrent ?? 0}/${findTotal ?? 0}`) : null), findCurrent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
39486
39494
  IconButton,
39487
39495
  {
39488
39496
  "aria-label": texts.searchInput.findPrevious,
@@ -45174,6 +45182,7 @@ function Print(props) {
45174
45182
  {
45175
45183
  icon: "print",
45176
45184
  "aria-label": texts.table.print.tooltip,
45185
+ id: `${tableId}-toolbar-print`,
45177
45186
  dialog: (dialogProps) => /* @__PURE__ */ React.createElement(
45178
45187
  PrintDialog,
45179
45188
  {
@@ -45510,7 +45519,7 @@ function Filter(props) {
45510
45519
  ref.current.focus();
45511
45520
  }
45512
45521
  }, [id2]);
45513
- return /* @__PURE__ */ React.createElement("div", { className: "flex items-start gap-2" }, /* @__PURE__ */ React.createElement("div", { className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right" }, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /* @__PURE__ */ React.createElement(FilterColumn, { allHeaders, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React.createElement(FilterComparator, { column: column == null ? void 0 : column.column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React.createElement(FilterValue, { column: column == null ? void 0 : column.column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
45522
+ return /* @__PURE__ */ React.createElement("div", { className: "flex items-start gap-2", "data-taco": "filter-row" }, /* @__PURE__ */ React.createElement("div", { className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right" }, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /* @__PURE__ */ React.createElement(FilterColumn, { allHeaders, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React.createElement(FilterComparator, { column: column == null ? void 0 : column.column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React.createElement(FilterValue, { column: column == null ? void 0 : column.column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
45514
45523
  }
45515
45524
  const placeholderFilter = { id: "", value: { comparator: TableFilterComparator.Contains, value: void 0 } };
45516
45525
  function ManageFiltersPopover(props) {
@@ -45591,10 +45600,10 @@ function ManageFiltersPopover(props) {
45591
45600
  onChange: handleChangeFilter,
45592
45601
  onRemove: filters.length > 0 && filters.some((f2) => f2.id) || filters.length > 1 ? handleRemoveFilter : void 0
45593
45602
  }
45594
- )), /* @__PURE__ */ React.createElement("div", { className: "justify-start" }, /* @__PURE__ */ React.createElement(Button$4, { appearance: "discrete", onClick: handleCreate }, "+ ", texts.table.filters.buttons.addFilter))), /* @__PURE__ */ React.createElement(Group$6, { className: "ml-auto" }, /* @__PURE__ */ React.createElement(Popover.Close, null, /* @__PURE__ */ React.createElement(Button$4, null, texts.table.filters.buttons.cancel)), /* @__PURE__ */ React.createElement(Button$4, { onClick: handleClear }, texts.table.filters.buttons.clear), /* @__PURE__ */ React.createElement(Button$4, { appearance: "primary", onClick: handleApply }, texts.table.filters.buttons.apply))))));
45603
+ )), /* @__PURE__ */ React.createElement("div", { className: "justify-start" }, /* @__PURE__ */ React.createElement(Button$4, { appearance: "discrete", onClick: handleCreate, name: "add-filter" }, "+ ", texts.table.filters.buttons.addFilter))), /* @__PURE__ */ React.createElement(Group$6, { className: "ml-auto" }, /* @__PURE__ */ React.createElement(Popover.Close, null, /* @__PURE__ */ React.createElement(Button$4, { name: "close-filters" }, texts.table.filters.buttons.cancel)), /* @__PURE__ */ React.createElement(Button$4, { name: "clear-filters", onClick: handleClear }, texts.table.filters.buttons.clear), /* @__PURE__ */ React.createElement(Button$4, { appearance: "primary", name: "apply-filters", onClick: handleApply }, texts.table.filters.buttons.apply))))));
45595
45604
  }
45596
45605
  function Filters(props) {
45597
- const { length, table } = props;
45606
+ const { length, tableId, table } = props;
45598
45607
  const { texts } = useLocalization();
45599
45608
  const isLargeScreen = useIsLargeScreen();
45600
45609
  const columnFilters = table.getState().columnFilters;
@@ -45607,7 +45616,8 @@ function Filters(props) {
45607
45616
  popover: (popoverProps) => /* @__PURE__ */ React.createElement(ManageFiltersPopover, { ...popoverProps, length, table }),
45608
45617
  shortcut: shortcut2,
45609
45618
  ref,
45610
- tooltip: /* @__PURE__ */ React.createElement(React.Fragment, null, texts.table.filters.tooltip, /* @__PURE__ */ React.createElement(Shortcut, { className: "ml-2", keys: shortcut2 }))
45619
+ tooltip: /* @__PURE__ */ React.createElement(React.Fragment, null, texts.table.filters.tooltip, /* @__PURE__ */ React.createElement(Shortcut, { className: "ml-2", keys: shortcut2 })),
45620
+ id: `${tableId}-toolbar-filters`
45611
45621
  };
45612
45622
  React.useEffect(() => {
45613
45623
  var _a;
@@ -45640,7 +45650,7 @@ function TableToolbar(props) {
45640
45650
  "data-taco": "table-toolbar"
45641
45651
  },
45642
45652
  table.props.toolbarLeft,
45643
- /* @__PURE__ */ React.createElement(Group$6, { className: "ml-auto flex-shrink-0 items-center print:hidden" }, customTools, canFilter ? /* @__PURE__ */ React.createElement(Filters, { length: table.meta.length, table: table.instance }) : null, table.props.toolbarRight, canPrint ? /* @__PURE__ */ React.createElement(Print, { table: table.instance, tableId: table.id, tableRef: table.ref }) : null, canSettings ? /* @__PURE__ */ React.createElement(Settings, { customSettings: table.props.customSettings, id: `${id2}-settings`, table: table.instance }) : null, canSearch ? /* @__PURE__ */ React.createElement(Search$1, { scrollToIndex: table.renderer.scrollToIndex, table: table.instance, tableRef: table.ref }) : null)
45653
+ /* @__PURE__ */ React.createElement(Group$6, { className: "ml-auto flex-shrink-0 items-center print:hidden" }, customTools, canFilter ? /* @__PURE__ */ React.createElement(Filters, { length: table.meta.length, tableId: table.id, table: table.instance }) : null, table.props.toolbarRight, canPrint ? /* @__PURE__ */ React.createElement(Print, { table: table.instance, tableId: table.id, tableRef: table.ref }) : null, canSettings ? /* @__PURE__ */ React.createElement(Settings, { customSettings: table.props.customSettings, id: `${id2}-settings`, table: table.instance }) : null, canSearch ? /* @__PURE__ */ React.createElement(Search$1, { scrollToIndex: table.renderer.scrollToIndex, table: table.instance, tableRef: table.ref }) : null)
45644
45654
  ), table.props.toolbarPanel ? /* @__PURE__ */ React.createElement("div", { className: "mb-4" }, table.props.toolbarPanel) : void 0);
45645
45655
  }
45646
45656
  function canChangeSettings(table, customSettings) {
@@ -55285,6 +55295,13 @@ function reducer(state, action) {
55285
55295
  indexes: setWith(state.indexes, rowId, index2, Object)
55286
55296
  };
55287
55297
  }
55298
+ case "forceValidate": {
55299
+ const { newState } = payload;
55300
+ return {
55301
+ ...state,
55302
+ ...newState
55303
+ };
55304
+ }
55288
55305
  default:
55289
55306
  return state;
55290
55307
  }
@@ -55444,6 +55461,46 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55444
55461
  }
55445
55462
  });
55446
55463
  }
55464
+ async function forceValidate(table) {
55465
+ if (validator && table.getRowModel().rows.length) {
55466
+ const newState = { ...state };
55467
+ const returnIds = [];
55468
+ await Promise.all(
55469
+ table.getRowModel().rows.map(async (row, index2) => {
55470
+ var _a, _b;
55471
+ const rowWithChanges = { ...row.original, ...state.changes.rows[row.id] };
55472
+ if (rowWithChanges) {
55473
+ const cellErrors = await validator(rowWithChanges);
55474
+ if (cellErrors) {
55475
+ newState.changes.dirty[row.id] = true;
55476
+ newState.changes.originals[row.id] = row.original;
55477
+ newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };
55478
+ newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };
55479
+ newState.changes.status[row.id] = "errored";
55480
+ newState.indexes[row.id] = index2;
55481
+ newState.changes.errors[row.id] = {
55482
+ cells: cellErrors,
55483
+ row: ((_a = newState.changes.errors[row.id]) == null ? void 0 : _a.row) ?? void 0,
55484
+ shouldShowErrorAlert: ((_b = newState.changes.errors[row.id]) == null ? void 0 : _b.shouldShowErrorAlert) ?? false
55485
+ };
55486
+ Object.keys(cellErrors).forEach((columnId) => {
55487
+ newState.changes.rows[row.id][columnId] = rowWithChanges[columnId];
55488
+ });
55489
+ returnIds.push(row.id);
55490
+ }
55491
+ }
55492
+ })
55493
+ );
55494
+ dispatch({
55495
+ type: "forceValidate",
55496
+ payload: {
55497
+ newState
55498
+ }
55499
+ });
55500
+ return returnIds;
55501
+ }
55502
+ return [];
55503
+ }
55447
55504
  function getErrors() {
55448
55505
  return Object.keys(state.changes.errors);
55449
55506
  }
@@ -55572,6 +55629,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55572
55629
  hasTemporaryRowErrors,
55573
55630
  getRowStatus,
55574
55631
  setRowStatus,
55632
+ forceValidate,
55575
55633
  // cells
55576
55634
  setCellValue,
55577
55635
  getCellValue,
@@ -56325,14 +56383,7 @@ function useTable3(props, ref) {
56325
56383
  ]) : props.rowActions
56326
56384
  };
56327
56385
  const meta = { editing };
56328
- const options = {
56329
- virtualiserPaddingEndOffset: 0
56330
- };
56331
- if (props.enableEditing) {
56332
- const validationErrorLabelHeight = 17;
56333
- options.virtualiserPaddingEndOffset = editing.getErrors().length * validationErrorLabelHeight;
56334
- }
56335
- const table = useTable$1(extendedProps, ref, RENDERERS, meta, options);
56386
+ const table = useTable$1(extendedProps, ref, RENDERERS, meta);
56336
56387
  const toggleEditing = (enabled) => table.meta.editing.toggleEditing(enabled ?? ((editing2) => !editing2), table.instance, table.renderer.scrollToIndex);
56337
56388
  React.useEffect(() => {
56338
56389
  if (props.defaultToggleEditing) {
@@ -56355,6 +56406,14 @@ function useTable3(props, ref) {
56355
56406
  }
56356
56407
  }
56357
56408
  }, [table.ref.current, table.meta.editing.isEnabled]);
56409
+ React.useEffect(() => {
56410
+ if (table.ref.current) {
56411
+ const instance = table.ref.current.instance;
56412
+ if (table.meta.editing.isEnabled) {
56413
+ instance.editing.forceValidate = async () => table.meta.editing.forceValidate(table.instance);
56414
+ }
56415
+ }
56416
+ }, [table.meta.editing.forceValidate]);
56358
56417
  return table;
56359
56418
  }
56360
56419
  function Alert(props) {