@economic/taco 2.61.3 → 2.62.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.d.ts CHANGED
@@ -3062,8 +3062,12 @@ export declare type Table3Props<TType = unknown> = Table3WithoutEditingWithClien
3062
3062
 
3063
3063
  export declare type Table3Ref = TableRef & {
3064
3064
  instance: {
3065
- toggleEditing: (enabled: boolean | undefined) => void;
3066
- createRow?: (row: unknown) => Promise<void>;
3065
+ editing?: {
3066
+ toggleEditing: (enabled: boolean | undefined) => void;
3067
+ createRow?: (row: unknown) => Promise<void>;
3068
+ save: (rowId: string) => Promise<boolean>;
3069
+ removeRowChanges: (rowId: string) => Promise<void>;
3070
+ };
3067
3071
  };
3068
3072
  };
3069
3073
 
@@ -3408,8 +3412,11 @@ export declare type TableRef = HTMLTableElement & {
3408
3412
  export declare type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;
3409
3413
 
3410
3414
  export declare type TableRowActionRenderer<TType = unknown> = (row: TType, helpers: {
3411
- cleanup: (rowId: string) => void;
3412
- isEditing: boolean;
3415
+ editing?: {
3416
+ isEditing: boolean;
3417
+ removeRowChanges: () => Promise<void>;
3418
+ save: () => Promise<boolean>;
3419
+ };
3413
3420
  }) => JSX.Element | null;
3414
3421
 
3415
3422
  export declare type TableRowClickHandler<TType = unknown> = (row: TType) => void;
package/dist/taco.js CHANGED
@@ -13468,6 +13468,11 @@ function isBefore(date2, dateToCompare) {
13468
13468
  const _dateToCompare = toDate(dateToCompare);
13469
13469
  return +_date < +_dateToCompare;
13470
13470
  }
13471
+ function isEqual$2(leftDate, rightDate) {
13472
+ const _dateLeft = toDate(leftDate);
13473
+ const _dateRight = toDate(rightDate);
13474
+ return +_dateLeft === +_dateRight;
13475
+ }
13471
13476
  function transpose(fromDate, constructor) {
13472
13477
  const date2 = constructor instanceof Date ? constructFrom(constructor, 0) : new constructor(0);
13473
13478
  date2.setFullYear(
@@ -29775,13 +29780,12 @@ const Item$2 = React.forwardRef(function MenuItem(props, ref) {
29775
29780
  className: props.className
29776
29781
  });
29777
29782
  const disabled = props.disabled ?? props["aria-disabled"];
29778
- let handleClick;
29779
- if (disabled) {
29780
- handleClick = (event) => {
29783
+ const handleClick = (event) => {
29784
+ if (disabled) {
29781
29785
  event.preventDefault();
29782
- event.stopPropagation();
29783
- };
29784
- }
29786
+ }
29787
+ event.stopPropagation();
29788
+ };
29785
29789
  if (subMenu) {
29786
29790
  return /* @__PURE__ */ React.createElement($d08ef79370b62062$export$d7a01e11500dfb6f, null, /* @__PURE__ */ React.createElement($d08ef79370b62062$export$2ea8a7a591ac5eac, { ...otherProps, className, onClick: handleClick, ref }, icon ? /* @__PURE__ */ React.createElement(Icon, { name: icon }) : null, props.children, /* @__PURE__ */ React.createElement(Icon$1, { className: "-mr-1.5 ml-auto !h-5 !w-5", name: "chevron-right" })), subMenu());
29787
29791
  }
@@ -35066,27 +35070,27 @@ function isMatched(query, cellValue, rowValue, dataType, dataTypeOptions, locali
35066
35070
  if (typeof cellValue === "object") {
35067
35071
  return flattenCellValue(cellValue).flat(Infinity).find((y2) => matcher(y2, query));
35068
35072
  } else {
35069
- const cellValueAsString = String(cellValue ?? "");
35070
- if (cellValueAsString !== void 0 && matcher(cellValueAsString, query)) {
35071
- return true;
35073
+ const dataTypeProperties = getDataTypeProperties(dataType);
35074
+ if (dataTypeProperties.getDisplayValue) {
35075
+ const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, rowValue, {
35076
+ dataTypeOptions,
35077
+ localization
35078
+ });
35079
+ if (Array.isArray(cellDisplayValue)) {
35080
+ return cellDisplayValue.some((cdv) => matcher(cdv, query));
35081
+ } else if (cellDisplayValue !== void 0 && isWeakContains(cellDisplayValue, query)) {
35082
+ return true;
35083
+ }
35072
35084
  } else {
35073
- const dataTypeProperties = getDataTypeProperties(dataType);
35074
- if (dataTypeProperties.getDisplayValue) {
35075
- const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, rowValue, {
35076
- dataTypeOptions,
35077
- localization
35078
- });
35079
- if (Array.isArray(cellDisplayValue)) {
35080
- return cellDisplayValue.some((cdv) => matcher(cdv, query));
35081
- } else if (cellDisplayValue !== void 0 && isWeakContains(cellDisplayValue, query)) {
35082
- return true;
35083
- }
35085
+ const cellValueAsString = String(cellValue ?? "");
35086
+ if (cellValueAsString !== void 0 && matcher(cellValueAsString, query)) {
35087
+ return true;
35084
35088
  }
35085
- if (typeof query !== typeof cellValue && dataTypeProperties.parse) {
35086
- const parsedQuery = dataTypeProperties.parse(query, localization.locale);
35087
- if (parsedQuery !== void 0 && matcher(cellValue, parsedQuery)) {
35088
- return true;
35089
- }
35089
+ }
35090
+ if (typeof query !== typeof cellValue && dataTypeProperties.parse) {
35091
+ const parsedQuery = dataTypeProperties.parse(query, localization.locale);
35092
+ if (parsedQuery !== void 0 && matcher(cellValue, parsedQuery)) {
35093
+ return true;
35090
35094
  }
35091
35095
  }
35092
35096
  }
@@ -35852,17 +35856,8 @@ function useTablePrintingSettings(tableId) {
35852
35856
  }
35853
35857
  const DEFAULT_ROW_ACTIONS_LENGTH = 4;
35854
35858
  function useTableRowActions(isEnabled = false, rowActions, rowActionsLength = DEFAULT_ROW_ACTIONS_LENGTH) {
35855
- const [handlers, setHandlers] = React__default.useState({});
35856
- const registerHandler = (key, handler) => {
35857
- return setHandlers((h2) => ({
35858
- ...h2,
35859
- [key]: handler
35860
- }));
35861
- };
35862
35859
  return {
35863
- handlers,
35864
35860
  isEnabled,
35865
- registerHandler,
35866
35861
  rowActions: isEnabled ? rowActions : void 0,
35867
35862
  rowActionsLength: rowActions ? Math.min(rowActions.length, rowActionsLength) : 0
35868
35863
  };
@@ -37779,7 +37774,7 @@ function getScrollPaddingEndOffset(table) {
37779
37774
  }
37780
37775
  function getPaddingEndOffset(table, options) {
37781
37776
  const bottomRows = table.getBottomRows() ?? [];
37782
- return ROW_HEIGHT_ESTIMATES.medium * ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ?? 1) * bottomRows.length;
37777
+ return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length + ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ?? 0);
37783
37778
  }
37784
37779
  const OVERSCAN_ROW_COUNT = 8;
37785
37780
  function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
@@ -37939,17 +37934,21 @@ function Actions(props) {
37939
37934
  const { actions, actionsLength, data, isActiveRow, rowId, table } = props;
37940
37935
  const { texts } = useLocalization();
37941
37936
  const tableMeta = table.options.meta;
37942
- const visibleActions = actions.map(
37943
- (action) => {
37944
- var _a2;
37945
- return action(data, {
37946
- cleanup: tableMeta.rowActions.handlers["cleanup"] ?? (() => void 0),
37937
+ const visibleActions = actions.map((action) => {
37938
+ var _a2;
37939
+ const helpers = {
37940
+ rowId,
37941
+ table
37942
+ };
37943
+ if (tableMeta.editing.isEnabled) {
37944
+ helpers.editing = {
37947
37945
  isEditing: ((_a2 = tableMeta.editing) == null ? void 0 : _a2.isEditing) ?? false,
37948
- rowId,
37949
- table
37950
- });
37946
+ removeRowChanges: () => tableMeta.editing.discardChanges(rowId, table),
37947
+ save: () => tableMeta.editing.saveChanges(table, rowId)
37948
+ };
37951
37949
  }
37952
- ).filter((action) => !!action);
37950
+ return action(data, helpers);
37951
+ }).filter((action) => !!action);
37953
37952
  let length = actionsLength;
37954
37953
  if ((_a = tableMeta.editing) == null ? void 0 : _a.isEditing) {
37955
37954
  const lengthWithoutEditingItems = visibleActions.length - 1;
@@ -44179,7 +44178,14 @@ const Placeholder = ({ disabled, readOnly, ...props }) => {
44179
44178
  if (readOnly) {
44180
44179
  return null;
44181
44180
  }
44182
- return /* @__PURE__ */ React__default.createElement("div", { ...props, className: clsx({ "text-grey-500": disabled, "text-grey-700": !disabled }) });
44181
+ return /* @__PURE__ */ React__default.createElement(
44182
+ "div",
44183
+ {
44184
+ ...props,
44185
+ className: clsx({ "text-grey-500": disabled, "text-grey-700": !disabled }),
44186
+ "data-taco": "select2-placeholder"
44187
+ }
44188
+ );
44183
44189
  };
44184
44190
  const Trigger = React__default.forwardRef(function Select2Trigger(props, ref) {
44185
44191
  const { multiple, value } = useSelect2Context();
@@ -44280,7 +44286,7 @@ const Single = React__default.forwardRef(function Select2TriggerSingle(props, re
44280
44286
  output = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, currentValue.props.prefix ? typeof currentValue.props.prefix === "string" ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: currentValue.props.prefix, className: "mr-1 !h-5 !w-5" }) : currentValue.props.prefix : null, currentValue.props.children);
44281
44287
  }
44282
44288
  }
44283
- return /* @__PURE__ */ React__default.createElement(Button$1, { ...buttonProps, ref }, /* @__PURE__ */ React__default.createElement("div", { className: contentClassName }, output));
44289
+ return /* @__PURE__ */ React__default.createElement(Button$1, { ...buttonProps, ref }, /* @__PURE__ */ React__default.createElement("div", { className: contentClassName, "data-taco": placeholder ? void 0 : "select2-value" }, output));
44284
44290
  });
44285
44291
  const Multiple = React__default.forwardRef(function Select2TriggerMultiple(props, ref) {
44286
44292
  var _a;
@@ -44296,8 +44302,9 @@ const Multiple = React__default.forwardRef(function Select2TriggerMultiple(props
44296
44302
  let content;
44297
44303
  let { className } = buttonProps;
44298
44304
  if (open) {
44305
+ const hasValues = valuesAsChildren.length > 0;
44299
44306
  className = clsx("!absolute z-20 !h-fit", buttonProps.className);
44300
- content = /* @__PURE__ */ React__default.createElement(ScrollArea, { className: "my-1 flex max-h-[5.5rem] flex-col", onClick: forwardClick }, /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-wrap gap-1" }, valuesAsChildren.length === 0 ? /* @__PURE__ */ React__default.createElement(Placeholder, { disabled, readOnly }, placeholder) : valuesAsChildren.map(
44307
+ content = /* @__PURE__ */ React__default.createElement(ScrollArea, { className: "my-1 flex max-h-[5.5rem] flex-col", onClick: forwardClick }, /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-wrap gap-1" }, !hasValues ? /* @__PURE__ */ React__default.createElement(Placeholder, { disabled, readOnly }, placeholder) : valuesAsChildren.map(
44301
44308
  (child) => typeof child.props.children === "string" ? /* @__PURE__ */ React__default.createElement(
44302
44309
  Tag,
44303
44310
  {
@@ -44321,7 +44328,7 @@ const Multiple = React__default.forwardRef(function Select2TriggerMultiple(props
44321
44328
  {
44322
44329
  key: String(child.props.value),
44323
44330
  className: "!pr-0 !pl-1.5",
44324
- children: /* @__PURE__ */ React__default.createElement("span", { className: "flex items-center" }, child.props.children.props.children, /* @__PURE__ */ React__default.createElement(
44331
+ children: /* @__PURE__ */ React__default.createElement("span", { className: "flex items-center", "data-taco": "select2-value" }, child.props.children.props.children, /* @__PURE__ */ React__default.createElement(
44325
44332
  Icon$1,
44326
44333
  {
44327
44334
  name: "close",
@@ -45323,17 +45330,6 @@ function Control(props) {
45323
45330
  return /* @__PURE__ */ React__default.createElement(Switch$1, { ...attributes, className: "m-1.5", checked: Boolean(value), onChange });
45324
45331
  } else if (controlRenderer === "checkbox") {
45325
45332
  return /* @__PURE__ */ React__default.createElement(Checkbox$2, { ...attributes, className: "!m-1.5", checked: Boolean(value), onChange });
45326
- } else if ((controlRenderer === "input" || controlRenderer === void 0) && dataType === "number") {
45327
- return /* @__PURE__ */ React__default.createElement(
45328
- Input,
45329
- {
45330
- ...attributes,
45331
- className: "flex-grow",
45332
- type: "number",
45333
- onChange: (event) => onChange(event.target.valueAsNumber),
45334
- value: String(value ?? "")
45335
- }
45336
- );
45337
45333
  }
45338
45334
  return /* @__PURE__ */ React__default.createElement(
45339
45335
  Input,
@@ -53890,9 +53886,10 @@ function isTableScrolled(ref) {
53890
53886
  var _a, _b, _c, _d;
53891
53887
  if (ref.current) {
53892
53888
  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");
53893
- return height > ref.current.scrollHeight;
53889
+ const hasVerticalScrollbar = ref.current.scrollHeight > ref.current.clientHeight;
53890
+ return [hasVerticalScrollbar, height > ref.current.scrollHeight];
53894
53891
  }
53895
- return false;
53892
+ return [false, false];
53896
53893
  }
53897
53894
  function useTableEditingListener(table, tableRef, scrollToIndex) {
53898
53895
  const tableMeta = table.options.meta;
@@ -53904,7 +53901,7 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
53904
53901
  tableMeta.editing.saveChanges(table, (_a = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) == null ? void 0 : _a.id);
53905
53902
  }
53906
53903
  };
53907
- }, [tableMeta.rowActive.rowActiveIndex]);
53904
+ }, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.isEditing]);
53908
53905
  const hasChanges = tableMeta.editing.hasChanges();
53909
53906
  React__default.useEffect(() => {
53910
53907
  function showUnsavedChangesWarning(event) {
@@ -53938,13 +53935,6 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
53938
53935
  document.addEventListener("click", onClickOutside);
53939
53936
  return () => document.removeEventListener("click", onClickOutside);
53940
53937
  }, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
53941
- React__default.useEffect(() => {
53942
- if (tableMeta.editing.isEnabled) {
53943
- tableMeta.rowActions.registerHandler("cleanup", (rowId) => {
53944
- tableMeta.editing.discardChanges(rowId, table);
53945
- });
53946
- }
53947
- }, []);
53948
53938
  useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : void 0, (event) => {
53949
53939
  event.preventDefault();
53950
53940
  tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);
@@ -55043,7 +55033,8 @@ function reducer(state, action) {
55043
55033
  changes: {
55044
55034
  ...state.changes,
55045
55035
  rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
55046
- originals: setWith(state.changes.originals, rowId, row, Object)
55036
+ originals: setWith(state.changes.originals, rowId, row, Object),
55037
+ dirty: setWith(state.changes.dirty, rowId, true, Object)
55047
55038
  },
55048
55039
  indexes: setWith(state.indexes, rowId, index2, Object)
55049
55040
  };
@@ -55100,7 +55091,8 @@ function reducer(state, action) {
55100
55091
  errors: omit$1(state.changes.errors, rowId),
55101
55092
  moveReasons: omit$1(state.changes.moveReasons, rowId),
55102
55093
  originals: omit$1(state.changes.originals, rowId),
55103
- status: omit$1(state.changes.status, rowId)
55094
+ status: omit$1(state.changes.status, rowId),
55095
+ dirty: omit$1(state.changes.dirty, rowId)
55104
55096
  },
55105
55097
  indexes: omit$1(state.indexes, rowId),
55106
55098
  temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== rowId)
@@ -55167,7 +55159,7 @@ function reducer(state, action) {
55167
55159
  function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator) {
55168
55160
  const localization = useLocalization();
55169
55161
  const [state, dispatch] = React__default.useReducer(reducer, {
55170
- changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },
55162
+ changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {}, dirty: {} },
55171
55163
  indexes: {},
55172
55164
  temporaryRows: []
55173
55165
  });
@@ -55256,7 +55248,9 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55256
55248
  }
55257
55249
  async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true) {
55258
55250
  var _a;
55259
- const changes = nextValue !== void 0 ? { ...state.changes.rows[cell.row.id], [cell.column.id]: nextValue } : { ...state.changes.rows[cell.row.id] };
55251
+ const tableMeta = cell.getContext().table.options.meta;
55252
+ const state2 = tableMeta.editing.getState();
55253
+ const changes = nextValue !== void 0 ? { ...state2.changes.rows[cell.row.id], [cell.column.id]: nextValue } : { ...state2.changes.rows[cell.row.id] };
55260
55254
  const original = cell.row.original;
55261
55255
  if (!Object.keys(changes).length) {
55262
55256
  return;
@@ -55279,8 +55273,8 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55279
55273
  ) ?? {};
55280
55274
  }
55281
55275
  const nextChanges = { ...changes, ...updatesForOtherCells };
55282
- const nextMoveReasons = { ...state.changes.moveReasons[cell.row.id] };
55283
- const nextCellErrors = { ...(_a = state.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
55276
+ const nextMoveReasons = { ...state2.changes.moveReasons[cell.row.id] };
55277
+ const nextCellErrors = { ...(_a = state2.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
55284
55278
  let validationErrors = {};
55285
55279
  if (validator && Object.keys(nextChanges).length && original) {
55286
55280
  const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };
@@ -55317,8 +55311,11 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55317
55311
  }
55318
55312
  });
55319
55313
  }
55314
+ function getErrors() {
55315
+ return Object.keys(state.changes.errors);
55316
+ }
55320
55317
  function getErrorsShownInAlert() {
55321
- const rowsWithErrors = Object.keys(state.changes.errors);
55318
+ const rowsWithErrors = getErrors();
55322
55319
  if (!rowsWithErrors.length) {
55323
55320
  return [];
55324
55321
  }
@@ -55337,13 +55334,19 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55337
55334
  }
55338
55335
  async function saveChanges(table, rowId = void 0) {
55339
55336
  var _a, _b, _c;
55337
+ const tableMeta = table.options.meta;
55338
+ const state2 = tableMeta.editing.getState();
55340
55339
  if (!handleSave) {
55341
55340
  console.warn("Tried to save, but Table has no onEditingSave handler");
55342
55341
  return false;
55343
55342
  }
55344
- const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;
55343
+ const changes = rowId ? { [rowId]: state2.changes.rows[rowId] } : state2.changes.rows;
55345
55344
  let completed = true;
55346
55345
  for (const rowId2 of Object.keys(changes)) {
55346
+ if (!state2.changes.dirty[rowId2]) {
55347
+ discardChanges(rowId2, table);
55348
+ continue;
55349
+ }
55347
55350
  const status = getRowStatus(rowId2);
55348
55351
  try {
55349
55352
  const rowChanges = JSON.parse(JSON.stringify(changes[rowId2] ?? {}));
@@ -55351,7 +55354,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55351
55354
  continue;
55352
55355
  }
55353
55356
  setRowStatus(rowId2, "saving");
55354
- const changeSet = { ...state.changes.originals[rowId2], ...rowChanges };
55357
+ const changeSet = { ...state2.changes.originals[rowId2], ...rowChanges };
55355
55358
  if (isTemporaryRow(changeSet[rowIdentityAccessor])) {
55356
55359
  delete changeSet[rowIdentityAccessor];
55357
55360
  }
@@ -55421,7 +55424,11 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55421
55424
  payload: { rowIdentityAccessor, changes, handleDiscard: handleDiscard2 }
55422
55425
  });
55423
55426
  }
55427
+ function getState() {
55428
+ return state;
55429
+ }
55424
55430
  return {
55431
+ getState,
55425
55432
  // row
55426
55433
  getRowValue,
55427
55434
  getRowMoveReason,
@@ -55436,6 +55443,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55436
55443
  getCellError,
55437
55444
  onCellChanged,
55438
55445
  // general
55446
+ getErrors,
55439
55447
  getErrorsShownInAlert,
55440
55448
  hasChanges,
55441
55449
  saveChanges,
@@ -55446,7 +55454,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55446
55454
  temporaryRows: state.temporaryRows
55447
55455
  };
55448
55456
  }
55449
- function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator) {
55457
+ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator, onEvent) {
55450
55458
  const [isEditing, setEditing] = React__default.useState(false);
55451
55459
  const [isDetailedMode, toggleDetailedMode] = React__default.useState(false);
55452
55460
  const createRowButtonRef = React__default.useRef(null);
@@ -55458,8 +55466,13 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
55458
55466
  rowIdentityAccessor,
55459
55467
  validator
55460
55468
  );
55469
+ useLazyEffect(() => {
55470
+ if (onEvent) {
55471
+ onEvent("editing-mode", { enabled: isEditing });
55472
+ }
55473
+ }, [isEditing]);
55461
55474
  function toggleEditing(enabled, table, scrollToIndex) {
55462
- var _a, _b;
55475
+ var _a;
55463
55476
  const tableMeta = table.options.meta;
55464
55477
  if (enabled) {
55465
55478
  const index2 = tableMeta.rowActive.rowActiveIndex ?? 0;
@@ -55475,7 +55488,6 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
55475
55488
  }
55476
55489
  setEditing(enabled);
55477
55490
  pendingChangesFns.saveChanges(table);
55478
- (_b = tableMeta.onEvent) == null ? void 0 : _b.call(tableMeta, "editing-mode", { enabled });
55479
55491
  }
55480
55492
  async function createRow2(table, row) {
55481
55493
  if (!handleCreate) {
@@ -55493,18 +55505,18 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
55493
55505
  if (changeset) {
55494
55506
  const temporaryRows = tableMeta.editing.temporaryRows;
55495
55507
  const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
55496
- const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);
55497
- table.setRowPinning((currentState) => {
55498
- var _a;
55499
- return {
55500
- ...currentState,
55501
- bottom: (_a = currentState.bottom ?? []) == null ? void 0 : _a.concat(newRowId)
55502
- };
55503
- });
55504
- toggleDetailedMode(false);
55505
- setLastFocusedCellIndex(void 0);
55508
+ tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
55506
55509
  requestAnimationFrame(() => {
55507
- tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
55510
+ const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);
55511
+ table.setRowPinning((currentState) => {
55512
+ var _a;
55513
+ return {
55514
+ ...currentState,
55515
+ bottom: (_a = currentState.bottom ?? []) == null ? void 0 : _a.concat(newRowId)
55516
+ };
55517
+ });
55518
+ toggleDetailedMode(false);
55519
+ setLastFocusedCellIndex(void 0);
55508
55520
  table.resetRowSelection();
55509
55521
  if (!tableMeta.editing.isEditing) {
55510
55522
  setEditing(true);
@@ -55731,14 +55743,26 @@ function EditingControlCell(props) {
55731
55743
  }, [cellRef.current]);
55732
55744
  const handleChange = React__default.useCallback(
55733
55745
  (nextValue) => {
55734
- if (nextValue !== value) {
55746
+ let hasChanged = false;
55747
+ if (columnMeta.dataType === "date") {
55748
+ hasChanged = !isSameDay(new Date(nextValue), new Date(value));
55749
+ } else if (columnMeta.dataType === "datetime") {
55750
+ hasChanged = !isEqual$2(new Date(nextValue), new Date(value));
55751
+ } else if (columnMeta.dataType === "time") {
55752
+ const next = new Date(nextValue);
55753
+ const current = new Date(value);
55754
+ hasChanged = !(next.getHours() === current.getHours() && next.getMinutes() === current.getMinutes());
55755
+ } else {
55756
+ hasChanged = nextValue !== value;
55757
+ }
55758
+ if (hasChanged) {
55735
55759
  tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
55736
55760
  if (hasNonTextControl) {
55737
55761
  requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
55738
55762
  }
55739
55763
  }
55740
55764
  },
55741
- [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value]
55765
+ [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value, columnMeta.dataType]
55742
55766
  );
55743
55767
  const handleBlur = React__default.useCallback(
55744
55768
  (event) => {
@@ -55970,7 +55994,10 @@ function Cell$1(props) {
55970
55994
  const hasErrorAndIsEditing = cellError ? tableMeta.editing.isEditing : true;
55971
55995
  const changedValue = tableMeta.editing.getCellValue(cell);
55972
55996
  if (changedValue !== void 0 && changedValue !== cell.getValue() && hasErrorAndIsEditing) {
55973
- cell.getValue = () => changedValue;
55997
+ const getValue2 = () => changedValue;
55998
+ const context = cell.getContext();
55999
+ cell.getValue = getValue2;
56000
+ cell.getContext = () => ({ ...context, getValue: getValue2 });
55974
56001
  }
55975
56002
  if (isActiveRow || !!cellError || isHovered && !isActiveRow && !tableMeta.rowActive.isHoverStatePaused) {
55976
56003
  return /* @__PURE__ */ React__default.createElement(EditingControlCell, { ...props });
@@ -56007,7 +56034,7 @@ function DiscardChangesConfirmationDialog(props) {
56007
56034
  event.stopPropagation();
56008
56035
  }
56009
56036
  };
56010
- return /* @__PURE__ */ React__default.createElement(Dialog, { ...dialogProps }, /* @__PURE__ */ React__default.createElement(
56037
+ return /* @__PURE__ */ React__default.createElement(Dialog, { ...dialogProps, showCloseButton: false }, /* @__PURE__ */ React__default.createElement(
56011
56038
  Dialog.Content,
56012
56039
  {
56013
56040
  "aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
@@ -56016,7 +56043,15 @@ function DiscardChangesConfirmationDialog(props) {
56016
56043
  },
56017
56044
  /* @__PURE__ */ React__default.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title),
56018
56045
  /* @__PURE__ */ React__default.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description),
56019
- /* @__PURE__ */ React__default.createElement(Dialog.Footer, null, /* @__PURE__ */ React__default.createElement(Group$6, null, /* @__PURE__ */ React__default.createElement(Dialog.Close, null, /* @__PURE__ */ React__default.createElement(Button$4, { tabIndex: 0 }, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /* @__PURE__ */ React__default.createElement(Dialog.Close, null, /* @__PURE__ */ React__default.createElement(Button$4, { tabIndex: 0, appearance: "primary", onClick: handleDiscard }, texts.table3.editing.clearChangesConfirmationDialog.confirm))))
56046
+ /* @__PURE__ */ React__default.createElement($9bf71ea28793e738$export$20e40289641fbbb6, { contain: true, restoreFocus: true }, /* @__PURE__ */ React__default.createElement(Dialog.Footer, null, /* @__PURE__ */ React__default.createElement(Group$6, null, /* @__PURE__ */ React__default.createElement(Dialog.Close, null, /* @__PURE__ */ React__default.createElement(Button$4, { tabIndex: 0 }, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /* @__PURE__ */ React__default.createElement(Dialog.Close, null, /* @__PURE__ */ React__default.createElement(Button$4, { tabIndex: 0, appearance: "primary", onClick: handleDiscard }, texts.table3.editing.clearChangesConfirmationDialog.confirm)))), /* @__PURE__ */ React__default.createElement($5d3850c4d0b4e6c7$export$f39c2d165cd861fe, { asChild: true }, /* @__PURE__ */ React__default.createElement(
56047
+ IconButton,
56048
+ {
56049
+ appearance: "discrete",
56050
+ "aria-label": texts.dialog.close,
56051
+ className: "absolute right-0 top-0 mr-2 mt-2 print:hidden",
56052
+ icon: "close"
56053
+ }
56054
+ )))
56020
56055
  ));
56021
56056
  }
56022
56057
  function Row(props) {
@@ -56064,7 +56099,7 @@ function Row(props) {
56064
56099
  if (event.isDefaultPrevented() || event.isPropagationStopped()) {
56065
56100
  return;
56066
56101
  }
56067
- if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !isElementTriggeredFromContainer(event.target, event.currentTarget)) {
56102
+ if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !isElementInsideOverlay(event.target)) {
56068
56103
  event.preventDefault();
56069
56104
  setShowDiscardDialog(true);
56070
56105
  }
@@ -56097,7 +56132,8 @@ function useTable3(props, ref) {
56097
56132
  props.onEditingCreate,
56098
56133
  props.onEditingDiscard,
56099
56134
  props.rowIdentityAccessor,
56100
- props.validator
56135
+ props.validator,
56136
+ props.onEvent
56101
56137
  );
56102
56138
  const data = React__default.useMemo(() => {
56103
56139
  if (editing.temporaryRows.length) {
@@ -56149,18 +56185,33 @@ function useTable3(props, ref) {
56149
56185
  };
56150
56186
  const meta = { editing };
56151
56187
  const options = {
56152
- virtualiserPaddingEndOffset: props.enableEditing && props.onEditingCreate ? editing.hasTemporaryRowErrors() ? 1.4 : 1 : 0
56188
+ virtualiserPaddingEndOffset: 0
56153
56189
  };
56190
+ if (props.enableEditing) {
56191
+ const validationErrorLabelHeight = 17;
56192
+ options.virtualiserPaddingEndOffset = editing.getErrors().length * validationErrorLabelHeight;
56193
+ }
56154
56194
  const table = useTable$1(extendedProps, ref, RENDERERS, meta, options);
56155
56195
  useTableEditingListener(table.instance, table.ref, table.renderer.scrollToIndex);
56156
56196
  React__default.useEffect(() => {
56157
56197
  if (table.ref.current) {
56158
- table.ref.current.instance.toggleEditing = (enabled) => table.meta.editing.toggleEditing(enabled ?? ((editing2) => !editing2), table.instance, table.renderer.scrollToIndex);
56159
- if (props.onEditingCreate) {
56160
- table.ref.current.instance.createRow = (row) => table.meta.editing.createRow(table.instance, row);
56198
+ const instance = table.ref.current.instance;
56199
+ if (table.meta.editing.isEnabled) {
56200
+ instance.editing = {
56201
+ toggleEditing: (enabled) => table.meta.editing.toggleEditing(
56202
+ enabled ?? ((editing2) => !editing2),
56203
+ table.instance,
56204
+ table.renderer.scrollToIndex
56205
+ ),
56206
+ removeRowChanges: (rowId) => table.meta.editing.discardChanges(rowId, table.instance),
56207
+ save: (rowId) => table.meta.editing.saveChanges(table.instance, rowId)
56208
+ };
56209
+ if (props.onEditingCreate) {
56210
+ instance.editing.createRow = (row) => table.meta.editing.createRow(table.instance, row);
56211
+ }
56161
56212
  }
56162
56213
  }
56163
- }, [table.ref.current]);
56214
+ }, [table.ref.current, table.meta.editing.isEnabled]);
56164
56215
  return table;
56165
56216
  }
56166
56217
  function Alert(props) {
@@ -56270,7 +56321,7 @@ function Editing(props) {
56270
56321
  }
56271
56322
  function CreateNewRow(props) {
56272
56323
  var _a, _b;
56273
- const { buttonRef, isScrolled, table, tableMeta } = props;
56324
+ const { buttonRef, hasScrollbar, table, tableMeta } = props;
56274
56325
  const { texts } = useLocalization();
56275
56326
  const temporaryRows = tableMeta.editing.temporaryRows;
56276
56327
  const temporaryRowId = ((_a = temporaryRows[0]) == null ? void 0 : _a[tableMeta.rowIdentityAccessor]) ?? "";
@@ -56293,7 +56344,8 @@ function CreateNewRow(props) {
56293
56344
  }
56294
56345
  const className = clsx("group/row !sticky z-[21]", {
56295
56346
  "bottom-10": tableMeta.footer.isEnabled,
56296
- "bottom-0": !tableMeta.footer.isEnabled
56347
+ "bottom-0": !tableMeta.footer.isEnabled,
56348
+ "border-b !border-t-[0]": !hasScrollbar
56297
56349
  });
56298
56350
  return /* @__PURE__ */ React__default.createElement("tr", { "data-row-create": true, className, tabIndex: -1 }, /* @__PURE__ */ React__default.createElement("td", { className: "!bg-grey-50 col-span-full !px-1" }, /* @__PURE__ */ React__default.createElement(
56299
56351
  Button$4,
@@ -56314,9 +56366,8 @@ function TemporaryRows(props) {
56314
56366
  return props.table.getBottomRows().map((row) => /* @__PURE__ */ React__default.createElement(TemporaryRow, { key: row.id, row, ...props }));
56315
56367
  }
56316
56368
  function TemporaryRow(props) {
56317
- const { createRowButtonRef, row, table, tableMeta, tableRef } = props;
56369
+ const { createRowButtonRef, hasScrollbar, row, table, tableMeta, tableRef } = props;
56318
56370
  const handleKeyDown = async (event) => {
56319
- var _a;
56320
56371
  const target = event.target;
56321
56372
  if (isAriaDirectionKey(event) && isElementInsideExternalRelatedOverlay(target, tableRef)) {
56322
56373
  return;
@@ -56326,12 +56377,16 @@ function TemporaryRow(props) {
56326
56377
  if (!isElementTriggeredFromContainer(target, event.currentTarget)) {
56327
56378
  const saved = await tableMeta.editing.saveChanges(table);
56328
56379
  if (saved) {
56329
- (_a = createRowButtonRef.current) == null ? void 0 : _a.focus();
56380
+ requestAnimationFrame(() => {
56381
+ var _a;
56382
+ (_a = createRowButtonRef.current) == null ? void 0 : _a.focus();
56383
+ });
56330
56384
  }
56331
56385
  }
56332
56386
  } else if (event.key === "ArrowUp") {
56333
56387
  event.preventDefault();
56334
56388
  event.stopPropagation();
56389
+ await tableMeta.editing.saveChanges(table);
56335
56390
  const lastIndex = tableMeta.length - 1;
56336
56391
  tableMeta.rowActive.setRowActiveIndex(lastIndex);
56337
56392
  if (tableRef.current) {
@@ -56344,20 +56399,10 @@ function TemporaryRow(props) {
56344
56399
  }
56345
56400
  }
56346
56401
  };
56347
- const handleKeyDownCapture = (event) => {
56348
- if (event.key === "ArrowLeft" && tableMeta.editing.lastFocusedCellIndex === 0) {
56349
- event.preventDefault();
56350
- event.stopPropagation();
56351
- } else if (event.key === "ArrowRight" && tableMeta.editing.lastFocusedCellIndex) {
56352
- if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {
56353
- event.preventDefault();
56354
- event.stopPropagation();
56355
- }
56356
- }
56357
- };
56358
56402
  const className = clsx("group/row border-grey-300 !sticky z-[22] print:hidden border-t-2", {
56359
56403
  "bottom-[calc(5rem_+_5px)] data-[row-editing-move]:bottom-[calc(5rem_+_5px)]": tableMeta.footer.isEnabled,
56360
- "bottom-[calc(2.5rem_+_5px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_5px)]": !tableMeta.footer.isEnabled
56404
+ "bottom-[calc(2.5rem_+_5px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_5px)]": !tableMeta.footer.isEnabled,
56405
+ "border-b !border-t": !hasScrollbar
56361
56406
  });
56362
56407
  return /* @__PURE__ */ React__default.createElement(
56363
56408
  Row$2,
@@ -56371,7 +56416,6 @@ function TemporaryRow(props) {
56371
56416
  table,
56372
56417
  className,
56373
56418
  onKeyDown: handleKeyDown,
56374
- onKeyDownCapture: handleKeyDownCapture,
56375
56419
  hideInternalColumns: true,
56376
56420
  hideRowActions: !tableMeta.editing.isEditing,
56377
56421
  skipPageLoading: true
@@ -56399,14 +56443,14 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
56399
56443
  return rowsById[row.rowId];
56400
56444
  }).length;
56401
56445
  const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;
56402
- const isScrolled = isTableScrolled(table3.ref);
56446
+ const [hasScrollbar, isScrolled] = isTableScrolled(table3.ref);
56403
56447
  let createWorkflow;
56404
56448
  if (hasCreateWorkflow) {
56405
56449
  createWorkflow = /* @__PURE__ */ React__default.createElement(
56406
56450
  CreateNewRow,
56407
56451
  {
56408
56452
  buttonRef: table3.meta.editing.createRowButtonRef,
56409
- isScrolled,
56453
+ hasScrollbar,
56410
56454
  table: table3.instance,
56411
56455
  tableMeta: table3.meta
56412
56456
  }
@@ -56432,6 +56476,7 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
56432
56476
  TemporaryRows,
56433
56477
  {
56434
56478
  createRowButtonRef: table3.meta.editing.createRowButtonRef,
56479
+ hasScrollbar,
56435
56480
  table: table3.instance,
56436
56481
  tableMeta: table3.meta,
56437
56482
  tableRef: table3.ref