@economic/taco 2.66.1-test.0 → 2.67.1-footer-fix.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) => {
@@ -35564,7 +35564,7 @@ function configureReactTableOptions(options, props, localization) {
35564
35564
  if (originalRow) {
35565
35565
  return String(originalRow[props.rowIdentityAccessor]);
35566
35566
  }
35567
- return String(index2);
35567
+ return `skeleton-${index2}-${Math.random().toString(36).substr(2, 9)}`;
35568
35568
  };
35569
35569
  }
35570
35570
  const tableOptions = {
@@ -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
  },
@@ -38336,17 +38345,10 @@ const INTERNAL_RENDERERS = {
38336
38345
  rowExpansion: renderer$1,
38337
38346
  rowSelection: renderer
38338
38347
  };
38339
- function useTable$1(props, externalRef, renderers, meta, options) {
38348
+ function useTable$1(props, externalRef, renderers, meta) {
38340
38349
  const ref = useMergedRef(externalRef);
38341
38350
  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
- );
38351
+ const renderer2 = useTableRenderer(renderers, manager.instance, ref, manager.meta.length, props.defaultRowActiveIndex);
38350
38352
  const { style, stylesheet } = useTableStyle(manager.id, manager.instance);
38351
38353
  useTableGlobalShortcuts(manager.instance, ref, renderer2.scrollToIndex, props.enableLocalKeyboardShortcuts);
38352
38354
  useTableRef(manager.instance, ref);
@@ -39037,6 +39039,9 @@ function Header$1(props) {
39037
39039
  if (canHide) {
39038
39040
  memoedProps.onHide = header.column.getToggleVisibilityHandler();
39039
39041
  }
39042
+ if (header.id === "__expansion") {
39043
+ memoedProps.isExpanded = table.getIsSomeRowsExpanded();
39044
+ }
39040
39045
  if (canPin) {
39041
39046
  memoedProps.onPin = (index2) => {
39042
39047
  table.setColumnPinning((pinningState) => {
@@ -39087,6 +39092,7 @@ const MemoedHeader = React.memo(function MemoedHeader2(props) {
39087
39092
  hasMenu,
39088
39093
  id: id2,
39089
39094
  index: index2,
39095
+ isExpanded,
39090
39096
  isFiltered,
39091
39097
  isGroup: isGroup2,
39092
39098
  isPinned,
@@ -39126,6 +39132,7 @@ const MemoedHeader = React.memo(function MemoedHeader2(props) {
39126
39132
  "data-cell-id": id2,
39127
39133
  "data-cell-pinned": isPinned ? isPinned : void 0,
39128
39134
  "data-taco": isGroup2 ? "grouped-column-header" : "column-header",
39135
+ "data-rows-expanded": isExpanded ? isExpanded : void 0,
39129
39136
  style,
39130
39137
  ref: setRef
39131
39138
  },
@@ -39320,10 +39327,10 @@ function Summary(props) {
39320
39327
  } else if (!tableMeta.server.isEnabled && (((_a = table.getState().columnFilters) == null ? void 0 : _a.length) || // filtered data
39321
39328
  !!table.getState().globalFilter && table.options.enableGlobalFilter)) {
39322
39329
  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)));
39330
+ 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
39331
  } else {
39325
39332
  label = texts.table.footer.summary.records;
39326
- count2 = /* @__PURE__ */ React.createElement("strong", null, new Intl.NumberFormat(locale2).format(length));
39333
+ count2 = /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale2).format(length));
39327
39334
  }
39328
39335
  return /* @__PURE__ */ React.createElement(
39329
39336
  "div",
@@ -39482,7 +39489,7 @@ const SearchInput22 = React.forwardRef(function SearchInput222(props, ref) {
39482
39489
  );
39483
39490
  }
39484
39491
  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(
39492
+ 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
39493
  IconButton,
39487
39494
  {
39488
39495
  "aria-label": texts.searchInput.findPrevious,
@@ -45174,6 +45181,7 @@ function Print(props) {
45174
45181
  {
45175
45182
  icon: "print",
45176
45183
  "aria-label": texts.table.print.tooltip,
45184
+ id: `${tableId}-toolbar-print`,
45177
45185
  dialog: (dialogProps) => /* @__PURE__ */ React.createElement(
45178
45186
  PrintDialog,
45179
45187
  {
@@ -45510,7 +45518,7 @@ function Filter(props) {
45510
45518
  ref.current.focus();
45511
45519
  }
45512
45520
  }, [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);
45521
+ 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
45522
  }
45515
45523
  const placeholderFilter = { id: "", value: { comparator: TableFilterComparator.Contains, value: void 0 } };
45516
45524
  function ManageFiltersPopover(props) {
@@ -45591,10 +45599,10 @@ function ManageFiltersPopover(props) {
45591
45599
  onChange: handleChangeFilter,
45592
45600
  onRemove: filters.length > 0 && filters.some((f2) => f2.id) || filters.length > 1 ? handleRemoveFilter : void 0
45593
45601
  }
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))))));
45602
+ )), /* @__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
45603
  }
45596
45604
  function Filters(props) {
45597
- const { length, table } = props;
45605
+ const { length, tableId, table } = props;
45598
45606
  const { texts } = useLocalization();
45599
45607
  const isLargeScreen = useIsLargeScreen();
45600
45608
  const columnFilters = table.getState().columnFilters;
@@ -45607,7 +45615,8 @@ function Filters(props) {
45607
45615
  popover: (popoverProps) => /* @__PURE__ */ React.createElement(ManageFiltersPopover, { ...popoverProps, length, table }),
45608
45616
  shortcut: shortcut2,
45609
45617
  ref,
45610
- tooltip: /* @__PURE__ */ React.createElement(React.Fragment, null, texts.table.filters.tooltip, /* @__PURE__ */ React.createElement(Shortcut, { className: "ml-2", keys: shortcut2 }))
45618
+ tooltip: /* @__PURE__ */ React.createElement(React.Fragment, null, texts.table.filters.tooltip, /* @__PURE__ */ React.createElement(Shortcut, { className: "ml-2", keys: shortcut2 })),
45619
+ id: `${tableId}-toolbar-filters`
45611
45620
  };
45612
45621
  React.useEffect(() => {
45613
45622
  var _a;
@@ -45640,7 +45649,7 @@ function TableToolbar(props) {
45640
45649
  "data-taco": "table-toolbar"
45641
45650
  },
45642
45651
  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)
45652
+ /* @__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
45653
  ), table.props.toolbarPanel ? /* @__PURE__ */ React.createElement("div", { className: "mb-4" }, table.props.toolbarPanel) : void 0);
45645
45654
  }
