@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.
Files changed (71) hide show
  1. package/dist/DataTable.d.ts +58 -10
  2. package/dist/DataTable.js +1294 -1625
  3. package/dist/DataTableToolbar.js +1 -2
  4. package/dist/FilterBar.d.ts +3 -0
  5. package/dist/FilterBar.js +131 -108
  6. package/dist/QueryBuilder.js +72 -68
  7. package/dist/cell-edit.js +1 -2
  8. package/dist/client-state.d.ts +9 -3
  9. package/dist/client-state.js +36 -31
  10. package/dist/client-view.js +12 -13
  11. package/dist/column-layout.js +1 -2
  12. package/dist/columns.d.ts +5 -1
  13. package/dist/columns.js +7 -5
  14. package/dist/constrained-columns.js +1 -2
  15. package/dist/core.d.ts +5 -5
  16. package/dist/core.js +28 -28
  17. package/dist/data-table-features.d.ts +134 -0
  18. package/dist/data-table-features.js +560 -0
  19. package/dist/export.js +1 -2
  20. package/dist/facets.js +5 -7
  21. package/dist/filter-bar-state.js +14 -18
  22. package/dist/filter-client.js +1 -2
  23. package/dist/filter.js +1 -2
  24. package/dist/grouping.js +1 -2
  25. package/dist/index.d.ts +5 -3
  26. package/dist/index.js +32 -31
  27. package/dist/messages.d.ts +4 -1
  28. package/dist/messages.js +5 -3
  29. package/dist/pagination.d.ts +43 -1
  30. package/dist/pagination.js +110 -56
  31. package/dist/query-builder-state.js +1 -2
  32. package/dist/requests.d.ts +3 -3
  33. package/dist/requests.js +39 -30
  34. package/dist/row-hierarchy.js +1 -2
  35. package/dist/row-identity.js +1 -2
  36. package/dist/saved-views.d.ts +17 -14
  37. package/dist/saved-views.js +72 -70
  38. package/dist/search-controller.js +1 -2
  39. package/dist/search.js +1 -2
  40. package/dist/selection-client.js +1 -2
  41. package/dist/selection.d.ts +3 -0
  42. package/dist/selection.js +9 -2
  43. package/dist/server-export.d.ts +16 -7
  44. package/dist/server-export.js +58 -55
  45. package/dist/sorting.js +1 -2
  46. package/dist/table-state-changes.d.ts +6 -3
  47. package/dist/table-state-changes.js +45 -42
  48. package/dist/table-state.d.ts +20 -4
  49. package/dist/table-state.js +67 -42
  50. package/dist/text-normalization.js +1 -2
  51. package/dist/url-state.d.ts +12 -9
  52. package/dist/url-state.js +34 -32
  53. package/package.json +5 -5
  54. package/src/DataTable.tsx +490 -766
  55. package/src/FilterBar.tsx +19 -3
  56. package/src/QueryBuilder.tsx +5 -5
  57. package/src/client-state.ts +31 -17
  58. package/src/columns.ts +9 -3
  59. package/src/core.ts +5 -5
  60. package/src/data-table-features.tsx +592 -0
  61. package/src/index.ts +5 -3
  62. package/src/messages.ts +2 -2
  63. package/src/pagination.ts +83 -14
  64. package/src/requests.ts +22 -8
  65. package/src/saved-views.ts +33 -11
  66. package/src/selection.ts +8 -0
  67. package/src/server-export.ts +17 -11
  68. package/src/styles.css +17 -11
  69. package/src/table-state-changes.ts +22 -12
  70. package/src/table-state.ts +53 -11
  71. package/src/url-state.ts +27 -10
