@gemologic/sheen-table 0.2.1 → 0.4.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/DataTable.d.ts +58 -10
- package/dist/DataTable.js +1294 -1625
- package/dist/DataTableToolbar.js +1 -2
- package/dist/FilterBar.d.ts +3 -0
- package/dist/FilterBar.js +131 -108
- package/dist/QueryBuilder.js +72 -68
- package/dist/cell-edit.js +1 -2
- package/dist/client-state.d.ts +9 -3
- package/dist/client-state.js +36 -31
- package/dist/client-view.js +12 -13
- package/dist/column-layout.js +1 -2
- package/dist/columns.d.ts +5 -1
- package/dist/columns.js +7 -5
- package/dist/constrained-columns.js +1 -2
- package/dist/core.d.ts +5 -5
- package/dist/core.js +28 -28
- package/dist/data-table-features.d.ts +134 -0
- package/dist/data-table-features.js +560 -0
- package/dist/export.js +1 -2
- package/dist/facets.js +5 -7
- package/dist/filter-bar-state.js +14 -18
- package/dist/filter-client.js +1 -2
- package/dist/filter.js +1 -2
- package/dist/grouping.js +1 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +32 -31
- package/dist/messages.d.ts +4 -1
- package/dist/messages.js +5 -3
- package/dist/pagination.d.ts +43 -1
- package/dist/pagination.js +110 -56
- package/dist/query-builder-state.js +1 -2
- package/dist/requests.d.ts +3 -3
- package/dist/requests.js +39 -30
- package/dist/row-hierarchy.js +1 -2
- package/dist/row-identity.js +1 -2
- package/dist/saved-views.d.ts +17 -14
- package/dist/saved-views.js +72 -70
- package/dist/search-controller.js +1 -2
- package/dist/search.js +1 -2
- package/dist/selection-client.js +1 -2
- package/dist/selection.d.ts +3 -0
- package/dist/selection.js +9 -2
- package/dist/server-export.d.ts +16 -7
- package/dist/server-export.js +58 -55
- package/dist/sorting.js +1 -2
- package/dist/table-state-changes.d.ts +6 -3
- package/dist/table-state-changes.js +45 -42
- package/dist/table-state.d.ts +20 -4
- package/dist/table-state.js +67 -42
- package/dist/text-normalization.js +1 -2
- package/dist/url-state.d.ts +12 -9
- package/dist/url-state.js +34 -32
- package/package.json +5 -5
- package/src/DataTable.tsx +490 -766
- package/src/FilterBar.tsx +19 -3
- package/src/QueryBuilder.tsx +5 -5
- package/src/client-state.ts +31 -17
- package/src/columns.ts +9 -3
- package/src/core.ts +5 -5
- package/src/data-table-features.tsx +592 -0
- package/src/index.ts +5 -3
- package/src/messages.ts +2 -2
- package/src/pagination.ts +83 -14
- package/src/requests.ts +22 -8
- package/src/saved-views.ts +33 -11
- package/src/selection.ts +8 -0
- package/src/server-export.ts +17 -11
- package/src/styles.css +17 -11
- package/src/table-state-changes.ts +22 -12
- package/src/table-state.ts +53 -11
- package/src/url-state.ts +27 -10
package/dist/saved-views.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CursorPagination, ServerPagination, TablePagination } from "./pagination.ts";
|
|
2
|
+
import type { CursorTableStateSchema, TableState, TableStateSchema } from "./table-state.ts";
|
|
2
3
|
export interface SavedViewRecord {
|
|
3
4
|
readonly id: string;
|
|
4
5
|
readonly name: string;
|
|
@@ -30,23 +31,25 @@ export interface SavedViewsSnapshot {
|
|
|
30
31
|
readonly error: unknown;
|
|
31
32
|
}
|
|
32
33
|
export type SavedViewOutcome = "accepted" | "failed" | "superseded" | "disposed";
|
|
33
|
-
export type SavedViewRestore = {
|
|
34
|
+
export type SavedViewRestore<Pagination extends ServerPagination = TablePagination> = {
|
|
34
35
|
readonly kind: "accepted";
|
|
35
|
-
readonly state: TableState
|
|
36
|
+
readonly state: TableState<Pagination>;
|
|
36
37
|
} | {
|
|
37
38
|
readonly kind: "missing";
|
|
38
39
|
} | {
|
|
39
40
|
readonly kind: "invalid";
|
|
40
41
|
readonly error: unknown;
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
export interface SavedViews<Pagination extends ServerPagination = TablePagination> {
|
|
44
|
+
readonly getSnapshot: () => SavedViewsSnapshot;
|
|
45
|
+
readonly list: () => Promise<SavedViewOutcome>;
|
|
46
|
+
readonly save: (name: string, state: TableState<Pagination>, id?: string | null) => Promise<SavedViewOutcome>;
|
|
47
|
+
readonly delete: (id: string) => Promise<SavedViewOutcome>;
|
|
48
|
+
readonly restore: (id: string) => SavedViewRestore<Pagination>;
|
|
49
|
+
readonly retry: () => Promise<SavedViewOutcome>;
|
|
50
|
+
readonly clear: () => void;
|
|
51
|
+
readonly dispose: () => void;
|
|
52
|
+
}
|
|
53
|
+
/** Async saved-view ownership. Persistence and authorization stay in the app adapter. Cursor schemas save and restore only the first page. */
|
|
54
|
+
export declare function createSavedViews(adapter: SavedViewsAdapter, schema: CursorTableStateSchema): SavedViews<CursorPagination>;
|
|
55
|
+
export declare function createSavedViews(adapter: SavedViewsAdapter, schema: TableStateSchema): SavedViews;
|
package/dist/saved-views.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { deserializeState as e,
|
|
2
|
-
|
|
3
|
-
function
|
|
1
|
+
import { deserializeState as e, schemaPagination as t, serializeState as n } from "./table-state.js";
|
|
2
|
+
// src/saved-views.ts
|
|
3
|
+
function r(e, t) {
|
|
4
4
|
if (typeof e != "string" || !e || e.trim() !== e) throw Error(`${t} must be a nonempty trimmed string`);
|
|
5
5
|
return e;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function i(e, t) {
|
|
8
8
|
if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`${t} must be an object`);
|
|
9
|
-
let
|
|
10
|
-
if (
|
|
11
|
-
let i =
|
|
9
|
+
let n = Object.keys(e);
|
|
10
|
+
if (n.length !== 3 || !n.includes("id") || !n.includes("name") || !n.includes("state")) throw Error(`${t} must contain exactly id, name, and state`);
|
|
11
|
+
let i = r(e.id, `${t}.id`), a = r(e.name, `${t}.name`);
|
|
12
12
|
if (typeof e.state != "string" || !e.state) throw Error(`${t}.state must be a nonempty serialized string`);
|
|
13
13
|
return Object.freeze({
|
|
14
14
|
id: i,
|
|
@@ -16,99 +16,102 @@ function r(e, t) {
|
|
|
16
16
|
state: e.state
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function a(e) {
|
|
20
20
|
if (!Array.isArray(e)) throw Error("Saved view list must be an array");
|
|
21
|
-
let t = [], n = /* @__PURE__ */ new Set(),
|
|
21
|
+
let t = [], n = /* @__PURE__ */ new Set(), r = 0;
|
|
22
22
|
for (let a of e) {
|
|
23
|
-
let e =
|
|
24
|
-
if (n.has(e.id)) throw Error(`views[${
|
|
25
|
-
n.add(e.id), t.push(e),
|
|
23
|
+
let e = i(a, `views[${r}]`);
|
|
24
|
+
if (n.has(e.id)) throw Error(`views[${r}] duplicates ID ${e.id}`);
|
|
25
|
+
n.add(e.id), t.push(e), r++;
|
|
26
26
|
}
|
|
27
27
|
return Object.freeze(t);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function o(e) {
|
|
30
30
|
return e.kind === "save" ? Object.freeze({
|
|
31
31
|
kind: "save",
|
|
32
32
|
view: Object.freeze({ ...e.view })
|
|
33
33
|
}) : Object.freeze({ ...e });
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
35
|
+
function s(r, i) {
|
|
36
|
+
return t(i), i.pagination, c(r, (e) => n(e, i), (t) => e(t, i));
|
|
37
|
+
}
|
|
38
|
+
function c(e, t, n) {
|
|
39
|
+
let s = Object.freeze({
|
|
37
40
|
accepted: null,
|
|
38
41
|
pending: null,
|
|
39
42
|
failed: null,
|
|
40
43
|
error: null
|
|
41
|
-
}),
|
|
42
|
-
async function
|
|
43
|
-
if (
|
|
44
|
-
if (
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
47
|
-
if (
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
...
|
|
51
|
-
pending:
|
|
44
|
+
}), c = 0n, l, u = !1, d = !1;
|
|
45
|
+
async function f(t) {
|
|
46
|
+
if (u) return "disposed";
|
|
47
|
+
if (d) return "superseded";
|
|
48
|
+
let r = o(t), f = ++c, p = l;
|
|
49
|
+
if (l = void 0, p?.abort(), u) return "disposed";
|
|
50
|
+
if (f !== c) return "superseded";
|
|
51
|
+
let m = new AbortController();
|
|
52
|
+
l = m, s = Object.freeze({
|
|
53
|
+
...s,
|
|
54
|
+
pending: r,
|
|
52
55
|
failed: null,
|
|
53
56
|
error: null
|
|
54
57
|
});
|
|
55
58
|
try {
|
|
56
|
-
if (
|
|
57
|
-
let
|
|
58
|
-
return
|
|
59
|
-
accepted:
|
|
59
|
+
if (r.kind === "list") {
|
|
60
|
+
let t = a(await e.list(m.signal));
|
|
61
|
+
return u ? "disposed" : f === c ? (s = Object.freeze({
|
|
62
|
+
accepted: t,
|
|
60
63
|
pending: null,
|
|
61
64
|
failed: null,
|
|
62
65
|
error: null
|
|
63
66
|
}), "accepted") : "superseded";
|
|
64
67
|
}
|
|
65
|
-
if (
|
|
66
|
-
let t =
|
|
67
|
-
if (
|
|
68
|
-
if (
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
let
|
|
72
|
-
return
|
|
73
|
-
accepted: Object.freeze(
|
|
68
|
+
if (r.kind === "save") {
|
|
69
|
+
let t = i(await e.save(r.view, m.signal), "saved view");
|
|
70
|
+
if (u) return "disposed";
|
|
71
|
+
if (f !== c) return "superseded";
|
|
72
|
+
if (r.view.id !== null && r.view.id !== t.id) throw Error("Saved view adapter changed the requested ID");
|
|
73
|
+
n(t.state);
|
|
74
|
+
let a = s.accepted ?? [], o = a.findIndex((e) => e.id === t.id) < 0 ? [...a, t] : a.map((e) => e.id === t.id ? t : e);
|
|
75
|
+
return s = Object.freeze({
|
|
76
|
+
accepted: Object.freeze(o),
|
|
74
77
|
pending: null,
|
|
75
78
|
failed: null,
|
|
76
79
|
error: null
|
|
77
80
|
}), "accepted";
|
|
78
81
|
}
|
|
79
|
-
return await
|
|
80
|
-
accepted:
|
|
82
|
+
return await e.delete(r.id, m.signal), u ? "disposed" : f === c ? (s = Object.freeze({
|
|
83
|
+
accepted: s.accepted ? Object.freeze(s.accepted.filter((e) => e.id !== r.id)) : null,
|
|
81
84
|
pending: null,
|
|
82
85
|
failed: null,
|
|
83
86
|
error: null
|
|
84
87
|
}), "accepted") : "superseded";
|
|
85
88
|
} catch (e) {
|
|
86
|
-
return
|
|
87
|
-
...
|
|
89
|
+
return u ? "disposed" : f === c ? (s = Object.freeze({
|
|
90
|
+
...s,
|
|
88
91
|
pending: null,
|
|
89
|
-
failed:
|
|
92
|
+
failed: r,
|
|
90
93
|
error: e
|
|
91
94
|
}), "failed") : "superseded";
|
|
92
95
|
} finally {
|
|
93
|
-
|
|
96
|
+
f === c && (l = void 0);
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
99
|
+
function p(e, n, i = null) {
|
|
100
|
+
return f({
|
|
98
101
|
kind: "save",
|
|
99
102
|
view: Object.freeze({
|
|
100
|
-
id: i === null ? null :
|
|
101
|
-
name:
|
|
102
|
-
state: t(
|
|
103
|
+
id: i === null ? null : r(i, "Saved view ID"),
|
|
104
|
+
name: r(e, "Saved view name"),
|
|
105
|
+
state: t(n)
|
|
103
106
|
})
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
|
-
function
|
|
109
|
+
function m(e) {
|
|
107
110
|
try {
|
|
108
|
-
let
|
|
111
|
+
let t = r(e, "Saved view ID"), i = s.accepted?.find((e) => e.id === t);
|
|
109
112
|
return Object.freeze(i ? {
|
|
110
113
|
kind: "accepted",
|
|
111
|
-
state:
|
|
114
|
+
state: n(i.state)
|
|
112
115
|
} : { kind: "missing" });
|
|
113
116
|
} catch (e) {
|
|
114
117
|
return Object.freeze({
|
|
@@ -117,11 +120,11 @@ function o(o, s) {
|
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
|
-
function
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
let e =
|
|
124
|
-
|
|
123
|
+
function h() {
|
|
124
|
+
if (d) return;
|
|
125
|
+
d = !0, c++;
|
|
126
|
+
let e = l;
|
|
127
|
+
l = void 0, s = Object.freeze({
|
|
125
128
|
accepted: null,
|
|
126
129
|
pending: null,
|
|
127
130
|
failed: null,
|
|
@@ -130,24 +133,23 @@ function o(o, s) {
|
|
|
130
133
|
try {
|
|
131
134
|
e?.abort();
|
|
132
135
|
} finally {
|
|
133
|
-
|
|
136
|
+
d = !1;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
return {
|
|
137
|
-
getSnapshot: () =>
|
|
138
|
-
list: () =>
|
|
139
|
-
save:
|
|
140
|
-
delete: (e) =>
|
|
140
|
+
getSnapshot: () => s,
|
|
141
|
+
list: () => f({ kind: "list" }),
|
|
142
|
+
save: p,
|
|
143
|
+
delete: (e) => f({
|
|
141
144
|
kind: "delete",
|
|
142
|
-
id:
|
|
145
|
+
id: r(e, "Saved view ID")
|
|
143
146
|
}),
|
|
144
|
-
restore:
|
|
145
|
-
retry: () =>
|
|
146
|
-
clear:
|
|
147
|
+
restore: m,
|
|
148
|
+
retry: () => s.failed ? f(s.failed) : Promise.resolve(u ? "disposed" : "failed"),
|
|
149
|
+
clear: h,
|
|
147
150
|
dispose() {
|
|
148
|
-
|
|
151
|
+
u = !0, h();
|
|
149
152
|
}
|
|
150
153
|
};
|
|
151
154
|
}
|
|
152
|
-
|
|
153
|
-
export { o as createSavedViews };
|
|
155
|
+
export { s as createSavedViews };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/search-controller.ts
|
|
2
2
|
function e(e, t = 120, n) {
|
|
3
3
|
if (!Number.isSafeInteger(t) || t < 0 || t > 2147483647) throw Error("Search delay must be a nonnegative timer-safe integer");
|
|
4
4
|
if (n && typeof n.query != "string") throw Error("Initial search query must be a string");
|
|
@@ -71,5 +71,4 @@ function e(e, t = 120, n) {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
//#endregion
|
|
75
74
|
export { e as createDebouncedSearch };
|
package/dist/search.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createTextNormalizer as e } from "./text-normalization.js";
|
|
2
|
-
|
|
2
|
+
// src/search.ts
|
|
3
3
|
function t(e, t) {
|
|
4
4
|
if (e === t) return 0;
|
|
5
5
|
if (e.startsWith(t)) return 1;
|
|
@@ -107,5 +107,4 @@ function s(e, t, n) {
|
|
|
107
107
|
let r = i(t, n);
|
|
108
108
|
return r.terms.length === 0 ? e : a(e, r, n).map((e) => e.row);
|
|
109
109
|
}
|
|
110
|
-
//#endregion
|
|
111
110
|
export { r as formatSearchQuery, n as parseSearchQuery, s as searchClientRowValues, o as searchClientRows };
|
package/dist/selection-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compileFilter as e } from "./filter-client.js";
|
|
2
|
-
|
|
2
|
+
// src/selection-client.ts
|
|
3
3
|
function t(t, n, r) {
|
|
4
4
|
let i = new Set(n.kind === "ids" ? n.ids : n.excluded);
|
|
5
5
|
for (let e of i) if (typeof e != "string" || !e.trim()) throw Error("Invalid selection ID");
|
|
@@ -10,5 +10,4 @@ function t(t, n, r) {
|
|
|
10
10
|
return o.add(t), n.kind === "ids" ? i.has(t) : !i.has(t) && !!a?.(e);
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
//#endregion
|
|
14
13
|
export { t as selectClientRows };
|
package/dist/selection.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export declare function createTableSelection(initialFilter: FilterNode, columns:
|
|
|
16
16
|
selectRange(anchor: string, target: string, selected?: boolean): void;
|
|
17
17
|
selectAllMatching(): void;
|
|
18
18
|
isSelected(id: string): boolean;
|
|
19
|
+
isLoaded(id: string): boolean;
|
|
20
|
+
/** Counts selected loaded rows from the smaller explicit/excluded set instead of walking every loaded row. */
|
|
21
|
+
loadedSelectedCount(): number;
|
|
19
22
|
getPayload(): BulkSelection;
|
|
20
23
|
/** Filter changes clear selection and loaded-row eligibility. Reapplying identical state does not. */
|
|
21
24
|
setFilter(value: FilterNode): void;
|
package/dist/selection.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseFilter as e } from "./filter.js";
|
|
2
|
-
|
|
2
|
+
// src/selection.ts
|
|
3
3
|
function t(e) {
|
|
4
4
|
let t = /* @__PURE__ */ new Set();
|
|
5
5
|
for (let n of e) {
|
|
@@ -36,6 +36,14 @@ function n(n, r) {
|
|
|
36
36
|
isSelected(e) {
|
|
37
37
|
return l ? o.has(e) && !c.has(e) : s.has(e);
|
|
38
38
|
},
|
|
39
|
+
isLoaded(e) {
|
|
40
|
+
return o.has(e);
|
|
41
|
+
},
|
|
42
|
+
loadedSelectedCount() {
|
|
43
|
+
let e = l ? c : s, t = 0;
|
|
44
|
+
for (let n of e) o.has(n) && t++;
|
|
45
|
+
return l ? o.size - t : t;
|
|
46
|
+
},
|
|
39
47
|
getPayload() {
|
|
40
48
|
return Object.freeze(l ? {
|
|
41
49
|
kind: "query",
|
|
@@ -56,5 +64,4 @@ function n(n, r) {
|
|
|
56
64
|
}
|
|
57
65
|
};
|
|
58
66
|
}
|
|
59
|
-
//#endregion
|
|
60
67
|
export { n as createTableSelection };
|
package/dist/server-export.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { BulkSelection } from "./selection.ts";
|
|
2
|
+
import type { ServerPagination, TablePagination } from "./pagination.ts";
|
|
2
3
|
import type { TableState, TableStateSchema } from "./table-state.ts";
|
|
3
|
-
export interface TableExportRequest {
|
|
4
|
+
export interface TableExportRequest<Pagination extends ServerPagination = TablePagination> {
|
|
4
5
|
readonly format: "csv" | "json";
|
|
5
|
-
readonly state: TableState
|
|
6
|
+
readonly state: TableState<Pagination>;
|
|
6
7
|
/** null exports the whole matching view; explicit empty IDs export zero rows. */
|
|
7
8
|
readonly selection: BulkSelection | null;
|
|
8
9
|
}
|
|
9
|
-
export interface ServerExportSnapshot<Artifact> {
|
|
10
|
+
export interface ServerExportSnapshot<Artifact, Pagination extends ServerPagination = TablePagination> {
|
|
10
11
|
readonly accepted: {
|
|
11
|
-
readonly request: TableExportRequest
|
|
12
|
+
readonly request: TableExportRequest<Pagination>;
|
|
12
13
|
readonly artifact: Artifact;
|
|
13
14
|
} | null;
|
|
14
|
-
readonly requested: TableExportRequest | null;
|
|
15
|
+
readonly requested: TableExportRequest<Pagination> | null;
|
|
15
16
|
readonly pending: boolean;
|
|
16
17
|
readonly error: unknown;
|
|
17
18
|
}
|
|
@@ -19,8 +20,16 @@ export type ServerExportOutcome = "accepted" | "failed" | "busy" | "unavailable"
|
|
|
19
20
|
/** App callback creates the artifact; only the accepted result should be offered for download. */
|
|
20
21
|
export declare function createServerExport<Artifact>(schema: TableStateSchema, onExport?: (request: TableExportRequest, signal: AbortSignal) => Promise<Artifact>): {
|
|
21
22
|
available: boolean;
|
|
22
|
-
getSnapshot: () => ServerExportSnapshot<Artifact>;
|
|
23
|
-
request: (value: TableExportRequest) => Promise<ServerExportOutcome>;
|
|
23
|
+
getSnapshot: () => ServerExportSnapshot<Artifact, TablePagination>;
|
|
24
|
+
request: (value: TableExportRequest<TablePagination>) => Promise<ServerExportOutcome>;
|
|
25
|
+
retry: () => Promise<ServerExportOutcome>;
|
|
26
|
+
clear: () => void;
|
|
27
|
+
dispose(): void;
|
|
28
|
+
};
|
|
29
|
+
export declare function createServerExportWith<Artifact, Pagination extends ServerPagination>(schema: TableStateSchema, readPagination: (value: unknown) => Pagination, onExport?: (request: TableExportRequest<Pagination>, signal: AbortSignal) => Promise<Artifact>): {
|
|
30
|
+
available: boolean;
|
|
31
|
+
getSnapshot: () => ServerExportSnapshot<Artifact, Pagination>;
|
|
32
|
+
request: (value: TableExportRequest<Pagination>) => Promise<ServerExportOutcome>;
|
|
24
33
|
retry: () => Promise<ServerExportOutcome>;
|
|
25
34
|
clear: () => void;
|
|
26
35
|
dispose(): void;
|
package/dist/server-export.js
CHANGED
|
@@ -1,84 +1,88 @@
|
|
|
1
1
|
import { parseFilter as e } from "./filter.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { parsePagination as t } from "./pagination.js";
|
|
3
|
+
import { parseTableStateWith as n } from "./table-state.js";
|
|
4
|
+
// src/server-export.ts
|
|
5
|
+
function r(t, r, i) {
|
|
6
|
+
if (t.format !== "csv" && t.format !== "json") throw Error("Unsupported table export format");
|
|
7
|
+
let a = n(t.state, r, i), o = null;
|
|
8
|
+
if (t.selection !== null) {
|
|
9
|
+
let n = t.selection;
|
|
10
|
+
if (n.kind !== "ids" && n.kind !== "query") throw Error("Invalid export selection kind");
|
|
11
|
+
let i = n.kind === "ids" ? n.ids : n.excluded;
|
|
11
12
|
if (!Array.isArray(i)) throw Error("Export selection IDs must be an array");
|
|
12
|
-
let
|
|
13
|
+
let a = /* @__PURE__ */ new Set();
|
|
13
14
|
for (let e of i) {
|
|
14
|
-
if (typeof e != "string" || !e.trim() ||
|
|
15
|
-
|
|
15
|
+
if (typeof e != "string" || !e.trim() || a.has(e)) throw Error("Export selection IDs must be unique nonempty strings");
|
|
16
|
+
a.add(e);
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
o = n.kind === "ids" ? Object.freeze({
|
|
18
19
|
kind: "ids",
|
|
19
|
-
ids: Object.freeze([...
|
|
20
|
+
ids: Object.freeze([...a])
|
|
20
21
|
}) : Object.freeze({
|
|
21
22
|
kind: "query",
|
|
22
|
-
filter: e(
|
|
23
|
-
excluded: Object.freeze([...
|
|
23
|
+
filter: e(n.filter, r.filterColumns),
|
|
24
|
+
excluded: Object.freeze([...a])
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
return Object.freeze({
|
|
27
|
-
format:
|
|
28
|
-
state:
|
|
29
|
-
selection:
|
|
28
|
+
format: t.format,
|
|
29
|
+
state: a,
|
|
30
|
+
selection: o
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
33
|
+
function i(e, n) {
|
|
34
|
+
return a(e, t, n);
|
|
35
|
+
}
|
|
36
|
+
function a(e, t, n) {
|
|
37
|
+
let i = {
|
|
34
38
|
accepted: null,
|
|
35
39
|
requested: null,
|
|
36
40
|
pending: !1,
|
|
37
41
|
error: null
|
|
38
|
-
},
|
|
39
|
-
async function
|
|
40
|
-
if (
|
|
41
|
-
if (!
|
|
42
|
-
if (
|
|
43
|
-
if (
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
...
|
|
42
|
+
}, a = 0n, o, s = !1, c = !1;
|
|
43
|
+
async function l(l) {
|
|
44
|
+
if (s) return "disposed";
|
|
45
|
+
if (!n) return "unavailable";
|
|
46
|
+
if (c) return "canceled";
|
|
47
|
+
if (i.pending) return "busy";
|
|
48
|
+
let u = ++a, d = new AbortController();
|
|
49
|
+
o = d, i = {
|
|
50
|
+
...i,
|
|
47
51
|
requested: null,
|
|
48
52
|
pending: !0,
|
|
49
53
|
error: null
|
|
50
54
|
};
|
|
51
55
|
try {
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
...
|
|
55
|
-
requested:
|
|
56
|
+
let o = r(l, e, t);
|
|
57
|
+
i = {
|
|
58
|
+
...i,
|
|
59
|
+
requested: o
|
|
56
60
|
};
|
|
57
|
-
let
|
|
58
|
-
return
|
|
61
|
+
let c = await n(o, d.signal);
|
|
62
|
+
return s ? "disposed" : u === a ? (i = {
|
|
59
63
|
accepted: {
|
|
60
|
-
request:
|
|
61
|
-
artifact:
|
|
64
|
+
request: o,
|
|
65
|
+
artifact: c
|
|
62
66
|
},
|
|
63
67
|
requested: null,
|
|
64
68
|
pending: !1,
|
|
65
69
|
error: null
|
|
66
70
|
}, "accepted") : "canceled";
|
|
67
71
|
} catch (e) {
|
|
68
|
-
return
|
|
69
|
-
...
|
|
72
|
+
return s ? "disposed" : u === a ? (i = {
|
|
73
|
+
...i,
|
|
70
74
|
pending: !1,
|
|
71
75
|
error: e
|
|
72
76
|
}, "failed") : "canceled";
|
|
73
77
|
} finally {
|
|
74
|
-
|
|
78
|
+
u === a && (o = void 0);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
|
-
function
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
let e =
|
|
81
|
-
|
|
81
|
+
function u() {
|
|
82
|
+
if (c) return;
|
|
83
|
+
c = !0, a++;
|
|
84
|
+
let e = o;
|
|
85
|
+
o = void 0, i = {
|
|
82
86
|
accepted: null,
|
|
83
87
|
requested: null,
|
|
84
88
|
pending: !1,
|
|
@@ -87,19 +91,18 @@ function r(e, t) {
|
|
|
87
91
|
try {
|
|
88
92
|
e?.abort();
|
|
89
93
|
} finally {
|
|
90
|
-
|
|
94
|
+
c = !1;
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
return {
|
|
94
|
-
available:
|
|
95
|
-
getSnapshot: () =>
|
|
96
|
-
request:
|
|
97
|
-
retry: () =>
|
|
98
|
-
clear:
|
|
98
|
+
available: n !== void 0,
|
|
99
|
+
getSnapshot: () => i,
|
|
100
|
+
request: l,
|
|
101
|
+
retry: () => i.requested ? l(i.requested) : Promise.resolve(s ? "disposed" : n ? "failed" : "unavailable"),
|
|
102
|
+
clear: u,
|
|
99
103
|
dispose() {
|
|
100
|
-
|
|
104
|
+
s = !0, u();
|
|
101
105
|
}
|
|
102
106
|
};
|
|
103
107
|
}
|
|
104
|
-
|
|
105
|
-
export { r as createServerExport };
|
|
108
|
+
export { i as createServerExport, a as createServerExportWith };
|
package/dist/sorting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/sorting.ts
|
|
2
2
|
function e(e, t) {
|
|
3
3
|
let n = /* @__PURE__ */ new Set();
|
|
4
4
|
for (let e of t) {
|
|
@@ -54,5 +54,4 @@ function t(t, n, r, i) {
|
|
|
54
54
|
return e.index - t.index;
|
|
55
55
|
}), u.map((e) => e.row);
|
|
56
56
|
}
|
|
57
|
-
//#endregion
|
|
58
57
|
export { e as parseSorting, t as sortClientRows };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ClientStateChange } from "./client-state.ts";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { CursorPagination, ServerPagination, TablePagination } from "./pagination.ts";
|
|
3
|
+
import type { ColumnState, CursorTableStateSchema, TableState, TableStateSchema, TableStateSchemaFields } from "./table-state.ts";
|
|
4
|
+
export type TableStateChange<Pagination extends ServerPagination = TablePagination> = {
|
|
4
5
|
readonly kind: "query";
|
|
5
|
-
readonly change: ClientStateChange
|
|
6
|
+
readonly change: ClientStateChange<Pagination>;
|
|
6
7
|
} | {
|
|
7
8
|
readonly kind: "sortCycle";
|
|
8
9
|
readonly column: string;
|
|
@@ -24,4 +25,6 @@ export type TableStateChange = {
|
|
|
24
25
|
readonly pin: ColumnState["pin"];
|
|
25
26
|
};
|
|
26
27
|
/** Pure requested-state update. Apply accepted layout/query/results atomically in the table owner. */
|
|
28
|
+
export declare function changeTableState(value: TableState<CursorPagination>, change: TableStateChange<CursorPagination>, schema: CursorTableStateSchema): TableState<CursorPagination>;
|
|
27
29
|
export declare function changeTableState(value: TableState, change: TableStateChange, schema: TableStateSchema): TableState;
|
|
30
|
+
export declare function changeTableStateWith<Pagination extends ServerPagination>(value: TableState<Pagination>, change: TableStateChange<Pagination>, schema: TableStateSchemaFields, readPagination: (value: unknown) => Pagination): TableState<Pagination>;
|