@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
@@ -0,0 +1,560 @@
1
+ import { createCellEdit as e } from "./cell-edit.js";
2
+ import { groupClientRows as t, normalizeServerGroups as n } from "./grouping.js";
3
+ import { createRowHierarchy as r } from "./row-hierarchy.js";
4
+ import { createRowIdentity as i } from "./row-identity.js";
5
+ import { createComponent as a, delegateEvents as o, effect as s, insert as c, setAttribute as l, setStyleProperty as u, template as d, use as f } from "solid-js/web";
6
+ import { Toaster as p, createToaster as m } from "@gemologic/sheen";
7
+ import { For as h, Show as g, createComputed as _, createEffect as v, createMemo as y, createSignal as b, createUniqueId as x, on as S, onCleanup as C, onMount as w, untrack as T } from "solid-js";
8
+ // src/data-table-features.tsx
9
+ var E = /*#__PURE__*/ d("<button type=button class=sheen-data-table-expander>"), D = /*#__PURE__*/ d("<span class=sheen-data-table-row-status role=status>"), O = /*#__PURE__*/ d("<span class=sheen-data-table-row-status role=alert> <button type=button>"), k = /*#__PURE__*/ d("<div class=sheen-data-table-tree-cell><span class=sheen-data-table-tree-value>"), A = /*#__PURE__*/ d("<span class=sheen-data-table-expander-space aria-hidden=true>"), j = /*#__PURE__*/ d("<div class=sheen-data-table-tree-cell style=--sheen-table-depth:0><span class=sheen-data-table-group-label> <span class=sheen-data-table-group-count>(<!>)"), M = /*#__PURE__*/ d("<input class=\"sheen-data-table-editor sheen-data-table-editor-boolean\"type=checkbox>"), N = /*#__PURE__*/ d("<option value>"), P = /*#__PURE__*/ d("<select class=sheen-data-table-editor>"), F = /*#__PURE__*/ d("<option>"), I = /*#__PURE__*/ d("<input class=sheen-data-table-editor type=number inputmode=decimal>"), L = /*#__PURE__*/ d("<input class=sheen-data-table-editor type=text>"), R = /*#__PURE__*/ d("<span class=sheen-data-table-edit-value>"), z = /*#__PURE__*/ d("<span class=sheen-data-table-edit-rest tabindex=0 aria-keyshortcuts=Enter>"), B = /*#__PURE__*/ d("<span class=sheen-data-table-edit-message>");
10
+ function V(e) {
11
+ return e === null ? "" : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
12
+ }
13
+ function H(e) {
14
+ let [t, n] = b(e()), r = () => {
15
+ n(() => e());
16
+ };
17
+ return {
18
+ snapshot: t,
19
+ sync: r,
20
+ track: (e) => (r(), e.finally(r))
21
+ };
22
+ }
23
+ function U(e, t) {
24
+ let n = i(e), r = /* @__PURE__ */ new Map(), a = y(() => {
25
+ let e = t(), i = n.resolveIds(e), a = /* @__PURE__ */ new Map();
26
+ for (let t = 0; t < e.length; t++) a.set(i[t], e[t]);
27
+ for (let e of r.keys()) a.has(e) || r.delete(e);
28
+ return a;
29
+ });
30
+ function o(e, t) {
31
+ let n = t, i = Object.freeze({
32
+ id: e,
33
+ value: () => {
34
+ let t = a().get(e);
35
+ return t !== void 0 && (n = t), n;
36
+ }
37
+ });
38
+ return r.set(e, i), i;
39
+ }
40
+ return Object.freeze({ resolve(t, n) {
41
+ let i = e(t);
42
+ if (!a().has(i)) throw Error(`Result row at index ${n} is not part of the supplied data`);
43
+ return r.get(i) ?? o(i, t);
44
+ } });
45
+ }
46
+ function W(e) {
47
+ return (() => {
48
+ var t = k(), n = t.firstChild;
49
+ return c(t, a(g, {
50
+ get when() {
51
+ return e.row.canExpand;
52
+ },
53
+ get fallback() {
54
+ return A();
55
+ },
56
+ get children() {
57
+ var t = E();
58
+ return t.$$click = () => e.onToggle(e.row), c(t, () => e.row.expanded ? "▾" : "▸"), s((n) => {
59
+ var r = `${e.row.expanded ? e.messages.collapse : e.messages.expand} ${e.row.row.id}`, i = e.row.expanded, a = e.pending;
60
+ return r !== n.e && l(t, "aria-label", n.e = r), i !== n.t && l(t, "aria-expanded", n.t = i), a !== n.a && (t.disabled = n.a = a), n;
61
+ }, {
62
+ e: void 0,
63
+ t: void 0,
64
+ a: void 0
65
+ }), t;
66
+ }
67
+ }), n), c(n, () => e.children), c(t, a(g, {
68
+ get when() {
69
+ return e.row.pending;
70
+ },
71
+ get children() {
72
+ var t = D();
73
+ return c(t, () => e.messages.loadingChildren), t;
74
+ }
75
+ }), null), c(t, a(g, {
76
+ get when() {
77
+ return e.row.error !== null;
78
+ },
79
+ get children() {
80
+ var t = O(), n = t.firstChild, r = n.nextSibling;
81
+ return c(t, () => e.messages.serverError, n), r.$$click = () => e.onRetry(e.row), c(r, () => e.messages.retry), t;
82
+ }
83
+ }), null), s((n) => u(t, "--sheen-table-depth", Math.max(0, e.row.depth - 1))), t;
84
+ })();
85
+ }
86
+ function G(e) {
87
+ return !e.ctrlKey && !e.metaKey && !e.shiftKey;
88
+ }
89
+ function K(e) {
90
+ let r = e.props, i = r.grouping;
91
+ if (!i) return;
92
+ if (r.mode !== "server" && r.pagination !== !1) throw Error("Client grouping requires complete continuous data with pagination=false");
93
+ if (typeof i.by != "string" || !i.by.trim()) throw Error("DataTable grouping requires a column ID");
94
+ if (i.getLabel !== void 0 && typeof i.getLabel != "function") throw Error("DataTable grouping getLabel must be a function");
95
+ let o = e.definitions.find((e) => e.id === i.by), u = o?.accessor;
96
+ if (!o || !u) throw Error(`Grouping column ${i.by} must be an accessor column`);
97
+ let d = e.definitions.flatMap((e) => e.aggregate && e.accessor ? [{
98
+ id: e.id,
99
+ aggregate: e.aggregate,
100
+ getValue: e.accessor
101
+ }] : []), [f, p] = b(/* @__PURE__ */ new Map()), m = /* @__PURE__ */ new Map(), h = y(() => new Intl.NumberFormat(e.locale()));
102
+ function _(e) {
103
+ let t = f().get(e);
104
+ if (t !== void 0) return t;
105
+ let n = m.get(e);
106
+ if (n !== void 0) return n;
107
+ let i = r.grouping?.collapsible === !1 || r.grouping?.defaultExpanded !== !1;
108
+ return m.set(e, i), i;
109
+ }
110
+ function v(t, n) {
111
+ e.pending() || r.grouping?.collapsible === !1 || _(t) === n || p((e) => new Map(e).set(t, n));
112
+ }
113
+ function x(t) {
114
+ let n = r.grouping?.getLabel?.(t.value) ?? (t.value === null ? e.messages().groupMissing : typeof t.value == "number" ? h().format(t.value) : String(t.value));
115
+ if (typeof n != "string" || !n.trim()) throw Error(`Group ${t.id} requires a nonempty label`);
116
+ return n;
117
+ }
118
+ let S = y(() => {
119
+ if (r.mode === "server" && !e.accepted()) return Object.freeze([]);
120
+ let i = e.result(), a = r.mode === "server" ? n(i.rows, i.groups, {
121
+ column: o.id,
122
+ aggregateColumns: d.map((e) => e.id),
123
+ getRowId: r.getRowId
124
+ }) : t(i.rows, {
125
+ column: o.id,
126
+ getValue: u,
127
+ aggregates: d
128
+ }), s = [], c = 0;
129
+ for (let t = 0; t < a.length; t++) {
130
+ let n = a[t], r = _(n.id);
131
+ s.push(Object.freeze({
132
+ kind: "group",
133
+ key: n.id,
134
+ group: n,
135
+ label: x(n),
136
+ position: t + 1,
137
+ setSize: a.length,
138
+ expanded: r
139
+ }));
140
+ for (let t = 0; t < n.rows.length; t++, c++) {
141
+ if (!r) continue;
142
+ let i = e.stableRows.resolve(n.rows[t], c);
143
+ s.push(Object.freeze({
144
+ kind: "data",
145
+ key: `row:${i.id}`,
146
+ row: i,
147
+ parentId: n.id,
148
+ depth: 2,
149
+ position: t + 1,
150
+ setSize: n.rows.length,
151
+ canExpand: !1,
152
+ expanded: !1,
153
+ unloaded: !1,
154
+ pending: !1,
155
+ error: null
156
+ }));
157
+ }
158
+ }
159
+ return Object.freeze(s);
160
+ }), C = () => void 0;
161
+ return { presentation: {
162
+ rows: S,
163
+ allowSelectAll: !0,
164
+ labelColumn: o.id,
165
+ keyDown(e, t) {
166
+ if (t.kind !== "group" || !G(e)) return !1;
167
+ if (e.key === " " || e.key === "Enter") v(t.group.id, !t.expanded);
168
+ else if (e.key === "ArrowRight" || e.key === "ArrowLeft") v(t.group.id, e.key === "ArrowRight");
169
+ else return !1;
170
+ return e.preventDefault(), !0;
171
+ },
172
+ TreeCell: (t) => a(W, {
173
+ get row() {
174
+ return t.row;
175
+ },
176
+ get messages() {
177
+ return e.messages();
178
+ },
179
+ get pending() {
180
+ return e.pending();
181
+ },
182
+ onToggle: C,
183
+ onRetry: C,
184
+ get children() {
185
+ return t.children;
186
+ }
187
+ }),
188
+ GroupCell: (t) => t.label ? (() => {
189
+ var n = j(), i = n.firstChild, o = i.firstChild, u = o.nextSibling, d = u.firstChild.nextSibling;
190
+ return d.nextSibling, c(n, a(g, {
191
+ get when() {
192
+ return r.grouping?.collapsible !== !1;
193
+ },
194
+ get fallback() {
195
+ return A();
196
+ },
197
+ get children() {
198
+ var n = E();
199
+ return n.$$click = () => v(t.row.group.id, !t.row.expanded), c(n, () => t.row.expanded ? "▾" : "▸"), s((r) => {
200
+ var i = e.pending(), a = `${t.row.expanded ? e.messages().collapse : e.messages().expand} ${t.row.label}`, o = t.row.expanded;
201
+ return i !== r.e && (n.disabled = r.e = i), a !== r.t && l(n, "aria-label", r.t = a), o !== r.a && l(n, "aria-expanded", r.a = o), r;
202
+ }, {
203
+ e: void 0,
204
+ t: void 0,
205
+ a: void 0
206
+ }), n;
207
+ }
208
+ }), i), c(i, () => t.row.label, o), c(u, () => h().format(t.row.group.count), d), n;
209
+ })() : V(t.row.group.aggregates.find((e) => e.column === t.column.id)?.value ?? null)
210
+ } };
211
+ }
212
+ function q(e) {
213
+ let t = e.props, n = t.hierarchy;
214
+ if (!n) return;
215
+ if (!n.getChildren && !n.onLoadChildren) throw Error("DataTable hierarchy requires getChildren or onLoadChildren");
216
+ if (n.onLoadChildren && !n.hasChildren) throw Error("Async DataTable hierarchy requires hasChildren");
217
+ if (typeof n.resetKey == "number" && !Number.isFinite(n.resetKey)) throw Error("DataTable hierarchy resetKey must be a finite number or string");
218
+ let i = r({
219
+ getRowId: t.getRowId,
220
+ ...n.getChildren ? { getChildren: n.getChildren } : {},
221
+ ...n.hasChildren ? { canLoadChildren: n.hasChildren } : {},
222
+ ...n.onLoadChildren ? { loadChildren: n.onLoadChildren } : {},
223
+ ...n.defaultExpanded === void 0 ? {} : { defaultExpanded: n.defaultExpanded }
224
+ });
225
+ C(() => i.dispose());
226
+ let { snapshot: o, sync: s, track: c } = H(i.getSnapshot), l = n.resetKey;
227
+ _(() => {
228
+ let n = e.result().rows, r = t.hierarchy?.resetKey;
229
+ T(() => {
230
+ Object.is(r, l) || i.reset(), l = r, i.updateRoots(n), s();
231
+ });
232
+ });
233
+ let u = e.createStableRows(() => o().map((e) => e.row)), d = y(() => Object.freeze(o().map((e, t) => {
234
+ let n = u.resolve(e.row, t);
235
+ return Object.freeze({
236
+ kind: "data",
237
+ key: `row:${e.id}`,
238
+ row: n,
239
+ parentId: e.parentId,
240
+ depth: e.depth,
241
+ position: e.position,
242
+ setSize: e.setSize,
243
+ canExpand: e.canExpand,
244
+ expanded: e.expanded,
245
+ unloaded: e.unloaded,
246
+ pending: e.pending,
247
+ error: e.error
248
+ });
249
+ })));
250
+ function f(t, n) {
251
+ e.pending() || c(i.setExpanded(t.row.id, n));
252
+ }
253
+ function p(t) {
254
+ e.pending() || c(i.retry(t.row.id));
255
+ }
256
+ let [m, h] = b(!1);
257
+ return w(() => {
258
+ h(!0);
259
+ }), v(() => {
260
+ if (m()) for (let e of d()) e.kind === "data" && e.expanded && e.unloaded && !e.pending && e.error === null && f(e, !0);
261
+ }), { presentation: {
262
+ rows: d,
263
+ allowSelectAll: !1,
264
+ keyDown(t, n, r, i) {
265
+ if (n.kind !== "data" || !G(t)) return !1;
266
+ if (i === "cards") return !n.canExpand || t.key !== "ArrowRight" && t.key !== "ArrowLeft" ? !1 : (t.preventDefault(), f(n, t.key === "ArrowRight"), !0);
267
+ if (n.canExpand && t.key === "ArrowRight") {
268
+ if (t.preventDefault(), !n.expanded) f(n, !0);
269
+ else {
270
+ let t = e.rowIndex(n.key, r), i = e.rowAt(t + 1);
271
+ i?.kind === "data" && i.parentId === n.row.id && e.focusRow(t + 1);
272
+ }
273
+ return !0;
274
+ }
275
+ if (t.key !== "ArrowLeft") return !1;
276
+ if (t.preventDefault(), n.expanded) f(n, !1);
277
+ else if (n.parentId) {
278
+ let t = d().findIndex((e) => e.kind === "data" && e.row.id === n.parentId);
279
+ t >= 0 && e.focusRow(t);
280
+ }
281
+ return !0;
282
+ },
283
+ TreeCell: (t) => a(W, {
284
+ get row() {
285
+ return t.row;
286
+ },
287
+ get messages() {
288
+ return e.messages();
289
+ },
290
+ get pending() {
291
+ return e.pending();
292
+ },
293
+ onToggle: (e) => f(e, !e.expanded),
294
+ onRetry: p,
295
+ get children() {
296
+ return t.children;
297
+ }
298
+ })
299
+ } };
300
+ }
301
+ function J(e, t) {
302
+ return t === null ? e.nullable === !0 : e.type === "text" ? typeof t == "string" : e.type === "number" ? typeof t == "number" : e.type === "boolean" ? typeof t == "boolean" : e.type === "select" && typeof t == "string" && e.options.includes(t);
303
+ }
304
+ function Y(t) {
305
+ let n = t.props, r = t.definitions.filter((e) => e.editor !== null);
306
+ if (r.length > 0 && !n.onCellCommit) throw Error("DataTable editable columns require onCellCommit");
307
+ if (r.length === 0 && n.onCellCommit) throw Error("DataTable onCellCommit requires at least one editable column");
308
+ for (let e of r) if (!e.accessor || !e.editor) throw Error(`Editable column ${e.id} requires an accessor and editor`);
309
+ let i = n.onCellCommit;
310
+ if (!i) return;
311
+ let o = m(), u = y(() => {
312
+ let e = n.editResetKey;
313
+ if (typeof e == "number" && !Number.isFinite(e)) throw Error("DataTable editResetKey must be a finite number or string");
314
+ let t = /* @__PURE__ */ new Map();
315
+ return C(() => {
316
+ for (let e of t.values()) e.controller.dispose();
317
+ }), t;
318
+ });
319
+ v(S(() => n.editResetKey, () => o.clear(), { defer: !0 }));
320
+ function d(n, r, a) {
321
+ let o = a.editor, s = a.accessor;
322
+ if (!o || !s || !i) return;
323
+ let c = `${r.id}\u0000${a.id}`, l = n.get(c);
324
+ if (l) return l;
325
+ let u = s(T(r.value));
326
+ if (!J(o, u)) throw Error(`Initial value for editable cell ${r.id}/${a.id} does not match its editor`);
327
+ let d = e(u, async (e, t) => {
328
+ let n = Object.freeze({
329
+ ...e,
330
+ rowId: r.id,
331
+ row: T(r.value),
332
+ column: a.id
333
+ }), s = await i(n, t), c = s.kind === "accepted" ? s.value : s.current;
334
+ if (!J(o, c)) throw Error(`Committed value for ${r.id}/${a.id} does not match its editor`);
335
+ return s;
336
+ }, { validate: (e) => J(o, e) ? o.validate?.(e, T(r.value)) ?? null : e === null ? t.messages().cellValueRequired : t.messages().cellValueInvalid }), { snapshot: f, sync: p } = H(d.getSnapshot), m = Object.freeze({
337
+ controller: d,
338
+ snapshot: f,
339
+ sync: p
340
+ });
341
+ return n.set(c, m), m;
342
+ }
343
+ function _(e) {
344
+ let n = e.column.editor, r = e.column.accessor;
345
+ if (!n || !r) throw Error(`Editable cell ${e.row.row.id}/${e.column.id} is missing its editor`);
346
+ let i = n, u = x(), d, p, m = !1, _ = r(T(e.row.row.value)), y = () => e.record.snapshot(), b = () => y().draft?.value ?? y().committed, S = () => t.messages().editCell.replaceAll("{column}", e.column.header).replaceAll("{id}", e.row.row.id), C = () => {
347
+ let e = y();
348
+ return e.invalid ? e.invalid : e.conflict ? t.messages().cellConflict.replaceAll("{value}", e.conflict.current === null ? t.messages().noValue : String(e.conflict.current)) : e.error ? t.messages().cellUpdateFailedDescription : null;
349
+ }, w = () => e.column.cell?.(y().committed, e.row.row.value()) ?? V(y().committed);
350
+ v(() => {
351
+ let t = r(e.row.row.value());
352
+ Object.is(t, _) || (_ = t, e.record.controller.acceptRefetch(t), e.record.sync());
353
+ });
354
+ function E() {
355
+ queueMicrotask(() => d?.focus({ preventScroll: !0 }));
356
+ }
357
+ function D() {
358
+ queueMicrotask(() => {
359
+ m = !0;
360
+ try {
361
+ p?.focus({ preventScroll: !0 });
362
+ } finally {
363
+ m = !1;
364
+ }
365
+ });
366
+ }
367
+ function O() {
368
+ m || t.pending() || e.record.controller.begin() && (e.record.sync(), E());
369
+ }
370
+ function k(t) {
371
+ e.record.controller.setDraft(t), e.record.sync();
372
+ }
373
+ async function A(n, r, i = !0) {
374
+ e.record.sync();
375
+ let a = await n;
376
+ e.record.sync();
377
+ let s = y();
378
+ return a === "accepted" && !s.editing && r && D(), (a === "invalid" || a === "conflict") && r && E(), a === "failed" && i && o.show({
379
+ title: t.messages().cellUpdateFailed,
380
+ description: t.messages().cellUpdateFailedDescription,
381
+ tone: "danger",
382
+ priority: "assertive",
383
+ duration: null,
384
+ action: {
385
+ label: t.messages().retry,
386
+ retryLabel: t.messages().retry,
387
+ errorMessage: t.messages().retryFailed,
388
+ run: async () => {
389
+ let t = await A(e.record.controller.retry(), !1, !1);
390
+ if (t !== "accepted") throw Error(`Cell retry was not accepted: ${t}`);
391
+ D();
392
+ }
393
+ }
394
+ }), a;
395
+ }
396
+ function j(t) {
397
+ A(e.record.controller.commit(), t);
398
+ }
399
+ function H() {
400
+ let e = y();
401
+ (e.error === null && e.conflict === null || e.attempt === null || e.draft === null || !Object.is(e.attempt.value, e.draft.value)) && j(!1);
402
+ }
403
+ function U(t) {
404
+ t.key === "Enter" ? (t.preventDefault(), j(!0)) : t.key === "Escape" && (t.preventDefault(), e.record.controller.discard(), e.record.sync(), D());
405
+ }
406
+ function W() {
407
+ let e = () => y().invalid !== null || y().error !== null || void 0, n = () => C() ? `${u}-message` : void 0;
408
+ return i.type === "boolean" ? (() => {
409
+ var t = M();
410
+ return t.addEventListener("change", (e) => k(e.currentTarget.checked)), t.$$keydown = U, t.addEventListener("blur", H), f((e) => {
411
+ d = e, e.checked = b() === !0;
412
+ }, t), s((r) => {
413
+ var i = S(), a = n(), o = e(), s = y().pending || void 0;
414
+ return i !== r.e && l(t, "aria-label", r.e = i), a !== r.t && l(t, "aria-describedby", r.t = a), o !== r.a && l(t, "aria-invalid", r.a = o), s !== r.o && l(t, "aria-busy", r.o = s), r;
415
+ }, {
416
+ e: void 0,
417
+ t: void 0,
418
+ a: void 0,
419
+ o: void 0
420
+ }), t;
421
+ })() : i.type === "select" ? (() => {
422
+ var r = P();
423
+ return r.addEventListener("change", (e) => k(e.currentTarget.value === "" && i.nullable ? null : e.currentTarget.value)), r.$$keydown = U, r.addEventListener("blur", H), f((e) => {
424
+ d = e, e.value = b() === null ? "" : String(b());
425
+ }, r), c(r, a(g, {
426
+ get when() {
427
+ return i.nullable;
428
+ },
429
+ get children() {
430
+ var e = N();
431
+ return c(e, () => t.messages().noValue), e;
432
+ }
433
+ }), null), c(r, a(h, {
434
+ get each() {
435
+ return i.options;
436
+ },
437
+ children: (e) => (() => {
438
+ var t = F();
439
+ return t.value = e, c(t, e), t;
440
+ })()
441
+ }), null), s((t) => {
442
+ var i = S(), a = n(), o = e(), s = y().pending || void 0;
443
+ return i !== t.e && l(r, "aria-label", t.e = i), a !== t.t && l(r, "aria-describedby", t.t = a), o !== t.a && l(r, "aria-invalid", t.a = o), s !== t.o && l(r, "aria-busy", t.o = s), t;
444
+ }, {
445
+ e: void 0,
446
+ t: void 0,
447
+ a: void 0,
448
+ o: void 0
449
+ }), r;
450
+ })() : i.type === "number" ? (() => {
451
+ var t = I();
452
+ return t.$$input = (e) => k(e.currentTarget.value === "" ? null : e.currentTarget.valueAsNumber), t.$$keydown = U, t.addEventListener("blur", H), f((e) => {
453
+ d = e, e.value = b() === null ? "" : String(b());
454
+ }, t), s((r) => {
455
+ var i = S(), a = n(), o = e(), s = y().pending || void 0;
456
+ return i !== r.e && l(t, "aria-label", r.e = i), a !== r.t && l(t, "aria-describedby", r.t = a), o !== r.a && l(t, "aria-invalid", r.a = o), s !== r.o && l(t, "aria-busy", r.o = s), r;
457
+ }, {
458
+ e: void 0,
459
+ t: void 0,
460
+ a: void 0,
461
+ o: void 0
462
+ }), t;
463
+ })() : (() => {
464
+ var t = L();
465
+ return t.$$input = (e) => k(e.currentTarget.value === "" && i.nullable ? null : e.currentTarget.value), t.$$keydown = U, t.addEventListener("blur", H), f((e) => {
466
+ d = e, e.value = b() === null ? "" : String(b());
467
+ }, t), s((r) => {
468
+ var i = S(), a = n(), o = e(), s = y().pending || void 0;
469
+ return i !== r.e && l(t, "aria-label", r.e = i), a !== r.t && l(t, "aria-describedby", r.t = a), o !== r.a && l(t, "aria-invalid", r.a = o), s !== r.o && l(t, "aria-busy", r.o = s), r;
470
+ }, {
471
+ e: void 0,
472
+ t: void 0,
473
+ a: void 0,
474
+ o: void 0
475
+ }), t;
476
+ })();
477
+ }
478
+ return (() => {
479
+ var e = R();
480
+ return c(e, a(g, {
481
+ get when() {
482
+ return y().editing;
483
+ },
484
+ get fallback() {
485
+ return (() => {
486
+ var e = z();
487
+ return e.$$keydown = (e) => {
488
+ e.key === "Enter" && (e.preventDefault(), O());
489
+ }, e.$$click = O, f((e) => {
490
+ p = e, e.addEventListener("focus", O), e.ownerDocument.activeElement === e && queueMicrotask(O);
491
+ }, e), c(e, w), e;
492
+ })();
493
+ },
494
+ get children() {
495
+ return a(W, {});
496
+ }
497
+ }), null), c(e, a(g, {
498
+ get when() {
499
+ return C();
500
+ },
501
+ children: (e) => (() => {
502
+ var t = B();
503
+ return l(t, "id", `${u}-message`), c(t, e), s(() => l(t, "role", y().invalid !== null || y().conflict !== null ? "alert" : void 0)), t;
504
+ })()
505
+ }), null), e;
506
+ })();
507
+ }
508
+ return {
509
+ cell(e, t) {
510
+ if (!t.editor) return;
511
+ let n = y(() => {
512
+ let n = e();
513
+ return n ? d(u(), n.row, t) : void 0;
514
+ });
515
+ return {
516
+ active: () => n() !== void 0,
517
+ attributes: () => {
518
+ let e = n()?.snapshot();
519
+ return e ? {
520
+ "data-editable": "",
521
+ ...e.invalid !== null || e.error !== null ? { "data-invalid": "" } : {},
522
+ ...e.stale ? { "data-stale": "" } : {},
523
+ ...e.pending ? { "data-pending": "" } : {},
524
+ ...e.conflict ? { "data-conflict": "" } : {}
525
+ } : {};
526
+ },
527
+ render: (e) => a(g, {
528
+ get when() {
529
+ return n();
530
+ },
531
+ keyed: !0,
532
+ children: (n) => a(_, {
533
+ get row() {
534
+ return e();
535
+ },
536
+ column: t,
537
+ record: n
538
+ })
539
+ })
540
+ };
541
+ },
542
+ overlay: () => a(p, { controller: o })
543
+ };
544
+ }
545
+ var X = {
546
+ id: "grouping",
547
+ create: K
548
+ }, Z = {
549
+ id: "hierarchy",
550
+ create: q
551
+ }, Q = {
552
+ id: "cellEditing",
553
+ create: Y
554
+ };
555
+ o([
556
+ "click",
557
+ "keydown",
558
+ "input"
559
+ ]);
560
+ export { Q as cellEditingFeature, H as createSnapshotSignal, U as createStableRows, V as defaultCell, X as groupingFeature, Z as hierarchyFeature };
package/dist/export.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/export.ts
1
+ // src/export.ts
2
2
  function e(e, t, n) {
3
3
  if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
4
4
  throw Error(`Invalid export value at row ${t}, column ${n}: expected string, finite number, boolean, or null`);
@@ -23,5 +23,4 @@ function n(n, r) {
23
23
  toJSON: () => JSON.stringify(c.map((e) => Object.fromEntries(s.map((t, n) => [t, e[n]]))))
24
24
  });
