@gemologic/sheen-table 0.1.0-rc.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 (106) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +19 -0
  3. package/dist/DataTable.d.ts +159 -0
  4. package/dist/DataTable.js +2724 -0
  5. package/dist/DataTableToolbar.d.ts +28 -0
  6. package/dist/DataTableToolbar.js +132 -0
  7. package/dist/FilterBar.d.ts +24 -0
  8. package/dist/FilterBar.js +681 -0
  9. package/dist/QueryBuilder.d.ts +11 -0
  10. package/dist/QueryBuilder.js +693 -0
  11. package/dist/cell-edit.d.ts +50 -0
  12. package/dist/cell-edit.js +178 -0
  13. package/dist/client-state.d.ts +28 -0
  14. package/dist/client-state.js +57 -0
  15. package/dist/client-view.d.ts +31 -0
  16. package/dist/client-view.js +30 -0
  17. package/dist/column-layout.d.ts +10 -0
  18. package/dist/column-layout.js +34 -0
  19. package/dist/columns.d.ts +108 -0
  20. package/dist/columns.js +217 -0
  21. package/dist/core.d.ts +54 -0
  22. package/dist/core.js +28 -0
  23. package/dist/export.d.ts +14 -0
  24. package/dist/export.js +27 -0
  25. package/dist/facets.d.ts +15 -0
  26. package/dist/facets.js +41 -0
  27. package/dist/filter-bar-state.d.ts +22 -0
  28. package/dist/filter-bar-state.js +128 -0
  29. package/dist/filter-client.d.ts +9 -0
  30. package/dist/filter-client.js +69 -0
  31. package/dist/filter.d.ts +64 -0
  32. package/dist/filter.js +132 -0
  33. package/dist/grouping.d.ts +37 -0
  34. package/dist/grouping.js +126 -0
  35. package/dist/index.d.ts +7 -0
  36. package/dist/index.js +31 -0
  37. package/dist/messages.d.ts +115 -0
  38. package/dist/messages.js +121 -0
  39. package/dist/pagination.d.ts +36 -0
  40. package/dist/pagination.js +102 -0
  41. package/dist/query-builder-state.d.ts +28 -0
  42. package/dist/query-builder-state.js +128 -0
  43. package/dist/requests.d.ts +26 -0
  44. package/dist/requests.js +106 -0
  45. package/dist/row-hierarchy.d.ts +32 -0
  46. package/dist/row-hierarchy.js +170 -0
  47. package/dist/row-identity.d.ts +11 -0
  48. package/dist/row-identity.js +36 -0
  49. package/dist/saved-views.d.ts +52 -0
  50. package/dist/saved-views.js +153 -0
  51. package/dist/search-controller.d.ts +22 -0
  52. package/dist/search-controller.js +75 -0
  53. package/dist/search.d.ts +28 -0
  54. package/dist/search.js +111 -0
  55. package/dist/selection-client.d.ts +9 -0
  56. package/dist/selection-client.js +14 -0
  57. package/dist/selection.d.ts +25 -0
  58. package/dist/selection.js +60 -0
  59. package/dist/server-export.d.ts +27 -0
  60. package/dist/server-export.js +105 -0
  61. package/dist/sorting.d.ts +17 -0
  62. package/dist/sorting.js +58 -0
  63. package/dist/table-state-changes.d.ts +27 -0
  64. package/dist/table-state-changes.js +67 -0
  65. package/dist/table-state.d.ts +20 -0
  66. package/dist/table-state.js +77 -0
  67. package/dist/text-normalization.d.ts +2 -0
  68. package/dist/text-normalization.js +12 -0
  69. package/dist/url-state.d.ts +39 -0
  70. package/dist/url-state.js +75 -0
  71. package/package.json +66 -0
  72. package/src/DataTable.tsx +2322 -0
  73. package/src/DataTableToolbar.tsx +69 -0
  74. package/src/FilterBar.tsx +396 -0
  75. package/src/QueryBuilder.tsx +274 -0
  76. package/src/cell-edit.ts +187 -0
  77. package/src/client-state.ts +52 -0
  78. package/src/client-view.ts +61 -0
  79. package/src/column-layout.ts +47 -0
  80. package/src/columns.ts +271 -0
  81. package/src/core.ts +54 -0
  82. package/src/export.ts +39 -0
  83. package/src/facets.ts +46 -0
  84. package/src/filter-bar-state.ts +118 -0
  85. package/src/filter-client.ts +79 -0
  86. package/src/filter.ts +113 -0
  87. package/src/grouping.ts +185 -0
  88. package/src/index.ts +7 -0
  89. package/src/messages.ts +29 -0
  90. package/src/pagination.ts +81 -0
  91. package/src/query-builder-state.ts +105 -0
  92. package/src/requests.ts +85 -0
  93. package/src/row-hierarchy.ts +280 -0
  94. package/src/row-identity.ts +39 -0
  95. package/src/saved-views.ts +143 -0
  96. package/src/search-controller.ts +61 -0
  97. package/src/search.ts +137 -0
  98. package/src/selection-client.ts +23 -0
  99. package/src/selection.ts +62 -0
  100. package/src/server-export.ts +89 -0
  101. package/src/sorting.ts +63 -0
  102. package/src/styles.css +197 -0
  103. package/src/table-state-changes.ts +51 -0
  104. package/src/table-state.ts +72 -0
  105. package/src/text-normalization.ts +14 -0
  106. package/src/url-state.ts +62 -0
