@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/DataTable.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSX } from "solid-js";
|
|
2
2
|
import type { ColumnValue, SheenColumns } from "./columns.ts";
|
|
3
|
-
import type { PageResult, TablePagination } from "./pagination.ts";
|
|
3
|
+
import type { CursorPageResult, CursorPagination, PageResult, ServerPagination, TablePagination } from "./pagination.ts";
|
|
4
4
|
import type { ServerRowGroup } from "./grouping.ts";
|
|
5
5
|
import type { BulkSelection } from "./selection.ts";
|
|
6
6
|
import type { ColumnState, TableState } from "./table-state.ts";
|
|
@@ -8,11 +8,19 @@ import type { FilterNode } from "./filter.ts";
|
|
|
8
8
|
import type { FilterDateEditor } from "./FilterBar.tsx";
|
|
9
9
|
import type { TableExportRequest } from "./server-export.ts";
|
|
10
10
|
import type { CellCommitRequest, CellCommitResult } from "./cell-edit.ts";
|
|
11
|
+
import type { DataTableFeature, DataTableFeatureId } from "./data-table-features.tsx";
|
|
11
12
|
export interface DataTableResult<Row extends object> extends PageResult<Row> {
|
|
12
13
|
readonly facets?: Readonly<Record<string, Readonly<Record<string, number>>>>;
|
|
13
14
|
/** Required for delegated server grouping; describes the accepted page with full-group totals. */
|
|
14
15
|
readonly groups?: readonly ServerRowGroup[];
|
|
15
16
|
}
|
|
17
|
+
/** One cursor page. Either cursor may be null; total is optional and may be an estimate or lower bound. */
|
|
18
|
+
export interface DataTableCursorResult<Row extends object> extends CursorPageResult<Row> {
|
|
19
|
+
readonly facets?: Readonly<Record<string, Readonly<Record<string, number>>>>;
|
|
20
|
+
}
|
|
21
|
+
/** The request state for a pagination prop: cursor props produce cursor state, everything else numbered or complete state. */
|
|
22
|
+
type DataTableServerPagination<Pagination extends ServerPagination> = Pagination extends CursorPagination ? CursorPagination : TablePagination;
|
|
23
|
+
type DataTableServerResult<Row extends object, Pagination extends ServerPagination> = Pagination extends CursorPagination ? DataTableCursorResult<Row> : DataTableResult<Row>;
|
|
16
24
|
export interface DataTableInitialState {
|
|
17
25
|
readonly search?: string;
|
|
18
26
|
readonly filter?: TableState["filter"];
|
|
@@ -107,16 +115,15 @@ interface DataTableBaseProps<Row extends object> {
|
|
|
107
115
|
readonly variant?: DataTableVariant;
|
|
108
116
|
/** Optional local density for table chrome and rows. Omission inherits the surrounding application density. */
|
|
109
117
|
readonly density?: DataTableDensity;
|
|
110
|
-
readonly pagination?: TablePagination;
|
|
111
118
|
readonly initialState?: DataTableInitialState;
|
|
112
119
|
/** Reactively applies an app-owned accepted filter. Use onAcceptedStateChange to keep table-authored changes synchronized. */
|
|
113
120
|
readonly filter?: FilterNode;
|
|
121
|
+
/** Row and cell height as a CSS length, such as `"2.75rem"` for two-line cells. Pair with `estimatedRowHeight` in pixels. */
|
|
114
122
|
readonly rowHeight?: string;
|
|
115
123
|
readonly variableRowHeight?: boolean;
|
|
116
124
|
readonly estimatedRowHeight?: number;
|
|
117
125
|
readonly initialViewportHeight?: number;
|
|
118
126
|
readonly class?: string;
|
|
119
|
-
readonly onAcceptedStateChange?: (state: TableState) => void;
|
|
120
127
|
readonly onRowActivate?: (row: Row) => void;
|
|
121
128
|
readonly selection?: DataTableSelectionOptions<Row>;
|
|
122
129
|
/** One action model rendered in both the selection bar and each row context menu. */
|
|
@@ -143,22 +150,63 @@ interface DataTableBaseProps<Row extends object> {
|
|
|
143
150
|
export interface ClientDataTableProps<Row extends object> extends DataTableBaseProps<Row> {
|
|
144
151
|
readonly mode?: "client";
|
|
145
152
|
readonly data: readonly Row[];
|
|
153
|
+
readonly pagination?: TablePagination;
|
|
154
|
+
readonly onAcceptedStateChange?: (state: TableState) => void;
|
|
146
155
|
readonly initialResult?: never;
|
|
147
156
|
readonly onStateChange?: never;
|
|
148
157
|
readonly onExport?: never;
|
|
149
158
|
readonly refreshKey?: never;
|
|
150
159
|
}
|
|
151
|
-
|
|
160
|
+
/** Pagination is false, numbered `{ pageIndex, pageSize }`, or `{ kind: "cursor", pageSize, cursor }`; its kind selects the result contract. */
|
|
161
|
+
export interface ServerDataTableProps<Row extends object, Pagination extends ServerPagination = TablePagination> extends DataTableBaseProps<Row> {
|
|
152
162
|
readonly mode: "server";
|
|
153
|
-
readonly pagination:
|
|
163
|
+
readonly pagination: Pagination;
|
|
164
|
+
readonly onAcceptedStateChange?: (state: TableState<DataTableServerPagination<Pagination>>) => void;
|
|
154
165
|
readonly data?: never;
|
|
155
|
-
readonly initialResult?:
|
|
156
|
-
readonly onStateChange: (state: TableState
|
|
166
|
+
readonly initialResult?: DataTableServerResult<Row, Pagination>;
|
|
167
|
+
readonly onStateChange: (state: TableState<DataTableServerPagination<Pagination>>, signal: AbortSignal) => Promise<DataTableServerResult<Row, Pagination>>;
|
|
157
168
|
/** Change to revalidate the latest requested/accepted query without resetting layout or scroll. Initial value does not fetch. */
|
|
158
169
|
readonly refreshKey?: string | number;
|
|
159
170
|
/** Creates a complete server-side export for the captured accepted query and selection. Without this adapter, export UI is hidden. */
|
|
160
|
-
readonly onExport?: (request: TableExportRequest
|
|
171
|
+
readonly onExport?: (request: TableExportRequest<DataTableServerPagination<Pagination>>, signal: AbortSignal) => Promise<Blob>;
|
|
172
|
+
}
|
|
173
|
+
export type DataTableProps<Row extends object, Pagination extends ServerPagination = TablePagination> = ClientDataTableProps<Row> | ServerDataTableProps<Row, Pagination>;
|
|
174
|
+
/**
|
|
175
|
+
* The composition root erases the server pagination kind. Method signatures accept every public pairing;
|
|
176
|
+
* parseServerPagination and per-response assessment enforce that state and results keep the configured kind.
|
|
177
|
+
*/
|
|
178
|
+
interface ErasedClientProps<Row extends object> extends Omit<ClientDataTableProps<Row>, "onAcceptedStateChange"> {
|
|
179
|
+
onAcceptedStateChange?(state: TableState<ServerPagination>): void;
|
|
180
|
+
}
|
|
181
|
+
interface ErasedServerProps<Row extends object> extends DataTableBaseProps<Row> {
|
|
182
|
+
readonly mode: "server";
|
|
183
|
+
readonly pagination: ServerPagination;
|
|
184
|
+
readonly data?: never;
|
|
185
|
+
readonly initialResult?: DataTableResult<Row> | DataTableCursorResult<Row>;
|
|
186
|
+
readonly refreshKey?: string | number;
|
|
187
|
+
onAcceptedStateChange?(state: TableState<ServerPagination>): void;
|
|
188
|
+
onStateChange(state: TableState<ServerPagination>, signal: AbortSignal): Promise<DataTableResult<Row> | DataTableCursorResult<Row>>;
|
|
189
|
+
onExport?(request: TableExportRequest<ServerPagination>, signal: AbortSignal): Promise<Blob>;
|
|
190
|
+
}
|
|
191
|
+
export type DataTableInternalProps<Row extends object> = ErasedClientProps<Row> | ErasedServerProps<Row>;
|
|
192
|
+
export declare function DataTable<Row extends object, Pagination extends ServerPagination = TablePagination>(props: DataTableProps<Row, Pagination>): JSX.Element;
|
|
193
|
+
/** Props owned by each opt-in feature. A composition without the feature rejects them at compile time and at render. */
|
|
194
|
+
interface DataTableFeatureProps {
|
|
195
|
+
readonly filterBar: "filterBar";
|
|
196
|
+
readonly grouping: "grouping";
|
|
197
|
+
readonly hierarchy: "hierarchy";
|
|
198
|
+
readonly cellEditing: "onCellCommit" | "editResetKey";
|
|
161
199
|
}
|
|
162
|
-
|
|
163
|
-
export
|
|
200
|
+
/** DataTable props for a composition that includes only the features named by `Id`. */
|
|
201
|
+
export type ComposedDataTableProps<Row extends object, Id extends DataTableFeatureId, Pagination extends ServerPagination = TablePagination> = DataTableProps<Row, Pagination> & {
|
|
202
|
+
readonly [Key in DataTableFeatureProps[Exclude<DataTableFeatureId, Id>]]?: never;
|
|
203
|
+
};
|
|
204
|
+
export type ComposedDataTable<Id extends DataTableFeatureId> = <Row extends object, Pagination extends ServerPagination = TablePagination>(props: ComposedDataTableProps<Row, Id, Pagination>) => JSX.Element;
|
|
205
|
+
/**
|
|
206
|
+
* A DataTable that bundles only the listed features. `createDataTable([])` is the lightest table; `DataTable`
|
|
207
|
+
* is the same composition with every feature.
|
|
208
|
+
*/
|
|
209
|
+
export declare function createDataTable<const Features extends readonly DataTableFeature[]>(features: Features): ComposedDataTable<Features[number]["id"]>;
|
|
210
|
+
/** Internal composition root behind DataTable and createDataTable. Features own their props, state, and rendering hooks; omitted features are not bundled. */
|
|
211
|
+
export declare function renderDataTable<Row extends object>(props: DataTableInternalProps<Row>, features: readonly DataTableFeature[]): JSX.Element;
|
|
164
212
|
export {};
|