@economic/taco 2.61.4 → 2.62.1

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
@@ -13486,6 +13486,11 @@ function isBefore(date2, dateToCompare) {
13486
13486
  const _dateToCompare = toDate(dateToCompare);
13487
13487
  return +_date < +_dateToCompare;
13488
13488
  }
13489
+ function isEqual$2(leftDate, rightDate) {
13490
+ const _dateLeft = toDate(leftDate);
13491
+ const _dateRight = toDate(rightDate);
13492
+ return +_dateLeft === +_dateRight;
13493
+ }
13489
13494
  function transpose(fromDate, constructor) {
13490
13495
  const date2 = constructor instanceof Date ? constructFrom(constructor, 0) : new constructor(0);
13491
13496
  date2.setFullYear(
@@ -35083,27 +35088,27 @@ function isMatched(query, cellValue, rowValue, dataType, dataTypeOptions, locali
35083
35088
  if (typeof cellValue === "object") {
35084
35089
  return flattenCellValue(cellValue).flat(Infinity).find((y2) => matcher(y2, query));
35085
35090
  } else {
35086
- const cellValueAsString = String(cellValue ?? "");
35087
- if (cellValueAsString !== void 0 && matcher(cellValueAsString, query)) {
35088
- return true;
35091
+ const dataTypeProperties = getDataTypeProperties(dataType);
35092
+ if (dataTypeProperties.getDisplayValue) {
35093
+ const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, rowValue, {
35094
+ dataTypeOptions,
35095
+ localization
35096
+ });
35097
+ if (Array.isArray(cellDisplayValue)) {
35098
+ return cellDisplayValue.some((cdv) => matcher(cdv, query));
35099
+ } else if (cellDisplayValue !== void 0 && isWeakContains(cellDisplayValue, query)) {
35100
+ return true;
35101
+ }
35089
35102
  } else {
35090
- const dataTypeProperties = getDataTypeProperties(dataType);
35091
- if (dataTypeProperties.getDisplayValue) {
35092
- const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, rowValue, {
35093
- dataTypeOptions,
35094
- localization
35095
- });
35096
- if (Array.isArray(cellDisplayValue)) {
35097
- return cellDisplayValue.some((cdv) => matcher(cdv, query));
35098
- } else if (cellDisplayValue !== void 0 && isWeakContains(cellDisplayValue, query)) {
35099
- return true;
35100
- }
35103
+ const cellValueAsString = String(cellValue ?? "");
35104
+ if (cellValueAsString !== void 0 && matcher(cellValueAsString, query)) {
35105
+ return true;
35101
35106
  }
35102
- if (typeof query !== typeof cellValue && dataTypeProperties.parse) {
35103
- const parsedQuery = dataTypeProperties.parse(query, localization.locale);
35104
- if (parsedQuery !== void 0 && matcher(cellValue, parsedQuery)) {
35105
- return true;
35106
- }
35107
+ }
35108
+ if (typeof query !== typeof cellValue && dataTypeProperties.parse) {
35109
+ const parsedQuery = dataTypeProperties.parse(query, localization.locale);
35110
+ if (parsedQuery !== void 0 && matcher(cellValue, parsedQuery)) {
35111
+ return true;
35107
35112
  }
35108
35113
  }
35109
35114
  }
@@ -35869,17 +35874,8 @@ function useTablePrintingSettings(tableId) {
35869
35874
  }
35870
35875
  const DEFAULT_ROW_ACTIONS_LENGTH = 4;
35871
35876
  function useTableRowActions(isEnabled = false, rowActions, rowActionsLength = DEFAULT_ROW_ACTIONS_LENGTH) {
35872
- const [handlers, setHandlers] = React.useState({});
35873
- const registerHandler = (key, handler) => {
35874
- return setHandlers((h2) => ({
35875
- ...h2,
35876
- [key]: handler
35877
- }));
35878
- };
35879
35877
  return {
35880
- handlers,
35881
35878
  isEnabled,
35882
- registerHandler,
35883
35879
  rowActions: isEnabled ? rowActions : void 0,
35884
35880
  rowActionsLength: rowActions ? Math.min(rowActions.length, rowActionsLength) : 0
35885
35881
  };
@@ -37796,7 +37792,7 @@ function getScrollPaddingEndOffset(table) {
37796
37792
  }
37797
37793
  function getPaddingEndOffset(table, options) {
37798
37794
  const bottomRows = table.getBottomRows() ?? [];
37799
- return ROW_HEIGHT_ESTIMATES.medium * ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ?? 1) * bottomRows.length;
37795
+ return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length + ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ?? 0);
37800
37796
  }
37801
37797
  const OVERSCAN_ROW_COUNT = 8;
37802
37798
  function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
@@ -37956,17 +37952,21 @@ function Actions(props) {
37956
37952
  const { actions, actionsLength, data, isActiveRow, rowId, table } = props;
37957
37953
  const { texts } = useLocalization();
37958
37954
  const tableMeta = table.options.meta;
37959
- const visibleActions = actions.map(
37960
- (action) => {
37961
- var _a2;
37962
- return action(data, {
37963
- cleanup: tableMeta.rowActions.handlers["cleanup"] ?? (() => void 0),
37964
- isEditing: ((_a2 = tableMeta.editing) == null ? void 0 : _a2.isEditing) ?? false,
37965
- rowId,
37966
- table
37967
- });
37955
+ const visibleActions = actions.map((action) => {
37956
+ var _a2, _b;
37957
+ const helpers = {
37958
+ rowId,
37959
+ table
37960
+ };
37961
+ if ((_a2 = tableMeta.editing) == null ? void 0 : _a2.isEnabled) {
37962
+ helpers.editing = {
37963
+ isEditing: ((_b = tableMeta.editing) == null ? void 0 : _b.isEditing) ?? false,
37964
+ removeRowChanges: () => tableMeta.editing.discardChanges(rowId, table),
37965
+ save: () => tableMeta.editing.saveChanges(table, rowId)
37966
+ };
37968
37967
  }
37969
- ).filter((action) => !!action);
37968
+ return action(data, helpers);
37969
+ }).filter((action) => !!action);
37970
37970
  let length = actionsLength;
37971
37971
  if ((_a = tableMeta.editing) == null ? void 0 : _a.isEditing) {
37972
37972
  const lengthWithoutEditingItems = visibleActions.length - 1;
@@ -44196,7 +44196,14 @@ const Placeholder = ({ disabled, readOnly, ...props }) => {
44196
44196
  if (readOnly) {
44197
44197
  return null;
44198
44198
  }
44199
- return /* @__PURE__ */ React.createElement("div", { ...props, className: clsx({ "text-grey-500": disabled, "text-grey-700": !disabled }) });
44199
+ return /* @__PURE__ */ React.createElement(
44200
+ "div",
44201
+ {
44202
+ ...props,
44203
+ className: clsx({ "text-grey-500": disabled, "text-grey-700": !disabled }),
44204
+ "data-taco": "select2-placeholder"
44205
+ }
44206
+ );
44200
44207
  };
44201
44208
  const Trigger = React.forwardRef(function Select2Trigger(props, ref) {
44202
44209
  const { multiple, value } = useSelect2Context();
@@ -44297,7 +44304,7 @@ const Single = React.forwardRef(function Select2TriggerSingle(props, ref) {
44297
44304
  output = /* @__PURE__ */ React.createElement(React.Fragment, null, currentValue.props.prefix ? typeof currentValue.props.prefix === "string" ? /* @__PURE__ */ React.createElement(Icon$1, { name: currentValue.props.prefix, className: "mr-1 !h-5 !w-5" }) : currentValue.props.prefix : null, currentValue.props.children);
44298
44305
  }
44299
44306
  }
44300
- return /* @__PURE__ */ React.createElement(Button$1, { ...buttonProps, ref }, /* @__PURE__ */ React.createElement("div", { className: contentClassName }, output));
44307
+ return /* @__PURE__ */ React.createElement(Button$1, { ...buttonProps, ref }, /* @__PURE__ */ React.createElement("div", { className: contentClassName, "data-taco": placeholder ? void 0 : "select2-value" }, output));
44301
44308
  });
44302
44309
  const Multiple = React.forwardRef(function Select2TriggerMultiple(props, ref) {
44303
44310
  var _a;
@@ -44313,8 +44320,9 @@ const Multiple = React.forwardRef(function Select2TriggerMultiple(props, ref) {
44313
44320
  let content;
44314
44321
  let { className } = buttonProps;
44315
44322
  if (open) {
44323
+ const hasValues = valuesAsChildren.length > 0;
44316
44324
  className = clsx("!absolute z-20 !h-fit", buttonProps.className);
44317
- content = /* @__PURE__ */ React.createElement(ScrollArea, { className: "my-1 flex max-h-[5.5rem] flex-col", onClick: forwardClick }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-wrap gap-1" }, valuesAsChildren.length === 0 ? /* @__PURE__ */ React.createElement(Placeholder, { disabled, readOnly }, placeholder) : valuesAsChildren.map(
44325
+ content = /* @__PURE__ */ React.createElement(ScrollArea, { className: "my-1 flex max-h-[5.5rem] flex-col", onClick: forwardClick }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-wrap gap-1" }, !hasValues ? /* @__PURE__ */ React.createElement(Placeholder, { disabled, readOnly }, placeholder) : valuesAsChildren.map(
44318
44326
  (child) => typeof child.props.children === "string" ? /* @__PURE__ */ React.createElement(
44319
44327
  Tag,
44320
44328
  {
@@ -44338,7 +44346,7 @@ const Multiple = React.forwardRef(function Select2TriggerMultiple(props, ref) {
44338
44346
  {
44339
44347
  key: String(child.props.value),
44340
44348
  className: "!pr-0 !pl-1.5",
44341
- children: /* @__PURE__ */ React.createElement("span", { className: "flex items-center" }, child.props.children.props.children, /* @__PURE__ */ React.createElement(
44349
+ children: /* @__PURE__ */ React.createElement("span", { className: "flex items-center", "data-taco": "select2-value" }, child.props.children.props.children, /* @__PURE__ */ React.createElement(
44342
44350
  Icon$1,
44343
44351
  {
44344
44352
  name: "close",
@@ -45340,17 +45348,6 @@ function Control(props) {
45340
45348
  return /* @__PURE__ */ React.createElement(Switch$1, { ...attributes, className: "m-1.5", checked: Boolean(value), onChange });
45341
45349
  } else if (controlRenderer === "checkbox") {
45342
45350
  return /* @__PURE__ */ React.createElement(Checkbox$2, { ...attributes, className: "!m-1.5", checked: Boolean(value), onChange });
45343
- } else if ((controlRenderer === "input" || controlRenderer === void 0) && dataType === "number") {
45344
- return /* @__PURE__ */ React.createElement(
45345
- Input,
45346
- {
45347
- ...attributes,
45348
- className: "flex-grow",
45349
- type: "number",
45350
- onChange: (event) => onChange(event.target.valueAsNumber),
45351
- value: String(value ?? "")
45352
- }
45353
- );
45354
45351
  }
45355
45352
  return /* @__PURE__ */ React.createElement(
45356
45353
  Input,
@@ -53907,9 +53904,10 @@ function isTableScrolled(ref) {
53907
53904
  var _a, _b, _c, _d;
53908
53905
  if (ref.current) {
53909
53906
  const height = parseFloat(((_b = (_a = ref.current) == null ? void 0 : _a.querySelector("tbody")) == null ? void 0 : _b.style.height) || "0") + parseFloat(((_d = (_c = ref.current) == null ? void 0 : _c.querySelector("tbody")) == null ? void 0 : _d.style.paddingBottom) || "0");
53910
- return height > ref.current.scrollHeight;
53907
+ const hasVerticalScrollbar = ref.current.scrollHeight > ref.current.clientHeight;
53908
+ return [hasVerticalScrollbar, height > ref.current.scrollHeight];
53911
53909
  }
53912
- return false;
53910
+ return [false, false];
53913
53911
  }
53914
53912
  function useTableEditingListener(table, tableRef, scrollToIndex) {
53915
53913
  const tableMeta = table.options.meta;
@@ -53955,13 +53953,6 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
53955
53953
  document.addEventListener("click", onClickOutside);
53956
53954
  return () => document.removeEventListener("click", onClickOutside);
53957
53955
  }, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
53958
- React.useEffect(() => {
53959
- if (tableMeta.editing.isEnabled) {
53960
- tableMeta.rowActions.registerHandler("cleanup", (rowId) => {
53961
- tableMeta.editing.discardChanges(rowId, table);
53962
- });
53963
- }
53964
- }, []);
53965
53956
  useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : void 0, (event) => {
53966
53957
  event.preventDefault();
53967
53958
  tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);
@@ -55060,7 +55051,8 @@ function reducer(state, action) {
55060
55051
  changes: {
55061
55052
  ...state.changes,
55062
55053
  rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
55063
- originals: setWith(state.changes.originals, rowId, row, Object)
55054
+ originals: setWith(state.changes.originals, rowId, row, Object),
55055
+ dirty: setWith(state.changes.dirty, rowId, true, Object)
55064
55056
  },
55065
55057
  indexes: setWith(state.indexes, rowId, index2, Object)
55066
55058
  };
@@ -55117,7 +55109,8 @@ function reducer(state, action) {
55117
55109
  errors: omit$1(state.changes.errors, rowId),
55118
55110
  moveReasons: omit$1(state.changes.moveReasons, rowId),
55119
55111
  originals: omit$1(state.changes.originals, rowId),
55120
- status: omit$1(state.changes.status, rowId)
55112
+ status: omit$1(state.changes.status, rowId),
55113
+ dirty: omit$1(state.changes.dirty, rowId)
55121
55114
  },
55122
55115
  indexes: omit$1(state.indexes, rowId),
55123
55116
  temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== rowId)
@@ -55184,7 +55177,7 @@ function reducer(state, action) {
55184
55177
  function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator) {
55185
55178
  const localization = useLocalization();
55186
55179
  const [state, dispatch] = React.useReducer(reducer, {
55187
- changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },
55180
+ changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {}, dirty: {} },
55188
55181
  indexes: {},
55189
55182
  temporaryRows: []
55190
55183
  });
@@ -55273,7 +55266,9 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55273
55266
  }
55274
55267
  async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true) {
55275
55268
  var _a;
55276
- const changes = nextValue !== void 0 ? { ...state.changes.rows[cell.row.id], [cell.column.id]: nextValue } : { ...state.changes.rows[cell.row.id] };
55269
+ const tableMeta = cell.getContext().table.options.meta;
55270
+ const state2 = tableMeta.editing.getState();
55271
+ const changes = nextValue !== void 0 ? { ...state2.changes.rows[cell.row.id], [cell.column.id]: nextValue } : { ...state2.changes.rows[cell.row.id] };
55277
55272
  const original = cell.row.original;
55278
55273
  if (!Object.keys(changes).length) {
55279
55274
  return;
@@ -55296,8 +55291,8 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55296
55291
  ) ?? {};
55297
55292
  }
55298
55293
  const nextChanges = { ...changes, ...updatesForOtherCells };
55299
- const nextMoveReasons = { ...state.changes.moveReasons[cell.row.id] };
55300
- const nextCellErrors = { ...(_a = state.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
55294
+ const nextMoveReasons = { ...state2.changes.moveReasons[cell.row.id] };
55295
+ const nextCellErrors = { ...(_a = state2.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
55301
55296
  let validationErrors = {};
55302
55297
  if (validator && Object.keys(nextChanges).length && original) {
55303
55298
  const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };
@@ -55334,8 +55329,11 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55334
55329
  }
55335
55330
  });
55336
55331
  }
55332
+ function getErrors() {
55333
+ return Object.keys(state.changes.errors);
55334
+ }
55337
55335
  function getErrorsShownInAlert() {
55338
- const rowsWithErrors = Object.keys(state.changes.errors);
55336
+ const rowsWithErrors = getErrors();
55339
55337
  if (!rowsWithErrors.length) {
55340
55338
  return [];
55341
55339
  }
@@ -55363,6 +55361,10 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55363
55361
  const changes = rowId ? { [rowId]: state2.changes.rows[rowId] } : state2.changes.rows;
55364
55362
  let completed = true;
55365
55363
  for (const rowId2 of Object.keys(changes)) {
55364
+ if (!state2.changes.dirty[rowId2]) {
55365
+ discardChanges(rowId2, table);
55366
+ continue;
55367
+ }
55366
55368
  const status = getRowStatus(rowId2);
55367
55369
  try {
55368
55370
  const rowChanges = JSON.parse(JSON.stringify(changes[rowId2] ?? {}));
@@ -55459,6 +55461,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55459
55461
  getCellError,
55460
55462
  onCellChanged,
55461
55463
  // general
55464
+ getErrors,
55462
55465
  getErrorsShownInAlert,
55463
55466
  hasChanges,
55464
55467
  saveChanges,
@@ -55469,7 +55472,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55469
55472
  temporaryRows: state.temporaryRows
55470
55473
  };
55471
55474
  }
55472
- function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator) {
55475
+ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator, onEvent) {
55473
55476
  const [isEditing, setEditing] = React.useState(false);
55474
55477
  const [isDetailedMode, toggleDetailedMode] = React.useState(false);
55475
55478
  const createRowButtonRef = React.useRef(null);
@@ -55481,8 +55484,13 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
55481
55484
  rowIdentityAccessor,
55482
55485
  validator
55483
55486
  );
55487
+ useLazyEffect(() => {
55488
+ if (onEvent) {
55489
+ onEvent("editing-mode", { enabled: isEditing });
55490
+ }
55491
+ }, [isEditing]);
55484
55492
  function toggleEditing(enabled, table, scrollToIndex) {
55485
- var _a, _b;
55493
+ var _a;
55486
55494
  const tableMeta = table.options.meta;
55487
55495
  if (enabled) {
55488
55496
  const index2 = tableMeta.rowActive.rowActiveIndex ?? 0;
@@ -55498,7 +55506,6 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
55498
55506
  }
55499
55507
  setEditing(enabled);
55500
55508
  pendingChangesFns.saveChanges(table);
55501
- (_b = tableMeta.onEvent) == null ? void 0 : _b.call(tableMeta, "editing-mode", { enabled });
55502
55509
  }
55503
55510
  async function createRow2(table, row) {
55504
55511
  if (!handleCreate) {
@@ -55516,18 +55523,18 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
55516
55523
  if (changeset) {
55517
55524
  const temporaryRows = tableMeta.editing.temporaryRows;
55518
55525
  const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
55519
- const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);
55520
- table.setRowPinning((currentState) => {
55521
- var _a;
55522
- return {
55523
- ...currentState,
55524
- bottom: (_a = currentState.bottom ?? []) == null ? void 0 : _a.concat(newRowId)
55525
- };
55526
- });
55527
- toggleDetailedMode(false);
55528
- setLastFocusedCellIndex(void 0);
55526
+ tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
55529
55527
  requestAnimationFrame(() => {
55530
- tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
55528
+ const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);
55529
+ table.setRowPinning((currentState) => {
55530
+ var _a;
55531
+ return {
55532
+ ...currentState,
55533
+ bottom: (_a = currentState.bottom ?? []) == null ? void 0 : _a.concat(newRowId)
55534
+ };
55535
+ });
55536
+ toggleDetailedMode(false);
55537
+ setLastFocusedCellIndex(void 0);
55531
55538
  table.resetRowSelection();
55532
55539
  if (!tableMeta.editing.isEditing) {
55533
55540
  setEditing(true);
@@ -55754,14 +55761,26 @@ function EditingControlCell(props) {
55754
55761
  }, [cellRef.current]);
55755
55762
  const handleChange = React.useCallback(
55756
55763
  (nextValue) => {
55757
- if (nextValue !== value) {
55764
+ let hasChanged = false;
55765
+ if (columnMeta.dataType === "date") {
55766
+ hasChanged = !isSameDay(new Date(nextValue), new Date(value));
55767
+ } else if (columnMeta.dataType === "datetime") {
55768
+ hasChanged = !isEqual$2(new Date(nextValue), new Date(value));
55769
+ } else if (columnMeta.dataType === "time") {
55770
+ const next = new Date(nextValue);
55771
+ const current = new Date(value);
55772
+ hasChanged = !(next.getHours() === current.getHours() && next.getMinutes() === current.getMinutes());
55773
+ } else {
55774
+ hasChanged = nextValue !== value;
55775
+ }
55776
+ if (hasChanged) {
55758
55777
  tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
55759
55778
  if (hasNonTextControl) {
55760
55779
  requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
55761
55780
  }
55762
55781
  }
55763
55782
  },
55764
- [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value]
55783
+ [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value, columnMeta.dataType]
55765
55784
  );
55766
55785
  const handleBlur = React.useCallback(
55767
55786
  (event) => {
@@ -56033,7 +56052,7 @@ function DiscardChangesConfirmationDialog(props) {
56033
56052
  event.stopPropagation();
56034
56053
  }
56035
56054
  };
56036
- return /* @__PURE__ */ React.createElement(Dialog, { ...dialogProps }, /* @__PURE__ */ React.createElement(
56055
+ return /* @__PURE__ */ React.createElement(Dialog, { ...dialogProps, showCloseButton: false }, /* @__PURE__ */ React.createElement(
56037
56056
  Dialog.Content,
56038
56057
  {
56039
56058
  "aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
@@ -56042,7 +56061,15 @@ function DiscardChangesConfirmationDialog(props) {
56042
56061
  },
56043
56062
  /* @__PURE__ */ React.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title),
56044
56063
  /* @__PURE__ */ React.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description),
56045
- /* @__PURE__ */ React.createElement(Dialog.Footer, null, /* @__PURE__ */ React.createElement(Group$6, null, /* @__PURE__ */ React.createElement(Dialog.Close, null, /* @__PURE__ */ React.createElement(Button$4, { tabIndex: 0 }, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /* @__PURE__ */ React.createElement(Dialog.Close, null, /* @__PURE__ */ React.createElement(Button$4, { tabIndex: 0, appearance: "primary", onClick: handleDiscard }, texts.table3.editing.clearChangesConfirmationDialog.confirm))))
56064
+ /* @__PURE__ */ React.createElement($9bf71ea28793e738$export$20e40289641fbbb6, { contain: true, restoreFocus: true }, /* @__PURE__ */ React.createElement(Dialog.Footer, null, /* @__PURE__ */ React.createElement(Group$6, null, /* @__PURE__ */ React.createElement(Dialog.Close, null, /* @__PURE__ */ React.createElement(Button$4, { tabIndex: 0 }, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /* @__PURE__ */ React.createElement(Dialog.Close, null, /* @__PURE__ */ React.createElement(Button$4, { tabIndex: 0, appearance: "primary", onClick: handleDiscard }, texts.table3.editing.clearChangesConfirmationDialog.confirm)))), /* @__PURE__ */ React.createElement($5d3850c4d0b4e6c7$export$f39c2d165cd861fe, { asChild: true }, /* @__PURE__ */ React.createElement(
56065
+ IconButton,
56066
+ {
56067
+ appearance: "discrete",
56068
+ "aria-label": texts.dialog.close,
56069
+ className: "absolute right-0 top-0 mr-2 mt-2 print:hidden",
56070
+ icon: "close"
56071
+ }
56072
+ )))
56046
56073
  ));
56047
56074
  }
56048
56075
  function Row(props) {
@@ -56090,7 +56117,7 @@ function Row(props) {
56090
56117
  if (event.isDefaultPrevented() || event.isPropagationStopped()) {
56091
56118
  return;
56092
56119
  }
56093
- if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !isElementTriggeredFromContainer(event.target, event.currentTarget)) {
56120
+ if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !isElementInsideOverlay(event.target)) {
56094
56121
  event.preventDefault();
56095
56122
  setShowDiscardDialog(true);
56096
56123
  }
@@ -56123,7 +56150,8 @@ function useTable3(props, ref) {
56123
56150
  props.onEditingCreate,
56124
56151
  props.onEditingDiscard,
56125
56152
  props.rowIdentityAccessor,
56126
- props.validator
56153
+ props.validator,
56154
+ props.onEvent
56127
56155
  );
56128
56156
  const data = React.useMemo(() => {
56129
56157
  if (editing.temporaryRows.length) {
@@ -56175,18 +56203,33 @@ function useTable3(props, ref) {
56175
56203
  };
56176
56204
  const meta = { editing };
56177
56205
  const options = {
56178
- virtualiserPaddingEndOffset: props.enableEditing && props.onEditingCreate ? editing.hasTemporaryRowErrors() ? 1.4 : 1 : 0
56206
+ virtualiserPaddingEndOffset: 0
56179
56207
  };
56208
+ if (props.enableEditing) {
56209
+ const validationErrorLabelHeight = 17;
56210
+ options.virtualiserPaddingEndOffset = editing.getErrors().length * validationErrorLabelHeight;
56211
+ }
56180
56212
  const table = useTable$1(extendedProps, ref, RENDERERS, meta, options);
56181
56213
  useTableEditingListener(table.instance, table.ref, table.renderer.scrollToIndex);
56182
56214
  React.useEffect(() => {
56183
56215
  if (table.ref.current) {
56184
- table.ref.current.instance.toggleEditing = (enabled) => table.meta.editing.toggleEditing(enabled ?? ((editing2) => !editing2), table.instance, table.renderer.scrollToIndex);
56185
- if (props.onEditingCreate) {
56186
- table.ref.current.instance.createRow = (row) => table.meta.editing.createRow(table.instance, row);
56216
+ const instance = table.ref.current.instance;
56217
+ if (table.meta.editing.isEnabled) {
56218
+ instance.editing = {
56219
+ toggleEditing: (enabled) => table.meta.editing.toggleEditing(
56220
+ enabled ?? ((editing2) => !editing2),
56221
+ table.instance,
56222
+ table.renderer.scrollToIndex
56223
+ ),
56224
+ removeRowChanges: (rowId) => table.meta.editing.discardChanges(rowId, table.instance),
56225
+ save: (rowId) => table.meta.editing.saveChanges(table.instance, rowId)
56226
+ };
56227
+ if (props.onEditingCreate) {
56228
+ instance.editing.createRow = (row) => table.meta.editing.createRow(table.instance, row);
56229
+ }
56187
56230
  }
56188
56231
  }
56189
- }, [table.ref.current]);
56232
+ }, [table.ref.current, table.meta.editing.isEnabled]);
56190
56233
  return table;
56191
56234
  }
56192
56235
  function Alert(props) {
@@ -56296,7 +56339,7 @@ function Editing(props) {
56296
56339
  }
56297
56340
  function CreateNewRow(props) {
56298
56341
  var _a, _b;
56299
- const { buttonRef, isScrolled, table, tableMeta } = props;
56342
+ const { buttonRef, hasScrollbar, table, tableMeta } = props;
56300
56343
  const { texts } = useLocalization();
56301
56344
  const temporaryRows = tableMeta.editing.temporaryRows;
56302
56345
  const temporaryRowId = ((_a = temporaryRows[0]) == null ? void 0 : _a[tableMeta.rowIdentityAccessor]) ?? "";
@@ -56319,7 +56362,8 @@ function CreateNewRow(props) {
56319
56362
  }
56320
56363
  const className = clsx("group/row !sticky z-[21]", {
56321
56364
  "bottom-10": tableMeta.footer.isEnabled,
56322
- "bottom-0": !tableMeta.footer.isEnabled
56365
+ "bottom-0": !tableMeta.footer.isEnabled,
56366
+ "border-b !border-t-[0]": !hasScrollbar
56323
56367
  });
56324
56368
  return /* @__PURE__ */ React.createElement("tr", { "data-row-create": true, className, tabIndex: -1 }, /* @__PURE__ */ React.createElement("td", { className: "!bg-grey-50 col-span-full !px-1" }, /* @__PURE__ */ React.createElement(
56325
56369
  Button$4,
@@ -56340,9 +56384,8 @@ function TemporaryRows(props) {
56340
56384
  return props.table.getBottomRows().map((row) => /* @__PURE__ */ React.createElement(TemporaryRow, { key: row.id, row, ...props }));
56341
56385
  }
56342
56386
  function TemporaryRow(props) {
56343
- const { createRowButtonRef, row, table, tableMeta, tableRef } = props;
56387
+ const { createRowButtonRef, hasScrollbar, row, table, tableMeta, tableRef } = props;
56344
56388
  const handleKeyDown = async (event) => {
56345
- var _a;
56346
56389
  const target = event.target;
56347
56390
  if (isAriaDirectionKey(event) && isElementInsideExternalRelatedOverlay(target, tableRef)) {
56348
56391
  return;
@@ -56352,12 +56395,16 @@ function TemporaryRow(props) {
56352
56395
  if (!isElementTriggeredFromContainer(target, event.currentTarget)) {
56353
56396
  const saved = await tableMeta.editing.saveChanges(table);
56354
56397
  if (saved) {
56355
- (_a = createRowButtonRef.current) == null ? void 0 : _a.focus();
56398
+ requestAnimationFrame(() => {
56399
+ var _a;
56400
+ (_a = createRowButtonRef.current) == null ? void 0 : _a.focus();
56401
+ });
56356
56402
  }
56357
56403
  }
56358
56404
  } else if (event.key === "ArrowUp") {
56359
56405
  event.preventDefault();
56360
56406
  event.stopPropagation();
56407
+ await tableMeta.editing.saveChanges(table);
56361
56408
  const lastIndex = tableMeta.length - 1;
56362
56409
  tableMeta.rowActive.setRowActiveIndex(lastIndex);
56363
56410
  if (tableRef.current) {
@@ -56370,20 +56417,10 @@ function TemporaryRow(props) {
56370
56417
  }
56371
56418
  }
56372
56419
  };
56373
- const handleKeyDownCapture = (event) => {
56374
- if (event.key === "ArrowLeft" && tableMeta.editing.lastFocusedCellIndex === 0) {
56375
- event.preventDefault();
56376
- event.stopPropagation();
56377
- } else if (event.key === "ArrowRight" && tableMeta.editing.lastFocusedCellIndex) {
56378
- if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {
56379
- event.preventDefault();
56380
- event.stopPropagation();
56381
- }
56382
- }
56383
- };
56384
56420
  const className = clsx("group/row border-grey-300 !sticky z-[22] print:hidden border-t-2", {
56385
56421
  "bottom-[calc(5rem_+_5px)] data-[row-editing-move]:bottom-[calc(5rem_+_5px)]": tableMeta.footer.isEnabled,
56386
- "bottom-[calc(2.5rem_+_5px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_5px)]": !tableMeta.footer.isEnabled
56422
+ "bottom-[calc(2.5rem_+_5px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_5px)]": !tableMeta.footer.isEnabled,
56423
+ "border-b !border-t": !hasScrollbar
56387
56424
  });
56388
56425
  return /* @__PURE__ */ React.createElement(
56389
56426
  Row$2,
@@ -56397,7 +56434,6 @@ function TemporaryRow(props) {
56397
56434
  table,
56398
56435
  className,
56399
56436
  onKeyDown: handleKeyDown,
56400
- onKeyDownCapture: handleKeyDownCapture,
56401
56437
  hideInternalColumns: true,
56402
56438
  hideRowActions: !tableMeta.editing.isEditing,
56403
56439
  skipPageLoading: true
@@ -56425,14 +56461,14 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
56425
56461
  return rowsById[row.rowId];
56426
56462
  }).length;
56427
56463
  const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;
56428
- const isScrolled = isTableScrolled(table3.ref);
56464
+ const [hasScrollbar, isScrolled] = isTableScrolled(table3.ref);
56429
56465
  let createWorkflow;
56430
56466
  if (hasCreateWorkflow) {
56431
56467
  createWorkflow = /* @__PURE__ */ React.createElement(
56432
56468
  CreateNewRow,
56433
56469
  {
56434
56470
  buttonRef: table3.meta.editing.createRowButtonRef,
56435
- isScrolled,
56471
+ hasScrollbar,
56436
56472
  table: table3.instance,
56437
56473
  tableMeta: table3.meta
56438
56474
  }
@@ -56458,6 +56494,7 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
56458
56494
  TemporaryRows,
56459
56495
  {
56460
56496
  createRowButtonRef: table3.meta.editing.createRowButtonRef,
56497
+ hasScrollbar,
56461
56498
  table: table3.instance,
56462
56499
  tableMeta: table3.meta,
56463
56500
  tableRef: table3.ref