@x12i/data 1.0.0 → 1.1.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/README.md +524 -27
- package/dist/chunk-ASP4ABDG.js +1987 -0
- package/dist/chunk-ASP4ABDG.js.map +1 -0
- package/dist/index.d.ts +375 -89
- package/dist/index.js +218 -54
- package/dist/index.js.map +1 -1
- package/dist/messages-BF20Mq97.d.ts +508 -0
- package/dist/react.d.ts +328 -0
- package/dist/react.js +3078 -0
- package/dist/react.js.map +1 -0
- package/dist/styles.css +1169 -0
- package/package.json +58 -5
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts for the kit's DataGrid (spec section 7). The grid's data pipeline
|
|
3
|
+
* is this package's own headless engine and its windowing is TanStack Virtual;
|
|
4
|
+
* these types are the stable surface that apps, reports and charts depend on.
|
|
5
|
+
*
|
|
6
|
+
* Everything here is additive over the first release: a `ColumnDef` written
|
|
7
|
+
* for 1.0.0 still type-checks and means the same thing.
|
|
8
|
+
*/
|
|
9
|
+
type SortDirection = "asc" | "desc";
|
|
10
|
+
interface SortModelItem {
|
|
11
|
+
/** The column `id` the sort applies to. Server requests carry `column.field ?? column.id`. */
|
|
12
|
+
field: string;
|
|
13
|
+
direction: SortDirection;
|
|
14
|
+
}
|
|
15
|
+
type FilterOperator = "contains" | "not-contains" | "starts-with" | "equals" | "not-equals" | "gt" | "gte" | "lt" | "lte" | "between" | "in" | "before" | "after" | "is-empty" | "is-not-empty";
|
|
16
|
+
interface FilterModelItem {
|
|
17
|
+
/** The column `id` the filter applies to. */
|
|
18
|
+
field: string;
|
|
19
|
+
operator: FilterOperator;
|
|
20
|
+
/** Absent for `is-empty` and `is-not-empty`. An array for `in` and `between`. */
|
|
21
|
+
value?: unknown;
|
|
22
|
+
}
|
|
23
|
+
interface GroupModelItem {
|
|
24
|
+
/** The column `id` to group by. */
|
|
25
|
+
field: string;
|
|
26
|
+
}
|
|
27
|
+
/** What the grid asks a server for. Row indexes are zero-based and `endRow` is exclusive. */
|
|
28
|
+
interface GetRowsRequest {
|
|
29
|
+
startRow: number;
|
|
30
|
+
endRow: number;
|
|
31
|
+
sort: SortModelItem[];
|
|
32
|
+
filter: FilterModelItem[];
|
|
33
|
+
group: GroupModelItem[];
|
|
34
|
+
/** The quick-search text, when the grid has any. */
|
|
35
|
+
quickFilter?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Cursor from the previous block's `nextCursor`, for APIs that page by cursor
|
|
38
|
+
* instead of offset. `null` for the first block.
|
|
39
|
+
*/
|
|
40
|
+
cursor?: string | null;
|
|
41
|
+
}
|
|
42
|
+
interface GetRowsResult<Row> {
|
|
43
|
+
rows: Row[];
|
|
44
|
+
/** Total rows matching the filter, so the grid can size its scrollbar. */
|
|
45
|
+
total: number;
|
|
46
|
+
/** Cursor for the block after this one. Present only for cursor-paged APIs. */
|
|
47
|
+
nextCursor?: string | null;
|
|
48
|
+
}
|
|
49
|
+
interface GetRowsOptions {
|
|
50
|
+
/** Aborted when the grid no longer needs the answer, for example after a new sort. */
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}
|
|
53
|
+
/** The server data source: `getRows({ startRow, endRow, sort, filter, group })` returns `{ rows, total }`. */
|
|
54
|
+
interface ServerDataSource<Row> {
|
|
55
|
+
getRows(request: GetRowsRequest, options?: GetRowsOptions): Promise<GetRowsResult<Row>>;
|
|
56
|
+
}
|
|
57
|
+
/** Cell renderers the grid ships (spec section 7). */
|
|
58
|
+
type CellType = "text" | "number" | "currency" | "percent" | "date" | "datetime" | "boolean" | "status" | "avatar" | "progress" | "sparkline" | "link" | "tags" | "actions" | "custom";
|
|
59
|
+
/** Logical sides, so a pinned column follows the reading direction in RTL. */
|
|
60
|
+
type ColumnPin = "start" | "end";
|
|
61
|
+
/** Cell text alignment on the inline axis. Numeric types default to `end`. */
|
|
62
|
+
type ColumnAlign = "start" | "center" | "end";
|
|
63
|
+
/** Tones of the kit `Badge`, shared by status cells and charts. */
|
|
64
|
+
type StatusTone = "neutral" | "accent" | "success" | "warning" | "danger" | "info";
|
|
65
|
+
/** One choice of an enum column: status badge, select editor and set filter. */
|
|
66
|
+
interface ColumnOption {
|
|
67
|
+
value: string;
|
|
68
|
+
/** Display text. Pass a translated string. */
|
|
69
|
+
label: string;
|
|
70
|
+
/** Badge tone for `status` cells. */
|
|
71
|
+
tone?: StatusTone;
|
|
72
|
+
}
|
|
73
|
+
type AggregateName = "sum" | "avg" | "min" | "max" | "count";
|
|
74
|
+
/** A custom aggregate: receives the column's values and the rows they came from. */
|
|
75
|
+
type AggregateFn<Row> = (values: unknown[], rows: Row[]) => unknown;
|
|
76
|
+
/** The filter UI and operators a column offers. Derived from `cellType` when absent. */
|
|
77
|
+
type ColumnFilterType = "text" | "number" | "date" | "enum" | "boolean";
|
|
78
|
+
type ColumnEditor = "text" | "number" | "select" | "boolean" | "date";
|
|
79
|
+
interface ColumnDef<Row> {
|
|
80
|
+
/** Stable identifier, also used in saved views. */
|
|
81
|
+
id: string;
|
|
82
|
+
/** Header text. Pass a translated string. */
|
|
83
|
+
header: string;
|
|
84
|
+
/** Property of the row to read. */
|
|
85
|
+
field?: Extract<keyof Row, string>;
|
|
86
|
+
cellType?: CellType;
|
|
87
|
+
/**
|
|
88
|
+
* An `Intl`-based format name, by cell type. Number: `integer`, `compact`,
|
|
89
|
+
* `decimal:2`, `unit:kilobyte`. Currency: an ISO code such as `EUR`. Percent:
|
|
90
|
+
* `whole` when the value is 0 to 100 instead of a fraction. Date and datetime:
|
|
91
|
+
* `short`, `medium`, `long`, `full`, `iso`.
|
|
92
|
+
*/
|
|
93
|
+
format?: string;
|
|
94
|
+
width?: number;
|
|
95
|
+
minWidth?: number;
|
|
96
|
+
pinned?: ColumnPin;
|
|
97
|
+
sortable?: boolean;
|
|
98
|
+
filterable?: boolean;
|
|
99
|
+
resizable?: boolean;
|
|
100
|
+
editable?: boolean;
|
|
101
|
+
maxWidth?: number;
|
|
102
|
+
align?: ColumnAlign;
|
|
103
|
+
/** Reads the value when `field` is not enough, for example a nested property. */
|
|
104
|
+
accessor?: (row: Row) => unknown;
|
|
105
|
+
/**
|
|
106
|
+
* Text for a value. Used by CSV export, copy, quick search and screen readers,
|
|
107
|
+
* and by the default cell renderer. Overrides `format`.
|
|
108
|
+
*/
|
|
109
|
+
formatter?: (value: unknown, row: Row) => string;
|
|
110
|
+
/** Replaces the default comparison. Return a negative, zero or positive number. */
|
|
111
|
+
comparator?: (a: unknown, b: unknown, rowA: Row, rowB: Row) => number;
|
|
112
|
+
/** Shown in group rows and in the totals footer. */
|
|
113
|
+
aggregate?: AggregateName | AggregateFn<Row>;
|
|
114
|
+
filterType?: ColumnFilterType;
|
|
115
|
+
/** Choices for `status` cells, enum filters and select editors. */
|
|
116
|
+
options?: ColumnOption[];
|
|
117
|
+
/** ISO 4217 code for `currency` cells. Defaults to `USD`. */
|
|
118
|
+
currency?: string;
|
|
119
|
+
numberFormat?: Intl.NumberFormatOptions;
|
|
120
|
+
dateFormat?: Intl.DateTimeFormatOptions;
|
|
121
|
+
/** Maximum for `progress` cells. Defaults to 100. */
|
|
122
|
+
progressMax?: number;
|
|
123
|
+
editor?: ColumnEditor;
|
|
124
|
+
/** Per-row editability on top of `editable`. */
|
|
125
|
+
canEdit?: (row: Row) => boolean;
|
|
126
|
+
/** Return an error message to reject an edit, or nothing to accept it. */
|
|
127
|
+
validate?: (value: unknown, row: Row) => string | null | undefined;
|
|
128
|
+
/** Turns the editor's text into a value. Defaults by editor type. */
|
|
129
|
+
parseValue?: (input: string, row: Row) => unknown;
|
|
130
|
+
/** Hidden until the user shows the column. */
|
|
131
|
+
hidden?: boolean;
|
|
132
|
+
/** `false` keeps the column out of the visibility menu. Default `true`. */
|
|
133
|
+
hideable?: boolean;
|
|
134
|
+
/** `false` keeps the column out of the grouping menu. Default `true`. */
|
|
135
|
+
groupable?: boolean;
|
|
136
|
+
/** `false` leaves the column out of quick search. */
|
|
137
|
+
searchable?: boolean;
|
|
138
|
+
/** Adjacent columns with the same `group` share a header above them. */
|
|
139
|
+
group?: string;
|
|
140
|
+
/** Free-form data for custom renderers. The grid never reads it. */
|
|
141
|
+
meta?: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
/** Identity helper that infers `Row` for column authoring. */
|
|
144
|
+
declare function defineColumns<Row>(columns: ColumnDef<Row>[]): ColumnDef<Row>[];
|
|
145
|
+
interface ColumnState {
|
|
146
|
+
id: string;
|
|
147
|
+
width?: number;
|
|
148
|
+
hidden?: boolean;
|
|
149
|
+
pinned?: ColumnPin;
|
|
150
|
+
}
|
|
151
|
+
declare const SAVED_VIEW_VERSION = 1;
|
|
152
|
+
/** Column state, filters and sort, serialized to JSON. */
|
|
153
|
+
interface SavedView {
|
|
154
|
+
version: typeof SAVED_VIEW_VERSION;
|
|
155
|
+
name?: string;
|
|
156
|
+
columns: ColumnState[];
|
|
157
|
+
sort: SortModelItem[];
|
|
158
|
+
filter: FilterModelItem[];
|
|
159
|
+
group?: GroupModelItem[];
|
|
160
|
+
}
|
|
161
|
+
/** Every filter operator, as a runtime list for validation and pickers. */
|
|
162
|
+
declare const FILTER_OPERATORS: readonly ["contains", "not-contains", "starts-with", "equals", "not-equals", "gt", "gte", "lt", "lte", "between", "in", "before", "after", "is-empty", "is-not-empty"];
|
|
163
|
+
|
|
164
|
+
interface FormatLabels {
|
|
165
|
+
yes: string;
|
|
166
|
+
no: string;
|
|
167
|
+
}
|
|
168
|
+
/** English labels for boolean values. The grid replaces them with its `messages`. */
|
|
169
|
+
declare const defaultFormatLabels: FormatLabels;
|
|
170
|
+
interface FormatContext {
|
|
171
|
+
/** BCP 47 locale for `Intl`. Defaults to the runtime locale. */
|
|
172
|
+
locale?: string;
|
|
173
|
+
/** IANA time zone for dates and times. Date-only values always format in UTC. */
|
|
174
|
+
timeZone?: string;
|
|
175
|
+
labels?: FormatLabels;
|
|
176
|
+
}
|
|
177
|
+
type CellFormatter<Row> = (value: unknown, row: Row) => string;
|
|
178
|
+
/** `Intl.NumberFormat` options for a numeric column, from `cellType`, `format` and the overrides. */
|
|
179
|
+
declare function resolveNumberFormatOptions<Row>(column: ColumnDef<Row>): Intl.NumberFormatOptions;
|
|
180
|
+
/** `Intl.DateTimeFormat` options for a date or datetime column. */
|
|
181
|
+
declare function resolveDateFormatOptions<Row>(column: ColumnDef<Row>): Intl.DateTimeFormatOptions;
|
|
182
|
+
/**
|
|
183
|
+
* Builds a formatter for a column once, so formatting 100,000 cells reuses one
|
|
184
|
+
* `Intl` object. A column's own `formatter` always wins. Empty values give "".
|
|
185
|
+
*
|
|
186
|
+
* Without a `cellType`, the value decides: numbers use number format, dates use
|
|
187
|
+
* date format, booleans use yes/no, arrays join.
|
|
188
|
+
*/
|
|
189
|
+
declare function createCellFormatter<Row>(column: ColumnDef<Row>, ctx?: FormatContext): CellFormatter<Row>;
|
|
190
|
+
/** One-off formatting. Prefer `createCellFormatter` when formatting many cells. */
|
|
191
|
+
declare function formatCellValue<Row>(column: ColumnDef<Row>, value: unknown, row: Row, ctx?: FormatContext): string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Row selection as a plain immutable value.
|
|
195
|
+
*
|
|
196
|
+
* `include` lists the selected ids. `exclude` means "every row except these
|
|
197
|
+
* ids": it is how "select all rows" works when the grid cannot list ids, for
|
|
198
|
+
* example when a server holds the rows. Both are safe to keep in React state.
|
|
199
|
+
*/
|
|
200
|
+
interface SelectionState {
|
|
201
|
+
readonly mode: "include" | "exclude";
|
|
202
|
+
readonly ids: ReadonlySet<string>;
|
|
203
|
+
}
|
|
204
|
+
declare const EMPTY_SELECTION: SelectionState;
|
|
205
|
+
declare function createSelection(ids?: Iterable<string>): SelectionState;
|
|
206
|
+
declare function isSelected(state: SelectionState, id: string): boolean;
|
|
207
|
+
declare function isSelectionEmpty(state: SelectionState): boolean;
|
|
208
|
+
/** Selects or deselects one row. Without `selected`, flips it. */
|
|
209
|
+
declare function toggleRow(state: SelectionState, id: string, selected?: boolean): SelectionState;
|
|
210
|
+
/** A selection of exactly one row. */
|
|
211
|
+
declare function selectOnly(id: string): SelectionState;
|
|
212
|
+
/**
|
|
213
|
+
* Selects or deselects every row between two positions of `orderedIds`,
|
|
214
|
+
* inclusive and in either direction. This is the Shift+click behavior.
|
|
215
|
+
* Positions outside the list are clamped.
|
|
216
|
+
*/
|
|
217
|
+
declare function selectRange(state: SelectionState, orderedIds: readonly string[], from: number, to: number, selected?: boolean): SelectionState;
|
|
218
|
+
/** Selects the given ids and nothing else. Use it when the grid knows every id. */
|
|
219
|
+
declare function selectAll(ids: Iterable<string>): SelectionState;
|
|
220
|
+
/** "Every row except none": the select-all of a grid that cannot list its ids. */
|
|
221
|
+
declare function selectAllExceptNone(): SelectionState;
|
|
222
|
+
declare function clearSelection(): SelectionState;
|
|
223
|
+
/** How many rows are selected, given the total row count (needed in `exclude` mode). */
|
|
224
|
+
declare function countSelected(state: SelectionState, total: number): number;
|
|
225
|
+
type SelectionSummary = "none" | "some" | "all";
|
|
226
|
+
/**
|
|
227
|
+
* The state of a select-all checkbox for a set of ids (the rows the checkbox
|
|
228
|
+
* stands for): `none`, `some` (indeterminate) or `all`.
|
|
229
|
+
*/
|
|
230
|
+
declare function summarizeSelection(state: SelectionState, ids: readonly string[]): SelectionSummary;
|
|
231
|
+
/** The ids that are selected, given every id the grid has. */
|
|
232
|
+
declare function resolveSelectedIds(state: SelectionState, allIds: Iterable<string>): string[];
|
|
233
|
+
/** JSON-safe form, for storage or a URL. */
|
|
234
|
+
interface SerializedSelection {
|
|
235
|
+
mode: "include" | "exclude";
|
|
236
|
+
ids: string[];
|
|
237
|
+
}
|
|
238
|
+
declare function serializeSelection(state: SelectionState): SerializedSelection;
|
|
239
|
+
declare function deserializeSelection(value: SerializedSelection): SelectionState;
|
|
240
|
+
|
|
241
|
+
/** Pinned column ids, in display order. `start` and `end` follow the reading direction. */
|
|
242
|
+
interface ColumnPinning {
|
|
243
|
+
start: string[];
|
|
244
|
+
end: string[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The part of the grid state a saved view keeps. Selection, expansion, paging
|
|
248
|
+
* and quick search are about the data on screen, not the view, and stay out.
|
|
249
|
+
*/
|
|
250
|
+
interface GridViewState {
|
|
251
|
+
sort: SortModelItem[];
|
|
252
|
+
filter: FilterModelItem[];
|
|
253
|
+
group: GroupModelItem[];
|
|
254
|
+
/** Column ids in display order. Ids missing here follow in definition order. */
|
|
255
|
+
columnOrder: string[];
|
|
256
|
+
/** `false` hides a column. A missing id is visible. */
|
|
257
|
+
columnVisibility: Record<string, boolean>;
|
|
258
|
+
/** Pixel widths of columns the user resized. */
|
|
259
|
+
columnSizing: Record<string, number>;
|
|
260
|
+
columnPinning: ColumnPinning;
|
|
261
|
+
}
|
|
262
|
+
/** The view a grid starts from, read from the column definitions (`hidden`, `pinned`). */
|
|
263
|
+
declare function createViewState<Row>(columns: readonly ColumnDef<Row>[]): GridViewState;
|
|
264
|
+
/** Known ids in the given order, then the rest in definition order. Duplicates and unknown ids drop out. */
|
|
265
|
+
declare function resolveColumnOrder<Row>(columns: readonly ColumnDef<Row>[], order: readonly string[]): string[];
|
|
266
|
+
/** The three zones of the grid, in display order. Hidden columns are left out. */
|
|
267
|
+
interface ColumnLayout {
|
|
268
|
+
start: string[];
|
|
269
|
+
center: string[];
|
|
270
|
+
end: string[];
|
|
271
|
+
}
|
|
272
|
+
declare function layoutColumns<Row>(columns: readonly ColumnDef<Row>[], state: Pick<GridViewState, "columnOrder" | "columnVisibility" | "columnPinning">): ColumnLayout;
|
|
273
|
+
/**
|
|
274
|
+
* The next sort model after the user activates a column header. A plain click
|
|
275
|
+
* replaces the model and cycles that column: ascending, descending, off. With
|
|
276
|
+
* `multi` (Shift+click) the column joins the model, or cycles inside it, and the
|
|
277
|
+
* other columns keep their rank.
|
|
278
|
+
*/
|
|
279
|
+
declare function toggleSort(sort: readonly SortModelItem[], field: string, multi?: boolean): SortModelItem[];
|
|
280
|
+
/** Sets the direction of one column, or removes it with `null`. */
|
|
281
|
+
declare function setSort(sort: readonly SortModelItem[], field: string, direction: SortDirection | null, multi?: boolean): SortModelItem[];
|
|
282
|
+
/** The 1-based rank of a column in a multi-column sort, or `null` when it is not sorted. */
|
|
283
|
+
declare function sortRank(sort: readonly SortModelItem[], field: string): number | null;
|
|
284
|
+
/** Replaces the filter items of one column, or clears them with `null`. */
|
|
285
|
+
declare function setColumnFilter(filter: readonly FilterModelItem[], field: string, item: FilterModelItem | null): FilterModelItem[];
|
|
286
|
+
/** Adds the column to the group model, or removes it when it is already there. */
|
|
287
|
+
declare function toggleGroup(group: readonly GroupModelItem[], field: string): GroupModelItem[];
|
|
288
|
+
/** Pins a column to a side, or unpins it with `false`. A pinned column is appended to its side. */
|
|
289
|
+
declare function setPinning(pinning: ColumnPinning, id: string, pin: ColumnPin | false): ColumnPinning;
|
|
290
|
+
/**
|
|
291
|
+
* Moves a visible column one step earlier (`-1`) or later (`1`) inside its own
|
|
292
|
+
* zone: start-pinned, center or end-pinned. A column does not jump across
|
|
293
|
+
* pinning; use `setPinning` for that. Hidden columns are skipped over.
|
|
294
|
+
*/
|
|
295
|
+
declare function moveColumn<Row>(columns: readonly ColumnDef<Row>[], state: Pick<GridViewState, "columnOrder" | "columnVisibility" | "columnPinning">, id: string, delta: -1 | 1): Pick<GridViewState, "columnOrder" | "columnPinning">;
|
|
296
|
+
/**
|
|
297
|
+
* Moves a visible column to just before or after another one: what dropping a
|
|
298
|
+
* dragged header does. Like `moveColumn` it stays inside its zone (start-pinned,
|
|
299
|
+
* center or end-pinned); a target in another zone changes nothing.
|
|
300
|
+
*/
|
|
301
|
+
declare function moveColumnTo<Row>(columns: readonly ColumnDef<Row>[], state: Pick<GridViewState, "columnOrder" | "columnVisibility" | "columnPinning">, id: string, targetId: string, placement: "before" | "after"): Pick<GridViewState, "columnOrder" | "columnPinning">;
|
|
302
|
+
/** Sets the width of a column, clamped to its `minWidth` and `maxWidth`. */
|
|
303
|
+
declare function resizeColumn<Row>(columns: readonly ColumnDef<Row>[], sizing: Readonly<Record<string, number>>, id: string, width: number): Record<string, number>;
|
|
304
|
+
|
|
305
|
+
interface DelimitedOptions extends FormatContext {
|
|
306
|
+
/** Field separator. Defaults to `,` for CSV and a tab for TSV. */
|
|
307
|
+
delimiter?: string;
|
|
308
|
+
/** Row separator. Defaults to CRLF for CSV (RFC 4180) and LF for TSV. */
|
|
309
|
+
eol?: string;
|
|
310
|
+
/** Write the column headers as the first line. Default `true`. */
|
|
311
|
+
header?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* `formatted` writes what the grid shows ("$1,234.50", "Mar 5, 2024"); `raw`
|
|
314
|
+
* writes the stored value (1234.5, an ISO date). Default `formatted`.
|
|
315
|
+
*/
|
|
316
|
+
values?: "formatted" | "raw";
|
|
317
|
+
/**
|
|
318
|
+
* Prefix cells that a spreadsheet would run as a formula (a leading `=`,
|
|
319
|
+
* `@`, tab, or a `+`/`-` that is not a plain number) with an apostrophe, so
|
|
320
|
+
* an exported cell cannot execute. Default `true` for CSV, `false` for TSV.
|
|
321
|
+
*/
|
|
322
|
+
sanitizeFormulas?: boolean;
|
|
323
|
+
/** Write a UTF-8 byte order mark first, which Excel needs to read non-ASCII CSV. CSV only. */
|
|
324
|
+
bom?: boolean;
|
|
325
|
+
}
|
|
326
|
+
/** Quotes a field when it holds the delimiter, a quote or a line break. */
|
|
327
|
+
declare function escapeDelimitedField(text: string, delimiter?: string): string;
|
|
328
|
+
/** Escapes one CSV field per RFC 4180. */
|
|
329
|
+
declare function escapeCsvField(text: string, delimiter?: string): string;
|
|
330
|
+
/** Columns that hold data. `actions` columns carry buttons, not values. */
|
|
331
|
+
declare function exportableColumns<Row>(columns: readonly ColumnDef<Row>[]): ColumnDef<Row>[];
|
|
332
|
+
/**
|
|
333
|
+
* Serializes rows to CSV, one column per given column, in the given order.
|
|
334
|
+
* Pass the visible columns to export "the current view". Values go through the
|
|
335
|
+
* column formatters unless `values: "raw"`. Quotes, delimiters and line breaks
|
|
336
|
+
* are escaped, and formula-looking cells are neutralized. `actions` columns are
|
|
337
|
+
* skipped. The result has no trailing line break.
|
|
338
|
+
*/
|
|
339
|
+
declare function gridToCsv<Row>(rows: readonly Row[], columns: readonly ColumnDef<Row>[], options?: DelimitedOptions): string;
|
|
340
|
+
/** Tab-separated text, the format spreadsheets paste. Used by "copy selection". */
|
|
341
|
+
declare function gridToTsv<Row>(rows: readonly Row[], columns: readonly ColumnDef<Row>[], options?: DelimitedOptions): string;
|
|
342
|
+
/** Reads CSV or TSV back into rows of text. Handles quoted fields, escaped quotes and line breaks. */
|
|
343
|
+
declare function parseDelimited(text: string, delimiter?: string): string[][];
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Reads a saved view from untrusted JSON (storage, a URL, a server). Returns
|
|
347
|
+
* `null` when the value is not a view this version understands, so a bad or
|
|
348
|
+
* newer record is ignored instead of crashing the grid.
|
|
349
|
+
*/
|
|
350
|
+
declare function parseSavedView(value: unknown): SavedView | null;
|
|
351
|
+
/** One saved view in a list, without loading its body. */
|
|
352
|
+
interface SavedViewSummary {
|
|
353
|
+
id: string;
|
|
354
|
+
name?: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Where an app keeps saved views. The grid does not care: pass any
|
|
358
|
+
* implementation (local storage, your API, `@x12i/flowix-ui`'s Flowix adapter).
|
|
359
|
+
*/
|
|
360
|
+
interface SavedViewStore {
|
|
361
|
+
list(): Promise<SavedViewSummary[]>;
|
|
362
|
+
/** `null` when the id does not exist or holds something `parseSavedView` rejects. */
|
|
363
|
+
load(id: string): Promise<SavedView | null>;
|
|
364
|
+
save(id: string, view: SavedView): Promise<void>;
|
|
365
|
+
delete(id: string): Promise<void>;
|
|
366
|
+
}
|
|
367
|
+
interface CaptureViewOptions {
|
|
368
|
+
name?: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Snapshots the view state into a `SavedView`. Columns are written in display
|
|
372
|
+
* order (start-pinned, center, end-pinned) with their width, `hidden` and `pinned`.
|
|
373
|
+
*/
|
|
374
|
+
declare function captureView<Row>(state: GridViewState, columns: readonly ColumnDef<Row>[], options?: CaptureViewOptions): SavedView;
|
|
375
|
+
/**
|
|
376
|
+
* Turns a saved view back into view state for the given columns. Ids the grid
|
|
377
|
+
* does not have are ignored; columns the view does not mention keep their
|
|
378
|
+
* defaults and follow in definition order. The result never throws on a view
|
|
379
|
+
* saved against different columns, which is the normal case after a release.
|
|
380
|
+
*/
|
|
381
|
+
declare function applySavedView<Row>(view: SavedView, columns: readonly ColumnDef<Row>[]): GridViewState;
|
|
382
|
+
/** A saved-view store that keeps views in memory. Handy for tests and demos. */
|
|
383
|
+
declare function createMemorySavedViewStore(initial?: Record<string, SavedView>): SavedViewStore;
|
|
384
|
+
/** The slice of `Storage` the local-storage store needs. */
|
|
385
|
+
interface StorageLike {
|
|
386
|
+
getItem(key: string): string | null;
|
|
387
|
+
setItem(key: string, value: string): void;
|
|
388
|
+
}
|
|
389
|
+
interface LocalStorageSavedViewStoreOptions {
|
|
390
|
+
/** The key holding every view as one JSON object. Default `x12i-data-views`. */
|
|
391
|
+
key?: string;
|
|
392
|
+
/** Defaults to `localStorage`. Falls back to memory where there is none (SSR, private mode). */
|
|
393
|
+
storage?: StorageLike;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* A saved-view store backed by `localStorage`, one JSON object under one key.
|
|
397
|
+
* Reads go through `parseSavedView`, so a corrupted or newer record is skipped.
|
|
398
|
+
*/
|
|
399
|
+
declare function createLocalStorageSavedViewStore(options?: LocalStorageSavedViewStoreOptions): SavedViewStore;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Every user-facing string of the DataGrid and Pagination. Components contain
|
|
403
|
+
* no English: they read these. Templates use ICU MessageFormat (`{name}`,
|
|
404
|
+
* `{count, plural, one {# row} other {# rows}}`); see `formatMessage`.
|
|
405
|
+
*/
|
|
406
|
+
interface DataGridMessages {
|
|
407
|
+
loading: string;
|
|
408
|
+
loadingMore: string;
|
|
409
|
+
empty: string;
|
|
410
|
+
emptyFiltered: string;
|
|
411
|
+
error: string;
|
|
412
|
+
retry: string;
|
|
413
|
+
clearFilters: string;
|
|
414
|
+
toolbarLabel: string;
|
|
415
|
+
quickSearch: string;
|
|
416
|
+
quickSearchPlaceholder: string;
|
|
417
|
+
clearSearch: string;
|
|
418
|
+
columns: string;
|
|
419
|
+
columnsMenuLabel: string;
|
|
420
|
+
showAllColumns: string;
|
|
421
|
+
exportCsv: string;
|
|
422
|
+
copySelection: string;
|
|
423
|
+
copied: string;
|
|
424
|
+
copyFailed: string;
|
|
425
|
+
selectedCount: string;
|
|
426
|
+
allSelected: string;
|
|
427
|
+
clearSelection: string;
|
|
428
|
+
selectAll: string;
|
|
429
|
+
selectRow: string;
|
|
430
|
+
sortAscending: string;
|
|
431
|
+
sortDescending: string;
|
|
432
|
+
clearSort: string;
|
|
433
|
+
filterColumn: string;
|
|
434
|
+
columnMenu: string;
|
|
435
|
+
hideColumn: string;
|
|
436
|
+
pinStart: string;
|
|
437
|
+
pinEnd: string;
|
|
438
|
+
unpin: string;
|
|
439
|
+
moveEarlier: string;
|
|
440
|
+
moveLater: string;
|
|
441
|
+
groupBy: string;
|
|
442
|
+
ungroup: string;
|
|
443
|
+
resizeColumn: string;
|
|
444
|
+
sortRank: string;
|
|
445
|
+
filterOperator: string;
|
|
446
|
+
filterValue: string;
|
|
447
|
+
filterFrom: string;
|
|
448
|
+
filterTo: string;
|
|
449
|
+
filterApply: string;
|
|
450
|
+
filterClear: string;
|
|
451
|
+
filterAny: string;
|
|
452
|
+
filterNoOptions: string;
|
|
453
|
+
filterBlank: string;
|
|
454
|
+
operators: Record<FilterOperator, string>;
|
|
455
|
+
activeFilters: string;
|
|
456
|
+
filterSummary: string;
|
|
457
|
+
removeFilter: string;
|
|
458
|
+
clearAllFilters: string;
|
|
459
|
+
groupedBy: string;
|
|
460
|
+
removeGrouping: string;
|
|
461
|
+
expandRow: string;
|
|
462
|
+
collapseRow: string;
|
|
463
|
+
expandGroup: string;
|
|
464
|
+
collapseGroup: string;
|
|
465
|
+
groupLabel: string;
|
|
466
|
+
rowActions: string;
|
|
467
|
+
detailRegion: string;
|
|
468
|
+
totals: string;
|
|
469
|
+
yes: string;
|
|
470
|
+
no: string;
|
|
471
|
+
moreTags: string;
|
|
472
|
+
progressLabel: string;
|
|
473
|
+
editCell: string;
|
|
474
|
+
cellEditFailed: string;
|
|
475
|
+
cellSaved: string;
|
|
476
|
+
invalidNumber: string;
|
|
477
|
+
invalidDate: string;
|
|
478
|
+
announceSorted: string;
|
|
479
|
+
announceSortCleared: string;
|
|
480
|
+
announceFiltered: string;
|
|
481
|
+
announceFilterCleared: string;
|
|
482
|
+
announceGrouped: string;
|
|
483
|
+
announceColumnMoved: string;
|
|
484
|
+
announceColumnHidden: string;
|
|
485
|
+
announceColumnResized: string;
|
|
486
|
+
announcePinned: string;
|
|
487
|
+
announceSelection: string;
|
|
488
|
+
rowLoading: string;
|
|
489
|
+
rowFailed: string;
|
|
490
|
+
paginationLabel: string;
|
|
491
|
+
pageSize: string;
|
|
492
|
+
firstPage: string;
|
|
493
|
+
previousPage: string;
|
|
494
|
+
nextPage: string;
|
|
495
|
+
lastPage: string;
|
|
496
|
+
pageRange: string;
|
|
497
|
+
pageStatus: string;
|
|
498
|
+
}
|
|
499
|
+
type DataGridMessageOverrides = Partial<Omit<DataGridMessages, "operators">> & {
|
|
500
|
+
operators?: Partial<Record<FilterOperator, string>>;
|
|
501
|
+
};
|
|
502
|
+
/** The English messages. Pass a translated subset through the `messages` prop. */
|
|
503
|
+
declare const defaultMessages: DataGridMessages;
|
|
504
|
+
/** Merges overrides onto the English defaults. Missing keys keep their English text. */
|
|
505
|
+
declare function resolveMessages(overrides?: DataGridMessageOverrides): DataGridMessages;
|
|
506
|
+
|
|
507
|
+
export { deserializeSelection as $, EMPTY_SELECTION as E, applySavedView as O, captureView as P, clearSelection as Q, countSelected as R, createCellFormatter as T, createLocalStorageSavedViewStore as U, createMemorySavedViewStore as V, createSelection as W, createViewState as X, defaultFormatLabels as Y, defaultMessages as Z, defineColumns as _, escapeCsvField as a0, escapeDelimitedField as a1, exportableColumns as a2, formatCellValue as a3, gridToCsv as a4, gridToTsv as a5, isSelected as a6, isSelectionEmpty as a7, layoutColumns as a8, moveColumn as a9, moveColumnTo as aa, parseDelimited as ab, parseSavedView as ac, resizeColumn as ad, resolveColumnOrder as ae, resolveDateFormatOptions as af, resolveMessages as ag, resolveNumberFormatOptions as ah, resolveSelectedIds as ai, selectAll as aj, selectAllExceptNone as ak, selectOnly as al, selectRange as am, serializeSelection as an, setColumnFilter as ao, setPinning as ap, setSort as aq, sortRank as ar, summarizeSelection as as, toggleGroup as at, toggleRow as au, toggleSort as av, FILTER_OPERATORS as t, SAVED_VIEW_VERSION as y };
|
|
508
|
+
export type { AggregateName as A, SavedViewStore as B, ColumnDef as C, DataGridMessageOverrides as D, FormatContext as F, GroupModelItem as G, SavedViewSummary as H, SelectionState as I, SelectionSummary as J, SerializedSelection as K, LocalStorageSavedViewStoreOptions as L, StatusTone as M, StorageLike as N, SortModelItem as S, CellType as a, ColumnAlign as b, ColumnEditor as c, ColumnFilterType as d, FilterOperator as e, FilterModelItem as f, SortDirection as g, GetRowsRequest as h, ServerDataSource as i, AggregateFn as j, CaptureViewOptions as k, CellFormatter as l, ColumnLayout as m, ColumnOption as n, ColumnPin as o, ColumnPinning as p, ColumnState as q, DataGridMessages as r, DelimitedOptions as s, FormatLabels as u, GetRowsOptions as v, GetRowsResult as w, GridViewState as x, SavedView as z };
|