@economic/taco 2.69.1 → 2.69.2-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.d.ts CHANGED
@@ -1057,7 +1057,7 @@ export declare type DialogContentDrawerRenderProps = DialogContext['drawer'];
1057
1057
  export declare type DialogContentProps = Omit<React_2.HTMLAttributes<HTMLDivElement>, 'children'> & {
1058
1058
  /** An accessible label to be announced when the dialog is opened */
1059
1059
  'aria-label': string;
1060
- children: Omit<React_2.ReactNode, 'Function'> | ((props: DialogContentRenderProps) => JSX.Element);
1060
+ children: React_2.ReactNode | ((props: DialogContentRenderProps) => JSX.Element);
1061
1061
  onOpenAutoFocus?: DialogPrimitive.DialogContentProps['onOpenAutoFocus'];
1062
1062
  onCloseAutoFocus?: DialogPrimitive.DialogContentProps['onCloseAutoFocus'];
1063
1063
  };
@@ -1165,7 +1165,7 @@ declare type DrawerCloseProps = default_2.HTMLAttributes<HTMLButtonElement>;
1165
1165
  declare type DrawerContentProps = Omit<default_2.HTMLAttributes<HTMLDivElement>, 'children'> & {
1166
1166
  /** An accessible label to be announced when the side drawer is opened */
1167
1167
  'aria-label': string;
1168
- children: Omit<default_2.ReactNode, 'Function'> | ((props: DrawerContentRenderProps) => JSX.Element);
1168
+ children: default_2.ReactNode | ((props: DrawerContentRenderProps) => JSX.Element);
1169
1169
  };
1170
1170
 
1171
1171
  declare type DrawerContentRenderProps = {
@@ -3071,7 +3071,7 @@ export declare type Table3Ref = TableRef & {
3071
3071
  createRow?: (row: unknown) => Promise<void>;
3072
3072
  save: (rowId?: string) => Promise<boolean>;
3073
3073
  removeRowChanges: (rowId: string) => Promise<void>;
3074
- forceValidate: () => Promise<string[]>;
3074
+ forceValidate?: () => Promise<string[]>;
3075
3075
  };
3076
3076
  };
3077
3077
  };
@@ -3930,7 +3930,7 @@ export declare const Truncate: ({ children, tooltip }: TruncateProps) => default
3930
3930
 
3931
3931
  export declare type TruncateProps = {
3932
3932
  children: default_2.ReactElement;
3933
- tooltip: string;
3933
+ tooltip: string | JSX.Element;
3934
3934
  };
3935
3935
 
