@svgrid/grid 2.2.27 → 2.2.28

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.
Files changed (212) hide show
  1. package/README.md +199 -199
  2. package/dist/FlexRender.svelte +96 -96
  3. package/dist/GridFooter.svelte +179 -179
  4. package/dist/GridMenus.svelte +734 -734
  5. package/dist/SvAutoComplete.svelte +165 -165
  6. package/dist/SvCalendar.svelte +503 -503
  7. package/dist/SvCarousel.svelte +141 -141
  8. package/dist/SvCheckBox.svelte +101 -101
  9. package/dist/SvColorInput.svelte +181 -181
  10. package/dist/SvComboBox.svelte +275 -275
  11. package/dist/SvContextMenu.svelte +116 -116
  12. package/dist/SvCountryInput.svelte +160 -160
  13. package/dist/SvDrawer.svelte +254 -250
  14. package/dist/SvDropDownList.svelte +374 -374
  15. package/dist/SvDurationInput.svelte +126 -126
  16. package/dist/SvField.svelte +293 -293
  17. package/dist/SvForm.svelte +437 -437
  18. package/dist/SvGrid.css +2723 -2723
  19. package/dist/SvGrid.svelte +3333 -3333
  20. package/dist/SvGridChart.svelte +1724 -1724
  21. package/dist/SvGridChartPanel.svelte +485 -485
  22. package/dist/SvGridChartView.svelte +70 -70
  23. package/dist/SvGridDropdown.svelte +696 -696
  24. package/dist/SvGridSelect.svelte +259 -259
  25. package/dist/SvGroupCell.svelte +109 -109
  26. package/dist/SvListBox.svelte +287 -287
  27. package/dist/SvMaskedInput.svelte +122 -122
  28. package/dist/SvMenu.svelte +124 -124
  29. package/dist/SvMenuList.svelte +146 -146
  30. package/dist/SvMultiSelect.svelte +281 -281
  31. package/dist/SvNumberInput.svelte +168 -168
  32. package/dist/SvOtpInput.svelte +158 -158
  33. package/dist/SvPasswordInput.svelte +151 -151
  34. package/dist/SvPhoneInput.svelte +133 -131
  35. package/dist/SvPopover.svelte +197 -197
  36. package/dist/SvRadioGroup.svelte +107 -107
  37. package/dist/SvRowGroupPanel.svelte +170 -170
  38. package/dist/SvScrollArea.svelte +61 -61
  39. package/dist/SvSlider.svelte +200 -200
  40. package/dist/SvSwitchButton.svelte +107 -107
  41. package/dist/SvTagsInput.svelte +112 -112
  42. package/dist/SvTextInput.svelte +147 -147
  43. package/dist/SvTimePicker.svelte +245 -245
  44. package/dist/SvToaster.svelte +159 -159
  45. package/dist/SvToggleButton.svelte +85 -85
  46. package/dist/SvTooltip.svelte +161 -161
  47. package/dist/SvTour.svelte +204 -204
  48. package/dist/SvTree.svelte +437 -437
  49. package/dist/SvTreeSelect.svelte +233 -233
  50. package/dist/cdn/{GridMenus-BzxEYNtW.js → GridMenus-BbzEvTYO.js} +2 -2
  51. package/dist/cdn/{GridMenus-Dr-nGEXn.js → GridMenus-E220X2kM.js} +2 -2
  52. package/dist/cdn/{SvDateTimePicker-B1sDc9Pz.js → SvDateTimePicker-B8GopjhC.js} +2 -2
  53. package/dist/cdn/{SvDateTimePicker-Bh0FTs1E.js → SvDateTimePicker-DB0aIEk8.js} +2 -2
  54. package/dist/cdn/{SvGridChart-Bgk4hDs8.js → SvGridChart-BcLCYvw9.js} +1 -1
  55. package/dist/cdn/{SvGridChart-BKQsO5fZ.js → SvGridChart-BhnFdLd0.js} +1 -1
  56. package/dist/cdn/{SvGridChartPanel-DkCc2Z7b.js → SvGridChartPanel-Cmx9DHAS.js} +1 -1
  57. package/dist/cdn/{SvGridChartPanel-DSkHIQDd.js → SvGridChartPanel-DvjwxLvK.js} +1 -1
  58. package/dist/cdn/{SvGridChartView-BrbVaELm.js → SvGridChartView-B40DTJSX.js} +1 -1
  59. package/dist/cdn/{SvGridChartView-i9rWvSKg.js → SvGridChartView-PwqI4s02.js} +1 -1
  60. package/dist/cdn/{SvGridDropdown-D08sVmAy.js → SvGridDropdown-DjALc_4f.js} +1 -1
  61. package/dist/cdn/{SvGridDropdown-CGxxopQ4.js → SvGridDropdown-hpnHvOGt.js} +1 -1
  62. package/dist/cdn/{src-cgs1wcUS.js → src-BxNEslEo.js} +25 -25
  63. package/dist/cdn/{src-Cw8d9U8j.js → src-C4yKQZ5t.js} +26 -26
  64. package/dist/cdn/svgrid.js +5 -5
  65. package/dist/cdn/svgrid.svelte-external.js +5 -5
  66. package/dist/chart-export.js +8 -8
  67. package/package.json +10 -10
  68. package/src/FlexRender.svelte +96 -96
  69. package/src/GridFooter.svelte +179 -179
  70. package/src/GridMenus.svelte +734 -734
  71. package/src/SvAutoComplete.svelte +165 -165
  72. package/src/SvCalendar.svelte +503 -503
  73. package/src/SvCalendar.test.ts +226 -226
  74. package/src/SvCarousel.svelte +141 -141
  75. package/src/SvCheckBox.svelte +101 -101
  76. package/src/SvColorInput.svelte +181 -181
  77. package/src/SvComboBox.svelte +275 -275
  78. package/src/SvContextMenu.svelte +116 -116
  79. package/src/SvCountryInput.svelte +160 -160
  80. package/src/SvDrawer.svelte +254 -250
  81. package/src/SvDrawer.test.ts +18 -1
  82. package/src/SvDropDownList.svelte +374 -374
  83. package/src/SvDurationInput.svelte +126 -126
  84. package/src/SvField.svelte +293 -293
  85. package/src/SvForm.svelte +437 -437
  86. package/src/SvForm.test.ts +411 -411
  87. package/src/SvGrid.controller.svelte.ts +3239 -3239
  88. package/src/SvGrid.css +2723 -2723
  89. package/src/SvGrid.svelte +3333 -3333
  90. package/src/SvGrid.types.ts +1613 -1613
  91. package/src/SvGridChart.svelte +1724 -1724
  92. package/src/SvGridChartPanel.svelte +485 -485
  93. package/src/SvGridChartView.svelte +70 -70
  94. package/src/SvGridDropdown.svelte +696 -696
  95. package/src/SvGridSelect.svelte +259 -259
  96. package/src/SvGroupCell.svelte +109 -109
  97. package/src/SvListBox.svelte +287 -287
  98. package/src/SvMaskedInput.svelte +122 -122
  99. package/src/SvMenu.svelte +124 -124
  100. package/src/SvMenu.test.ts +97 -97
  101. package/src/SvMenuList.svelte +146 -146
  102. package/src/SvMultiSelect.svelte +281 -281
  103. package/src/SvNavPane.test.ts +15 -4
  104. package/src/SvNumberInput.svelte +168 -168
  105. package/src/SvOtpInput.svelte +158 -158
  106. package/src/SvPasswordInput.svelte +151 -151
  107. package/src/SvPhoneInput.svelte +133 -131
  108. package/src/SvPopover.svelte +197 -197
  109. package/src/SvRadioGroup.svelte +107 -107
  110. package/src/SvRowGroupPanel.svelte +170 -170
  111. package/src/SvScrollArea.svelte +61 -61
  112. package/src/SvSlider.svelte +200 -200
  113. package/src/SvSwitchButton.svelte +107 -107
  114. package/src/SvTagsInput.svelte +112 -112
  115. package/src/SvTextInput.svelte +147 -147
  116. package/src/SvTimePicker.svelte +245 -245
  117. package/src/SvToaster.svelte +159 -159
  118. package/src/SvToaster.test.ts +95 -95
  119. package/src/SvToggleButton.svelte +85 -85
  120. package/src/SvTooltip.svelte +161 -161
  121. package/src/SvTour.svelte +204 -204
  122. package/src/SvTree.svelte +437 -437
  123. package/src/SvTreeSelect.svelte +233 -233
  124. package/src/a11y/dismissable.test.ts +119 -119
  125. package/src/a11y/dismissable.ts +114 -114
  126. package/src/a11y.contract.test.ts +49 -49
  127. package/src/a11y.test.ts +59 -59
  128. package/src/a11y.ts +61 -61
  129. package/src/ai.test.ts +502 -502
  130. package/src/ai.ts +1391 -1391
  131. package/src/build-api.coverage.test.ts +633 -633
  132. package/src/build-api.ts +895 -895
  133. package/src/builtin-editors.grid.test.ts +85 -85
  134. package/src/cell-formatting.ts +169 -169
  135. package/src/cell-render.ts +469 -469
  136. package/src/chart-export.ts +201 -201
  137. package/src/chart-view.svelte.ts +36 -36
  138. package/src/chart.ts +2296 -2296
  139. package/src/collaboration.test.ts +104 -104
  140. package/src/collaboration.ts +167 -167
  141. package/src/core.performance.test.ts +30 -30
  142. package/src/core.ts +1111 -1111
  143. package/src/createAutocomplete.svelte.ts +132 -132
  144. package/src/createCombobox.svelte.ts +191 -191
  145. package/src/createCountryInput.svelte.ts +157 -157
  146. package/src/createDropdownList.svelte.ts +168 -168
  147. package/src/createForm.svelte.ts +386 -386
  148. package/src/createGrid.svelte.ts +42 -42
  149. package/src/createGrid.test.ts +10 -10
  150. package/src/createGridState.svelte.ts +17 -17
  151. package/src/createMenu.svelte.ts +225 -225
  152. package/src/createPopoverSelect.svelte.ts +213 -213
  153. package/src/createSlider.svelte.ts +191 -191
  154. package/src/createTooltip.svelte.ts +144 -144
  155. package/src/createTree.svelte.ts +319 -319
  156. package/src/editing.test.ts +859 -859
  157. package/src/editing.ts +675 -675
  158. package/src/editor-contract.ts +157 -157
  159. package/src/export-data-api.test.ts +126 -126
  160. package/src/export-format.test.ts +107 -107
  161. package/src/export-format.ts +598 -598
  162. package/src/filter-operators.ts +157 -157
  163. package/src/flex-render.ts +3 -3
  164. package/src/form-field.ts +127 -127
  165. package/src/index.ts +713 -713
  166. package/src/js-scroller.svelte.ts +173 -173
  167. package/src/keyboard.test.ts +59 -59
  168. package/src/keyboard.ts +97 -97
  169. package/src/list-nav.test.ts +49 -49
  170. package/src/list-nav.ts +29 -29
  171. package/src/list-option.test.ts +56 -56
  172. package/src/list-option.ts +172 -172
  173. package/src/menus.test.ts +700 -700
  174. package/src/menus.ts +652 -652
  175. package/src/merge-objects.ts +48 -48
  176. package/src/overlays.test.ts +90 -90
  177. package/src/render-component.ts +28 -28
  178. package/src/scheduler-model.test.ts +562 -562
  179. package/src/scheduler-model.ts +872 -872
  180. package/src/selection.test.ts +754 -754
  181. package/src/selection.ts +600 -600
  182. package/src/server-data-source.test.ts +289 -289
  183. package/src/server-data-source.ts +413 -413
  184. package/src/sparkline.test.ts +68 -68
  185. package/src/sparkline.ts +169 -169
  186. package/src/spreadsheet.test.ts +489 -489
  187. package/src/spreadsheet.ts +312 -312
  188. package/src/static-functions.ts +11 -11
  189. package/src/subscribe.ts +38 -38
  190. package/src/svgrid-wrapper.types.ts +524 -524
  191. package/src/svgrid.behavior.test.ts +706 -706
  192. package/src/svgrid.charting.test.ts +534 -534
  193. package/src/svgrid.features.test.ts +157 -157
  194. package/src/svgrid.new-features.wrapper.test.ts +251 -251
  195. package/src/svgrid.wrapper.test.ts +40 -40
  196. package/src/test-setup.ts +62 -62
  197. package/src/themes/index.ts +215 -215
  198. package/src/toast-store.svelte.ts +246 -246
  199. package/src/toast-store.test.ts +147 -147
  200. package/src/ui-buttons.test.ts +144 -144
  201. package/src/ui-inputs.test.ts +118 -118
  202. package/src/ui-range.test.ts +70 -70
  203. package/src/ui-selection.test.ts +155 -155
  204. package/src/ui-tier1.test.ts +142 -142
  205. package/src/virtual.test.ts +88 -88
  206. package/src/virtualization/column-virtualizer.test.ts +27 -27
  207. package/src/virtualization/column-virtualizer.ts +30 -30
  208. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  209. package/src/virtualization/types.ts +30 -30
  210. package/src/virtualization/virtualizer.test.ts +47 -47
  211. package/src/virtualization/virtualizer.ts +296 -296
  212. package/themes/ember.css +71 -71