25
25
  }
26
- //#endregion
27
26
  export { n as createClientExport };
package/dist/facets.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/facets.ts
1
+ // src/facets.ts
2
2
  function e(e, t, n) {
3
3
  let r = /* @__PURE__ */ new Set(), i = t.flatMap((e) => {
4
4
  if (typeof e.id != "string" || !e.id.trim() || r.has(e.id)) throw Error("Invalid or duplicate facet column");
@@ -22,12 +22,11 @@ function e(e, t, n) {
22
22
  let a = i[e];
23
23
  if (!a) throw Error(`Missing facet column at index ${e}`);
24
24
  let o = n.getValue(r, a.column);
25
- if (o == null) {
26
- a.missing++;
27
- continue;
25
+ if (o == null) a.missing++;
26
+ else {
27
+ if (typeof o != "string" || !a.counts.has(o)) throw Error(`Invalid enum value for facet ${a.column} at row ${t}`);
28
+ a.counts.set(o, (a.counts.get(o) ?? 0) + 1);
28
29
  }
29
- if (typeof o != "string" || !a.counts.has(o)) throw Error(`Invalid enum value for facet ${a.column} at row ${t}`);
30
- a.counts.set(o, (a.counts.get(o) ?? 0) + 1);
31
30
  }
32
31
  }
33
32
  return Object.freeze(i.map((e) => Object.freeze({
@@ -39,5 +38,4 @@ function e(e, t, n) {
39
38
  missing: e.missing
40
39
  })));
41
40
  }
42
- //#endregion
43
41
  export { e as countClientFacets };
@@ -1,4 +1,4 @@
1
- //#region src/filter-bar-state.ts
1
+ // src/filter-bar-state.ts
2
2
  function e(e) {
3
3
  return e.kind !== "and" && e.kind !== "or" && e.kind !== "not";
4
4
  }
@@ -8,26 +8,23 @@ function t(t) {
8
8
  if (t.kind === "and" || t.kind === "or") {
9
9
  let e = Object.freeze([...o, t.kind]);
10
10
  for (let n = 0; n < t.children.length; n++) r(t.children[n], Object.freeze([...i, n]), a, e);
11
- return;
12
- }
13
- if (t.kind === "not") {
14
- e(t.child) ? n.push(Object.freeze({
11
+ } else if (t.kind === "not") e(t.child) ? n.push(Object.freeze({
12
+ path: Object.freeze([...i]),
13
+ condition: t.child,
14
+ directNegated: !0,
15
+ inheritedNegated: a,
16
+ groups: Object.freeze([...o])
17
+ })) : r(t.child, Object.freeze([...i, "child"]), !a, o);
18
+ else {
19
+ if (!e(t)) throw Error("Filter condition traversal reached a non-leaf node");
20
+ n.push(Object.freeze({
15
21
  path: Object.freeze([...i]),
16
- condition: t.child,
17
- directNegated: !0,
22
+ condition: t,
23
+ directNegated: !1,
18
24
  inheritedNegated: a,
19
25
  groups: Object.freeze([...o])
20
- })) : r(t.child, Object.freeze([...i, "child"]), !a, o);
21
- return;
26
+ }));
22
27
  }
23
- if (!e(t)) throw Error("Filter condition traversal reached a non-leaf node");
24
- n.push(Object.freeze({
25
- path: Object.freeze([...i]),
26
- condition: t,
27
- directNegated: !1,
28
- inheritedNegated: a,
29
- groups: Object.freeze([...o])
30
- }));
31
28
  }
32
29
  return r(t, Object.freeze([]), !1, Object.freeze([])), Object.freeze(n);
33
30
  }
@@ -124,5 +121,4 @@ function l(e, t) {
124
121
  children: Object.freeze([])
125
122
  });
126
123
  }
