@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
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { parsePagination, resolvePagination, resetPagination, resizePagination, getPageRange, paginateClientRows, assessServerPage } from "./pagination.ts";
2
- export type { PageState, TablePagination, PageRange, PageResult, ServerPageAssessment } from "./pagination.ts";
1
+ export { parsePagination, parseCursorPagination, parseServerPagination, resolvePagination, resetPagination, resizePagination, getPageRange, paginateClientRows, assessServerPage, assessCursorPage } from "./pagination.ts";
2
+ export type { PageState, TablePagination, CursorPosition, CursorPagination, ServerPagination, CursorTotal, CursorPageResult, CursorPageAssessment, PageRange, PageResult, ServerPageAssessment } from "./pagination.ts";
3
3
  export { createTableRequests } from "./requests.ts";
4
4
  export type { TableRequestState, TableRequestSnapshot, TableRequestOutcome, InitialTableResult } from "./requests.ts";
5
5
  export { parseFilter, serializeFilter, deserializeFilter } from "./filter.ts";
@@ -23,7 +23,7 @@ export type { ClientView, ClientViewState, ClientViewOptions } from "./client-vi
23
23
  export { parseClientViewState, changeClientViewState } from "./client-state.ts";
24
24
  export type { ClientStateSchema, ClientStateChange } from "./client-state.ts";
25
25
  export { parseTableState, serializeState, deserializeState } from "./table-state.ts";
26
- export type { ColumnState, TableState, TableStateSchema } from "./table-state.ts";
26
+ export type { ColumnState, TableState, TableStateSchema, CursorTableStateSchema } from "./table-state.ts";
27
27
  export { changeTableState } from "./table-state-changes.ts";
28
28
  export type { TableStateChange } from "./table-state-changes.ts";
29
29
  export { orderColumnStates, placeColumn, moveColumn, canMoveColumn } from "./column-layout.ts";