@@ -1,4 +1,5 @@
1
- import type { TableState, TableStateSchema } from "./table-state.ts";
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
- /** Async saved-view ownership. Persistence and authorization stay in the app adapter. */
43
- export declare function createSavedViews(adapter: SavedViewsAdapter, schema: TableStateSchema): {
44
- getSnapshot: () => SavedViewsSnapshot;
45
- list: () => Promise<SavedViewOutcome>;
46
- save: (name: string, state: TableState, id?: string | null) => Promise<SavedViewOutcome>;
47
- delete: (id: string) => Promise<SavedViewOutcome>;
48
- restore: (id: string) => SavedViewRestore;
49
- retry: () => Promise<SavedViewOutcome>;
50
- clear: () => void;
51
- dispose(): void;
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;
@@ -1,14 +1,14 @@
1
- import { deserializeState as e, serializeState as t } from "./table-state.js";
2
- //#region src/saved-views.ts
3
- function n(e, t) {
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 r(e, t) {
7
+ function i(e, t) {
8
8
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`${t} must be an object`);
9
- let r = Object.keys(e);
10
- if (r.length !== 3 || !r.includes("id") || !r.includes("name") || !r.includes("state")) throw Error(`${t} must contain exactly id, name, and state`);
11
- let i = n(e.id, `${t}.id`), a = n(e.name, `${t}.name`);
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 i(e) {
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(), i = 0;
21
+ let t = [], n = /* @__PURE__ */ new Set(), r = 0;
22
22
  for (let a of e) {
23
- let e = r(a, `views[${i}]`);
24
- if (n.has(e.id)) throw Error(`views[${i}] duplicates ID ${e.id}`);
25
- n.add(e.id), t.push(e), i++;
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 a(e) {
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 o(o, s) {
36
- let c = Object.freeze({
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
- }), l = 0n, u, d = !1, f = !1;
42
- async function p(t) {
43
- if (d) return "disposed";
44
- if (f) return "superseded";
45
- let n = a(t), p = ++l, m = u;
46
- if (u = void 0, m?.abort(), d) return "disposed";
47
- if (p !== l) return "superseded";
48
- let h = new AbortController();
49
- u = h, c = Object.freeze({
50
- ...c,
51
- pending: n,
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 (n.kind === "list") {
57
- let e = i(await o.list(h.signal));
58
- return d ? "disposed" : p === l ? (c = Object.freeze({
59
- accepted: e,
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 (n.kind === "save") {
66
- let t = r(await o.save(n.view, h.signal), "saved view");
67
- if (d) return "disposed";
68
- if (p !== l) return "superseded";
69
- if (n.view.id !== null && n.view.id !== t.id) throw Error("Saved view adapter changed the requested ID");
70
- e(t.state, s);
71
- let i = c.accepted ?? [], a = i.findIndex((e) => e.id === t.id) < 0 ? [...i, t] : i.map((e) => e.id === t.id ? t : e);
72
- return c = Object.freeze({
73
- accepted: Object.freeze(a),
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 o.delete(n.id, h.signal), d ? "disposed" : p === l ? (c = Object.freeze({
80
- accepted: c.accepted ? Object.freeze(c.accepted.filter((e) => e.id !== n.id)) : null,
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 d ? "disposed" : p === l ? (c = Object.freeze({
87
- ...c,
89
+ return u ? "disposed" : f === c ? (s = Object.freeze({
90
+ ...s,
88
91
  pending: null,
89
- failed: n,
92
+ failed: r,
90
93
  error: e
91
94
  }), "failed") : "superseded";
92
95
  } finally {
93
- p === l && (u = void 0);
96
+ f === c && (l = void 0);
94
97
  }
95
98
  }
96
- function m(e, r, i = null) {
97
- return p({
99
+ function p(e, n, i = null) {
100
+ return f({
98
101
  kind: "save",
99
102
  view: Object.freeze({
100
- id: i === null ? null : n(i, "Saved view ID"),
101
- name: n(e, "Saved view name"),
102
- state: t(r, s)
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 h(t) {
109
+ function m(e) {
107
110
  try {
108
- let r = n(t, "Saved view ID"), i = c.accepted?.find((e) => e.id === r);
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: e(i.state, s)
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 g() {
121
- if (f) return;
122
- f = !0, l++;
123
- let e = u;
124
- u = void 0, c = Object.freeze({
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
- f = !1;
136
+ d = !1;
134
137
  }
135
138
  }
136
139
  return {
137
- getSnapshot: () => c,
138
- list: () => p({ kind: "list" }),
139
- save: m,
140
- delete: (e) => p({
140
+ getSnapshot: () => s,
141
+ list: () => f({ kind: "list" }),
142
+ save: p,
143
+ delete: (e) => f({
141
144
  kind: "delete",
142
- id: n(e, "Saved view ID")
145
+ id: r(e, "Saved view ID")
143
146
  }),
144
- restore: h,
145
- retry: () => c.failed ? p(c.failed) : Promise.resolve(d ? "disposed" : "failed"),
146
- clear: g,
147
+ restore: m,
148
+ retry: () => s.failed ? f(s.failed) : Promise.resolve(u ? "disposed" : "failed"),
149
+ clear: h,
147
150
  dispose() {
148
- d = !0, g();
151
+ u = !0, h();
149
152
  }
150
153
  };
151
154
  }
152
- //#endregion
153
- export { o as createSavedViews };
155
+ export { s as createSavedViews };
@@ -1,4 +1,4 @@
1
- //#region src/search-controller.ts
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
- //#region src/search.ts
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 };
@@ -1,5 +1,5 @@
1
1
  import { compileFilter as e } from "./filter-client.js";
2
- //#region src/selection-client.ts
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 };
@@ -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
- //#region src/selection.ts
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 };
@@ -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;
@@ -1,84 +1,88 @@
1
1
  import { parseFilter as e } from "./filter.js";
2
- import { parseTableState as t } from "./table-state.js";
3
- //#region src/server-export.ts
4
- function n(n, r) {
5
- if (n.format !== "csv" && n.format !== "json") throw Error("Unsupported table export format");
6
- let i = t(n.state, r), a = null;
7
- if (n.selection !== null) {
8
- let t = n.selection;
9
- if (t.kind !== "ids" && t.kind !== "query") throw Error("Invalid export selection kind");
10
- let i = t.kind === "ids" ? t.ids : t.excluded;
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 o = /* @__PURE__ */ new Set();
13
+ let a = /* @__PURE__ */ new Set();
13
14
  for (let e of i) {
14
- if (typeof e != "string" || !e.trim() || o.has(e)) throw Error("Export selection IDs must be unique nonempty strings");
15
- o.add(e);
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
- a = t.kind === "ids" ? Object.freeze({
18
+ o = n.kind === "ids" ? Object.freeze({
18
19
  kind: "ids",
19
- ids: Object.freeze([...o])
20
+ ids: Object.freeze([...a])
20
21
  }) : Object.freeze({
21
22
  kind: "query",
22
- filter: e(t.filter, r.filterColumns),
23
- excluded: Object.freeze([...o])
23
+ filter: e(n.filter, r.filterColumns),
24
+ excluded: Object.freeze([...a])
24
25
  });
25
26
  }
26
27
  return Object.freeze({
27
- format: n.format,
28
- state: i,
29
- selection: a
28
+ format: t.format,
29
+ state: a,
30
+ selection: o
30
31
  });
31
32
  }
32
- function r(e, t) {
33
- let r = {
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
- }, i = 0n, a, o = !1, s = !1;
39
- async function c(c) {
40
- if (o) return "disposed";
41
- if (!t) return "unavailable";
42
- if (s) return "canceled";
43
- if (r.pending) return "busy";
44
- let l = ++i, u = new AbortController();
45
- a = u, r = {
46
- ...r,
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 a = n(c, e);
53
- r = {
54
- ...r,
55
- requested: a
56
+ let o = r(l, e, t);
57
+ i = {
58
+ ...i,
59
+ requested: o
56
60
  };
57
- let s = await t(a, u.signal);
58
- return o ? "disposed" : l === i ? (r = {
61
+ let c = await n(o, d.signal);
62
+ return s ? "disposed" : u === a ? (i = {
59
63
  accepted: {
60
- request: a,
61
- artifact: s
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 o ? "disposed" : l === i ? (r = {
69
- ...r,
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
- l === i && (a = void 0);
78
+ u === a && (o = void 0);
75
79
  }
76
80
  }
77
- function l() {
78
- if (s) return;
79
- s = !0, i++;
80
- let e = a;
81
- a = void 0, r = {
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
- s = !1;
94
+ c = !1;
91
95
  }
92
96
  }
93
97
  return {
94
- available: t !== void 0,
95
- getSnapshot: () => r,
96
- request: c,
97
- retry: () => r.requested ? c(r.requested) : Promise.resolve(o ? "disposed" : t ? "failed" : "unavailable"),
98
- clear: l,
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
- o = !0, l();
104
+ s = !0, u();
101
105
  }
102
106
  };
103
107
  }
104
- //#endregion
105
- export { r as createServerExport };
108
+ export { i as createServerExport, a as createServerExportWith };
package/dist/sorting.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/sorting.ts
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 { ColumnState, TableState, TableStateSchema } from "./table-state.ts";
3
- export type TableStateChange = {
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>;