@economic/taco 2.64.1-test-1.0 → 2.65.0-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
@@ -36623,6 +36623,17 @@ function useTableRowDrop(isEnabled = false, onRowDrop) {
36623
36623
  handleDrop: isEnabled ? onRowDrop : void 0
36624
36624
  };
36625
36625
  }
36626
+ function useTableRowActiveListener$1(table, onRowActive) {
36627
+ var _a;
36628
+ const meta = table.options.meta;
36629
+ const rows = table.getRowModel().flatRows;
36630
+ const currentRow = meta.rowActive.rowActiveIndex !== void 0 ? (_a = rows[meta.rowActive.rowActiveIndex]) == null ? void 0 : _a.original : void 0;
36631
+ React.useEffect(() => {
36632
+ if (meta.rowActive.isEnabled && onRowActive) {
36633
+ onRowActive(currentRow);
36634
+ }
36635
+ }, [meta.rowActive.isEnabled, currentRow, onRowActive]);
36636
+ }
36626
36637
  const DEFAULT_EMPTY_ARRAY = [];
36627
36638
  function useTableManager(props, ref, meta, internalColumns) {
36628
36639
  var _a;
@@ -36723,6 +36734,7 @@ function useTableManager(props, ref, meta, internalColumns) {
36723
36734
  useTableDataListener(instance, length);
36724
36735
  useTableFilterListener(instance, props.onChangeFilter);
36725
36736
  useTableFontSizeListener(instance);
36737
+ useTableRowActiveListener$1(instance, props.onRowActive);
36726
36738
  useTableRowHeightListener(instance);
36727
36739
  useTableRowSelectionListener(instance, props.onRowSelect);
36728
36740
  useTableSearchListener(instance);
@@ -37836,15 +37848,6 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
37836
37848
  virtualiser.measure();
37837
37849
  }
37838
37850
  }, [expandedState]);
37839
- React.useEffect(() => {
37840
- const totalSize2 = virtualiser.getTotalSize();
37841
- console.log("before measuring totalSize", totalSize2);
37842
- virtualiser.measure();
37843
- setTimeout(() => {
37844
- const totalSize3 = virtualiser.getTotalSize();
37845
- console.log("after measuring totalSize", totalSize3);
37846
- }, 1e3);
37847
- }, [tableMeta.fontSize.size, tableMeta.rowHeight.height, JSON.stringify(table.getState().sorting), rows.length]);
37848
37851
  const totalSize = virtualiser.getTotalSize();
37849
37852
  const virtualItems = virtualiser.getVirtualItems();