@@ -0,0 +1,23 @@
1
+ import { compileFilter } from "./filter-client.ts";
2
+ import type { FilterEvaluation } from "./filter-client.ts";
3
+ import type { FilterColumn } from "./filter.ts";
4
+ import type { BulkSelection } from "./selection.ts";
5
+
6
+ export interface ClientSelectionOptions<Row> extends FilterEvaluation<Row> {
7
+ readonly filterColumns: readonly FilterColumn[];
8
+ readonly getRowId: (row: Row) => string;
9
+ }
10
+
11
+ /** Resolve a captured selection against a complete client view, preserving its order and row identity. */
12
+ export function selectClientRows<Row>(rows: readonly Row[], selection: BulkSelection, options: ClientSelectionOptions<Row>): readonly Row[] {
13
+ const selected = new Set(selection.kind === "ids" ? selection.ids : selection.excluded);
14
+ for (const id of selected) if (typeof id !== "string" || !id.trim()) throw new Error("Invalid selection ID");
15
+ const matches = selection.kind === "query" ? compileFilter(selection.filter, options.filterColumns, options) : undefined;
16
+ const seen = new Set<string>();
17
+ return rows.filter(row => {
18
+ const id = options.getRowId(row);
19
+ if (typeof id !== "string" || !id.trim() || seen.has(id)) throw new Error("Client row IDs must be unique nonempty strings");
20
+ seen.add(id);
21
+ return selection.kind === "ids" ? selected.has(id) : !selected.has(id) && Boolean(matches?.(row));
22
+ });
23
+ }
@@ -0,0 +1,62 @@
1
+ import { parseFilter } from "./filter.ts";
2
+ import type { FilterColumn, FilterNode } from "./filter.ts";
3
+
4
+ export type BulkSelection =
5
+ | { readonly kind: "ids"; readonly ids: readonly string[] }
6
+ | { readonly kind: "query"; readonly filter: FilterNode; readonly excluded: readonly string[] };
7
+
8
+ function validatedIds(ids: readonly string[]): Set<string> {
9
+ const result = new Set<string>();
10
+ for (const id of ids) {
11
+ if (typeof id !== "string" || !id.trim() || result.has(id)) throw new Error("Loaded selection IDs must be unique nonempty strings");
12
+ result.add(id);
13
+ }
14
+ return result;
15
+ }
16
+
17
+ /** Owns selection IDs only. The app owns authorization, matching rows, and bulk execution. */
18
+ export function createTableSelection(initialFilter: FilterNode, columns: readonly FilterColumn[]) {
19
+ let filter = parseFilter(initialFilter, columns);
20
+ let filterKey = JSON.stringify(filter);
21
+ let loaded = new Set<string>();
22
+ let explicit = new Set<string>();
23
+ let excluded = new Set<string>();
24
+ let inverted = false;
25
+ function clear() { explicit = new Set(); excluded = new Set(); inverted = false; }
26
+ function setSelected(id: string, selected: boolean) {
27
+ if (!loaded.has(id)) throw new Error(`Selection changes require a loaded matching row: ${id}`);
28
+ if (inverted) { if (selected) excluded.delete(id); else excluded.add(id); }
29
+ else { if (selected) explicit.add(id); else explicit.delete(id); }
30
+ }
31
+ return {
32
+ /** Supply only IDs from the accepted matching page/view, not pending-query placeholders. */
33
+ setLoadedIds(ids: readonly string[]) { loaded = validatedIds(ids); },
34
+ setSelected,
35
+ selectLoaded(selected = true) { for (const id of loaded) setSelected(id, selected); },
36
+ selectRange(anchor: string, target: string, selected = true) {
37
+ if (!loaded.has(anchor) || !loaded.has(target)) throw new Error("Selection range endpoints must belong to the loaded matching view");
38
+ const ids = [...loaded];
39
+ const start = ids.indexOf(anchor);
40
+ const end = ids.indexOf(target);
41
+ for (const id of ids.slice(Math.min(start, end), Math.max(start, end) + 1)) setSelected(id, selected);
42
+ },
43
+ selectAllMatching() { explicit = new Set(); excluded = new Set(); inverted = true; },
44
+ isSelected(id: string) { return inverted ? loaded.has(id) && !excluded.has(id) : explicit.has(id); },
45
+ getPayload(): BulkSelection {
46
+ return inverted
47
+ ? Object.freeze({ kind: "query", filter, excluded: Object.freeze([...excluded]) })
48
+ : Object.freeze({ kind: "ids", ids: Object.freeze([...explicit]) });
49
+ },
50
+ /** Filter changes clear selection and loaded-row eligibility. Reapplying identical state does not. */
51
+ setFilter(value: FilterNode) {
52
+ const next = parseFilter(value, columns);
53
+ const key = JSON.stringify(next);
54
+ if (key !== filterKey) { clear(); loaded = new Set(); }
55
+ filter = next;
56
+ filterKey = key;
57
+ },
58
+ clear,
59
+ /** Clear both payload and eligibility when an account/permission boundary changes. */
60
+ reset() { clear(); loaded = new Set(); },
61
+ };
62
+ }
@@ -0,0 +1,89 @@
1
+ import { parseFilter } from "./filter.ts";
2
+ import type { BulkSelection } from "./selection.ts";
3
+ import { parseTableState } from "./table-state.ts";
4
+ import type { TableState, TableStateSchema } from "./table-state.ts";
5
+
6
+ export interface TableExportRequest {
7
+ readonly format: "csv" | "json";
8
+ readonly state: TableState;
9
+ /** null exports the whole matching view; explicit empty IDs export zero rows. */
10
+ readonly selection: BulkSelection | null;
11
+ }
12
+ export interface ServerExportSnapshot<Artifact> {
13
+ readonly accepted: { readonly request: TableExportRequest; readonly artifact: Artifact } | null;
14
+ readonly requested: TableExportRequest | null;
15
+ readonly pending: boolean;
16
+ readonly error: unknown;
17
+ }
18
+ export type ServerExportOutcome = "accepted" | "failed" | "busy" | "unavailable" | "canceled" | "disposed";
19
+
20
+ function capture(request: TableExportRequest, schema: TableStateSchema): TableExportRequest {
21
+ if (request.format !== "csv" && request.format !== "json") throw new Error("Unsupported table export format");
22
+ const state = parseTableState(request.state, schema);
23
+ let selection: BulkSelection | null = null;
24
+ if (request.selection !== null) {
25
+ const source = request.selection;
26
+ if (source.kind !== "ids" && source.kind !== "query") throw new Error("Invalid export selection kind");
27
+ const ids = source.kind === "ids" ? source.ids : source.excluded;
28
+ if (!Array.isArray(ids)) throw new Error("Export selection IDs must be an array");
29
+ const unique = new Set<string>();
30
+ for (const id of ids) {
31
+ if (typeof id !== "string" || !id.trim() || unique.has(id)) throw new Error("Export selection IDs must be unique nonempty strings");
32
+ unique.add(id);
33
+ }
34
+ selection = source.kind === "ids"
35
+ ? Object.freeze({ kind: "ids", ids: Object.freeze([...unique]) })
36
+ : Object.freeze({ kind: "query", filter: parseFilter(source.filter, schema.filterColumns), excluded: Object.freeze([...unique]) });
37
+ }
38
+ return Object.freeze({ format: request.format, state, selection });
39
+ }
40
+
41
+ /** App callback creates the artifact; only the accepted result should be offered for download. */
42
+ export function createServerExport<Artifact>(schema: TableStateSchema, onExport?: (request: TableExportRequest, signal: AbortSignal) => Promise<Artifact>) {
43
+ let snapshot: ServerExportSnapshot<Artifact> = { accepted: null, requested: null, pending: false, error: null };
44
+ let sequence = 0n;
45
+ let controller: AbortController | undefined;
46
+ let disposed = false;
47
+ let clearing = false;
48
+ async function request(value: TableExportRequest): Promise<ServerExportOutcome> {
49
+ if (disposed) return "disposed";
50
+ if (!onExport) return "unavailable";
51
+ if (clearing) return "canceled";
52
+ if (snapshot.pending) return "busy";
53
+ const token = ++sequence;
54
+ const current = new AbortController();
55
+ controller = current;
56
+ snapshot = { ...snapshot, requested: null, pending: true, error: null };
57
+ try {
58
+ const captured = capture(value, schema);
59
+ snapshot = { ...snapshot, requested: captured };
60
+ const artifact = await onExport(captured, current.signal);
61
+ if (disposed) return "disposed";
62
+ if (token !== sequence) return "canceled";
63
+ snapshot = { accepted: { request: captured, artifact }, requested: null, pending: false, error: null };
64
+ return "accepted";
65
+ } catch (error) {
66
+ if (disposed) return "disposed";
67
+ if (token !== sequence) return "canceled";
68
+ snapshot = { ...snapshot, pending: false, error };
69
+ return "failed";
70
+ } finally { if (token === sequence) controller = undefined; }
71
+ }
72
+ function clear() {
73
+ if (clearing) return;
74
+ clearing = true;
75
+ sequence++;
76
+ const previous = controller;
77
+ controller = undefined;
78
+ snapshot = { accepted: null, requested: null, pending: false, error: null };
79
+ try { previous?.abort(); } finally { clearing = false; }
80
+ }
81
+ return {
82
+ available: onExport !== undefined,
83
+ getSnapshot: () => snapshot,
84
+ request,
85
+ retry: () => snapshot.requested ? request(snapshot.requested) : Promise.resolve<ServerExportOutcome>(disposed ? "disposed" : onExport ? "failed" : "unavailable"),
86
+ clear,
87
+ dispose() { disposed = true; clear(); },
88
+ };
89
+ }
package/src/sorting.ts ADDED
@@ -0,0 +1,63 @@
1
+ export interface SortColumn {
2
+ readonly id: string;
3
+ readonly type: "text" | "number" | "date";
4
+ }
5
+ export interface SortEntry {
6
+ readonly column: string;
7
+ readonly direction: "asc" | "desc";
8
+ }
9
+ export type SortState = readonly SortEntry[];
10
+ export interface SortEvaluation<Row> {
11
+ readonly locale: string;
12
+ readonly getValue: (row: Row, column: string) => unknown;
13
+ }
14
+
15
+ /** Validate URL/app state without exposing an upstream table state shape. */
16
+ export function parseSorting(value: unknown, columns: readonly SortColumn[]): SortState {
17
+ const ids = new Set<string>();
18
+ for (const column of columns) {
19
+ if (typeof column.id !== "string" || !column.id.trim() || ids.has(column.id)) throw new Error("Invalid or duplicate sort column");
20
+ if (column.type !== "text" && column.type !== "number" && column.type !== "date") throw new Error(`Invalid sort type for ${column.id}`);
21
+ ids.add(column.id);
22
+ }
23
+ if (!Array.isArray(value) || value.length > ids.size) throw new Error("Invalid sorting: expected at most one entry per column");
24
+ const used = new Set<string>();
25
+ return Object.freeze(Array.from(value, (entry: unknown, index): SortEntry => {
26
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) throw new Error(`Invalid sorting at [${index}]: expected an entry`);
27
+ if (Object.keys(entry).some(key => key !== "column" && key !== "direction")) throw new Error(`Invalid sorting at [${index}]: unknown field`);
28
+ if (!("column" in entry) || typeof entry.column !== "string" || !ids.has(entry.column) || used.has(entry.column)) throw new Error(`Invalid sorting at [${index}]: unknown or duplicate column`);
29
+ if (!("direction" in entry) || (entry.direction !== "asc" && entry.direction !== "desc")) throw new Error(`Invalid sorting at [${index}]: expected asc or desc`);
30
+ used.add(entry.column);
31
+ return Object.freeze({ column: entry.column, direction: entry.direction });
32
+ }));
33
+ }
34
+
35
+ /** Sort the complete filtered view before pagination, retaining row identity and stable ties. */
36
+ export function sortClientRows<Row>(rows: readonly Row[], sorting: SortState, columns: readonly SortColumn[], options: SortEvaluation<Row>): readonly Row[] {
37
+ const state = parseSorting(sorting, columns);
38
+ const locale = Intl.getCanonicalLocales(options.locale)[0];
39
+ if (!locale) throw new Error("Sorting requires an explicit locale");
40
+ if (Intl.Collator.supportedLocalesOf([locale]).length === 0) throw new Error(`Unsupported sort locale: ${locale}`);
41
+ if (state.length === 0) return rows;
42
+ const compareText = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant", numeric: true }).compare;
43
+ const schema = new Map(columns.map(column => [column.id, column.type]));
44
+ const keys = state.map(entry => ({ ...entry, type: schema.get(entry.column) }));
45
+ const decorated = rows.map((row, index) => ({ row, index, values: keys.map(key => {
46
+ const value = options.getValue(row, key.column);
47
+ if (key.type === "text") return typeof value === "string" && value !== "" ? value.normalize("NFC") : null;
48
+ return typeof value === "number" && Number.isFinite(value) && (key.type !== "date" || Math.abs(value) <= 8.64e15) ? value : null;
49
+ }) }));
50
+ decorated.sort((a, b) => {
51
+ for (let index = 0; index < keys.length; index++) {
52
+ const left = a.values[index];
53
+ const right = b.values[index];
54
+ if (left === right) continue;
55
+ if (left === null || left === undefined) { if (right !== null && right !== undefined) return 1; continue; }
56
+ if (right === null || right === undefined) return -1;
57
+ const order = typeof left === "string" && typeof right === "string" ? compareText(left, right) : left < right ? -1 : left > right ? 1 : 0;
58
+ if (order !== 0) return keys[index]?.direction === "desc" ? -order : order;
59
+ }
60
+ return a.index - b.index;
61
+ });
62
+ return decorated.map(entry => entry.row);
63
+ }
package/src/styles.css ADDED
@@ -0,0 +1,197 @@
1
+ @layer theme, base, components, utilities;
2
+ @layer components {
3
+ .sheen-data-table { --sheen-color-focus-ring-offset: var(--sheen-color-bg); display: flex; flex-direction: column; min-inline-size: 0; color: var(--sheen-color-fg); background: var(--sheen-color-bg); border: var(--sheen-data-table-frame-border, 1px solid var(--sheen-color-border)); border-radius: var(--sheen-data-table-frame-radius, var(--sheen-surface-radius)); overflow: clip; }
4
+ .sheen-data-table[data-variant="integrated"] { --sheen-data-table-frame-border: 0; --sheen-data-table-frame-radius: 0; --sheen-data-table-viewport-height: 100%; block-size: 100%; min-block-size: 0; }
5
+ .sheen-data-table[data-variant="framed"] { --sheen-data-table-frame-border: 1px solid var(--sheen-color-border); --sheen-data-table-frame-radius: var(--sheen-surface-radius); --sheen-data-table-viewport-height: var(--sheen-data-table-initial-viewport-height); }
6
+ .sheen-data-table-toolbar { container: sheen-table-toolbar / inline-size; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--sheen-space-inline-sm); min-block-size: var(--sheen-control-h-md); padding: var(--sheen-space-block-xs) var(--sheen-space-inline-sm); background: var(--sheen-color-bg-raised); border-block-end: 1px solid var(--sheen-color-border); }
7
+ .sheen-data-table-toolbar-query { display: flex; flex: 1 1 32rem; flex-wrap: wrap; align-items: center; gap: var(--sheen-space-inline-sm); min-inline-size: 0; }
8
+ .sheen-data-table-search-field { display: flex; flex: 1 1 18rem; align-items: stretch; min-inline-size: 12rem; max-inline-size: 28rem; }
9
+ .sheen-data-table-search-field .sheen-field-label { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
10
+ .sheen-data-table-search-field > .sheen-field { flex: 1 1 auto; min-inline-size: 0; }
11
+ .sheen-data-table-search-field .sheen-input-group { inline-size: 100%; }
12
+ .sheen-data-table-search { min-inline-size: 0; }
13
+ .sheen-data-table-search-field > [data-sheen-menu-trigger] { flex: none; margin-inline-start: var(--sheen-space-inline-xs); color: var(--sheen-color-fg-muted); }
14
+ .sheen-data-table-search-field[data-search-mode="exact"] > [data-sheen-menu-trigger] { color: var(--sheen-color-accent-fg); background: var(--sheen-color-accent-subtle); border-color: var(--sheen-color-accent-border); }
15
+ .sheen-data-table-result-count, .sheen-data-table-export-status { align-self: center; color: var(--sheen-color-fg-muted); font-size: var(--sheen-text-ui-sm-size); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; white-space: nowrap; }
16
+ .sheen-data-table-result-count[data-previous] { display: inline-flex; align-items: center; gap: var(--sheen-space-inline-xs); }
17
+ .sheen-data-table-previous-label { padding: 0.1rem var(--sheen-space-inline-xs); color: var(--sheen-color-warning-fg); background: var(--sheen-color-warning-subtle); border: 1px solid var(--sheen-color-warning-border); border-radius: var(--sheen-control-radius); font-size: var(--sheen-text-caption-size); font-weight: var(--sheen-text-h4-weight); line-height: var(--sheen-text-caption-leading); }
18
+ .sheen-data-table-toolbar-status, .sheen-data-table-toolbar-actions, .sheen-data-table-toolbar-action, .sheen-data-table-toolbar-overflow { display: flex; align-items: center; min-inline-size: 0; }
19
+ .sheen-data-table-toolbar-actions { gap: var(--sheen-space-inline-xs); }
20
+ .sheen-data-table-toolbar-overflow { display: none; }
21
+ .sheen-data-table-toolbar :is(.sheen-button, [data-sheen-menu-trigger]) { min-block-size: var(--sheen-control-h-md); block-size: var(--sheen-control-h-md); padding-block: 0; font-size: var(--sheen-text-ui-sm-size); }
22
+ .sheen-filter-bar { display: flex; flex: 1 1 18rem; flex-wrap: wrap; align-items: center; gap: var(--sheen-space-inline-sm); min-inline-size: 0; }
23
+ .sheen-filter-list { display: contents; margin: 0; padding: 0; list-style: none; }
24
+ .sheen-filter-chip { display: inline-flex; align-items: stretch; min-inline-size: 0; border: 1px solid var(--sheen-color-border-control); border-radius: var(--sheen-control-radius); background: var(--sheen-color-bg-raised); }
25
+ .sheen-filter-chip > .sheen-button { min-inline-size: 0; max-inline-size: 20rem; border: 0; border-start-end-radius: 0; border-end-end-radius: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
26
+ .sheen-filter-remove { flex: 0 0 2rem; min-inline-size: 24px; min-block-size: 24px; padding: 0; color: var(--sheen-color-fg-muted); background: transparent; border: 0; border-inline-start: 1px solid var(--sheen-color-border-control); border-start-end-radius: var(--sheen-control-radius); border-end-end-radius: var(--sheen-control-radius); cursor: pointer; }
27
+ .sheen-filter-remove:hover { color: var(--sheen-color-fg); background: var(--sheen-color-bg-hover); }
28
+ .sheen-filter-remove:disabled { cursor: wait; opacity: 0.65; }
29
+ .sheen-filter-remove:focus-visible { outline: var(--sheen-focus-ring-width) solid var(--sheen-color-focus-ring); outline-offset: var(--sheen-focus-ring-offset); }
30
+ .sheen-filter-add { display: inline-flex; }
31
+ .sheen-filter-picker, .sheen-filter-editor { inline-size: min(24rem, calc(100vw - 2rem)); }
32
+ .sheen-filter-column-list { display: grid; gap: var(--sheen-space-block-xs); max-block-size: 16rem; margin: var(--sheen-space-block-sm) 0 0; padding: 0; overflow: auto; list-style: none; }
33
+ .sheen-filter-column-list .sheen-button { justify-content: flex-start; inline-size: 100%; }
34
+ .sheen-filter-editor-form { display: grid; gap: var(--sheen-space-block-md); }
35
+ .sheen-filter-error { margin: 0; color: var(--sheen-color-danger-fg); }
36
+ @container sheen-table-toolbar (max-width: 34rem) {
37
+ .sheen-data-table-toolbar-action { display: none; }
38
+ .sheen-data-table-toolbar-overflow { display: flex; }
39
+ }
40
+ .sheen-data-table-frame { position: relative; flex: 1 1 auto; min-inline-size: 0; min-block-size: 0; }
41
+ .sheen-data-table-viewport { min-inline-size: 0; block-size: var(--sheen-data-table-viewport-height, var(--sheen-data-table-initial-viewport-height)); overflow: auto; background: var(--sheen-color-bg); contain: strict; }
42
+ .sheen-data-table table { display: grid; min-inline-size: 100%; border-collapse: collapse; }
43
+ .sheen-data-table caption { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
44
+ .sheen-data-table thead { position: sticky; inset-block-start: 0; z-index: var(--sheen-z-chrome); display: grid; background: var(--sheen-color-bg-raised); border-block-end: 1px solid var(--sheen-color-border); }
45
+ .sheen-data-table thead tr, .sheen-data-table tbody tr, .sheen-data-table tfoot tr { display: grid; align-items: center; inline-size: 100%; min-block-size: var(--sheen-table-row-h); }
46
+ .sheen-data-table th, .sheen-data-table td { box-sizing: border-box; min-inline-size: 0; block-size: var(--sheen-table-row-h); padding: var(--sheen-space-block-xs) var(--sheen-space-inline-md); overflow: hidden; text-align: start; text-overflow: ellipsis; white-space: nowrap; }
47
+ .sheen-data-table th { position: relative; overflow: visible; font-size: var(--sheen-text-ui-sm-size); line-height: var(--sheen-text-ui-sm-leading); font-weight: var(--sheen-text-h4-weight); color: var(--sheen-color-fg-muted); }
48
+ .sheen-data-table-header-content { display: flex; align-items: center; gap: var(--sheen-space-inline-xs); min-inline-size: 0; }
49
+ .sheen-data-table-header-label, .sheen-data-table-sort { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
50
+ .sheen-data-table-sort { display: flex; flex: 1 1 auto; align-items: center; min-block-size: 24px; gap: var(--sheen-space-inline-xs); color: inherit; background: transparent; border: 0; text-align: inherit; cursor: pointer; }
51
+ .sheen-data-table-sort-label { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
52
+ .sheen-data-table-sort-indicator { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 0.15rem; color: var(--sheen-color-accent); }
53
+ .sheen-data-table-sort-direction { font-size: 0.9em; line-height: 1; }
54
+ .sheen-data-table-sort-priority { display: grid; place-items: center; min-inline-size: 1rem; block-size: 1rem; padding-inline: 0.2rem; color: var(--sheen-color-accent-fg); background: var(--sheen-color-accent-subtle); border: 1px solid var(--sheen-color-accent-border); border-radius: var(--sheen-control-radius); font-size: var(--sheen-text-caption-size); line-height: 1; }
55
+ .sheen-data-table th[data-sort-direction] { color: var(--sheen-color-fg); }
56
+ .sheen-data-table-sort:disabled { cursor: wait; }
57
+ .sheen-data-table-reorder { display: grid; flex: 0 0 auto; place-items: center; inline-size: 24px; block-size: 24px; padding: 0; color: var(--sheen-color-fg-subtle); background: transparent; border: 0; border-radius: var(--sheen-control-radius); opacity: 0; cursor: grab; touch-action: none; }
58
+ .sheen-data-table-reorder-grip { inline-size: 0.65rem; block-size: 0.9rem; background-image: radial-gradient(circle, currentColor 1px, transparent 1.5px); background-position: 0 0; background-size: 0.325rem 0.325rem; }
59
+ .sheen-data-table th:hover .sheen-data-table-reorder, .sheen-data-table th:focus-within .sheen-data-table-reorder, .sheen-data-table[data-reordering] .sheen-data-table-reorder { color: var(--sheen-color-fg-muted); opacity: 1; }
60
+ .sheen-data-table-reorder:active { cursor: grabbing; }
61
+ .sheen-data-table-resizer { position: absolute; z-index: 2; inset-block: 0; inset-inline-end: 0; inline-size: 24px; padding: 0; background: transparent; border: 0; cursor: col-resize; touch-action: none; }
62
+ .sheen-data-table-resizer::after { content: ""; position: absolute; inset-block: 20%; inset-inline-start: calc(50% - 1px); inline-size: 2px; border-radius: 1px; background: transparent; }
63
+ .sheen-data-table-resizer:hover::after, .sheen-data-table-resizer[data-resizing]::after, .sheen-data-table-resizer:focus-visible::after { background: var(--sheen-color-accent); }
64
+ .sheen-data-table-sort:focus-visible, .sheen-data-table-reorder:focus-visible, .sheen-data-table-resizer:focus-visible { outline: var(--sheen-focus-ring-width) solid var(--sheen-color-focus-ring); outline-offset: var(--sheen-focus-ring-offset); }
65
+ .sheen-data-table[data-resizing] { cursor: col-resize; user-select: none; }
66
+ .sheen-data-table[data-reordering] th[data-drop-placement]::before { content: ""; position: absolute; z-index: 3; inset-block: 0; inline-size: 3px; background: var(--sheen-color-accent); }
67
+ .sheen-data-table[data-reordering] th[data-drop-placement="before"]::before { inset-inline-start: 0; }
68
+ .sheen-data-table[data-reordering] th[data-drop-placement="after"]::before { inset-inline-end: 0; }
69
+ .sheen-data-table tbody { position: relative; display: grid; min-inline-size: 100%; }
70
+ .sheen-data-table tfoot { position: sticky; z-index: var(--sheen-z-chrome); inset-block-end: 0; display: grid; min-inline-size: 100%; color: var(--sheen-color-fg); background: var(--sheen-color-bg-raised); border-block-start: 1px solid var(--sheen-color-border-control); font-weight: var(--sheen-text-h4-weight); }
71
+ .sheen-data-table tfoot td[data-pin] { z-index: calc(var(--sheen-z-chrome) + 1); background: var(--sheen-color-bg-raised); }
72
+ .sheen-data-table tbody tr:not(.sheen-data-table-empty) { --sheen-table-row-bg: var(--sheen-color-bg); position: absolute; inset-block-start: 0; inset-inline-start: 0; box-sizing: border-box; align-items: center; border-block-end: 1px solid var(--sheen-color-border); background: var(--sheen-table-row-bg); }
73
+ .sheen-data-table tbody tr[data-group-id] { --sheen-table-row-bg: var(--sheen-color-bg-raised); font-weight: var(--sheen-text-h4-weight); }
74
+ .sheen-data-table tbody tr[data-selected] { --sheen-table-row-bg: var(--sheen-color-bg-selected); }
75
+ @media (hover: hover) { .sheen-data-table tbody tr[data-row-id]:hover { --sheen-table-row-bg: var(--sheen-color-bg-hover); } }
76
+ .sheen-data-table tbody tr[data-row-id]:focus-visible { --sheen-table-row-bg: var(--sheen-color-bg-hover); }
77
+ @media (hover: hover) { .sheen-data-table tbody tr[data-row-id][data-selected]:hover { --sheen-table-row-bg: color-mix(in oklch, var(--sheen-color-bg-selected) 82%, var(--sheen-color-bg-hover)); } }
78
+ .sheen-data-table tbody tr[data-row-id][data-selected]:focus-visible { --sheen-table-row-bg: color-mix(in oklch, var(--sheen-color-bg-selected) 82%, var(--sheen-color-bg-hover)); }
79
+ .sheen-data-table[data-previous-results] tbody tr[data-row-id] { --sheen-table-row-bg: color-mix(in oklch, var(--sheen-color-bg) 92%, var(--sheen-color-warning-subtle)); }
80
+ .sheen-data-table[data-previous-results] tbody tr[data-row-id][data-selected] { --sheen-table-row-bg: color-mix(in oklch, var(--sheen-color-bg-selected) 84%, var(--sheen-color-warning-subtle)); }
81
+ @media (hover: hover) { .sheen-data-table[data-previous-results] tbody tr[data-row-id]:hover { --sheen-table-row-bg: color-mix(in oklch, var(--sheen-color-bg-hover) 88%, var(--sheen-color-warning-subtle)); } }
82
+ .sheen-data-table[data-previous-results] tbody tr[data-row-id]:focus-visible { --sheen-table-row-bg: color-mix(in oklch, var(--sheen-color-bg-hover) 88%, var(--sheen-color-warning-subtle)); }
83
+ @media (hover: hover) { .sheen-data-table[data-previous-results] tbody tr[data-row-id][data-selected]:hover { --sheen-table-row-bg: color-mix(in oklch, color-mix(in oklch, var(--sheen-color-bg-selected) 82%, var(--sheen-color-bg-hover)) 84%, var(--sheen-color-warning-subtle)); } }
84
+ .sheen-data-table[data-previous-results] tbody tr[data-row-id][data-selected]:focus-visible { --sheen-table-row-bg: color-mix(in oklch, color-mix(in oklch, var(--sheen-color-bg-selected) 82%, var(--sheen-color-bg-hover)) 84%, var(--sheen-color-warning-subtle)); }
85
+ .sheen-data-table tbody tr[data-load-error] { border-inline-start: 3px solid var(--sheen-color-danger-border); }
86
+ .sheen-data-table-selection-cell { position: sticky; z-index: var(--sheen-z-chrome); inset-inline-start: 0; display: grid; place-items: center; padding-inline: var(--sheen-space-inline-sm); overflow: visible; background: var(--sheen-table-row-bg, var(--sheen-color-bg)); }
87
+ .sheen-data-table thead .sheen-data-table-selection-cell { z-index: calc(var(--sheen-z-chrome) + 2); background: var(--sheen-color-bg-raised); }
88
+ .sheen-data-table-selection-control, .sheen-data-table-selection-control .sheen-checkbox-row { min-block-size: 0; }
89
+ .sheen-data-table-selection-control .sheen-checkbox-row { gap: 0; }
90
+ .sheen-data-table-selection-control .sheen-checkbox-label { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
91
+ .sheen-data-table th[data-pin], .sheen-data-table td[data-pin] { position: sticky; z-index: calc(var(--sheen-z-chrome) - 1); background: var(--sheen-table-row-bg, var(--sheen-color-bg)); }
92
+ .sheen-data-table th[data-pin] { z-index: calc(var(--sheen-z-chrome) + 1); background: var(--sheen-color-bg-raised); }
93
+ .sheen-data-table [data-pin-edge]::before { content: ""; position: absolute; z-index: 1; inset-block: 0; inline-size: 1px; background: var(--sheen-color-border-control); box-shadow: 0 0 0.55rem color-mix(in oklch, var(--sheen-color-fg) 22%, transparent); pointer-events: none; }
94
+ .sheen-data-table [data-pin-edge="start"]::before { inset-inline-end: 0; }
95
+ .sheen-data-table [data-pin-edge="end"]::before { inset-inline-start: 0; }
96
+ .sheen-data-table tbody tr:focus-visible { outline: var(--sheen-focus-ring-width) solid var(--sheen-color-focus-ring); outline-offset: calc(-1 * var(--sheen-focus-ring-width)); }
97
+ .sheen-data-table-tree-cell { display: flex; align-items: center; gap: var(--sheen-space-inline-xs); min-inline-size: 0; padding-inline-start: calc(var(--sheen-table-depth, 0) * var(--sheen-space-inline-lg)); }
98
+ .sheen-data-table-expander, .sheen-data-table-expander-space { flex: 0 0 1.5rem; inline-size: 1.5rem; block-size: 1.5rem; padding: 0; }
99
+ .sheen-data-table-expander { color: var(--sheen-color-fg-muted); background: transparent; border: 0; border-radius: var(--sheen-control-radius); cursor: pointer; }
100
+ .sheen-data-table-expander:disabled { cursor: wait; }
101
+ .sheen-data-table-expander:focus-visible, .sheen-data-table-row-status button:focus-visible { outline: var(--sheen-focus-ring-width) solid var(--sheen-color-focus-ring); outline-offset: var(--sheen-focus-ring-offset); }
102
+ .sheen-data-table-tree-value, .sheen-data-table-group-label { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
103
+ .sheen-data-table-group-count, .sheen-data-table-row-status { color: var(--sheen-color-fg-muted); font-size: var(--sheen-text-ui-sm-size); font-weight: var(--sheen-text-ui-sm-weight); }
104
+ .sheen-data-table-row-status { display: inline-flex; align-items: center; gap: var(--sheen-space-inline-xs); }
105
+ .sheen-data-table-row-status button { padding: 0; color: var(--sheen-color-danger-fg); background: transparent; border: 0; text-decoration: underline; cursor: pointer; }
106
+ .sheen-data-table[data-variable-height] tbody td { block-size: auto; min-block-size: var(--sheen-table-row-h); overflow-wrap: anywhere; white-space: normal; }
107
+ .sheen-data-table td[data-align="center"] { text-align: center; }
108
+ .sheen-data-table td[data-align="end"] { text-align: end; }
109
+ .sheen-data-table td[data-numeric] { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
110
+ .sheen-data-table td[data-editable]:not([data-pin]) { position: relative; }
111
+ .sheen-data-table td[data-editable][data-stale] { box-shadow: inset 3px 0 0 var(--sheen-color-warning-border); }
112
+ .sheen-data-table td[data-editable][data-invalid], .sheen-data-table td[data-editable][data-conflict] { z-index: calc(var(--sheen-z-chrome) + 3); overflow: visible; }
113
+ .sheen-data-table-edit-value { display: flex; align-items: center; gap: var(--sheen-space-inline-xs); min-inline-size: 0; }
114
+ .sheen-data-table-edit-rest { display: block; min-inline-size: 0; inline-size: 100%; overflow: hidden; border-radius: var(--sheen-control-radius); text-overflow: ellipsis; white-space: nowrap; cursor: text; }
115
+ .sheen-data-table-edit-rest:focus-visible { outline: var(--sheen-focus-ring-width) solid var(--sheen-color-focus-ring); outline-offset: var(--sheen-focus-ring-offset); }
116
+ .sheen-data-table-editor { box-sizing: border-box; min-inline-size: 0; inline-size: 100%; block-size: calc(var(--sheen-table-row-h) - 0.35rem); padding-inline: var(--sheen-space-inline-xs); color: var(--sheen-color-fg); background: var(--sheen-color-bg-inset); border: 1px solid var(--sheen-color-border-control); border-radius: var(--sheen-control-radius); font: inherit; }
117
+ .sheen-data-table-editor-boolean { inline-size: 1rem; block-size: 1rem; padding: 0; accent-color: var(--sheen-color-accent); }
118
+ .sheen-data-table-editor:focus-visible { outline: var(--sheen-focus-ring-width) solid var(--sheen-color-focus-ring); outline-offset: var(--sheen-focus-ring-offset); }
119
+ .sheen-data-table-edit-message { position: absolute; inset-block-start: calc(100% - 1px); inset-inline-start: var(--sheen-space-inline-sm); min-inline-size: min(16rem, calc(100vw - 2rem)); max-inline-size: 24rem; padding: var(--sheen-space-inline-xs) var(--sheen-space-inline-sm); color: var(--sheen-color-danger-fg); background: var(--sheen-color-bg-overlay); border: 1px solid var(--sheen-color-danger-border); border-radius: var(--sheen-surface-radius); box-shadow: var(--sheen-shadow-3); font-size: var(--sheen-text-ui-sm-size); line-height: var(--sheen-text-ui-sm-leading); white-space: normal; }
120
+ .sheen-data-table-empty { min-block-size: var(--sheen-table-row-h); }
121
+ .sheen-data-table-empty td { grid-column: 1 / -1; block-size: auto; min-block-size: var(--sheen-table-row-h); padding: 0; overflow: visible; white-space: normal; color: var(--sheen-color-fg-muted); }
122
+ .sheen-data-table-state { display: grid; justify-items: start; gap: var(--sheen-space-block-sm); padding: var(--sheen-space-section); color: var(--sheen-color-fg); }
123
+ .sheen-data-table-state-label { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
124
+ .sheen-data-table-cold { display: grid; gap: 1px; visibility: hidden; }
125
+ .sheen-data-table-cold[data-visible] { visibility: visible; }
126
+ .sheen-data-table-skeleton-row { display: grid; align-items: center; gap: var(--sheen-space-inline-md); min-block-size: var(--sheen-table-row-h); padding-inline: var(--sheen-space-inline-md); border-block-end: 1px solid var(--sheen-color-border); }
127
+ .sheen-data-table-skeleton-row .sheen-skeleton { inline-size: min(80%, 12rem); }
128
+ .sheen-data-table-refresh { position: absolute; z-index: calc(var(--sheen-z-chrome) + 4); inset-block-start: 1px; inset-inline: 1px; block-size: 2px; pointer-events: none; }
129
+ .sheen-data-table-refresh::before { content: ""; display: block; inline-size: 35%; block-size: 100%; background: var(--sheen-color-accent); animation: sheen-table-refresh var(--sheen-duration-slow) linear infinite alternate; }
130
+ .sheen-data-table-refresh span { position: absolute; inset-block-start: var(--sheen-space-block-xs); inset-inline-end: var(--sheen-space-inline-xs); padding: 0.15rem var(--sheen-space-inline-xs); color: var(--sheen-color-fg-muted); background: var(--sheen-color-bg-raised); border: 1px solid var(--sheen-color-border-control); border-radius: var(--sheen-control-radius); box-shadow: var(--sheen-shadow-1); font-size: var(--sheen-text-ui-sm-size); line-height: var(--sheen-text-ui-sm-leading); white-space: nowrap; }
131
+ .sheen-data-table-selection-actions { --sheen-color-focus-ring-offset: var(--sheen-color-bg-raised); position: absolute; z-index: calc(var(--sheen-z-overlay) - 1); inset-block-end: var(--sheen-space-block-md); inset-inline-start: 50%; display: flex; align-items: center; gap: var(--sheen-space-inline-sm); inline-size: max-content; max-inline-size: calc(100% - 2 * var(--sheen-space-inline-md)); padding: var(--sheen-space-block-sm) var(--sheen-space-inline-sm); overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; color: var(--sheen-color-fg); background: color-mix(in oklch, var(--sheen-color-bg-raised) 96%, var(--sheen-color-accent-subtle)); border: 1px solid var(--sheen-color-border-control); border-radius: var(--sheen-surface-radius); box-shadow: var(--sheen-elevation-overlay); translate: -50% 0; }
132
+ .sheen-data-table-selection-actions[data-open="true"] { animation: sheen-table-selection-enter var(--sheen-duration-fast) var(--sheen-ease-entrance); }
133
+ .sheen-data-table-selection-actions[data-open="false"] { opacity: 0; pointer-events: none; animation: sheen-table-selection-exit var(--sheen-duration-fast) var(--sheen-ease-exit); }
134
+ .sheen-data-table-selection-actions strong { flex: 0 0 auto; padding-inline: var(--sheen-space-inline-xs) var(--sheen-space-inline-sm); border-inline-end: 1px solid var(--sheen-color-border); font-size: var(--sheen-text-ui-sm-size); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
135
+ .sheen-data-table-error { display: flex; align-items: center; justify-content: space-between; gap: var(--sheen-space-inline-md); padding: var(--sheen-space-inline-sm); color: var(--sheen-color-danger-fg); background: var(--sheen-color-danger-subtle); border: 1px solid var(--sheen-color-danger-border); border-radius: var(--sheen-surface-radius); }
136
+ .sheen-data-table-pagination { justify-content: flex-end; min-block-size: var(--sheen-control-h-sm); padding: var(--sheen-space-block-xs) var(--sheen-space-inline-sm); background: var(--sheen-color-bg-raised); border-block-start: 1px solid var(--sheen-color-border); }
137
+ .sheen-data-table-mobile { display: none; }
138
+ .sheen-query-builder { --sheen-color-focus-ring-offset: var(--sheen-color-bg); display: grid; gap: var(--sheen-space-block-sm); min-inline-size: 0; color: var(--sheen-color-fg); }
139
+ .sheen-query-builder[data-disabled] { opacity: 0.72; }
140
+ .sheen-query-group, .sheen-query-not, .sheen-query-rule { min-inline-size: 0; margin: 0; padding: var(--sheen-space-block-sm) var(--sheen-space-inline-sm); background: var(--sheen-color-bg); border: 1px solid var(--sheen-color-border-control); border-radius: var(--sheen-surface-radius); }
141
+ .sheen-query-group > legend { padding-inline: var(--sheen-space-inline-xs); color: var(--sheen-color-fg-muted); font-size: var(--sheen-text-ui-sm-size); font-weight: var(--sheen-text-h4-weight); }
142
+ .sheen-query-group-toolbar, .sheen-query-not-toolbar, .sheen-query-node-actions { display: flex; flex-wrap: wrap; align-items: end; gap: var(--sheen-space-inline-xs); min-inline-size: 0; }
143
+ .sheen-query-group-toolbar > .sheen-select { min-inline-size: 9rem; }
144
+ .sheen-query-node-actions { margin-inline-start: auto; }
145
+ .sheen-query-children { display: grid; gap: var(--sheen-space-block-xs); margin: var(--sheen-space-block-sm) 0 0; padding: 0; list-style: none; }
146
+ .sheen-query-children > li { min-inline-size: 0; }
147
+ .sheen-query-children .sheen-query-group, .sheen-query-children .sheen-query-not { margin-inline-start: var(--sheen-space-inline-md); }
148
+ .sheen-query-not { display: grid; gap: var(--sheen-space-block-xs); background: color-mix(in oklch, var(--sheen-color-bg) 92%, var(--sheen-color-warning-subtle)); }
149
+ .sheen-query-not-toolbar strong { align-self: center; color: var(--sheen-color-warning-fg); font-size: var(--sheen-text-ui-sm-size); }
150
+ .sheen-query-rule { display: flex; align-items: end; gap: var(--sheen-space-inline-xs); }
151
+ .sheen-query-rule-fields { display: grid; flex: 1 1 auto; grid-template-columns: minmax(8rem, 1fr) minmax(8rem, 1fr) minmax(10rem, 1.4fr) auto; align-items: end; gap: var(--sheen-space-inline-xs); min-inline-size: 0; }
152
+ .sheen-query-rule-fields > :is(.sheen-field, .sheen-select, .sheen-checkbox-group, .sheen-switch) { min-inline-size: 0; }
153
+ .sheen-query-rule-fields :is(.sheen-field-label, .sheen-checkbox-group-label) { font-size: var(--sheen-text-caption-size); line-height: var(--sheen-text-caption-leading); }
154
+ .sheen-query-empty { margin: var(--sheen-space-block-sm) 0 0; color: var(--sheen-color-fg-muted); font-size: var(--sheen-text-ui-sm-size); }
155
+ .sheen-query-announcement { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
156
+ @media (max-width: 767px) {
157
+ .sheen-query-rule { display: grid; }
158
+ .sheen-query-rule-fields { grid-template-columns: minmax(0, 1fr); }
159
+ .sheen-query-node-actions { justify-content: flex-end; margin-inline-start: 0; }
160
+ .sheen-query-children .sheen-query-group, .sheen-query-children .sheen-query-not { margin-inline-start: var(--sheen-space-inline-xs); }
161
+ .sheen-data-table[data-mobile-layout] { border: 0; border-radius: 0; overflow: visible; background: transparent; }
162
+ .sheen-data-table[data-mobile-layout] .sheen-data-table-viewport { display: none; }
163
+ .sheen-data-table[data-mobile-layout] .sheen-data-table-mobile { display: grid; gap: var(--sheen-space-block-sm); min-inline-size: 0; }
164
+ .sheen-data-table[data-mobile-layout][data-selection] .sheen-data-table-mobile { padding-block-end: calc(var(--sheen-control-h-sm) + 2 * var(--sheen-space-block-lg)); }
165
+ .sheen-data-table[data-mobile-layout] .sheen-data-table-toolbar { justify-content: stretch; }
166
+ .sheen-data-table[data-mobile-layout] .sheen-data-table-search-field { flex-basis: 100%; max-inline-size: none; margin-inline-end: 0; }
167
+ .sheen-data-table[data-mobile-layout] .sheen-filter-bar { flex-basis: 100%; }
168
+ .sheen-data-table-mobile-list { display: grid; gap: var(--sheen-space-block-sm); min-inline-size: 0; }
169
+ .sheen-data-table-mobile-card { --sheen-color-focus-ring-offset: var(--sheen-color-bg); display: grid; gap: var(--sheen-space-block-sm); min-inline-size: 0; padding: var(--sheen-space-block-md) var(--sheen-space-inline-md); overflow: visible; background: var(--sheen-color-bg); border: 1px solid var(--sheen-color-border); border-radius: var(--sheen-surface-radius); box-shadow: var(--sheen-shadow-1); }
170
+ .sheen-data-table-mobile-card[data-selected] { background: var(--sheen-color-bg-selected); border-color: var(--sheen-color-border-control); }
171
+ .sheen-data-table-mobile-card[data-load-error] { border-inline-start: 3px solid var(--sheen-color-danger-border); }
172
+ .sheen-data-table-mobile-card:focus-visible { outline: var(--sheen-focus-ring-width) solid var(--sheen-color-focus-ring); outline-offset: var(--sheen-focus-ring-offset); }
173
+ .sheen-data-table-mobile-card-header { display: flex; align-items: center; gap: var(--sheen-space-inline-sm); min-inline-size: 0; }
174
+ .sheen-data-table-mobile-title { flex: 1 1 auto; min-inline-size: 0; font-size: var(--sheen-text-h4-size); line-height: var(--sheen-text-h4-leading); font-weight: var(--sheen-text-h4-weight); overflow-wrap: anywhere; }
175
+ .sheen-data-table-mobile-fields, .sheen-data-table-mobile-footer { display: grid; gap: var(--sheen-space-block-xs); min-inline-size: 0; margin: 0; }
176
+ .sheen-data-table-mobile-field { display: grid; grid-template-columns: minmax(5rem, 0.7fr) minmax(0, 1.3fr); align-items: baseline; gap: var(--sheen-space-inline-md); min-inline-size: 0; }
177
+ .sheen-data-table-mobile-field dt { color: var(--sheen-color-fg-muted); font-size: var(--sheen-text-ui-sm-size); line-height: var(--sheen-text-ui-sm-leading); }
178
+ .sheen-data-table-mobile-field dd { min-inline-size: 0; margin: 0; overflow-wrap: anywhere; }
179
+ .sheen-data-table-mobile-value { min-inline-size: 0; }
180
+ .sheen-data-table-mobile-value[data-align="center"] { text-align: center; }
181
+ .sheen-data-table-mobile-value[data-align="end"] { text-align: end; }
182
+ .sheen-data-table-mobile-value[data-numeric] { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
183
+ .sheen-data-table-mobile-value[data-editable] { position: relative; }
184
+ .sheen-data-table-mobile-value[data-stale] { box-shadow: inset 3px 0 0 var(--sheen-color-warning-border); }
185
+ .sheen-data-table-mobile-value[data-invalid], .sheen-data-table-mobile-value[data-conflict] { z-index: calc(var(--sheen-z-chrome) + 3); }
186
+ .sheen-data-table-mobile-controls { display: flex; align-items: center; justify-content: flex-end; gap: var(--sheen-space-inline-sm); }
187
+ .sheen-data-table-mobile-footer { padding: var(--sheen-space-block-md) var(--sheen-space-inline-md); background: var(--sheen-color-bg-raised); border: 1px solid var(--sheen-color-border-control); border-radius: var(--sheen-surface-radius); font-weight: var(--sheen-text-h4-weight); }
188
+ .sheen-data-table-mobile-cold { display: grid; gap: var(--sheen-space-block-sm); visibility: hidden; }
189
+ .sheen-data-table-mobile-cold[data-visible] { visibility: visible; }
190
+ .sheen-data-table-mobile-skeleton { display: grid; gap: var(--sheen-space-block-sm); min-block-size: 7rem; padding: var(--sheen-space-block-md) var(--sheen-space-inline-md); border: 1px solid var(--sheen-color-border); border-radius: var(--sheen-surface-radius); }
191
+ .sheen-data-table-mobile-skeleton .sheen-skeleton { inline-size: min(80%, 12rem); }
192
+ .sheen-data-table-mobile-pagination { justify-content: center; }
193
+ }
194
+ @keyframes sheen-table-refresh { from { translate: -100% 0; } to { translate: 285% 0; } }
195
+ @keyframes sheen-table-selection-enter { from { opacity: 0; transform: translateY(0.35rem); } to { opacity: 1; transform: translateY(0); } }
196
+ @keyframes sheen-table-selection-exit { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(0.35rem); } }
197
+ }
@@ -0,0 +1,51 @@
1
+ import { changeClientViewState } from "./client-state.ts";
2
+ import type { ClientStateChange } from "./client-state.ts";
3
+ import type { SortEntry, SortState } from "./sorting.ts";
4
+ import { parseTableState } from "./table-state.ts";
5
+ import type { ColumnState, TableState, TableStateSchema } from "./table-state.ts";
6
+
7
+ export type TableStateChange =
8
+ | { readonly kind: "query"; readonly change: ClientStateChange }
9
+ | { readonly kind: "sortCycle"; readonly column: string; readonly multiple: boolean }
10
+ | { readonly kind: "columnOrder"; readonly ids: readonly string[] }
11
+ | { readonly kind: "columnVisibility"; readonly column: string; readonly visible: boolean }
12
+ | { readonly kind: "columnWidth"; readonly column: string; readonly width: number | null }
13
+ | { readonly kind: "columnPin"; readonly column: string; readonly pin: ColumnState["pin"] };
14
+
15
+ /** Pure requested-state update. Apply accepted layout/query/results atomically in the table owner. */
16
+ export function changeTableState(value: TableState, change: TableStateChange, schema: TableStateSchema): TableState {
17
+ const state = parseTableState(value, schema);
18
+ const query = { search: state.search, filter: state.filter, sorting: state.sorting, pagination: state.pagination };
19
+ switch (change.kind) {
20
+ case "query": return parseTableState({ ...changeClientViewState(query, change.change, schema), columns: state.columns }, schema);
21
+ case "sortCycle": {
22
+ if (!schema.sortColumns.some(column => column.id === change.column)) throw new Error(`Column does not support sorting: ${change.column}`);
23
+ const current = state.sorting.find(entry => entry.column === change.column);
24
+ const next: SortEntry | null = current?.direction === "desc" ? null : { column: change.column, direction: current ? "desc" : "asc" };
25
+ let sorting: SortState;
26
+ if (!change.multiple) sorting = next ? [next] : [];
27
+ else if (!current && next) sorting = [...state.sorting, next];
28
+ else sorting = state.sorting.flatMap(entry => entry.column === change.column ? next ? [next] : [] : [entry]);
29
+ return parseTableState({ ...changeClientViewState(query, { kind: "sorting", value: sorting }, schema), columns: state.columns }, schema);
30
+ }
31
+ case "columnOrder": {
32
+ const columns = new Map(state.columns.map(column => [column.id, column]));
33
+ return parseTableState({ ...state, columns: Array.from(change.ids, id => columns.get(id)) }, schema);
34
+ }
35
+ case "columnVisibility":
36
+ case "columnWidth":
37
+ case "columnPin": {
38
+ if (!state.columns.some(column => column.id === change.column)) throw new Error(`Unknown table column: ${change.column}`);
39
+ const columns = state.columns.map(column => {
40
+ if (column.id !== change.column) return column;
41
+ switch (change.kind) {
42
+ case "columnVisibility": return { ...column, visible: change.visible };
43
+ case "columnWidth": return { ...column, width: change.width };
44
+ case "columnPin": return { ...column, pin: change.pin };
45
+ }
46
+ });
47
+ return parseTableState({ ...state, columns }, schema);
48
+ }
49
+ default: throw new Error("Unknown table state change");
50
+ }
51
+ }
@@ -0,0 +1,72 @@
1
+ import { parseClientViewState } from "./client-state.ts";
2
+ import type { ClientStateSchema } from "./client-state.ts";
3
+ import type { ClientViewState } from "./client-view.ts";
4
+
5
+ export interface ColumnState {
6
+ readonly id: string;
7
+ readonly visible: boolean;
8
+ /** Explicit resized width in CSS pixels; null uses the column definition's sizing policy. */
9
+ readonly width: number | null;
10
+ readonly pin: "start" | "end" | false;
11
+ }
12
+ export interface TableState extends ClientViewState {
13
+ /** Array order is the user-defined column order. Every available column occurs once. */
14
+ readonly columns: readonly ColumnState[];
15
+ }
16
+ export interface TableStateSchema extends ClientStateSchema {
17
+ readonly columns: readonly string[];
18
+ }
19
+
20
+ function record(value: unknown): value is Record<string, unknown> {
21
+ return typeof value === "object" && value !== null && !Array.isArray(value);
22
+ }
23
+ function exact(value: Record<string, unknown>, fields: readonly string[], path: string) {
24
+ for (const key of Object.keys(value)) if (!fields.includes(key)) throw new Error(`Invalid table state at ${path}: unknown field ${key}`);
25
+ for (const key of fields) if (!Object.hasOwn(value, key)) throw new Error(`Invalid table state at ${path}: missing ${key}`);
26
+ }
27
+
28
+ /** Strictly validate before applying saved/URL state, never partially restore it. */
29
+ export function parseTableState(value: unknown, schema: TableStateSchema): TableState {
30
+ const available = new Set<string>();
31
+ for (const id of schema.columns) {
32
+ if (typeof id !== "string" || !id.trim() || available.has(id)) throw new Error("Invalid or duplicate table schema column");
33
+ available.add(id);
34
+ }
35
+ for (const column of [...schema.filterColumns, ...schema.sortColumns]) {
36
+ if (!available.has(column.id)) throw new Error(`Query schema references unavailable table column: ${column.id}`);
37
+ }
38
+ if (!record(value)) throw new Error("Invalid table state: expected an object");
39
+ exact(value, ["search", "filter", "sorting", "pagination", "columns"], "$");
40
+ const query = parseClientViewState({ search: value.search, filter: value.filter, sorting: value.sorting, pagination: value.pagination }, schema);
41
+ if (!Array.isArray(value.columns) || value.columns.length !== available.size) throw new Error("Invalid table state: expected one state entry per available column");
42
+ const seen = new Set<string>();
43
+ const columns = Array.from(value.columns, (entry: unknown, index): ColumnState => {
44
+ const path = `$.columns[${index}]`;
45
+ if (!record(entry)) throw new Error(`Invalid table state at ${path}: expected a column object`);
46
+ exact(entry, ["id", "visible", "width", "pin"], path);
47
+ if (typeof entry.id !== "string" || !available.has(entry.id) || seen.has(entry.id)) throw new Error(`Invalid table state at ${path}: unknown or duplicate column`);
48
+ seen.add(entry.id);
49
+ if (typeof entry.visible !== "boolean") throw new Error(`Invalid table state at ${path}: visible must be boolean`);
50
+ if (entry.width !== null && (typeof entry.width !== "number" || !Number.isFinite(entry.width) || entry.width <= 0)) throw new Error(`Invalid table state at ${path}: width must be null or a positive finite pixel value`);
51
+ if (entry.pin !== false && entry.pin !== "start" && entry.pin !== "end") throw new Error(`Invalid table state at ${path}: pin must be false, start, or end`);
52
+ return Object.freeze({ id: entry.id, visible: entry.visible, width: entry.width, pin: entry.pin });
53
+ });
54
+ return Object.freeze({ ...query, columns: Object.freeze(columns) });
55
+ }
56
+
57
+ export function serializeState(state: TableState, schema: TableStateSchema): string {
58
+ const serialized = JSON.stringify({ version: 1, state: parseTableState(state, schema) });
59
+ if (serialized.length > 262144) throw new Error("Serialized table state exceeds 262144 characters");
60
+ return serialized;
61
+ }
62
+
63
+ export function deserializeState(serialized: string, schema: TableStateSchema): TableState {
64
+ if (serialized.length > 262144) throw new Error("Serialized table state exceeds 262144 characters");
65
+ let envelope: unknown;
66
+ try { envelope = JSON.parse(serialized); }
67
+ catch { throw new Error("Invalid table state JSON"); }
68
+ if (!record(envelope)) throw new Error("Invalid table state envelope");
69
+ exact(envelope, ["version", "state"], "$");
70
+ if (envelope.version !== 1) throw new Error("Unsupported table state version");
71
+ return parseTableState(envelope.state, schema);
72
+ }
@@ -0,0 +1,14 @@
1
+ const ascii = /^[\u0000-\u007f]*$/u;
2
+
3
+ /** NFC and locale casing, without Unicode normalization work for ASCII-only values. */
4
+ export function createTextNormalizer(locale: string, caseSensitive = false): (value: string) => string {
5
+ const asciiLowercase = caseSensitive || "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toLocaleLowerCase(locale) === "abcdefghijklmnopqrstuvwxyz";
6
+ return value => {
7
+ if (ascii.test(value)) {
8
+ if (caseSensitive) return value;
9
+ return asciiLowercase ? value.toLowerCase() : value.toLocaleLowerCase(locale);
10
+ }
11
+ const normalized = value.normalize("NFC");
12
+ return caseSensitive ? normalized : normalized.toLocaleLowerCase(locale).normalize("NFC");
13
+ };
14
+ }