@updog/data-editor-wc 0.1.28 → 0.1.29
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/index.d.ts +30 -5
- package/index.js +17 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1015,14 +1015,37 @@ type DataEditorResult<TRow extends DataEditorRow = DataEditorRow> = {
|
|
|
1015
1015
|
invalid: number;
|
|
1016
1016
|
};
|
|
1017
1017
|
};
|
|
1018
|
+
/**
|
|
1019
|
+
* Describes the change state of a single row within a chunk, used to seed
|
|
1020
|
+
* the editor with a previously saved diff on load.
|
|
1021
|
+
*
|
|
1022
|
+
* The client passes current-state rows via `onChunk` and attaches change
|
|
1023
|
+
* descriptors to mark which rows were edited, added, or deleted in a
|
|
1024
|
+
* previous session. The SDK uses these to seed DirtyTracker so the diff
|
|
1025
|
+
* is visible from the first frame.
|
|
1026
|
+
*/
|
|
1027
|
+
type InitialRowChange<TRow extends DataEditorRow = DataEditorRow> = {
|
|
1028
|
+
/** Index of this row within the chunk's rows array. */
|
|
1029
|
+
index: number;
|
|
1030
|
+
/**
|
|
1031
|
+
* Original field values before the user's edits.
|
|
1032
|
+
* Only include fields that differ from the current row.
|
|
1033
|
+
* Presence of this field marks the row as "edited".
|
|
1034
|
+
*/
|
|
1035
|
+
originalValues?: Partial<TRow>;
|
|
1036
|
+
/** Marks this row as a new addition (not from backend). */
|
|
1037
|
+
isNew?: boolean;
|
|
1038
|
+
/** Marks this row as pending deletion. */
|
|
1039
|
+
isDeleted?: boolean;
|
|
1040
|
+
};
|
|
1018
1041
|
/**
|
|
1019
1042
|
* Options used to tag a chunk passed to `loadData`'s `onChunk` callback.
|
|
1020
|
-
* Sources are auto-registered on first encounter. Chunks without options
|
|
1021
|
-
* to "Existing Data".
|
|
1043
|
+
* Sources are auto-registered on first encounter. Chunks without options
|
|
1044
|
+
* (or options without `source`) go to "Existing Data".
|
|
1022
1045
|
*/
|
|
1023
|
-
type ChunkSourceOptions = {
|
|
1024
|
-
/** Display name for this data source.
|
|
1025
|
-
source
|
|
1046
|
+
type ChunkSourceOptions<TRow extends DataEditorRow = DataEditorRow> = {
|
|
1047
|
+
/** Display name for this data source. When omitted, chunk goes to the default backend source. */
|
|
1048
|
+
source?: string;
|
|
1026
1049
|
/** Stable identifier. Defaults to the `source` value when omitted. */
|
|
1027
1050
|
id?: string;
|
|
1028
1051
|
/** Whether the user can delete this source from the editor. @default false */
|
|
@@ -1034,6 +1057,8 @@ type ChunkSourceOptions = {
|
|
|
1034
1057
|
* @default false
|
|
1035
1058
|
*/
|
|
1036
1059
|
done?: boolean;
|
|
1060
|
+
/** Seed change state for specific rows in this chunk. Sparse: only rows that differ from backend. */
|
|
1061
|
+
changes?: InitialRowChange<TRow>[];
|
|
1037
1062
|
};
|
|
1038
1063
|
type DataSourceId = string;
|
|
1039
1064
|
/**
|
package/index.js
CHANGED
|
@@ -18296,7 +18296,7 @@ function Nu(e, t, n) {
|
|
|
18296
18296
|
newValues: /* @__PURE__ */ new Map()
|
|
18297
18297
|
});
|
|
18298
18298
|
for (let i of n) {
|
|
18299
|
-
if (
|
|
18299
|
+
if (!e.isEdited(i)) continue;
|
|
18300
18300
|
let n = e.getRowById(i);
|
|
18301
18301
|
if (n) for (let a of t) {
|
|
18302
18302
|
if (!e.isCellDirty(i, a)) continue;
|
|
@@ -19726,6 +19726,20 @@ var gd = /* @__PURE__ */ new Map(), _d = class {
|
|
|
19726
19726
|
}
|
|
19727
19727
|
return r && (r.rowCount += i), this.valueIndex.bumpVersion(), this.snapshotManager.markCountsDirty(), this.rowStore.invalidateIndex(), this.sourceLifecycle.trackAppend(e, a, t, n !== void 0 && n.size > 0), this.filterEngine.notifyRowsAdded(o), this.filterEngine.updateRowsText(s), this.notify(), a;
|
|
19728
19728
|
}
|
|
19729
|
+
seedInitialChanges(e, t, n) {
|
|
19730
|
+
for (let r of n) {
|
|
19731
|
+
let n = e[r.index], i = t[r.index];
|
|
19732
|
+
if (r.isNew && (this.dirtyTracker.trackNonBackendRow(n), this.dirtyTracker.markNew(n)), r.originalValues) {
|
|
19733
|
+
let e = {
|
|
19734
|
+
...i,
|
|
19735
|
+
...r.originalValues
|
|
19736
|
+
};
|
|
19737
|
+
this.dirtyTracker.snapshotOriginal(n, e), this.dirtyTracker.markEdited(n);
|
|
19738
|
+
}
|
|
19739
|
+
r.isDeleted && this.dirtyTracker.markDeleted(n);
|
|
19740
|
+
}
|
|
19741
|
+
this.filterEngine.markFlagsDirty(), this.filterEngine.flushPendingFlags(), this.snapshotManager.markCountsDirty(), this.notify();
|
|
19742
|
+
}
|
|
19729
19743
|
upsertRows(e, t, n) {
|
|
19730
19744
|
let { anchorKey: r, newRowIds: i } = n ?? {};
|
|
19731
19745
|
r && this.sourceLifecycle.trackPrimaryKey(e, r);
|
|
@@ -21843,7 +21857,7 @@ function Wd(e, t, n, r) {
|
|
|
21843
21857
|
};
|
|
21844
21858
|
n((n, o) => {
|
|
21845
21859
|
let c;
|
|
21846
|
-
if (o ? (c = o.id ?? o.source, e.hasSource(c) || (e.registerSource({
|
|
21860
|
+
if (o?.source ? (c = o.id ?? o.source, e.hasSource(c) || (e.registerSource({
|
|
21847
21861
|
name: o.source,
|
|
21848
21862
|
id: c,
|
|
21849
21863
|
isDeletable: o.deletable ?? !1,
|
|
@@ -21855,7 +21869,7 @@ function Wd(e, t, n, r) {
|
|
|
21855
21869
|
isInitialData: !0
|
|
21856
21870
|
}), e.setSourceLoading($l, !0), !0), c = $l), n.length > 0) {
|
|
21857
21871
|
let r = e.appendRows(c, n);
|
|
21858
|
-
a++, requestIdleCallback(() => {
|
|
21872
|
+
o?.changes?.length && e.seedInitialChanges(r, n, o.changes), a++, requestIdleCallback(() => {
|
|
21859
21873
|
t.current.validateRows(n, r), a--, s();
|
|
21860
21874
|
});
|
|
21861
21875
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@updog/data-editor-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "Client-side CSV importer and spreadsheet editor SDK as a Web Component. Drop into Vue, Angular, Svelte, or vanilla JS. Import CSV, Excel, JSON; edit 1M+ rows entirely in the browser.",
|
|
5
5
|
"author": "Mikhail Kutateladze <admin@updog.tech>",
|
|
6
6
|
"homepage": "https://updog.tech",
|