45646
45655
  function canChangeSettings(table, customSettings) {
@@ -55285,6 +55294,13 @@ function reducer(state, action) {
55285
55294
  indexes: setWith(state.indexes, rowId, index2, Object)
55286
55295
  };
55287
55296
  }
55297
+ case "forceValidate": {
55298
+ const { newState } = payload;
55299
+ return {
55300
+ ...state,
55301
+ ...newState
55302
+ };
55303
+ }
55288
55304
  default:
55289
55305
  return state;
55290
55306
  }
@@ -55444,6 +55460,46 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55444
55460
  }
55445
55461
  });
55446
55462
  }
55463
+ async function forceValidate(table) {
55464
+ if (validator && table.getRowModel().rows.length) {
55465
+ const newState = { ...state };
55466
+ const returnIds = [];
55467
+ await Promise.all(
55468
+ table.getRowModel().rows.map(async (row, index2) => {
55469
+ var _a, _b;
55470
+ const rowWithChanges = { ...row.original, ...state.changes.rows[row.id] };
55471
+ if (rowWithChanges) {
55472
+ const cellErrors = await validator(rowWithChanges);
55473
+ if (cellErrors) {
55474
+ newState.changes.dirty[row.id] = true;
55475
+ newState.changes.originals[row.id] = row.original;
55476
+ newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };
55477
+ newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };
55478
+ newState.changes.status[row.id] = "errored";
55479
+ newState.indexes[row.id] = index2;
55480
+ newState.changes.errors[row.id] = {
55481
+ cells: cellErrors,
55482
+ row: ((_a = newState.changes.errors[row.id]) == null ? void 0 : _a.row) ?? void 0,
55483
+ shouldShowErrorAlert: ((_b = newState.changes.errors[row.id]) == null ? void 0 : _b.shouldShowErrorAlert) ?? false
55484
+ };
55485
+ Object.keys(cellErrors).forEach((columnId) => {
55486
+ newState.changes.rows[row.id][columnId] = rowWithChanges[columnId];
55487
+ });
55488
+ returnIds.push(row.id);
55489
+ }
55490
+ }
55491
+ })
55492
+ );
55493
+ dispatch({
55494
+ type: "forceValidate",
55495
+ payload: {
55496
+ newState
55497
+ }
55498
+ });
55499
+ return returnIds;
55500
+ }
55501
+ return [];
55502
+ }
55447
55503
  function getErrors() {
55448
55504
  return Object.keys(state.changes.errors);
55449
55505
  }
@@ -55572,6 +55628,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55572
55628
  hasTemporaryRowErrors,
55573
55629
  getRowStatus,
55574
55630
  setRowStatus,
55631
+ forceValidate,
55575
55632
  // cells
55576
55633
  setCellValue,
55577
55634
  getCellValue,
@@ -56325,14 +56382,7 @@ function useTable3(props, ref) {
56325
56382
  ]) : props.rowActions
56326
56383
  };
56327
56384
  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);
56385
+ const table = useTable$1(extendedProps, ref, RENDERERS, meta);
56336
56386
  const toggleEditing = (enabled) => table.meta.editing.toggleEditing(enabled ?? ((editing2) => !editing2), table.instance, table.renderer.scrollToIndex);
56337
56387
  React.useEffect(() => {
56338
56388
  if (props.defaultToggleEditing) {
@@ -56355,6 +56405,14 @@ function useTable3(props, ref) {
56355
56405
  }
56356
56406
  }
56357
56407
  }, [table.ref.current, table.meta.editing.isEnabled]);
56408
+ React.useEffect(() => {
56409
+ if (table.ref.current) {
56410
+ const instance = table.ref.current.instance;
56411
+ if (table.meta.editing.isEnabled) {
56412
+ instance.editing.forceValidate = async () => table.meta.editing.forceValidate(table.instance);
56413
+ }
56414
+ }
56415
+ }, [table.meta.editing.forceValidate]);
56358
56416
  return table;
56359
56417
  }
56360
56418
  function Alert(props) {