@svgrid/grid 1.0.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/LICENSE +33 -0
- package/README.md +39 -0
- package/dist/FlexRender.svelte +96 -0
- package/dist/FlexRender.svelte.d.ts +49 -0
- package/dist/SvGrid.svelte +8742 -0
- package/dist/SvGrid.svelte.d.ts +381 -0
- package/dist/SvGridChart.svelte +653 -0
- package/dist/SvGridChart.svelte.d.ts +25 -0
- package/dist/SvGridChart.test.d.ts +1 -0
- package/dist/SvGridChart.test.js +62 -0
- package/dist/SvGridDropdown.svelte +675 -0
- package/dist/SvGridDropdown.svelte.d.ts +40 -0
- package/dist/a11y.contract.test.d.ts +1 -0
- package/dist/a11y.contract.test.js +39 -0
- package/dist/a11y.d.ts +38 -0
- package/dist/a11y.js +37 -0
- package/dist/a11y.test.d.ts +1 -0
- package/dist/a11y.test.js +44 -0
- package/dist/cell-formatting.d.ts +17 -0
- package/dist/cell-formatting.js +141 -0
- package/dist/cell-formatting.test.d.ts +1 -0
- package/dist/cell-formatting.test.js +234 -0
- package/dist/chart-export.d.ts +14 -0
- package/dist/chart-export.js +112 -0
- package/dist/chart.d.ts +226 -0
- package/dist/chart.js +732 -0
- package/dist/chart.test.d.ts +1 -0
- package/dist/chart.test.js +289 -0
- package/dist/collaboration.d.ts +74 -0
- package/dist/collaboration.js +98 -0
- package/dist/collaboration.test.d.ts +1 -0
- package/dist/collaboration.test.js +65 -0
- package/dist/conditional-formatting.d.ts +91 -0
- package/dist/conditional-formatting.js +170 -0
- package/dist/conditional-formatting.test.d.ts +1 -0
- package/dist/conditional-formatting.test.js +87 -0
- package/dist/core.coverage.test.d.ts +1 -0
- package/dist/core.coverage.test.js +186 -0
- package/dist/core.d.ts +370 -0
- package/dist/core.js +568 -0
- package/dist/core.performance.test.d.ts +1 -0
- package/dist/core.performance.test.js +29 -0
- package/dist/createGrid.svelte.d.ts +6 -0
- package/dist/createGrid.svelte.js +17 -0
- package/dist/createGrid.test.d.ts +1 -0
- package/dist/createGrid.test.js +9 -0
- package/dist/createGridState.svelte.d.ts +3 -0
- package/dist/createGridState.svelte.js +13 -0
- package/dist/editors/cell-editors.d.ts +23 -0
- package/dist/editors/cell-editors.js +97 -0
- package/dist/editors/cell-editors.test.d.ts +1 -0
- package/dist/editors/cell-editors.test.js +75 -0
- package/dist/fill-patterns.d.ts +30 -0
- package/dist/fill-patterns.js +207 -0
- package/dist/fill-patterns.test.d.ts +1 -0
- package/dist/fill-patterns.test.js +81 -0
- package/dist/filtering/excel-filters.d.ts +26 -0
- package/dist/filtering/excel-filters.js +64 -0
- package/dist/filtering/excel-filters.test.d.ts +1 -0
- package/dist/filtering/excel-filters.test.js +116 -0
- package/dist/filtering/locale-filter.test.d.ts +13 -0
- package/dist/filtering/locale-filter.test.js +189 -0
- package/dist/flex-render.d.ts +1 -0
- package/dist/flex-render.js +2 -0
- package/dist/flex-render.test.d.ts +1 -0
- package/dist/flex-render.test.js +142 -0
- package/dist/group-aggregate.test.d.ts +1 -0
- package/dist/group-aggregate.test.js +32 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +27 -0
- package/dist/keyboard.d.ts +8 -0
- package/dist/keyboard.js +91 -0
- package/dist/keyboard.test.d.ts +1 -0
- package/dist/keyboard.test.js +27 -0
- package/dist/merge-objects.d.ts +9 -0
- package/dist/merge-objects.js +28 -0
- package/dist/named-views.d.ts +42 -0
- package/dist/named-views.js +80 -0
- package/dist/named-views.test.d.ts +1 -0
- package/dist/named-views.test.js +57 -0
- package/dist/new-features.test.d.ts +1 -0
- package/dist/new-features.test.js +183 -0
- package/dist/render-component.d.ts +13 -0
- package/dist/render-component.js +14 -0
- package/dist/render-component.test.d.ts +1 -0
- package/dist/render-component.test.js +41 -0
- package/dist/server-data-source.d.ts +76 -0
- package/dist/server-data-source.js +83 -0
- package/dist/server-data-source.test.d.ts +1 -0
- package/dist/server-data-source.test.js +81 -0
- package/dist/sparkline.d.ts +56 -0
- package/dist/sparkline.js +97 -0
- package/dist/sparkline.test.d.ts +1 -0
- package/dist/sparkline.test.js +52 -0
- package/dist/static-functions.d.ts +1 -0
- package/dist/static-functions.js +1 -0
- package/dist/subscribe.d.ts +9 -0
- package/dist/subscribe.js +31 -0
- package/dist/subscribe.test.d.ts +1 -0
- package/dist/subscribe.test.js +93 -0
- package/dist/sv-grid-scrollbar.d.ts +1 -0
- package/dist/sv-grid-scrollbar.js +310 -0
- package/dist/svgrid-wrapper.types.d.ts +341 -0
- package/dist/svgrid-wrapper.types.js +1 -0
- package/dist/svgrid.api-extensions.test.d.ts +14 -0
- package/dist/svgrid.api-extensions.test.js +334 -0
- package/dist/svgrid.api.test.d.ts +15 -0
- package/dist/svgrid.api.test.js +169 -0
- package/dist/svgrid.behavior.test.d.ts +15 -0
- package/dist/svgrid.behavior.test.js +605 -0
- package/dist/svgrid.column-reorder.test.d.ts +15 -0
- package/dist/svgrid.column-reorder.test.js +224 -0
- package/dist/svgrid.features.test.d.ts +1 -0
- package/dist/svgrid.features.test.js +129 -0
- package/dist/svgrid.interaction.test.d.ts +9 -0
- package/dist/svgrid.interaction.test.js +318 -0
- package/dist/svgrid.locale-filtering.test.d.ts +15 -0
- package/dist/svgrid.locale-filtering.test.js +261 -0
- package/dist/svgrid.new-features.wrapper.test.d.ts +1 -0
- package/dist/svgrid.new-features.wrapper.test.js +136 -0
- package/dist/svgrid.row-pinning.test.d.ts +14 -0
- package/dist/svgrid.row-pinning.test.js +250 -0
- package/dist/svgrid.set-filter.test.d.ts +17 -0
- package/dist/svgrid.set-filter.test.js +268 -0
- package/dist/svgrid.wrapper.test.d.ts +1 -0
- package/dist/svgrid.wrapper.test.js +33 -0
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.js +29 -0
- package/dist/transaction.test.d.ts +1 -0
- package/dist/transaction.test.js +89 -0
- package/dist/virtualization/column-virtualizer.d.ts +20 -0
- package/dist/virtualization/column-virtualizer.js +19 -0
- package/dist/virtualization/column-virtualizer.test.d.ts +1 -0
- package/dist/virtualization/column-virtualizer.test.js +25 -0
- package/dist/virtualization/svelte-virtualizer.svelte.d.ts +11 -0
- package/dist/virtualization/svelte-virtualizer.svelte.js +20 -0
- package/dist/virtualization/types.d.ts +28 -0
- package/dist/virtualization/types.js +1 -0
- package/dist/virtualization/virtualizer.d.ts +13 -0
- package/dist/virtualization/virtualizer.js +232 -0
- package/dist/virtualization/virtualizer.test.d.ts +1 -0
- package/dist/virtualization/virtualizer.test.js +41 -0
- package/package.json +69 -0
- package/src/FlexRender.svelte +96 -0
- package/src/SvGrid.svelte +8742 -0
- package/src/SvGridChart.svelte +653 -0
- package/src/SvGridChart.test.ts +69 -0
- package/src/SvGridDropdown.svelte +675 -0
- package/src/a11y.contract.test.ts +49 -0
- package/src/a11y.test.ts +59 -0
- package/src/a11y.ts +59 -0
- package/src/cell-formatting.test.ts +273 -0
- package/src/cell-formatting.ts +169 -0
- package/src/chart-export.ts +144 -0
- package/src/chart.test.ts +311 -0
- package/src/chart.ts +934 -0
- package/src/collaboration.test.ts +74 -0
- package/src/collaboration.ts +161 -0
- package/src/conditional-formatting.test.ts +107 -0
- package/src/conditional-formatting.ts +239 -0
- package/src/core.coverage.test.ts +230 -0
- package/src/core.performance.test.ts +30 -0
- package/src/core.ts +991 -0
- package/src/createGrid.svelte.ts +42 -0
- package/src/createGrid.test.ts +10 -0
- package/src/createGridState.svelte.ts +17 -0
- package/src/editors/cell-editors.test.ts +80 -0
- package/src/editors/cell-editors.ts +127 -0
- package/src/fill-patterns.test.ts +93 -0
- package/src/fill-patterns.ts +229 -0
- package/src/filtering/excel-filters.test.ts +131 -0
- package/src/filtering/excel-filters.ts +101 -0
- package/src/filtering/locale-filter.test.ts +220 -0
- package/src/flex-render.test.ts +143 -0
- package/src/flex-render.ts +3 -0
- package/src/group-aggregate.test.ts +48 -0
- package/src/index.ts +159 -0
- package/src/keyboard.test.ts +59 -0
- package/src/keyboard.ts +97 -0
- package/src/merge-objects.ts +48 -0
- package/src/named-views.test.ts +66 -0
- package/src/named-views.ts +120 -0
- package/src/new-features.test.ts +217 -0
- package/src/render-component.test.ts +51 -0
- package/src/render-component.ts +28 -0
- package/src/server-data-source.test.ts +88 -0
- package/src/server-data-source.ts +163 -0
- package/src/sparkline.test.ts +59 -0
- package/src/sparkline.ts +164 -0
- package/src/static-functions.ts +11 -0
- package/src/subscribe.test.ts +103 -0
- package/src/subscribe.ts +38 -0
- package/src/sv-grid-scrollbar.ts +347 -0
- package/src/svgrid-wrapper.types.ts +382 -0
- package/src/svgrid.api-extensions.test.ts +362 -0
- package/src/svgrid.api.test.ts +192 -0
- package/src/svgrid.behavior.test.ts +657 -0
- package/src/svgrid.column-reorder.test.ts +234 -0
- package/src/svgrid.features.test.ts +157 -0
- package/src/svgrid.interaction.test.ts +355 -0
- package/src/svgrid.locale-filtering.test.ts +259 -0
- package/src/svgrid.new-features.wrapper.test.ts +164 -0
- package/src/svgrid.row-pinning.test.ts +266 -0
- package/src/svgrid.set-filter.test.ts +270 -0
- package/src/svgrid.wrapper.test.ts +35 -0
- package/src/test-setup.ts +37 -0
- package/src/transaction.test.ts +100 -0
- package/src/virtualization/column-virtualizer.test.ts +27 -0
- package/src/virtualization/column-virtualizer.ts +30 -0
- package/src/virtualization/svelte-virtualizer.svelte.ts +24 -0
- package/src/virtualization/types.ts +30 -0
- package/src/virtualization/virtualizer.test.ts +47 -0
- package/src/virtualization/virtualizer.ts +270 -0
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import type { SparklineConfig } from './sparkline';
|
|
2
|
+
export type RowData = Record<string, unknown>;
|
|
3
|
+
export type Updater<T> = T | ((prev: T) => T);
|
|
4
|
+
export type SortingState = Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
desc: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export type ColumnFilter = {
|
|
9
|
+
id: string;
|
|
10
|
+
value: unknown;
|
|
11
|
+
fn?: keyof typeof filterFns;
|
|
12
|
+
};
|
|
13
|
+
export type ColumnFiltersState = Array<ColumnFilter>;
|
|
14
|
+
export type PaginationState = {
|
|
15
|
+
pageIndex: number;
|
|
16
|
+
pageSize: number;
|
|
17
|
+
};
|
|
18
|
+
export type GroupingState = Array<string>;
|
|
19
|
+
export type ExpandedState = Record<string, boolean>;
|
|
20
|
+
export type RowSelectionState = Record<string, boolean>;
|
|
21
|
+
export type ActiveCellState = {
|
|
22
|
+
rowIndex: number;
|
|
23
|
+
colIndex: number;
|
|
24
|
+
cellId: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type TableFeatures = Record<string, unknown>;
|
|
27
|
+
export type CellData = unknown;
|
|
28
|
+
export type HeaderContext<TData extends RowData> = {
|
|
29
|
+
header: Header<TData>;
|
|
30
|
+
column: Column<TData>;
|
|
31
|
+
table: SvGrid<TData>;
|
|
32
|
+
};
|
|
33
|
+
export type CellContext<TData extends RowData> = {
|
|
34
|
+
cell: Cell<TData>;
|
|
35
|
+
row: Row<TData>;
|
|
36
|
+
column: Column<TData>;
|
|
37
|
+
table: SvGrid<TData>;
|
|
38
|
+
getValue: () => unknown;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Context passed to a custom `cellEditor` snippet/component. Three write
|
|
42
|
+
* helpers cover the lifecycle:
|
|
43
|
+
*
|
|
44
|
+
* - `update(next)` - stage `next` as the draft, keep the editor open.
|
|
45
|
+
* Use this for live-preview controls (sliders,
|
|
46
|
+
* color pickers) so the user can keep adjusting.
|
|
47
|
+
* - `commit(next?)` - write the value AND close the editor. The
|
|
48
|
+
* argument is optional; when omitted, the most
|
|
49
|
+
* recently `update()`d value is saved. Use this
|
|
50
|
+
* for "done" gestures (Enter, picking an option).
|
|
51
|
+
* - `cancel()` - discard the draft and close the editor.
|
|
52
|
+
*/
|
|
53
|
+
export type EditorContext<TData extends RowData> = CellContext<TData> & {
|
|
54
|
+
value: unknown;
|
|
55
|
+
update: (next: unknown) => void;
|
|
56
|
+
commit: (next?: unknown) => void;
|
|
57
|
+
cancel: () => void;
|
|
58
|
+
};
|
|
59
|
+
export type CellFormatConfig = {
|
|
60
|
+
type: 'number';
|
|
61
|
+
locales?: string | Array<string>;
|
|
62
|
+
options?: Intl.NumberFormatOptions;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'currency';
|
|
65
|
+
/** ISO 4217 (default USD) */
|
|
66
|
+
currency?: string;
|
|
67
|
+
locales?: string | Array<string>;
|
|
68
|
+
options?: Omit<Intl.NumberFormatOptions, 'style' | 'currency'>;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'percent';
|
|
71
|
+
locales?: string | Array<string>;
|
|
72
|
+
options?: Omit<Intl.NumberFormatOptions, 'style'>;
|
|
73
|
+
/**
|
|
74
|
+
* If true, numeric cell values are 0–100 (e.g. 42 → 42%) instead of Intl’s 0–1 fraction (0.42 → 42%).
|
|
75
|
+
* Default false.
|
|
76
|
+
*/
|
|
77
|
+
valueIsPercentPoints?: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'date' | 'datetime';
|
|
80
|
+
locales?: string | Array<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Shortcut patterns merged with `options`:
|
|
83
|
+
* `'d'` short numeric date, `'D'` long date, `'y-m-d'` yyyy/mm/dd-style,
|
|
84
|
+
* `'short'`|`'medium'`|`'long'` use dateStyle/timeStyle presets.
|
|
85
|
+
*/
|
|
86
|
+
pattern?: string;
|
|
87
|
+
options?: Intl.DateTimeFormatOptions;
|
|
88
|
+
};
|
|
89
|
+
export type CellFormatter<TData extends RowData> = (context: {
|
|
90
|
+
value: unknown;
|
|
91
|
+
row: Row<TData>;
|
|
92
|
+
column: Column<TData>;
|
|
93
|
+
table: SvGrid<TData>;
|
|
94
|
+
}) => string;
|
|
95
|
+
export type ColumnDefTemplate<TContext> = string | ((context: TContext) => unknown);
|
|
96
|
+
/**
|
|
97
|
+
* How a column's value is aggregated for a group row when `columnGrouping`
|
|
98
|
+
* is active. Built-in reducers cover the common cases; pass a function for
|
|
99
|
+
* anything custom (weighted average, median, percentile, distinct count).
|
|
100
|
+
* The function receives the finite numeric values AND the raw leaf rows.
|
|
101
|
+
*/
|
|
102
|
+
export type GroupAggregator<TData = any> = 'sum' | 'avg' | 'min' | 'max' | 'count' | 'countDistinct' | 'extent' | 'first' | ((values: number[], rows: Array<TData>) => unknown);
|
|
103
|
+
/** Apply a group aggregator over a bucket's leaf rows for one column. */
|
|
104
|
+
export declare function applyGroupAggregate<TData extends RowData>(agg: GroupAggregator<TData>, columnId: string, rows: ReadonlyArray<Row<TData>>): unknown;
|
|
105
|
+
export type ColumnDef<TFeatures extends TableFeatures, TData extends RowData> = {
|
|
106
|
+
id?: string;
|
|
107
|
+
field?: keyof TData & string;
|
|
108
|
+
accessorFn?: (row: TData) => unknown;
|
|
109
|
+
header?: ColumnDefTemplate<HeaderContext<TData>>;
|
|
110
|
+
footer?: ColumnDefTemplate<HeaderContext<TData>>;
|
|
111
|
+
cell?: ColumnDefTemplate<CellContext<TData>>;
|
|
112
|
+
columns?: Array<ColumnDef<TFeatures, TData>>;
|
|
113
|
+
editorType?: 'text' | 'number' | 'date' | 'datetime' | 'time' | 'password' | 'checkbox' | 'list' | 'chips' | 'select' | 'rich-select' | 'textarea' | 'color' | 'rating';
|
|
114
|
+
/**
|
|
115
|
+
* Custom in-cell editor. Receives the cell context PLUS a `commit(value)`
|
|
116
|
+
* and `cancel()` helper. Use when none of the built-in `editorType`s fit;
|
|
117
|
+
* the snippet's outer element is mounted inside the editing cell and
|
|
118
|
+
* inherits keyboard handling (Esc cancels, Enter commits unless your
|
|
119
|
+
* snippet preventDefaults it).
|
|
120
|
+
*
|
|
121
|
+
* Coexists with `editorType`: when both are set, `cellEditor` wins and
|
|
122
|
+
* `editorType` is treated as a hint for parsing the saved value.
|
|
123
|
+
*/
|
|
124
|
+
cellEditor?: ColumnDefTemplate<EditorContext<TData>>;
|
|
125
|
+
/**
|
|
126
|
+
* Per-column tooltip. String shows as a native `title=`; `(ctx) => string`
|
|
127
|
+
* runs per cell so the tooltip can reflect the value. Returning an empty
|
|
128
|
+
* string skips the tooltip.
|
|
129
|
+
*/
|
|
130
|
+
tooltip?: string | ((ctx: CellContext<TData>) => string | null | undefined);
|
|
131
|
+
/**
|
|
132
|
+
* Gate editing per column or per cell.
|
|
133
|
+
*
|
|
134
|
+
* - `true` (or omitted): the column is fully editable.
|
|
135
|
+
* - `false`: the column is read-only - double-click, type-to-edit,
|
|
136
|
+
* fill-handle drag, Delete, and clipboard paste all skip it.
|
|
137
|
+
* - `(ctx) => boolean`: evaluated for each cell, so you can lock
|
|
138
|
+
* individual rows (e.g. by role, status, ownership). Returning
|
|
139
|
+
* `false` opts the cell out of every editing path, identical to
|
|
140
|
+
* setting `editable: false` on the whole column for that row.
|
|
141
|
+
*
|
|
142
|
+
* The grid-wide `enableInlineEditing` prop still wins when set to
|
|
143
|
+
* `false`.
|
|
144
|
+
*/
|
|
145
|
+
editable?: boolean | ((context: CellContext<TData>) => boolean);
|
|
146
|
+
/**
|
|
147
|
+
* When `false`, this column never shows a sort indicator and clicking
|
|
148
|
+
* its header is a no-op - `api.setSort(thisColumn, ...)` is also
|
|
149
|
+
* ignored. Defaults to `true` (the column participates in sorting as
|
|
150
|
+
* long as `rowSortingFeature` is registered).
|
|
151
|
+
*/
|
|
152
|
+
sortable?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* When `false`, this column never shows a filter funnel / menu and
|
|
155
|
+
* `api.setFilter(thisColumn, ...)` is ignored. Defaults to `true` (the
|
|
156
|
+
* column is filterable as long as `columnFilteringFeature` is
|
|
157
|
+
* registered).
|
|
158
|
+
*/
|
|
159
|
+
filterable?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Options for `editorType: 'list' | 'chips'`. Either bare values (the
|
|
162
|
+
* string is both value and label) or `{ value, label }` objects.
|
|
163
|
+
* For `chips` this is optional - when omitted, the chips editor becomes
|
|
164
|
+
* free-form (user types and presses Enter to commit a chip).
|
|
165
|
+
*
|
|
166
|
+
* Pass a function `(row) => options` for row-dependent (cascading)
|
|
167
|
+
* options - e.g. City options that depend on Country in the same row.
|
|
168
|
+
*/
|
|
169
|
+
editorOptions?: ReadonlyArray<string | number | {
|
|
170
|
+
value: string | number;
|
|
171
|
+
label?: string;
|
|
172
|
+
color?: string;
|
|
173
|
+
}> | ((row: TData) => ReadonlyArray<string | number | {
|
|
174
|
+
value: string | number;
|
|
175
|
+
label?: string;
|
|
176
|
+
color?: string;
|
|
177
|
+
}>);
|
|
178
|
+
/** When true, list/chips allow multiple selections. Cell value becomes an array. */
|
|
179
|
+
editorMultiple?: boolean;
|
|
180
|
+
/** Separator used when joining array values for the readonly cell display. Defaults to ', '. */
|
|
181
|
+
editorSeparator?: string;
|
|
182
|
+
format?: CellFormatConfig;
|
|
183
|
+
formatter?: CellFormatter<TData>;
|
|
184
|
+
/**
|
|
185
|
+
* Aggregate this column's values into the group row when grouping is
|
|
186
|
+
* active. `'sum' | 'avg' | 'min' | 'max' | 'count' | 'countDistinct' |
|
|
187
|
+
* 'extent' | 'first'`, or a custom `(values, rows) => unknown`. The result
|
|
188
|
+
* is formatted with this column's `format` and shown in the group header.
|
|
189
|
+
*/
|
|
190
|
+
aggregate?: GroupAggregator<TData>;
|
|
191
|
+
/**
|
|
192
|
+
* Render the cell as an in-cell sparkline chart. The cell value should be
|
|
193
|
+
* an array of numbers (or a comma/space separated string). Mutually
|
|
194
|
+
* exclusive with a custom `cell` renderer (a `cell` wins if both are set).
|
|
195
|
+
*
|
|
196
|
+
* { sparkline: { type: 'line' } } // default line
|
|
197
|
+
* { sparkline: { type: 'bar', color: '#16a34a' } }
|
|
198
|
+
* { sparkline: { type: 'winloss' } } // sign-only up/down
|
|
199
|
+
*
|
|
200
|
+
* See `SparklineConfig` for the full option set (type, color,
|
|
201
|
+
* negativeColor, width, height, fixed min/max).
|
|
202
|
+
*/
|
|
203
|
+
sparkline?: SparklineConfig;
|
|
204
|
+
/** Initial column width in pixels. Falls back to the grid's `columnWidth` prop. */
|
|
205
|
+
width?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Horizontal alignment for header and body cells. When omitted, the
|
|
208
|
+
* default is inferred from `editorType`:
|
|
209
|
+
* - `'number' | 'date' | 'datetime'` → `'right'`
|
|
210
|
+
* - `'checkbox'` → `'center'`
|
|
211
|
+
* - everything else → `'left'`
|
|
212
|
+
*/
|
|
213
|
+
align?: 'left' | 'center' | 'right';
|
|
214
|
+
/**
|
|
215
|
+
* Per-cell conditional CSS. Two shapes:
|
|
216
|
+
*
|
|
217
|
+
* - **String** (or array of strings): class name(s) added to the
|
|
218
|
+
* cell's `<td>` for every row in this column.
|
|
219
|
+
* - **Function**: invoked per cell with the same `CellContext` shape
|
|
220
|
+
* the `cell` renderer receives. Return a string, an array of
|
|
221
|
+
* strings, or an object mapping class names to booleans.
|
|
222
|
+
*
|
|
223
|
+
* Use it for status tinting, conditional bold, "negative number"
|
|
224
|
+
* coloring - anything that's a function of the row's value. Cells
|
|
225
|
+
* still receive their format / cell renderer; the class just
|
|
226
|
+
* augments the rendered `<td>`.
|
|
227
|
+
*/
|
|
228
|
+
cellClass?: string | ReadonlyArray<string> | ((ctx: CellContext<TData>) => string | ReadonlyArray<string> | Record<string, boolean> | undefined | null);
|
|
229
|
+
};
|
|
230
|
+
export type Column<TData extends RowData> = {
|
|
231
|
+
id: string;
|
|
232
|
+
columnDef: ColumnDef<any, TData>;
|
|
233
|
+
depth: number;
|
|
234
|
+
parentId?: string;
|
|
235
|
+
getCanSort: () => boolean;
|
|
236
|
+
getCanFilter: () => boolean;
|
|
237
|
+
getIsSorted: () => false | 'asc' | 'desc';
|
|
238
|
+
getToggleSortingHandler: () => () => void;
|
|
239
|
+
};
|
|
240
|
+
export type Header<TData extends RowData> = {
|
|
241
|
+
id: string;
|
|
242
|
+
isPlaceholder: boolean;
|
|
243
|
+
colSpan: number;
|
|
244
|
+
column: Column<TData>;
|
|
245
|
+
getContext: () => HeaderContext<TData>;
|
|
246
|
+
};
|
|
247
|
+
export type HeaderGroup<TData extends RowData> = {
|
|
248
|
+
id: string;
|
|
249
|
+
headers: Array<Header<TData>>;
|
|
250
|
+
};
|
|
251
|
+
export type Cell<TData extends RowData> = {
|
|
252
|
+
id: string;
|
|
253
|
+
row: Row<TData>;
|
|
254
|
+
column: Column<TData>;
|
|
255
|
+
getValue: () => unknown;
|
|
256
|
+
getContext: () => CellContext<TData>;
|
|
257
|
+
};
|
|
258
|
+
export type Row<TData extends RowData> = {
|
|
259
|
+
id: string;
|
|
260
|
+
index: number;
|
|
261
|
+
original: TData;
|
|
262
|
+
depth: number;
|
|
263
|
+
subRows?: Array<Row<TData>>;
|
|
264
|
+
/** Total leaf (data) rows under this group row. Undefined for data rows. */
|
|
265
|
+
leafCount?: number;
|
|
266
|
+
getCanExpand: () => boolean;
|
|
267
|
+
getIsExpanded: () => boolean;
|
|
268
|
+
toggleExpanded: () => void;
|
|
269
|
+
getIsSelected: () => boolean;
|
|
270
|
+
toggleSelected: () => void;
|
|
271
|
+
getAllCells: () => Array<Cell<TData>>;
|
|
272
|
+
getCellValueByColumnId: (columnId: string) => unknown;
|
|
273
|
+
};
|
|
274
|
+
export type RowModel<TData extends RowData> = {
|
|
275
|
+
rows: Array<Row<TData>>;
|
|
276
|
+
};
|
|
277
|
+
export type Store<T> = {
|
|
278
|
+
readonly state: T;
|
|
279
|
+
setState: (updater: (prev: T) => T) => void;
|
|
280
|
+
subscribe: (listener: () => void) => () => void;
|
|
281
|
+
};
|
|
282
|
+
export declare const rowSortingFeature: {
|
|
283
|
+
key: string;
|
|
284
|
+
};
|
|
285
|
+
export declare const columnFilteringFeature: {
|
|
286
|
+
key: string;
|
|
287
|
+
};
|
|
288
|
+
export declare const rowPaginationFeature: {
|
|
289
|
+
key: string;
|
|
290
|
+
};
|
|
291
|
+
export declare const columnGroupingFeature: {
|
|
292
|
+
key: string;
|
|
293
|
+
};
|
|
294
|
+
export declare const rowSelectionFeature: {
|
|
295
|
+
key: string;
|
|
296
|
+
};
|
|
297
|
+
export declare const rowExpandingFeature: {
|
|
298
|
+
key: string;
|
|
299
|
+
};
|
|
300
|
+
export declare function tableFeatures<T extends TableFeatures>(features: T): T;
|
|
301
|
+
export declare const sortFns: {
|
|
302
|
+
auto: (a: unknown, b: unknown) => number;
|
|
303
|
+
number: (a: unknown, b: unknown) => number;
|
|
304
|
+
date: (a: unknown, b: unknown) => number;
|
|
305
|
+
};
|
|
306
|
+
export declare const filterFns: {
|
|
307
|
+
includesString: (value: unknown, query: string) => boolean;
|
|
308
|
+
equals: (value: unknown, query: unknown) => boolean;
|
|
309
|
+
};
|
|
310
|
+
export type RowModelFactory<TData extends RowData> = (args: {
|
|
311
|
+
table: SvGrid<TData>;
|
|
312
|
+
rows: Array<Row<TData>>;
|
|
313
|
+
}) => Array<Row<TData>>;
|
|
314
|
+
export declare function createCoreRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
315
|
+
export declare function createFilteredRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
316
|
+
export declare function createPaginatedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
317
|
+
export declare function createGroupedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
318
|
+
export declare function createExpandedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
319
|
+
export declare function createSortedRowModel<TData extends RowData>(localSortFns?: typeof sortFns): RowModelFactory<TData>;
|
|
320
|
+
export type SvGridOptions<TFeatures extends TableFeatures, TData extends RowData> = {
|
|
321
|
+
_features: TFeatures;
|
|
322
|
+
_rowModels?: {
|
|
323
|
+
coreRowModel?: RowModelFactory<TData>;
|
|
324
|
+
filteredRowModel?: RowModelFactory<TData>;
|
|
325
|
+
sortedRowModel?: RowModelFactory<TData>;
|
|
326
|
+
paginatedRowModel?: RowModelFactory<TData>;
|
|
327
|
+
groupedRowModel?: RowModelFactory<TData>;
|
|
328
|
+
expandedRowModel?: RowModelFactory<TData>;
|
|
329
|
+
};
|
|
330
|
+
columns: Array<ColumnDef<TFeatures, TData>>;
|
|
331
|
+
data: ReadonlyArray<TData>;
|
|
332
|
+
/**
|
|
333
|
+
* Optional row-id resolver. When set, the value it returns becomes
|
|
334
|
+
* `row.id` (and therefore the selection / expansion / edit key). When
|
|
335
|
+
* omitted, ids fall back to the row's array index as a string. Use a
|
|
336
|
+
* stable id (database PK, UUID, etc.) so selection survives reorders.
|
|
337
|
+
*/
|
|
338
|
+
getRowId?: (row: TData, index: number) => string;
|
|
339
|
+
state?: Partial<Record<string, any>>;
|
|
340
|
+
onSortingChange?: (updater: Updater<SortingState>) => void;
|
|
341
|
+
onColumnFiltersChange?: (updater: Updater<ColumnFiltersState>) => void;
|
|
342
|
+
onPaginationChange?: (updater: Updater<PaginationState>) => void;
|
|
343
|
+
onGroupingChange?: (updater: Updater<GroupingState>) => void;
|
|
344
|
+
onExpandedChange?: (updater: Updater<ExpandedState>) => void;
|
|
345
|
+
onRowSelectionChange?: (updater: Updater<RowSelectionState>) => void;
|
|
346
|
+
onActiveCellChange?: (updater: Updater<ActiveCellState>) => void;
|
|
347
|
+
};
|
|
348
|
+
export type SvGrid<TData extends RowData> = {
|
|
349
|
+
store: Store<Record<string, any>>;
|
|
350
|
+
optionsStore: Store<Record<string, any>>;
|
|
351
|
+
state: Record<string, any>;
|
|
352
|
+
getState: () => Record<string, any>;
|
|
353
|
+
setOptions: (updater: Updater<Record<string, any>>) => void;
|
|
354
|
+
setColumnFilters: (updater: Updater<ColumnFiltersState>) => void;
|
|
355
|
+
setPagination: (updater: Updater<PaginationState>) => void;
|
|
356
|
+
setGrouping: (updater: Updater<GroupingState>) => void;
|
|
357
|
+
setExpanded: (updater: Updater<ExpandedState>) => void;
|
|
358
|
+
setRowSelection: (updater: Updater<RowSelectionState>) => void;
|
|
359
|
+
setActiveCell: (updater: Updater<ActiveCellState>) => void;
|
|
360
|
+
moveActiveCell: (next: {
|
|
361
|
+
rowDelta?: number;
|
|
362
|
+
colDelta?: number;
|
|
363
|
+
}) => void;
|
|
364
|
+
getAllColumns: () => Array<Column<TData>>;
|
|
365
|
+
getHeaderGroups: () => Array<HeaderGroup<TData>>;
|
|
366
|
+
getFooterGroups: () => Array<HeaderGroup<TData>>;
|
|
367
|
+
getRowModel: () => RowModel<TData>;
|
|
368
|
+
};
|
|
369
|
+
export declare function createSvGridCore<TFeatures extends TableFeatures, TData extends RowData>(options: SvGridOptions<TFeatures, TData>): SvGrid<TData>;
|
|
370
|
+
export declare function isFunction(value: unknown): value is (...args: Array<any>) => any;
|