37850
37853
  const scrollToIndex = React.useCallback(
@@ -38564,14 +38567,13 @@ const DisplayRow = React.memo(function DisplayRow2(props) {
38564
38567
  }
38565
38568
  const ref = React.useRef(null);
38566
38569
  const expansionRef = React.useRef(null);
38567
- const rowSize = useResizeObserver$1(ref, true);
38568
38570
  const expandedRowSize = useResizeObserver$1(expansionRef, !!expandedRow);
38569
38571
  React.useEffect(() => {
38570
38572
  var _a2, _b2;
38571
38573
  const rowHeight = ((_a2 = ref.current) == null ? void 0 : _a2.getBoundingClientRect().height) ?? 0;
38572
38574
  const expansionHeight = ((_b2 = expansionRef.current) == null ? void 0 : _b2.getBoundingClientRect().height) ?? 0;
38573
38575
  measureRow(rowHeight + expansionHeight);
38574
- }, [rowSize, expandedRowSize, measureRow]);
38576
+ }, [expansionRef.current, expandedRowSize == null ? void 0 : expandedRowSize.height]);
38575
38577
  const className = clsx("group/row", otherAttributes.className, {
38576
38578
  "hover:cursor-grab": tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== "function",
38577
38579
  "hover:cursor-pointer": typeof attributes.onClick === "function"
@@ -45187,11 +45189,11 @@ function guessComparatorsBasedOnControl(column) {
45187
45189
  }
45188
45190
  const FilterContext = React.createContext([]);
45189
45191
  const FilterColumn = React.forwardRef((props, ref) => {
45190
- const { allColumns, onChange: handleChange, value = null, ...attributes } = props;
45192
+ const { allHeaders, onChange: handleChange, value = null, ...attributes } = props;
45191
45193
  const { texts } = useLocalization();
45192
45194
  const filters = React.useContext(FilterContext);
45193
- const selectedColumn = allColumns.find((column) => column.id === value);
45194
- const warning2 = selectedColumn && !selectedColumn.getIsVisible();
45195
+ const selectedColumn = allHeaders.find((header) => header.id === value);
45196
+ const warning2 = selectedColumn && !selectedColumn.column.getIsVisible();
45195
45197
  return /* @__PURE__ */ React.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ React.createElement(
45196
45198
  Field,
45197
45199
  {
@@ -45209,23 +45211,23 @@ const FilterColumn = React.forwardRef((props, ref) => {
45209
45211
  onChange: handleChange,
45210
45212
  value
45211
45213
  },
45212
- allColumns.map((column) => {
45213
- var _a, _b, _c;
45214
+ allHeaders.map((header) => {
45215
+ var _a, _b;
45214
45216
  return /* @__PURE__ */ React.createElement(
45215
45217
  Select22.Option,
45216
45218
  {
45217
- key: column.id,
45218
- value: column.id,
45219
- postfix: !column.getIsVisible() || column.getIsGrouped() ? /* @__PURE__ */ React.createElement(
45219
+ key: header.column.id,
45220
+ value: header.column.id,
45221
+ postfix: !header.column.getIsVisible() || header.column.getIsGrouped() ? /* @__PURE__ */ React.createElement(
45220
45222
  Tooltip$3,
45221
45223
  {
45222
- title: column.getIsGrouped() ? texts.table.filters.hiddenGroupedColumn : texts.table.filters.hiddenColumn
45224
+ title: header.column.getIsGrouped() ? texts.table.filters.hiddenGroupedColumn : texts.table.filters.hiddenColumn
45223
45225
  },
45224
45226
  /* @__PURE__ */ React.createElement(Icon$1, { name: "eye-off", className: "text-grey-500 !h-5 !w-5" })
45225
45227
  ) : void 0,
45226
- disabled: column.id !== value && (!column.getCanFilter() || !!filters.find((f2) => f2.id === column.id))
45228
+ disabled: header.column.id !== value && (!header.column.getCanFilter() || !!filters.find((f2) => f2.id === header.column.id))
45227
45229
  },
45228
- ((_a = column.columnDef.meta) == null ? void 0 : _a.header) + (column.parent ? ` (${(_c = (_b = column.parent) == null ? void 0 : _b.columnDef.meta) == null ? void 0 : _c.header})` : "")
45230
+ /* @__PURE__ */ React.createElement(React.Fragment, null, flexRender(header.column.columnDef.header, header.getContext()), header.column.parent ? ` (${flexRender((_b = (_a = header.column.parent) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.header, header.getContext())})` : "")
45229
45231
  );
45230
45232
  })
45231
45233
  )
@@ -45394,9 +45396,9 @@ function Control(props) {
45394
45396
  );
45395
45397
  }
45396
45398
  function Filter(props) {
45397
- const { allColumns, filter: filter2, onChange: handleChange, onRemove, position } = props;
45399
+ const { allHeaders, filter: filter2, onChange: handleChange, onRemove, position } = props;
45398
45400
  const { texts } = useLocalization();
45399
- const column = allColumns.find((c2) => c2.id === filter2.id);
45401
+ const column = allHeaders.find((header) => header.column.id === filter2.id);
45400
45402
  const ref = React.useRef(null);
45401
45403
  const {
45402
45404
  id: id2,
@@ -45404,13 +45406,13 @@ function Filter(props) {
45404
45406
  } = filter2;
45405
45407
  const handleChangeColumn = (columnId) => {
45406
45408
  var _a, _b, _c;
45407
- const previousColumn = allColumns.find((column2) => column2.id === id2);
45408
- const nextColumn = allColumns.find((column2) => column2.id === columnId);
45409
- if (((_a = previousColumn == null ? void 0 : previousColumn.columnDef.meta) == null ? void 0 : _a.dataType) && ((_b = previousColumn == null ? void 0 : previousColumn.columnDef.meta) == null ? void 0 : _b.dataType) === ((_c = nextColumn == null ? void 0 : nextColumn.columnDef.meta) == null ? void 0 : _c.dataType)) {
45409
+ const previousColumn = allHeaders.find((header) => header.column.id === id2);
45410
+ const nextColumn = allHeaders.find((header) => header.column.id === columnId);
45411
+ if (((_a = previousColumn == null ? void 0 : previousColumn.column.columnDef.meta) == null ? void 0 : _a.dataType) && ((_b = previousColumn == null ? void 0 : previousColumn.column.columnDef.meta) == null ? void 0 : _b.dataType) === ((_c = nextColumn == null ? void 0 : nextColumn.column.columnDef.meta) == null ? void 0 : _c.dataType)) {
45410
45412
  handleChange(position, { id: columnId, value: filter2.value });
45411
45413
  return;
45412
45414
  }
45413
- const validComparators = guessComparatorsBasedOnControl(nextColumn);
45415
+ const validComparators = guessComparatorsBasedOnControl(nextColumn == null ? void 0 : nextColumn.column);
45414
45416
  const value2 = {
45415
45417
  comparator: validComparators[0],
45416
45418
  value: void 0
@@ -45433,13 +45435,13 @@ function Filter(props) {
45433
45435
  ref.current.focus();
45434
45436
  }
45435
45437
  }, [id2]);
45436
- 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, { allColumns, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React.createElement(FilterComparator, { column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React.createElement(FilterValue, { column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
45438
+ 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);
45437
45439
  }
45438
45440
  const placeholderFilter = { id: "", value: { comparator: TableFilterComparator.Contains, value: void 0 } };
45439
45441
  function ManageFiltersPopover(props) {
45440
45442
  const { length, table, ...popoverProps } = props;
45441
45443
  const { locale: locale2, texts } = useLocalization();
45442
- const allColumns = table.getAllLeafColumns().filter((column) => !isInternalColumn(column.id)).sort(sortByHeader);
45444
+ const allHeaders = table.getLeafHeaders().filter((column) => !isInternalColumn(column.id)).sort((headerA, headerB) => sortByHeader(headerA.column, headerB.column));
45443
45445
  const columnFilters = table.getState().columnFilters;
45444
45446
  const tableMeta = table.options.meta;
45445
45447
  const [filters, setFilters] = React.useState(columnFilters.length ? columnFilters : [placeholderFilter]);
@@ -45478,7 +45480,7 @@ function ManageFiltersPopover(props) {
45478
45480
  if (f2.id === null || f2.id === "") {
45479
45481
  return false;
45480
45482
  }
45481
- const controlRenderer = (_b = (_a = allColumns.find((c2) => c2.id === f2.id)) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.control;
45483
+ const controlRenderer = (_b = (_a = allHeaders.find((header) => header.column.id === f2.id)) == null ? void 0 : _a.column.columnDef.meta) == null ? void 0 : _b.control;
45482
45484
  if (f2.value.comparator === TableFilterComparator.IsEmpty || f2.value.comparator === TableFilterComparator.IsNotEmpty || controlRenderer === "switch") {
45483
45485
  return true;
45484
45486
  }
@@ -45508,7 +45510,7 @@ function ManageFiltersPopover(props) {
45508
45510
  Filter,
45509
45511
  {
45510
45512
  key: `filter_${index2}`,
45511
- allColumns,
45513
+ allHeaders,
45512
45514
  filter: filter2,
45513
45515
  position: index2,
45514
45516
  onChange: handleChangeFilter,
@@ -53948,14 +53950,6 @@ function isTableScrolled(ref) {
53948
53950
  function useTableEditingListener(table, tableRef, scrollToIndex) {
53949
53951
  const tableMeta = table.options.meta;
53950
53952
  const localization = useLocalization();
53951
- useLazyEffect(() => {
53952
- return () => {
53953
- var _a;
53954
- if (tableMeta.editing.isEditing && tableMeta.rowActive.rowActiveIndex !== void 0) {
53955
- tableMeta.editing.saveChanges(table, (_a = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) == null ? void 0 : _a.id);
53956
- }
53957
- };
53958
- }, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.isEditing]);
53959
53953
  const hasChanges = tableMeta.editing.hasChanges();
53960
53954
  React.useEffect(() => {
53961
53955
  function showUnsavedChangesWarning(event) {
@@ -55300,7 +55294,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55300
55294
  var _a, _b, _c;
55301
55295
  return (_c = (_b = (_a = state.changes.errors) == null ? void 0 : _a[cell.row.id]) == null ? void 0 : _b.cells) == null ? void 0 : _c[cell.column.id];
55302
55296
  }
55303
- async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true) {
55297
+ async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true, shouldRunValidation = true) {
55304
55298
  var _a;
55305
55299
  const tableMeta = cell.getContext().table.options.meta;
55306
55300
  const state2 = tableMeta.editing.getState();
@@ -55330,7 +55324,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55330
55324
  const nextMoveReasons = { ...state2.changes.moveReasons[cell.row.id] };
55331
55325
  const nextCellErrors = { ...(_a = state2.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
55332
55326
  let validationErrors = {};
55333
- if (validator && Object.keys(nextChanges).length && original) {
55327
+ if (validator && Object.keys(nextChanges).length && original && shouldRunValidation) {
55334
55328
  const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };
55335
55329
  validationErrors = await validator(nextRowValue) ?? {};
55336
55330
  }
@@ -55812,7 +55806,7 @@ function EditingControlCell(props) {
55812
55806
  if (hasChanged) {
55813
55807
  tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
55814
55808
  if (hasNonTextControl) {
55815
- requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
55809
+ requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue, true, false));
55816
55810
  }
55817
55811
  }
55818
55812
  },
@@ -55825,7 +55819,7 @@ function EditingControlCell(props) {
55825
55819
  }
55826
55820
  requestAnimationFrame(() => {
55827
55821
  tableMeta.editing.toggleDetailedMode(false);
55828
- tableMeta.editing.onCellChanged(cell, rowIndex, void 0, !hasNonTextControl);
55822
+ tableMeta.editing.onCellChanged(cell, rowIndex, void 0, !hasNonTextControl, true);
55829
55823
  });
55830
55824
  },
55831
55825
  [hasNonTextControl, cell.row.id, JSON.stringify(rowChanges), rowIndex, cell.column.id, cell.row.original]
@@ -56121,6 +56115,11 @@ function Row(props) {
56121
56115
  }
56122
56116
  }
56123
56117
  }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);
56118
+ useLazyEffect(() => {
56119
+ if (tableMeta.editing.isEditing && !isActiveRow) {
56120
+ tableMeta.editing.saveChanges(table, row.id);
56121
+ }
56122
+ }, [isActiveRow]);
56124
56123
  const handleFocus = React.useCallback(
56125
56124
  (event) => {
56126
56125
  var _a;