@vueye-table/core 3.0.0-alpha.6 → 3.0.0-alpha.7
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 +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ declare const DEFAULT_PAGE_SIZE = 10;
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/issues.d.ts
|
|
41
41
|
/** Every problem the engine can report. The union grows in minor versions. */
|
|
42
|
-
type TableIssueCode = "stream_error" | "invalid_stream_option" | "ingestion_conflict" | "invalid_ingestion" | "duplicate_row_key" | "unknown_column" | "invalid_page_size" | "unknown_row" | "read_only_cell" | "invalid_value" | "validation_failed" | "invalid_row_operation" | "invalid_expanded" | "unsafe_path" | "paste_truncated" | "invalid_paste_limit" | "invalid_virtual_option" | "invalid_virtual_size" | "invalid_virtual_viewport" | "duplicate_virtual_key" | "tree_cycle" | "tree_depth_exceeded" | "tree_orphan" | "tree_duplicate_key" | "tree_load_error" | "invalid_tree_option";
|
|
42
|
+
type TableIssueCode = "stream_error" | "invalid_stream_option" | "ingestion_conflict" | "invalid_ingestion" | "duplicate_row_key" | "unknown_column" | "invalid_page_size" | "unknown_row" | "read_only_cell" | "invalid_value" | "validation_failed" | "stale_draft" | "invalid_row_operation" | "invalid_expanded" | "unsafe_path" | "paste_truncated" | "invalid_paste_limit" | "invalid_virtual_option" | "invalid_virtual_size" | "invalid_virtual_viewport" | "duplicate_virtual_key" | "tree_cycle" | "tree_depth_exceeded" | "tree_orphan" | "tree_duplicate_key" | "tree_load_error" | "invalid_tree_option";
|
|
43
43
|
/**
|
|
44
44
|
* A problem the engine recovered from. Invalid input is never dropped silently: the engine falls
|
|
45
45
|
* back to something safe and reports what it did here.
|
|
@@ -625,6 +625,10 @@ interface CellInputEdit {
|
|
|
625
625
|
readonly input: string;
|
|
626
626
|
}
|
|
627
627
|
type CellEdit = CellValueEdit | CellInputEdit;
|
|
628
|
+
/** Optional identity checks for a batch prepared from an earlier row snapshot. */
|
|
629
|
+
interface EditOptions<TRow> {
|
|
630
|
+
readonly expectedRows?: ReadonlyMap<RowKey, TRow> | undefined;
|
|
631
|
+
}
|
|
628
632
|
interface CellChange<TRow> {
|
|
629
633
|
readonly rowKey: RowKey;
|
|
630
634
|
readonly column: string;
|
|
@@ -644,6 +648,8 @@ interface EditResult<TRow> {
|
|
|
644
648
|
readonly issues: readonly TableIssue[];
|
|
645
649
|
readonly rowChanges: readonly RowChange<TRow>[];
|
|
646
650
|
readonly pendingCells: readonly PendingCell[];
|
|
651
|
+
/** Present on pending batches; resolves to their final outcome, including superseded cells. */
|
|
652
|
+
readonly completion?: Promise<EditResult<TRow>> | undefined;
|
|
647
653
|
}
|
|
648
654
|
interface CopyOptions {
|
|
649
655
|
/** Prefix formula-like text with an apostrophe. Defaults to false for clipboard copies. */
|
|
@@ -721,7 +727,7 @@ interface DataTable<TRow> {
|
|
|
721
727
|
collapseAll(): void;
|
|
722
728
|
toggleColumn(columnId: string, visible?: boolean): void;
|
|
723
729
|
moveColumn(columnId: string, toIndex: number): void;
|
|
724
|
-
edit(edits: CellEdit | readonly CellEdit[]): EditResult<TRow>;
|
|
730
|
+
edit(edits: CellEdit | readonly CellEdit[], options?: EditOptions<TRow>): EditResult<TRow>;
|
|
725
731
|
undo(): boolean;
|
|
726
732
|
redo(): boolean;
|
|
727
733
|
/** The text of a range of shown cells, tab-separated like a spreadsheet clipboard. */
|
|
@@ -769,5 +775,5 @@ interface PendingChanges<TRow> {
|
|
|
769
775
|
*/
|
|
770
776
|
declare function inferColumns<TRow>(rows: readonly TRow[], sample?: number): readonly ColumnDef<TRow>[];
|
|
771
777
|
//#endregion
|
|
772
|
-
export { type AnyColumnDef, type CellChange, type CellEdit, type CellInputEdit, type CellPosition, type CellRange, type CellValueEdit, type ChildStatus, type ColumnAlign, type ColumnDef, type ColumnOptions, type ColumnType, type ComputedColumnDef, type CopyOptions, DEFAULT_PAGE_SIZE, type DataIngestionResult, type DataTable, type DeepKeys, type EditResult, type EditStatus, type EditorSpec, type ExpandMode, type ExpandedState, type ExportOptions, type GridBounds, type GridCommand, type GridDirection, type GridKey, type GridSelection, type InsertPosition, type LoadState, type MoveOptions, type PageItem, type PaginationState, type ParseResult, type PasteLimit, type PathColumnDef, type PathValue, type PendingCell, type PendingChanges, type RangeFilter, type RowChange, type RowItemKind, type RowKey, type SelectScope, type SelectionCoverage, type SelectionMode, type SortDirection, type SortInfo, type SortRule, type StreamOptions, type StreamResult, type StreamSignal, type TableColumn, type TableIssue, type TableIssueCode, type TableOptions, type TableRenderItem, type TableRow, type TableSnapshot, type TableState, type TableStatePatch, type TreeFilter, type TreeLoadController, type TreeLoadSignal, type TreeOptions, type TreePagination, type UndoStack, type UpdatedRow, type ValidationResult, type Validator, type VirtualAlign, type VirtualItem, type VirtualWindow, type Virtualizer, type VirtualizerOptions, clampPage, clampPosition, columnLabel, compareValues, countPages, createTable, createUndoStack, createVirtualizer, defineColumns, filterRows, formatValue, fromA1, getPath, getRowItemKey, gridCommand, humanize, inferColumns, matchesFilter, moveSelection, paginateRows, paginationItems, parseAs, parseDelimited, rangeContains, resolveColumn, selectCell, selectionRange, setPath, sortRows, toA1, toDelimited, typeOf };
|
|
778
|
+
export { type AnyColumnDef, type CellChange, type CellEdit, type CellInputEdit, type CellPosition, type CellRange, type CellValueEdit, type ChildStatus, type ColumnAlign, type ColumnDef, type ColumnOptions, type ColumnType, type ComputedColumnDef, type CopyOptions, DEFAULT_PAGE_SIZE, type DataIngestionResult, type DataTable, type DeepKeys, type EditOptions, type EditResult, type EditStatus, type EditorSpec, type ExpandMode, type ExpandedState, type ExportOptions, type GridBounds, type GridCommand, type GridDirection, type GridKey, type GridSelection, type InsertPosition, type LoadState, type MoveOptions, type PageItem, type PaginationState, type ParseResult, type PasteLimit, type PathColumnDef, type PathValue, type PendingCell, type PendingChanges, type RangeFilter, type RowChange, type RowItemKind, type RowKey, type SelectScope, type SelectionCoverage, type SelectionMode, type SortDirection, type SortInfo, type SortRule, type StreamOptions, type StreamResult, type StreamSignal, type TableColumn, type TableIssue, type TableIssueCode, type TableOptions, type TableRenderItem, type TableRow, type TableSnapshot, type TableState, type TableStatePatch, type TreeFilter, type TreeLoadController, type TreeLoadSignal, type TreeOptions, type TreePagination, type UndoStack, type UpdatedRow, type ValidationResult, type Validator, type VirtualAlign, type VirtualItem, type VirtualWindow, type Virtualizer, type VirtualizerOptions, clampPage, clampPosition, columnLabel, compareValues, countPages, createTable, createUndoStack, createVirtualizer, defineColumns, filterRows, formatValue, fromA1, getPath, getRowItemKey, gridCommand, humanize, inferColumns, matchesFilter, moveSelection, paginateRows, paginationItems, parseAs, parseDelimited, rangeContains, resolveColumn, selectCell, selectionRange, setPath, sortRows, toA1, toDelimited, typeOf };
|
|
773
779
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state.ts","../src/issues.ts","../src/path.ts","../src/validation.ts","../src/column.ts","../src/delimited.ts","../src/grid.ts","../src/undo-stack.ts","../src/virtualizer.ts","../src/humanize.ts","../src/tree.ts","../src/row.ts","../src/pipeline.ts","../src/stream.ts","../src/table.ts","../src/pending-changes.ts","../src/infer.ts"],"mappings":";;KAGY;KACA,yBAAyB;KAEzB;;UAGK;WACN;WACA,WAAW;;;UAIL;WACN;WACA;;;;;;;;UASM;WACN,kBAAkB;;WAElB;;WAEA,SAAS,SAAS;WAClB,YAAY;WACZ,oBAAoB;;WAEpB,UAAU;WACV;;WAEA;;;KAIC,8BACA,WAAW,cAAc,WAAW;cAGnC;;;;KC3CD;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state.ts","../src/issues.ts","../src/path.ts","../src/validation.ts","../src/column.ts","../src/delimited.ts","../src/grid.ts","../src/undo-stack.ts","../src/virtualizer.ts","../src/humanize.ts","../src/tree.ts","../src/row.ts","../src/pipeline.ts","../src/stream.ts","../src/table.ts","../src/pending-changes.ts","../src/infer.ts"],"mappings":";;KAGY;KACA,yBAAyB;KAEzB;;UAGK;WACN;WACA,WAAW;;;UAIL;WACN;WACA;;;;;;;;UASM;WACN,kBAAkB;;WAElB;;WAEA,SAAS,SAAS;WAClB,YAAY;WACZ,oBAAoB;;WAEpB,UAAU;WACV;;WAEA;;;KAIC,8BACA,WAAW,cAAc,WAAW;cAGnC;;;;KC3CD;;;;;UAiCK;WACN,MAAM;WACN;WACA;WACA,SAAS;WACT;;;;KChCN,wEAQD,iCAEK;KAEJ;;KAGO,SAAS,GAAG,8BAA8B,kCAElD,UAAU,kBAGL,WAAW,aACR,KACC,YAAY,EAAE,YAAY,kBAEpB,KAAK,SAAS,YAAY,EAAE,KAAK,MAAM,qBAC5C;;KAGF,UAAU,GAAG,wBAAwB,uBAAuB,eAAe,UACnF,oBAAoB,IAClB,UAAU,YAAY,EAAE,SAAS,4BAA4B,EAAE,0CAEjE,oBAAoB,IAClB,EAAE;;iBAiBQ,QAAQ,iBAAiB;;;;;;iBAmBzB,QAAQ,GACtB,QAAQ,GACR,cACA,gBACA,WAAW,SAAS,sBACnB;;;KChFS;WAA8C;WAA0B;;KACxE,UAAU,QAAQ,SAC5B,OAAO,QACP,KAAK,SACF,mBAAmB,QAAQ;UACf;WACN;WACA;WACA;WACA;WACA;WACA;;UAEM;WACN,QAAQ;WACR;WACA;;;;KCfC;;KAGA;;UAGK;WACN,wBAAwB;WACxB,wBAAwB;;;UAIlB,cAAc,MAAM;;WAE1B;WACA,QAAQ;;WAER;WACA;;WAEA;;WAEA;;WAEA;;;;;WAKA,OAAO;;WAEP,uBAAuB,KAAK;;WAE5B,YAAY,MAAM,QAAQ,OAAO;;WAEjC,WAAW,OAAO,QAAQ,sBAAsB,KAAK;;WAErD,WAAW,OAAO,QAAQ,KAA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Y;;EAEZ,UAAU,WAAW,UAAU,cAAc;;EAG7C,SAAS,OAAO;;EAEhB,QAAQ,eAAe;EACvB,WAAW,kBAAkB,UAAU;;EAEvC,YAAY;;EAGZ,WAAW,kBAAkB;aAAqB;;;EAElD,KACE,kBACA,WAAW,2BACX;aAAqB;;EAEvB;EACA,OAAO;;EAEP,OAAO,kBAAkB;EACzB;EAEA,SAAS;EACT;EACA;;EAEA,YAAY;EAEZ,OAAO,eAAe;EACtB,SAAS,eAAe;EACxB,UAAU,KAAK,QAAQ;;EAEvB,UAAU,QAAQ;EAClB;;EAEA,4BAA4B,SAAS;EAErC,eAAe,KAAK,QAAQ;EAC5B;EACA;EAEA,aAAa,kBAAkB;EAC/B,WAAW,kBAAkB;EAE7B,KAAK,OAAO,oBAAoB,YAAY,UAAU,YAAY,QAAQ,WAAW;EACrF;EACA;;EAEA,KAAK,OAAO,WAAW,UAAU;;EAEjC,MAAM,QAAQ,cAAc,eAAe,WAAW;;EAEtD,MAAM,OAAO,YAAY,WAAW;EACpC,WAAW,UAAU;;EAGrB;;EAEA;;;iBA6Ec,YAAY,MAAM,gBAAgB,iBAAiB,gBACjE,SAAS,aAAa,MAAM,WAC3B,UAAU;;;UClZI;WACN,SAAS;WACT,SAAS;;UAEH,UAAU;WAChB;WACA,QAAQ;WACR,KAAK;WACL,UAAU;;UAEJ,WAAW;WACjB,QAAQ;WACR,KAAK;WACL,UAAU;WACV,kBAAkB,WAAW;;UAEvB,eAAe;WACrB,mBAAmB,UAAU;WAC7B,kBAAkB,WAAW;WAC7B,kBAAkB,UAAU;;;;;;;;iBCMvB,aAAa,MAAM,eAAe,QAAQ,2BAAuB,UAAU"}
|
package/dist/index.js
CHANGED
|
@@ -1070,6 +1070,7 @@ function createEditValidation(host) {
|
|
|
1070
1070
|
const pending = /* @__PURE__ */ new Map();
|
|
1071
1071
|
const problems = /* @__PURE__ */ new Map();
|
|
1072
1072
|
const current = (candidate) => tokens.get(candidate.edit.rowKey)?.get(candidate.edit.column) === candidate.token;
|
|
1073
|
+
const fresh = (candidate) => !candidate.guard || host.snapshot().getRow(candidate.edit.rowKey)?.original === candidate.guard.row;
|
|
1073
1074
|
const tokenFor = (rowKey, column) => {
|
|
1074
1075
|
const row = tokens.get(rowKey) ?? /* @__PURE__ */ new Map();
|
|
1075
1076
|
const token = {};
|
|
@@ -1123,7 +1124,7 @@ function createEditValidation(host) {
|
|
|
1123
1124
|
}
|
|
1124
1125
|
function settle(accepted, all, failures, asynchronous) {
|
|
1125
1126
|
return host.batch(() => {
|
|
1126
|
-
const live = accepted.filter(current);
|
|
1127
|
+
const live = accepted.filter((candidate) => current(candidate) && fresh(candidate));
|
|
1127
1128
|
const liveKeys = new Set(live);
|
|
1128
1129
|
const active = all.filter(current);
|
|
1129
1130
|
for (const candidate of active) {
|
|
@@ -1175,11 +1176,12 @@ function createEditValidation(host) {
|
|
|
1175
1176
|
problems.delete(key);
|
|
1176
1177
|
}
|
|
1177
1178
|
},
|
|
1178
|
-
edit(edits, recovered = []) {
|
|
1179
|
+
edit(edits, recovered = [], options) {
|
|
1179
1180
|
const metadataChanged = edits.some((edit) => pending.get(edit.rowKey)?.has(edit.column) || problems.get(edit.rowKey)?.has(edit.column) || host.validateRow && pending.get(edit.rowKey)?.size);
|
|
1180
1181
|
const snapshot = host.snapshot();
|
|
1181
1182
|
const failures = [...recovered];
|
|
1182
1183
|
const candidates = [];
|
|
1184
|
+
const guards = new Map([...options?.expectedRows ?? []].map(([key, row]) => [key, { row }]));
|
|
1183
1185
|
const drafts = /* @__PURE__ */ new Map();
|
|
1184
1186
|
const samples = /* @__PURE__ */ new Map();
|
|
1185
1187
|
if (host.validateRow) for (const key of new Set(edits.map((edit) => edit.rowKey))) {
|
|
@@ -1204,6 +1206,11 @@ function createEditValidation(host) {
|
|
|
1204
1206
|
fail("unknown_row", `No row has the key "${String(edit.rowKey)}".`);
|
|
1205
1207
|
continue;
|
|
1206
1208
|
}
|
|
1209
|
+
const guard = guards.get(row.key);
|
|
1210
|
+
if (guard && row.original !== guard.row) {
|
|
1211
|
+
fail("stale_draft", "The row changed after this draft was opened.");
|
|
1212
|
+
continue;
|
|
1213
|
+
}
|
|
1207
1214
|
if (!column) {
|
|
1208
1215
|
fail("unknown_column", `No column has the id "${edit.column}".`);
|
|
1209
1216
|
continue;
|
|
@@ -1261,14 +1268,15 @@ function createEditValidation(host) {
|
|
|
1261
1268
|
original: row.original,
|
|
1262
1269
|
column,
|
|
1263
1270
|
validation,
|
|
1264
|
-
token
|
|
1271
|
+
token,
|
|
1272
|
+
guard
|
|
1265
1273
|
});
|
|
1266
1274
|
} catch (error) {
|
|
1267
1275
|
fail("invalid_value", error instanceof Error ? error.message : String(error));
|
|
1268
1276
|
}
|
|
1269
1277
|
}
|
|
1270
1278
|
const asynchronous = candidates.some((candidate) => isPromise(candidate.validation));
|
|
1271
|
-
const validateRows = (accepted) => rowValidation(accepted.filter(current), failures);
|
|
1279
|
+
const validateRows = (accepted) => rowValidation(accepted.filter((candidate) => current(candidate) && fresh(candidate)), failures);
|
|
1272
1280
|
const outcome = asynchronous ? Promise.all(candidates.map(async (candidate) => {
|
|
1273
1281
|
const problem = await candidate.validation;
|
|
1274
1282
|
if (problem) {
|
|
@@ -1289,17 +1297,47 @@ function createEditValidation(host) {
|
|
|
1289
1297
|
}
|
|
1290
1298
|
setIssues(failures);
|
|
1291
1299
|
const optimistic = host.optimistic ? host.apply(candidates.map((candidate) => candidate.edit), false, failures) : void 0;
|
|
1300
|
+
if (optimistic) for (const [key, guard] of guards) {
|
|
1301
|
+
const row = host.snapshot().getRow(key);
|
|
1302
|
+
if (row) guard.row = row.original;
|
|
1303
|
+
}
|
|
1292
1304
|
if (!optimistic?.changes.length) host.notify();
|
|
1293
1305
|
if (!host.optimistic && failures.length) host.onIssues(failures);
|
|
1294
|
-
outcome.then((accepted) => {
|
|
1295
|
-
|
|
1306
|
+
const completion = outcome.then((accepted) => {
|
|
1307
|
+
const staleCandidates = candidates.filter((candidate) => !current(candidate) || !fresh(candidate)).map((candidate) => ({
|
|
1308
|
+
candidate,
|
|
1309
|
+
problem: issue("stale_draft", "This edit was superseded or its row is no longer current.", {
|
|
1310
|
+
rowKey: candidate.edit.rowKey,
|
|
1311
|
+
column: candidate.edit.column
|
|
1312
|
+
})
|
|
1313
|
+
}));
|
|
1314
|
+
const stale = staleCandidates.map(({ problem }) => problem);
|
|
1315
|
+
const issues = [...failures, ...stale];
|
|
1316
|
+
if (candidates.some(current)) {
|
|
1317
|
+
const superseded = staleCandidates.filter(({ candidate }) => !current(candidate)).map(({ problem }) => problem);
|
|
1318
|
+
const result = settle(accepted, candidates, [...failures, ...staleCandidates.filter(({ candidate }) => current(candidate)).map(({ problem }) => problem)], true);
|
|
1319
|
+
if (!stale.length) return result;
|
|
1320
|
+
return Object.freeze({
|
|
1321
|
+
...result,
|
|
1322
|
+
issues: Object.freeze([...result.issues, ...superseded]),
|
|
1323
|
+
status: result.changes.length ? "partial" : "rejected"
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
return Object.freeze({
|
|
1327
|
+
status: "rejected",
|
|
1328
|
+
changes: Object.freeze([]),
|
|
1329
|
+
rowChanges: Object.freeze([]),
|
|
1330
|
+
issues: Object.freeze(issues),
|
|
1331
|
+
pendingCells: Object.freeze([])
|
|
1332
|
+
});
|
|
1296
1333
|
});
|
|
1297
1334
|
return Object.freeze({
|
|
1298
1335
|
status: "pending",
|
|
1299
1336
|
changes: optimistic?.changes ?? Object.freeze([]),
|
|
1300
1337
|
rowChanges: Object.freeze([]),
|
|
1301
1338
|
issues: Object.freeze([...failures]),
|
|
1302
|
-
pendingCells: Object.freeze(candidates.map((candidate) => Object.freeze({ ...candidate.edit })))
|
|
1339
|
+
pendingCells: Object.freeze(candidates.map((candidate) => Object.freeze({ ...candidate.edit }))),
|
|
1340
|
+
completion
|
|
1303
1341
|
});
|
|
1304
1342
|
}
|
|
1305
1343
|
};
|
|
@@ -3444,8 +3482,8 @@ function createTable(options) {
|
|
|
3444
3482
|
order.splice(target, 0, columnId);
|
|
3445
3483
|
commit({ columnOrder: order });
|
|
3446
3484
|
},
|
|
3447
|
-
edit(edits) {
|
|
3448
|
-
return validation.edit(Array.isArray(edits) ? edits : [edits]);
|
|
3485
|
+
edit(edits, editOptions) {
|
|
3486
|
+
return validation.edit(Array.isArray(edits) ? edits : [edits], [], editOptions);
|
|
3449
3487
|
},
|
|
3450
3488
|
undo() {
|
|
3451
3489
|
const entry = undoStack.undo();
|