@gemologic/sheen-table 0.2.1 → 0.3.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 +4 -0
- package/dist/DataTable.js +1154 -1628
- package/dist/DataTableToolbar.js +1 -2
- package/dist/FilterBar.d.ts +3 -0
- package/dist/FilterBar.js +127 -108
- package/dist/QueryBuilder.js +72 -68
- package/dist/cell-edit.js +1 -2
- package/dist/client-state.js +20 -21
- 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/data-table-features.d.ts +129 -0
- package/dist/data-table-features.js +550 -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.js +3 -3
- package/dist/messages.d.ts +1 -1
- package/dist/messages.js +2 -3
- package/dist/pagination.js +1 -2
- package/dist/query-builder-state.js +1 -2
- package/dist/requests.js +1 -2
- package/dist/row-hierarchy.js +1 -2
- package/dist/row-identity.js +1 -2
- package/dist/saved-views.js +1 -2
- 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.js +1 -2
- package/dist/sorting.js +1 -2
- package/dist/table-state-changes.js +1 -2
- package/dist/table-state.js +1 -2
- package/dist/text-normalization.js +1 -2
- package/dist/url-state.js +1 -2
- package/package.json +5 -5
- package/src/DataTable.tsx +276 -712
- package/src/FilterBar.tsx +17 -3
- package/src/QueryBuilder.tsx +5 -5
- package/src/columns.ts +9 -3
- package/src/data-table-features.tsx +579 -0
- package/src/messages.ts +1 -1
- package/src/selection.ts +8 -0
- package/src/styles.css +17 -11
package/dist/QueryBuilder.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseFilter as e } from "./filter.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { resolveTableMessages as t } from "./messages.js";
|
|
3
|
+
import { appendQueryChild as n, defaultQueryRule as r, moveQueryNode as i, queryBuilderFilterColumns as a, removeQueryNode as o, replaceQueryNode as s, toggleQueryNegation as c } from "./query-builder-state.js";
|
|
4
4
|
import { createComponent as l, effect as u, insert as d, memo as f, mergeProps as p, setAttribute as m, spread as h, template as g, use as ee } from "solid-js/web";
|
|
5
5
|
import { Button as _, CheckboxGroup as v, Input as y, NumberField as b, Select as x, Switch as S, cn as C, useTheme as w } from "@gemologic/sheen";
|
|
6
6
|
import { Index as te, Match as T, Show as E, Switch as D, createMemo as O, createSignal as k, splitProps as A } from "solid-js";
|
|
7
|
-
|
|
8
|
-
var j = /*#__PURE__*/ g("<div class=sheen-query-node-actions>"), M = /*#__PURE__*/ g("<ol class=sheen-query-children>"),
|
|
7
|
+
// src/QueryBuilder.tsx
|
|
8
|
+
var j = /*#__PURE__*/ g("<div class=sheen-query-node-actions>"), M = /*#__PURE__*/ g("<ol class=sheen-query-children>"), N = /*#__PURE__*/ g("<fieldset class=sheen-query-group><legend></legend><div class=sheen-query-group-toolbar>"), ne = /*#__PURE__*/ g("<p class=sheen-query-empty>"), re = /*#__PURE__*/ g("<li>"), P = /*#__PURE__*/ g("<div class=sheen-query-rule role=group><div class=sheen-query-rule-fields>"), F = /*#__PURE__*/ g("<section class=sheen-query-not><div class=sheen-query-not-toolbar><strong>"), I = /*#__PURE__*/ g("<section><div class=sheen-query-announcement role=status aria-live=polite>");
|
|
9
9
|
function L(e) {
|
|
10
10
|
if (e.kind !== "text") throw Error("QueryBuilder expected a text rule");
|
|
11
11
|
return e;
|
|
@@ -134,21 +134,21 @@ function ae(e, t) {
|
|
|
134
134
|
function oe(e) {
|
|
135
135
|
return e.kind === "and" || e.kind === "or" || e.kind === "not" ? "" : e.kind === "empty" ? "empty" : e.operator;
|
|
136
136
|
}
|
|
137
|
-
function se(e, t,
|
|
138
|
-
if (
|
|
137
|
+
function se(e, t, n) {
|
|
138
|
+
if (n === "empty") return Object.freeze({
|
|
139
139
|
kind: "empty",
|
|
140
140
|
column: t.id
|
|
141
141
|
});
|
|
142
|
-
if (t.type === "text" && (
|
|
142
|
+
if (t.type === "text" && (n === "eq" || n === "contains" || n === "startsWith" || n === "endsWith")) return Object.freeze({
|
|
143
143
|
kind: "text",
|
|
144
144
|
column: t.id,
|
|
145
|
-
operator:
|
|
145
|
+
operator: n,
|
|
146
146
|
value: e.kind === "text" ? e.value : "",
|
|
147
147
|
caseSensitive: e.kind === "text" && e.caseSensitive
|
|
148
148
|
});
|
|
149
|
-
if ((t.type === "number" || t.type === "date") && (
|
|
150
|
-
let i =
|
|
151
|
-
return Object.freeze(
|
|
149
|
+
if ((t.type === "number" || t.type === "date") && (n === "eq" || n === "lt" || n === "lte" || n === "gt" || n === "gte" || n === "between")) {
|
|
150
|
+
let i = r(t), a = e.kind === t.type ? e.operator === "between" ? e.min : e.value : i.kind === t.type && i.operator !== "between" ? i.value : 0;
|
|
151
|
+
return Object.freeze(n === "between" ? {
|
|
152
152
|
kind: t.type,
|
|
153
153
|
column: t.id,
|
|
154
154
|
operator: "between",
|
|
@@ -157,12 +157,12 @@ function se(e, t, r) {
|
|
|
157
157
|
} : {
|
|
158
158
|
kind: t.type,
|
|
159
159
|
column: t.id,
|
|
160
|
-
operator:
|
|
160
|
+
operator: n,
|
|
161
161
|
value: a
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
if (t.type === "enum" &&
|
|
165
|
-
let
|
|
164
|
+
if (t.type === "enum" && n === "in") {
|
|
165
|
+
let n = r(t), i = e.kind === "enum" ? e.values : n.kind === "enum" ? n.values : [];
|
|
166
166
|
return Object.freeze({
|
|
167
167
|
kind: "enum",
|
|
168
168
|
column: t.id,
|
|
@@ -170,7 +170,7 @@ function se(e, t, r) {
|
|
|
170
170
|
values: i
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
throw Error(`QueryBuilder operator ${JSON.stringify(
|
|
173
|
+
throw Error(`QueryBuilder operator ${JSON.stringify(n)} is not valid for ${t.type}`);
|
|
174
174
|
}
|
|
175
175
|
function Q(e) {
|
|
176
176
|
if (!e.structural) return null;
|
|
@@ -178,6 +178,7 @@ function Q(e) {
|
|
|
178
178
|
return (() => {
|
|
179
179
|
var n = j();
|
|
180
180
|
return d(n, l(_, {
|
|
181
|
+
variant: "ghost",
|
|
181
182
|
size: "xs",
|
|
182
183
|
get "aria-label"() {
|
|
183
184
|
return e.messages.queryMoveBefore;
|
|
@@ -185,11 +186,12 @@ function Q(e) {
|
|
|
185
186
|
get disabled() {
|
|
186
187
|
return e.disabled || e.index === 0;
|
|
187
188
|
},
|
|
188
|
-
onClick: () => t(
|
|
189
|
+
onClick: () => t(i(e.root(), e.path, -1, e.schema), e.messages.queryChanged),
|
|
189
190
|
get children() {
|
|
190
191
|
return e.messages.queryMoveBefore;
|
|
191
192
|
}
|
|
192
193
|
}), null), d(n, l(_, {
|
|
194
|
+
variant: "ghost",
|
|
193
195
|
size: "xs",
|
|
194
196
|
get "aria-label"() {
|
|
195
197
|
return e.messages.queryMoveAfter;
|
|
@@ -197,26 +199,28 @@ function Q(e) {
|
|
|
197
199
|
get disabled() {
|
|
198
200
|
return e.disabled || e.index >= e.siblingCount - 1;
|
|
199
201
|
},
|
|
200
|
-
onClick: () => t(
|
|
202
|
+
onClick: () => t(i(e.root(), e.path, 1, e.schema), e.messages.queryChanged),
|
|
201
203
|
get children() {
|
|
202
204
|
return e.messages.queryMoveAfter;
|
|
203
205
|
}
|
|
204
206
|
}), null), d(n, l(_, {
|
|
207
|
+
variant: "ghost",
|
|
205
208
|
size: "xs",
|
|
206
209
|
get disabled() {
|
|
207
210
|
return e.disabled;
|
|
208
211
|
},
|
|
209
|
-
onClick: () => t(
|
|
212
|
+
onClick: () => t(c(e.root(), e.path, e.schema), e.messages.queryChanged),
|
|
210
213
|
get children() {
|
|
211
214
|
return e.messages.queryNegate;
|
|
212
215
|
}
|
|
213
216
|
}), null), d(n, l(_, {
|
|
217
|
+
variant: "ghost",
|
|
214
218
|
size: "xs",
|
|
215
219
|
tone: "danger",
|
|
216
220
|
get disabled() {
|
|
217
221
|
return e.disabled;
|
|
218
222
|
},
|
|
219
|
-
onClick: () => t(
|
|
223
|
+
onClick: () => t(o(e.root(), e.path, e.schema), e.messages.queryChanged),
|
|
220
224
|
get children() {
|
|
221
225
|
return e.messages.queryRemove;
|
|
222
226
|
}
|
|
@@ -224,16 +228,16 @@ function Q(e) {
|
|
|
224
228
|
})();
|
|
225
229
|
}
|
|
226
230
|
function ce(e) {
|
|
227
|
-
let
|
|
228
|
-
let
|
|
229
|
-
|
|
230
|
-
}, a = () => e.publish(
|
|
231
|
+
let t = (t) => e.publish(s(e.root(), e.path, t, e.schema), e.messages.queryChanged), i = () => {
|
|
232
|
+
let t = e.columns[0];
|
|
233
|
+
t && e.publish(n(e.root(), e.path, r(t), e.schema), e.messages.queryChanged);
|
|
234
|
+
}, a = () => e.publish(n(e.root(), e.path, Object.freeze({
|
|
231
235
|
kind: "and",
|
|
232
236
|
children: Object.freeze([])
|
|
233
237
|
}), e.schema), e.messages.queryChanged);
|
|
234
238
|
return (() => {
|
|
235
|
-
var
|
|
236
|
-
return d(
|
|
239
|
+
var n = N(), r = n.firstChild, o = r.nextSibling;
|
|
240
|
+
return d(r, () => e.messages.queryGroup), d(o, l(x, {
|
|
237
241
|
get label() {
|
|
238
242
|
return e.messages.queryMatch;
|
|
239
243
|
},
|
|
@@ -252,9 +256,9 @@ function ce(e) {
|
|
|
252
256
|
label: e.messages.queryMatchAny
|
|
253
257
|
}];
|
|
254
258
|
},
|
|
255
|
-
onValueChange: (
|
|
256
|
-
(
|
|
257
|
-
kind:
|
|
259
|
+
onValueChange: (n) => {
|
|
260
|
+
(n === "and" || n === "or") && t(Object.freeze({
|
|
261
|
+
kind: n,
|
|
258
262
|
children: e.node.children
|
|
259
263
|
}));
|
|
260
264
|
}
|
|
@@ -276,13 +280,13 @@ function ce(e) {
|
|
|
276
280
|
get children() {
|
|
277
281
|
return e.messages.queryAddGroup;
|
|
278
282
|
}
|
|
279
|
-
}), null), d(o, l(Q, e), null), d(
|
|
283
|
+
}), null), d(o, l(Q, e), null), d(n, l(E, {
|
|
280
284
|
get when() {
|
|
281
285
|
return e.node.children.length > 0;
|
|
282
286
|
},
|
|
283
287
|
get fallback() {
|
|
284
288
|
return (() => {
|
|
285
|
-
var t =
|
|
289
|
+
var t = ne();
|
|
286
290
|
return d(t, () => e.messages.noResults), t;
|
|
287
291
|
})();
|
|
288
292
|
},
|
|
@@ -293,7 +297,7 @@ function ce(e) {
|
|
|
293
297
|
return e.node.children;
|
|
294
298
|
},
|
|
295
299
|
children: (t, n) => (() => {
|
|
296
|
-
var r =
|
|
300
|
+
var r = re();
|
|
297
301
|
return d(r, l($, p(e, {
|
|
298
302
|
get node() {
|
|
299
303
|
return t();
|
|
@@ -310,12 +314,12 @@ function ce(e) {
|
|
|
310
314
|
})()
|
|
311
315
|
})), t;
|
|
312
316
|
}
|
|
313
|
-
}), null), u(() => m(
|
|
317
|
+
}), null), u(() => m(n, "data-query-path", J(e.path))), n;
|
|
314
318
|
})();
|
|
315
319
|
}
|
|
316
320
|
function le(e) {
|
|
317
|
-
let t = O(() => Z(e.columns, e.node.column)),
|
|
318
|
-
|
|
321
|
+
let t = O(() => Z(e.columns, e.node.column)), n = (t) => e.publish(s(e.root(), e.path, t, e.schema), e.messages.queryChanged), i = (r) => {
|
|
322
|
+
r && n(se(e.node, t(), r));
|
|
319
323
|
};
|
|
320
324
|
return (() => {
|
|
321
325
|
var a = P(), o = a.firstChild;
|
|
@@ -337,7 +341,7 @@ function le(e) {
|
|
|
337
341
|
},
|
|
338
342
|
onValueChange: (t) => {
|
|
339
343
|
let i = e.columns.find((e) => e.id === t);
|
|
340
|
-
i && r(
|
|
344
|
+
i && n(r(i));
|
|
341
345
|
}
|
|
342
346
|
}), null), d(o, l(x, {
|
|
343
347
|
get label() {
|
|
@@ -370,7 +374,7 @@ function le(e) {
|
|
|
370
374
|
get disabled() {
|
|
371
375
|
return e.disabled;
|
|
372
376
|
},
|
|
373
|
-
onInput: (t) =>
|
|
377
|
+
onInput: (t) => n(Object.freeze({
|
|
374
378
|
...L(e.node),
|
|
375
379
|
value: t.currentTarget.value
|
|
376
380
|
}))
|
|
@@ -384,7 +388,7 @@ function le(e) {
|
|
|
384
388
|
get disabled() {
|
|
385
389
|
return e.disabled;
|
|
386
390
|
},
|
|
387
|
-
onCheckedChange: (t) =>
|
|
391
|
+
onCheckedChange: (t) => n(Object.freeze({
|
|
388
392
|
...L(e.node),
|
|
389
393
|
caseSensitive: t
|
|
390
394
|
}))
|
|
@@ -413,9 +417,9 @@ function le(e) {
|
|
|
413
417
|
return e.disabled;
|
|
414
418
|
},
|
|
415
419
|
onValueChange: (t) => {
|
|
416
|
-
let
|
|
417
|
-
t !== null && t <=
|
|
418
|
-
...
|
|
420
|
+
let r = V(R(e.node));
|
|
421
|
+
t !== null && t <= r.max && n(Object.freeze({
|
|
422
|
+
...r,
|
|
419
423
|
min: t
|
|
420
424
|
}));
|
|
421
425
|
}
|
|
@@ -430,9 +434,9 @@ function le(e) {
|
|
|
430
434
|
return e.disabled;
|
|
431
435
|
},
|
|
432
436
|
onValueChange: (t) => {
|
|
433
|
-
let
|
|
434
|
-
t !== null && t >=
|
|
435
|
-
...
|
|
437
|
+
let r = V(R(e.node));
|
|
438
|
+
t !== null && t >= r.min && n(Object.freeze({
|
|
439
|
+
...r,
|
|
436
440
|
max: t
|
|
437
441
|
}));
|
|
438
442
|
}
|
|
@@ -454,7 +458,7 @@ function le(e) {
|
|
|
454
458
|
return e.disabled;
|
|
455
459
|
},
|
|
456
460
|
onValueChange: (t) => {
|
|
457
|
-
t !== null &&
|
|
461
|
+
t !== null && n(Object.freeze({
|
|
458
462
|
...H(R(e.node)),
|
|
459
463
|
value: t
|
|
460
464
|
}));
|
|
@@ -488,9 +492,9 @@ function le(e) {
|
|
|
488
492
|
return e.disabled;
|
|
489
493
|
},
|
|
490
494
|
onInput: (t) => {
|
|
491
|
-
let
|
|
492
|
-
i !== void 0 && i <=
|
|
493
|
-
...
|
|
495
|
+
let r = U(z(e.node)), i = X(t.currentTarget.value);
|
|
496
|
+
i !== void 0 && i <= r.max && n(Object.freeze({
|
|
497
|
+
...r,
|
|
494
498
|
min: i
|
|
495
499
|
}));
|
|
496
500
|
}
|
|
@@ -506,9 +510,9 @@ function le(e) {
|
|
|
506
510
|
return e.disabled;
|
|
507
511
|
},
|
|
508
512
|
onInput: (t) => {
|
|
509
|
-
let
|
|
510
|
-
i !== void 0 && i >=
|
|
511
|
-
...
|
|
513
|
+
let r = U(z(e.node)), i = X(t.currentTarget.value);
|
|
514
|
+
i !== void 0 && i >= r.min && n(Object.freeze({
|
|
515
|
+
...r,
|
|
512
516
|
max: i
|
|
513
517
|
}));
|
|
514
518
|
}
|
|
@@ -531,10 +535,10 @@ function le(e) {
|
|
|
531
535
|
return e.disabled;
|
|
532
536
|
},
|
|
533
537
|
onInput: (t) => {
|
|
534
|
-
let
|
|
535
|
-
|
|
538
|
+
let r = X(t.currentTarget.value);
|
|
539
|
+
r !== void 0 && n(Object.freeze({
|
|
536
540
|
...W(z(e.node)),
|
|
537
|
-
value:
|
|
541
|
+
value: r
|
|
538
542
|
}));
|
|
539
543
|
}
|
|
540
544
|
});
|
|
@@ -562,7 +566,7 @@ function le(e) {
|
|
|
562
566
|
return ie(t());
|
|
563
567
|
},
|
|
564
568
|
onValueChange: (t) => {
|
|
565
|
-
t.length > 0 &&
|
|
569
|
+
t.length > 0 && n(Object.freeze({
|
|
566
570
|
...B(e.node),
|
|
567
571
|
values: Object.freeze([...t])
|
|
568
572
|
}));
|
|
@@ -590,11 +594,12 @@ function $(e) {
|
|
|
590
594
|
get children() {
|
|
591
595
|
var t = F(), n = t.firstChild, r = n.firstChild;
|
|
592
596
|
return d(r, () => e.messages.queryNegate), d(n, l(_, {
|
|
597
|
+
variant: "ghost",
|
|
593
598
|
size: "xs",
|
|
594
599
|
get disabled() {
|
|
595
600
|
return e.disabled;
|
|
596
601
|
},
|
|
597
|
-
onClick: () => e.publish(
|
|
602
|
+
onClick: () => e.publish(c(e.root(), e.path, e.schema), e.messages.queryChanged),
|
|
598
603
|
get children() {
|
|
599
604
|
return e.messages.queryRemoveNegation;
|
|
600
605
|
}
|
|
@@ -640,8 +645,8 @@ function $(e) {
|
|
|
640
645
|
];
|
|
641
646
|
} });
|
|
642
647
|
}
|
|
643
|
-
function ue(
|
|
644
|
-
let [
|
|
648
|
+
function ue(n) {
|
|
649
|
+
let [r, i] = A(n, [
|
|
645
650
|
"columns",
|
|
646
651
|
"value",
|
|
647
652
|
"onChange",
|
|
@@ -649,20 +654,20 @@ function ue(t) {
|
|
|
649
654
|
"disabled",
|
|
650
655
|
"class",
|
|
651
656
|
"ref"
|
|
652
|
-
]),
|
|
653
|
-
|
|
657
|
+
]), o = w(), [s, c] = k(""), u = O(() => t(o.messages())), f = O(() => a(r.columns)), m = O(() => e(r.value, f())), g = (t, n) => {
|
|
658
|
+
r.onChange(e(t, f())), c(""), queueMicrotask(() => c(n));
|
|
654
659
|
};
|
|
655
660
|
return (() => {
|
|
656
|
-
var e = I(), t = e.firstChild,
|
|
657
|
-
return typeof
|
|
661
|
+
var e = I(), t = e.firstChild, n = r.ref;
|
|
662
|
+
return typeof n == "function" ? ee(n, e) : r.ref = e, h(e, p(i, {
|
|
658
663
|
get class() {
|
|
659
|
-
return C("sheen-query-builder",
|
|
664
|
+
return C("sheen-query-builder", r.class);
|
|
660
665
|
},
|
|
661
666
|
get "aria-label"() {
|
|
662
|
-
return
|
|
667
|
+
return r.label ?? u().queryBuilder;
|
|
663
668
|
},
|
|
664
669
|
get "data-disabled"() {
|
|
665
|
-
return
|
|
670
|
+
return r.disabled || void 0;
|
|
666
671
|
}
|
|
667
672
|
}), !1, !0), d(e, l($, {
|
|
668
673
|
get node() {
|
|
@@ -670,13 +675,13 @@ function ue(t) {
|
|
|
670
675
|
},
|
|
671
676
|
path: [],
|
|
672
677
|
get columns() {
|
|
673
|
-
return
|
|
678
|
+
return r.columns;
|
|
674
679
|
},
|
|
675
680
|
get schema() {
|
|
676
681
|
return f();
|
|
677
682
|
},
|
|
678
683
|
get disabled() {
|
|
679
|
-
return
|
|
684
|
+
return r.disabled ?? !1;
|
|
680
685
|
},
|
|
681
686
|
structural: !1,
|
|
682
687
|
index: 0,
|
|
@@ -686,8 +691,7 @@ function ue(t) {
|
|
|
686
691
|
},
|
|
687
692
|
publish: g,
|
|
688
693
|
root: m
|
|
689
|
-
}), t), d(t,
|
|
694
|
+
}), t), d(t, s), e;
|
|
690
695
|
})();
|
|
691
696
|
}
|
|
692
|
-
//#endregion
|
|
693
697
|
export { ue as QueryBuilder };
|
package/dist/cell-edit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cell-edit.ts
|
|
2
2
|
function e(e) {
|
|
3
3
|
if (e !== null && typeof e != "string" && typeof e != "number" && typeof e != "boolean") throw Error("Cell edit values must be strings, finite numbers, booleans, or null");
|
|
4
4
|
if (typeof e == "number" && !Number.isFinite(e)) throw Error("Cell edit numbers must be finite");
|
|
@@ -174,5 +174,4 @@ function t(t, n, r = {}) {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
//#endregion
|
|
178
177
|
export { t as createCellEdit };
|
package/dist/client-state.js
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { parseFilter as e } from "./filter.js";
|
|
2
|
+
import { parsePagination as t, resetPagination as n, resizePagination as r } from "./pagination.js";
|
|
3
3
|
import { parseSorting as i } from "./sorting.js";
|
|
4
|
-
|
|
5
|
-
function a(
|
|
6
|
-
if (typeof
|
|
7
|
-
if (Object.keys(
|
|
4
|
+
// src/client-state.ts
|
|
5
|
+
function a(n, r) {
|
|
6
|
+
if (typeof n != "object" || !n || Array.isArray(n)) throw Error("Invalid client state: expected an object");
|
|
7
|
+
if (Object.keys(n).some((e) => ![
|
|
8
8
|
"search",
|
|
9
9
|
"filter",
|
|
10
10
|
"sorting",
|
|
11
11
|
"pagination"
|
|
12
12
|
].includes(e))) throw Error("Invalid client state: unknown field");
|
|
13
|
-
if (!("search" in
|
|
14
|
-
if (!("filter" in
|
|
13
|
+
if (!("search" in n) || typeof n.search != "string") throw Error("Invalid client state: search must be a string");
|
|
14
|
+
if (!("filter" in n) || !("sorting" in n) || !("pagination" in n)) throw Error("Invalid client state: missing query field");
|
|
15
15
|
return Object.freeze({
|
|
16
|
-
search:
|
|
17
|
-
filter:
|
|
18
|
-
sorting: i(
|
|
19
|
-
pagination:
|
|
16
|
+
search: n.search,
|
|
17
|
+
filter: e(n.filter, r.filterColumns),
|
|
18
|
+
sorting: i(n.sorting, r.sortColumns),
|
|
19
|
+
pagination: t(n.pagination)
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
function o(
|
|
23
|
-
let s = a(
|
|
22
|
+
function o(e, i, o) {
|
|
23
|
+
let s = a(e, o);
|
|
24
24
|
switch (i.kind) {
|
|
25
25
|
case "search": return a({
|
|
26
26
|
...s,
|
|
27
27
|
search: i.value,
|
|
28
|
-
pagination:
|
|
28
|
+
pagination: n(s.pagination)
|
|
29
29
|
}, o);
|
|
30
30
|
case "filter": return a({
|
|
31
31
|
...s,
|
|
32
32
|
filter: i.value,
|
|
33
|
-
pagination:
|
|
33
|
+
pagination: n(s.pagination)
|
|
34
34
|
}, o);
|
|
35
35
|
case "sorting": return a({
|
|
36
36
|
...s,
|
|
37
37
|
sorting: i.value,
|
|
38
|
-
pagination:
|
|
38
|
+
pagination: n(s.pagination)
|
|
39
39
|
}, o);
|
|
40
40
|
case "pagination": {
|
|
41
|
-
let
|
|
41
|
+
let e = t(i.value), r = e !== !1 && s.pagination !== !1 && e.pageSize !== s.pagination.pageSize;
|
|
42
42
|
return a({
|
|
43
43
|
...s,
|
|
44
|
-
pagination: r ?
|
|
44
|
+
pagination: r ? n(e) : e
|
|
45
45
|
}, o);
|
|
46
46
|
}
|
|
47
47
|
case "pageSize":
|
|
48
48
|
if (s.pagination === !1) throw Error("Page-size changes require pagination to be enabled");
|
|
49
49
|
return a({
|
|
50
50
|
...s,
|
|
51
|
-
pagination:
|
|
51
|
+
pagination: r(s.pagination, i.value)
|
|
52
52
|
}, o);
|
|
53
53
|
default: throw Error("Unknown client state change");
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
//#endregion
|
|
57
56
|
export { o as changeClientViewState, a as parseClientViewState };
|
package/dist/client-view.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { countClientFacets as e } from "./facets.js";
|
|
2
|
+
import { filterClientRows as t } from "./filter-client.js";
|
|
3
|
+
import { paginateClientRows as n, parsePagination as r } from "./pagination.js";
|
|
4
|
+
import { searchClientRowValues as i } from "./search.js";
|
|
5
|
+
import { sortClientRows as a } from "./sorting.js";
|
|
6
|
+
import { removeFilterColumnConditions as o } from "./filter-bar-state.js";
|
|
7
|
+
// src/client-view.ts
|
|
8
8
|
function s(s, c, l) {
|
|
9
|
-
let u =
|
|
9
|
+
let u = r(c.pagination), d = i(s, c.search, {
|
|
10
10
|
locale: l.locale,
|
|
11
11
|
columns: l.searchColumns,
|
|
12
12
|
getValue: l.getSearchValue ?? l.getValue,
|
|
13
13
|
exactMatch: l.exactMatch ?? !1
|
|
14
|
-
}), f =
|
|
14
|
+
}), f = t(d, c.filter, l.filterColumns, l), p = /* @__PURE__ */ new Map();
|
|
15
15
|
for (let e of l.filterColumns) {
|
|
16
16
|
if (e.type !== "enum") continue;
|
|
17
|
-
let t =
|
|
18
|
-
|
|
17
|
+
let t = o(c.filter, e.id), n = p.get(t);
|
|
18
|
+
n ? n.push(e) : p.set(t, [e]);
|
|
19
19
|
}
|
|
20
|
-
let m = Object.freeze([...p].flatMap(([
|
|
20
|
+
let m = Object.freeze([...p].flatMap(([n, r]) => e(n === c.filter ? f : t(d, n, l.filterColumns, l), r, l))), h = a(f, c.sorting, l.sortColumns, l), g = n(h, u);
|
|
21
21
|
return {
|
|
22
22
|
view: h,
|
|
23
23
|
rows: g.rows,
|
|
@@ -26,5 +26,4 @@ function s(s, c, l) {
|
|
|
26
26
|
facets: m
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
//#endregion
|
|
30
29
|
export { s as createClientView };
|
package/dist/column-layout.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/column-layout.ts
|
|
2
2
|
function e(e) {
|
|
3
3
|
return [
|
|
4
4
|
...e.filter((e) => e.pin === "start"),
|
|
@@ -30,5 +30,4 @@ function n(n, r, i) {
|
|
|
30
30
|
function r(e, t, r) {
|
|
31
31
|
return n(e, t, r) !== e;
|
|
32
32
|
}
|
|
33
|
-
//#endregion
|
|
34
33
|
export { r as canMoveColumn, n as moveColumn, e as orderColumnStates, t as placeColumn };
|
package/dist/columns.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface SheenAccessorColumn<Row extends object> extends ColumnBase<Row>
|
|
|
60
60
|
/** Omit to infer number/date from filter or numeric, otherwise text. */
|
|
61
61
|
readonly sort?: ColumnSort;
|
|
62
62
|
readonly aggregate?: ColumnAggregate;
|
|
63
|
+
/** Tint a numeric cell up or down when its value changes for the same row. Off under reduced motion. */
|
|
64
|
+
readonly flash?: boolean;
|
|
63
65
|
}
|
|
64
66
|
export interface SheenDisplayColumn<Row extends object> extends ColumnBase<Row> {
|
|
65
67
|
readonly accessor?: never;
|
|
@@ -71,9 +73,10 @@ export interface SheenDisplayColumn<Row extends object> extends ColumnBase<Row>
|
|
|
71
73
|
readonly sort?: never;
|
|
72
74
|
readonly aggregate?: never;
|
|
73
75
|
readonly editor?: never;
|
|
76
|
+
readonly flash?: never;
|
|
74
77
|
}
|
|
75
78
|
export type SheenColumnInput<Row extends object> = SheenAccessorColumn<Row> | SheenDisplayColumn<Row>;
|
|
76
|
-
interface ResolvedColumn<Row extends object> {
|
|
79
|
+
export interface ResolvedColumn<Row extends object> {
|
|
77
80
|
readonly id: string;
|
|
78
81
|
readonly header: string;
|
|
79
82
|
readonly accessor: ((row: Row) => ColumnValue) | null;
|
|
@@ -94,6 +97,7 @@ interface ResolvedColumn<Row extends object> {
|
|
|
94
97
|
readonly faceted: boolean;
|
|
95
98
|
readonly sort: SortColumn | null;
|
|
96
99
|
readonly aggregate: ColumnAggregate | null;
|
|
100
|
+
readonly flash: boolean;
|
|
97
101
|
readonly unsafeTanStack: UnsafeTanStackColumnOptions | null;
|
|
98
102
|
}
|
|
99
103
|
declare const columnsBrand: unique symbol;
|
package/dist/columns.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/columns.ts
|
|
2
2
|
var e = Symbol("inspect-sheen-columns"), t = class {
|
|
3
3
|
#e;
|
|
4
4
|
constructor(e) {
|
|
@@ -27,6 +27,7 @@ var e = Symbol("inspect-sheen-columns"), t = class {
|
|
|
27
27
|
"filter",
|
|
28
28
|
"sort",
|
|
29
29
|
"aggregate",
|
|
30
|
+
"flash",
|
|
30
31
|
"__unsafe_tanstack"
|
|
31
32
|
]);
|
|
32
33
|
function r(e, t) {
|
|
@@ -178,8 +179,9 @@ function p(e) {
|
|
|
178
179
|
let A = _.visible ?? !0, j = _.sensitive ?? !1, M = d(g.search, b, A, j, `${e}.search`), N = l(g.editor, b !== null, `${e}.editor`), P = o(_.filter, _.id, `${e}.filter`), F = c(_.filter, `${e}.filter`), I = s(_.sort, b !== null, P, D, _.id, `${e}.sort`), L = _.aggregate ?? null;
|
|
179
180
|
if (L !== null && L !== "sum" && L !== "average" && L !== "min" && L !== "max" && L !== "count") throw Error(`${e}.aggregate is invalid`);
|
|
180
181
|
if (L !== null && L !== "count" && !D && P?.type !== "number") throw Error(`${e}.${L} requires a numeric column`);
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
if (_.flash !== void 0 && (typeof _.flash != "boolean" || b === null)) throw Error(`${e}.flash must be boolean on an accessor column`);
|
|
183
|
+
let R = _.flash ?? !1, z = null;
|
|
184
|
+
_.__unsafe_tanstack !== void 0 && (r(_.__unsafe_tanstack, `${e}.__unsafe_tanstack`), z = Object.freeze({ ..._.__unsafe_tanstack })), m.push(Object.freeze({
|
|
183
185
|
id: _.id,
|
|
184
186
|
header: _.header,
|
|
185
187
|
accessor: b,
|
|
@@ -200,7 +202,8 @@ function p(e) {
|
|
|
200
202
|
faceted: F,
|
|
201
203
|
sort: I,
|
|
202
204
|
aggregate: L,
|
|
203
|
-
|
|
205
|
+
flash: R,
|
|
206
|
+
unsafeTanStack: z
|
|
204
207
|
})), h++;
|
|
205
208
|
}
|
|
206
209
|
return new t(Object.freeze(m));
|
|
@@ -218,5 +221,4 @@ function h(e) {
|
|
|
218
221
|
sortColumns: Object.freeze(t.flatMap((e) => e.sort ? [e.sort] : []))
|
|
219
222
|
});
|
|
220
223
|
}
|
|
221
|
-
//#endregion
|
|
222
224
|
export { h as columnStateSchema, p as defineColumns, m as readColumnDefinitions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/constrained-columns.ts
|
|
2
2
|
function e(e, t) {
|
|
3
3
|
return t !== void 0 && e.kind === t.kind && e.value === t.value;
|
|
4
4
|
}
|
|
@@ -45,5 +45,4 @@ function n(e, t, n, r) {
|
|
|
45
45
|
});
|
|
46
46
|
return a.filter((e) => !r.has(e.column) && (a.length !== i.length || e.column !== i[0]?.id));
|
|
47
47
|
}
|
|
48
|
-
//#endregion
|
|
49
48
|
export { t as constrainedColumnValues, n as summarizedColumns };
|