127
- //#endregion
128
124
  export { s as appendFilterCondition, t as listFilterConditions, l as removeFilterColumnConditions, o as removeFilterCondition, i as replaceFilterCondition };
@@ -1,6 +1,6 @@
1
1
  import { parseFilter as e } from "./filter.js";
2
2
  import { createTextNormalizer as t } from "./text-normalization.js";
3
- //#region src/filter-client.ts
3
+ // src/filter-client.ts
4
4
  function n(n, r, i) {
5
5
  let a = Intl.getCanonicalLocales(i.locale)[0] ?? "";
6
6
  if (!a) throw Error("Filter evaluation requires an explicit locale");
@@ -65,5 +65,4 @@ function r(e, t, r, i) {
65
65
  let a = n(t, r, i);
66
66
  return t.kind === "and" && t.children.length === 0 ? e : e.filter(a);
67
67
  }
68
- //#endregion
69
68
  export { n as compileFilter, r as filterClientRows };
package/dist/filter.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/filter.ts
1
+ // src/filter.ts
2
2
  function e(e) {
3
3
  return typeof e == "object" && !!e && !Array.isArray(e);
4
4
  }
@@ -128,5 +128,4 @@ function o(r, a) {
128
128
  }
129
129
  return e(o) ? (n(o, ["version", "filter"], "$"), o.version === 1 ? i(o.filter, a) : t("$", "unsupported filter version")) : t("$", "expected versioned envelope");
130
130
  }
131
- //#endregion
132
131
  export { o as deserializeFilter, i as parseFilter, a as serializeFilter };
package/dist/grouping.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/grouping.ts
1
+ // src/grouping.ts
2
2
  function e(e, t) {
3
3
  if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
4
4
  throw Error(`${t} must be a string, finite number, boolean, or null`);
@@ -122,5 +122,4 @@ function o(e) {
122
122
  }
123
123
  return Object.freeze(t);
124
124
  }
125
- //#endregion
126
125
  export { r as groupClientRows, a as normalizeServerGroups };