@economic/taco 2.61.4 → 2.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/taco.cjs +152 -115
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.d.ts +11 -4
- package/dist/taco.js +152 -115
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
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
|
-
|
3066
|
-
|
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
|
-
|
3412
|
-
|
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(
|
@@ -35065,27 +35070,27 @@ function isMatched(query, cellValue, rowValue, dataType, dataTypeOptions, locali
|
|
35065
35070
|
if (typeof cellValue === "object") {
|
35066
35071
|
return flattenCellValue(cellValue).flat(Infinity).find((y2) => matcher(y2, query));
|
35067
35072
|
} else {
|
35068
|
-
const
|
35069
|
-
if (
|
35070
|
-
|
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
|
+
}
|
35071
35084
|
} else {
|
35072
|
-
const
|
35073
|
-
if (
|
35074
|
-
|
35075
|
-
dataTypeOptions,
|
35076
|
-
localization
|
35077
|
-
});
|
35078
|
-
if (Array.isArray(cellDisplayValue)) {
|
35079
|
-
return cellDisplayValue.some((cdv) => matcher(cdv, query));
|
35080
|
-
} else if (cellDisplayValue !== void 0 && isWeakContains(cellDisplayValue, query)) {
|
35081
|
-
return true;
|
35082
|
-
}
|
35085
|
+
const cellValueAsString = String(cellValue ?? "");
|
35086
|
+
if (cellValueAsString !== void 0 && matcher(cellValueAsString, query)) {
|
35087
|
+
return true;
|
35083
35088
|
}
|
35084
|
-
|
35085
|
-
|
35086
|
-
|
35087
|
-
|
35088
|
-
|
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;
|
35089
35094
|
}
|
35090
35095
|
}
|
35091
35096
|
}
|
@@ -35851,17 +35856,8 @@ function useTablePrintingSettings(tableId) {
|
|
35851
35856
|
}
|
35852
35857
|
const DEFAULT_ROW_ACTIONS_LENGTH = 4;
|
35853
35858
|
function useTableRowActions(isEnabled = false, rowActions, rowActionsLength = DEFAULT_ROW_ACTIONS_LENGTH) {
|
35854
|
-
const [handlers, setHandlers] = React__default.useState({});
|
35855
|
-
const registerHandler = (key, handler) => {
|
35856
|
-
return setHandlers((h2) => ({
|
35857
|
-
...h2,
|
35858
|
-
[key]: handler
|
35859
|
-
}));
|
35860
|
-
};
|
35861
35859
|
return {
|
35862
|
-
handlers,
|
35863
35860
|
isEnabled,
|
35864
|
-
registerHandler,
|
35865
35861
|
rowActions: isEnabled ? rowActions : void 0,
|
35866
35862
|
rowActionsLength: rowActions ? Math.min(rowActions.length, rowActionsLength) : 0
|
35867
35863
|
};
|
@@ -37778,7 +37774,7 @@ function getScrollPaddingEndOffset(table) {
|
|
37778
37774
|
}
|
37779
37775
|
function getPaddingEndOffset(table, options) {
|
37780
37776
|
const bottomRows = table.getBottomRows() ?? [];
|
37781
|
-
return ROW_HEIGHT_ESTIMATES.medium * ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ??
|
37777
|
+
return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length + ((options == null ? void 0 : options.virtualiserPaddingEndOffset) ?? 0);
|
37782
37778
|
}
|
37783
37779
|
const OVERSCAN_ROW_COUNT = 8;
|
37784
37780
|
function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
|
@@ -37938,17 +37934,21 @@ function Actions(props) {
|
|
37938
37934
|
const { actions, actionsLength, data, isActiveRow, rowId, table } = props;
|
37939
37935
|
const { texts } = useLocalization();
|
37940
37936
|
const tableMeta = table.options.meta;
|
37941
|
-
const visibleActions = actions.map(
|
37942
|
-
|
37943
|
-
|
37944
|
-
|
37945
|
-
|
37946
|
-
|
37947
|
-
|
37948
|
-
|
37949
|
-
|
37937
|
+
const visibleActions = actions.map((action) => {
|
37938
|
+
var _a2, _b;
|
37939
|
+
const helpers = {
|
37940
|
+
rowId,
|
37941
|
+
table
|
37942
|
+
};
|
37943
|
+
if ((_a2 = tableMeta.editing) == null ? void 0 : _a2.isEnabled) {
|
37944
|
+
helpers.editing = {
|
37945
|
+
isEditing: ((_b = tableMeta.editing) == null ? void 0 : _b.isEditing) ?? false,
|
37946
|
+
removeRowChanges: () => tableMeta.editing.discardChanges(rowId, table),
|
37947
|
+
save: () => tableMeta.editing.saveChanges(table, rowId)
|
37948
|
+
};
|
37950
37949
|
}
|
37951
|
-
|
37950
|
+
return action(data, helpers);
|
37951
|
+
}).filter((action) => !!action);
|
37952
37952
|
let length = actionsLength;
|
37953
37953
|
if ((_a = tableMeta.editing) == null ? void 0 : _a.isEditing) {
|
37954
37954
|
const lengthWithoutEditingItems = visibleActions.length - 1;
|
@@ -44178,7 +44178,14 @@ const Placeholder = ({ disabled, readOnly, ...props }) => {
|
|
44178
44178
|
if (readOnly) {
|
44179
44179
|
return null;
|
44180
44180
|
}
|
44181
|
-
return /* @__PURE__ */ React__default.createElement(
|
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
|
+
);
|
44182
44189
|
};
|
44183
44190
|
const Trigger = React__default.forwardRef(function Select2Trigger(props, ref) {
|
44184
44191
|
const { multiple, value } = useSelect2Context();
|
@@ -44279,7 +44286,7 @@ const Single = React__default.forwardRef(function Select2TriggerSingle(props, re
|
|
44279
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);
|
44280
44287
|
}
|
44281
44288
|
}
|
44282
|
-
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));
|
44283
44290
|
});
|
44284
44291
|
const Multiple = React__default.forwardRef(function Select2TriggerMultiple(props, ref) {
|
44285
44292
|
var _a;
|
@@ -44295,8 +44302,9 @@ const Multiple = React__default.forwardRef(function Select2TriggerMultiple(props
|
|
44295
44302
|
let content;
|
44296
44303
|
let { className } = buttonProps;
|
44297
44304
|
if (open) {
|
44305
|
+
const hasValues = valuesAsChildren.length > 0;
|
44298
44306
|
className = clsx("!absolute z-20 !h-fit", buttonProps.className);
|
44299
|
-
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" },
|
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(
|
44300
44308
|
(child) => typeof child.props.children === "string" ? /* @__PURE__ */ React__default.createElement(
|
44301
44309
|
Tag,
|
44302
44310
|
{
|
@@ -44320,7 +44328,7 @@ const Multiple = React__default.forwardRef(function Select2TriggerMultiple(props
|
|
44320
44328
|
{
|
44321
44329
|
key: String(child.props.value),
|
44322
44330
|
className: "!pr-0 !pl-1.5",
|
44323
|
-
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(
|
44324
44332
|
Icon$1,
|
44325
44333
|
{
|
44326
44334
|
name: "close",
|
@@ -45322,17 +45330,6 @@ function Control(props) {
|
|
45322
45330
|
return /* @__PURE__ */ React__default.createElement(Switch$1, { ...attributes, className: "m-1.5", checked: Boolean(value), onChange });
|
45323
45331
|
} else if (controlRenderer === "checkbox") {
|
45324
45332
|
return /* @__PURE__ */ React__default.createElement(Checkbox$2, { ...attributes, className: "!m-1.5", checked: Boolean(value), onChange });
|
45325
|
-
} else if ((controlRenderer === "input" || controlRenderer === void 0) && dataType === "number") {
|
45326
|
-
return /* @__PURE__ */ React__default.createElement(
|
45327
|
-
Input,
|
45328
|
-
{
|
45329
|
-
...attributes,
|
45330
|
-
className: "flex-grow",
|
45331
|
-
type: "number",
|
45332
|
-
onChange: (event) => onChange(event.target.valueAsNumber),
|
45333
|
-
value: String(value ?? "")
|
45334
|
-
}
|
45335
|
-
);
|
45336
45333
|
}
|
45337
45334
|
return /* @__PURE__ */ React__default.createElement(
|
45338
45335
|
Input,
|
@@ -53889,9 +53886,10 @@ function isTableScrolled(ref) {
|
|
53889
53886
|
var _a, _b, _c, _d;
|
53890
53887
|
if (ref.current) {
|
53891
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");
|
53892
|
-
|
53889
|
+
const hasVerticalScrollbar = ref.current.scrollHeight > ref.current.clientHeight;
|
53890
|
+
return [hasVerticalScrollbar, height > ref.current.scrollHeight];
|
53893
53891
|
}
|
53894
|
-
return false;
|
53892
|
+
return [false, false];
|
53895
53893
|
}
|
53896
53894
|
function useTableEditingListener(table, tableRef, scrollToIndex) {
|
53897
53895
|
const tableMeta = table.options.meta;
|
@@ -53937,13 +53935,6 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
|
|
53937
53935
|
document.addEventListener("click", onClickOutside);
|
53938
53936
|
return () => document.removeEventListener("click", onClickOutside);
|
53939
53937
|
}, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
|
53940
|
-
React__default.useEffect(() => {
|
53941
|
-
if (tableMeta.editing.isEnabled) {
|
53942
|
-
tableMeta.rowActions.registerHandler("cleanup", (rowId) => {
|
53943
|
-
tableMeta.editing.discardChanges(rowId, table);
|
53944
|
-
});
|
53945
|
-
}
|
53946
|
-
}, []);
|
53947
53938
|
useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : void 0, (event) => {
|
53948
53939
|
event.preventDefault();
|
53949
53940
|
tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);
|
@@ -55042,7 +55033,8 @@ function reducer(state, action) {
|
|
55042
55033
|
changes: {
|
55043
55034
|
...state.changes,
|
55044
55035
|
rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
|
55045
|
-
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)
|
55046
55038
|
},
|
55047
55039
|
indexes: setWith(state.indexes, rowId, index2, Object)
|
55048
55040
|
};
|
@@ -55099,7 +55091,8 @@ function reducer(state, action) {
|
|
55099
55091
|
errors: omit$1(state.changes.errors, rowId),
|
55100
55092
|
moveReasons: omit$1(state.changes.moveReasons, rowId),
|
55101
55093
|
originals: omit$1(state.changes.originals, rowId),
|
55102
|
-
status: omit$1(state.changes.status, rowId)
|
55094
|
+
status: omit$1(state.changes.status, rowId),
|
55095
|
+
dirty: omit$1(state.changes.dirty, rowId)
|
55103
55096
|
},
|
55104
55097
|
indexes: omit$1(state.indexes, rowId),
|
55105
55098
|
temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== rowId)
|
@@ -55166,7 +55159,7 @@ function reducer(state, action) {
|
|
55166
55159
|
function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator) {
|
55167
55160
|
const localization = useLocalization();
|
55168
55161
|
const [state, dispatch] = React__default.useReducer(reducer, {
|
55169
|
-
changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },
|
55162
|
+
changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {}, dirty: {} },
|
55170
55163
|
indexes: {},
|
55171
55164
|
temporaryRows: []
|
55172
55165
|
});
|
@@ -55255,7 +55248,9 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55255
55248
|
}
|
55256
55249
|
async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true) {
|
55257
55250
|
var _a;
|
55258
|
-
const
|
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] };
|
55259
55254
|
const original = cell.row.original;
|
55260
55255
|
if (!Object.keys(changes).length) {
|
55261
55256
|
return;
|
@@ -55278,8 +55273,8 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55278
55273
|
) ?? {};
|
55279
55274
|
}
|
55280
55275
|
const nextChanges = { ...changes, ...updatesForOtherCells };
|
55281
|
-
const nextMoveReasons = { ...
|
55282
|
-
const nextCellErrors = { ...(_a =
|
55276
|
+
const nextMoveReasons = { ...state2.changes.moveReasons[cell.row.id] };
|
55277
|
+
const nextCellErrors = { ...(_a = state2.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
|
55283
55278
|
let validationErrors = {};
|
55284
55279
|
if (validator && Object.keys(nextChanges).length && original) {
|
55285
55280
|
const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };
|
@@ -55316,8 +55311,11 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55316
55311
|
}
|
55317
55312
|
});
|
55318
55313
|
}
|
55314
|
+
function getErrors() {
|
55315
|
+
return Object.keys(state.changes.errors);
|
55316
|
+
}
|
55319
55317
|
function getErrorsShownInAlert() {
|
55320
|
-
const rowsWithErrors =
|
55318
|
+
const rowsWithErrors = getErrors();
|
55321
55319
|
if (!rowsWithErrors.length) {
|
55322
55320
|
return [];
|
55323
55321
|
}
|
@@ -55345,6 +55343,10 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55345
55343
|
const changes = rowId ? { [rowId]: state2.changes.rows[rowId] } : state2.changes.rows;
|
55346
55344
|
let completed = true;
|
55347
55345
|
for (const rowId2 of Object.keys(changes)) {
|
55346
|
+
if (!state2.changes.dirty[rowId2]) {
|
55347
|
+
discardChanges(rowId2, table);
|
55348
|
+
continue;
|
55349
|
+
}
|
55348
55350
|
const status = getRowStatus(rowId2);
|
55349
55351
|
try {
|
55350
55352
|
const rowChanges = JSON.parse(JSON.stringify(changes[rowId2] ?? {}));
|
@@ -55441,6 +55443,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55441
55443
|
getCellError,
|
55442
55444
|
onCellChanged,
|
55443
55445
|
// general
|
55446
|
+
getErrors,
|
55444
55447
|
getErrorsShownInAlert,
|
55445
55448
|
hasChanges,
|
55446
55449
|
saveChanges,
|
@@ -55451,7 +55454,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
|
|
55451
55454
|
temporaryRows: state.temporaryRows
|
55452
55455
|
};
|
55453
55456
|
}
|
55454
|
-
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator) {
|
55457
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator, onEvent) {
|
55455
55458
|
const [isEditing, setEditing] = React__default.useState(false);
|
55456
55459
|
const [isDetailedMode, toggleDetailedMode] = React__default.useState(false);
|
55457
55460
|
const createRowButtonRef = React__default.useRef(null);
|
@@ -55463,8 +55466,13 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
55463
55466
|
rowIdentityAccessor,
|
55464
55467
|
validator
|
55465
55468
|
);
|
55469
|
+
useLazyEffect(() => {
|
55470
|
+
if (onEvent) {
|
55471
|
+
onEvent("editing-mode", { enabled: isEditing });
|
55472
|
+
}
|
55473
|
+
}, [isEditing]);
|
55466
55474
|
function toggleEditing(enabled, table, scrollToIndex) {
|
55467
|
-
var _a
|
55475
|
+
var _a;
|
55468
55476
|
const tableMeta = table.options.meta;
|
55469
55477
|
if (enabled) {
|
55470
55478
|
const index2 = tableMeta.rowActive.rowActiveIndex ?? 0;
|
@@ -55480,7 +55488,6 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
55480
55488
|
}
|
55481
55489
|
setEditing(enabled);
|
55482
55490
|
pendingChangesFns.saveChanges(table);
|
55483
|
-
(_b = tableMeta.onEvent) == null ? void 0 : _b.call(tableMeta, "editing-mode", { enabled });
|
55484
55491
|
}
|
55485
55492
|
async function createRow2(table, row) {
|
55486
55493
|
if (!handleCreate) {
|
@@ -55498,18 +55505,18 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
55498
55505
|
if (changeset) {
|
55499
55506
|
const temporaryRows = tableMeta.editing.temporaryRows;
|
55500
55507
|
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
55501
|
-
|
55502
|
-
table.setRowPinning((currentState) => {
|
55503
|
-
var _a;
|
55504
|
-
return {
|
55505
|
-
...currentState,
|
55506
|
-
bottom: (_a = currentState.bottom ?? []) == null ? void 0 : _a.concat(newRowId)
|
55507
|
-
};
|
55508
|
-
});
|
55509
|
-
toggleDetailedMode(false);
|
55510
|
-
setLastFocusedCellIndex(void 0);
|
55508
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
55511
55509
|
requestAnimationFrame(() => {
|
55512
|
-
|
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);
|
55513
55520
|
table.resetRowSelection();
|
55514
55521
|
if (!tableMeta.editing.isEditing) {
|
55515
55522
|
setEditing(true);
|
@@ -55736,14 +55743,26 @@ function EditingControlCell(props) {
|
|
55736
55743
|
}, [cellRef.current]);
|
55737
55744
|
const handleChange = React__default.useCallback(
|
55738
55745
|
(nextValue) => {
|
55739
|
-
|
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) {
|
55740
55759
|
tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
|
55741
55760
|
if (hasNonTextControl) {
|
55742
55761
|
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
|
55743
55762
|
}
|
55744
55763
|
}
|
55745
55764
|
},
|
55746
|
-
[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]
|
55747
55766
|
);
|
55748
55767
|
const handleBlur = React__default.useCallback(
|
55749
55768
|
(event) => {
|
@@ -56015,7 +56034,7 @@ function DiscardChangesConfirmationDialog(props) {
|
|
56015
56034
|
event.stopPropagation();
|
56016
56035
|
}
|
56017
56036
|
};
|
56018
|
-
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(
|
56019
56038
|
Dialog.Content,
|
56020
56039
|
{
|
56021
56040
|
"aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
|
@@ -56024,7 +56043,15 @@ function DiscardChangesConfirmationDialog(props) {
|
|
56024
56043
|
},
|
56025
56044
|
/* @__PURE__ */ React__default.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title),
|
56026
56045
|
/* @__PURE__ */ React__default.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description),
|
56027
|
-
/* @__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
|
+
)))
|
56028
56055
|
));
|
56029
56056
|
}
|
56030
56057
|
function Row(props) {
|
@@ -56072,7 +56099,7 @@ function Row(props) {
|
|
56072
56099
|
if (event.isDefaultPrevented() || event.isPropagationStopped()) {
|
56073
56100
|
return;
|
56074
56101
|
}
|
56075
|
-
if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !
|
56102
|
+
if (event.key === "Escape" && tableMeta.editing.hasChanges(row.id) && !isElementInsideOverlay(event.target)) {
|
56076
56103
|
event.preventDefault();
|
56077
56104
|
setShowDiscardDialog(true);
|
56078
56105
|
}
|
@@ -56105,7 +56132,8 @@ function useTable3(props, ref) {
|
|
56105
56132
|
props.onEditingCreate,
|
56106
56133
|
props.onEditingDiscard,
|
56107
56134
|
props.rowIdentityAccessor,
|
56108
|
-
props.validator
|
56135
|
+
props.validator,
|
56136
|
+
props.onEvent
|
56109
56137
|
);
|
56110
56138
|
const data = React__default.useMemo(() => {
|
56111
56139
|
if (editing.temporaryRows.length) {
|
@@ -56157,18 +56185,33 @@ function useTable3(props, ref) {
|
|
56157
56185
|
};
|
56158
56186
|
const meta = { editing };
|
56159
56187
|
const options = {
|
56160
|
-
virtualiserPaddingEndOffset:
|
56188
|
+
virtualiserPaddingEndOffset: 0
|
56161
56189
|
};
|
56190
|
+
if (props.enableEditing) {
|
56191
|
+
const validationErrorLabelHeight = 17;
|
56192
|
+
options.virtualiserPaddingEndOffset = editing.getErrors().length * validationErrorLabelHeight;
|
56193
|
+
}
|
56162
56194
|
const table = useTable$1(extendedProps, ref, RENDERERS, meta, options);
|
56163
56195
|
useTableEditingListener(table.instance, table.ref, table.renderer.scrollToIndex);
|
56164
56196
|
React__default.useEffect(() => {
|
56165
56197
|
if (table.ref.current) {
|
56166
|
-
|
56167
|
-
if (
|
56168
|
-
|
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
|
+
}
|
56169
56212
|
}
|
56170
56213
|
}
|
56171
|
-
}, [table.ref.current]);
|
56214
|
+
}, [table.ref.current, table.meta.editing.isEnabled]);
|
56172
56215
|
return table;
|
56173
56216
|
}
|
56174
56217
|
function Alert(props) {
|
@@ -56278,7 +56321,7 @@ function Editing(props) {
|
|
56278
56321
|
}
|
56279
56322
|
function CreateNewRow(props) {
|
56280
56323
|
var _a, _b;
|
56281
|
-
const { buttonRef,
|
56324
|
+
const { buttonRef, hasScrollbar, table, tableMeta } = props;
|
56282
56325
|
const { texts } = useLocalization();
|
56283
56326
|
const temporaryRows = tableMeta.editing.temporaryRows;
|
56284
56327
|
const temporaryRowId = ((_a = temporaryRows[0]) == null ? void 0 : _a[tableMeta.rowIdentityAccessor]) ?? "";
|
@@ -56301,7 +56344,8 @@ function CreateNewRow(props) {
|
|
56301
56344
|
}
|
56302
56345
|
const className = clsx("group/row !sticky z-[21]", {
|
56303
56346
|
"bottom-10": tableMeta.footer.isEnabled,
|
56304
|
-
"bottom-0": !tableMeta.footer.isEnabled
|
56347
|
+
"bottom-0": !tableMeta.footer.isEnabled,
|
56348
|
+
"border-b !border-t-[0]": !hasScrollbar
|
56305
56349
|
});
|
56306
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(
|
56307
56351
|
Button$4,
|
@@ -56322,9 +56366,8 @@ function TemporaryRows(props) {
|
|
56322
56366
|
return props.table.getBottomRows().map((row) => /* @__PURE__ */ React__default.createElement(TemporaryRow, { key: row.id, row, ...props }));
|
56323
56367
|
}
|
56324
56368
|
function TemporaryRow(props) {
|
56325
|
-
const { createRowButtonRef, row, table, tableMeta, tableRef } = props;
|
56369
|
+
const { createRowButtonRef, hasScrollbar, row, table, tableMeta, tableRef } = props;
|
56326
56370
|
const handleKeyDown = async (event) => {
|
56327
|
-
var _a;
|
56328
56371
|
const target = event.target;
|
56329
56372
|
if (isAriaDirectionKey(event) && isElementInsideExternalRelatedOverlay(target, tableRef)) {
|
56330
56373
|
return;
|
@@ -56334,12 +56377,16 @@ function TemporaryRow(props) {
|
|
56334
56377
|
if (!isElementTriggeredFromContainer(target, event.currentTarget)) {
|
56335
56378
|
const saved = await tableMeta.editing.saveChanges(table);
|
56336
56379
|
if (saved) {
|
56337
|
-
(
|
56380
|
+
requestAnimationFrame(() => {
|
56381
|
+
var _a;
|
56382
|
+
(_a = createRowButtonRef.current) == null ? void 0 : _a.focus();
|
56383
|
+
});
|
56338
56384
|
}
|
56339
56385
|
}
|
56340
56386
|
} else if (event.key === "ArrowUp") {
|
56341
56387
|
event.preventDefault();
|
56342
56388
|
event.stopPropagation();
|
56389
|
+
await tableMeta.editing.saveChanges(table);
|
56343
56390
|
const lastIndex = tableMeta.length - 1;
|
56344
56391
|
tableMeta.rowActive.setRowActiveIndex(lastIndex);
|
56345
56392
|
if (tableRef.current) {
|
@@ -56352,20 +56399,10 @@ function TemporaryRow(props) {
|
|
56352
56399
|
}
|
56353
56400
|
}
|
56354
56401
|
};
|
56355
|
-
const handleKeyDownCapture = (event) => {
|
56356
|
-
if (event.key === "ArrowLeft" && tableMeta.editing.lastFocusedCellIndex === 0) {
|
56357
|
-
event.preventDefault();
|
56358
|
-
event.stopPropagation();
|
56359
|
-
} else if (event.key === "ArrowRight" && tableMeta.editing.lastFocusedCellIndex) {
|
56360
|
-
if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {
|
56361
|
-
event.preventDefault();
|
56362
|
-
event.stopPropagation();
|
56363
|
-
}
|
56364
|
-
}
|
56365
|
-
};
|
56366
56402
|
const className = clsx("group/row border-grey-300 !sticky z-[22] print:hidden border-t-2", {
|
56367
56403
|
"bottom-[calc(5rem_+_5px)] data-[row-editing-move]:bottom-[calc(5rem_+_5px)]": tableMeta.footer.isEnabled,
|
56368
|
-
"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
|
56369
56406
|
});
|
56370
56407
|
return /* @__PURE__ */ React__default.createElement(
|
56371
56408
|
Row$2,
|
@@ -56379,7 +56416,6 @@ function TemporaryRow(props) {
|
|
56379
56416
|
table,
|
56380
56417
|
className,
|
56381
56418
|
onKeyDown: handleKeyDown,
|
56382
|
-
onKeyDownCapture: handleKeyDownCapture,
|
56383
56419
|
hideInternalColumns: true,
|
56384
56420
|
hideRowActions: !tableMeta.editing.isEditing,
|
56385
56421
|
skipPageLoading: true
|
@@ -56407,14 +56443,14 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
|
|
56407
56443
|
return rowsById[row.rowId];
|
56408
56444
|
}).length;
|
56409
56445
|
const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;
|
56410
|
-
const isScrolled = isTableScrolled(table3.ref);
|
56446
|
+
const [hasScrollbar, isScrolled] = isTableScrolled(table3.ref);
|
56411
56447
|
let createWorkflow;
|
56412
56448
|
if (hasCreateWorkflow) {
|
56413
56449
|
createWorkflow = /* @__PURE__ */ React__default.createElement(
|
56414
56450
|
CreateNewRow,
|
56415
56451
|
{
|
56416
56452
|
buttonRef: table3.meta.editing.createRowButtonRef,
|
56417
|
-
|
56453
|
+
hasScrollbar,
|
56418
56454
|
table: table3.instance,
|
56419
56455
|
tableMeta: table3.meta
|
56420
56456
|
}
|
@@ -56440,6 +56476,7 @@ const BaseTable3 = fixedForwardRef(function BaseTable32(props, ref) {
|
|
56440
56476
|
TemporaryRows,
|
56441
56477
|
{
|
56442
56478
|
createRowButtonRef: table3.meta.editing.createRowButtonRef,
|
56479
|
+
hasScrollbar,
|
56443
56480
|
table: table3.instance,
|
56444
56481
|
tableMeta: table3.meta,
|
56445
56482
|
tableRef: table3.ref
|