@@ -1,524 +1,524 @@
1
- import type { CellFormatConfig, ColumnDef, RowData, SvGridOptions, TableFeatures } from './core'
2
- // Type-only import (the reverse of SvGrid.types importing SvGridApi); TS resolves the
3
- // type-level cycle. Backs the generic key/value typing of `setOption` / `getOption`.
4
- import type { Props } from './SvGrid.types'
5
- import type { GridExportOptions, GridClipboardOptions } from './export-format'
6
- import type { ChartSpec, ChartType } from './chart'
7
-
8
- export type SvGridFilterOperator =
9
- | 'contains'
10
- | 'equals'
11
- | 'startsWith'
12
- | 'greaterThan'
13
- | 'lessThan'
14
- | 'between'
15
- | 'isBlank'
16
-
17
- /**
18
- * A serializable snapshot of everything that makes up the current "view":
19
- * sort, grouping, pagination, column layout (width / pinning / order /
20
- * visibility), and all filter surfaces. Round-trippable through
21
- * `api.getState()` / `api.setState()` - persist it to a URL, localStorage, or
22
- * a server to implement "save view" / "named views".
23
- */
24
- export type SvGridViewState = {
25
- sorting: Array<{ id: string; desc: boolean }>
26
- grouping: string[]
27
- pagination: { pageIndex: number; pageSize: number }
28
- columnWidths: Record<string, number>
29
- columnPinning: { left: string[]; right: string[] }
30
- columnOrder: string[]
31
- /** Ids of columns currently hidden via setColumnVisible. */
32
- hiddenColumns: string[]
33
- globalFilter: string
34
- columnFilters: Record<
35
- string,
36
- { operator: SvGridFilterOperator; value: string; valueTo?: string }
37
- >
38
- /** Facet (Excel-style value checklist) selections, keyed by column id. */
39
- facetFilters: Record<string, string[]>
40
- /** Built-in chart panel state (present only when `charting` is on): the
41
- * ACTIVE chart, for back-compat + spread-and-tweak. */
42
- chart?: {
43
- open: boolean
44
- type: ChartType
45
- dimension: string | null
46
- series: string | null
47
- measure: string | null
48
- reduce: 'sum' | 'avg' | 'count'
49
- stacked: boolean
50
- }
51
- /** All charts in the tab strip (multi-chart), plus the active index. */
52
- charts?: Array<{
53
- title: string
54
- type: ChartType
55
- dimension: string | null
56
- series: string | null
57
- measure: string | null
58
- reduce: 'sum' | 'avg' | 'count'
59
- stacked: boolean | null
60
- dataLabels: boolean | null
61
- logScale: boolean | null
62
- timeAxis: boolean | null
63
- valueFormat: 'number' | 'currency' | 'percent' | 'compact' | null
64
- }>
65
- chartActive?: number
66
- }
67
-
68
- /**
69
- * A batch of row mutations for `api.applyTransaction`. `update` / `remove`
70
- * (by id) match on `getRowId`; `remove` also accepts row object references.
71
- */
72
- export type SvGridTransaction<TData> = {
73
- add?: ReadonlyArray<TData>
74
- update?: ReadonlyArray<TData>
75
- remove?: ReadonlyArray<TData | string>
76
- }
77
-
78
- export type SvGridTransactionResult = {
79
- added: number
80
- updated: number
81
- removed: number
82
- }
83
-
84
- /**
85
- * Imperative API exposed via the `<SvGrid onApiReady>` callback. Use it for
86
- * data, column, filter, sort, group, and visibility operations from outside
87
- * the component.
88
- */
89
- export type SvGridApi<
90
- TFeatures extends TableFeatures,
91
- TData extends RowData,
92
- > = {
93
- // ----- Cells -----
94
- /** Read a cell value from the underlying data at `rowIndex`. */
95
- getCellValue(rowIndex: number, columnId: string): unknown
96
- /** Write a cell value through the column's field. */
97
- setCellValue(rowIndex: number, columnId: string, value: unknown): void
98
- /**
99
- * Programmatically begin editing a cell (as a double-click would). Returns
100
- * `true` if editing started (cell exists, editable, editing enabled).
101
- */
102
- startEditing(rowIndex: number, columnId: string): boolean
103
- /**
104
- * Commit (default) or, with `cancel: true`, discard the active edit.
105
- * Returns `true` if there was an edit in progress.
106
- */
107
- stopEditing(cancel?: boolean): boolean
108
-
109
- // ----- Cell selection -----
110
- /**
111
- * Programmatically select one or more rectangular cell ranges. Each
112
- * range is `[rowStart, colStart, rowEnd, colEnd]` in 0-indexed grid
113
- * coordinates. Pass an empty array to clear the selection.
114
- *
115
- * The grid currently honours the FIRST range only (single-range
116
- * engine); subsequent ranges are accepted for API forward compat
117
- * but ignored. The grid's active cell jumps to the range's start
118
- * corner.
119
- */
120
- selectCells(ranges: ReadonlyArray<readonly [number, number, number, number]>): void
121
- /**
122
- * Returns the current cell-selection rectangles in the same shape
123
- * `selectCells` accepts. Empty array when no range is active.
124
- */
125
- getSelected(): Array<[number, number, number, number]>
126
-
127
- // ----- Integrated charting (requires the `charting` prop) -----
128
- /** Open the built-in chart panel. */
129
- openChart(): void
130
- /** Close the built-in chart panel. */
131
- closeChart(): void
132
- /** The live chart spec the panel is rendering, or `null`. */
133
- getChartSpec(): ChartSpec | null
134
- /** Select cell rectangles + open the chart panel (scopes to the range). */
135
- chartRange(ranges?: ReadonlyArray<readonly [number, number, number, number]>): void
136
- /**
137
- * Configure the built-in chart panel's ACTIVE chart. Column references
138
- * accept a column id OR field name. Opens the panel unless `open === false`.
139
- */
140
- configureChart(config: {
141
- open?: boolean
142
- type?: ChartType
143
- dimension?: string | null
144
- series?: string | null
145
- measure?: string | null
146
- reduce?: 'sum' | 'avg' | 'count'
147
- stacked?: boolean
148
- dataLabels?: boolean
149
- logScale?: boolean
150
- timeAxis?: boolean
151
- valueFormat?: 'number' | 'currency' | 'percent' | 'compact'
152
- }): void
153
- /**
154
- * Register a natural-language "chart this" handler. When set, the chart
155
- * panel shows an AI button. `@svgrid/enterprise`'s `enableAiCharting(api)`
156
- * fills this. Pass `null` to remove it.
157
- */
158
- setChartAiHandler(
159
- handler: ((prompt: string) => Promise<Record<string, unknown> | null>) | null,
160
- ): void
161
-
162
- // ----- Rows -----
163
- /** Add one row. `position` defaults to `'bottom'`. */
164
- addRow(row: TData, position?: 'top' | 'bottom' | number): void
165
- addRows(rows: ReadonlyArray<TData>, position?: 'top' | 'bottom' | number): void
166
- /** Remove a row at the given data-array index. */
167
- removeRow(rowIndex: number): void
168
- removeRows(rowIndices: ReadonlyArray<number>): void
169
- /**
170
- * Apply a batch of add / update / remove mutations in a SINGLE data update
171
- * (one re-render, not one per row) - the high-frequency / streaming path.
172
- * `update` and `remove`-by-id match rows via `getRowId`, so set that prop
173
- * for those to work; `remove` also accepts row object references. Returns
174
- * the counts actually applied.
175
- */
176
- applyTransaction(tx: SvGridTransaction<TData>): SvGridTransactionResult
177
-
178
- // ----- Columns -----
179
- /** Add one column. `position` defaults to `'right'`. */
180
- addColumn(
181
- column: ColumnDef<TFeatures, TData>,
182
- position?: 'left' | 'right' | number,
183
- ): void
184
- addColumns(
185
- columns: ReadonlyArray<ColumnDef<TFeatures, TData>>,
186
- position?: 'left' | 'right' | number,
187
- ): void
188
- /** Remove a column by id (or field when no id was provided). */
189
- removeColumn(columnId: string): void
190
-
191
- // ----- Visibility -----
192
- setColumnVisible(columnId: string, visible: boolean): void
193
- isColumnVisible(columnId: string): boolean
194
-
195
- // ----- Sort / group / filter -----
196
- /** Sort by one column (replaces any existing sort). Pass `null` to clear. */
197
- setSort(columnId: string, direction: 'asc' | 'desc' | null): void
198
- clearSort(): void
199
- setGroupBy(columnIds: ReadonlyArray<string>): void
200
-
201
- // ----- Options (runtime prop overrides) -----
202
- /**
203
- * Change a grid prop at runtime, e.g. `api.setOption('sortable', true)`. The
204
- * override is merged over the incoming prop and the grid re-renders reactively -
205
- * identical to the parent passing a new prop value. Pass `undefined` to clear the
206
- * override and fall back to the prop.
207
- *
208
- * Note: seed-once props are NOT retroactive - `initialSorting`,
209
- * `initialColumnPinning`, `initialHiddenColumns`, `columnOrder`, the initial
210
- * `pageSize`, and the one-shot `externalSort` / `externalFilter` are read at mount,
211
- * so overriding them later has no effect. Prefer the dedicated data path for
212
- * `data` / `columns` (this works, but the sync effects are the idiomatic route).
213
- */
214
- setOption<K extends keyof Props<TFeatures, TData>>(key: K, value: Props<TFeatures, TData>[K] | undefined): void
215
- /** Read a prop's effective value: the runtime override if set, else the incoming prop. */
216
- getOption<K extends keyof Props<TFeatures, TData>>(key: K): Props<TFeatures, TData>[K]
217
- /** Clear every runtime override set via `setOption`, reverting to the incoming props. */
218
- resetOptions(): void
219
-
220
- /** Set the operator filter for a column. Pass `null` to clear. */
221
- setFilter(
222
- columnId: string,
223
- filter:
224
- | {
225
- operator: SvGridFilterOperator
226
- value?: string
227
- /** Upper bound for the `between` operator. Required when `operator === 'between'`. */
228
- valueTo?: string
229
- /**
230
- * Optional SECOND condition on the same column, joined by `join`
231
- * (multi-condition filtering, e.g. "> 100 AND < 500").
232
- */
233
- operator2?: SvGridFilterOperator
234
- value2?: string
235
- valueTo2?: string
236
- /** How to combine the two conditions. Defaults to `'AND'`. */
237
- join?: 'AND' | 'OR'
238
- }
239
- | null,
240
- ): void
241
- /**
242
- * Set the facet (set-list, Excel-style multi-select) filter for a column.
243
- * Pass an empty array or `null` to clear it. The values restore the
244
- * checked state of the column-menu's value list - the engine then filters
245
- * the data to rows whose cell value is in the set. Used to restore
246
- * snapshots captured via `onFiltersChange`'s `selectedValues`.
247
- */
248
- setFacetFilter(columnId: string, values: ReadonlyArray<string> | null): void
249
- clearFilter(columnId: string): void
250
- /**
251
- * Clear every active column filter (menu, filter-row, set-list, and global).
252
- * Resets the grid to "no filtering" in a single call.
253
- */
254
- clearAllFilters(): void
255
- /**
256
- * Read the active column-menu filters as a snapshot. Keyed by column id.
257
- * Returns an empty object when nothing is filtered. `valueTo` is only
258
- * present when `operator === 'between'`.
259
- */
260
- getFilters(): Record<
261
- string,
262
- { operator: SvGridFilterOperator; value: string; valueTo?: string }
263
- >
264
-
265
- /**
266
- * Snapshot of the rows the grid is actually displaying right now -
267
- * after filtering, sorting, grouping, and pagination have been applied.
268
- * Use this when you need to export the visible result set (e.g. CSV).
269
- */
270
- getDisplayedRows(): ReadonlyArray<TData>
271
-
272
- /** Snapshot of the current data array (pre-pipeline). */
273
- getData(): ReadonlyArray<TData>
274
-
275
- /**
276
- * Snapshot of every column the grid currently knows about, in visual
277
- * order, with the human-readable header label. Use this when exporting
278
- * or building a column-picker UI - the data is read once, no
279
- * subscription. Hidden columns are included; check `visible` to filter.
280
- */
281
- getColumns(): ReadonlyArray<{
282
- id: string
283
- field?: string
284
- header: string
285
- visible: boolean
286
- /** The column's `format` config, when set. Lets an exporter reproduce
287
- * the on-screen display value (currency, date pattern, etc.). */
288
- format?: CellFormatConfig
289
- /** Effective horizontal alignment ('left' | 'center' | 'right'). */
290
- align?: 'left' | 'center' | 'right'
291
- }>
292
-
293
- // ----- Free data export (CSV / TSV / JSON + clipboard) -----
294
- /**
295
- * Export the grid to a **CSV** file. Free in the community grid; the
296
- * richer Excel / PDF / styled formats live in @svgrid/enterprise. Values
297
- * are formatted as shown on screen (pass `rawValues: true` for raw). Rows
298
- * default to the current view (`rows: 'selected' | 'all'` to change).
299
- * Resolves with the serialized text; pass `download: false` to skip the
300
- * browser download and just get the string.
301
- */
302
- exportCsv(options?: GridExportOptions): Promise<string>
303
- /** Export the grid to a **TSV** file (tab-separated). See `exportCsv`. */
304
- exportTsv(options?: GridExportOptions): Promise<string>
305
- /** Export the grid to a **JSON** file (array of `{ field: value }`). */
306
- exportJson(options?: GridExportOptions): Promise<string>
307
- /**
308
- * Copy the grid to the system clipboard. `format: 'tsv'` (default) pastes
309
- * straight into Excel / Sheets; `'csv'` / `'markdown'` also supported.
310
- * Resolves with the copied text.
311
- */
312
- copyToClipboard(options?: GridClipboardOptions): Promise<string>
313
-
314
- /** Clear every checked row. Emits `onRowSelectionChange({}, [])`. */
315
- clearRowSelection(): void
316
-
317
- // ----- Column layout (width + pinning) -----
318
- /**
319
- * Set the width of one column in pixels. Identical to dragging the
320
- * column's resize handle. Width is clamped to `MIN_COLUMN_WIDTH`.
321
- */
322
- setColumnWidth(columnId: string, width: number): void
323
- /**
324
- * Snapshot of every column's current width (in pixels), keyed by
325
- * column id. Columns the user has never resized AND that have no
326
- * explicit `width` on their ColumnDef are reported at the grid-wide
327
- * default. Useful for "save view" + URL persistence.
328
- */
329
- getColumnWidths(): Record<string, number>
330
- /**
331
- * Snap one column's width to its widest visible cell (header text +
332
- * any rendered body cell). Equivalent to double-clicking the column's
333
- * resize handle. The grid also exposes this through the column menu's
334
- * "Autosize" item.
335
- */
336
- autosizeColumn(columnId: string): void
337
- /** Run `autosizeColumn` on every column. */
338
- autosizeAllColumns(): void
339
- /**
340
- * Replace the column-pinning state in one call. Each entry is a
341
- * column id; the order in the array becomes the visible order along
342
- * the pinned edge.
343
- */
344
- setColumnPinning(pinning: {
345
- left?: ReadonlyArray<string>
346
- right?: ReadonlyArray<string>
347
- }): void
348
- /** Snapshot of the current column-pinning state. */
349
- getColumnPinning(): { left: string[]; right: string[] }
350
-
351
- // ----- Column reorder -----
352
- /**
353
- * Replace the column order. Pass an array of column ids in the
354
- * desired visual order. Unknown ids are skipped; columns not in the
355
- * array keep their existing relative position after the listed ones.
356
- * Fires `onColumnOrderChange` once the new order is applied. Pin
357
- * groups (`columnPinning.left` / `right`) are still applied on top.
358
- */
359
- setColumnOrder(order: ReadonlyArray<string>): void
360
- /**
361
- * Snapshot of the current visual column order - the same shape the
362
- * `onColumnOrderChange` callback receives. Useful for saving and
363
- * restoring a view layout.
364
- */
365
- getColumnOrder(): string[]
366
-
367
- // ----- Row expansion -----
368
- /**
369
- * Set whether a row (group node or expandable leaf) is expanded.
370
- * The `id` is the engine's row id - for grouped rows that's the
371
- * synthetic group key (e.g. `"department:Engineering"`).
372
- */
373
- setRowExpanded(id: string, expanded: boolean): void
374
- /** Expand every group node in the current grouped row model. */
375
- expandAllGroups(): void
376
- /** Collapse every expansion - resets expanded state to {}. */
377
- collapseAllGroups(): void
378
-
379
- // ----- Undo / redo -----
380
- /** Undo the most recent inline-edit. Returns false when the history is empty. */
381
- undo(): boolean
382
- /** Redo the most recently undone edit. Returns false when the redo stack is empty. */
383
- redo(): boolean
384
- /** True when there's at least one step on the undo stack. */
385
- canUndo(): boolean
386
- /** True when there's at least one step on the redo stack. */
387
- canRedo(): boolean
388
- /** Wipe both stacks (e.g. after a server save commits the buffer). */
389
- clearHistory(): void
390
-
391
- // ----- Find in grid -----
392
- /** Open the built-in find overlay (Ctrl+F also opens it). */
393
- openFind(): void
394
- /** Close the find overlay and clear the query. */
395
- closeFind(): void
396
- /** Update the find query programmatically (useful for app-wide command palettes). */
397
- setFindQuery(q: string): void
398
- /** Snapshot of the current find hits (rowIndex / colIndex / columnId). */
399
- getFindHits(): Array<{ rowIndex: number; colIndex: number; columnId: string }>
400
-
401
- // ----- Row selection (read + write) -----
402
- /**
403
- * The currently selected data rows (group-header rows excluded), in row-model
404
- * order. Read once - no subscription. The push-based equivalent is
405
- * `onRowSelectionChange`.
406
- */
407
- getSelectedRows(): TData[]
408
- /** The engine row ids of the selected rows. Keys into the selection record. */
409
- getSelectedRowIds(): string[]
410
- /**
411
- * Select rows by engine row id. By default this REPLACES the selection;
412
- * pass `additive: true` to add to the existing selection instead.
413
- */
414
- selectRows(ids: ReadonlyArray<string>, additive?: boolean): void
415
- /** Select every selectable (non-group) row in the current row model. */
416
- selectAllRows(): void
417
- /** Flip one row's selected state by id. */
418
- toggleRowSelected(id: string): void
419
-
420
- // ----- Pagination -----
421
- /**
422
- * Current pagination snapshot. `total` is the post-filter row count;
423
- * `pageCount` is derived from it and `pageSize` (always >= 1).
424
- */
425
- getPageInfo(): {
426
- pageIndex: number
427
- pageSize: number
428
- pageCount: number
429
- total: number
430
- }
431
- /** Jump to a 0-based page. Clamped to [0, pageCount - 1]. */
432
- setPage(pageIndex: number): void
433
- /** Advance one page (no-op past the last page). */
434
- nextPage(): void
435
- /** Go back one page (no-op before the first page). */
436
- prevPage(): void
437
- /** Jump to the first page. */
438
- firstPage(): void
439
- /** Jump to the last page. */
440
- lastPage(): void
441
- /** Change the page size, keeping the first visible row in view. */
442
- setPageSize(pageSize: number): void
443
-
444
- // ----- Navigation / scrolling -----
445
- /**
446
- * Scroll the body so the given row index is at the top of the viewport.
447
- * Works with virtualization on. Index is clamped to the row count.
448
- */
449
- scrollToRow(rowIndex: number): void
450
- /** The active (focused) cell, or null when nothing is focused. */
451
- getActiveCell(): { rowIndex: number; colIndex: number; columnId: string } | null
452
- /** Move the active cell. Both coordinates are clamped to the grid bounds. */
453
- setActiveCell(rowIndex: number, colIndex: number): void
454
-
455
- // ----- View state (save / restore) -----
456
- /**
457
- * Serializable snapshot of the whole view - sort, grouping, pagination,
458
- * column layout, and every filter surface. Pair with `setState` for
459
- * "save view" / URL persistence / named views.
460
- */
461
- getState(): SvGridViewState
462
- /**
463
- * Restore a view from a (partial) snapshot produced by `getState`. Only the
464
- * keys present are applied, so you can restore just the columns, just the
465
- * filters, etc.
466
- */
467
- setState(state: Partial<SvGridViewState>): void
468
- /** Force a recompute of the row pipeline + a re-render. */
469
- refresh(): void
470
- }
471
-
472
- export type SvGridWrapperProps<
473
- TFeatures extends TableFeatures,
474
- TData extends RowData,
475
- > = {
476
- data: ReadonlyArray<TData>
477
- columns: Array<ColumnDef<TFeatures, TData>>
478
- /**
479
- * Feature set from `tableFeatures({ ... })`. Optional - the `sortable` /
480
- * `filterable` / `groupable` shortcuts inject the matching feature, so a
481
- * grid can be configured from the boolean shortcuts alone.
482
- */
483
- features?: TFeatures
484
- /**
485
- * Capability shortcuts. Every capability is OFF by default (a bare grid is
486
- * a plain read-only table); set a shortcut `true` to opt in.
487
- *
488
- * `sortable` - column sorting (injects `rowSortingFeature`)
489
- * `filterable` - column filtering (injects `columnFilteringFeature`)
490
- * `editable` - inline editing (alias of `enableInlineEditing`)
491
- * `groupable` - grouping controls (alias of `showGroupingControls`)
492
- * `pageable` - pagination footer (alias of `showPagination`)
493
- */
494
- sortable?: boolean
495
- filterable?: boolean
496
- editable?: boolean
497
- groupable?: boolean
498
- pageable?: boolean
499
- options?: Partial<SvGridOptions<TFeatures, TData>>
500
- loading?: boolean
501
- error?: string | null
502
- emptyMessage?: string
503
- showGlobalFilter?: boolean
504
- showColumnFilters?: boolean
505
- showGroupingControls?: boolean
506
- showRowSelection?: boolean
507
- showPagination?: boolean
508
- virtualization?: boolean
509
- /** Row height in pixels. Pass a function `(rowIndex) => px` for per-row
510
- * variable heights (e.g. when wiring up an interactive row-resize). */
511
- rowHeight?: number | ((rowIndex: number) => number)
512
- overscan?: number
513
- containerHeight?: number
514
- columnVirtualization?: boolean
515
- columnOverscan?: number
516
- columnWidth?: number
517
- showFilterMenu?: boolean
518
- showFilterRow?: boolean
519
- enableCellSelection?: boolean
520
- enableInlineEditing?: boolean
521
- enableRowSummaries?: boolean
522
- /** Receives the imperative grid API when the component is ready. */
523
- onApiReady?: (api: SvGridApi<TFeatures, TData>) => void
524
- }
1
+ import type { CellFormatConfig, ColumnDef, RowData, SvGridOptions, TableFeatures } from './core'
2
+ // Type-only import (the reverse of SvGrid.types importing SvGridApi); TS resolves the
3
+ // type-level cycle. Backs the generic key/value typing of `setOption` / `getOption`.
4
+ import type { Props } from './SvGrid.types'
5
+ import type { GridExportOptions, GridClipboardOptions } from './export-format'
6
+ import type { ChartSpec, ChartType } from './chart'
7
+
8
+ export type SvGridFilterOperator =
9
+ | 'contains'
10
+ | 'equals'
11
+ | 'startsWith'
12
+ | 'greaterThan'
13
+ | 'lessThan'
14
+ | 'between'
15
+ | 'isBlank'
16
+
17
+ /**
18
+ * A serializable snapshot of everything that makes up the current "view":
19
+ * sort, grouping, pagination, column layout (width / pinning / order /
20
+ * visibility), and all filter surfaces. Round-trippable through
21
+ * `api.getState()` / `api.setState()` - persist it to a URL, localStorage, or
22
+ * a server to implement "save view" / "named views".
23
+ */
24
+ export type SvGridViewState = {
25
+ sorting: Array<{ id: string; desc: boolean }>
26
+ grouping: string[]
27
+ pagination: { pageIndex: number; pageSize: number }
28
+ columnWidths: Record<string, number>
29
+ columnPinning: { left: string[]; right: string[] }
30
+ columnOrder: string[]
31
+ /** Ids of columns currently hidden via setColumnVisible. */
32
+ hiddenColumns: string[]
33
+ globalFilter: string
34
+ columnFilters: Record<
35
+ string,
36
+ { operator: SvGridFilterOperator; value: string; valueTo?: string }
37
+ >
38
+ /** Facet (Excel-style value checklist) selections, keyed by column id. */
39
+ facetFilters: Record<string, string[]>
40
+ /** Built-in chart panel state (present only when `charting` is on): the
41
+ * ACTIVE chart, for back-compat + spread-and-tweak. */
42
+ chart?: {
43
+ open: boolean
44
+ type: ChartType
45
+ dimension: string | null
46
+ series: string | null
47
+ measure: string | null
48
+ reduce: 'sum' | 'avg' | 'count'
49
+ stacked: boolean
50
+ }
51
+ /** All charts in the tab strip (multi-chart), plus the active index. */
52
+ charts?: Array<{
53
+ title: string
54
+ type: ChartType
55
+ dimension: string | null
56
+ series: string | null
57
+ measure: string | null
58
+ reduce: 'sum' | 'avg' | 'count'
59
+ stacked: boolean | null
60
+ dataLabels: boolean | null
61
+ logScale: boolean | null
62
+ timeAxis: boolean | null
63
+ valueFormat: 'number' | 'currency' | 'percent' | 'compact' | null
64
+ }>
65
+ chartActive?: number
66
+ }
67
+
68
+ /**
69
+ * A batch of row mutations for `api.applyTransaction`. `update` / `remove`
70
+ * (by id) match on `getRowId`; `remove` also accepts row object references.
71
+ */
72
+ export type SvGridTransaction<TData> = {
73
+ add?: ReadonlyArray<TData>
74
+ update?: ReadonlyArray<TData>
75
+ remove?: ReadonlyArray<TData | string>
76
+ }
77
+
78
+ export type SvGridTransactionResult = {
79
+ added: number
80
+ updated: number
81
+ removed: number
82
+ }
83
+
84
+ /**
85
+ * Imperative API exposed via the `<SvGrid onApiReady>` callback. Use it for
86
+ * data, column, filter, sort, group, and visibility operations from outside
87
+ * the component.
88
+ */
89
+ export type SvGridApi<
90
+ TFeatures extends TableFeatures,
91
+ TData extends RowData,
92
+ > = {
93
+ // ----- Cells -----
94
+ /** Read a cell value from the underlying data at `rowIndex`. */
95
+ getCellValue(rowIndex: number, columnId: string): unknown
96
+ /** Write a cell value through the column's field. */
97
+ setCellValue(rowIndex: number, columnId: string, value: unknown): void
98
+ /**
99
+ * Programmatically begin editing a cell (as a double-click would). Returns
100
+ * `true` if editing started (cell exists, editable, editing enabled).
101
+ */
102
+ startEditing(rowIndex: number, columnId: string): boolean
103
+ /**
104
+ * Commit (default) or, with `cancel: true`, discard the active edit.
105
+ * Returns `true` if there was an edit in progress.
106
+ */
107
+ stopEditing(cancel?: boolean): boolean
108
+
109
+ // ----- Cell selection -----
110
+ /**
111
+ * Programmatically select one or more rectangular cell ranges. Each
112
+ * range is `[rowStart, colStart, rowEnd, colEnd]` in 0-indexed grid
113
+ * coordinates. Pass an empty array to clear the selection.
114
+ *
115
+ * The grid currently honours the FIRST range only (single-range
116
+ * engine); subsequent ranges are accepted for API forward compat
117
+ * but ignored. The grid's active cell jumps to the range's start
118
+ * corner.
119
+ */
120
+ selectCells(ranges: ReadonlyArray<readonly [number, number, number, number]>): void
121
+ /**
122
+ * Returns the current cell-selection rectangles in the same shape
123
+ * `selectCells` accepts. Empty array when no range is active.
124
+ */
125
+ getSelected(): Array<[number, number, number, number]>
126
+
127
+ // ----- Integrated charting (requires the `charting` prop) -----
128
+ /** Open the built-in chart panel. */
129
+ openChart(): void
130
+ /** Close the built-in chart panel. */
131
+ closeChart(): void
132
+ /** The live chart spec the panel is rendering, or `null`. */
133
+ getChartSpec(): ChartSpec | null
134
+ /** Select cell rectangles + open the chart panel (scopes to the range). */
135
+ chartRange(ranges?: ReadonlyArray<readonly [number, number, number, number]>): void
136
+ /**
137
+ * Configure the built-in chart panel's ACTIVE chart. Column references
138
+ * accept a column id OR field name. Opens the panel unless `open === false`.
139
+ */
140
+ configureChart(config: {
141
+ open?: boolean
142
+ type?: ChartType
143
+ dimension?: string | null
144
+ series?: string | null
145
+ measure?: string | null
146
+ reduce?: 'sum' | 'avg' | 'count'
147
+ stacked?: boolean
148
+ dataLabels?: boolean
149
+ logScale?: boolean
150
+ timeAxis?: boolean
151
+ valueFormat?: 'number' | 'currency' | 'percent' | 'compact'
152
+ }): void
153
+ /**
154
+ * Register a natural-language "chart this" handler. When set, the chart
155
+ * panel shows an AI button. `@svgrid/enterprise`'s `enableAiCharting(api)`
156
+ * fills this. Pass `null` to remove it.
157
+ */
158
+ setChartAiHandler(
159
+ handler: ((prompt: string) => Promise<Record<string, unknown> | null>) | null,
160
+ ): void
161
+
162
+ // ----- Rows -----
163
+ /** Add one row. `position` defaults to `'bottom'`. */
164
+ addRow(row: TData, position?: 'top' | 'bottom' | number): void
165
+ addRows(rows: ReadonlyArray<TData>, position?: 'top' | 'bottom' | number): void
166
+ /** Remove a row at the given data-array index. */
167
+ removeRow(rowIndex: number): void
168
+ removeRows(rowIndices: ReadonlyArray<number>): void
169
+ /**
170
+ * Apply a batch of add / update / remove mutations in a SINGLE data update
171
+ * (one re-render, not one per row) - the high-frequency / streaming path.
172
+ * `update` and `remove`-by-id match rows via `getRowId`, so set that prop
173
+ * for those to work; `remove` also accepts row object references. Returns
174
+ * the counts actually applied.
175
+ */
176
+ applyTransaction(tx: SvGridTransaction<TData>): SvGridTransactionResult
177
+
178
+ // ----- Columns -----
179
+ /** Add one column. `position` defaults to `'right'`. */
180
+ addColumn(
181
+ column: ColumnDef<TFeatures, TData>,
182
+ position?: 'left' | 'right' | number,
183
+ ): void
184
+ addColumns(
185
+ columns: ReadonlyArray<ColumnDef<TFeatures, TData>>,
186
+ position?: 'left' | 'right' | number,
187
+ ): void
188
+ /** Remove a column by id (or field when no id was provided). */
189
+ removeColumn(columnId: string): void
190
+
191
+ // ----- Visibility -----
192
+ setColumnVisible(columnId: string, visible: boolean): void
193
+ isColumnVisible(columnId: string): boolean
194
+
195
+ // ----- Sort / group / filter -----
196
+ /** Sort by one column (replaces any existing sort). Pass `null` to clear. */
197
+ setSort(columnId: string, direction: 'asc' | 'desc' | null): void
198
+ clearSort(): void
199
+ setGroupBy(columnIds: ReadonlyArray<string>): void
200
+
201
+ // ----- Options (runtime prop overrides) -----
202
+ /**
203
+ * Change a grid prop at runtime, e.g. `api.setOption('sortable', true)`. The
204
+ * override is merged over the incoming prop and the grid re-renders reactively -
205
+ * identical to the parent passing a new prop value. Pass `undefined` to clear the
206
+ * override and fall back to the prop.
207
+ *
208
+ * Note: seed-once props are NOT retroactive - `initialSorting`,
209
+ * `initialColumnPinning`, `initialHiddenColumns`, `columnOrder`, the initial
210
+ * `pageSize`, and the one-shot `externalSort` / `externalFilter` are read at mount,
211
+ * so overriding them later has no effect. Prefer the dedicated data path for
212
+ * `data` / `columns` (this works, but the sync effects are the idiomatic route).
213
+ */
214
+ setOption<K extends keyof Props<TFeatures, TData>>(key: K, value: Props<TFeatures, TData>[K] | undefined): void
215
+ /** Read a prop's effective value: the runtime override if set, else the incoming prop. */
216
+ getOption<K extends keyof Props<TFeatures, TData>>(key: K): Props<TFeatures, TData>[K]
217
+ /** Clear every runtime override set via `setOption`, reverting to the incoming props. */
218
+ resetOptions(): void
219
+
220
+ /** Set the operator filter for a column. Pass `null` to clear. */
221
+ setFilter(
222
+ columnId: string,
223
+ filter:
224
+ | {
225
+ operator: SvGridFilterOperator
226
+ value?: string
227
+ /** Upper bound for the `between` operator. Required when `operator === 'between'`. */
228
+ valueTo?: string
229
+ /**
230
+ * Optional SECOND condition on the same column, joined by `join`
231
+ * (multi-condition filtering, e.g. "> 100 AND < 500").
232
+ */
233
+ operator2?: SvGridFilterOperator
234
+ value2?: string
235
+ valueTo2?: string
236
+ /** How to combine the two conditions. Defaults to `'AND'`. */
237
+ join?: 'AND' | 'OR'
238
+ }
239
+ | null,
240
+ ): void
241
+ /**
242
+ * Set the facet (set-list, Excel-style multi-select) filter for a column.
243
+ * Pass an empty array or `null` to clear it. The values restore the
244
+ * checked state of the column-menu's value list - the engine then filters
245
+ * the data to rows whose cell value is in the set. Used to restore
246
+ * snapshots captured via `onFiltersChange`'s `selectedValues`.
247
+ */
248
+ setFacetFilter(columnId: string, values: ReadonlyArray<string> | null): void
249
+ clearFilter(columnId: string): void
250
+ /**
251
+ * Clear every active column filter (menu, filter-row, set-list, and global).
252
+ * Resets the grid to "no filtering" in a single call.
253
+ */
254
+ clearAllFilters(): void
255
+ /**
256
+ * Read the active column-menu filters as a snapshot. Keyed by column id.
257
+ * Returns an empty object when nothing is filtered. `valueTo` is only
258
+ * present when `operator === 'between'`.
259
+ */
260
+ getFilters(): Record<
261
+ string,
262
+ { operator: SvGridFilterOperator; value: string; valueTo?: string }
263
+ >
264
+
265
+ /**
266
+ * Snapshot of the rows the grid is actually displaying right now -
267
+ * after filtering, sorting, grouping, and pagination have been applied.
268
+ * Use this when you need to export the visible result set (e.g. CSV).
269
+ */
270
+ getDisplayedRows(): ReadonlyArray<TData>
271
+
272
+ /** Snapshot of the current data array (pre-pipeline). */
273
+ getData(): ReadonlyArray<TData>
274
+
275
+ /**
276
+ * Snapshot of every column the grid currently knows about, in visual
277
+ * order, with the human-readable header label. Use this when exporting
278
+ * or building a column-picker UI - the data is read once, no
279
+ * subscription. Hidden columns are included; check `visible` to filter.
280
+ */
281
+ getColumns(): ReadonlyArray<{
282
+ id: string
283
+ field?: string
284
+ header: string
285
+ visible: boolean
286
+ /** The column's `format` config, when set. Lets an exporter reproduce
287
+ * the on-screen display value (currency, date pattern, etc.). */
288
+ format?: CellFormatConfig
289
+ /** Effective horizontal alignment ('left' | 'center' | 'right'). */
290
+ align?: 'left' | 'center' | 'right'
291
+ }>
292
+
293
+ // ----- Free data export (CSV / TSV / JSON + clipboard) -----
294
+ /**
295
+ * Export the grid to a **CSV** file. Free in the community grid; the
296
+ * richer Excel / PDF / styled formats live in @svgrid/enterprise. Values
297
+ * are formatted as shown on screen (pass `rawValues: true` for raw). Rows
298
+ * default to the current view (`rows: 'selected' | 'all'` to change).
299
+ * Resolves with the serialized text; pass `download: false` to skip the
300
+ * browser download and just get the string.
301
+ */
302
+ exportCsv(options?: GridExportOptions): Promise<string>
303
+ /** Export the grid to a **TSV** file (tab-separated). See `exportCsv`. */
304
+ exportTsv(options?: GridExportOptions): Promise<string>
305
+ /** Export the grid to a **JSON** file (array of `{ field: value }`). */
306
+ exportJson(options?: GridExportOptions): Promise<string>
307
+ /**
308
+ * Copy the grid to the system clipboard. `format: 'tsv'` (default) pastes
309
+ * straight into Excel / Sheets; `'csv'` / `'markdown'` also supported.
310
+ * Resolves with the copied text.
311
+ */
312
+ copyToClipboard(options?: GridClipboardOptions): Promise<string>
313
+
314
+ /** Clear every checked row. Emits `onRowSelectionChange({}, [])`. */
315
+ clearRowSelection(): void
316
+
317
+ // ----- Column layout (width + pinning) -----
318
+ /**
319
+ * Set the width of one column in pixels. Identical to dragging the
320
+ * column's resize handle. Width is clamped to `MIN_COLUMN_WIDTH`.
321
+ */
322
+ setColumnWidth(columnId: string, width: number): void
323
+ /**
324
+ * Snapshot of every column's current width (in pixels), keyed by
325
+ * column id. Columns the user has never resized AND that have no
326
+ * explicit `width` on their ColumnDef are reported at the grid-wide
327
+ * default. Useful for "save view" + URL persistence.
328
+ */
329
+ getColumnWidths(): Record<string, number>
330
+ /**
331
+ * Snap one column's width to its widest visible cell (header text +
332
+ * any rendered body cell). Equivalent to double-clicking the column's
333
+ * resize handle. The grid also exposes this through the column menu's
334
+ * "Autosize" item.
335
+ */
336
+ autosizeColumn(columnId: string): void
337
+ /** Run `autosizeColumn` on every column. */
338
+ autosizeAllColumns(): void
339
+ /**
340
+ * Replace the column-pinning state in one call. Each entry is a
341
+ * column id; the order in the array becomes the visible order along
342
+ * the pinned edge.
343
+ */
344
+ setColumnPinning(pinning: {
345
+ left?: ReadonlyArray<string>
346
+ right?: ReadonlyArray<string>
347
+ }): void
348
+ /** Snapshot of the current column-pinning state. */
349
+ getColumnPinning(): { left: string[]; right: string[] }
350
+
351
+ // ----- Column reorder -----
352
+ /**
353
+ * Replace the column order. Pass an array of column ids in the
354
+ * desired visual order. Unknown ids are skipped; columns not in the
355
+ * array keep their existing relative position after the listed ones.
356
+ * Fires `onColumnOrderChange` once the new order is applied. Pin
357
+ * groups (`columnPinning.left` / `right`) are still applied on top.
358
+ */
359
+ setColumnOrder(order: ReadonlyArray<string>): void
360
+ /**
361
+ * Snapshot of the current visual column order - the same shape the
362
+ * `onColumnOrderChange` callback receives. Useful for saving and
363
+ * restoring a view layout.
364
+ */
365
+ getColumnOrder(): string[]
366
+
367
+ // ----- Row expansion -----
368
+ /**
369
+ * Set whether a row (group node or expandable leaf) is expanded.
370
+ * The `id` is the engine's row id - for grouped rows that's the
371
+ * synthetic group key (e.g. `"department:Engineering"`).
372
+ */
373
+ setRowExpanded(id: string, expanded: boolean): void
374
+ /** Expand every group node in the current grouped row model. */
375
+ expandAllGroups(): void
376
+ /** Collapse every expansion - resets expanded state to {}. */
377
+ collapseAllGroups(): void
378
+
379
+ // ----- Undo / redo -----
380
+ /** Undo the most recent inline-edit. Returns false when the history is empty. */
381
+ undo(): boolean
382
+ /** Redo the most recently undone edit. Returns false when the redo stack is empty. */
383
+ redo(): boolean
384
+ /** True when there's at least one step on the undo stack. */
385
+ canUndo(): boolean
386
+ /** True when there's at least one step on the redo stack. */
387
+ canRedo(): boolean
388
+ /** Wipe both stacks (e.g. after a server save commits the buffer). */
389
+ clearHistory(): void
390
+
391
+ // ----- Find in grid -----
392
+ /** Open the built-in find overlay (Ctrl+F also opens it). */
393
+ openFind(): void
394
+ /** Close the find overlay and clear the query. */
395
+ closeFind(): void
396
+ /** Update the find query programmatically (useful for app-wide command palettes). */
397
+ setFindQuery(q: string): void
398
+ /** Snapshot of the current find hits (rowIndex / colIndex / columnId). */
399
+ getFindHits(): Array<{ rowIndex: number; colIndex: number; columnId: string }>
400
+
401
+ // ----- Row selection (read + write) -----
402
+ /**
403
+ * The currently selected data rows (group-header rows excluded), in row-model
404
+ * order. Read once - no subscription. The push-based equivalent is
405
+ * `onRowSelectionChange`.
406
+ */
407
+ getSelectedRows(): TData[]
408
+ /** The engine row ids of the selected rows. Keys into the selection record. */
409
+ getSelectedRowIds(): string[]
410
+ /**
411
+ * Select rows by engine row id. By default this REPLACES the selection;
412
+ * pass `additive: true` to add to the existing selection instead.
413
+ */
414
+ selectRows(ids: ReadonlyArray<string>, additive?: boolean): void
415
+ /** Select every selectable (non-group) row in the current row model. */
416
+ selectAllRows(): void
417
+ /** Flip one row's selected state by id. */
418
+ toggleRowSelected(id: string): void
419
+
420
+ // ----- Pagination -----
421
+ /**
422
+ * Current pagination snapshot. `total` is the post-filter row count;
423
+ * `pageCount` is derived from it and `pageSize` (always >= 1).
424
+ */
425
+ getPageInfo(): {
426
+ pageIndex: number
427
+ pageSize: number
428
+ pageCount: number
429
+ total: number
430
+ }
431
+ /** Jump to a 0-based page. Clamped to [0, pageCount - 1]. */
432
+ setPage(pageIndex: number): void
433
+ /** Advance one page (no-op past the last page). */
434
+ nextPage(): void
435
+ /** Go back one page (no-op before the first page). */
436
+ prevPage(): void
437
+ /** Jump to the first page. */
438
+ firstPage(): void
439
+ /** Jump to the last page. */
440
+ lastPage(): void
441
+ /** Change the page size, keeping the first visible row in view. */
442
+ setPageSize(pageSize: number): void
443
+
444
+ // ----- Navigation / scrolling -----
445
+ /**
446
+ * Scroll the body so the given row index is at the top of the viewport.
447
+ * Works with virtualization on. Index is clamped to the row count.
448
+ */
449
+ scrollToRow(rowIndex: number): void
450
+ /** The active (focused) cell, or null when nothing is focused. */
451
+ getActiveCell(): { rowIndex: number; colIndex: number; columnId: string } | null
452
+ /** Move the active cell. Both coordinates are clamped to the grid bounds. */
453
+ setActiveCell(rowIndex: number, colIndex: number): void
454
+
455
+ // ----- View state (save / restore) -----
456
+ /**
457
+ * Serializable snapshot of the whole view - sort, grouping, pagination,
458
+ * column layout, and every filter surface. Pair with `setState` for
459
+ * "save view" / URL persistence / named views.
460
+ */
461
+ getState(): SvGridViewState
462
+ /**
463
+ * Restore a view from a (partial) snapshot produced by `getState`. Only the
464
+ * keys present are applied, so you can restore just the columns, just the
465
+ * filters, etc.
466
+ */
467
+ setState(state: Partial<SvGridViewState>): void
468
+ /** Force a recompute of the row pipeline + a re-render. */
469
+ refresh(): void
470
+ }
471
+
472
+ export type SvGridWrapperProps<
473
+ TFeatures extends TableFeatures,
474
+ TData extends RowData,
475
+ > = {
476
+ data: ReadonlyArray<TData>
477
+ columns: Array<ColumnDef<TFeatures, TData>>
478
+ /**
479
+ * Feature set from `tableFeatures({ ... })`. Optional - the `sortable` /
480
+ * `filterable` / `groupable` shortcuts inject the matching feature, so a
481
+ * grid can be configured from the boolean shortcuts alone.
482
+ */
483
+ features?: TFeatures
484
+ /**
485
+ * Capability shortcuts. Every capability is OFF by default (a bare grid is
486
+ * a plain read-only table); set a shortcut `true` to opt in.
487
+ *
488
+ * `sortable` - column sorting (injects `rowSortingFeature`)
489
+ * `filterable` - column filtering (injects `columnFilteringFeature`)
490
+ * `editable` - inline editing (alias of `enableInlineEditing`)
491
+ * `groupable` - grouping controls (alias of `showGroupingControls`)
492
+ * `pageable` - pagination footer (alias of `showPagination`)
493
+ */
494
+ sortable?: boolean
495
+ filterable?: boolean
496
+ editable?: boolean
497
+ groupable?: boolean
498
+ pageable?: boolean
499
+ options?: Partial<SvGridOptions<TFeatures, TData>>
500
+ loading?: boolean
501
+ error?: string | null
502
+ emptyMessage?: string
503
+ showGlobalFilter?: boolean
504
+ showColumnFilters?: boolean
505
+ showGroupingControls?: boolean
506
+ showRowSelection?: boolean
507
+ showPagination?: boolean
508
+ virtualization?: boolean
509
+ /** Row height in pixels. Pass a function `(rowIndex) => px` for per-row
510
+ * variable heights (e.g. when wiring up an interactive row-resize). */
511
+ rowHeight?: number | ((rowIndex: number) => number)
512
+ overscan?: number
513
+ containerHeight?: number
514
+ columnVirtualization?: boolean
515
+ columnOverscan?: number
516
+ columnWidth?: number
517
+ showFilterMenu?: boolean
518
+ showFilterRow?: boolean
519
+ enableCellSelection?: boolean
520
+ enableInlineEditing?: boolean
521
+ enableRowSummaries?: boolean
522
+ /** Receives the imperative grid API when the component is ready. */
523
+ onApiReady?: (api: SvGridApi<TFeatures, TData>) => void
524
+ }