@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.
- package/dist/DataTable.d.ts +58 -10
- package/dist/DataTable.js +1294 -1625
- package/dist/DataTableToolbar.js +1 -2
- package/dist/FilterBar.d.ts +3 -0
- package/dist/FilterBar.js +131 -108
- package/dist/QueryBuilder.js +72 -68
- package/dist/cell-edit.js +1 -2
- package/dist/client-state.d.ts +9 -3
- package/dist/client-state.js +36 -31
- 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/core.d.ts +5 -5
- package/dist/core.js +28 -28
- package/dist/data-table-features.d.ts +134 -0
- package/dist/data-table-features.js +560 -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.d.ts +5 -3
- package/dist/index.js +32 -31
- package/dist/messages.d.ts +4 -1
- package/dist/messages.js +5 -3
- package/dist/pagination.d.ts +43 -1
- package/dist/pagination.js +110 -56
- package/dist/query-builder-state.js +1 -2
- package/dist/requests.d.ts +3 -3
- package/dist/requests.js +39 -30
- package/dist/row-hierarchy.js +1 -2
- package/dist/row-identity.js +1 -2
- package/dist/saved-views.d.ts +17 -14
- package/dist/saved-views.js +72 -70
- 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.d.ts +16 -7
- package/dist/server-export.js +58 -55
- package/dist/sorting.js +1 -2
- package/dist/table-state-changes.d.ts +6 -3
- package/dist/table-state-changes.js +45 -42
- package/dist/table-state.d.ts +20 -4
- package/dist/table-state.js +67 -42
- package/dist/text-normalization.js +1 -2
- package/dist/url-state.d.ts +12 -9
- package/dist/url-state.js +34 -32
- package/package.json +5 -5
- package/src/DataTable.tsx +490 -766
- package/src/FilterBar.tsx +19 -3
- package/src/QueryBuilder.tsx +5 -5
- package/src/client-state.ts +31 -17
- package/src/columns.ts +9 -3
- package/src/core.ts +5 -5
- package/src/data-table-features.tsx +592 -0
- package/src/index.ts +5 -3
- package/src/messages.ts +2 -2
- package/src/pagination.ts +83 -14
- package/src/requests.ts +22 -8
- package/src/saved-views.ts +33 -11
- package/src/selection.ts +8 -0
- package/src/server-export.ts +17 -11
- package/src/styles.css +17 -11
- package/src/table-state-changes.ts +22 -12
- package/src/table-state.ts +53 -11
- package/src/url-state.ts +27 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./core.ts";
|
|
2
|
-
export { DataTable } from "./DataTable.tsx";
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
2
|
+
export { DataTable, createDataTable } from "./DataTable.tsx";
|
|
3
|
+
export { groupingFeature, hierarchyFeature, cellEditingFeature } from "./data-table-features.tsx";
|
|
4
|
+
export type { DataTableFeature, DataTableFeatureId } from "./data-table-features.tsx";
|
|
5
|
+
export type { ComposedDataTable, ComposedDataTableProps, DataTableProps, DataTableResult, DataTableCursorResult, DataTableInitialState, DataTableSelectionOptions, DataTableGroupingOptions, DataTableHierarchyOptions, DataTableExportFormat, DataTableExportOptions, DataTableCellCommitRequest, DataTableAction, DataTableActionContext, DataTableMobileLayoutOptions, DataTableVariant, DataTableDensity, DataTableSearchOptions, DataTableFilterBarOptions, ClientDataTableProps, ServerDataTableProps } from "./DataTable.tsx";
|
|
6
|
+
export { FilterBar, filterBarFeature } from "./FilterBar.tsx";
|
|
5
7
|
export type { FilterBarProps, FilterDateEditor, FilterDateEditorProps } from "./FilterBar.tsx";
|
|
6
8
|
export { QueryBuilder } from "./QueryBuilder.tsx";
|
|
7
9
|
export type { QueryBuilderProps } from "./QueryBuilder.tsx";
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createTableRequests as
|
|
3
|
-
import { deserializeFilter as
|
|
4
|
-
import { appendQueryChild as
|
|
5
|
-
import { appendFilterCondition as
|
|
6
|
-
import { compileFilter as
|
|
7
|
-
import { parseSorting as
|
|
8
|
-
import { countClientFacets as
|
|
9
|
-
import { formatSearchQuery as
|
|
10
|
-
import { createDebouncedSearch as
|
|
11
|
-
import { createClientView as
|
|
12
|
-
import { changeClientViewState as
|
|
13
|
-
import { deserializeState as
|
|
14
|
-
import { changeTableState as
|
|
15
|
-
import { canMoveColumn as
|
|
16
|
-
import { createTableSelection as
|
|
17
|
-
import { createClientExport as
|
|
18
|
-
import { selectClientRows as
|
|
19
|
-
import { createServerExport as
|
|
20
|
-
import { createCellEdit as
|
|
21
|
-
import { defineColumns as
|
|
22
|
-
import { createRowIdentity as
|
|
23
|
-
import { groupClientRows as
|
|
24
|
-
import { createRowHierarchy as
|
|
25
|
-
import { createTableUrlState as
|
|
26
|
-
import { createSavedViews as
|
|
27
|
-
import { englishTableMessages as
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
|
|
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
|
+
import { DataTable as se, createDataTable as ce } from "./DataTable.js";
|
|
29
|
+
import { cellEditingFeature as le, groupingFeature as ue, hierarchyFeature as de } from "./data-table-features.js";
|
|
30
|
+
import { FilterBar as fe, filterBarFeature as pe } from "./FilterBar.js";
|
|
31
|
+
import { QueryBuilder as me } from "./QueryBuilder.js";
|
|
32
|
+
export { se as DataTable, fe as FilterBar, me as QueryBuilder, S as appendFilterCondition, m as appendQueryChild, e as assessCursorPage, t as assessServerPage, U as canMoveColumn, le as cellEditingFeature, L as changeClientViewState, H as changeTableState, D as compileFilter, j as countClientFacets, Z as createCellEdit, J as createClientExport, I as createClientView, ce as createDataTable, 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, pe as filterBarFeature, O as filterClientRows, M as formatSearchQuery, n as getPageRange, ee as groupClientRows, ue as groupingFeature, de as hierarchyFeature, 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 };
|
package/dist/messages.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export declare const englishTableMessages: Readonly<{
|
|
|
13
13
|
tableControls: "{caption} table controls";
|
|
14
14
|
resultCountOne: "{count} result";
|
|
15
15
|
resultCount: "{count} results";
|
|
16
|
+
resultCountEstimate: "About {count} results";
|
|
17
|
+
resultCountAtLeast: "{count}+ results";
|
|
18
|
+
cursorPageRows: "Rows on this page: {count}";
|
|
16
19
|
previousResults: "Previous results";
|
|
17
20
|
clearFilters: "Clear filters";
|
|
18
21
|
clearSearchAndFilters: "Clear search and filters";
|
|
@@ -38,7 +41,7 @@ export declare const englishTableMessages: Readonly<{
|
|
|
38
41
|
retryExport: "Retry export";
|
|
39
42
|
downloadLastExport: "Download last export";
|
|
40
43
|
filters: "Filters";
|
|
41
|
-
filterAdd: "
|
|
44
|
+
filterAdd: "Add filter";
|
|
42
45
|
filterColumns: "Filter columns";
|
|
43
46
|
filterSearchColumns: "Search filter columns";
|
|
44
47
|
filterEdit: "Edit filter";
|
package/dist/messages.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/messages.ts
|
|
2
2
|
var e = Object.freeze({
|
|
3
3
|
loading: "Loading",
|
|
4
4
|
refreshing: "Refreshing, showing existing results",
|
|
@@ -14,6 +14,9 @@ var e = Object.freeze({
|
|
|
14
14
|
tableControls: "{caption} table controls",
|
|
15
15
|
resultCountOne: "{count} result",
|
|
16
16
|
resultCount: "{count} results",
|
|
17
|
+
resultCountEstimate: "About {count} results",
|
|
18
|
+
resultCountAtLeast: "{count}+ results",
|
|
19
|
+
cursorPageRows: "Rows on this page: {count}",
|
|
17
20
|
previousResults: "Previous results",
|
|
18
21
|
clearFilters: "Clear filters",
|
|
19
22
|
clearSearchAndFilters: "Clear search and filters",
|
|
@@ -39,7 +42,7 @@ var e = Object.freeze({
|
|
|
39
42
|
retryExport: "Retry export",
|
|
40
43
|
downloadLastExport: "Download last export",
|
|
41
44
|
filters: "Filters",
|
|
42
|
-
filterAdd: "
|
|
45
|
+
filterAdd: "Add filter",
|
|
43
46
|
filterColumns: "Filter columns",
|
|
44
47
|
filterSearchColumns: "Search filter columns",
|
|
45
48
|
filterEdit: "Edit filter",
|
|
@@ -120,5 +123,4 @@ function t(t) {
|
|
|
120
123
|
...t
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
|
-
//#endregion
|
|
124
126
|
export { e as englishTableMessages, t as resolveTableMessages };
|
package/dist/pagination.d.ts
CHANGED
|
@@ -21,11 +21,51 @@ export type ServerPageAssessment<Row> = {
|
|
|
21
21
|
readonly pagination: PageState;
|
|
22
22
|
readonly total: number;
|
|
23
23
|
};
|
|
24
|
+
/** Opaque server cursor plus the side of it to read. Null requests the first page. */
|
|
25
|
+
export interface CursorPosition {
|
|
26
|
+
readonly direction: "after" | "before";
|
|
27
|
+
readonly value: string;
|
|
28
|
+
}
|
|
29
|
+
export interface CursorPagination {
|
|
30
|
+
readonly kind: "cursor";
|
|
31
|
+
readonly pageSize: number;
|
|
32
|
+
readonly cursor: CursorPosition | null;
|
|
33
|
+
}
|
|
34
|
+
/** Every server pagination choice: complete (false), numbered, or cursor. */
|
|
35
|
+
export type ServerPagination = TablePagination | CursorPagination;
|
|
36
|
+
/** Optional full-query count. Estimates and lower bounds are announced as such, never as exact counts. */
|
|
37
|
+
export interface CursorTotal {
|
|
38
|
+
readonly kind: "exact" | "estimate" | "atLeast";
|
|
39
|
+
readonly value: number;
|
|
40
|
+
}
|
|
41
|
+
export interface CursorPageResult<Row> {
|
|
42
|
+
readonly rows: readonly Row[];
|
|
43
|
+
/** Null when no later page exists. */
|
|
44
|
+
readonly nextCursor: string | null;
|
|
45
|
+
/** Null when no earlier page exists. */
|
|
46
|
+
readonly previousCursor: string | null;
|
|
47
|
+
readonly total?: CursorTotal;
|
|
48
|
+
}
|
|
49
|
+
export type CursorPageAssessment<Row> = {
|
|
50
|
+
readonly kind: "accepted";
|
|
51
|
+
readonly pagination: CursorPagination;
|
|
52
|
+
readonly result: CursorPageResult<Row>;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: "refetch";
|
|
55
|
+
readonly pagination: CursorPagination;
|
|
56
|
+
};
|
|
24
57
|
export declare function parsePagination(value: unknown): TablePagination;
|
|
25
58
|
export declare function resolvePagination(mode: "client" | "server", value?: TablePagination): TablePagination;
|
|
26
|
-
|
|
59
|
+
export declare function parseCursorPagination(value: unknown): CursorPagination;
|
|
60
|
+
/** Validates any server choice. Cursor state is distinguished by its kind field. */
|
|
61
|
+
export declare function parseServerPagination(value: unknown): ServerPagination;
|
|
62
|
+
/** Filter and sort changes reset the requested page, not accepted rows. Cursor state returns to the first page. */
|
|
27
63
|
export declare function resetPagination(value: TablePagination): TablePagination;
|
|
64
|
+
export declare function resetPagination(value: CursorPagination): CursorPagination;
|
|
65
|
+
export declare function resetPagination(value: ServerPagination): ServerPagination;
|
|
28
66
|
export declare function resizePagination(value: PageState, pageSize: number): PageState;
|
|
67
|
+
export declare function resizePagination(value: CursorPagination, pageSize: number): CursorPagination;
|
|
68
|
+
export declare function resizePagination(value: PageState | CursorPagination, pageSize: number): PageState | CursorPagination;
|
|
29
69
|
/** Clamp before multiplying so even extreme valid requested indices cannot overflow the offset. */
|
|
30
70
|
export declare function getPageRange(value: PageState, total: number): PageRange;
|
|
31
71
|
/** Call after transforming the complete client dataset, never on an individual server page. */
|
|
@@ -34,3 +74,5 @@ export declare function paginateClientRows<Row>(rows: readonly Row[], value?: Ta
|
|
|
34
74
|
};
|
|
35
75
|
/** Validate a single response; never fetch, concatenate pages, or publish an invalid result. */
|
|
36
76
|
export declare function assessServerPage<Row>(value: TablePagination, result: PageResult<Row>): ServerPageAssessment<Row>;
|
|
77
|
+
/** Validate a single cursor response. An empty later page (for example after deletions) refetches the first page. */
|
|
78
|
+
export declare function assessCursorPage<Row>(value: CursorPagination, result: CursorPageResult<Row>): CursorPageAssessment<Row>;
|
package/dist/pagination.js
CHANGED
|
@@ -1,102 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/pagination.ts
|
|
2
|
+
var e = "Server mode requires explicit pagination, including explicit false for complete results";
|
|
3
|
+
function t(e, t) {
|
|
3
4
|
if (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) throw Error(`${t} must be a nonnegative safe integer`);
|
|
4
5
|
}
|
|
5
|
-
function
|
|
6
|
-
if (t ===
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
function n(e) {
|
|
7
|
+
if (t(e, "pageSize"), e === 0) throw Error("pageSize must be positive");
|
|
8
|
+
return e;
|
|
9
|
+
}
|
|
10
|
+
function r(e, t) {
|
|
11
|
+
if (Object.keys(e).some((e) => !t.includes(e))) throw Error("pagination contains unknown fields");
|
|
12
|
+
}
|
|
13
|
+
function i(e, t) {
|
|
14
|
+
if (typeof e != "string" || !e) throw Error(`${t} must be a nonempty string or null`);
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
17
|
+
function a(e) {
|
|
18
|
+
if (e === !1) return !1;
|
|
19
|
+
if (typeof e != "object" || !e || Array.isArray(e) || !("pageIndex" in e) || !("pageSize" in e)) throw Error("pagination must be false or { pageIndex, pageSize }");
|
|
20
|
+
return r(e, ["pageIndex", "pageSize"]), t(e.pageIndex, "pageIndex"), Object.freeze({
|
|
21
|
+
pageIndex: e.pageIndex,
|
|
22
|
+
pageSize: n(e.pageSize)
|
|
13
23
|
});
|
|
14
24
|
}
|
|
15
|
-
function
|
|
16
|
-
if (
|
|
25
|
+
function o(t, n) {
|
|
26
|
+
if (t !== "client" && t !== "server") throw Error("Table mode must be client or server");
|
|
17
27
|
if (n === void 0) {
|
|
18
|
-
if (
|
|
28
|
+
if (t === "server") throw Error(e);
|
|
19
29
|
return !1;
|
|
20
30
|
}
|
|
21
|
-
return
|
|
31
|
+
return a(n);
|
|
22
32
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
function s(e) {
|
|
34
|
+
if (typeof e != "object" || !e || Array.isArray(e) || !("kind" in e) || e.kind !== "cursor" || !("pageSize" in e) || !("cursor" in e)) throw Error("cursor pagination must be { kind: \"cursor\", pageSize, cursor }");
|
|
35
|
+
r(e, [
|
|
36
|
+
"kind",
|
|
37
|
+
"pageSize",
|
|
38
|
+
"cursor"
|
|
39
|
+
]);
|
|
40
|
+
let t = e.cursor;
|
|
41
|
+
if (t === null) return Object.freeze({
|
|
42
|
+
kind: "cursor",
|
|
43
|
+
pageSize: n(e.pageSize),
|
|
44
|
+
cursor: null
|
|
45
|
+
});
|
|
46
|
+
if (typeof t != "object" || !("direction" in t) || !("value" in t) || t.direction !== "after" && t.direction !== "before") throw Error("cursor must be null or { direction: after | before, value }");
|
|
47
|
+
return r(t, ["direction", "value"]), Object.freeze({
|
|
48
|
+
kind: "cursor",
|
|
49
|
+
pageSize: n(e.pageSize),
|
|
50
|
+
cursor: Object.freeze({
|
|
51
|
+
direction: t.direction,
|
|
52
|
+
value: i(t.value, "cursor value")
|
|
53
|
+
})
|
|
28
54
|
});
|
|
29
55
|
}
|
|
30
|
-
function
|
|
31
|
-
if (t
|
|
32
|
-
|
|
33
|
-
|
|
56
|
+
function c(t) {
|
|
57
|
+
if (t === void 0) throw Error(e);
|
|
58
|
+
return typeof t == "object" && t && "kind" in t ? s(t) : a(t);
|
|
59
|
+
}
|
|
60
|
+
function l(e) {
|
|
61
|
+
let t = c(e);
|
|
62
|
+
return t !== !1 && u(t, t.pageSize);
|
|
63
|
+
}
|
|
64
|
+
function u(e, t) {
|
|
65
|
+
let r = c(e);
|
|
66
|
+
if (r === !1) throw Error("Page-size changes require paginated state");
|
|
67
|
+
return "kind" in r ? Object.freeze({
|
|
68
|
+
kind: "cursor",
|
|
69
|
+
pageSize: n(t),
|
|
70
|
+
cursor: null
|
|
71
|
+
}) : Object.freeze({
|
|
34
72
|
pageIndex: 0,
|
|
35
|
-
pageSize:
|
|
73
|
+
pageSize: n(t)
|
|
36
74
|
});
|
|
37
75
|
}
|
|
38
|
-
function
|
|
39
|
-
let
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
let
|
|
76
|
+
function d(e, n) {
|
|
77
|
+
let r = a(e);
|
|
78
|
+
if (r === !1) throw Error("Page ranges require paginated state");
|
|
79
|
+
t(n, "total");
|
|
80
|
+
let i = Math.ceil(n / r.pageSize), o = Math.min(r.pageIndex, Math.max(0, i - 1)), s = o * r.pageSize, c = s + Math.min(r.pageSize, n - s);
|
|
43
81
|
return Object.freeze({
|
|
44
82
|
pageIndex: o,
|
|
45
|
-
pageSize:
|
|
46
|
-
pageCount:
|
|
83
|
+
pageSize: r.pageSize,
|
|
84
|
+
pageCount: i,
|
|
47
85
|
start: s,
|
|
48
86
|
end: c
|
|
49
87
|
});
|
|
50
88
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
89
|
+
function f(e, t = !1) {
|
|
90
|
+
let n = a(t);
|
|
91
|
+
if (n === !1) return {
|
|
54
92
|
rows: e,
|
|
55
93
|
total: e.length,
|
|
56
94
|
pagination: !1
|
|
57
95
|
};
|
|
58
|
-
let
|
|
96
|
+
let r = d(n, e.length);
|
|
59
97
|
return {
|
|
60
|
-
rows: e.slice(
|
|
98
|
+
rows: e.slice(r.start, r.end),
|
|
61
99
|
total: e.length,
|
|
62
100
|
pagination: Object.freeze({
|
|
63
|
-
pageIndex:
|
|
64
|
-
pageSize:
|
|
101
|
+
pageIndex: r.pageIndex,
|
|
102
|
+
pageSize: r.pageSize
|
|
65
103
|
})
|
|
66
104
|
};
|
|
67
105
|
}
|
|
68
|
-
function
|
|
69
|
-
let
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
72
|
-
if (
|
|
106
|
+
function p(e, n) {
|
|
107
|
+
let r = a(e);
|
|
108
|
+
if (t(n.total, "total"), !Array.isArray(n.rows)) throw Error("Server rows must be an array");
|
|
109
|
+
if (r === !1) {
|
|
110
|
+
if (n.rows.length !== n.total) throw Error("Non-paginated server results must be complete: rows.length must equal total");
|
|
73
111
|
return {
|
|
74
112
|
kind: "accepted",
|
|
75
113
|
pagination: !1,
|
|
76
|
-
result:
|
|
114
|
+
result: n
|
|
77
115
|
};
|
|
78
116
|
}
|
|
79
|
-
let
|
|
80
|
-
if (
|
|
81
|
-
if (
|
|
117
|
+
let i = d(r, n.total);
|
|
118
|
+
if (i.pageIndex !== r.pageIndex && n.total > 0) {
|
|
119
|
+
if (n.rows.length) throw Error("Out-of-range server page must not contain rows");
|
|
82
120
|
return {
|
|
83
121
|
kind: "refetch",
|
|
84
122
|
pagination: Object.freeze({
|
|
85
|
-
pageIndex:
|
|
86
|
-
pageSize:
|
|
123
|
+
pageIndex: i.pageIndex,
|
|
124
|
+
pageSize: i.pageSize
|
|
87
125
|
}),
|
|
88
|
-
total:
|
|
126
|
+
total: n.total
|
|
89
127
|
};
|
|
90
128
|
}
|
|
91
|
-
if (
|
|
129
|
+
if (n.rows.length !== i.end - i.start) throw Error("Server page row count does not match the requested page and total");
|
|
92
130
|
return {
|
|
93
131
|
kind: "accepted",
|
|
94
132
|
pagination: Object.freeze({
|
|
95
|
-
pageIndex:
|
|
96
|
-
pageSize:
|
|
133
|
+
pageIndex: i.pageIndex,
|
|
134
|
+
pageSize: i.pageSize
|
|
97
135
|
}),
|
|
98
|
-
result:
|
|
136
|
+
result: n
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function m(e, n) {
|
|
140
|
+
let r = s(e);
|
|
141
|
+
if (!Array.isArray(n.rows)) throw Error("Server rows must be an array");
|
|
142
|
+
if (n.rows.length > r.pageSize) throw Error("Cursor page contains more rows than pageSize");
|
|
143
|
+
if (n.nextCursor !== null && i(n.nextCursor, "nextCursor"), n.previousCursor !== null && i(n.previousCursor, "previousCursor"), n.total !== void 0) {
|
|
144
|
+
if (typeof n.total != "object" || n.total === null || n.total.kind !== "exact" && n.total.kind !== "estimate" && n.total.kind !== "atLeast") throw Error("Cursor total must be { kind: exact | estimate | atLeast, value }");
|
|
145
|
+
t(n.total.value, "total value");
|
|
146
|
+
}
|
|
147
|
+
return n.rows.length === 0 && r.cursor !== null ? {
|
|
148
|
+
kind: "refetch",
|
|
149
|
+
pagination: l(r)
|
|
150
|
+
} : {
|
|
151
|
+
kind: "accepted",
|
|
152
|
+
pagination: r,
|
|
153
|
+
result: n
|
|
99
154
|
};
|
|
100
155
|
}
|
|
101
|
-
|
|
102
|
-
export { s as assessServerPage, a as getPageRange, o as paginateClientRows, t as parsePagination, r as resetPagination, i as resizePagination, n as resolvePagination };
|
|
156
|
+
export { m as assessCursorPage, p as assessServerPage, d as getPageRange, f as paginateClientRows, s as parseCursorPagination, a as parsePagination, c as parseServerPagination, l as resetPagination, u as resizePagination, o as resolvePagination };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseFilter as e } from "./filter.js";
|
|
2
|
-
|
|
2
|
+
// src/query-builder-state.ts
|
|
3
3
|
function t(e) {
|
|
4
4
|
let t = /* @__PURE__ */ new Set();
|
|
5
5
|
return Object.freeze(e.map((e) => {
|
|
@@ -124,5 +124,4 @@ function l(t, n, i) {
|
|
|
124
124
|
child: e
|
|
125
125
|
})), i);
|
|
126
126
|
}
|
|
127
|
-
//#endregion
|
|
128
127
|
export { o as appendQueryChild, n as defaultQueryRule, c as moveQueryNode, t as queryBuilderFilterColumns, i as queryNodeAt, s as removeQueryNode, a as replaceQueryNode, l as toggleQueryNegation };
|
package/dist/requests.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PageResult,
|
|
1
|
+
import type { CursorPageResult, PageResult, ServerPagination } from "./pagination.ts";
|
|
2
2
|
export interface TableRequestState {
|
|
3
|
-
readonly pagination:
|
|
3
|
+
readonly pagination: ServerPagination;
|
|
4
4
|
}
|
|
5
5
|
export interface TableRequestSnapshot<State, Result> {
|
|
6
6
|
readonly accepted: {
|
|
@@ -17,7 +17,7 @@ export interface InitialTableResult<State, Result> {
|
|
|
17
17
|
readonly result: Result;
|
|
18
18
|
}
|
|
19
19
|
/** Framework-neutral request ownership. Read snapshots before/after awaiting request in the UI adapter. */
|
|
20
|
-
export declare function createTableRequests<State extends TableRequestState, Result extends PageResult<unknown>>(onStateChange: (state: State, signal: AbortSignal) => Promise<Result>, initial?: InitialTableResult<State, Result>): {
|
|
20
|
+
export declare function createTableRequests<State extends TableRequestState, Result extends PageResult<unknown> | CursorPageResult<unknown>>(onStateChange: (state: State, signal: AbortSignal) => Promise<Result>, initial?: InitialTableResult<State, Result>): {
|
|
21
21
|
getSnapshot: () => TableRequestSnapshot<State, Result>;
|
|
22
22
|
request: (value: State) => Promise<TableRequestOutcome>;
|
|
23
23
|
retry: () => Promise<TableRequestOutcome>;
|
package/dist/requests.js
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
1
|
+
import { assessCursorPage as e, assessServerPage as t, parseServerPagination as n } from "./pagination.js";
|
|
2
|
+
// src/requests.ts
|
|
3
|
+
function r(e) {
|
|
4
|
+
return "nextCursor" in e && "previousCursor" in e;
|
|
5
|
+
}
|
|
6
|
+
function i(i, a) {
|
|
7
|
+
let o = n(i);
|
|
8
|
+
if (o !== !1 && "kind" in o) {
|
|
9
|
+
if (!r(a)) throw Error("Cursor pagination results require nextCursor and previousCursor");
|
|
10
|
+
return e(o, a);
|
|
11
|
+
}
|
|
12
|
+
if (r(a)) throw Error("Numbered and complete server results must report total instead of cursors");
|
|
13
|
+
return t(o, a);
|
|
14
|
+
}
|
|
15
|
+
function a(e, t) {
|
|
16
|
+
let r = {
|
|
5
17
|
accepted: null,
|
|
6
18
|
requested: null,
|
|
7
19
|
pending: !1,
|
|
8
20
|
error: null
|
|
9
21
|
};
|
|
10
|
-
if (
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (a.kind !== "accepted") throw Error("Initial table results must describe a valid accepted page, not a page requiring refetch");
|
|
15
|
-
i = {
|
|
22
|
+
if (t) {
|
|
23
|
+
let e = structuredClone(t.state), n = i(e.pagination, t.result);
|
|
24
|
+
if (n.kind !== "accepted") throw Error("Initial table results must describe a valid accepted page, not a page requiring refetch");
|
|
25
|
+
r = {
|
|
16
26
|
accepted: {
|
|
17
27
|
state: {
|
|
18
|
-
...
|
|
19
|
-
pagination:
|
|
28
|
+
...e,
|
|
29
|
+
pagination: n.pagination
|
|
20
30
|
},
|
|
21
|
-
result:
|
|
31
|
+
result: t.result
|
|
22
32
|
},
|
|
23
33
|
requested: null,
|
|
24
34
|
pending: !1,
|
|
@@ -26,36 +36,36 @@ function n(n, r) {
|
|
|
26
36
|
};
|
|
27
37
|
}
|
|
28
38
|
let a = 0n, o, s = !1, c = !1;
|
|
29
|
-
async function l(
|
|
39
|
+
async function l(t) {
|
|
30
40
|
if (s) return "disposed";
|
|
31
41
|
if (c) return "superseded";
|
|
32
42
|
let l = ++a;
|
|
33
43
|
if (o?.abort(), s) return "disposed";
|
|
34
44
|
if (l !== a) return "superseded";
|
|
35
45
|
let u = new AbortController();
|
|
36
|
-
o = u,
|
|
37
|
-
...
|
|
46
|
+
o = u, r = {
|
|
47
|
+
...r,
|
|
38
48
|
requested: null,
|
|
39
49
|
pending: !0,
|
|
40
50
|
error: null
|
|
41
51
|
};
|
|
42
52
|
try {
|
|
43
|
-
let o = structuredClone(
|
|
44
|
-
|
|
45
|
-
...
|
|
53
|
+
let o = structuredClone(t);
|
|
54
|
+
n(o.pagination), r = {
|
|
55
|
+
...r,
|
|
46
56
|
requested: structuredClone(o),
|
|
47
57
|
pending: !0,
|
|
48
58
|
error: null
|
|
49
59
|
};
|
|
50
60
|
for (let t = 0; t < 4; t++) {
|
|
51
|
-
let t = await
|
|
61
|
+
let t = await e(structuredClone(o), u.signal);
|
|
52
62
|
if (s) return "disposed";
|
|
53
63
|
if (l !== a) return "superseded";
|
|
54
|
-
let
|
|
64
|
+
let n = i(o.pagination, t);
|
|
55
65
|
if (o = {
|
|
56
66
|
...o,
|
|
57
|
-
pagination:
|
|
58
|
-
},
|
|
67
|
+
pagination: n.pagination
|
|
68
|
+
}, n.kind === "accepted") return r = {
|
|
59
69
|
accepted: {
|
|
60
70
|
state: o,
|
|
61
71
|
result: t
|
|
@@ -67,8 +77,8 @@ function n(n, r) {
|
|
|
67
77
|
}
|
|
68
78
|
throw Error("Server page kept moving during clamping; retry the latest query");
|
|
69
79
|
} catch (e) {
|
|
70
|
-
return s ? "disposed" : l === a ? (
|
|
71
|
-
...
|
|
80
|
+
return s ? "disposed" : l === a ? (r = {
|
|
81
|
+
...r,
|
|
72
82
|
pending: !1,
|
|
73
83
|
error: e
|
|
74
84
|
}, "failed") : "superseded";
|
|
@@ -80,7 +90,7 @@ function n(n, r) {
|
|
|
80
90
|
if (c) return;
|
|
81
91
|
c = !0, a++;
|
|
82
92
|
let e = o;
|
|
83
|
-
o = void 0,
|
|
93
|
+
o = void 0, r = {
|
|
84
94
|
accepted: null,
|
|
85
95
|
requested: null,
|
|
86
96
|
pending: !1,
|
|
@@ -93,14 +103,13 @@ function n(n, r) {
|
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
return {
|
|
96
|
-
getSnapshot: () =>
|
|
106
|
+
getSnapshot: () => r,
|
|
97
107
|
request: l,
|
|
98
|
-
retry: () =>
|
|
108
|
+
retry: () => r.requested ? l(r.requested) : Promise.resolve(s ? "disposed" : "failed"),
|
|
99
109
|
clear: u,
|
|
100
110
|
dispose: () => {
|
|
101
111
|
s = !0, u();
|
|
102
112
|
}
|
|
103
113
|
};
|
|
104
114
|
}
|
|
105
|
-
|
|
106
|
-
export { n as createTableRequests };
|
|
115
|
+
export { a as createTableRequests };
|
package/dist/row-hierarchy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/row-hierarchy.ts
|
|
2
2
|
function e(e, t) {
|
|
3
3
|
if (!Array.isArray(e)) throw Error(`${t} must be an array`);
|
|
4
4
|
let n = [];
|
|
@@ -166,5 +166,4 @@ function t(t) {
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
//#endregion
|
|
170
169
|
export { t as createRowHierarchy };
|
package/dist/row-identity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/row-identity.ts
|
|
2
2
|
function e(e) {
|
|
3
3
|
if (typeof e != "function") throw Error("getRowId must be a function");
|
|
4
4
|
let t = /* @__PURE__ */ new WeakMap();
|
|
@@ -32,5 +32,4 @@ function e(e) {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
//#endregion
|
|
36
35
|
export { e as createRowIdentity };
|