@jielga/tmdatagrid 2.4.0 → 2.5.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/index.d.ts +28 -2
- package/dist/index.js +80 -64
- package/dist/index.js.map +1 -1
- package/docs/columns.md +1 -0
- package/docs/editors.md +31 -0
- package/package.json +1 -1
- package/skills/appearance/SKILL.md +1 -1
- package/skills/cell-selection/SKILL.md +1 -1
- package/skills/columns/SKILL.md +2 -2
- package/skills/columns/references/columns-api.md +1 -0
- package/skills/data/SKILL.md +1 -1
- package/skills/editing/SKILL.md +15 -2
- package/skills/editing/references/editing-api.md +2 -1
- package/skills/editing/references/editors-and-validation.md +24 -0
- package/skills/filtering/SKILL.md +1 -1
- package/skills/getting-started/SKILL.md +1 -1
- package/skills/grouping/SKILL.md +1 -1
- package/skills/migrating-to-2/SKILL.md +1 -1
- package/skills/options/SKILL.md +1 -1
- package/skills/rows/SKILL.md +1 -1
- package/skills/server-side/SKILL.md +1 -1
- package/skills/testing/SKILL.md +1 -1
- package/skills/testing-components/SKILL.md +1 -1
- package/skills/testing-editing/SKILL.md +1 -1
- package/src/core/editEngine.ts +101 -5
- package/src/index.ts +2 -0
- package/src/useTMDataGrid.tsx +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -390,6 +390,24 @@ type TMDataGridEditValueMapArgs = {
|
|
|
390
390
|
* user sees, what validators judge and what commits.
|
|
391
391
|
*/
|
|
392
392
|
type TMDataGridEditValueMap = (args: TMDataGridEditValueMapArgs) => unknown;
|
|
393
|
+
/** What `meta.edit.mapCommitValue` is handed for one field of a row being committed. */
|
|
394
|
+
type TMDataGridEditCommitMapArgs = {
|
|
395
|
+
/** The value the field holds as the row is committed. */
|
|
396
|
+
value: unknown;
|
|
397
|
+
/** What the field held when editing began. */
|
|
398
|
+
previous: unknown;
|
|
399
|
+
/** The row being committed. `undefined` for a row that is being added. */
|
|
400
|
+
row: ErasedRow$1 | undefined;
|
|
401
|
+
column: ErasedColumn$1;
|
|
402
|
+
table: TMDataGridTable<TMDataGridRowData>;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* `meta.edit.mapCommitValue` - the value as the row commits, mapped.
|
|
406
|
+
*
|
|
407
|
+
* Runs once per field, not per keystroke, so the user can type what the
|
|
408
|
+
* mapped value would not allow, like a trailing space.
|
|
409
|
+
*/
|
|
410
|
+
type TMDataGridEditCommitMap = (args: TMDataGridEditCommitMapArgs) => unknown;
|
|
393
411
|
/**
|
|
394
412
|
* `meta.edit` - everything about how this column is edited, in one place,
|
|
395
413
|
* mirroring the `edit.*` engine the grid exposes at runtime.
|
|
@@ -440,6 +458,14 @@ type TMDataGridColumnEditOptions<TData extends RowData = TMDataGridRowData> = {
|
|
|
440
458
|
* {@link TMDataGridEditValueMap}.
|
|
441
459
|
*/
|
|
442
460
|
mapValue?: TMDataGridEditValueMap;
|
|
461
|
+
/**
|
|
462
|
+
* Maps the value of each field the user changed, once, as its row commits -
|
|
463
|
+
* trim a string the user was free to type spaces into. It runs before the
|
|
464
|
+
* validators of the submit, and its result is written back into the form,
|
|
465
|
+
* so the draft, `changes` and `onCommit` hold the mapped value. See
|
|
466
|
+
* {@link TMDataGridEditCommitMap}.
|
|
467
|
+
*/
|
|
468
|
+
mapCommitValue?: TMDataGridEditCommitMap;
|
|
443
469
|
};
|
|
444
470
|
/** A new row being committed - `onRowAdd`, and `saveDrafts`'s `created`. */
|
|
445
471
|
type TMDataGridRowAddArgs<TData extends RowData> = {
|
|
@@ -2488,7 +2514,7 @@ type TMDataGridEditingCallbacks<TData extends RowData> = {
|
|
|
2488
2514
|
* One TanStack Form per editing row; drafts survive scrolling because the
|
|
2489
2515
|
* forms live outside the DOM, keyed by row id. Which columns edit, and with
|
|
2490
2516
|
* what, is declared per column under `meta.edit`: `meta.type` picks the
|
|
2491
|
-
* built-in editor, and `enabled`, `field`, `editor`, `validate` and `
|
|
2517
|
+
* built-in editor, and `enabled`, `field`, `editor`, `validate`, `mapValue` and `mapCommitValue`
|
|
2492
2518
|
* override the rest.
|
|
2493
2519
|
*/
|
|
2494
2520
|
type TMDataGridEditingOptions<TData extends RowData> = TMDataGridEditingCallbacks<TData> & {
|
|
@@ -4294,4 +4320,4 @@ declare function getSelectableRowIds<TData extends RowData>(row: Row<TMDataGridF
|
|
|
4294
4320
|
*/
|
|
4295
4321
|
declare function resolveRowSelectionClick<TData extends RowData>({ rows, rowId, anchorRowId, modifiers, selection, canReplaceSelection }: ResolveRowSelectionClickArgs<TData>): ResolvedRowSelection;
|
|
4296
4322
|
//#endregion
|
|
4297
|
-
export { type BuildExportDataArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, type ExportGridArgs, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, type ResolveRangeBoundsArgs, type ResolveRowSelectionClickArgs, type ResolvedRowSelection, SELECT_COLUMN_ID, SETTINGS_STATE_SLICES, SIZE_CONTROL_SIZE, SIZE_ROW_HEIGHT, TMDATAGRID_LABELS_EN, TMDATAGRID_LABELS_SV, TMDataGrid, type TMDataGridAddRowsOptions, type TMDataGridAddRowsResult, type TMDataGridAggregationName, type TMDataGridApi, TMDataGridBooleanEditor, type TMDataGridCapabilities, type TMDataGridCellEventArgs, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridClipboardTextOptions, type TMDataGridColSpanArgs, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilter, type TMDataGridColumnFilterOptions, type TMDataGridColumnHelper, type TMDataGridColumnInfo, type TMDataGridColumnInfoOf, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnSearchable, type TMDataGridColumnType, type TMDataGridColumnsPanelProps, type TMDataGridCommitAllResult, type TMDataGridContextValue, type TMDataGridCsvFormatOptions, type TMDataGridDataSlice, TMDataGridDateEditor, type TMDataGridDateInput, type TMDataGridDetailsArgs, type TMDataGridDetailsRenderer, TMDataGridDraftActions, type TMDataGridDraftActionsActions, type TMDataGridDraftActionsControls, type TMDataGridDraftActionsProps, type TMDataGridDraftActionsSlotArgs, type TMDataGridDraftActionsState, type TMDataGridDropSide, type TMDataGridEditApi, type TMDataGridEditChange, type TMDataGridEditCommitArgs, type TMDataGridEditField, type TMDataGridEditMode, type TMDataGridEditRowProjection, type TMDataGridEditRowSnapshot, type TMDataGridEditState, type TMDataGridEditValueMap, type TMDataGridEditValueMapArgs, type TMDataGridEditingOptions, type TMDataGridEditorArgs, type TMDataGridEditorComponent, type TMDataGridExpandAllArgs, type TMDataGridExpandTarget, type TMDataGridExportApi, type TMDataGridExportColumns, type TMDataGridExportData, type TMDataGridExportFormat, type TMDataGridExportOptions, type TMDataGridExportPickerRequest, type TMDataGridExportRows, type TMDataGridExportSettings, type TMDataGridExportValueGetter, type TMDataGridExportWriteOptions, type TMDataGridFeatureFlags, type TMDataGridFeatures, type TMDataGridFieldValidate, type TMDataGridFilterControlArgs, type TMDataGridFilterControlComponent, type TMDataGridFilterControlLayout, type TMDataGridFilterFn, type TMDataGridFilterOperator, type TMDataGridFilterPanelLayout, type TMDataGridFilterPanelProps, TMDataGridFilterPills, type TMDataGridFilterPillsProps, type TMDataGridFilterSidebarSide, type TMDataGridFilterSurface, type TMDataGridFilterValue, TMDataGridFilterValueInput, type TMDataGridFilterValueShape, type TMDataGridFiltersOptions, type TMDataGridFiltersSettings, type TMDataGridFooterProps, type TMDataGridJsonFormatOptions, type TMDataGridLabels, type TMDataGridLabelsOverride, type TMDataGridMenuColumnsProps, type TMDataGridMenuExportProps, type TMDataGridMenuProps, TMDataGridMultiSelectEditor, TMDataGridNumberEditor, type TMDataGridOption, type TMDataGridOptionsArgs, type TMDataGridOptionsSource, type TMDataGridPaginationActions, type TMDataGridPaginationApi, type TMDataGridPaginationControls, type TMDataGridPaginationSlotArgs, type TMDataGridPaginationState, type TMDataGridPersistKey, type TMDataGridPersistence, type TMDataGridProps, type TMDataGridQuickSearchMode, type TMDataGridRangeBounds, type TMDataGridRowAddArgs, type TMDataGridRowClickModifiers, type TMDataGridRowContextMenuArgs, type TMDataGridRowContextMenuRenderer, type TMDataGridRowData, type TMDataGridRowDeleteArgs, type TMDataGridRowEditForm, type TMDataGridRowStyle, type TMDataGridRowValidators, type TMDataGridSaveDraftsArgs, type TMDataGridSaveDraftsResponse, type TMDataGridSaveDraftsResult, type TMDataGridSaveOutcomes, type TMDataGridScrollAlign, type TMDataGridScrollToRowArgs, TMDataGridSearch, type TMDataGridSearchProps, TMDataGridSelectEditor, type TMDataGridSelectionMode, type TMDataGridSettingsSlice, type TMDataGridSize, type TMDataGridStorageMode, TMDataGridStringEditor, type TMDataGridTable, type TMDataGridTableMeta, type TMDataGridTableProps, type TMDataGridTableValidateArgs, type TMDataGridTableValidators, type TMDataGridToolbarProps, type TMDataGridTsvFormatOptions, type TMDataGridTypedColumn, type TMDataGridUiActions, type TMDataGridUiState, type TMDataGridUiStore, type TMDataGridUrlFiltersInput, type TMDataGridUrlInput, type TMDataGridUrlPayload, type TMDataGridUrlSearchStorage, type TMDataGridUrlSortableId, type TMDataGridUrlState, type TMDataGridUrlStorage, type UseTMDataGridOptions, activeColumnFilters, aggregateColumn, areAllRowsExpanded, autosizeColumn, buildExportData, clearedValueForType, countSelectedExportRows, createTMDataGridColumnHelper, createTMDataGridUrlState, csvExcelFormat, csvFormat, downloadFile, emptyValueForOperator, exportGrid, filterValueShape, formatExportValue, formatFilterLabel, formatGroupValue, fuzzyGlobalFilterFn, getColumnCapabilities, getColumnDefaultOperator, getColumnLabel, getColumnOperators, getColumnRegion, getColumnType, getDisplayedRows, getEditFieldName, getExportableColumns, getGridCapabilities, getGroupDataRows, getOperatorsForType, getSelectableRowIds, getStepTargetColumn, getTMDataGridPaginationApi, guardFormula, hasPendingEdits, isControlColumn, isFilterActive, isGeneratedColumn, isPagingActive, jsonFormat, keepGeneratedColumnsOutermost, matchesFilter, mergeLabels, moveColumn, moveColumnByStep, normalizeFieldValidate, openColumnFilter, operatorNeedsValue, operatorTakesArrayValue, operatorTakesRangeValue, optionsToComboboxData, readFeatureFlags, resolveColumnOptions, resolveExpandAll, resolveExportOptions, resolveRangeBounds, resolveRowSelectionClick, tmDataGridFilterFn, toClipboardText, tsvFormat, useTMDataGrid, useTMDataGridContext, useTMDataGridExport, writeClipboardText, writeExportFile };
|
|
4323
|
+
export { type BuildExportDataArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, type ExportGridArgs, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, type ResolveRangeBoundsArgs, type ResolveRowSelectionClickArgs, type ResolvedRowSelection, SELECT_COLUMN_ID, SETTINGS_STATE_SLICES, SIZE_CONTROL_SIZE, SIZE_ROW_HEIGHT, TMDATAGRID_LABELS_EN, TMDATAGRID_LABELS_SV, TMDataGrid, type TMDataGridAddRowsOptions, type TMDataGridAddRowsResult, type TMDataGridAggregationName, type TMDataGridApi, TMDataGridBooleanEditor, type TMDataGridCapabilities, type TMDataGridCellEventArgs, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridClipboardTextOptions, type TMDataGridColSpanArgs, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilter, type TMDataGridColumnFilterOptions, type TMDataGridColumnHelper, type TMDataGridColumnInfo, type TMDataGridColumnInfoOf, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnSearchable, type TMDataGridColumnType, type TMDataGridColumnsPanelProps, type TMDataGridCommitAllResult, type TMDataGridContextValue, type TMDataGridCsvFormatOptions, type TMDataGridDataSlice, TMDataGridDateEditor, type TMDataGridDateInput, type TMDataGridDetailsArgs, type TMDataGridDetailsRenderer, TMDataGridDraftActions, type TMDataGridDraftActionsActions, type TMDataGridDraftActionsControls, type TMDataGridDraftActionsProps, type TMDataGridDraftActionsSlotArgs, type TMDataGridDraftActionsState, type TMDataGridDropSide, type TMDataGridEditApi, type TMDataGridEditChange, type TMDataGridEditCommitArgs, type TMDataGridEditCommitMap, type TMDataGridEditCommitMapArgs, type TMDataGridEditField, type TMDataGridEditMode, type TMDataGridEditRowProjection, type TMDataGridEditRowSnapshot, type TMDataGridEditState, type TMDataGridEditValueMap, type TMDataGridEditValueMapArgs, type TMDataGridEditingOptions, type TMDataGridEditorArgs, type TMDataGridEditorComponent, type TMDataGridExpandAllArgs, type TMDataGridExpandTarget, type TMDataGridExportApi, type TMDataGridExportColumns, type TMDataGridExportData, type TMDataGridExportFormat, type TMDataGridExportOptions, type TMDataGridExportPickerRequest, type TMDataGridExportRows, type TMDataGridExportSettings, type TMDataGridExportValueGetter, type TMDataGridExportWriteOptions, type TMDataGridFeatureFlags, type TMDataGridFeatures, type TMDataGridFieldValidate, type TMDataGridFilterControlArgs, type TMDataGridFilterControlComponent, type TMDataGridFilterControlLayout, type TMDataGridFilterFn, type TMDataGridFilterOperator, type TMDataGridFilterPanelLayout, type TMDataGridFilterPanelProps, TMDataGridFilterPills, type TMDataGridFilterPillsProps, type TMDataGridFilterSidebarSide, type TMDataGridFilterSurface, type TMDataGridFilterValue, TMDataGridFilterValueInput, type TMDataGridFilterValueShape, type TMDataGridFiltersOptions, type TMDataGridFiltersSettings, type TMDataGridFooterProps, type TMDataGridJsonFormatOptions, type TMDataGridLabels, type TMDataGridLabelsOverride, type TMDataGridMenuColumnsProps, type TMDataGridMenuExportProps, type TMDataGridMenuProps, TMDataGridMultiSelectEditor, TMDataGridNumberEditor, type TMDataGridOption, type TMDataGridOptionsArgs, type TMDataGridOptionsSource, type TMDataGridPaginationActions, type TMDataGridPaginationApi, type TMDataGridPaginationControls, type TMDataGridPaginationSlotArgs, type TMDataGridPaginationState, type TMDataGridPersistKey, type TMDataGridPersistence, type TMDataGridProps, type TMDataGridQuickSearchMode, type TMDataGridRangeBounds, type TMDataGridRowAddArgs, type TMDataGridRowClickModifiers, type TMDataGridRowContextMenuArgs, type TMDataGridRowContextMenuRenderer, type TMDataGridRowData, type TMDataGridRowDeleteArgs, type TMDataGridRowEditForm, type TMDataGridRowStyle, type TMDataGridRowValidators, type TMDataGridSaveDraftsArgs, type TMDataGridSaveDraftsResponse, type TMDataGridSaveDraftsResult, type TMDataGridSaveOutcomes, type TMDataGridScrollAlign, type TMDataGridScrollToRowArgs, TMDataGridSearch, type TMDataGridSearchProps, TMDataGridSelectEditor, type TMDataGridSelectionMode, type TMDataGridSettingsSlice, type TMDataGridSize, type TMDataGridStorageMode, TMDataGridStringEditor, type TMDataGridTable, type TMDataGridTableMeta, type TMDataGridTableProps, type TMDataGridTableValidateArgs, type TMDataGridTableValidators, type TMDataGridToolbarProps, type TMDataGridTsvFormatOptions, type TMDataGridTypedColumn, type TMDataGridUiActions, type TMDataGridUiState, type TMDataGridUiStore, type TMDataGridUrlFiltersInput, type TMDataGridUrlInput, type TMDataGridUrlPayload, type TMDataGridUrlSearchStorage, type TMDataGridUrlSortableId, type TMDataGridUrlState, type TMDataGridUrlStorage, type UseTMDataGridOptions, activeColumnFilters, aggregateColumn, areAllRowsExpanded, autosizeColumn, buildExportData, clearedValueForType, countSelectedExportRows, createTMDataGridColumnHelper, createTMDataGridUrlState, csvExcelFormat, csvFormat, downloadFile, emptyValueForOperator, exportGrid, filterValueShape, formatExportValue, formatFilterLabel, formatGroupValue, fuzzyGlobalFilterFn, getColumnCapabilities, getColumnDefaultOperator, getColumnLabel, getColumnOperators, getColumnRegion, getColumnType, getDisplayedRows, getEditFieldName, getExportableColumns, getGridCapabilities, getGroupDataRows, getOperatorsForType, getSelectableRowIds, getStepTargetColumn, getTMDataGridPaginationApi, guardFormula, hasPendingEdits, isControlColumn, isFilterActive, isGeneratedColumn, isPagingActive, jsonFormat, keepGeneratedColumnsOutermost, matchesFilter, mergeLabels, moveColumn, moveColumnByStep, normalizeFieldValidate, openColumnFilter, operatorNeedsValue, operatorTakesArrayValue, operatorTakesRangeValue, optionsToComboboxData, readFeatureFlags, resolveColumnOptions, resolveExpandAll, resolveExportOptions, resolveRangeBounds, resolveRowSelectionClick, tmDataGridFilterFn, toClipboardText, tsvFormat, useTMDataGrid, useTMDataGridContext, useTMDataGridExport, writeClipboardText, writeExportFile };
|
package/dist/index.js
CHANGED
|
@@ -774,25 +774,41 @@ function rn(e) {
|
|
|
774
774
|
message: i
|
|
775
775
|
}];
|
|
776
776
|
});
|
|
777
|
-
}, V =
|
|
778
|
-
let i =
|
|
779
|
-
|
|
777
|
+
}, V = (t, n, r) => {
|
|
778
|
+
let { table: i } = e(), a = t.form.state.values, o = t.isNew ? null : new Set(m(t.original, a).map((e) => e.columnId)), c = t.isNew ? void 0 : z(n);
|
|
779
|
+
for (let e of s()) {
|
|
780
|
+
let n = e.columnDef.meta?.edit?.mapCommitValue;
|
|
781
|
+
if (n === void 0 || o !== null && !o.has(e.id)) continue;
|
|
782
|
+
let a = qt(e);
|
|
783
|
+
if (a === null || r.has(a)) continue;
|
|
784
|
+
let s = X(t.form.state.values, a), l = n({
|
|
785
|
+
value: s,
|
|
786
|
+
previous: X(t.original, a),
|
|
787
|
+
row: c,
|
|
788
|
+
column: e,
|
|
789
|
+
table: i
|
|
790
|
+
});
|
|
791
|
+
Zt(s, l) || t.form.setFieldValue(a, l, { dontValidate: !0 });
|
|
792
|
+
}
|
|
793
|
+
}, H = (e) => te(e, /* @__PURE__ */ new Set()), te = async (t, i) => {
|
|
794
|
+
let a = n.get(t);
|
|
795
|
+
return a === void 0 ? !0 : a.pendingCommit === null ? (i !== "all" && V(a, t, i), !a.isNew && m(a.original, a.form.state.values).length === 0 ? (P(t), !0) : (Xt(a.form), a.lastSubmitOk = !1, a.submitErrors = [], a.parkOnly = e().draft, a.pendingCommit = (async () => {
|
|
780
796
|
try {
|
|
781
|
-
await
|
|
797
|
+
await a.form.handleSubmit();
|
|
782
798
|
} finally {
|
|
783
|
-
|
|
799
|
+
a.pendingCommit = null;
|
|
784
800
|
}
|
|
785
|
-
return n.get(t) ===
|
|
786
|
-
let e =
|
|
801
|
+
return n.get(t) === a ? a.lastSubmitOk ? a.parkOnly ? (D(() => {
|
|
802
|
+
let e = a.form.state.values;
|
|
787
803
|
r.set(t, {
|
|
788
|
-
original:
|
|
804
|
+
original: a.original,
|
|
789
805
|
values: e,
|
|
790
|
-
dirtyFields: m(
|
|
791
|
-
isNew:
|
|
792
|
-
}),
|
|
793
|
-
}), !0) : (P(t), !0) : (
|
|
794
|
-
})(),
|
|
795
|
-
},
|
|
806
|
+
dirtyFields: m(a.original, e).map((e) => e.field),
|
|
807
|
+
isNew: a.isNew
|
|
808
|
+
}), a.isNew ? j(t, !0) : M(t, !0), _.active?.rowId === t && k(null), N(t);
|
|
809
|
+
}), !0) : (P(t), !0) : (a.submitErrors = B(a), O(t), !1) : !0;
|
|
810
|
+
})(), a.pendingCommit)) : a.pendingCommit;
|
|
811
|
+
}, U = (t, i) => {
|
|
796
812
|
D(() => {
|
|
797
813
|
if (n.get(t)?.isNew === !0) {
|
|
798
814
|
k({
|
|
@@ -820,48 +836,48 @@ function rn(e) {
|
|
|
820
836
|
});
|
|
821
837
|
}
|
|
822
838
|
});
|
|
823
|
-
},
|
|
839
|
+
}, W = ({ rowId: t, columnId: r }) => {
|
|
824
840
|
let { editMode: i } = e();
|
|
825
841
|
if (i === "cell") {
|
|
826
842
|
let e = [...n.keys()].find((e) => e !== t && n.get(e)?.isNew !== !0);
|
|
827
843
|
if (e !== void 0) {
|
|
828
|
-
|
|
829
|
-
e &&
|
|
844
|
+
H(e).then((e) => {
|
|
845
|
+
e && U(t, r);
|
|
830
846
|
});
|
|
831
847
|
return;
|
|
832
848
|
}
|
|
833
849
|
}
|
|
834
|
-
|
|
835
|
-
},
|
|
850
|
+
U(t, r);
|
|
851
|
+
}, ne = (e) => {
|
|
836
852
|
P(e);
|
|
837
|
-
},
|
|
853
|
+
}, re = () => {
|
|
838
854
|
k(null);
|
|
839
|
-
},
|
|
855
|
+
}, ie = () => {
|
|
840
856
|
D(() => {
|
|
841
857
|
for (let e of [..._.openRowIds]) P(e);
|
|
842
858
|
r.clear(), _.active = null, _.committedRowIds.clear(), _.committedValues.clear(), _.deletedRowIds.clear(), v.add("active"), v.add("committedRowIds"), v.add("committedValues"), v.add("deletedRowIds");
|
|
843
859
|
});
|
|
844
|
-
},
|
|
860
|
+
}, ae = (e) => {
|
|
845
861
|
i += 1;
|
|
846
862
|
let t = `${a}${i}`;
|
|
847
|
-
return F(t,
|
|
848
|
-
},
|
|
863
|
+
return F(t, se(e), !0), _.newRows.set(t, !1), v.add("newRows"), t;
|
|
864
|
+
}, oe = (e) => D(() => ae(e)), se = (t) => {
|
|
849
865
|
let { newRowDefaults: n } = e();
|
|
850
866
|
return {
|
|
851
867
|
...typeof n == "function" ? n() : n ?? {},
|
|
852
868
|
...t
|
|
853
869
|
};
|
|
854
|
-
},
|
|
855
|
-
let r = t.map((e) =>
|
|
870
|
+
}, G = async (t, n) => E(async () => {
|
|
871
|
+
let r = t.map((e) => ae(e));
|
|
856
872
|
if (n?.commit !== !0) return {
|
|
857
873
|
ok: r.length === 0,
|
|
858
874
|
committed: [],
|
|
859
875
|
open: r
|
|
860
876
|
};
|
|
861
|
-
let i = e().draft ? await Promise.all(r.map((e) =>
|
|
862
|
-
if (!e().draft) for (let e of r) i.push(await
|
|
877
|
+
let i = e().draft ? await Promise.all(r.map((e) => te(e, "all"))) : [];
|
|
878
|
+
if (!e().draft) for (let e of r) i.push(await te(e, "all"));
|
|
863
879
|
return Yt(r, i);
|
|
864
|
-
}),
|
|
880
|
+
}), K = (t) => {
|
|
865
881
|
if (n.get(t)?.isNew === !0 || r.get(t)?.isNew === !0) {
|
|
866
882
|
P(t);
|
|
867
883
|
return;
|
|
@@ -879,28 +895,28 @@ function rn(e) {
|
|
|
879
895
|
rowId: t,
|
|
880
896
|
row: o
|
|
881
897
|
});
|
|
882
|
-
},
|
|
898
|
+
}, ce = (e) => {
|
|
883
899
|
D(() => {
|
|
884
|
-
for (let t of e)
|
|
900
|
+
for (let t of e) K(t);
|
|
885
901
|
});
|
|
886
|
-
},
|
|
902
|
+
}, le = (e) => {
|
|
887
903
|
_.deletedRowIds.delete(e) && T("deletedRowIds");
|
|
888
|
-
},
|
|
904
|
+
}, ue = () => {
|
|
889
905
|
let t = e();
|
|
890
906
|
return t.draft ? t.onRowDelete !== void 0 || t.onSaveDrafts !== void 0 : t.onRowDelete !== void 0;
|
|
891
|
-
},
|
|
907
|
+
}, de = () => [..._.openRowIds].filter((e) => r.has(e)), q = async () => {
|
|
892
908
|
let e = [...n.keys()];
|
|
893
|
-
return Yt(e, await E(() => Promise.all(e.map((e) =>
|
|
894
|
-
},
|
|
895
|
-
|
|
896
|
-
})),
|
|
909
|
+
return Yt(e, await E(() => Promise.all(e.map((e) => H(e)))));
|
|
910
|
+
}, fe = null, J = () => (fe === null && (fe = pe().finally(() => {
|
|
911
|
+
fe = null, _.isSaving && (_.isSaving = !1, T("isSaving"));
|
|
912
|
+
})), fe), Y = (t, n) => ({
|
|
897
913
|
rowId: t,
|
|
898
914
|
value: n.values,
|
|
899
915
|
original: n.original,
|
|
900
916
|
changes: m(n.original, n.values),
|
|
901
917
|
source: e().editMode
|
|
902
|
-
}),
|
|
903
|
-
let t = [..._.deletedRowIds], n =
|
|
918
|
+
}), pe = async () => {
|
|
919
|
+
let t = [..._.deletedRowIds], n = de().filter((e) => !_.deletedRowIds.has(e)), i = [], a = [], o = [], s = () => ({
|
|
904
920
|
ok: a.length === 0 && o.length === 0,
|
|
905
921
|
saved: i,
|
|
906
922
|
kept: a,
|
|
@@ -919,7 +935,7 @@ function rn(e) {
|
|
|
919
935
|
n.isNew ? await e().onRowAdd?.({
|
|
920
936
|
tempId: t,
|
|
921
937
|
value: n.values
|
|
922
|
-
}) : await e().onEditCommit?.(
|
|
938
|
+
}) : await e().onEditCommit?.(Y(t, n));
|
|
923
939
|
} catch (e) {
|
|
924
940
|
return I(t, e instanceof Error ? e.message : String(e)), "reopened";
|
|
925
941
|
}
|
|
@@ -966,7 +982,7 @@ function rn(e) {
|
|
|
966
982
|
}), i.isNew ? f.push({
|
|
967
983
|
tempId: t,
|
|
968
984
|
value: i.values
|
|
969
|
-
}) : l.push(
|
|
985
|
+
}) : l.push(Y(t, i));
|
|
970
986
|
}
|
|
971
987
|
});
|
|
972
988
|
});
|
|
@@ -997,19 +1013,19 @@ function rn(e) {
|
|
|
997
1013
|
});
|
|
998
1014
|
}
|
|
999
1015
|
return s();
|
|
1000
|
-
},
|
|
1016
|
+
}, he = async (e, t) => {
|
|
1001
1017
|
let i = z(e);
|
|
1002
1018
|
if (i === void 0 || _.deletedRowIds.has(e)) return !1;
|
|
1003
1019
|
if (t.length === 0) return !0;
|
|
1004
1020
|
let a = (n) => {
|
|
1005
1021
|
for (let { field: e, value: r } of t) n.form.setFieldValue(e, r);
|
|
1006
|
-
return
|
|
1022
|
+
return te(e, new Set(t.map(({ field: e }) => e)));
|
|
1007
1023
|
}, o = n.get(e);
|
|
1008
1024
|
return o === void 0 ? r.has(e) ? E(async () => {
|
|
1009
1025
|
let t = ee(e);
|
|
1010
1026
|
return t !== void 0 && a(t);
|
|
1011
1027
|
}) : a(F(e, i.original, !1)) : a(o);
|
|
1012
|
-
},
|
|
1028
|
+
}, _e = (t, n) => {
|
|
1013
1029
|
let r = z(t), i = e().table.getColumn(n);
|
|
1014
1030
|
return r === void 0 || i === void 0 || !R(r, i) ? null : qt(i);
|
|
1015
1031
|
};
|
|
@@ -1050,23 +1066,23 @@ function rn(e) {
|
|
|
1050
1066
|
canEditCell: R,
|
|
1051
1067
|
canEditRow: L,
|
|
1052
1068
|
isColumnEditable: o,
|
|
1053
|
-
begin:
|
|
1054
|
-
commit:
|
|
1055
|
-
cancel:
|
|
1056
|
-
deactivate:
|
|
1057
|
-
cancelAll:
|
|
1058
|
-
commitAll:
|
|
1059
|
-
saveDrafts:
|
|
1069
|
+
begin: W,
|
|
1070
|
+
commit: H,
|
|
1071
|
+
cancel: ne,
|
|
1072
|
+
deactivate: re,
|
|
1073
|
+
cancelAll: ie,
|
|
1074
|
+
commitAll: q,
|
|
1075
|
+
saveDrafts: J,
|
|
1060
1076
|
clearCell: async (t, n) => {
|
|
1061
|
-
let r = e().table.getColumn(n), i =
|
|
1062
|
-
return i === null || r === void 0 ? !1 :
|
|
1077
|
+
let r = e().table.getColumn(n), i = _e(t, n);
|
|
1078
|
+
return i === null || r === void 0 ? !1 : he(t, [{
|
|
1063
1079
|
field: i,
|
|
1064
1080
|
value: Jt(r.columnDef.meta?.type ?? "string")
|
|
1065
1081
|
}]);
|
|
1066
1082
|
},
|
|
1067
1083
|
setCellValue: async (e, t, n) => {
|
|
1068
|
-
let r =
|
|
1069
|
-
return r !== null &&
|
|
1084
|
+
let r = _e(e, t);
|
|
1085
|
+
return r !== null && he(e, [{
|
|
1070
1086
|
field: r,
|
|
1071
1087
|
value: n
|
|
1072
1088
|
}]);
|
|
@@ -1074,21 +1090,21 @@ function rn(e) {
|
|
|
1074
1090
|
setRowValues: async (e, t) => {
|
|
1075
1091
|
let n = [];
|
|
1076
1092
|
for (let [r, i] of Object.entries(t)) {
|
|
1077
|
-
let t =
|
|
1093
|
+
let t = _e(e, r);
|
|
1078
1094
|
if (t === null) return !1;
|
|
1079
1095
|
n.push({
|
|
1080
1096
|
field: t,
|
|
1081
1097
|
value: i
|
|
1082
1098
|
});
|
|
1083
1099
|
}
|
|
1084
|
-
return
|
|
1100
|
+
return he(e, n);
|
|
1085
1101
|
},
|
|
1086
|
-
addRow:
|
|
1087
|
-
addRows:
|
|
1088
|
-
deleteRow:
|
|
1089
|
-
deleteRows:
|
|
1090
|
-
restoreRow:
|
|
1091
|
-
canDeleteRows:
|
|
1102
|
+
addRow: oe,
|
|
1103
|
+
addRows: G,
|
|
1104
|
+
deleteRow: K,
|
|
1105
|
+
deleteRows: ce,
|
|
1106
|
+
restoreRow: le,
|
|
1107
|
+
canDeleteRows: ue
|
|
1092
1108
|
};
|
|
1093
1109
|
}
|
|
1094
1110
|
function an(e) {
|