@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.cjs +88 -60
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.d.ts +4 -4
- package/dist/taco.js +88 -60
- package/dist/taco.js.map +1 -1
- package/package.json +3 -3
- package/tailwind.config.js +0 -3
package/dist/taco.cjs
CHANGED
@@ -39614,9 +39614,9 @@ function Search$1(props) {
|
|
39614
39614
|
if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {
|
39615
39615
|
clearTimeout(searchTimeoutRef.current);
|
39616
39616
|
searchTimeoutRef.current = setTimeout(() => {
|
39617
|
-
var _a2, _b;
|
39617
|
+
var _a2, _b, _c;
|
39618
39618
|
setLoading(true);
|
39619
|
-
(_b = (_a2 = tableMeta.search).handleSearch) == null ? void 0 : _b.call(_a2, query2, hiddenColumns).then(() => {
|
39619
|
+
(_c = (_b = (_a2 = tableMeta.search).handleSearch) == null ? void 0 : _b.call(_a2, query2, hiddenColumns)) == null ? void 0 : _c.then(() => {
|
39620
39620
|
setLoading(false);
|
39621
39621
|
});
|
39622
39622
|
}, 150);
|
@@ -44160,7 +44160,14 @@ const EditPopover = (props) => {
|
|
44160
44160
|
onChangeColor: setColor,
|
44161
44161
|
onKeyDown: preventKeyDownPropagation
|
44162
44162
|
}
|
44163
|
-
)) : null, /* @__PURE__ */ React.createElement(Group$6, null, /* @__PURE__ */ React.createElement(Button$4, { onClick: close }, texts.select2.cancel), /* @__PURE__ */ React.createElement(
|
44163
|
+
)) : null, /* @__PURE__ */ React.createElement(Group$6, null, /* @__PURE__ */ React.createElement(Button$4, { onClick: close }, texts.select2.cancel), /* @__PURE__ */ React.createElement(
|
44164
|
+
Button$4,
|
44165
|
+
{
|
44166
|
+
appearance: "primary",
|
44167
|
+
onClick: handleSave(close)
|
44168
|
+
},
|
44169
|
+
texts.select2.save
|
44170
|
+
))) : null, onEdit && onDelete ? /* @__PURE__ */ React.createElement("hr", null) : null, onDelete ? /* @__PURE__ */ React.createElement(
|
44164
44171
|
"button",
|
44165
44172
|
{
|
44166
44173
|
className: "hover:text-grey-700 flex items-center justify-start gap-1",
|
@@ -45426,6 +45433,7 @@ function Control(props) {
|
|
45426
45433
|
const controlRenderer = (_a = column == null ? void 0 : column.columnDef.meta) == null ? void 0 : _a.control;
|
45427
45434
|
const dataType = (_b = column == null ? void 0 : column.columnDef.meta) == null ? void 0 : _b.dataType;
|
45428
45435
|
const filters = React.useContext(FilterContext);
|
45436
|
+
const ref = React.useRef(null);
|
45429
45437
|
React.useEffect(() => {
|
45430
45438
|
if ((controlRenderer === "switch" || controlRenderer === "checkbox") && value === void 0) {
|
45431
45439
|
onChange(false);
|
@@ -45435,8 +45443,9 @@ function Control(props) {
|
|
45435
45443
|
const control = controlRenderer(
|
45436
45444
|
{
|
45437
45445
|
...attributes,
|
45438
|
-
setValue:
|
45439
|
-
value
|
45446
|
+
setValue: onChange,
|
45447
|
+
value,
|
45448
|
+
ref
|
45440
45449
|
},
|
45441
45450
|
void 0,
|
45442
45451
|
filters
|
@@ -51698,7 +51707,9 @@ const useRowSelect = (onSelectedRows) => {
|
|
51698
51707
|
const { onChange: _, ...props } = getToggleAllRowsSelectedProps();
|
51699
51708
|
const onChange = (checked) => {
|
51700
51709
|
if (checked) {
|
51701
|
-
onSelectedRows(
|
51710
|
+
onSelectedRows(
|
51711
|
+
Object.assign({}, Array.from({ length: rows.length }).fill(true))
|
51712
|
+
);
|
51702
51713
|
} else {
|
51703
51714
|
onSelectedRows({});
|
51704
51715
|
}
|
@@ -55145,7 +55156,8 @@ var setWithExports = requireSetWith();
|
|
55145
55156
|
const setWith = /* @__PURE__ */ getDefaultExportFromCjs(setWithExports);
|
55146
55157
|
const DELAY_BEFORE_REMOVING_SAVE_STATUS = 3e3;
|
55147
55158
|
function reducer(state, action) {
|
55148
|
-
|
55159
|
+
var _a;
|
55160
|
+
const { type, payload } = action;
|
55149
55161
|
switch (type) {
|
55150
55162
|
case "setCellValue": {
|
55151
55163
|
const { columnId, index: index2, row, value } = payload;
|
@@ -55153,26 +55165,26 @@ function reducer(state, action) {
|
|
55153
55165
|
...state,
|
55154
55166
|
changes: {
|
55155
55167
|
...state.changes,
|
55156
|
-
rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
|
55157
|
-
originals: setWith(state.changes.originals, rowId, row, Object),
|
55158
|
-
dirty: setWith(state.changes.dirty, rowId, true, Object)
|
55168
|
+
rows: setWith(state.changes.rows, `${action.rowId}.${columnId}`, value, Object),
|
55169
|
+
originals: setWith(state.changes.originals, action.rowId, row, Object),
|
55170
|
+
dirty: setWith(state.changes.dirty, action.rowId, true, Object)
|
55159
55171
|
},
|
55160
|
-
indexes: setWith(state.indexes, rowId, index2, Object)
|
55172
|
+
indexes: setWith(state.indexes, action.rowId, index2, Object)
|
55161
55173
|
};
|
55162
55174
|
}
|
55163
55175
|
case "removeCellValue": {
|
55164
55176
|
const { columnId, rowIdentityAccessor } = payload;
|
55165
|
-
const changes = omit$1(state.changes.rows, `${rowId}.${columnId}`);
|
55166
|
-
if (!Object.keys(changes[rowId]).length) {
|
55167
|
-
return reducer(state, { type: "removeRow", rowId, payload: { rowIdentityAccessor } });
|
55177
|
+
const changes = omit$1(state.changes.rows, `${action.rowId}.${columnId}`);
|
55178
|
+
if (!Object.keys(changes[action.rowId]).length) {
|
55179
|
+
return reducer(state, { type: "removeRow", rowId: action.rowId, payload: { rowIdentityAccessor } });
|
55168
55180
|
}
|
55169
55181
|
return {
|
55170
55182
|
...state,
|
55171
55183
|
changes: {
|
55172
55184
|
...state.changes,
|
55173
|
-
rows: omit$1(state.changes.rows, `${rowId}.${columnId}`),
|
55174
|
-
errors: omit$1(state.changes.errors, `${rowId}.cells.${columnId}`),
|
55175
|
-
moveReasons: omit$1(state.changes.moveReasons, `${rowId}.${columnId}`)
|
55185
|
+
rows: omit$1(state.changes.rows, `${action.rowId}.${columnId}`),
|
55186
|
+
errors: omit$1(state.changes.errors, `${action.rowId}.cells.${columnId}`),
|
55187
|
+
moveReasons: omit$1(state.changes.moveReasons, `${action.rowId}.${columnId}`)
|
55176
55188
|
}
|
55177
55189
|
};
|
55178
55190
|
}
|
@@ -55182,24 +55194,28 @@ function reducer(state, action) {
|
|
55182
55194
|
...state,
|
55183
55195
|
changes: {
|
55184
55196
|
...state.changes,
|
55185
|
-
rows: setWith(state.changes.rows, rowId, value, Object),
|
55197
|
+
rows: setWith(state.changes.rows, action.rowId, value, Object),
|
55186
55198
|
errors: setWith(
|
55187
55199
|
state.changes.errors,
|
55188
|
-
`${rowId}.cells`,
|
55189
|
-
cellErrors ?? state.changes.errors.
|
55200
|
+
`${action.rowId}.cells`,
|
55201
|
+
cellErrors ?? ((_a = state.changes.errors[action.rowId]) == null ? void 0 : _a.cells),
|
55202
|
+
Object
|
55203
|
+
),
|
55204
|
+
originals: setWith(
|
55205
|
+
state.changes.originals,
|
55206
|
+
action.rowId,
|
55207
|
+
original ?? state.changes.originals[action.rowId],
|
55190
55208
|
Object
|
55191
55209
|
),
|
55192
|
-
originals: setWith(state.changes.originals, rowId, original ?? state.changes.originals[rowId], Object),
|
55193
55210
|
moveReasons: setWith(
|
55194
55211
|
state.changes.moveReasons,
|
55195
|
-
rowId,
|
55196
|
-
moveReasons ?? state.changes.moveReasons[rowId],
|
55212
|
+
action.rowId,
|
55213
|
+
moveReasons ?? state.changes.moveReasons[action.rowId],
|
55197
55214
|
Object
|
55198
|
-
)
|
55199
|
-
// status can be undefined, so don't use ??
|
55200
|
-
status: setWith(state.changes.status, rowId, void 0, Object)
|
55215
|
+
)
|
55201
55216
|
},
|
55202
|
-
indexes: setWith(state.indexes, rowId, index2, Object)
|
55217
|
+
indexes: setWith(state.indexes, action.rowId, index2, Object),
|
55218
|
+
statuses: omit$1(state.statuses, action.rowId)
|
55203
55219
|
};
|
55204
55220
|
}
|
55205
55221
|
case "removeRow": {
|
@@ -55208,28 +55224,27 @@ function reducer(state, action) {
|
|
55208
55224
|
...state,
|
55209
55225
|
changes: {
|
55210
55226
|
...state.changes,
|
55211
|
-
rows: omit$1(state.changes.rows, rowId),
|
55212
|
-
errors: omit$1(state.changes.errors, rowId),
|
55213
|
-
moveReasons: omit$1(state.changes.moveReasons, rowId),
|
55214
|
-
originals: omit$1(state.changes.originals, rowId),
|
55215
|
-
|
55216
|
-
dirty: omit$1(state.changes.dirty, rowId)
|
55227
|
+
rows: omit$1(state.changes.rows, action.rowId),
|
55228
|
+
errors: omit$1(state.changes.errors, action.rowId),
|
55229
|
+
moveReasons: omit$1(state.changes.moveReasons, action.rowId),
|
55230
|
+
originals: omit$1(state.changes.originals, action.rowId),
|
55231
|
+
dirty: omit$1(state.changes.dirty, action.rowId)
|
55217
55232
|
},
|
55218
|
-
indexes: omit$1(state.indexes, rowId),
|
55219
|
-
temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== rowId)
|
55233
|
+
indexes: omit$1(state.indexes, action.rowId),
|
55234
|
+
temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== action.rowId)
|
55220
55235
|
};
|
55221
55236
|
}
|
55222
55237
|
case "complete": {
|
55223
55238
|
const { changes, handleDiscard } = payload;
|
55224
|
-
if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[rowId])) {
|
55239
|
+
if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[action.rowId])) {
|
55225
55240
|
return {
|
55226
55241
|
...state,
|
55227
55242
|
changes: {
|
55228
55243
|
...state.changes,
|
55229
55244
|
originals: setWith(
|
55230
55245
|
state.changes.originals,
|
55231
|
-
rowId,
|
55232
|
-
{ ...state.changes.originals[rowId], ...changes },
|
55246
|
+
action.rowId,
|
55247
|
+
{ ...state.changes.originals[action.rowId], ...changes },
|
55233
55248
|
Object
|
55234
55249
|
)
|
55235
55250
|
}
|
@@ -55242,12 +55257,15 @@ function reducer(state, action) {
|
|
55242
55257
|
}
|
55243
55258
|
case "setRowStatus": {
|
55244
55259
|
const { status } = payload;
|
55260
|
+
if (status) {
|
55261
|
+
return {
|
55262
|
+
...state,
|
55263
|
+
statuses: setWith(state.statuses, action.rowId, status, Object)
|
55264
|
+
};
|
55265
|
+
}
|
55245
55266
|
return {
|
55246
55267
|
...state,
|
55247
|
-
|
55248
|
-
...state.changes,
|
55249
|
-
status: status ? setWith(state.changes.status, rowId, status, Object) : omit$1(state.changes.status, rowId)
|
55250
|
-
}
|
55268
|
+
statuses: omit$1(state.statuses, action.rowId)
|
55251
55269
|
};
|
55252
55270
|
}
|
55253
55271
|
case "setRowErrors": {
|
@@ -55256,7 +55274,7 @@ function reducer(state, action) {
|
|
55256
55274
|
...state,
|
55257
55275
|
changes: {
|
55258
55276
|
...state.changes,
|
55259
|
-
errors: setWith(state.changes.errors, rowId, errors, Object)
|
55277
|
+
errors: setWith(state.changes.errors, action.rowId, errors, Object)
|
55260
55278
|
}
|
55261
55279
|
};
|
55262
55280
|
}
|
@@ -55267,10 +55285,10 @@ function reducer(state, action) {
|
|
55267
55285
|
temporaryRows: state.temporaryRows.concat(value),
|
55268
55286
|
changes: {
|
55269
55287
|
...state.changes,
|
55270
|
-
rows: setWith(state.changes.rows, rowId, value, Object),
|
55271
|
-
originals: setWith(state.changes.originals, rowId, value, Object)
|
55288
|
+
rows: setWith(state.changes.rows, action.rowId, value, Object),
|
55289
|
+
originals: setWith(state.changes.originals, action.rowId, value, Object)
|
55272
55290
|
},
|
55273
|
-
indexes: setWith(state.indexes, rowId, index2, Object)
|
55291
|
+
indexes: setWith(state.indexes, action.rowId, index2, Object)
|
55274
55292
|
};
|
55275
55293
|
}
|
55276
55294
|
case "forceValidate": {
|
@@ -55287,9 +55305,10 @@ function reducer(state, action) {
|
|
55287
55305
|
function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator) {
|
55288
55306
|
const localization = useLocalization();
|
55289
55307
|
const [state, dispatch] = React.useReducer(reducer, {
|
55290
|
-
changes: { rows: {}, errors: {}, moveReasons: {}, originals: {},
|
55308
|
+
changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, dirty: {} },
|
55291
55309
|
indexes: {},
|
55292
|
-
temporaryRows: []
|
55310
|
+
temporaryRows: [],
|
55311
|
+
statuses: {}
|
55293
55312
|
});
|
55294
55313
|
function getRowValue(rowId) {
|
55295
55314
|
var _a;
|
@@ -55317,7 +55336,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55317
55336
|
return !!((_b = state.changes.errors[rowId]) == null ? void 0 : _b.row) || !!Object.keys(((_c = state.changes.errors[rowId]) == null ? void 0 : _c.cells) ?? {}).length;
|
55318
55337
|
}
|
55319
55338
|
function getRowStatus(rowId) {
|
55320
|
-
return state.
|
55339
|
+
return state.statuses[rowId];
|
55321
55340
|
}
|
55322
55341
|
function setRowStatus(rowId, status) {
|
55323
55342
|
dispatch({
|
@@ -55328,6 +55347,12 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55328
55347
|
}
|
55329
55348
|
});
|
55330
55349
|
}
|
55350
|
+
function showSavedStatus(rowId) {
|
55351
|
+
setRowStatus(rowId, "saved");
|
55352
|
+
setTimeout(() => {
|
55353
|
+
setRowStatus(rowId, void 0);
|
55354
|
+
}, DELAY_BEFORE_REMOVING_SAVE_STATUS);
|
55355
|
+
}
|
55331
55356
|
function insertTemporaryRow(data, rowIndex) {
|
55332
55357
|
const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${nanoid()}`;
|
55333
55358
|
const value = {
|
@@ -55454,7 +55479,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55454
55479
|
newState.changes.originals[row.id] = row.original;
|
55455
55480
|
newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };
|
55456
55481
|
newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };
|
55457
|
-
newState.
|
55482
|
+
newState.statuses[row.id] = "errored";
|
55458
55483
|
newState.indexes[row.id] = index2;
|
55459
55484
|
newState.changes.errors[row.id] = {
|
55460
55485
|
cells: cellErrors,
|
@@ -55495,7 +55520,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55495
55520
|
}));
|
55496
55521
|
}
|
55497
55522
|
function hasSaved() {
|
55498
|
-
return !!Object.values(state.
|
55523
|
+
return !!Object.values(state.statuses).filter((status) => status === "saved").length;
|
55499
55524
|
}
|
55500
55525
|
function hasChanges(rowId) {
|
55501
55526
|
return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;
|
@@ -55534,10 +55559,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55534
55559
|
}
|
55535
55560
|
await handleSave(changeSet);
|
55536
55561
|
complete(rowId2, table, rowChanges);
|
55537
|
-
|
55538
|
-
setTimeout(() => {
|
55539
|
-
setRowStatus(rowId2, void 0);
|
55540
|
-
}, DELAY_BEFORE_REMOVING_SAVE_STATUS);
|
55562
|
+
showSavedStatus(rowId2);
|
55541
55563
|
} catch (error) {
|
55542
55564
|
if (error instanceof ReferenceError || error instanceof TypeError || ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) >= 500) {
|
55543
55565
|
console.error(error);
|
@@ -55917,10 +55939,17 @@ function EditingControlCell(props) {
|
|
55917
55939
|
const handleFocus = useEditingCellAutofocus(props);
|
55918
55940
|
const value = cell.getValue();
|
55919
55941
|
const rowChanges = tableMeta.editing.getRowValue(cell.row.id);
|
55942
|
+
const shouldRunUpdate = React.useRef(false);
|
55920
55943
|
const hasNonTextControl = React.useMemo(() => {
|
55921
55944
|
var _a;
|
55922
55945
|
return typeof type === "function" && !!((_a = cellRef.current) == null ? void 0 : _a.querySelector('[data-taco="Select2"],[data-taco="switch"],[data-taco="checkbox"]'));
|
55923
55946
|
}, [cellRef.current]);
|
55947
|
+
useLazyEffect(() => {
|
55948
|
+
if (hasNonTextControl && shouldRunUpdate.current) {
|
55949
|
+
tableMeta.editing.onCellChanged(cell, rowIndex, value, true, false);
|
55950
|
+
shouldRunUpdate.current = false;
|
55951
|
+
}
|
55952
|
+
}, [value]);
|
55924
55953
|
const handleChange = React.useCallback(
|
55925
55954
|
(nextValue) => {
|
55926
55955
|
let hasChanged = false;
|
@@ -55937,9 +55966,7 @@ function EditingControlCell(props) {
|
|
55937
55966
|
}
|
55938
55967
|
if (hasChanged) {
|
55939
55968
|
tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
|
55940
|
-
|
55941
|
-
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue, true, false));
|
55942
|
-
}
|
55969
|
+
shouldRunUpdate.current = hasNonTextControl;
|
55943
55970
|
}
|
55944
55971
|
},
|
55945
55972
|
[hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value, columnMeta.dataType]
|
@@ -56217,6 +56244,7 @@ function DiscardChangesConfirmationDialog(props) {
|
|
56217
56244
|
return /* @__PURE__ */ React.createElement(Dialog, { ...dialogProps, showCloseButton: false }, /* @__PURE__ */ React.createElement(
|
56218
56245
|
Dialog.Content,
|
56219
56246
|
{
|
56247
|
+
"data-taco": "discard-changes-dialog",
|
56220
56248
|
"aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
|
56221
56249
|
onClick: handleClickInsideDialogContent,
|
56222
56250
|
onKeyDown: handleKeydown
|
@@ -56393,7 +56421,7 @@ function useTable3(props, ref) {
|
|
56393
56421
|
removeRowChanges: (rowId) => table.meta.editing.discardChanges(rowId, table.instance),
|
56394
56422
|
save: (rowId) => table.meta.editing.saveChanges(table.instance, rowId)
|
56395
56423
|
};
|
56396
|
-
if (props.onEditingCreate) {
|
56424
|
+
if (props.onEditingCreate && instance.editing) {
|
56397
56425
|
instance.editing.createRow = (row) => table.meta.editing.createRow(table.instance, row);
|
56398
56426
|
}
|
56399
56427
|
}
|
@@ -56402,7 +56430,7 @@ function useTable3(props, ref) {
|
|
56402
56430
|
React.useEffect(() => {
|
56403
56431
|
if (table.ref.current) {
|
56404
56432
|
const instance = table.ref.current.instance;
|
56405
|
-
if (table.meta.editing.isEnabled) {
|
56433
|
+
if (table.meta.editing.isEnabled && instance.editing) {
|
56406
56434
|
instance.editing.forceValidate = async () => await table.meta.editing.forceValidate(table.instance);
|
56407
56435
|
}
|
56408
56436
|
}
|