@svgrid/grid 1.1.0 → 1.1.2
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/FlexRender.svelte +96 -96
- package/dist/GridMenus.svelte +205 -127
- package/dist/SvGrid.controller.svelte.d.ts +44 -1
- package/dist/SvGrid.controller.svelte.js +240 -44
- package/dist/SvGrid.css +325 -22
- package/dist/SvGrid.helpers.test.d.ts +1 -0
- package/dist/SvGrid.helpers.test.js +298 -0
- package/dist/SvGrid.svelte +729 -203
- package/dist/SvGrid.types.d.ts +91 -4
- package/dist/aligned-grids.d.ts +6 -0
- package/dist/aligned-grids.js +84 -0
- package/dist/aligned-grids.test.d.ts +1 -0
- package/dist/aligned-grids.test.js +75 -0
- package/dist/build-api.coverage.test.d.ts +20 -0
- package/dist/build-api.coverage.test.js +505 -0
- package/dist/build-api.js +61 -31
- package/dist/cell-render.test.d.ts +1 -0
- package/dist/cell-render.test.js +338 -0
- package/dist/cell-values.d.ts +1 -1
- package/dist/cell-values.js +7 -7
- package/dist/chart-export.test.d.ts +1 -0
- package/dist/chart-export.test.js +302 -0
- package/dist/chart.coverage.test.d.ts +1 -0
- package/dist/chart.coverage.test.js +748 -0
- package/dist/clipboard.js +88 -24
- package/dist/clipboard.test.d.ts +1 -0
- package/dist/clipboard.test.js +700 -0
- package/dist/collaboration.coverage.test.d.ts +1 -0
- package/dist/collaboration.coverage.test.js +200 -0
- package/dist/column-groups.d.ts +19 -0
- package/dist/column-groups.js +62 -0
- package/dist/column-groups.test.d.ts +1 -0
- package/dist/column-groups.test.js +56 -0
- package/dist/column-types.d.ts +10 -0
- package/dist/column-types.js +63 -0
- package/dist/column-types.test.d.ts +1 -0
- package/dist/column-types.test.js +62 -0
- package/dist/columns.test.d.ts +1 -0
- package/dist/columns.test.js +625 -0
- package/dist/core.d.ts +86 -1
- package/dist/core.js +2 -2
- package/dist/editing.d.ts +7 -0
- package/dist/editing.js +191 -5
- package/dist/editing.test.d.ts +1 -0
- package/dist/editing.test.js +732 -0
- package/dist/editors/cell-editors.coverage.test.d.ts +1 -0
- package/dist/editors/cell-editors.coverage.test.js +139 -0
- package/dist/facet-buckets.test.d.ts +1 -0
- package/dist/facet-buckets.test.js +296 -0
- package/dist/filter-operators.test.d.ts +1 -0
- package/dist/filter-operators.test.js +135 -0
- package/dist/hyperformula-adapter.test.d.ts +1 -0
- package/dist/hyperformula-adapter.test.js +205 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -1
- package/dist/keyboard-handlers.coverage.test.d.ts +1 -0
- package/dist/keyboard-handlers.coverage.test.js +495 -0
- package/dist/keyboard-handlers.js +7 -2
- package/dist/menus.js +1 -0
- package/dist/menus.test.d.ts +1 -0
- package/dist/menus.test.js +560 -0
- package/dist/named-views.coverage.test.d.ts +1 -0
- package/dist/named-views.coverage.test.js +180 -0
- package/dist/row-drag.d.ts +49 -0
- package/dist/row-drag.js +221 -0
- package/dist/row-drag.test.d.ts +1 -0
- package/dist/row-drag.test.js +142 -0
- package/dist/row-resize.test.d.ts +1 -0
- package/dist/row-resize.test.js +329 -0
- package/dist/scroll-sync.js +3 -0
- package/dist/scroll-sync.test.d.ts +1 -0
- package/dist/scroll-sync.test.js +290 -0
- package/dist/selection.d.ts +7 -1
- package/dist/selection.js +76 -36
- package/dist/selection.multi-range.test.d.ts +1 -0
- package/dist/selection.multi-range.test.js +55 -0
- package/dist/selection.test.d.ts +1 -0
- package/dist/selection.test.js +647 -0
- package/dist/server-data-source.coverage.test.d.ts +1 -0
- package/dist/server-data-source.coverage.test.js +154 -0
- package/dist/spreadsheet.d.ts +30 -0
- package/dist/spreadsheet.js +48 -0
- package/dist/spreadsheet.test.d.ts +1 -0
- package/dist/spreadsheet.test.js +446 -0
- package/dist/summaries.js +4 -4
- package/dist/sv-grid-scrollbar.js +13 -1
- package/dist/svgrid-wrapper.types.d.ts +19 -0
- package/dist/svgrid.behavior.test.js +20 -0
- package/dist/svgrid.interaction.test.js +31 -0
- package/dist/svgrid.new-features.wrapper.test.js +34 -2
- package/dist/test-setup.js +9 -3
- package/dist/virtualization/scroll-scaling.d.ts +17 -0
- package/dist/virtualization/scroll-scaling.js +35 -0
- package/dist/virtualization/scroll-scaling.test.js +42 -1
- package/package.json +2 -1
- package/src/FlexRender.svelte +96 -96
- package/src/GridMenus.svelte +205 -127
- package/src/SvGrid.controller.svelte.ts +204 -36
- package/src/SvGrid.css +277 -12
- package/src/SvGrid.svelte +727 -205
- package/src/SvGrid.types.ts +85 -4
- package/src/a11y.contract.test.ts +49 -49
- package/src/a11y.test.ts +59 -59
- package/src/a11y.ts +59 -59
- package/src/aligned-grids.test.ts +80 -0
- package/src/aligned-grids.ts +87 -0
- package/src/build-api.ts +43 -23
- package/src/cell-formatting.ts +169 -169
- package/src/cell-values.ts +4 -4
- package/src/clipboard.test.ts +49 -0
- package/src/clipboard.ts +51 -23
- package/src/column-groups.test.ts +59 -0
- package/src/column-groups.ts +80 -0
- package/src/column-types.test.ts +68 -0
- package/src/column-types.ts +82 -0
- package/src/core.performance.test.ts +30 -30
- package/src/core.ts +1077 -999
- package/src/createGrid.svelte.ts +42 -42
- package/src/createGrid.test.ts +10 -10
- package/src/createGridState.svelte.ts +17 -17
- package/src/editing.ts +161 -5
- package/src/flex-render.ts +3 -3
- package/src/index.ts +208 -196
- package/src/keyboard.test.ts +59 -59
- package/src/keyboard.ts +97 -97
- package/src/menus.ts +1 -0
- package/src/merge-objects.ts +48 -48
- package/src/render-component.ts +28 -28
- package/src/row-drag.test.ts +168 -0
- package/src/row-drag.ts +255 -0
- package/src/scroll-sync.ts +2 -0
- package/src/selection.multi-range.test.ts +61 -0
- package/src/selection.ts +71 -37
- package/src/spreadsheet.test.ts +46 -2
- package/src/spreadsheet.ts +58 -0
- package/src/static-functions.ts +11 -11
- package/src/subscribe.ts +38 -38
- package/src/summaries.ts +4 -4
- package/src/svgrid-wrapper.types.ts +412 -393
- package/src/svgrid.features.test.ts +157 -157
- package/src/svgrid.new-features.wrapper.test.ts +2 -2
- package/src/svgrid.wrapper.test.ts +40 -40
- package/src/virtualization/column-virtualizer.test.ts +27 -27
- package/src/virtualization/column-virtualizer.ts +30 -30
- package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
- package/src/virtualization/types.ts +30 -30
- package/src/virtualization/virtualizer.test.ts +47 -47
- package/src/virtualization/virtualizer.ts +296 -296
|
@@ -1,393 +1,412 @@
|
|
|
1
|
-
import type { ColumnDef, RowData, SvGridOptions, TableFeatures } from './core'
|
|
2
|
-
|
|
3
|
-
export type SvGridFilterOperator =
|
|
4
|
-
| 'contains'
|
|
5
|
-
| 'equals'
|
|
6
|
-
| 'startsWith'
|
|
7
|
-
| 'greaterThan'
|
|
8
|
-
| 'lessThan'
|
|
9
|
-
| 'between'
|
|
10
|
-
| 'isBlank'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A serializable snapshot of everything that makes up the current "view":
|
|
14
|
-
* sort, grouping, pagination, column layout (width / pinning / order /
|
|
15
|
-
* visibility), and all filter surfaces. Round-trippable through
|
|
16
|
-
* `api.getState()` / `api.setState()` - persist it to a URL, localStorage, or
|
|
17
|
-
* a server to implement "save view" / "named views".
|
|
18
|
-
*/
|
|
19
|
-
export type SvGridViewState = {
|
|
20
|
-
sorting: Array<{ id: string; desc: boolean }>
|
|
21
|
-
grouping: string[]
|
|
22
|
-
pagination: { pageIndex: number; pageSize: number }
|
|
23
|
-
columnWidths: Record<string, number>
|
|
24
|
-
columnPinning: { left: string[]; right: string[] }
|
|
25
|
-
columnOrder: string[]
|
|
26
|
-
/** Ids of columns currently hidden via setColumnVisible. */
|
|
27
|
-
hiddenColumns: string[]
|
|
28
|
-
globalFilter: string
|
|
29
|
-
columnFilters: Record<
|
|
30
|
-
string,
|
|
31
|
-
{ operator: SvGridFilterOperator; value: string; valueTo?: string }
|
|
32
|
-
>
|
|
33
|
-
/** Facet (Excel-style value checklist) selections, keyed by column id. */
|
|
34
|
-
facetFilters: Record<string, string[]>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A batch of row mutations for `api.applyTransaction`. `update` / `remove`
|
|
39
|
-
* (by id) match on `getRowId`; `remove` also accepts row object references.
|
|
40
|
-
*/
|
|
41
|
-
export type SvGridTransaction<TData> = {
|
|
42
|
-
add?: ReadonlyArray<TData>
|
|
43
|
-
update?: ReadonlyArray<TData>
|
|
44
|
-
remove?: ReadonlyArray<TData | string>
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type SvGridTransactionResult = {
|
|
48
|
-
added: number
|
|
49
|
-
updated: number
|
|
50
|
-
removed: number
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Imperative API exposed via the `<SvGrid onApiReady>` callback. Use it for
|
|
55
|
-
* data, column, filter, sort, group, and visibility operations from outside
|
|
56
|
-
* the component.
|
|
57
|
-
*/
|
|
58
|
-
export type SvGridApi<
|
|
59
|
-
TFeatures extends TableFeatures,
|
|
60
|
-
TData extends RowData,
|
|
61
|
-
> = {
|
|
62
|
-
// ----- Cells -----
|
|
63
|
-
/** Read a cell value from the underlying data at `rowIndex`. */
|
|
64
|
-
getCellValue(rowIndex: number, columnId: string): unknown
|
|
65
|
-
/** Write a cell value through the column's field. */
|
|
66
|
-
setCellValue(rowIndex: number, columnId: string, value: unknown): void
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
*
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// -----
|
|
290
|
-
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
*
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
1
|
+
import type { ColumnDef, RowData, SvGridOptions, TableFeatures } from './core'
|
|
2
|
+
|
|
3
|
+
export type SvGridFilterOperator =
|
|
4
|
+
| 'contains'
|
|
5
|
+
| 'equals'
|
|
6
|
+
| 'startsWith'
|
|
7
|
+
| 'greaterThan'
|
|
8
|
+
| 'lessThan'
|
|
9
|
+
| 'between'
|
|
10
|
+
| 'isBlank'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A serializable snapshot of everything that makes up the current "view":
|
|
14
|
+
* sort, grouping, pagination, column layout (width / pinning / order /
|
|
15
|
+
* visibility), and all filter surfaces. Round-trippable through
|
|
16
|
+
* `api.getState()` / `api.setState()` - persist it to a URL, localStorage, or
|
|
17
|
+
* a server to implement "save view" / "named views".
|
|
18
|
+
*/
|
|
19
|
+
export type SvGridViewState = {
|
|
20
|
+
sorting: Array<{ id: string; desc: boolean }>
|
|
21
|
+
grouping: string[]
|
|
22
|
+
pagination: { pageIndex: number; pageSize: number }
|
|
23
|
+
columnWidths: Record<string, number>
|
|
24
|
+
columnPinning: { left: string[]; right: string[] }
|
|
25
|
+
columnOrder: string[]
|
|
26
|
+
/** Ids of columns currently hidden via setColumnVisible. */
|
|
27
|
+
hiddenColumns: string[]
|
|
28
|
+
globalFilter: string
|
|
29
|
+
columnFilters: Record<
|
|
30
|
+
string,
|
|
31
|
+
{ operator: SvGridFilterOperator; value: string; valueTo?: string }
|
|
32
|
+
>
|
|
33
|
+
/** Facet (Excel-style value checklist) selections, keyed by column id. */
|
|
34
|
+
facetFilters: Record<string, string[]>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A batch of row mutations for `api.applyTransaction`. `update` / `remove`
|
|
39
|
+
* (by id) match on `getRowId`; `remove` also accepts row object references.
|
|
40
|
+
*/
|
|
41
|
+
export type SvGridTransaction<TData> = {
|
|
42
|
+
add?: ReadonlyArray<TData>
|
|
43
|
+
update?: ReadonlyArray<TData>
|
|
44
|
+
remove?: ReadonlyArray<TData | string>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type SvGridTransactionResult = {
|
|
48
|
+
added: number
|
|
49
|
+
updated: number
|
|
50
|
+
removed: number
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Imperative API exposed via the `<SvGrid onApiReady>` callback. Use it for
|
|
55
|
+
* data, column, filter, sort, group, and visibility operations from outside
|
|
56
|
+
* the component.
|
|
57
|
+
*/
|
|
58
|
+
export type SvGridApi<
|
|
59
|
+
TFeatures extends TableFeatures,
|
|
60
|
+
TData extends RowData,
|
|
61
|
+
> = {
|
|
62
|
+
// ----- Cells -----
|
|
63
|
+
/** Read a cell value from the underlying data at `rowIndex`. */
|
|
64
|
+
getCellValue(rowIndex: number, columnId: string): unknown
|
|
65
|
+
/** Write a cell value through the column's field. */
|
|
66
|
+
setCellValue(rowIndex: number, columnId: string, value: unknown): void
|
|
67
|
+
/**
|
|
68
|
+
* Programmatically begin editing a cell (as a double-click would). Returns
|
|
69
|
+
* `true` if editing started (cell exists, editable, editing enabled).
|
|
70
|
+
*/
|
|
71
|
+
startEditing(rowIndex: number, columnId: string): boolean
|
|
72
|
+
/**
|
|
73
|
+
* Commit (default) or, with `cancel: true`, discard the active edit.
|
|
74
|
+
* Returns `true` if there was an edit in progress.
|
|
75
|
+
*/
|
|
76
|
+
stopEditing(cancel?: boolean): boolean
|
|
77
|
+
|
|
78
|
+
// ----- Cell selection -----
|
|
79
|
+
/**
|
|
80
|
+
* Programmatically select one or more rectangular cell ranges. Each
|
|
81
|
+
* range is `[rowStart, colStart, rowEnd, colEnd]` in 0-indexed grid
|
|
82
|
+
* coordinates. Pass an empty array to clear the selection.
|
|
83
|
+
*
|
|
84
|
+
* The grid currently honours the FIRST range only (single-range
|
|
85
|
+
* engine); subsequent ranges are accepted for API forward compat
|
|
86
|
+
* but ignored. The grid's active cell jumps to the range's start
|
|
87
|
+
* corner.
|
|
88
|
+
*/
|
|
89
|
+
selectCells(ranges: ReadonlyArray<readonly [number, number, number, number]>): void
|
|
90
|
+
/**
|
|
91
|
+
* Returns the current cell-selection rectangles in the same shape
|
|
92
|
+
* `selectCells` accepts. Empty array when no range is active.
|
|
93
|
+
*/
|
|
94
|
+
getSelected(): Array<[number, number, number, number]>
|
|
95
|
+
|
|
96
|
+
// ----- Rows -----
|
|
97
|
+
/** Add one row. `position` defaults to `'bottom'`. */
|
|
98
|
+
addRow(row: TData, position?: 'top' | 'bottom' | number): void
|
|
99
|
+
addRows(rows: ReadonlyArray<TData>, position?: 'top' | 'bottom' | number): void
|
|
100
|
+
/** Remove a row at the given data-array index. */
|
|
101
|
+
removeRow(rowIndex: number): void
|
|
102
|
+
removeRows(rowIndices: ReadonlyArray<number>): void
|
|
103
|
+
/**
|
|
104
|
+
* Apply a batch of add / update / remove mutations in a SINGLE data update
|
|
105
|
+
* (one re-render, not one per row) - the high-frequency / streaming path.
|
|
106
|
+
* `update` and `remove`-by-id match rows via `getRowId`, so set that prop
|
|
107
|
+
* for those to work; `remove` also accepts row object references. Returns
|
|
108
|
+
* the counts actually applied.
|
|
109
|
+
*/
|
|
110
|
+
applyTransaction(tx: SvGridTransaction<TData>): SvGridTransactionResult
|
|
111
|
+
|
|
112
|
+
// ----- Columns -----
|
|
113
|
+
/** Add one column. `position` defaults to `'right'`. */
|
|
114
|
+
addColumn(
|
|
115
|
+
column: ColumnDef<TFeatures, TData>,
|
|
116
|
+
position?: 'left' | 'right' | number,
|
|
117
|
+
): void
|
|
118
|
+
addColumns(
|
|
119
|
+
columns: ReadonlyArray<ColumnDef<TFeatures, TData>>,
|
|
120
|
+
position?: 'left' | 'right' | number,
|
|
121
|
+
): void
|
|
122
|
+
/** Remove a column by id (or field when no id was provided). */
|
|
123
|
+
removeColumn(columnId: string): void
|
|
124
|
+
|
|
125
|
+
// ----- Visibility -----
|
|
126
|
+
setColumnVisible(columnId: string, visible: boolean): void
|
|
127
|
+
isColumnVisible(columnId: string): boolean
|
|
128
|
+
|
|
129
|
+
// ----- Sort / group / filter -----
|
|
130
|
+
/** Sort by one column (replaces any existing sort). Pass `null` to clear. */
|
|
131
|
+
setSort(columnId: string, direction: 'asc' | 'desc' | null): void
|
|
132
|
+
clearSort(): void
|
|
133
|
+
setGroupBy(columnIds: ReadonlyArray<string>): void
|
|
134
|
+
/** Set the operator filter for a column. Pass `null` to clear. */
|
|
135
|
+
setFilter(
|
|
136
|
+
columnId: string,
|
|
137
|
+
filter:
|
|
138
|
+
| {
|
|
139
|
+
operator: SvGridFilterOperator
|
|
140
|
+
value?: string
|
|
141
|
+
/** Upper bound for the `between` operator. Required when `operator === 'between'`. */
|
|
142
|
+
valueTo?: string
|
|
143
|
+
/**
|
|
144
|
+
* Optional SECOND condition on the same column, joined by `join`
|
|
145
|
+
* (multi-condition filtering, e.g. "> 100 AND < 500").
|
|
146
|
+
*/
|
|
147
|
+
operator2?: SvGridFilterOperator
|
|
148
|
+
value2?: string
|
|
149
|
+
valueTo2?: string
|
|
150
|
+
/** How to combine the two conditions. Defaults to `'AND'`. */
|
|
151
|
+
join?: 'AND' | 'OR'
|
|
152
|
+
}
|
|
153
|
+
| null,
|
|
154
|
+
): void
|
|
155
|
+
/**
|
|
156
|
+
* Set the facet (set-list, Excel-style multi-select) filter for a column.
|
|
157
|
+
* Pass an empty array or `null` to clear it. The values restore the
|
|
158
|
+
* checked state of the column-menu's value list - the engine then filters
|
|
159
|
+
* the data to rows whose cell value is in the set. Used to restore
|
|
160
|
+
* snapshots captured via `onFiltersChange`'s `selectedValues`.
|
|
161
|
+
*/
|
|
162
|
+
setFacetFilter(columnId: string, values: ReadonlyArray<string> | null): void
|
|
163
|
+
clearFilter(columnId: string): void
|
|
164
|
+
/**
|
|
165
|
+
* Clear every active column filter (menu, filter-row, set-list, and global).
|
|
166
|
+
* Resets the grid to "no filtering" in a single call.
|
|
167
|
+
*/
|
|
168
|
+
clearAllFilters(): void
|
|
169
|
+
/**
|
|
170
|
+
* Read the active column-menu filters as a snapshot. Keyed by column id.
|
|
171
|
+
* Returns an empty object when nothing is filtered. `valueTo` is only
|
|
172
|
+
* present when `operator === 'between'`.
|
|
173
|
+
*/
|
|
174
|
+
getFilters(): Record<
|
|
175
|
+
string,
|
|
176
|
+
{ operator: SvGridFilterOperator; value: string; valueTo?: string }
|
|
177
|
+
>
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Snapshot of the rows the grid is actually displaying right now -
|
|
181
|
+
* after filtering, sorting, grouping, and pagination have been applied.
|
|
182
|
+
* Use this when you need to export the visible result set (e.g. CSV).
|
|
183
|
+
*/
|
|
184
|
+
getDisplayedRows(): ReadonlyArray<TData>
|
|
185
|
+
|
|
186
|
+
/** Snapshot of the current data array (pre-pipeline). */
|
|
187
|
+
getData(): ReadonlyArray<TData>
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Snapshot of every column the grid currently knows about, in visual
|
|
191
|
+
* order, with the human-readable header label. Use this when exporting
|
|
192
|
+
* or building a column-picker UI - the data is read once, no
|
|
193
|
+
* subscription. Hidden columns are included; check `visible` to filter.
|
|
194
|
+
*/
|
|
195
|
+
getColumns(): ReadonlyArray<{
|
|
196
|
+
id: string
|
|
197
|
+
field?: string
|
|
198
|
+
header: string
|
|
199
|
+
visible: boolean
|
|
200
|
+
}>
|
|
201
|
+
|
|
202
|
+
/** Clear every checked row. Emits `onRowSelectionChange({}, [])`. */
|
|
203
|
+
clearRowSelection(): void
|
|
204
|
+
|
|
205
|
+
// ----- Column layout (width + pinning) -----
|
|
206
|
+
/**
|
|
207
|
+
* Set the width of one column in pixels. Identical to dragging the
|
|
208
|
+
* column's resize handle. Width is clamped to `MIN_COLUMN_WIDTH`.
|
|
209
|
+
*/
|
|
210
|
+
setColumnWidth(columnId: string, width: number): void
|
|
211
|
+
/**
|
|
212
|
+
* Snapshot of every column's current width (in pixels), keyed by
|
|
213
|
+
* column id. Columns the user has never resized AND that have no
|
|
214
|
+
* explicit `width` on their ColumnDef are reported at the grid-wide
|
|
215
|
+
* default. Useful for "save view" + URL persistence.
|
|
216
|
+
*/
|
|
217
|
+
getColumnWidths(): Record<string, number>
|
|
218
|
+
/**
|
|
219
|
+
* Snap one column's width to its widest visible cell (header text +
|
|
220
|
+
* any rendered body cell). Equivalent to double-clicking the column's
|
|
221
|
+
* resize handle. The grid also exposes this through the column menu's
|
|
222
|
+
* "Autosize" item.
|
|
223
|
+
*/
|
|
224
|
+
autosizeColumn(columnId: string): void
|
|
225
|
+
/** Run `autosizeColumn` on every column. */
|
|
226
|
+
autosizeAllColumns(): void
|
|
227
|
+
/**
|
|
228
|
+
* Replace the column-pinning state in one call. Each entry is a
|
|
229
|
+
* column id; the order in the array becomes the visible order along
|
|
230
|
+
* the pinned edge.
|
|
231
|
+
*/
|
|
232
|
+
setColumnPinning(pinning: {
|
|
233
|
+
left?: ReadonlyArray<string>
|
|
234
|
+
right?: ReadonlyArray<string>
|
|
235
|
+
}): void
|
|
236
|
+
/** Snapshot of the current column-pinning state. */
|
|
237
|
+
getColumnPinning(): { left: string[]; right: string[] }
|
|
238
|
+
|
|
239
|
+
// ----- Column reorder -----
|
|
240
|
+
/**
|
|
241
|
+
* Replace the column order. Pass an array of column ids in the
|
|
242
|
+
* desired visual order. Unknown ids are skipped; columns not in the
|
|
243
|
+
* array keep their existing relative position after the listed ones.
|
|
244
|
+
* Fires `onColumnOrderChange` once the new order is applied. Pin
|
|
245
|
+
* groups (`columnPinning.left` / `right`) are still applied on top.
|
|
246
|
+
*/
|
|
247
|
+
setColumnOrder(order: ReadonlyArray<string>): void
|
|
248
|
+
/**
|
|
249
|
+
* Snapshot of the current visual column order - the same shape the
|
|
250
|
+
* `onColumnOrderChange` callback receives. Useful for saving and
|
|
251
|
+
* restoring a view layout.
|
|
252
|
+
*/
|
|
253
|
+
getColumnOrder(): string[]
|
|
254
|
+
|
|
255
|
+
// ----- Row expansion -----
|
|
256
|
+
/**
|
|
257
|
+
* Set whether a row (group node or expandable leaf) is expanded.
|
|
258
|
+
* The `id` is the engine's row id - for grouped rows that's the
|
|
259
|
+
* synthetic group key (e.g. `"department:Engineering"`).
|
|
260
|
+
*/
|
|
261
|
+
setRowExpanded(id: string, expanded: boolean): void
|
|
262
|
+
/** Expand every group node in the current grouped row model. */
|
|
263
|
+
expandAllGroups(): void
|
|
264
|
+
/** Collapse every expansion - resets expanded state to {}. */
|
|
265
|
+
collapseAllGroups(): void
|
|
266
|
+
|
|
267
|
+
// ----- Undo / redo -----
|
|
268
|
+
/** Undo the most recent inline-edit. Returns false when the history is empty. */
|
|
269
|
+
undo(): boolean
|
|
270
|
+
/** Redo the most recently undone edit. Returns false when the redo stack is empty. */
|
|
271
|
+
redo(): boolean
|
|
272
|
+
/** True when there's at least one step on the undo stack. */
|
|
273
|
+
canUndo(): boolean
|
|
274
|
+
/** True when there's at least one step on the redo stack. */
|
|
275
|
+
canRedo(): boolean
|
|
276
|
+
/** Wipe both stacks (e.g. after a server save commits the buffer). */
|
|
277
|
+
clearHistory(): void
|
|
278
|
+
|
|
279
|
+
// ----- Find in grid -----
|
|
280
|
+
/** Open the built-in find overlay (Ctrl+F also opens it). */
|
|
281
|
+
openFind(): void
|
|
282
|
+
/** Close the find overlay and clear the query. */
|
|
283
|
+
closeFind(): void
|
|
284
|
+
/** Update the find query programmatically (useful for app-wide command palettes). */
|
|
285
|
+
setFindQuery(q: string): void
|
|
286
|
+
/** Snapshot of the current find hits (rowIndex / colIndex / columnId). */
|
|
287
|
+
getFindHits(): Array<{ rowIndex: number; colIndex: number; columnId: string }>
|
|
288
|
+
|
|
289
|
+
// ----- Row selection (read + write) -----
|
|
290
|
+
/**
|
|
291
|
+
* The currently selected data rows (group-header rows excluded), in row-model
|
|
292
|
+
* order. Read once - no subscription. The push-based equivalent is
|
|
293
|
+
* `onRowSelectionChange`.
|
|
294
|
+
*/
|
|
295
|
+
getSelectedRows(): TData[]
|
|
296
|
+
/** The engine row ids of the selected rows. Keys into the selection record. */
|
|
297
|
+
getSelectedRowIds(): string[]
|
|
298
|
+
/**
|
|
299
|
+
* Select rows by engine row id. By default this REPLACES the selection;
|
|
300
|
+
* pass `additive: true` to add to the existing selection instead.
|
|
301
|
+
*/
|
|
302
|
+
selectRows(ids: ReadonlyArray<string>, additive?: boolean): void
|
|
303
|
+
/** Select every selectable (non-group) row in the current row model. */
|
|
304
|
+
selectAllRows(): void
|
|
305
|
+
/** Flip one row's selected state by id. */
|
|
306
|
+
toggleRowSelected(id: string): void
|
|
307
|
+
|
|
308
|
+
// ----- Pagination -----
|
|
309
|
+
/**
|
|
310
|
+
* Current pagination snapshot. `total` is the post-filter row count;
|
|
311
|
+
* `pageCount` is derived from it and `pageSize` (always >= 1).
|
|
312
|
+
*/
|
|
313
|
+
getPageInfo(): {
|
|
314
|
+
pageIndex: number
|
|
315
|
+
pageSize: number
|
|
316
|
+
pageCount: number
|
|
317
|
+
total: number
|
|
318
|
+
}
|
|
319
|
+
/** Jump to a 0-based page. Clamped to [0, pageCount - 1]. */
|
|
320
|
+
setPage(pageIndex: number): void
|
|
321
|
+
/** Advance one page (no-op past the last page). */
|
|
322
|
+
nextPage(): void
|
|
323
|
+
/** Go back one page (no-op before the first page). */
|
|
324
|
+
prevPage(): void
|
|
325
|
+
/** Jump to the first page. */
|
|
326
|
+
firstPage(): void
|
|
327
|
+
/** Jump to the last page. */
|
|
328
|
+
lastPage(): void
|
|
329
|
+
/** Change the page size, keeping the first visible row in view. */
|
|
330
|
+
setPageSize(pageSize: number): void
|
|
331
|
+
|
|
332
|
+
// ----- Navigation / scrolling -----
|
|
333
|
+
/**
|
|
334
|
+
* Scroll the body so the given row index is at the top of the viewport.
|
|
335
|
+
* Works with virtualization on. Index is clamped to the row count.
|
|
336
|
+
*/
|
|
337
|
+
scrollToRow(rowIndex: number): void
|
|
338
|
+
/** The active (focused) cell, or null when nothing is focused. */
|
|
339
|
+
getActiveCell(): { rowIndex: number; colIndex: number; columnId: string } | null
|
|
340
|
+
/** Move the active cell. Both coordinates are clamped to the grid bounds. */
|
|
341
|
+
setActiveCell(rowIndex: number, colIndex: number): void
|
|
342
|
+
|
|
343
|
+
// ----- View state (save / restore) -----
|
|
344
|
+
/**
|
|
345
|
+
* Serializable snapshot of the whole view - sort, grouping, pagination,
|
|
346
|
+
* column layout, and every filter surface. Pair with `setState` for
|
|
347
|
+
* "save view" / URL persistence / named views.
|
|
348
|
+
*/
|
|
349
|
+
getState(): SvGridViewState
|
|
350
|
+
/**
|
|
351
|
+
* Restore a view from a (partial) snapshot produced by `getState`. Only the
|
|
352
|
+
* keys present are applied, so you can restore just the columns, just the
|
|
353
|
+
* filters, etc.
|
|
354
|
+
*/
|
|
355
|
+
setState(state: Partial<SvGridViewState>): void
|
|
356
|
+
/** Force a recompute of the row pipeline + a re-render. */
|
|
357
|
+
refresh(): void
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export type SvGridWrapperProps<
|
|
361
|
+
TFeatures extends TableFeatures,
|
|
362
|
+
TData extends RowData,
|
|
363
|
+
> = {
|
|
364
|
+
data: ReadonlyArray<TData>
|
|
365
|
+
columns: Array<ColumnDef<TFeatures, TData>>
|
|
366
|
+
/**
|
|
367
|
+
* Feature set from `tableFeatures({ ... })`. Optional - the `sortable` /
|
|
368
|
+
* `filterable` / `groupable` shortcuts inject the matching feature, so a
|
|
369
|
+
* grid can be configured from the boolean shortcuts alone.
|
|
370
|
+
*/
|
|
371
|
+
features?: TFeatures
|
|
372
|
+
/**
|
|
373
|
+
* Capability shortcuts. Every capability is OFF by default (a bare grid is
|
|
374
|
+
* a plain read-only table); set a shortcut `true` to opt in.
|
|
375
|
+
*
|
|
376
|
+
* `sortable` - column sorting (injects `rowSortingFeature`)
|
|
377
|
+
* `filterable` - column filtering (injects `columnFilteringFeature`)
|
|
378
|
+
* `editable` - inline editing (alias of `enableInlineEditing`)
|
|
379
|
+
* `groupable` - grouping controls (alias of `showGroupingControls`)
|
|
380
|
+
* `pageable` - pagination footer (alias of `showPagination`)
|
|
381
|
+
*/
|
|
382
|
+
sortable?: boolean
|
|
383
|
+
filterable?: boolean
|
|
384
|
+
editable?: boolean
|
|
385
|
+
groupable?: boolean
|
|
386
|
+
pageable?: boolean
|
|
387
|
+
options?: Partial<SvGridOptions<TFeatures, TData>>
|
|
388
|
+
loading?: boolean
|
|
389
|
+
error?: string | null
|
|
390
|
+
emptyMessage?: string
|
|
391
|
+
showGlobalFilter?: boolean
|
|
392
|
+
showColumnFilters?: boolean
|
|
393
|
+
showGroupingControls?: boolean
|
|
394
|
+
showRowSelection?: boolean
|
|
395
|
+
showPagination?: boolean
|
|
396
|
+
virtualization?: boolean
|
|
397
|
+
/** Row height in pixels. Pass a function `(rowIndex) => px` for per-row
|
|
398
|
+
* variable heights (e.g. when wiring up an interactive row-resize). */
|
|
399
|
+
rowHeight?: number | ((rowIndex: number) => number)
|
|
400
|
+
overscan?: number
|
|
401
|
+
containerHeight?: number
|
|
402
|
+
columnVirtualization?: boolean
|
|
403
|
+
columnOverscan?: number
|
|
404
|
+
columnWidth?: number
|
|
405
|
+
showFilterMenu?: boolean
|
|
406
|
+
showFilterRow?: boolean
|
|
407
|
+
enableCellSelection?: boolean
|
|
408
|
+
enableInlineEditing?: boolean
|
|
409
|
+
enableRowSummaries?: boolean
|
|
410
|
+
/** Receives the imperative grid API when the component is ready. */
|
|
411
|
+
onApiReady?: (api: SvGridApi<TFeatures, TData>) => void
|
|
412
|
+
}
|