@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.cjs +169 -124
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.d.ts +11 -4
- package/dist/taco.js +169 -124
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
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(
|
@@ -29793,13 +29798,12 @@ const Item$2 = React__namespace.forwardRef(function MenuItem(props, ref) {
|
|
29793
29798
|
className: props.className
|
29794
29799
|
});
|
29795
29800
|
const disabled = props.disabled ?? props["aria-disabled"];
|
29796
|
-
|
29797
|
-
|
29798
|
-
handleClick = (event) => {
|
29801
|
+
const handleClick = (event) => {
|
29802
|
+
if (disabled) {
|
29799
29803
|
event.preventDefault();
|
29800
|
-
|
29801
|
-
|
29802
|
-
}
|
29804
|
+
}
|
29805
|
+
event.stopPropagation();
|
29806
|
+
};
|
29803
29807
|
if (subMenu) {
|
29804
29808
|
return /* @__PURE__ */ React__namespace.createElement($d08ef79370b62062$export$d7a01e11500dfb6f, null, /* @__PURE__ */ React__namespace.createElement($d08ef79370b62062$export$2ea8a7a591ac5eac, { ...otherProps, className, onClick: handleClick, ref }, icon ? /* @__PURE__ */ React__namespace.createElement(Icon, { name: icon }) : null, props.children, /* @__PURE__ */ React__namespace.createElement(Icon$1, { className: "-mr-1.5 ml-auto !h-5 !w-5", name: "chevron-right" })), subMenu());
|
29805
29809
|
}
|
@@ -35084,27 +35088,27 @@ function isMatched(query, cellValue, rowValue, dataType, dataTypeOptions, locali
|
|
35084
35088
|
if (typeof cellValue === "object") {
|
35085
35089
|
return flattenCellValue(cellValue).flat(Infinity).find((y2) => matcher(y2, query));
|
35086
35090
|
} else {
|
35087
|
-
const
|
35088
|
-
if (
|
35089
|
-
|
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
|
+
}
|
35090
35102
|
} else {
|
35091
|
-
const
|
35092
|
-
if (
|
35093
|
-
|
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
|
-
}
|
35103
|
+
const cellValueAsString = String(cellValue ?? "");
|
35104
|
+
if (cellValueAsString !== void 0 && matcher(cellValueAsString, query)) {
|
35105
|
+
return true;
|
35102
35106
|
}
|
35103
|
-
|
35104
|
-
|
35105
|
-
|
35106
|
-
|
35107
|
-
|
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;
|
35108
35112
|
}
|
35109
35113
|
}
|
35110
35114
|
}
|
@@ -35870,17 +35874,8 @@ function useTablePrintingSettings(tableId) {
|
|
35870
35874
|
}
|
35871
35875
|
const DEFAULT_ROW_ACTIONS_LENGTH = 4;
|
35872
35876
|
function useTableRowActions(isEnabled = false, rowActions, rowActionsLength = DEFAULT_ROW_ACTIONS_LENGTH) {
|
35873
|
-
const [handlers, setHandlers] = React.useState({});
|
35874
|
-
const registerHandler = (key, handler) => {
|
35875
|
-
return setHandlers((h2) => ({
|
35876
|
-
...h2,
|
35877
|
-
[key]: handler
|
35878
|
-
}));
|
35879
|
-
};
|
35880
35877
|
return {
|
35881
|
-
handlers,
|
35882
35878
|
isEnabled,
|
35883
|
-
registerHandler,
|
35884
35879
|
rowActions: isEnabled ? rowActions : void 0,
|
35885
35880
|
rowActionsLength: rowActions ? Math.min(rowActions.length, rowActionsLength) : 0
|
35886
35881
|
};
|
@@ -37797,7 +37792,7 @@ function getScrollPaddingEndOffset(table) {
|
|
37797
37792
|
}
|
37798
37793
|
function getPaddingEndOffset(table, options) {
|
37799
37794
|
const bottomRows = table.getBottomRows() ?? [];
|
37800
|
-
return ROW_HEIGHT_ESTIMATES.medium * ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ??
|
37795
|
+
return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length + ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ?? 0);
|
37801
37796
|
}
|
37802
37797
|
const OVERSCAN_ROW_COUNT = 8;
|
37803
37798
|
function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
|
@@ -37957,17 +37952,21 @@ function Actions(props) {
|
|
37957
37952
|
const { actions, actionsLength, data, isActiveRow, rowId, table } = props;
|
37958
37953
|
const { texts } = useLocalization();
|
37959
37954
|
const tableMeta = table.options.meta;
|
37960
|
-
const visibleActions = actions.map(
|
37961
|
-
|
37962
|
-
|
37963
|
-
|
37964
|
-
|
37955
|
+
const visibleActions = actions.map((action) => {
|
37956
|
+
var _a2;
|
37957
|
+
const helpers = {
|
37958
|
+
rowId,
|
37959
|
+
table
|
37960
|
+
};
|
37961
|
+
if (tableMeta.editing.isEnabled) {
|
37962
|
+
helpers.editing = {
|
37965
37963
|
isEditing: ((_a2 = tableMeta.editing) == null ? void 0 : _a2.isEditing) ?? false,
|
37966
|
-
rowId,
|
37967
|
-
table
|
37968
|
-
}
|
37964
|
+
removeRowChanges: () => tableMeta.editing.discardChanges(rowId, table),
|
37965
|
+
save: () => tableMeta.editing.saveChanges(table, rowId)
|
37966
|
+
};
|
37969
37967
|
}
|
37970
|
-
|
37968
|
+
return action(data, helpers);
|
37969
|
+
}).filter((action) => !!action);
|
37971
37970
|
let length = actionsLength;
|
37972
37971
|
if ((_a = tableMeta.editing) == null ? void 0 : _a.isEditing) {
|
37973
37972
|
const lengthWithoutEditingItems = visibleActions.length - 1;
|
@@ -44197,7 +44196,14 @@ const Placeholder = ({ disabled, readOnly, ...props }) => {
|
|
44197
44196
|
if (readOnly) {
|
44198
44197
|
return null;
|
44199
44198
|
}
|
44200
|
-
return /* @__PURE__ */ React.createElement(
|
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
|
+
);
|
44201
44207
|
};
|
44202
44208
|
const Trigger = React.forwardRef(function Select2Trigger(props, ref) {
|
44203
44209
|
const { multiple, value } = useSelect2Context();
|
@@ -44298,7 +44304,7 @@ const Single = React.forwardRef(function Select2TriggerSingle(props, ref) {
|
|
44298
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);
|
44299
44305
|
}
|
44300
44306
|
}
|
44301
|
-
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));
|
44302
44308
|
});
|
44303
44309
|
const Multiple = React.forwardRef(function Select2TriggerMultiple(props, ref) {
|
44304
44310
|
var _a;
|
@@ -44314,8 +44320,9 @@ const Multiple = React.forwardRef(function Select2TriggerMultiple(props, ref) {
|
|
44314
44320
|
let content;
|
44315
44321
|
let { className } = buttonProps;
|
44316
44322
|
if (open) {
|
44323
|
+
const hasValues = valuesAsChildren.length > 0;
|
44317
44324
|
className = clsx("!absolute z-20 !h-fit", buttonProps.className);
|
44318
|
-
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" },
|
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(
|
44319
44326
|
(child) => typeof child.props.children === "string" ? /* @__PURE__ */ React.createElement(
|
44320
44327
|
Tag,
|
44321
44328
|
{
|
@@ -44339,7 +44346,7 @@ const Multiple = React.forwardRef(function Select2TriggerMultiple(props, ref) {
|
|
44339
44346
|
{
|
44340
44347
|
key: String(child.props.value),
|
44341
44348
|
className: "!pr-0 !pl-1.5",
|
44342
|
-
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(
|
44343
44350
|
Icon$1,
|
44344
44351
|
{
|
44345
44352
|
name: "close",
|
@@ -45341,17 +45348,6 @@ function Control(props) {
|
|
45341
45348
|
return /* @__PURE__ */ React.createElement(Switch$1, { ...attributes, className: "m-1.5", checked: Boolean(value), onChange });
|
45342
45349
|
} else if (controlRenderer === "checkbox") {
|
45343
45350
|
return /* @__PURE__ */ React.createElement(Checkbox$2, { ...attributes, className: "!m-1.5", checked: Boolean(value), onChange });
|
45344
|
-
} else if ((controlRenderer === "input" || controlRenderer === void 0) && dataType === "number") {
|
45345
|
-
return /* @__PURE__ */ React.createElement(
|
45346
|
-
Input,
|
45347
|
-
{
|
45348
|
-
...attributes,
|
45349
|
-
className: "flex-grow",
|
45350
|
-
type: "number",
|
45351
|
-
onChange: (event) => onChange(event.target.valueAsNumber),
|
45352
|
-
value: String(value ?? "")
|
45353
|
-
}
|
45354
|
-
);
|
45355
45351
|
}
|
45356
45352
|
return /* @__PURE__ */ React.createElement(
|
45357
45353
|
Input,
|
@@ -53908,9 +53904,10 @@ function isTableScrolled(ref) {
|
|
53908
53904
|
var _a, _b, _c, _d;
|
53909
53905
|
if (ref.current) {
|
53910
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");
|
53911
|
-
|
53907
|
+
const hasVerticalScrollbar = ref.current.scrollHeight > ref.current.clientHeight;
|
53908
|
+
return [hasVerticalScrollbar, height > ref.current.scrollHeight];
|
53912
53909
|
}
|
53913
|
-
return false;
|
53910
|
+
return [false, false];
|
53914
53911
|
}
|
53915
53912
|
function useTableEditingListener(table, tableRef, scrollToIndex) {
|
53916
53913
|
const tableMeta = table.options.meta;
|
@@ -53922,7 +53919,7 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
|
|
53922
53919
|
tableMeta.editing.saveChanges(table, (_a = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) == null ? void 0 : _a.id);
|
53923
53920
|
}
|
53924
53921
|
};
|
53925
|
-
}, [tableMeta.rowActive.rowActiveIndex]);
|
53922
|
+
}, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.isEditing]);
|
53926
53923
|
const hasChanges = tableMeta.editing.hasChanges();
|
53927
53924
|
React.useEffect(() => {
|
53928
53925
|
function showUnsavedChangesWarning(event) {
|
@@ -53956,13 +53953,6 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
|
|
53956
53953
|
document.addEventListener("click", onClickOutside);
|
53957
53954
|
return () => document.removeEventListener("click", onClickOutside);
|
53958
53955
|
}, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
|
53959
|
-
React.useEffect(() => {
|
53960
|
-
if (tableMeta.editing.isEnabled) {
|
53961
|
-
tableMeta.rowActions.registerHandler("cleanup", (rowId) => {
|
53962
|
-
tableMeta.editing.discardChanges(rowId, table);
|
53963
|
-
});
|
53964
|
-
}
|
53965
|
-
}, []);
|
53966
53956
|
useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : void 0, (event) => {
|
53967
53957
|
event.preventDefault();
|
53968
53958
|
tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);
|
@@ -55061,7 +55051,8 @@ function reducer(state, action) {
|
|
55061
55051
|
changes: {
|
55062
55052
|
...state.changes,
|
55063
55053
|
rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
|
55064
|
-
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)
|
55065
55056
|
},
|
55066
55057
|
indexes: setWith(state.indexes, rowId, index2, Object)
|
55067
55058
|
};
|
@@ -55118,7 +55109,8 @@ function reducer(state, action) {
|
|
55118
55109
|
errors: omit$1(state.changes.errors, rowId),
|
55119
55110
|
moveReasons: omit$1(state.changes.moveReasons, rowId),
|
55120
55111
|
originals: omit$1(state.changes.originals, rowId),
|
55121
|
-
status: omit$1(state.changes.status, rowId)
|
55112
|
+
status: omit$1(state.changes.status, rowId),
|
55113
|
+
dirty: omit$1(state.changes.dirty, rowId)
|
55122
55114
|
},
|
55123
55115
|
indexes: omit$1(state.indexes, rowId),
|
55124
55116
|
temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== rowId)
|
@@ -55185,7 +55177,7 @@ function reducer(state, action) {
|
|
55185
55177
|
function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator) {
|
55186
55178
|
const localization = useLocalization();
|
55187
55179
|
const [state, dispatch] = React.useReducer(reducer, {
|
55188
|
-
changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },
|
55180
|
+
changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {}, dirty: {} },
|
55189
55181
|
indexes: {},
|
55190
55182
|
temporaryRows: []
|
55191
55183
|
});
|
@@ -55274,7 +55266,9 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55274
55266
|
}
|
55275
55267
|
async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true) {
|
55276
55268
|
var _a;
|
55277
|
-
const
|
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] };
|
55278
55272
|
const original = cell.row.original;
|
55279
55273
|
if (!Object.keys(changes).length) {
|
55280
55274
|
return;
|
@@ -55297,8 +55291,8 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55297
55291
|
) ?? {};
|
55298
55292
|
}
|
55299
55293
|
const nextChanges = { ...changes, ...updatesForOtherCells };
|
55300
|
-
const nextMoveReasons = { ...
|
55301
|
-
const nextCellErrors = { ...(_a =
|
55294
|
+
const nextMoveReasons = { ...state2.changes.moveReasons[cell.row.id] };
|
55295
|
+
const nextCellErrors = { ...(_a = state2.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
|
55302
55296
|
let validationErrors = {};
|
55303
55297
|
if (validator && Object.keys(nextChanges).length && original) {
|
55304
55298
|
const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };
|
@@ -55335,8 +55329,11 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55335
55329
|
}
|
55336
55330
|
});
|
55337
55331
|
}
|
55332
|
+
function getErrors() {
|
55333
|
+
return Object.keys(state.changes.errors);
|
55334
|
+
}
|
55338
55335
|
function getErrorsShownInAlert() {
|
55339
|
-
const rowsWithErrors =
|
55336
|
+
const rowsWithErrors = getErrors();
|
55340
55337
|
if (!rowsWithErrors.length) {
|
55341
55338
|
return [];
|
55342
55339
|
}
|
@@ -55355,13 +55352,19 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55355
55352
|
}
|
55356
55353
|
async function saveChanges(table, rowId = void 0) {
|
55357
55354
|
var _a, _b, _c;
|
55355
|
+
const tableMeta = table.options.meta;
|
55356
|
+
const state2 = tableMeta.editing.getState();
|
55358
55357
|
if (!handleSave) {
|
55359
55358
|
console.warn("Tried to save, but Table has no onEditingSave handler");
|
55360
55359
|
return false;
|
55361
55360
|
}
|
55362
|
-
const changes = rowId ? { [rowId]:
|
55361
|
+
const changes = rowId ? { [rowId]: state2.changes.rows[rowId] } : state2.changes.rows;
|
55363
55362
|
let completed = true;
|
55364
55363
|
for (const rowId2 of Object.keys(changes)) {
|
55364
|
+
if (!state2.changes.dirty[rowId2]) {
|
55365
|
+
discardChanges(rowId2, table);
|
55366
|
+
continue;
|
55367
|
+
}
|
55365
55368
|
const status = getRowStatus(rowId2);
|
55366
55369
|
try {
|
55367
55370
|
const rowChanges = JSON.parse(JSON.stringify(changes[rowId2] ?? {}));
|
@@ -55369,7 +55372,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55369
55372
|
continue;
|
55370
55373
|
}
|
55371
55374
|
setRowStatus(rowId2, "saving");
|
55372
|
-
const changeSet = { ...
|
55375
|
+
const changeSet = { ...state2.changes.originals[rowId2], ...rowChanges };
|
55373
55376
|
if (isTemporaryRow(changeSet[rowIdentityAccessor])) {
|
55374
55377
|
delete changeSet[rowIdentityAccessor];
|
55375
55378
|
}
|
@@ -55439,7 +55442,11 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55439
55442
|
payload: { rowIdentityAccessor, changes, handleDiscard: handleDiscard2 }
|
55440
55443
|
});
|
55441
55444
|
}
|
55445
|
+
function getState() {
|
55446
|
+
return state;
|
55447
|
+
}
|
55442
55448
|
return {
|
55449
|
+
getState,
|
55443
55450
|
// row
|
55444
55451
|
getRowValue,
|
55445
55452
|
getRowMoveReason,
|
@@ -55454,6 +55461,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55454
55461
|
getCellError,
|
55455
55462
|
onCellChanged,
|
55456
55463
|
// general
|
55464
|
+
getErrors,
|
55457
55465
|
getErrorsShownInAlert,
|
55458
55466
|
hasChanges,
|
55459
55467
|
saveChanges,
|
@@ -55464,7 +55472,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55464
55472
|
temporaryRows: state.temporaryRows
|
55465
55473
|
};
|
55466
55474
|
}
|
55467
|
-
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator) {
|
55475
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator, onEvent) {
|
55468
55476
|
const [isEditing, setEditing] = React.useState(false);
|
55469
55477
|
const [isDetailedMode, toggleDetailedMode] = React.useState(false);
|
55470
55478
|
const createRowButtonRef = React.useRef(null);
|
@@ -55476,8 +55484,13 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
55476
55484
|
rowIdentityAccessor,
|
55477
55485
|
validator
|
55478
55486
|
);
|
55487
|
+
useLazyEffect(() => {
|
55488
|
+
if (onEvent) {
|
55489
|
+
onEvent("editing-mode", { enabled: isEditing });
|
55490
|
+
}
|
55491
|
+
}, [isEditing]);
|
55479
55492
|
function toggleEditing(enabled, table, scrollToIndex) {
|
55480
|
-
var _a
|
55493
|
+
var _a;
|
55481
55494
|
const tableMeta = table.options.meta;
|
55482
55495
|
if (enabled) {
|
55483
55496
|
const index2 = tableMeta.rowActive.rowActiveIndex ?? 0;
|
@@ -55493,7 +55506,6 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
55493
55506
|
}
|
55494
55507
|
setEditing(enabled);
|
55495
55508
|
pendingChangesFns.saveChanges(table);
|
55496
|
-
(_b = tableMeta.onEvent) == null ? void 0 : _b.call(tableMeta, "editing-mode", { enabled });
|
55497
55509
|
}
|
55498
55510
|
async function createRow2(table, row) {
|
55499
55511
|
if (!handleCreate) {
|
@@ -55511,18 +55523,18 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
55511
55523
|
if (changeset) {
|
55512
55524
|
const temporaryRows = tableMeta.editing.temporaryRows;
|
55513
55525
|
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
55514
|
-
|
55515
|
-
table.setRowPinning((currentState) => {
|
55516
|
-
var _a;
|
55517
|
-
return {
|
55518
|
-
...currentState,
|
55519
|
-
bottom: (_a = currentState.bottom ?? []) == null ? void 0 : _a.concat(newRowId)
|
55520
|
-
};
|
55521
|
-
});
|
55522
|
-
toggleDetailedMode(false);
|
55523
|
-
setLastFocusedCellIndex(void 0);
|
55526
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
55524
55527
|
requestAnimationFrame(() => {
|
55525
|
-
|
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);
|
55526
55538
|
table.resetRowSelection();
|
55527
55539
|
if (!tableMeta.editing.isEditing) {
|
55528
55540
|
setEditing(true);
|
@@ -55749,14 +55761,26 @@ function EditingControlCell(props) {
|
|
55749
55761
|
}, [cellRef.current]);
|
55750
55762
|
const handleChange = React.useCallback(
|
55751
55763
|
(nextValue) => {
|
55752
|
-
|
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) {
|
55753
55777
|
tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
|
55754
55778
|
if (hasNonTextControl) {
|
55755
55779
|
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
|
55756
55780
|
}
|
55757
55781
|
}
|
55758
55782
|
},
|
55759
|
-
[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]
|
55760
55784
|
);
|
55761
55785
|
const handleBlur = React.useCallback(
|
55762
55786
|
(event) => {
|
@@ -55988,7 +56012,10 @@ function Cell$1(props) {
|
|
55988
56012
|
const hasErrorAndIsEditing = cellError ? tableMeta.editing.isEditing : true;
|
55989
56013
|
const changedValue = tableMeta.editing.getCellValue(cell);
|
55990
56014
|
if (changedValue !== void 0 && changedValue !== cell.getValue() && hasErrorAndIsEditing) {
|
55991
|
-
|
56015
|
+
const getValue2 = () => changedValue;
|
56016
|
+
const context = cell.getContext();
|
56017
|
+
cell.getValue = getValue2;
|
56018
|
+
cell.getContext = () => ({ ...context, getValue: getValue2 });
|
55992
56019
|
}
|
55993
56020
|
if (isActiveRow || !!cellError || isHovered && !isActiveRow && !tableMeta.rowActive.isHoverStatePaused) {
|
55994
56021
|
return /* @__PURE__ */ React.createElement(EditingControlCell, { ...props });
|
@@ -56025,7 +56052,7 @@ function DiscardChangesConfirmationDialog(props) {
|
|
56025
56052
|
event.stopPropagation();
|
56026
56053
|
}
|
56027
56054
|
};
|
56028
|
-
return /* @__PURE__ */ React.createElement(Dialog, { ...dialogProps }, /* @__PURE__ */ React.createElement(
|
56055
|
+
return /* @__PURE__ */ React.createElement(Dialog, { ...dialogProps, showCloseButton: false }, /* @__PURE__ */ React.createElement(
|
56029
56056
|
Dialog.Content,
|
56030
56057
|
{
|
56031
56058
|
"aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
|
@@ -56034,7 +56061,15 @@ function DiscardChangesConfirmationDialog(props) {
|
|
56034
56061
|
},
|
56035
56062
|
/* @__PURE__ */ React.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title),
|
56036
56063
|
/* @__PURE__ */ React.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description),
|
56037
|
-
/* @__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
|
+
)))
|
56038
56073
|
));
|
56039
56074
|
}
|
56040
56075
|
function Row(props) {
|
@@ -56082,7 +56117,7 @@ function Row(props) {
|
|
56082
56117
|
if (event.isDefaultPrevented() || event.isPropagationStopped()) {
|
56083
56118
|
return;
|
56084
56119
|
}
|
56085
|
-
if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !
|
56120
|
+
if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !isElementInsideOverlay(event.target)) {
|
56086
56121
|
event.preventDefault();
|
56087
56122
|
setShowDiscardDialog(true);
|
56088
56123
|
}
|
@@ -56115,7 +56150,8 @@ function useTable3(props, ref) {
|
|
56115
56150
|
props.onEditingCreate,
|
56116
56151
|
props.onEditingDiscard,
|
56117
56152
|
props.rowIdentityAccessor,
|
56118
|
-
props.validator
|
56153
|
+
props.validator,
|
56154
|
+
props.onEvent
|
56119
56155
|
);
|
56120
56156
|
const data = React.useMemo(() => {
|
56121
56157
|
if (editing.temporaryRows.length) {
|
@@ -56167,18 +56203,33 @@ function useTable3(props, ref) {
|
|
56167
56203
|
};
|
56168
56204
|
const meta = { editing };
|
56169
56205
|
const options = {
|
56170
|
-
virtualiserPaddingEndOffset:
|
56206
|
+
virtualiserPaddingEndOffset: 0
|
56171
56207
|
};
|
56208
|
+
if (props.enableEditing) {
|
56209
|
+
const validationErrorLabelHeight = 17;
|
56210
|
+
options.virtualiserPaddingEndOffset = editing.getErrors().length * validationErrorLabelHeight;
|
56211
|
+
}
|
56172
56212
|
const table = useTable$1(extendedProps, ref, RENDERERS, meta, options);
|
56173
56213
|
useTableEditingListener(table.instance, table.ref, table.renderer.scrollToIndex);
|
56174
56214
|
React.useEffect(() => {
|
56175
56215
|
if (table.ref.current) {
|
56176
|
-
|
56177
|
-
if (
|
56178
|
-
|
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
|
+
}
|
56179
56230
|
}
|
56180
56231
|
}
|
56181
|
-
}, [table.ref.current]);
|
56232
|
+
}, [table.ref.current, table.meta.editing.isEnabled]);
|
56182
56233
|
return table;
|
56183
56234
|
}
|
56184
56235
|
function Alert(props) {
|
@@ -56288,7 +56339,7 @@ function Editing(props) {
|
|
56288
56339
|
}
|
56289
56340
|
function CreateNewRow(props) {
|
56290
56341
|
var _a, _b;
|
56291
|
-
const { buttonRef,
|
56342
|
+
const { buttonRef, hasScrollbar, table, tableMeta } = props;
|
56292
56343
|
const { texts } = useLocalization();
|
56293
56344
|
const temporaryRows = tableMeta.editing.temporaryRows;
|
56294
56345
|
const temporaryRowId = ((_a = temporaryRows[0]) == null ? void 0 : _a[tableMeta.rowIdentityAccessor]) ?? "";
|
@@ -56311,7 +56362,8 @@ function CreateNewRow(props) {
|
|
56311
56362
|
}
|
56312
56363
|
const className = clsx("group/row !sticky z-[21]", {
|
56313
56364
|
"bottom-10": tableMeta.footer.isEnabled,
|
56314
|
-
"bottom-0": !tableMeta.footer.isEnabled
|
56365
|
+
"bottom-0": !tableMeta.footer.isEnabled,
|
56366
|
+
"border-b !border-t-[0]": !hasScrollbar
|
56315
56367
|
});
|
56316
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(
|
56317
56369
|
Button$4,
|
@@ -56332,9 +56384,8 @@ function TemporaryRows(props) {
|
|
56332
56384
|
return props.table.getBottomRows().map((row) => /* @__PURE__ */ React.createElement(TemporaryRow, { key: row.id, row, ...props }));
|
56333
56385
|
}
|
56334
56386
|
function TemporaryRow(props) {
|
56335
|
-
const { createRowButtonRef, row, table, tableMeta, tableRef } = props;
|
56387
|
+
const { createRowButtonRef, hasScrollbar, row, table, tableMeta, tableRef } = props;
|
56336
56388
|
const handleKeyDown = async (event) => {
|
56337
|
-
var _a;
|
56338
56389
|
const target = event.target;
|
56339
56390
|
if (isAriaDirectionKey(event) && isElementInsideExternalRelatedOverlay(target, tableRef)) {
|
56340
56391
|
return;
|
@@ -56344,12 +56395,16 @@ function TemporaryRow(props) {
|
|
56344
56395
|
if (!isElementTriggeredFromContainer(target, event.currentTarget)) {
|
56345
56396
|
const saved = await tableMeta.editing.saveChanges(table);
|
56346
56397
|
if (saved) {
|
56347
|
-
(
|
56398
|
+
requestAnimationFrame(() => {
|
56399
|
+
var _a;
|
56400
|
+
(_a = createRowButtonRef.current) == null ? void 0 : _a.focus();
|
56401
|
+
});
|
56348
56402
|
}
|
56349
56403
|
}
|
56350
56404
|
} else if (event.key === "ArrowUp") {
|
56351
56405
|
event.preventDefault();
|
56352
56406
|
event.stopPropagation();
|
56407
|
+
await tableMeta.editing.saveChanges(table);
|
56353
56408
|
const lastIndex = tableMeta.length - 1;
|
56354
56409
|
tableMeta.rowActive.setRowActiveIndex(lastIndex);
|
56355
56410
|
if (tableRef.current) {
|
@@ -56362,20 +56417,10 @@ function TemporaryRow(props) {
|
|
56362
56417
|
}
|
56363
56418
|
}
|
56364
56419
|
};
|
56365
|
-
const handleKeyDownCapture = (event) => {
|
56366
|
-
if (event.key === "ArrowLeft" && tableMeta.editing.lastFocusedCellIndex === 0) {
|
56367
|
-
event.preventDefault();
|
56368
|
-
event.stopPropagation();
|
56369
|
-
} else if (event.key === "ArrowRight" && tableMeta.editing.lastFocusedCellIndex) {
|
56370
|
-
if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {
|
56371
|
-
event.preventDefault();
|
56372
|
-
event.stopPropagation();
|
56373
|
-
}
|
56374
|
-
}
|
56375
|
-
};
|
56376
56420
|
const className = clsx("group/row border-grey-300 !sticky z-[22] print:hidden border-t-2", {
|
56377
56421
|
"bottom-[calc(5rem_+_5px)] data-[row-editing-move]:bottom-[calc(5rem_+_5px)]": tableMeta.footer.isEnabled,
|
56378
|
-
"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
|
56379
56424
|
});
|
56380
56425
|
return /* @__PURE__ */ React.createElement(
|
56381
56426
|
Row$2,
|
@@ -56389,7 +56434,6 @@ function TemporaryRow(props) {
|
|
56389
56434
|
table,
|
56390
56435
|
className,
|
56391
56436
|
onKeyDown: handleKeyDown,
|
56392
|
-
onKeyDownCapture: handleKeyDownCapture,
|
56393
56437
|
hideInternalColumns: true,
|
56394
56438
|
hideRowActions: !tableMeta.editing.isEditing,
|
56395
56439
|
skipPageLoading: true
|
@@ -56417,14 +56461,14 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
|
|
56417
56461
|
return rowsById[row.rowId];
|
56418
56462
|
}).length;
|
56419
56463
|
const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;
|
56420
|
-
const isScrolled = isTableScrolled(table3.ref);
|
56464
|
+
const [hasScrollbar, isScrolled] = isTableScrolled(table3.ref);
|
56421
56465
|
let createWorkflow;
|
56422
56466
|
if (hasCreateWorkflow) {
|
56423
56467
|
createWorkflow = /* @__PURE__ */ React.createElement(
|
56424
56468
|
CreateNewRow,
|
56425
56469
|
{
|
56426
56470
|
buttonRef: table3.meta.editing.createRowButtonRef,
|
56427
|
-
|
56471
|
+
hasScrollbar,
|
56428
56472
|
table: table3.instance,
|
56429
56473
|
tableMeta: table3.meta
|
56430
56474
|
}
|
@@ -56450,6 +56494,7 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
|
|
56450
56494
|
TemporaryRows,
|
56451
56495
|
{
|
56452
56496
|
createRowButtonRef: table3.meta.editing.createRowButtonRef,
|
56497
|
+
hasScrollbar,
|
56453
56498
|
table: table3.instance,
|
56454
56499
|
tableMeta: table3.meta,
|
56455
56500
|
tableRef: table3.ref
|