3936
3936
  export declare interface UncontrolledCheckboxProps extends CheckboxBaseProps {
package/dist/taco.js CHANGED
@@ -39596,9 +39596,9 @@ function Search$1(props) {
39596
39596
  if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {
39597
39597
  clearTimeout(searchTimeoutRef.current);
39598
39598
  searchTimeoutRef.current = setTimeout(() => {
39599
- var _a2, _b;
39599
+ var _a2, _b, _c;
39600
39600
  setLoading(true);
39601
- (_b = (_a2 = tableMeta.search).handleSearch) == null ? void 0 : _b.call(_a2, query2, hiddenColumns).then(() => {
39601
+ (_c = (_b = (_a2 = tableMeta.search).handleSearch) == null ? void 0 : _b.call(_a2, query2, hiddenColumns)) == null ? void 0 : _c.then(() => {
39602
39602
  setLoading(false);
39603
39603
  });
39604
39604
  }, 150);
@@ -44142,7 +44142,14 @@ const EditPopover = (props) => {
44142
44142
  onChangeColor: setColor,
44143
44143
  onKeyDown: preventKeyDownPropagation
44144
44144
  }
44145
- )) : null, /* @__PURE__ */ React__default.createElement(Group$6, null, /* @__PURE__ */ React__default.createElement(Button$4, { onClick: close }, texts.select2.cancel), /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "primary", onClick: handleSave(close) }, texts.select2.save))) : null, onEdit && onDelete ? /* @__PURE__ */ React__default.createElement("hr", null) : null, onDelete ? /* @__PURE__ */ React__default.createElement(
44145
+ )) : null, /* @__PURE__ */ React__default.createElement(Group$6, null, /* @__PURE__ */ React__default.createElement(Button$4, { onClick: close }, texts.select2.cancel), /* @__PURE__ */ React__default.createElement(
44146
+ Button$4,
44147
+ {
44148
+ appearance: "primary",
44149
+ onClick: handleSave(close)
44150
+ },
44151
+ texts.select2.save
44152
+ ))) : null, onEdit && onDelete ? /* @__PURE__ */ React__default.createElement("hr", null) : null, onDelete ? /* @__PURE__ */ React__default.createElement(
44146
44153
  "button",
44147
44154
  {
44148
44155
  className: "hover:text-grey-700 flex items-center justify-start gap-1",
@@ -45408,6 +45415,7 @@ function Control(props) {
45408
45415
  const controlRenderer = (_a = column == null ? void 0 : column.columnDef.meta) == null ? void 0 : _a.control;
45409
45416
  const dataType = (_b = column == null ? void 0 : column.columnDef.meta) == null ? void 0 : _b.dataType;
45410
45417
  const filters = React__default.useContext(FilterContext);
45418
+ const ref = React__default.useRef(null);
45411
45419
  useEffect(() => {
45412
45420
  if ((controlRenderer === "switch" || controlRenderer === "checkbox") && value === void 0) {
45413
45421
  onChange(false);
@@ -45417,8 +45425,9 @@ function Control(props) {
45417
45425
  const control = controlRenderer(
45418
45426
  {
45419
45427
  ...attributes,
45420
- setValue: (value2) => onChange(value2),
45421
- value
45428
+ setValue: onChange,
45429
+ value,
45430
+ ref
45422
45431
  },
45423
45432
  void 0,
45424
45433
  filters
@@ -51680,7 +51689,9 @@ const useRowSelect = (onSelectedRows) => {
51680
51689
  const { onChange: _, ...props } = getToggleAllRowsSelectedProps();
51681
51690
  const onChange = (checked) => {
51682
51691
  if (checked) {
51683
- onSelectedRows(Object.assign({}, Array.from({ length: rows.length }).fill(true)));
51692
+ onSelectedRows(
51693
+ Object.assign({}, Array.from({ length: rows.length }).fill(true))
51694
+ );
51684
51695
  } else {
51685
51696
  onSelectedRows({});
51686
51697
  }
@@ -55127,7 +55138,8 @@ var setWithExports = requireSetWith();
55127
55138
  const setWith = /* @__PURE__ */ getDefaultExportFromCjs(setWithExports);
55128
55139
  const DELAY_BEFORE_REMOVING_SAVE_STATUS = 3e3;
55129
55140
  function reducer(state, action) {
55130
- const { type, rowId, payload } = action;
55141
+ var _a;
55142
+ const { type, payload } = action;
55131
55143
  switch (type) {
55132
55144
  case "setCellValue": {
55133
55145
  const { columnId, index: index2, row, value } = payload;
@@ -55135,26 +55147,26 @@ function reducer(state, action) {
55135
55147
  ...state,
55136
55148
  changes: {
55137
55149
  ...state.changes,
55138
- rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
55139
- originals: setWith(state.changes.originals, rowId, row, Object),
55140
- dirty: setWith(state.changes.dirty, rowId, true, Object)
55150
+ rows: setWith(state.changes.rows, `${action.rowId}.${columnId}`, value, Object),
55151
+ originals: setWith(state.changes.originals, action.rowId, row, Object),
55152
+ dirty: setWith(state.changes.dirty, action.rowId, true, Object)
55141
55153
  },
55142
- indexes: setWith(state.indexes, rowId, index2, Object)
55154
+ indexes: setWith(state.indexes, action.rowId, index2, Object)
55143
55155
  };
55144
55156
  }
55145
55157
  case "removeCellValue": {
55146
55158
  const { columnId, rowIdentityAccessor } = payload;
55147
- const changes = omit$1(state.changes.rows, `${rowId}.${columnId}`);
55148
- if (!Object.keys(changes[rowId]).length) {
55149
- return reducer(state, { type: "removeRow", rowId, payload: { rowIdentityAccessor } });
55159
+ const changes = omit$1(state.changes.rows, `${action.rowId}.${columnId}`);
55160
+ if (!Object.keys(changes[action.rowId]).length) {
55161
+ return reducer(state, { type: "removeRow", rowId: action.rowId, payload: { rowIdentityAccessor } });
55150
55162
  }
55151
55163
  return {
55152
55164
  ...state,
55153
55165
  changes: {
55154
55166
  ...state.changes,
55155
- rows: omit$1(state.changes.rows, `${rowId}.${columnId}`),
55156
- errors: omit$1(state.changes.errors, `${rowId}.cells.${columnId}`),
55157
- moveReasons: omit$1(state.changes.moveReasons, `${rowId}.${columnId}`)
55167
+ rows: omit$1(state.changes.rows, `${action.rowId}.${columnId}`),
55168
+ errors: omit$1(state.changes.errors, `${action.rowId}.cells.${columnId}`),
55169
+ moveReasons: omit$1(state.changes.moveReasons, `${action.rowId}.${columnId}`)
55158
55170
  }
55159
55171
  };
55160
55172
  }
@@ -55164,24 +55176,28 @@ function reducer(state, action) {
55164
55176
  ...state,
55165
55177
  changes: {
55166
55178
  ...state.changes,
55167
- rows: setWith(state.changes.rows, rowId, value, Object),
55179
+ rows: setWith(state.changes.rows, action.rowId, value, Object),
55168
55180
  errors: setWith(
55169
55181
  state.changes.errors,
55170
- `${rowId}.cells`,
55171
- cellErrors ?? state.changes.errors.cells[rowId],
55182
+ `${action.rowId}.cells`,
55183
+ cellErrors ?? ((_a = state.changes.errors[action.rowId]) == null ? void 0 : _a.cells),
55184
+ Object
55185
+ ),
55186
+ originals: setWith(
55187
+ state.changes.originals,
55188
+ action.rowId,
55189
+ original ?? state.changes.originals[action.rowId],
55172
55190
  Object
55173
55191
  ),
55174
- originals: setWith(state.changes.originals, rowId, original ?? state.changes.originals[rowId], Object),
55175
55192
  moveReasons: setWith(
55176
55193
  state.changes.moveReasons,
55177
- rowId,
55178
- moveReasons ?? state.changes.moveReasons[rowId],
55194
+ action.rowId,
55195
+ moveReasons ?? state.changes.moveReasons[action.rowId],
55179
55196
  Object
55180
- ),
55181
- // status can be undefined, so don't use ??
55182
- status: setWith(state.changes.status, rowId, void 0, Object)
55197
+ )
55183
55198
  },
55184
- indexes: setWith(state.indexes, rowId, index2, Object)
55199
+ indexes: setWith(state.indexes, action.rowId, index2, Object),
55200
+ statuses: omit$1(state.statuses, action.rowId)
55185
55201
  };
55186
55202
  }
55187
55203
  case "removeRow": {
@@ -55190,28 +55206,27 @@ function reducer(state, action) {
55190
55206
  ...state,
55191
55207
  changes: {
55192
55208
  ...state.changes,
55193
- rows: omit$1(state.changes.rows, rowId),
55194
- errors: omit$1(state.changes.errors, rowId),
55195
- moveReasons: omit$1(state.changes.moveReasons, rowId),
55196
- originals: omit$1(state.changes.originals, rowId),
55197
- status: omit$1(state.changes.status, rowId),
55198
- dirty: omit$1(state.changes.dirty, rowId)
55209
+ rows: omit$1(state.changes.rows, action.rowId),
55210
+ errors: omit$1(state.changes.errors, action.rowId),
55211
+ moveReasons: omit$1(state.changes.moveReasons, action.rowId),
55212
+ originals: omit$1(state.changes.originals, action.rowId),
55213
+ dirty: omit$1(state.changes.dirty, action.rowId)
55199
55214
  },
55200
- indexes: omit$1(state.indexes, rowId),
55201
- temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== rowId)
55215
+ indexes: omit$1(state.indexes, action.rowId),
55216
+ temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== action.rowId)
55202
55217
  };
55203
55218
  }
55204
55219
  case "complete": {
55205
55220
  const { changes, handleDiscard } = payload;
55206
- if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[rowId])) {
55221
+ if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[action.rowId])) {
55207
55222
  return {
55208
55223
  ...state,
55209
55224
  changes: {
55210
55225
  ...state.changes,
55211
55226
  originals: setWith(
55212
55227
  state.changes.originals,
55213
- rowId,
55214
- { ...state.changes.originals[rowId], ...changes },
55228
+ action.rowId,
55229
+ { ...state.changes.originals[action.rowId], ...changes },
55215
55230
  Object
55216
55231
  )
55217
55232
  }
@@ -55224,12 +55239,15 @@ function reducer(state, action) {
55224
55239
  }
55225
55240
  case "setRowStatus": {
55226
55241
  const { status } = payload;
55242
+ if (status) {
55243
+ return {
55244
+ ...state,
55245
+ statuses: setWith(state.statuses, action.rowId, status, Object)
55246
+ };
55247
+ }
55227
55248
  return {
55228
55249
  ...state,
55229
- changes: {
55230
- ...state.changes,
55231
- status: status ? setWith(state.changes.status, rowId, status, Object) : omit$1(state.changes.status, rowId)
55232
- }
55250
+ statuses: omit$1(state.statuses, action.rowId)
55233
55251
  };
55234
55252
  }
55235
55253
  case "setRowErrors": {
@@ -55238,7 +55256,7 @@ function reducer(state, action) {
55238
55256
  ...state,
55239
55257
  changes: {
55240
55258
  ...state.changes,
55241
- errors: setWith(state.changes.errors, rowId, errors, Object)
55259
+ errors: setWith(state.changes.errors, action.rowId, errors, Object)
55242
55260
  }
55243
55261
  };
55244
55262
  }
@@ -55249,10 +55267,10 @@ function reducer(state, action) {
55249
55267
  temporaryRows: state.temporaryRows.concat(value),
55250
55268
  changes: {
55251
55269
  ...state.changes,
55252
- rows: setWith(state.changes.rows, rowId, value, Object),
55253
- originals: setWith(state.changes.originals, rowId, value, Object)
55270
+ rows: setWith(state.changes.rows, action.rowId, value, Object),
55271
+ originals: setWith(state.changes.originals, action.rowId, value, Object)
55254
55272
  },
55255
- indexes: setWith(state.indexes, rowId, index2, Object)
55273
+ indexes: setWith(state.indexes, action.rowId, index2, Object)
55256
55274
  };
55257
55275
  }
55258
55276
  case "forceValidate": {
@@ -55269,9 +55287,10 @@ function reducer(state, action) {
55269
55287
  function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator) {
55270
55288
  const localization = useLocalization();
55271
55289
  const [state, dispatch] = React__default.useReducer(reducer, {
55272
- changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {}, dirty: {} },
55290
+ changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, dirty: {} },
55273
55291
  indexes: {},
55274
- temporaryRows: []
55292
+ temporaryRows: [],
55293
+ statuses: {}
55275
55294
  });
55276
55295
  function getRowValue(rowId) {
55277
55296
  var _a;
@@ -55299,7 +55318,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55299
55318
  return !!((_b = state.changes.errors[rowId]) == null ? void 0 : _b.row) || !!Object.keys(((_c = state.changes.errors[rowId]) == null ? void 0 : _c.cells) ?? {}).length;
55300
55319
  }
55301
55320
  function getRowStatus(rowId) {
55302
- return state.changes.status[rowId];
55321
+ return state.statuses[rowId];
55303
55322
  }
55304
55323
  function setRowStatus(rowId, status) {
55305
55324
  dispatch({
@@ -55310,6 +55329,12 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55310
55329
  }
55311
55330
  });
55312
55331
  }
55332
+ function showSavedStatus(rowId) {
55333
+ setRowStatus(rowId, "saved");
55334
+ setTimeout(() => {
55335
+ setRowStatus(rowId, void 0);
55336
+ }, DELAY_BEFORE_REMOVING_SAVE_STATUS);
55337
+ }
55313
55338
  function insertTemporaryRow(data, rowIndex) {
55314
55339
  const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${nanoid()}`;
55315
55340
  const value = {
@@ -55436,7 +55461,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55436
55461
  newState.changes.originals[row.id] = row.original;
55437
55462
  newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };
55438
55463
  newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };
55439
- newState.changes.status[row.id] = "errored";
55464
+ newState.statuses[row.id] = "errored";
55440
55465
  newState.indexes[row.id] = index2;
55441
55466
  newState.changes.errors[row.id] = {
55442
55467
  cells: cellErrors,
@@ -55477,7 +55502,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55477
55502
  }));
55478
55503
  }
55479
55504
  function hasSaved() {
55480
- return !!Object.values(state.changes.status).filter((value) => value === "saved").length;
55505
+ return !!Object.values(state.statuses).filter((status) => status === "saved").length;
55481
55506
  }
55482
55507
  function hasChanges(rowId) {
55483
55508
  return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;
@@ -55516,10 +55541,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55516
55541
  }
55517
55542
  await handleSave(changeSet);
55518
55543
  complete(rowId2, table, rowChanges);
55519
- setRowStatus(rowId2, "saved");
55520
- setTimeout(() => {
55521
- setRowStatus(rowId2, void 0);
55522
- }, DELAY_BEFORE_REMOVING_SAVE_STATUS);
55544
+ showSavedStatus(rowId2);
55523
55545
  } catch (error) {
55524
55546
  if (error instanceof ReferenceError || error instanceof TypeError || ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) >= 500) {
55525
55547
  console.error(error);
@@ -55899,10 +55921,17 @@ function EditingControlCell(props) {
55899
55921
  const handleFocus = useEditingCellAutofocus(props);
55900
55922
  const value = cell.getValue();
55901
55923
  const rowChanges = tableMeta.editing.getRowValue(cell.row.id);
55924
+ const shouldRunUpdate = React__default.useRef(false);
55902
55925
  const hasNonTextControl = React__default.useMemo(() => {
55903
55926
  var _a;
55904
55927
  return typeof type === "function" && !!((_a = cellRef.current) == null ? void 0 : _a.querySelector('[data-taco="Select2"],[data-taco="switch"],[data-taco="checkbox"]'));
55905
55928
  }, [cellRef.current]);
55929
+ useLazyEffect(() => {
55930
+ if (hasNonTextControl && shouldRunUpdate.current) {
55931
+ tableMeta.editing.onCellChanged(cell, rowIndex, value, true, false);
55932
+ shouldRunUpdate.current = false;
55933
+ }
55934
+ }, [value]);
55906
55935
  const handleChange = React__default.useCallback(
55907
55936
  (nextValue) => {
55908
55937
  let hasChanged = false;
@@ -55919,9 +55948,7 @@ function EditingControlCell(props) {
55919
55948
  }
55920
55949
  if (hasChanged) {
55921
55950
  tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
55922
- if (hasNonTextControl) {
55923
- requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue, true, false));
55924
- }
55951
+ shouldRunUpdate.current = hasNonTextControl;
55925
55952
  }
55926
55953
  },
55927
55954
  [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value, columnMeta.dataType]
@@ -56199,6 +56226,7 @@ function DiscardChangesConfirmationDialog(props) {
56199
56226
  return /* @__PURE__ */ React__default.createElement(Dialog, { ...dialogProps, showCloseButton: false }, /* @__PURE__ */ React__default.createElement(
56200
56227
  Dialog.Content,
56201
56228
  {
56229
+ "data-taco": "discard-changes-dialog",
56202
56230
  "aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
56203
56231
  onClick: handleClickInsideDialogContent,
56204
56232
  onKeyDown: handleKeydown
@@ -56375,7 +56403,7 @@ function useTable3(props, ref) {
56375
56403
  removeRowChanges: (rowId) => table.meta.editing.discardChanges(rowId, table.instance),
56376
56404
  save: (rowId) => table.meta.editing.saveChanges(table.instance, rowId)
56377
56405
  };
56378
- if (props.onEditingCreate) {
56406
+ if (props.onEditingCreate && instance.editing) {
56379
56407
  instance.editing.createRow = (row) => table.meta.editing.createRow(table.instance, row);
56380
56408
  }
56381
56409
  }
@@ -56384,7 +56412,7 @@ function useTable3(props, ref) {
56384
56412
  React__default.useEffect(() => {
56385
56413
  if (table.ref.current) {
56386
56414
  const instance = table.ref.current.instance;
56387
- if (table.meta.editing.isEnabled) {
56415
+ if (table.meta.editing.isEnabled && instance.editing) {
56388
56416
  instance.editing.forceValidate = async () => await table.meta.editing.forceValidate(table.instance);
56389
56417
  }
56390
56418
  }