@@ -47,8 +47,8 @@ export type { GroupAggregateColumn, GroupAggregateValue, ClientRowGroup, ServerR
47
47
  export { createRowHierarchy } from "./row-hierarchy.ts";
48
48
  export type { HierarchyLoadOutcome, RowHierarchyOptions, HierarchyRow } from "./row-hierarchy.ts";
49
49
  export { createTableUrlState } from "./url-state.ts";
50
- export type { TableUrlLocation, TableUrlRouter, TableUrlRead, TableUrlWrite } from "./url-state.ts";
50
+ export type { TableUrlLocation, TableUrlRouter, TableUrlRead, TableUrlWrite, TableUrlState } from "./url-state.ts";
51
51
  export { createSavedViews } from "./saved-views.ts";
52
- export type { SavedViewRecord, SavedViewSave, SavedViewsAdapter, SavedViewOperation, SavedViewsSnapshot, SavedViewOutcome, SavedViewRestore } from "./saved-views.ts";
52
+ export type { SavedViews, SavedViewRecord, SavedViewSave, SavedViewsAdapter, SavedViewOperation, SavedViewsSnapshot, SavedViewOutcome, SavedViewRestore } from "./saved-views.ts";
53
53
  export { englishTableMessages, resolveTableMessages } from "./messages.ts";
54
54
  export type { TableMessages } from "./messages.ts";
package/dist/core.js CHANGED
@@ -1,28 +1,28 @@
1
- import { assessServerPage as e, getPageRange as t, paginateClientRows as n, parsePagination as r, resetPagination as i, resizePagination as a, resolvePagination as o } from "./pagination.js";
2
- import { createTableRequests as s } from "./requests.js";
3
- import { deserializeFilter as c, parseFilter as l, serializeFilter as u } from "./filter.js";
4
- import { appendQueryChild as d, defaultQueryRule as f, moveQueryNode as p, queryBuilderFilterColumns as m, queryNodeAt as h, removeQueryNode as g, replaceQueryNode as _, toggleQueryNegation as v } from "./query-builder-state.js";
5
- import { appendFilterCondition as y, listFilterConditions as b, removeFilterColumnConditions as x, removeFilterCondition as S, replaceFilterCondition as C } from "./filter-bar-state.js";
6
- import { compileFilter as w, filterClientRows as T } from "./filter-client.js";
7
- import { parseSorting as E, sortClientRows as D } from "./sorting.js";
8
- import { countClientFacets as O } from "./facets.js";
9
- import { formatSearchQuery as k, parseSearchQuery as A, searchClientRows as j } from "./search.js";
10
- import { createDebouncedSearch as M } from "./search-controller.js";
11
- import { createClientView as N } from "./client-view.js";
12
- import { changeClientViewState as P, parseClientViewState as F } from "./client-state.js";
13
- import { deserializeState as I, parseTableState as L, serializeState as R } from "./table-state.js";
14
- import { changeTableState as z } from "./table-state-changes.js";
15
- import { canMoveColumn as B, moveColumn as V, orderColumnStates as H, placeColumn as U } from "./column-layout.js";
16
- import { createTableSelection as W } from "./selection.js";
17
- import { createClientExport as G } from "./export.js";
18
- import { selectClientRows as K } from "./selection-client.js";
19
- import { createServerExport as q } from "./server-export.js";
20
- import { createCellEdit as J } from "./cell-edit.js";
21
- import { defineColumns as Y } from "./columns.js";
22
- import { createRowIdentity as X } from "./row-identity.js";
23
- import { groupClientRows as Z, normalizeServerGroups as Q } from "./grouping.js";
24
- import { createRowHierarchy as $ } from "./row-hierarchy.js";
25
- import { createTableUrlState as ee } from "./url-state.js";
26
- import { createSavedViews as te } from "./saved-views.js";
27
- import { englishTableMessages as ne, resolveTableMessages as re } from "./messages.js";
28
- export { y as appendFilterCondition, d as appendQueryChild, e as assessServerPage, B as canMoveColumn, P as changeClientViewState, z as changeTableState, w as compileFilter, O as countClientFacets, J as createCellEdit, G as createClientExport, N as createClientView, M as createDebouncedSearch, $ as createRowHierarchy, X as createRowIdentity, te as createSavedViews, q as createServerExport, s as createTableRequests, W as createTableSelection, ee as createTableUrlState, f as defaultQueryRule, Y as defineColumns, c as deserializeFilter, I as deserializeState, ne as englishTableMessages, T as filterClientRows, k as formatSearchQuery, t as getPageRange, Z as groupClientRows, b as listFilterConditions, V as moveColumn, p as moveQueryNode, Q as normalizeServerGroups, H as orderColumnStates, n as paginateClientRows, F as parseClientViewState, l as parseFilter, r as parsePagination, A as parseSearchQuery, E as parseSorting, L as parseTableState, U as placeColumn, m as queryBuilderFilterColumns, h as queryNodeAt, x as removeFilterColumnConditions, S as removeFilterCondition, g as removeQueryNode, C as replaceFilterCondition, _ as replaceQueryNode, i as resetPagination, a as resizePagination, o as resolvePagination, re as resolveTableMessages, j as searchClientRows, K as selectClientRows, u as serializeFilter, R as serializeState, D as sortClientRows, v as toggleQueryNegation };
1
+ import { assessCursorPage as e, assessServerPage as t, getPageRange as n, paginateClientRows as r, parseCursorPagination as i, parsePagination as a, parseServerPagination as o, resetPagination as s, resizePagination as c, resolvePagination as l } from "./pagination.js";
2
+ import { createTableRequests as u } from "./requests.js";
3
+ import { deserializeFilter as d, parseFilter as f, serializeFilter as p } from "./filter.js";
4
+ import { appendQueryChild as m, defaultQueryRule as h, moveQueryNode as g, queryBuilderFilterColumns as _, queryNodeAt as v, removeQueryNode as y, replaceQueryNode as b, toggleQueryNegation as x } from "./query-builder-state.js";
5
+ import { appendFilterCondition as S, listFilterConditions as C, removeFilterColumnConditions as w, removeFilterCondition as T, replaceFilterCondition as E } from "./filter-bar-state.js";
6
+ import { compileFilter as D, filterClientRows as O } from "./filter-client.js";
7
+ import { parseSorting as k, sortClientRows as A } from "./sorting.js";
8
+ import { countClientFacets as j } from "./facets.js";
9
+ import { formatSearchQuery as M, parseSearchQuery as N, searchClientRows as P } from "./search.js";
10
+ import { createDebouncedSearch as F } from "./search-controller.js";
11
+ import { createClientView as I } from "./client-view.js";
12
+ import { changeClientViewState as L, parseClientViewState as R } from "./client-state.js";
13
+ import { deserializeState as z, parseTableState as B, serializeState as V } from "./table-state.js";
14
+ import { changeTableState as H } from "./table-state-changes.js";
15
+ import { canMoveColumn as U, moveColumn as W, orderColumnStates as G, placeColumn as K } from "./column-layout.js";
16
+ import { createTableSelection as q } from "./selection.js";
17
+ import { createClientExport as J } from "./export.js";
18
+ import { selectClientRows as Y } from "./selection-client.js";
19
+ import { createServerExport as X } from "./server-export.js";
20
+ import { createCellEdit as Z } from "./cell-edit.js";
21
+ import { defineColumns as Q } from "./columns.js";
22
+ import { createRowIdentity as $ } from "./row-identity.js";
23
+ import { groupClientRows as ee, normalizeServerGroups as te } from "./grouping.js";
24
+ import { createRowHierarchy as ne } from "./row-hierarchy.js";
25
+ import { createTableUrlState as re } from "./url-state.js";
26
+ import { createSavedViews as ie } from "./saved-views.js";
27
+ import { englishTableMessages as ae, resolveTableMessages as oe } from "./messages.js";
28
+ export { S as appendFilterCondition, m as appendQueryChild, e as assessCursorPage, t as assessServerPage, U as canMoveColumn, L as changeClientViewState, H as changeTableState, D as compileFilter, j as countClientFacets, Z as createCellEdit, J as createClientExport, I as createClientView, F as createDebouncedSearch, ne as createRowHierarchy, $ as createRowIdentity, ie as createSavedViews, X as createServerExport, u as createTableRequests, q as createTableSelection, re as createTableUrlState, h as defaultQueryRule, Q as defineColumns, d as deserializeFilter, z as deserializeState, ae as englishTableMessages, O as filterClientRows, M as formatSearchQuery, n as getPageRange, ee as groupClientRows, C as listFilterConditions, W as moveColumn, g as moveQueryNode, te as normalizeServerGroups, G as orderColumnStates, r as paginateClientRows, R as parseClientViewState, i as parseCursorPagination, f as parseFilter, a as parsePagination, N as parseSearchQuery, o as parseServerPagination, k as parseSorting, B as parseTableState, K as placeColumn, _ as queryBuilderFilterColumns, v as queryNodeAt, w as removeFilterColumnConditions, T as removeFilterCondition, y as removeQueryNode, E as replaceFilterCondition, b as replaceQueryNode, s as resetPagination, c as resizePagination, l as resolvePagination, oe as resolveTableMessages, P as searchClientRows, Y as selectClientRows, p as serializeFilter, V as serializeState, A as sortClientRows, x as toggleQueryNegation };
@@ -0,0 +1,134 @@
1
+ import type { Accessor, JSX } from "solid-js";
2
+ import type { ColumnValue, ResolvedColumn } from "./columns.ts";
3
+ import type { DataTableInternalProps, DataTableResult } from "./DataTable.tsx";
4
+ import type { FilterColumn, FilterNode } from "./filter.ts";
5
+ import type { ClientRowGroup } from "./grouping.ts";
6
+ import type { TableMessages } from "./messages.ts";
7
+ /** One application row with a stable ID. The accessor follows the current source row for that ID. */
8
+ export interface StableRow<Row extends object> {
9
+ readonly id: string;
10
+ readonly value: Accessor<Row>;
11
+ }
12
+ export interface StableRows<Row extends object> {
13
+ readonly resolve: (row: Row, index: number) => StableRow<Row>;
14
+ }
15
+ export interface DisplayDataRow<Row extends object> {
16
+ readonly kind: "data";
17
+ readonly key: string;
18
+ readonly row: StableRow<Row>;
19
+ readonly parentId: string | null;
20
+ readonly depth: number;
21
+ readonly position: number;
22
+ readonly setSize: number;
23
+ readonly canExpand: boolean;
24
+ readonly expanded: boolean;
25
+ readonly unloaded: boolean;
26
+ readonly pending: boolean;
27
+ readonly error: unknown;
28
+ }
29
+ export interface DisplayGroupRow<Row extends object> {
30
+ readonly kind: "group";
31
+ readonly key: string;
32
+ readonly group: ClientRowGroup<Row>;
33
+ readonly label: string;
34
+ readonly position: number;
35
+ readonly setSize: number;
36
+ readonly expanded: boolean;
37
+ }
38
+ export type DisplayRow<Row extends object> = DisplayDataRow<Row> | DisplayGroupRow<Row>;
39
+ /** What a feature may read from, and ask of, the table that composes it. */
40
+ export interface DataTableFeatureContext<Row extends object> {
41
+ readonly props: DataTableInternalProps<Row>;
42
+ readonly definitions: readonly ResolvedColumn<Row>[];
43
+ readonly filterColumns: readonly FilterColumn[];
44
+ readonly messages: Accessor<TableMessages>;
45
+ readonly locale: Accessor<string>;
46
+ /** A query is unsettled. Structural changes wait for accepted state. */
47
+ readonly pending: Accessor<boolean>;
48
+ /** Accepted rows, facets, and server groups. Totals stay with the table because cursor pages may not know them. */
49
+ readonly result: Accessor<Pick<DataTableResult<Row>, "rows" | "facets" | "groups">>;
50
+ readonly accepted: Accessor<boolean>;
51
+ readonly acceptedFilter: Accessor<FilterNode>;
52
+ readonly requestFilter: (filter: FilterNode) => void;
53
+ /** Stable rows for the table's own source (client data or the accepted server page). */
54
+ readonly stableRows: StableRows<Row>;
55
+ readonly createStableRows: (source: Accessor<readonly Row[]>) => StableRows<Row>;
56
+ readonly rowAt: (index: number) => DisplayRow<Row> | undefined;
57
+ readonly rowIndex: (key: string, hint?: number) => number;
58
+ readonly focusRow: (index: number) => void;
59
+ }
60
+ /** Replaces the flat row model with a structured treegrid presentation. At most one may be active. */
61
+ export interface DataTablePresentation<Row extends object> {
62
+ readonly rows: Accessor<readonly DisplayRow<Row>[]>;
63
+ readonly allowSelectAll: boolean;
64
+ /** Column that labels group rows when it is visible. */
65
+ readonly labelColumn?: string;
66
+ /** Returns true when the feature handled the key. Cards omit child/parent focus movement. */
67
+ readonly keyDown: (event: KeyboardEvent, row: DisplayRow<Row>, index: number, layout: "table" | "cards") => boolean;
68
+ /** Wraps the first visible data cell with tree indentation and expansion controls. */
69
+ readonly TreeCell: (props: {
70
+ readonly row: DisplayDataRow<Row>;
71
+ readonly children: JSX.Element;
72
+ }) => JSX.Element;
73
+ readonly GroupCell?: (props: {
74
+ readonly row: DisplayGroupRow<Row>;
75
+ readonly column: ResolvedColumn<Row>;
76
+ readonly label: boolean;
77
+ }) => JSX.Element;
78
+ }
79
+ export interface DataTableCellAttributes {
80
+ readonly "data-editable"?: "";
81
+ readonly "data-invalid"?: "";
82
+ readonly "data-stale"?: "";
83
+ readonly "data-pending"?: "";
84
+ readonly "data-conflict"?: "";
85
+ }
86
+ /** Per-cell extension bound inside the owning cell. */
87
+ export interface DataTableCellBinding<Row extends object> {
88
+ readonly active: Accessor<boolean>;
89
+ readonly attributes: Accessor<DataTableCellAttributes>;
90
+ readonly render: (row: Accessor<DisplayDataRow<Row>>) => JSX.Element;
91
+ }
92
+ export interface DataTableFeatureInstance<Row extends object> {
93
+ readonly presentation?: DataTablePresentation<Row>;
94
+ /** Toolbar query control rendered beside search. */
95
+ readonly query?: {
96
+ readonly visible: Accessor<boolean>;
97
+ readonly render: () => JSX.Element;
98
+ };
99
+ /** Returns undefined for columns the feature does not own. */
100
+ readonly cell?: (row: Accessor<DisplayDataRow<Row> | undefined>, column: ResolvedColumn<Row>) => DataTableCellBinding<Row> | undefined;
101
+ /** Rendered once at the end of the table section. */
102
+ readonly overlay?: () => JSX.Element;
103
+ }
104
+ export type DataTableFeatureId = "filterBar" | "grouping" | "hierarchy" | "cellEditing";
105
+ /**
106
+ * An opt-in DataTable capability for `createDataTable`. Only Sheen's exported features are supported; the
107
+ * context contract is internal. A feature validates the props it owns and returns undefined when inactive.
108
+ * Features are row-agnostic so one list type-checks against any DataTable.
109
+ */
110
+ export interface DataTableFeature<Id extends DataTableFeatureId = DataTableFeatureId> {
111
+ readonly id: Id;
112
+ readonly create: <Row extends object>(context: DataTableFeatureContext<Row>) => DataTableFeatureInstance<Row> | undefined;
113
+ }
114
+ export declare function defaultCell(value: ColumnValue): JSX.Element;
115
+ /**
116
+ * Holds a framework-neutral store's immutable snapshot in a signal. Stores publish by replacing their
117
+ * snapshot object, so equal references do not notify readers.
118
+ */
119
+ export declare function createSnapshotSignal<Snapshot>(read: () => Snapshot): {
120
+ readonly snapshot: Accessor<Snapshot>;
121
+ readonly sync: () => void;
122
+ readonly track: <Value>(completion: Promise<Value>) => Promise<Value>;
123
+ };
124
+ /**
125
+ * Resolves stable row records lazily by ID. Each record reads the validated source index, so a changed row
126
+ * object reaches only the readers of that record without writing reactive state while deriving rows.
127
+ */
128
+ export declare function createStableRows<Row extends object>(getRowId: (row: Row) => string, source: Accessor<readonly Row[]>): StableRows<Row>;
129
+ /** Client or delegated server grouping through the `grouping` prop. */
130
+ export declare const groupingFeature: DataTableFeature<"grouping">;
131
+ /** Expandable row trees through the `hierarchy` prop. */
132
+ export declare const hierarchyFeature: DataTableFeature<"hierarchy">;
133
+ /** Inline editing for columns that declare an editor, through `onCellCommit` and `editResetKey`. */
134
+ export declare const cellEditingFeature: DataTableFeature<"cellEditing">;