@svgrid/grid 2.6.23 → 3.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.
Files changed (263) hide show
  1. package/CHANGELOG.md +88 -88
  2. package/README.md +199 -199
  3. package/dist/FlexRender.svelte +96 -96
  4. package/dist/GridFooter.svelte +181 -181
  5. package/dist/SvAutoComplete.svelte +169 -169
  6. package/dist/SvAvatar.svelte +75 -75
  7. package/dist/SvCalendar.svelte +503 -503
  8. package/dist/SvCarousel.svelte +141 -141
  9. package/dist/SvCheckBox.svelte +102 -102
  10. package/dist/SvCircularProgress.svelte +109 -109
  11. package/dist/SvColorInput.svelte +181 -181
  12. package/dist/SvComboBox.svelte +279 -279
  13. package/dist/SvContextMenu.svelte +116 -116
  14. package/dist/SvCountryInput.svelte +163 -163
  15. package/dist/SvDrawer.svelte +254 -254
  16. package/dist/SvDropDownList.svelte +378 -378
  17. package/dist/SvDurationInput.svelte +126 -126
  18. package/dist/SvField.svelte +293 -293
  19. package/dist/SvForm.svelte +437 -437
  20. package/dist/SvGridCellEditor.svelte +744 -744
  21. package/dist/SvGridChart.svelte +1716 -1716
  22. package/dist/SvGridChartPanel.svelte +485 -485
  23. package/dist/SvGridChartView.svelte +70 -70
  24. package/dist/SvGridDropdown.svelte +728 -728
  25. package/dist/SvGridSelect.svelte +270 -270
  26. package/dist/SvGroupCell.svelte +116 -116
  27. package/dist/SvListBox.svelte +334 -334
  28. package/dist/SvMaskedInput.svelte +122 -122
  29. package/dist/SvMenu.svelte +124 -124
  30. package/dist/SvMenuList.svelte +146 -146
  31. package/dist/SvMultiSelect.svelte +293 -293
  32. package/dist/SvNumberInput.svelte +172 -172
  33. package/dist/SvOtpInput.svelte +158 -158
  34. package/dist/SvPasswordInput.svelte +151 -151
  35. package/dist/SvPhoneInput.svelte +133 -133
  36. package/dist/SvPopover.svelte +197 -197
  37. package/dist/SvProgress.svelte +116 -116
  38. package/dist/SvRadioGroup.svelte +107 -107
  39. package/dist/SvRating.svelte +112 -112
  40. package/dist/SvResult.svelte +73 -73
  41. package/dist/SvRichText.svelte +211 -211
  42. package/dist/SvRowGroupPanel.svelte +170 -170
  43. package/dist/SvScrollArea.svelte +61 -61
  44. package/dist/SvSlider.svelte +203 -203
  45. package/dist/SvSwitchButton.svelte +108 -108
  46. package/dist/SvTagsInput.svelte +115 -115
  47. package/dist/SvTextInput.svelte +147 -147
  48. package/dist/SvTimePicker.svelte +245 -245
  49. package/dist/SvToaster.svelte +159 -159
  50. package/dist/SvToggleButton.svelte +85 -85
  51. package/dist/SvTooltip.svelte +161 -161
  52. package/dist/SvTour.svelte +208 -208
  53. package/dist/SvTree.svelte +444 -444
  54. package/dist/SvTreeSelect.svelte +239 -239
  55. package/dist/cdn/{GridMenus-BzWXQjv3.js → GridMenus-DMihUtma.js} +3 -3
  56. package/dist/cdn/{GridMenus-xr_rHx8F.js → GridMenus-nmNDj1a3.js} +3 -3
  57. package/dist/cdn/{SvDateRangeInput-DMLKmGEc.js → SvDateRangeInput-Bh0A0JkF.js} +1 -1
  58. package/dist/cdn/{SvDateRangeInput-CaOuMs8O.js → SvDateRangeInput-DflbiP7N.js} +1 -1
  59. package/dist/cdn/{SvDateTimePicker-sonaH0oh.js → SvDateTimePicker-BWwpfB_o.js} +1 -1
  60. package/dist/cdn/{SvDateTimePicker-CCbDZNZB.js → SvDateTimePicker-Bivn8dAP.js} +1 -1
  61. package/dist/cdn/{SvGridCellEditor-BAPSC7EL.js → SvGridCellEditor-AXL8cHGO.js} +1 -1
  62. package/dist/cdn/{SvGridCellEditor-BwzmUWtL.js → SvGridCellEditor-Ba7rY3eu.js} +1 -1
  63. package/dist/cdn/{SvGridChart-BwVos976.js → SvGridChart-Bs2GIR2Q.js} +1 -1
  64. package/dist/cdn/{SvGridChart-BEJmNNx9.js → SvGridChart-CwhFz7GV.js} +1 -1
  65. package/dist/cdn/{SvGridChartPanel-BOknOkrP.js → SvGridChartPanel-1WXuStzM.js} +1 -1
  66. package/dist/cdn/{SvGridChartPanel-D2PjII4O.js → SvGridChartPanel-e5_nqNP9.js} +1 -1
  67. package/dist/cdn/{SvGridChartView-00LPUHL1.js → SvGridChartView-SmPW10dI.js} +1 -1
  68. package/dist/cdn/{SvGridChartView-BhUEJ5ki.js → SvGridChartView-eSPuJE6g.js} +1 -1
  69. package/dist/cdn/{SvGridDropdown-D0VdjeR8.js → SvGridDropdown-B1ZcLpgs.js} +1 -1
  70. package/dist/cdn/{SvGridDropdown-D13MtJ2j.js → SvGridDropdown-CtdbHcIS.js} +1 -1
  71. package/dist/cdn/{date-format-BnnHlqGw.js → date-format-CcP1tafP.js} +2 -2
  72. package/dist/cdn/{date-format-BNii4zeD.js → date-format-DZT7T1wf.js} +2 -2
  73. package/dist/cdn/{row-drag-touch-Ddaa-QeB.js → row-drag-touch-CycRR65n.js} +12 -10
  74. package/dist/cdn/{src-skQN5eqh.js → src-B_YS5AOc.js} +45 -45
  75. package/dist/cdn/{src-DGo7IHug.js → src-DYXXpuSk.js} +44 -44
  76. package/dist/cdn/svgrid.js +7 -7
  77. package/dist/cdn/svgrid.svelte-external.js +7 -7
  78. package/dist/chart-export.js +8 -8
  79. package/dist/row-drag-touch.d.ts +5 -1
  80. package/dist/row-drag-touch.js +15 -4
  81. package/dist/row-drag.js +7 -3
  82. package/package.json +11 -11
  83. package/src/FlexRender.svelte +96 -96
  84. package/src/GridFooter.svelte +181 -181
  85. package/src/SvAutoComplete.svelte +169 -169
  86. package/src/SvAvatar.svelte +75 -75
  87. package/src/SvCalendar.svelte +503 -503
  88. package/src/SvCalendar.test.ts +226 -226
  89. package/src/SvCarousel.svelte +141 -141
  90. package/src/SvCheckBox.svelte +102 -102
  91. package/src/SvCircularProgress.svelte +109 -109
  92. package/src/SvColorInput.svelte +181 -181
  93. package/src/SvComboBox.svelte +279 -279
  94. package/src/SvContextMenu.svelte +116 -116
  95. package/src/SvCountryInput.svelte +163 -163
  96. package/src/SvDrawer.svelte +254 -254
  97. package/src/SvDropDownList.svelte +378 -378
  98. package/src/SvDurationInput.svelte +126 -126
  99. package/src/SvField.svelte +293 -293
  100. package/src/SvForm.svelte +437 -437
  101. package/src/SvForm.test.ts +411 -411
  102. package/src/SvGrid.types.ts +2092 -2092
  103. package/src/SvGridCellEditor.svelte +744 -744
  104. package/src/SvGridChart.svelte +1716 -1716
  105. package/src/SvGridChartPanel.svelte +485 -485
  106. package/src/SvGridChartView.svelte +70 -70
  107. package/src/SvGridDropdown.svelte +728 -728
  108. package/src/SvGridSelect.svelte +270 -270
  109. package/src/SvGroupCell.svelte +116 -116
  110. package/src/SvListBox.svelte +334 -334
  111. package/src/SvMaskedInput.svelte +122 -122
  112. package/src/SvMenu.svelte +124 -124
  113. package/src/SvMenu.test.ts +97 -97
  114. package/src/SvMenuList.svelte +146 -146
  115. package/src/SvMultiSelect.svelte +293 -293
  116. package/src/SvNumberInput.svelte +172 -172
  117. package/src/SvOtpInput.svelte +158 -158
  118. package/src/SvPasswordInput.svelte +151 -151
  119. package/src/SvPhoneInput.svelte +133 -133
  120. package/src/SvPopover.svelte +197 -197
  121. package/src/SvProgress.svelte +116 -116
  122. package/src/SvRadioGroup.svelte +107 -107
  123. package/src/SvRating.svelte +112 -112
  124. package/src/SvResult.svelte +73 -73
  125. package/src/SvRichText.svelte +211 -211
  126. package/src/SvRowGroupPanel.svelte +170 -170
  127. package/src/SvScrollArea.svelte +61 -61
  128. package/src/SvSlider.svelte +203 -203
  129. package/src/SvSwitchButton.svelte +108 -108
  130. package/src/SvTagsInput.svelte +115 -115
  131. package/src/SvTextInput.svelte +147 -147
  132. package/src/SvTimePicker.svelte +245 -245
  133. package/src/SvToaster.svelte +159 -159
  134. package/src/SvToaster.test.ts +95 -95
  135. package/src/SvToggleButton.svelte +85 -85
  136. package/src/SvTooltip.svelte +161 -161
  137. package/src/SvTour.svelte +208 -208
  138. package/src/SvTree.svelte +444 -444
  139. package/src/SvTreeSelect.svelte +239 -239
  140. package/src/a11y/dismissable.test.ts +119 -119
  141. package/src/a11y/dismissable.ts +114 -114
  142. package/src/a11y.contract.test.ts +49 -49
  143. package/src/a11y.test.ts +59 -59
  144. package/src/a11y.ts +61 -61
  145. package/src/ai.test.ts +502 -502
  146. package/src/ai.ts +1419 -1419
  147. package/src/build-api.coverage.test.ts +633 -633
  148. package/src/build-api.ts +846 -846
  149. package/src/builtin-editors.grid.test.ts +83 -83
  150. package/src/cell-formatting.ts +171 -171
  151. package/src/cell-render.test.ts +513 -513
  152. package/src/cell-render.ts +496 -496
  153. package/src/cell-values.ts +148 -148
  154. package/src/chart-export.ts +202 -202
  155. package/src/chart-view.svelte.ts +36 -36
  156. package/src/chart.ts +2321 -2321
  157. package/src/collaboration.test.ts +104 -104
  158. package/src/collaboration.ts +167 -167
  159. package/src/column-groups.ts +78 -78
  160. package/src/core.performance.test.ts +30 -30
  161. package/src/core.ts +1865 -1865
  162. package/src/createAutocomplete.svelte.ts +132 -132
  163. package/src/createCombobox.svelte.ts +191 -191
  164. package/src/createCountryInput.svelte.ts +157 -157
  165. package/src/createDropdownList.svelte.ts +168 -168
  166. package/src/createForm.svelte.ts +386 -386
  167. package/src/createGrid.svelte.ts +42 -42
  168. package/src/createGrid.test.ts +10 -10
  169. package/src/createGridState.svelte.ts +17 -17
  170. package/src/createListbox.svelte.ts +250 -250
  171. package/src/createMenu.svelte.ts +224 -224
  172. package/src/createPopoverSelect.svelte.ts +213 -213
  173. package/src/createSlider.svelte.ts +191 -191
  174. package/src/createTooltip.svelte.ts +144 -144
  175. package/src/createTree.svelte.ts +322 -322
  176. package/src/datetime/date-core.ts +206 -206
  177. package/src/datetime/date-restrict.ts +61 -61
  178. package/src/datetime/timezone.ts +135 -135
  179. package/src/dock-manager-model.ts +596 -596
  180. package/src/dock-model.ts +374 -374
  181. package/src/editing.test.ts +974 -974
  182. package/src/editing.ts +609 -609
  183. package/src/editor-contract.ts +171 -171
  184. package/src/editor-registry.grid.test.ts +144 -144
  185. package/src/editor-registry.ts +122 -122
  186. package/src/export-data-api.test.ts +126 -126
  187. package/src/export-format.test.ts +107 -107
  188. package/src/export-format.ts +601 -601
  189. package/src/filter-operators.ts +160 -160
  190. package/src/filtering/excel-filters.ts +325 -325
  191. package/src/flex-render.ts +3 -3
  192. package/src/form-field.ts +127 -127
  193. package/src/group-display.test.ts +167 -167
  194. package/src/group-display.ts +200 -200
  195. package/src/headless.ts +87 -87
  196. package/src/js-scroller.svelte.ts +173 -173
  197. package/src/keyboard-handlers.ts +270 -270
  198. package/src/keyboard.test.ts +59 -59
  199. package/src/keyboard.ts +97 -97
  200. package/src/list-nav.test.ts +49 -49
  201. package/src/list-nav.ts +29 -29
  202. package/src/list-option.test.ts +56 -56
  203. package/src/list-option.ts +179 -179
  204. package/src/menus.ts +597 -597
  205. package/src/merge-objects.ts +48 -48
  206. package/src/overlays.test.ts +90 -90
  207. package/src/positioning.ts +268 -268
  208. package/src/render-component.ts +28 -28
  209. package/src/row-drag-touch.ts +20 -5
  210. package/src/row-drag.test.ts +401 -353
  211. package/src/row-drag.ts +419 -415
  212. package/src/row-resize.test.ts +524 -524
  213. package/src/row-resize.ts +228 -228
  214. package/src/scheduler-ical.ts +181 -181
  215. package/src/scheduler-model.test.ts +562 -562
  216. package/src/scheduler-model.ts +873 -873
  217. package/src/selection.test.ts +885 -885
  218. package/src/server-data-source.test.ts +383 -383
  219. package/src/server-data-source.ts +469 -469
  220. package/src/sparkline.test.ts +68 -68
  221. package/src/sparkline.ts +169 -169
  222. package/src/spreadsheet.test.ts +488 -488
  223. package/src/spreadsheet.ts +312 -312
  224. package/src/static-functions.ts +11 -11
  225. package/src/subscribe.ts +38 -38
  226. package/src/summaries.ts +113 -113
  227. package/src/svgrid-wrapper.types.ts +563 -563
  228. package/src/svgrid.async-editor-options.test.ts +273 -273
  229. package/src/svgrid.auto-row-height.test.ts +204 -204
  230. package/src/svgrid.behavior.test.ts +910 -910
  231. package/src/svgrid.charting.test.ts +534 -534
  232. package/src/svgrid.comments-autocomplete.test.ts +127 -127
  233. package/src/svgrid.context-menu.test.ts +147 -147
  234. package/src/svgrid.features.test.ts +157 -157
  235. package/src/svgrid.filter-depth.test.ts +163 -163
  236. package/src/svgrid.filter-menu-listbox.svelte.test.ts +377 -377
  237. package/src/svgrid.filter-menu-scroll.test.ts +112 -112
  238. package/src/svgrid.grand-total.test.ts +188 -188
  239. package/src/svgrid.group-display-mode.test.ts +171 -171
  240. package/src/svgrid.group-footers.test.ts +121 -121
  241. package/src/svgrid.group-pagination.test.ts +153 -153
  242. package/src/svgrid.new-features.wrapper.test.ts +251 -251
  243. package/src/svgrid.tree-data.test.ts +186 -186
  244. package/src/svgrid.wrapper.test.ts +63 -63
  245. package/src/svgriddropdown.async-panel.svelte.test.ts +195 -195
  246. package/src/test-setup.ts +62 -62
  247. package/src/themes/index.ts +288 -288
  248. package/src/toast-store.svelte.ts +250 -250
  249. package/src/toast-store.test.ts +147 -147
  250. package/src/tree-row-model.test.ts +168 -168
  251. package/src/ui-buttons.test.ts +144 -144
  252. package/src/ui-inputs.test.ts +118 -118
  253. package/src/ui-localization.test.ts +113 -113
  254. package/src/ui-range.test.ts +70 -70
  255. package/src/ui-selection.test.ts +155 -155
  256. package/src/ui-tier1.test.ts +142 -142
  257. package/src/virtual.test.ts +88 -88
  258. package/src/virtualization/column-virtualizer.test.ts +27 -27
  259. package/src/virtualization/column-virtualizer.ts +30 -30
  260. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  261. package/src/virtualization/types.ts +30 -30
  262. package/src/virtualization/virtualizer.test.ts +47 -47
  263. package/src/virtualization/virtualizer.ts +322 -322
@@ -1,2092 +1,2092 @@
1
- // Type definitions extracted from SvGrid.svelte. These are compile-time
2
- // only - moving them out keeps the component's <script> focused on logic.
3
- import type { Snippet } from "svelte";
4
- import type {
5
- CellEditorType,
6
- ColumnDef,
7
- RowData,
8
- SvGridApi,
9
- TableFeatures,
10
- } from "./index";
11
- import type { ConditionalFormat } from "./conditional-formatting";
12
- import type { GroupDisplayType } from "./group-display";
13
- import type { GridMessages } from "./grid-messages";
14
- import type { GridPivotConfig } from "./pivot-view.svelte";
15
- import type { GridPredicateExpr } from "./filtering/predicate-expr";
16
- import type { MenuItem } from "./SvMenuList.svelte";
17
-
18
- /** The calendar views the scheduler can render. {@link SchedulerConfig}. The
19
- * `timeline*` views are horizontal: time runs left→right and resources are
20
- * rows (a single "All" row without `resourceField`). */
21
- export type SchedulerView =
22
- | "month"
23
- | "week"
24
- | "day"
25
- | "agenda"
26
- | "timelineDay"
27
- | "timelineWeek"
28
- | "timelineMonth"
29
- | "timelineYear";
30
-
31
- /**
32
- * How overlapping ("colliding") time-grid events are laid out:
33
- * - `split` - every collision divides the column width evenly (default).
34
- * - `cap` - show up to `maxColumns` columns; the rest collapse into a
35
- * clickable `+N more` overflow tile.
36
- * - `stack` - overlapping events overlap with a horizontal offset + z-order
37
- * instead of shrinking, so each stays readable (hover to raise).
38
- */
39
- export type SchedulerCollisionMode = "split" | "cap" | "stack";
40
-
41
- /** A scheduler resource - a person / room / machine an event can be assigned to. */
42
- export type SchedulerResource = {
43
- id: string;
44
- title?: string;
45
- color?: string;
46
- /**
47
- * This resource's own working windows (hours), optionally per weekday - e.g. a
48
- * doctor available Mon/Wed/Fri 9-13 and Tue/Thu 14-18. Overrides the global
49
- * `businessHours` / `nonWorkingDays` for this resource's columns: time outside
50
- * every matching window is shaded, and (with `restrictToBusinessHours`)
51
- * non-bookable. A weekday with no matching window is a full day off.
52
- */
53
- availability?: ReadonlyArray<{ days?: ReadonlyArray<number>; start: number; end: number }>;
54
- /**
55
- * Per-date overrides to this resource's weekly `availability` - a specific day
56
- * off (`off: true`, e.g. vacation) or custom hours (`windows`) for that one
57
- * date. Matched by calendar date; takes precedence over `availability` for the
58
- * matching day.
59
- */
60
- dateOverrides?: ReadonlyArray<{
61
- date: Date | number | string;
62
- off?: boolean;
63
- windows?: ReadonlyArray<{ start: number; end: number }>;
64
- }>;
65
- };
66
- import type {
67
- ChartType,
68
- ChartSpec,
69
- ChartAnnotation,
70
- ChartReferenceLine,
71
- ChartValueFormat,
72
- } from "./chart";
73
-
74
- /** One aggregated bucket returned by a server-side `getAggregate`. */
75
- export type ChartAggregateBucket = { category: string; series?: string; value: number };
76
- /** The request a server-side `getAggregate` receives (whole-dataset charting). */
77
- export type ChartAggregateRequest = {
78
- dimension: string | undefined;
79
- measure: string | null;
80
- series?: string;
81
- reduce: "sum" | "avg" | "count";
82
- filterModel: Record<string, unknown>;
83
- };
84
-
85
- /**
86
- * Config for the built-in `charting` prop. All fields optional and additive;
87
- * `charting={true}` is the zero-config form. Column references are column
88
- * field names / ids.
89
- */
90
- export type ChartingConfig<TData extends RowData = RowData> = {
91
- /** Right-side drawer (default) or bottom dock. */
92
- position?: "bottom" | "right";
93
- /** Open the panel on first render. */
94
- defaultOpen?: boolean;
95
- /** Initial chart type. */
96
- defaultType?: ChartType;
97
- /** Docked-bottom height (px). */
98
- height?: number;
99
- /** Drawer width (px). */
100
- width?: number;
101
- /** Clicking a chart category filters the grid on the charted dimension. */
102
- crossFilter?: boolean;
103
- /** Group-by column. */
104
- dimension?: string;
105
- /** Split-by column: one series per distinct value. */
106
- series?: string;
107
- /** Measure column, or several for a multi-series chart. */
108
- measures?: string | string[];
109
- reduce?: "sum" | "avg" | "count";
110
- stacked?: boolean;
111
- stacked100?: boolean;
112
- /** Per-series-label type override (combo). */
113
- seriesTypes?: Record<string, "bar" | "line" | "area">;
114
- /** Per-series-label axis override (dual axis). */
115
- seriesAxes?: Record<string, "left" | "right">;
116
- referenceLines?: ChartReferenceLine[];
117
- averageLine?: boolean;
118
- trend?: "sma" | "ema" | "linear";
119
- annotations?: ChartAnnotation[];
120
- yScale?: "linear" | "log";
121
- timeAxis?: boolean;
122
- valueFormat?: "number" | "currency" | "percent" | "compact";
123
- smooth?: boolean;
124
- orientation?: "vertical" | "horizontal";
125
- donut?: number | boolean;
126
- palette?: string[];
127
- patternFallback?: boolean;
128
- topN?: number;
129
- otherLabel?: string;
130
- sort?: "value-desc" | "value-asc" | "category" | "none";
131
- dataLabels?: boolean;
132
- zoom?: boolean;
133
- brush?: boolean;
134
- /** Show the chart's PNG/SVG export toolbar. */
135
- export?: boolean;
136
- /** Escape hatch: build a fully custom ChartSpec from the (scoped) rows. */
137
- buildSpec?: (rows: TData[]) => ChartSpec | null;
138
- /** Server-side aggregation: chart the whole dataset, not just loaded rows. */
139
- getAggregate?: (
140
- request: ChartAggregateRequest,
141
- ) => Promise<ReadonlyArray<ChartAggregateBucket>>;
142
- /** Bump to force a server-side refetch. */
143
- refreshKey?: unknown;
144
- };
145
-
146
- /**
147
- * The built-in card detail drawer. Set `board.drawer` (`true` for all fields,
148
- * or this object to customize) and opening a card shows a drawer with an
149
- * `SvForm` of its fields, rendered with the UI-kit editors.
150
- */
151
- export type BoardDrawerConfig<TData extends RowData = RowData> = {
152
- /** Fields to show, in order. Omit for every column that has a `field`. */
153
- fields?: ReadonlyArray<keyof TData & string>;
154
- /** Drawer title - a string or derived from the row. Defaults to the title field. */
155
- title?: string | ((row: TData) => string);
156
- /** Which edge the drawer opens from. Defaults to `'right'`. */
157
- side?: "right" | "left" | "top" | "bottom";
158
- /** Drawer size (any CSS length). Defaults to `'380px'`. */
159
- size?: string;
160
- /** Save button label. Defaults to `'Save'`. */
161
- submitLabel?: string;
162
- /** Form columns inside the drawer. Defaults to `1`. */
163
- columns?: number;
164
- };
165
-
166
- /** Board-native helpers passed to `board.cardMenu` for building context items. */
167
- export type BoardMenuContext<TData extends RowData = RowData> = {
168
- /** The board's lanes (id + title). */
169
- lanes: BoardLane[];
170
- /** Move this card to a lane (board-native; fires onCardMove). */
171
- moveTo: (laneId: string) => void;
172
- /** Open this card's editor (inline, or your `onCardEdit`). */
173
- edit: () => void;
174
- };
175
-
176
- /** Board-native helpers passed to `board.laneMenu` for building lane context items. */
177
- export type BoardLaneMenuContext<TData extends RowData = RowData> = {
178
- /** The lane's id. */
179
- laneId: string;
180
- /** The lane's current cards (this swimlane's, if any). */
181
- cards: TData[];
182
- /** Whether the lane is collapsed. */
183
- collapsed: boolean;
184
- /** Collapse / expand the lane (needs `collapsibleLanes`). */
185
- toggleCollapse: () => void;
186
- /** Add a card to the lane (fires `onCardAdd`). */
187
- addCard: (title?: string) => void;
188
- };
189
-
190
- /** The cell a context menu was opened on. Passed to every item's callbacks. */
191
- export type ContextMenuTarget<TData extends RowData = RowData> = {
192
- rowIndex: number;
193
- colIndex: number;
194
- columnId: string;
195
- /** Stable row id (from getRowId / row model), for keying notes etc. */
196
- rowId: string;
197
- row: TData | null;
198
- };
199
-
200
- /**
201
- * A context-menu entry. Either a built-in action key, the `"separator"`
202
- * divider, or a custom item. Built-in keys: `"copy" | "cut" | "paste" |
203
- * "clear" | "row_above" | "row_below" | "remove_row" | "remove_col" |
204
- * "chart"`. The `"chart"` item (chart the selected range) is only shown when
205
- * `charting` is enabled; it is appended to the default menu automatically.
206
- */
207
- export type ContextMenuItem<TData extends RowData = RowData> =
208
- | string
209
- | {
210
- key: string;
211
- label: string;
212
- /** Hide the item entirely for this target. */
213
- hidden?: (target: ContextMenuTarget<TData>) => boolean;
214
- /** Render the item greyed-out and non-clickable for this target. */
215
- disabled?: (target: ContextMenuTarget<TData>) => boolean;
216
- /** Invoked on click. The menu closes afterwards. */
217
- action: (target: ContextMenuTarget<TData>) => void;
218
- };
219
-
220
- /** What a {@link SelectionBarAction} is handed when it runs. */
221
- export type SelectionBarTarget<TData extends RowData = RowData> = {
222
- /** The selected rows, in the grid's current display order. */
223
- rows: TData[];
224
- /** Their row ids, same order as `rows`. */
225
- ids: string[];
226
- };
227
-
228
- /**
229
- * One button on the selection bar. Same shape as {@link ContextMenuItem}'s
230
- * object form - key, label, optional hidden/disabled predicates, and an action -
231
- * except everything here is handed the whole SELECTION rather than one cell.
232
- */
233
- export type SelectionBarAction<TData extends RowData = RowData> = {
234
- key: string;
235
- label: string;
236
- /**
237
- * Inline SVG path data (the `d` of a single 24x24 path) drawn to the left of
238
- * the label. A string rather than a component so an action array stays plain
239
- * data that can live in a `.ts` module next to the columns.
240
- */
241
- icon?: string;
242
- /** Render in the destructive style (red). Does not add a confirmation. */
243
- danger?: boolean;
244
- /** Hide the button entirely for this selection. */
245
- hidden?: (target: SelectionBarTarget<TData>) => boolean;
246
- /** Render greyed-out and non-clickable for this selection. */
247
- disabled?: (target: SelectionBarTarget<TData>) => boolean;
248
- /** Invoked on click. The bar stays open; clear the selection yourself if the
249
- * action should dismiss it. */
250
- action: (target: SelectionBarTarget<TData>) => void;
251
- };
252
-
253
- /**
254
- * A built-in bar button, named by key - the same convention
255
- * {@link ContextMenuItem} uses for its string form.
256
- *
257
- * - `'selectAll'` selects every row in the current view.
258
- * - `'editFields'` opens the bulk-edit dialog: pick a field, set one value,
259
- * apply it to every selected row in a single undo step.
260
- * - `'separator'` draws a divider.
261
- */
262
- export type SelectionBarBuiltin = "selectAll" | "editFields" | "separator";
263
-
264
- /**
265
- * Full form of the {@link SvGridProps.selectionBar} prop, for when the array
266
- * shorthand is not enough.
267
- */
268
- export type SelectionBarConfig<TData extends RowData = RowData> = {
269
- /**
270
- * The buttons, left to right. Strings are {@link SelectionBarBuiltin} keys,
271
- * objects are your own actions - so a Jira-shaped bar is
272
- * `['selectAll', 'editFields', 'separator', myAction]`.
273
- */
274
- actions?: ReadonlyArray<SelectionBarAction<TData> | SelectionBarBuiltin>;
275
- /**
276
- * Which edge of the grid the bar floats against. Default `'bottom'`, where
277
- * the eye is already going after ticking a checkbox and where it covers the
278
- * rows a user is least likely to be reading.
279
- */
280
- position?: "bottom" | "top";
281
- /**
282
- * How many actions stay on the bar before the rest collapse into an overflow
283
- * menu. Default 6, which fits a full issue-tracker set (select all, edit,
284
- * status, watch, delete) without collapsing. A bar wide enough to need
285
- * horizontal scrolling is a bar whose last button nobody finds.
286
- */
287
- maxVisible?: number;
288
- /** Hide the trailing clear (x) button. Default false. */
289
- hideClear?: boolean;
290
- };
291
-
292
- /** A single Kanban lane (board column). {@link BoardConfig}. */
293
- export type BoardLane = {
294
- /** Lane id - equals the `groupBy` field value of the cards it holds. */
295
- id: string;
296
- /** Header title. Defaults to the id (or `(empty)` for a blank value). */
297
- title?: string;
298
- /** Accent color (any CSS color) for the lane header bar + card ring. */
299
- color?: string;
300
- /**
301
- * Soft max number of cards. When exceeded the lane header is flagged
302
- * over-limit. Enforcement/styling is an enterprise concern; the count is
303
- * always shown.
304
- */
305
- wipLimit?: number;
306
- };
307
-
308
- /** A checklist item inside a card. See {@link BoardConfig.subtasks}. */
309
- export type BoardSubtask = {
310
- id: string | number;
311
- title: string;
312
- done: boolean;
313
- };
314
-
315
- /** A comment on a card. See {@link BoardConfig.commentsField}. */
316
- export type BoardComment = {
317
- id: string | number;
318
- text: string;
319
- author?: string;
320
- /** Timestamp label (any string). */
321
- at?: string;
322
- };
323
-
324
- /**
325
- * The serializable board layout - the per-card position/edit overlay plus
326
- * collapsed lanes. Persisted by `board.persistKey` and passed to
327
- * `board.onLayoutChange`.
328
- */
329
- export type BoardLayout = {
330
- /** rowId -> lane id. */
331
- laneOf?: Record<string, string>;
332
- /** rowId -> sort order within its lane. */
333
- orderOf?: Record<string, number>;
334
- /** rowId -> swimlane id. */
335
- swimOf?: Record<string, string>;
336
- /** rowId -> edited field values. */
337
- edits?: Record<string, Record<string, unknown>>;
338
- /** lane id -> collapsed. */
339
- collapsed?: Record<string, boolean>;
340
- /** swimlane id -> collapsed. */
341
- collapsedSwim?: Record<string, boolean>;
342
- /** Explicit lane order (ids), when lanes have been drag-reordered. */
343
- laneOrder?: string[];
344
- /** rowId -> subtaskId -> done override. */
345
- subDone?: Record<string, Record<string, boolean>>;
346
- /** rowId -> subtasks added on the card. */
347
- subAdded?: Record<string, BoardSubtask[]>;
348
- };
349
-
350
- /** Emitted when a card's built-in editor is saved. */
351
- export type BoardCardCommitEvent<TData extends RowData = RowData> = {
352
- /** The edited row. */
353
- row: TData;
354
- /** Only the fields that changed, `{ field: newValue }`. */
355
- changes: Record<string, unknown>;
356
- /** The full set of edited field values. */
357
- values: Record<string, unknown>;
358
- };
359
-
360
- /** Emitted when a card is dragged to a new lane and/or position. */
361
- export type BoardCardMoveEvent<TData extends RowData = RowData> = {
362
- /** The dragged row. */
363
- row: TData;
364
- /** Lane the card came from. */
365
- fromLane: string;
366
- /** Lane the card was dropped on. */
367
- toLane: string;
368
- /** Insertion index within the destination lane. */
369
- toIndex: number;
370
- /** Swimlane the card came from (only when `swimlaneBy` is set). */
371
- fromSwimlane?: string;
372
- /** Swimlane the card was dropped on (only when `swimlaneBy` is set). */
373
- toSwimlane?: string;
374
- };
375
-
376
- /**
377
- * Turns the grid into a Kanban board. Set `board` and the grid renders its
378
- * rows as cards in horizontal lanes (bucketed by the `groupBy` field) instead
379
- * of a table. Dragging a card between lanes fires {@link BoardConfig.onCardMove}
380
- * where you reassign the `groupBy` field on your own data.
381
- */
382
- /**
383
- * Chart view of the grid. Setting the `chart` prop on `<SvGrid>` swaps the table
384
- * for a chart driven by the grid's FILTERED + SORTED rows - so the search box,
385
- * column filters and sort all flow through to the chart. Unlike the board and
386
- * scheduler views, the renderer is free: the grid lazy-loads a built-in
387
- * `SvChart` view unless a host overrides it via `registerChartView`.
388
- *
389
- * The config maps directly onto `rowsToChartSpec` - one row field for the
390
- * category axis, one or more for the value series (or a `series` field to pivot
391
- * one series per distinct value).
392
- *
393
- * ```svelte
394
- * <SvGrid {data} {columns}
395
- * chart={{ type: 'bar', category: 'month', value: 'revenue', reduce: 'sum' }} />
396
- * ```
397
- */
398
- export type ChartViewConfig<
399
- TFeatures extends TableFeatures = TableFeatures,
400
- TData extends RowData = RowData,
401
- > = {
402
- /** Chart type. Default `'bar'`. */
403
- type?: ChartType;
404
- /** Row field for the category (x) axis. */
405
- category: keyof TData & string;
406
- /** Row field(s) for the value (y) series. */
407
- value: (keyof TData & string) | Array<keyof TData & string>;
408
- /** Pivot dimension: one series per distinct value of this field. */
409
- series?: keyof TData & string;
410
- /** Aggregation when several rows share a category. Default `'sum'`. */
411
- reduce?: "sum" | "avg" | "count";
412
- /** Stack bar / area series instead of grouping them. */
413
- stacked?: boolean;
414
- /** Stack to 100% (implies `stacked`). */
415
- stacked100?: boolean;
416
- /** Order categories. Default: insertion order (value-desc when `topN` is set). */
417
- sort?: "value-desc" | "value-asc" | "category" | "none";
418
- /** Keep only the top N categories; bucket the rest into "Other". */
419
- topN?: number;
420
- /** Palette for series without an explicit colour. */
421
- palette?: string[];
422
- /** Number format for the value axis, tooltips and data labels. */
423
- valueFormat?: ChartValueFormat;
424
- /** Show the clickable legend. Default `true`. */
425
- legend?: boolean;
426
- /** Draw the value on each bar / point / slice. Default `false`. */
427
- dataLabels?: boolean;
428
- /** Show the search box above the chart (filters rows first). Default `true`. */
429
- searchable?: boolean;
430
- /** Placeholder for the search box. */
431
- searchPlaceholder?: string;
432
- };
433
-
434
- export type BoardConfig<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> = {
435
- /** Field whose value buckets each row into a lane. */
436
- groupBy: keyof TData & string;
437
- /**
438
- * Explicit, ordered lanes. Omit to derive lanes from the distinct
439
- * `groupBy` values found in the data (first-seen order).
440
- */
441
- lanes?: ReadonlyArray<BoardLane>;
442
- /** Custom card body. Receives the row. Omit for the built-in default card. */
443
- card?: Snippet<[TData]>;
444
- /**
445
- * Fired when a card is dragged to a new lane/position. Update your data
446
- * here (reassign the `groupBy` field, and optionally reorder). Without it
447
- * the board is display-only.
448
- */
449
- onCardMove?: (event: BoardCardMoveEvent<TData>) => void;
450
- /**
451
- * Add-card affordance. A `+` in the lane header (or, with `composer`, a
452
- * type-a-title box at the bottom of the lane) fires this with the lane id
453
- * and - from the composer - the typed title.
454
- */
455
- onCardAdd?: (laneId: string, title?: string) => void;
456
- /**
457
- * Show a quick-add composer at the bottom of each lane (a "+ Add a card"
458
- * button that opens an inline title input; Enter calls `onCardAdd(lane,
459
- * title)`). Without it, `onCardAdd` shows a plain `+` in the header.
460
- */
461
- composer?: boolean;
462
- /**
463
- * Field holding a card's checklist of sub-tasks (`BoardSubtask[]`). The card
464
- * shows a progress chip + bar and expands to an inline checklist with a
465
- * quick-add. Toggles/adds run through an overlay (never mutating your data)
466
- * and fire the callbacks below.
467
- */
468
- subtasks?: keyof TData & string;
469
- /** Fired when a sub-task checkbox is toggled. */
470
- onSubtaskToggle?: (row: TData, subtaskId: string | number, done: boolean) => void;
471
- /** Fired when a sub-task is added from the card. */
472
- onSubtaskAdd?: (row: TData, title: string) => void;
473
- /**
474
- * Field holding label/tag strings (or `{ text, color }`) shown as chips on
475
- * the default card's badge row.
476
- */
477
- labelsField?: keyof TData & string;
478
- /** Field holding a due date (Date | ISO string); shown as a badge, red when overdue. */
479
- dueField?: keyof TData & string;
480
- /**
481
- * Field holding one or more assignee names (string | string[]); shown as
482
- * avatar(s) on the default card's badge row.
483
- */
484
- assigneesField?: keyof TData & string;
485
- /**
486
- * Enable the built-in card editor: double-click a card (or press F2 while
487
- * it is focused) to edit its fields inline. Fields are rendered from the
488
- * columns that declare an `editorType` (or all fields if none do). Ignored
489
- * when `onCardEdit` is set.
490
- */
491
- editable?: boolean;
492
- /**
493
- * Open your own editor instead of the built-in one. Called on double-click /
494
- * F2 with the row; you might open a drawer or route to a detail screen.
495
- */
496
- onCardEdit?: (row: TData) => void;
497
- /**
498
- * Built-in **detail drawer**: opening a card (double-click / F2) shows an
499
- * `SvDrawer` with an `SvForm` of its fields (kit editors). `true` = all
500
- * fields; pass a {@link BoardDrawerConfig} to pick a subset / customize.
501
- * Ignored when `onCardEdit` is set.
502
- */
503
- drawer?: boolean | BoardDrawerConfig<TData>;
504
- /** Fired when the built-in editor is saved. Persist / mirror the changes. */
505
- onCardCommit?: (event: BoardCardCommitEvent<TData>) => void;
506
- /** Field used as the card title. Defaults to the first column's field. */
507
- titleField?: keyof TData & string;
508
- /**
509
- * Column fields shown as label:value meta lines on the default card
510
- * (max 4). Defaults to the first few non-title, non-groupBy columns.
511
- */
512
- cardFields?: ReadonlyArray<keyof TData & string>;
513
- /**
514
- * Second grouping axis: split the board into horizontal **swimlanes** by
515
- * this field. Each swimlane band shows the full lane set with only its own
516
- * cards. Dragging a card into another band reassigns this field too.
517
- */
518
- swimlaneBy?: keyof TData & string;
519
- /** Let users collapse a swimlane band via its header chevron. */
520
- collapsibleSwimlanes?: boolean;
521
- /**
522
- * Field holding a card's comments - `BoardComment[]` (or plain strings, or a
523
- * number for a count only). Renders a comment-count badge that expands to a
524
- * thread; provide the callbacks below to let users write / delete comments.
525
- */
526
- commentsField?: keyof TData & string;
527
- /** Fired when a comment is added on the card; append it to your data. */
528
- onCommentAdd?: (row: TData, text: string) => void;
529
- /** Fired when a comment's delete button is pressed; remove it from your data. */
530
- onCommentDelete?: (row: TData, commentId: string | number) => void;
531
- /**
532
- * Field holding a card's attachments - an array or a number. Renders an
533
- * attachment-count badge on the default card.
534
- */
535
- attachmentsField?: keyof TData & string;
536
- /**
537
- * Field holding a cover colour (any CSS colour string) shown as a strip
538
- * across the top of the default card.
539
- */
540
- coverField?: keyof TData & string;
541
- /**
542
- * Enforce `wipLimit`: reject a drop / keyboard move that would push a lane
543
- * past its limit (the card snaps back). Off by default (the limit is a
544
- * soft, visual flag only).
545
- */
546
- enforceWip?: boolean;
547
- /** Let users collapse a lane to a slim strip by clicking its header. */
548
- collapsibleLanes?: boolean;
549
- /** Let users drag lane headers to reorder lanes (persisted with `persistKey`). */
550
- reorderableLanes?: boolean;
551
- /** Fired after a lane drag-reorder, with the new ordered lane ids. */
552
- onLaneReorder?: (orderedIds: string[]) => void;
553
- /**
554
- * Enable inline lane rename: double-click a lane title to edit it. Fires
555
- * with the lane id and new title - update your own lane config / data.
556
- */
557
- onLaneRename?: (laneId: string, title: string) => void;
558
- /**
559
- * Per-swimlane summary shown in the band header (e.g. a points/$ total or a
560
- * WIP count). Receives the swimlane's cards and its id; return a short string.
561
- */
562
- swimlaneSummary?: (rows: TData[], swimId: string) => string;
563
- /**
564
- * Right-click (or long-press) a card to open a context menu. Return the
565
- * menu items for that card; `ctx` gives board-native `moveTo(laneId)` and
566
- * `edit()` helpers plus the lane list. Return empty/undefined for no menu.
567
- */
568
- cardMenu?: (row: TData, ctx: BoardMenuContext<TData>) => ReadonlyArray<MenuItem> | undefined;
569
- /** Right-click a lane header for a lane context menu (rename / clear / add / collapse). */
570
- laneMenu?: (laneId: string, ctx: BoardLaneMenuContext<TData>) => ReadonlyArray<MenuItem> | undefined;
571
- /**
572
- * Truthy field marks a card as **blocked** (waiting on a dependency): a red
573
- * corner + a "Blocked" badge on the card. If the value is a non-empty string
574
- * it is used as the blocked **reason** (shown in the badge tooltip). A blocked
575
- * card is **locked from moving** (drag + keyboard) until it is unblocked - set
576
- * {@link BoardConfig.flagBlocksMoves} `false` for a purely visual flag.
577
- */
578
- flagField?: keyof TData & string;
579
- /** Whether a blocked (`flagField`) card is locked from moving. Defaults to `true`. */
580
- flagBlocksMoves?: boolean;
581
- /**
582
- * Field holding a created/started date (Date | ISO string); shown as a
583
- * relative **age** badge (e.g. `3d`).
584
- */
585
- ageField?: keyof TData & string;
586
- /**
587
- * Fields to expose as a **facet filter bar** above the board - a chip per
588
- * distinct value; selecting chips filters the visible cards.
589
- */
590
- facets?: ReadonlyArray<keyof TData & string>;
591
- /**
592
- * Enable card **multi-select**: click to select, Ctrl/Cmd-click to toggle,
593
- * and dragging a selected card moves the whole selection. Fires
594
- * `onSelectionChange`.
595
- */
596
- selectable?: boolean;
597
- /** Fired when the selection changes, with the selected rows. */
598
- onSelectionChange?: (rows: TData[]) => void;
599
- /**
600
- * Field holding a card's **child rows** (`TData[]`) - the card gets a
601
- * children count and expands to show them as nested mini-cards (epic ->
602
- * stories). Each child renders its title and, if present, its `groupBy` value.
603
- */
604
- childrenField?: keyof TData & string;
605
- /**
606
- * Optional per-lane summary shown in the lane header (e.g. a story-point or
607
- * dollar total). Receives the lane's cards (the current swimlane's, when
608
- * `swimlaneBy` is set) and the lane id; return a short string.
609
- */
610
- laneSummary?: (rows: TData[], laneId: string) => string;
611
- /** Show the built-in card search box (default `true`). */
612
- searchable?: boolean;
613
- /** Placeholder for the search box. Defaults to `"Search cards..."`. */
614
- searchPlaceholder?: string;
615
- /**
616
- * Virtualize each lane so only the cards in view are in the DOM - for boards
617
- * with thousands of cards per lane. Assumes roughly uniform card height; set
618
- * `cardHeight` to match your cards.
619
- */
620
- virtualized?: boolean;
621
- /** Estimated card height in px used by `virtualized` windowing (default 76). */
622
- cardHeight?: number;
623
- /**
624
- * Persist the board layout (card positions, edits, collapsed lanes) to
625
- * `localStorage` under this key, restored on load. Requires `getRowId` for
626
- * stable identity across reloads.
627
- */
628
- persistKey?: string;
629
- /** Called whenever the board layout changes, with the serializable state. */
630
- onLayoutChange?: (layout: BoardLayout) => void;
631
- };
632
-
633
- /**
634
- * The built-in event detail drawer for the scheduler. Set `scheduler.drawer`
635
- * (`true` for all fields, or this object) and clicking an event opens a drawer
636
- * with an `SvForm` of its fields. Mirrors {@link BoardDrawerConfig}.
637
- */
638
- export type SchedulerDrawerConfig<TData extends RowData = RowData> = {
639
- /** Fields to show, in order. Omit for every column that has a `field`. */
640
- fields?: ReadonlyArray<keyof TData & string>;
641
- /** Drawer title - a string or derived from the row. Defaults to the title field. */
642
- title?: string | ((row: TData) => string);
643
- /** Which edge the drawer opens from. Defaults to `'right'`. */
644
- side?: "right" | "left" | "top" | "bottom";
645
- /** Drawer size (any CSS length). Defaults to `'380px'`. */
646
- size?: string;
647
- /** Save button label. Defaults to `'Save'`. */
648
- submitLabel?: string;
649
- /** Form columns inside the drawer. Defaults to `1`. */
650
- columns?: number;
651
- };
652
-
653
- /** Emitted when an event is dragged to a new time (and/or resource). */
654
- export type SchedulerEventMoveEvent<TData extends RowData = RowData> = {
655
- /** The dragged row. */
656
- row: TData;
657
- /** New start / end after the move. */
658
- start: Date;
659
- end: Date;
660
- /** Whether the event is all-day after the move. */
661
- allDay: boolean;
662
- /** Resource it came from (only with `resourceField`). */
663
- fromResource?: string;
664
- /** Resource it was dropped on (only with `resourceField`). */
665
- toResource?: string;
666
- };
667
-
668
- /** Emitted when an event's start or end edge is dragged to resize it. */
669
- export type SchedulerEventResizeEvent<TData extends RowData = RowData> = {
670
- row: TData;
671
- start: Date;
672
- end: Date;
673
- };
674
-
675
- /**
676
- * A drag-selected range (see `rangeSelectable`). `start`/`end` are a single
677
- * CONTINUOUS datetime range - dragging across days makes it a longer span, not a
678
- * per-day rectangle. `days` / `resourceIds` list the days / resources the range
679
- * touched (for reference); `allDay` is true when the all-day row was dragged.
680
- */
681
- export type SchedulerRangeSelection = {
682
- start: Date;
683
- end: Date;
684
- allDay?: boolean;
685
- /** Every day the range touched (one entry for a within-a-day drag). */
686
- days: Date[];
687
- /** Every resource the range touched (empty without `resourceField`). */
688
- resourceIds: string[];
689
- };
690
-
691
- /** Emitted when an event's built-in editor/drawer is saved. */
692
- export type SchedulerEventCommitEvent<TData extends RowData = RowData> = {
693
- row: TData;
694
- /** Only the fields that changed, `{ field: newValue }`. */
695
- changes: Record<string, unknown>;
696
- /** The full set of edited field values. */
697
- values: Record<string, unknown>;
698
- };
699
-
700
- /**
701
- * One override of a single occurrence of a recurring event (stored in the row's
702
- * `recurrenceExceptionsField`). `occurrenceStart` identifies the occurrence (its
703
- * original start, like an iCal `RECURRENCE-ID`); `deleted` removes just that one,
704
- * otherwise the given fields override it. Times are the same ISO / Date shape you
705
- * store on the row.
706
- */
707
- export type SchedulerException = {
708
- occurrenceStart: string | number | Date;
709
- deleted?: boolean;
710
- start?: string | number | Date;
711
- end?: string | number | Date;
712
- title?: string;
713
- allDay?: boolean;
714
- /**
715
- * Per-occurrence overrides for ANY other field (e.g. attendees, calendar,
716
- * color, resource). Merged over the row for just this occurrence, so "This
717
- * event" can change fields beyond start / end / title / all-day.
718
- */
719
- fields?: Record<string, unknown>;
720
- };
721
-
722
- /** How a change to a recurring event should apply. */
723
- export type SchedulerEditScope = "occurrence" | "following" | "series";
724
-
725
- /**
726
- * Fired when a single occurrence of a recurring event is edited or deleted (the
727
- * user chose "This event"). Append/merge `exception` into the row's
728
- * `recurrenceExceptionsField`; for `deleted` it carries `{ deleted: true }`.
729
- */
730
- export type SchedulerOccurrenceChangeEvent<TData extends RowData = RowData> = {
731
- row: TData;
732
- /** The occurrence's original start (its identity within the series). */
733
- occurrenceStart: Date;
734
- /** The override to store (already in real-instant time). */
735
- exception: SchedulerException;
736
- /**
737
- * Which scope the user chose. `'occurrence'` (default): merge `exception` into
738
- * the row. `'following'` ("this and all following"): split the series - stop
739
- * the original series before `occurrenceStart` and start a NEW series at it
740
- * carrying `exception`'s start/end/deleted. `'series'` never reaches here (it
741
- * edits the base row directly). Handle `'following'` in your own data.
742
- */
743
- scope: SchedulerEditScope;
744
- };
745
-
746
- /**
747
- * Turns the grid into a calendar / scheduler. Set `scheduler` and the grid
748
- * renders its rows as events on a Month / Week / Day / Agenda calendar (bucketed
749
- * by time, and optionally split into per-resource columns) instead of a table.
750
- * Dragging an event fires {@link SchedulerConfig.onEventMove} where you reassign
751
- * the start / end (and resource) on your own data. Like the Kanban board, it is
752
- * a pure *view of the grid*: it renders the grid's filtered + sorted rows and
753
- * writes back only through callbacks, never mutating your data.
754
- */
755
- export type SchedulerConfig<
756
- TFeatures extends TableFeatures = TableFeatures,
757
- TData extends RowData = RowData,
758
- > = {
759
- /** Field holding each event's start (`Date` | epoch-ms | ISO string). Required. */
760
- startField: keyof TData & string;
761
- /** Field holding the end. Omit to use `defaultDurationMin` from the start. */
762
- endField?: keyof TData & string;
763
- /** Boolean field marking an event as all-day (rendered in the all-day row). */
764
- allDayField?: keyof TData & string;
765
- /** Field for the event title. Defaults to the first column's field. */
766
- titleField?: keyof TData & string;
767
- /** Field holding a per-event accent color (any CSS color). Else `color`. */
768
- colorField?: keyof TData & string;
769
- /** Fallback accent color for every event. */
770
- color?: string;
771
- /**
772
- * Field holding a SECONDARY accent color, rendered as a strip on the LEFT edge
773
- * of the event - distinct from the main `colorField`. Lets an event encode two
774
- * dimensions at once (e.g. main color = person, left strip = role).
775
- */
776
- secondaryColorField?: keyof TData & string;
777
- /**
778
- * Field holding a free/busy status that drives a distinct visual treatment
779
- * (Outlook-style): `'busy'` (default solid), `'free'` (hollow / outline),
780
- * `'tentative'` (hatched), `'oof'` / `'outOfOffice'` (distinct tint). Ties to
781
- * iCal `STATUS`. Unrecognised values render as busy.
782
- */
783
- statusField?: keyof TData & string;
784
- /**
785
- * Field holding minutes-before-start for a reminder. When set (and the event
786
- * is upcoming) the scheduler fires `onReminder` once as that lead time is
787
- * crossed - pair it with a toast. Ties to iCal `VALARM`.
788
- */
789
- reminderField?: keyof TData & string;
790
- /** Fired once when an event's reminder lead time is crossed (see `reminderField`). */
791
- onReminder?: (row: TData, minutesUntil: number) => void;
792
- /**
793
- * Field holding a {@link RecurrenceRule} (or array) - the row renders as one
794
- * event per matching day in view, keeping its time-of-day + duration.
795
- */
796
- recurrenceField?: keyof TData & string;
797
- /**
798
- * Field holding an array of {@link SchedulerException} - per-occurrence
799
- * overrides of a recurring event (a moved / edited / deleted single instance).
800
- * When set, editing a recurring occurrence offers "This event" vs "All events"
801
- * and "This event" fires {@link onOccurrenceChange}.
802
- */
803
- recurrenceExceptionsField?: keyof TData & string;
804
- /** Event length in minutes when a row has a start but no `endField`. Default 60. */
805
- defaultDurationMin?: number;
806
-
807
- /** Which views to offer in the toolbar. Default all four. */
808
- views?: ReadonlyArray<SchedulerView>;
809
- /** The view shown first. Default `'month'`. */
810
- initialView?: SchedulerView;
811
- /** The date the calendar opens on. Defaults to "today". */
812
- initialDate?: Date | number | string;
813
- /**
814
- * Controlled anchor date - when this changes the calendar navigates to it (a
815
- * mini date-picker or external "go to" can drive the view). Pair with
816
- * {@link onNavigate} for two-way sync.
817
- */
818
- date?: Date | number | string;
819
- /** Fired when the visible date changes (prev / next / today). */
820
- onNavigate?: (date: Date) => void;
821
- /** First day of the week, 0-6 (0 = Sunday). Default 0. */
822
- weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
823
- /** Time-grid slot size in minutes (week / day snap granularity). Default 30. */
824
- slotMinutes?: number;
825
- /**
826
- * Slot sizes (minutes) offered as a runtime picker in the Week / Day time-grid
827
- * ruler, e.g. `[60, 30, 15, 5]`. When set, a size selector appears in the
828
- * toolbar and the ruler subdivides accordingly; the active size starts at
829
- * `slotMinutes`. Omit to hide the picker (the ruler still uses `slotMinutes`).
830
- */
831
- slotSizes?: ReadonlyArray<number>;
832
- /** First / last hour shown in the time-grid band (0-24). Default 0..24. */
833
- dayStartHour?: number;
834
- dayEndHour?: number;
835
-
836
- // --- booking rules: working hours, non-working days, conflicts -------------
837
- /**
838
- * Working-hours window (hours, e.g. `{ start: 9, end: 17 }`). Time outside it
839
- * is shaded in the Week / Day time-grid. Visual only - see `disableConflicts`
840
- * to enforce.
841
- */
842
- businessHours?: { start: number; end: number };
843
- /** Weekday numbers (0 = Sun … 6 = Sat) shaded as non-working (e.g. `[0, 6]`). */
844
- nonWorkingDays?: ReadonlyArray<number>;
845
- /** Shade elapsed time on today's column (the past is "used up"). */
846
- shadeUntilNow?: boolean;
847
- /**
848
- * Enforce the shaded time: reject a drag / resize / create that lands outside
849
- * `businessHours` or on a `nonWorkingDays` day (snap back + flash). Without
850
- * this the shading is a visual hint only.
851
- */
852
- restrictToBusinessHours?: boolean;
853
- /**
854
- * Prevent double-booking: dragging / resizing / creating an event so it
855
- * overlaps another event **on the same resource** is rejected and reverted.
856
- */
857
- disableConflicts?: boolean;
858
- /**
859
- * Hard-blocked hour bands (e.g. a daily maintenance window `[{ start: 12, end: 13 }]`).
860
- * Unlike `businessHours` these are ALWAYS non-bookable (drop / create rejected,
861
- * no opt-in needed) and rendered as a distinct restricted (hatched) band.
862
- */
863
- restrictedHours?: ReadonlyArray<{ start: number; end: number }>;
864
- /** Specific calendar dates that are fully blocked (no bookings) - e.g. closures. */
865
- restrictedDates?: ReadonlyArray<Date | number | string>;
866
- /**
867
- * Highlighted dates (holidays, launches …) - a coloured strip + optional label
868
- * on that day's column / month cell. Decorative; does not block booking.
869
- */
870
- specialDates?: ReadonlyArray<{ date: Date | number | string; label?: string; color?: string }>;
871
- /** Earliest navigable / bookable date. Prev-nav stops here and creates are blocked before it. */
872
- minDate?: Date | number | string;
873
- /** Latest navigable / bookable date. Next-nav stops here and creates are blocked after it. */
874
- maxDate?: Date | number | string;
875
- /**
876
- * Cap concurrent events per resource at any moment: a drag / resize / create
877
- * that would make more than N events overlap on the same resource is rejected.
878
- */
879
- maxEventsPerSlot?: number;
880
- /**
881
- * Enable **undo / redo** of drag-move + resize with `Ctrl/Cmd+Z` and
882
- * `Ctrl/Cmd+Shift+Z` (or `Ctrl+Y`). The scheduler re-emits the move/resize
883
- * callbacks with the reversed values, so your data follows.
884
- */
885
- history?: boolean;
886
- /**
887
- * Show the current-time indicator - a line across today's column(s) in the
888
- * Week / Day time-grid and the Day timeline, tracking the local time. On by
889
- * default; set to `false` to hide it.
890
- */
891
- nowIndicator?: boolean;
892
- /**
893
- * IANA time zone (e.g. `'America/New_York'`) the whole calendar is shown in -
894
- * the hour ruler, event positions, day boundaries, all-day grouping and the
895
- * now-line. Defaults to the browser's local zone. Event `start`/`end` must be
896
- * instant-unambiguous (UTC / offset ISO or epoch ms) for this to be correct;
897
- * bare local strings are read as wall-clock in this zone.
898
- */
899
- timeZone?: string;
900
- /**
901
- * Extra read-only hour rulers for other zones (a "world clock"), shown left of
902
- * the primary ruler in the Week / Day time-grid. Each entry's `label` heads its
903
- * column (defaults to a short zone abbreviation).
904
- */
905
- secondaryTimeZones?: ReadonlyArray<{ id: string; label?: string }>;
906
- /**
907
- * How overlapping time-grid events are laid out. `split` (default) divides the
908
- * width evenly per collision; `cap` shows up to `maxColumns` then a clickable
909
- * `+N more` tile; `stack` overlaps them with an offset instead of shrinking.
910
- */
911
- collisionMode?: SchedulerCollisionMode;
912
- /** For `collisionMode: 'cap'`: max side-by-side columns before overflow (min 2). Default 3. */
913
- maxColumns?: number;
914
- /** How many days the agenda view spans. Default 30. */
915
- agendaDays?: number;
916
-
917
- /**
918
- * Field whose value groups events by resource (people, rooms, machines). In
919
- * the Week / Day time-grid the columns split into resource x day groups; a
920
- * resource filter/legend appears in every view. See {@link SchedulerResource}.
921
- */
922
- resourceField?: keyof TData & string;
923
- /** Explicit, ordered resources (with colors). Omit to derive from the data. */
924
- resources?: ReadonlyArray<SchedulerResource>;
925
- /**
926
- * Time-grid resource grouping order. `false` (default) groups by resource then
927
- * day (resource-major); `true` groups by day then resource (date-major), like
928
- * Smart's `groupByDate`. Only affects Week / Day when `resourceField` is set.
929
- */
930
- groupByDate?: boolean;
931
-
932
- /** Timeline views only: width (px) of the left resource-label gutter. Default 160. */
933
- resourceAreaWidth?: number;
934
- /** `timelineDay` tick size + move/resize snap, in minutes. Default = `slotMinutes`. */
935
- timelineSlotMinutes?: number;
936
- /** Timeline views only: height (px) of one event lane inside a resource row. Default 26. */
937
- timelineLaneHeight?: number;
938
-
939
- /** Enable drag-to-move and edge-resize. Without it the calendar is read-only. */
940
- editable?: boolean;
941
- /** Fired when an event is dragged to a new time / resource. */
942
- onEventMove?: (event: SchedulerEventMoveEvent<TData>) => void;
943
- /** Fired when an event edge is dragged to resize it. */
944
- onEventResize?: (event: SchedulerEventResizeEvent<TData>) => void;
945
- /**
946
- * Fired to create an event - double-clicking an empty slot, or confirming a
947
- * pending range when no {@link onRangeSelect} is set. `allDay` is `true` when
948
- * the slot / range is an all-day one (the all-day row, a month day cell, or a
949
- * multi-day timeline zoom), so the handler can set the `allDayField`.
950
- */
951
- onEventAdd?: (start: Date, end: Date, resourceId?: string, allDay?: boolean) => void;
952
- /**
953
- * Fired when the event's Delete button is used. Setting this shows a Delete
954
- * button in the detail drawer (and a `Delete` item is easy to add via
955
- * `eventMenu`). Remove the row from your data in the handler.
956
- */
957
- onEventDelete?: (row: TData) => void;
958
- /**
959
- * Fired when a single occurrence of a recurring event is moved / resized /
960
- * deleted with scope "This event". Merge `event.exception` into the row's
961
- * `recurrenceExceptionsField` array (keyed by `occurrenceStart`).
962
- */
963
- onOccurrenceChange?: (event: SchedulerOccurrenceChangeEvent<TData>) => void;
964
-
965
- /**
966
- * Selecting empty cells: click or drag across the time-grid / timeline to mark
967
- * a time range (and, across days / resources, a rectangle of cells). Arrow keys
968
- * move the selection and `Shift`+arrows extend it. Marking only *marks* the
969
- * range - it does NOT create anything. The event is created on an explicit
970
- * confirm: press `Enter`, or right-click the selection and choose "Add Event".
971
- * Confirming fires {@link onRangeSelect}, or falls back to `onEventAdd` for the
972
- * first cell; `Escape` cancels the marker.
973
- *
974
- * On by default; set to `false` to disable.
975
- */
976
- rangeSelectable?: boolean;
977
- /**
978
- * Fired when a pending cell range is confirmed with `Enter` or the "Add Event"
979
- * context menu (see {@link rangeSelectable}) - not on drag release.
980
- */
981
- onRangeSelect?: (selection: SchedulerRangeSelection) => void;
982
- /**
983
- * Multi-selecting existing events: Ctrl/Cmd-click toggles, Shift-click
984
- * range-selects; a plain click clears. Selected events move together when one
985
- * is dragged, and `Delete` removes them (via `onEventDelete`).
986
- *
987
- * On by default; set to `false` to disable.
988
- */
989
- eventSelectable?: boolean;
990
- /** Fired when the set of multi-selected events changes. */
991
- onEventSelectionChange?: (rows: TData[]) => void;
992
-
993
- /**
994
- * An "unscheduled" backlog list shown beside the Week / Day grid: drag an item
995
- * onto the calendar to schedule it. Each item is `{ id, title, durationMin?,
996
- * color? }`. Dropping fires {@link onSchedule} with the drop time + resource.
997
- */
998
- unscheduled?: ReadonlyArray<{ id: string; title: string; durationMin?: number; color?: string }>;
999
- /** Optional heading for the unscheduled backlog panel. Default "Unscheduled". */
1000
- backlogTitle?: string;
1001
- /** Fired when an unscheduled item is dropped on the grid - create an event from it. */
1002
- onSchedule?: (item: { id: string; title: string; durationMin?: number; color?: string }, start: Date, resourceId?: string) => void;
1003
- /**
1004
- * Fired when an event is dragged OFF the calendar onto the backlog panel -
1005
- * remove it from the schedule (and typically push it back to `unscheduled`).
1006
- * Requires the backlog panel (an `unscheduled` list) to be visible.
1007
- */
1008
- onUnschedule?: (row: TData) => void;
1009
-
1010
- /** Custom event body. Receives the row. Omit for the built-in default (title). */
1011
- event?: Snippet<[TData]>;
1012
- /**
1013
- * Hover tooltip for an event. Set a `Snippet<[TData]>` for custom content, or
1014
- * `true` for the built-in tooltip (title + time + resource). Omit to disable.
1015
- */
1016
- tooltip?: boolean | Snippet<[TData]>;
1017
- /** Delay (ms) before the hover tooltip opens. Default 400. */
1018
- tooltipDelay?: number;
1019
- /** Built-in detail drawer: `true` for all fields, or a config object. */
1020
- drawer?: boolean | SchedulerDrawerConfig<TData>;
1021
- /** Fired when the drawer / editor is saved. */
1022
- onEventCommit?: (event: SchedulerEventCommitEvent<TData>) => void;
1023
- /** Right-click menu for an event. Return items or `undefined` to suppress. */
1024
- eventMenu?: (row: TData) => MenuItem[] | undefined;
1025
-
1026
- /** Show the search box (binds to the grid's global filter). Default `true`. */
1027
- searchable?: boolean;
1028
- searchPlaceholder?: string;
1029
- };
1030
-
1031
- export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> = {
1032
- data: ReadonlyArray<TData>;
1033
- columns: Array<ColumnDef<TFeatures, TData>>;
1034
- /**
1035
- * Kanban board mode. When set, the grid renders its rows as cards in
1036
- * horizontal lanes (bucketed by `board.groupBy`) instead of a table. See
1037
- * {@link BoardConfig}.
1038
- */
1039
- board?: BoardConfig<TFeatures, TData>;
1040
- /**
1041
- * Scheduler / calendar mode. When set, the grid renders its rows as events on
1042
- * a Month / Week / Day / Agenda calendar instead of a table. See
1043
- * {@link SchedulerConfig}.
1044
- */
1045
- scheduler?: SchedulerConfig<TFeatures, TData>;
1046
- /**
1047
- * Chart view. When set, the grid renders its FILTERED + SORTED rows as a chart
1048
- * instead of a table (search / filters / sort flow through). Unlike board and
1049
- * scheduler, the renderer is free - the grid lazy-loads a built-in `SvChart`
1050
- * view, overridable via `registerChartView`. See {@link ChartViewConfig}.
1051
- */
1052
- chart?: ChartViewConfig<TFeatures, TData>;
1053
- /**
1054
- * Pivot mode. When set (and `pivotMode` is on), the grid renders its rows as a
1055
- * pivot table in place - the same grid, aggregated across `pivot.rows` /
1056
- * `pivot.cols` with nested column headers - instead of the flat table. The
1057
- * pivot ENGINE ships in `@svgrid/enterprise`; call `enablePivot()` (or
1058
- * `installEnterprise(api)`) to register it, otherwise an upsell note shows.
1059
- * See {@link GridPivotConfig}.
1060
- */
1061
- pivot?: GridPivotConfig<TData>;
1062
- /**
1063
- * Whether pivot mode is currently active. Defaults to `true` when `pivot` is
1064
- * set. Bindable so a toolbar toggle can flip between the pivot and the flat
1065
- * table over the same data.
1066
- */
1067
- pivotMode?: boolean;
1068
- /** Fired when the in-grid Pivot toggle flips `pivotMode`. */
1069
- onPivotModeChange?: (on: boolean) => void;
1070
- /**
1071
- * Right-click context menu. `true` shows the default item set (copy, cut,
1072
- * paste, clear, insert row above/below, remove row, remove column). Pass an
1073
- * array to customize: strings are built-in keys, `"separator"` is a divider,
1074
- * and objects are custom items. Omitted/`false` disables the menu (native
1075
- * browser menu shows instead).
1076
- */
1077
- contextMenu?: boolean | ReadonlyArray<ContextMenuItem<TData>>;
1078
- /**
1079
- * Floating bar that appears over the grid while rows are selected, showing
1080
- * the count and the actions that apply to the whole selection - the pattern
1081
- * an issue tracker uses for bulk edit.
1082
- *
1083
- * `true` gives the count and a Clear button. An array is the shorthand for
1084
- * `{ actions }`. Pass {@link SelectionBarConfig} to also set `position`
1085
- * (`'bottom'` default, or `'top'`), `maxVisible` and `hideClear`. Omitted /
1086
- * `false` is off.
1087
- *
1088
- * Default **off**. This is chrome that floats over your content, not a
1089
- * gesture: it overlaps a row, and what belongs on it is specific to the app.
1090
- *
1091
- * **The prop and its types are free; the bar itself is an Enterprise
1092
- * feature.** Install `@svgrid/enterprise` and call `enableSelectionBar()`
1093
- * (or `installEnterprise`, which does it for you) to render it - without
1094
- * that the grid shows a short upsell note in its place, the same way the
1095
- * scheduler and board views do.
1096
- */
1097
- selectionBar?:
1098
- | boolean
1099
- | ReadonlyArray<SelectionBarAction<TData> | SelectionBarBuiltin>
1100
- | SelectionBarConfig<TData>;
1101
- /**
1102
- * The feature set built with `tableFeatures({ ... })`. Optional - the
1103
- * `sortable` / `filterable` / `groupable` shortcuts below inject the
1104
- * matching feature for you, so a grid can be configured entirely from
1105
- * the boolean shortcuts without importing the feature constants.
1106
- */
1107
- features?: TFeatures;
1108
- /**
1109
- * Convenience shortcuts to switch a whole capability on without wiring
1110
- * `features` or the finer-grained props by hand. Every capability is OFF
1111
- * by default - a bare grid is a plain read-only table - so set the
1112
- * shortcut `true` to opt in. (`false` / omitted both leave it off; the
1113
- * shortcut is mainly there to turn things ON.)
1114
- *
1115
- * `sortable` - column sorting (injects `rowSortingFeature`)
1116
- * `filterable` - column filtering (injects `columnFilteringFeature`)
1117
- * `editable` - inline cell editing (alias of `enableInlineEditing`)
1118
- * `selectable` - cell selection (alias of `enableCellSelection`)
1119
- * `groupable` - row grouping controls(alias of `showGroupingControls`,
1120
- * also injects `columnGroupingFeature`)
1121
- * `pageable` - pagination footer (alias of `showPagination`)
1122
- *
1123
- * Fine-grained props (`enableInlineEditing`, `showPagination`, ...) still
1124
- * work; the shortcut wins only when it is explicitly set.
1125
- */
1126
- sortable?: boolean;
1127
- /**
1128
- * Click a header to filter that column. Injects `columnFilteringFeature`,
1129
- * so you do not import it yourself. Which filter surface appears is a
1130
- * separate question - see `filterMode` (default `'menu'`).
1131
- *
1132
- * <SvGrid {data} {columns} filterable />
1133
- */
1134
- filterable?: boolean;
1135
- /**
1136
- * Inline cell editing. Alias of `enableInlineEditing`, and wins over it when
1137
- * both are set. A column also needs an `editorType` to be editable; without
1138
- * one it falls back to a text editor.
1139
- *
1140
- * <SvGrid {data} {columns} editable />
1141
- */
1142
- editable?: boolean;
1143
- /**
1144
- * Cell selection - click a cell to select it, drag or shift-click to extend
1145
- * the selection to a range. Alias of `enableCellSelection`, and the highest
1146
- * priority of the three inputs that decide it:
1147
- * `selectable` -> `enableCellSelection` -> `selectionMode`.
1148
- *
1149
- * NOTE the asymmetry with its siblings, which are all off until you opt in:
1150
- * this one is **ON by default**, because `selectionMode` defaults to
1151
- * `'both'`. It is named here so the capability is discoverable next to the
1152
- * other shortcuts, and so `selectable={false}` is a one-word way to turn
1153
- * cell selection off (the longhand being `selectionMode="none"`, which also
1154
- * removes the row-selection surface).
1155
- *
1156
- * This is the CELL surface only. The selection **checkbox column** is the
1157
- * other half of `selectionMode`, controlled by `showRowSelection` - also on
1158
- * by default, and it needs no feature import (verified: the column renders
1159
- * and toggles rows with an empty `features` set). Use `selectionMode` when
1160
- * you want to move both surfaces at once.
1161
- */
1162
- selectable?: boolean;
1163
- /**
1164
- * Client-side tree data: nest rows into a hierarchy by parent id.
1165
- *
1166
- * ```svelte
1167
- * <SvGrid {data} {columns} treeData={{ parentField: 'managerId', column: 'name' }} />
1168
- * ```
1169
- *
1170
- * Unlike grouping, tree rows are real data rows - they keep their cells,
1171
- * editing and selection, and only gain an expander plus indentation in
1172
- * `column`. Rows whose parent is missing become roots rather than vanishing.
1173
- *
1174
- * For NESTED source data (`children: [...]`), flatten it first with
1175
- * `flattenTreeData(data, { childrenField: 'children' })` and point
1176
- * `parentField` at the `__parentId` it stamps on.
1177
- *
1178
- * Setting this replaces row grouping - a row cannot be both.
1179
- */
1180
- treeData?: {
1181
- /** Field holding each row's parent id. */
1182
- parentField: string;
1183
- /** Field holding the row's own id. Defaults to `'id'`. */
1184
- idField?: string;
1185
- /**
1186
- * Column id that carries the expander + indentation. Defaults to the first
1187
- * visible column.
1188
- */
1189
- column?: string;
1190
- /** Indent per depth level, in px. Default `12`. */
1191
- indentPx?: number;
1192
- };
1193
- /**
1194
- * Show the grouping controls: "Group by this column" in the column menu, and
1195
- * the group panel when `showGroupPanel` is on. Alias of
1196
- * `showGroupingControls`, and also injects `columnGroupingFeature`.
1197
- *
1198
- * This turns on the UI for grouping. To group without asking the user, set
1199
- * `groupBy` instead.
1200
- *
1201
- * <SvGrid {data} {columns} groupable />
1202
- */
1203
- groupable?: boolean;
1204
- /**
1205
- * Group the rows by these column ids, outermost first - `['region',
1206
- * 'country']` rolls country up inside region.
1207
- *
1208
- * ```svelte
1209
- * <SvGrid {data} {columns} {features} groupBy={['department']} />
1210
- * ```
1211
- *
1212
- * The prop seeds the group-by list and re-applies whenever it changes, so it
1213
- * works both as initial state and as a controlled value. The column menu and
1214
- * `api.setGroupBy()` write the same state; a change from either survives
1215
- * until this prop's own value changes.
1216
- *
1217
- * Ignored when `treeData` is set - a row cannot be both a hierarchy node and
1218
- * bucketed under a group banner.
1219
- */
1220
- groupBy?: ReadonlyArray<string>;
1221
- /**
1222
- * Which group / tree rows are expanded, keyed by row id.
1223
- *
1224
- * Expansion is owned by the engine by default; pass this prop to hoist it
1225
- * (saved views, "expand everything on load", persisted UI state). Like
1226
- * `groupBy` it seeds the state and re-applies whenever it changes.
1227
- *
1228
- * Group row ids are built from the grouping path, not the display label:
1229
- * `group_department_Engineering`, and one level deeper
1230
- * `group_department_Engineering_role_Senior`. Tree rows key off the engine's
1231
- * row id instead (set `getRowId` to make that your own id). Prefer capturing
1232
- * the map from `onExpandedChange` over hand-building these keys.
1233
- */
1234
- expanded?: Record<string, boolean>;
1235
- /**
1236
- * Fired whenever the expanded set changes - chevron clicks,
1237
- * `api.setRowExpanded()`, `expandAllGroups()` / `collapseAllGroups()`.
1238
- * Receives the full next map, so it can be written straight back into
1239
- * `expanded` for a controlled setup.
1240
- */
1241
- onExpandedChange?: (expanded: Record<string, boolean>) => void;
1242
- /**
1243
- * Render a subtotal row after each group's children, carrying that group's
1244
- * aggregate values under the columns they belong to (the columns with an
1245
- * `aggregate` set). Off by default.
1246
- *
1247
- * Footers are inserted after paging, so they never count against `pageSize` -
1248
- * a page shows its `pageSize` data rows plus whatever footers close on it.
1249
- */
1250
- groupFooters?: boolean;
1251
- /**
1252
- * Append a grand-total row at the very end, aggregating the whole filtered
1253
- * set (not just the current page) with each column's `aggregate` function.
1254
- *
1255
- * Independent of `groupFooters`: use it on a flat grid for a bottom totals
1256
- * line, or alongside group subtotals for both. Like group footers it is
1257
- * appended after paging, so it never counts against `pageSize` - but it is
1258
- * only appended on the LAST page, so a total never appears mid-dataset.
1259
- * Columns without an `aggregate` are left blank.
1260
- */
1261
- grandTotalRow?: boolean;
1262
- /**
1263
- * How grouped rows are displayed.
1264
- *
1265
- * - `groupRows` (default): a full-width banner row per group. Unchanged
1266
- * behaviour - existing grids are untouched.
1267
- * - `singleColumn`: one synthetic "Group" column holding every level,
1268
- * indented by depth.
1269
- * - `multipleColumns`: one synthetic column per grouped field.
1270
- *
1271
- * Both column modes hide the grouped source columns, since their values move
1272
- * into the auto column(s), and render group rows as ordinary rows so their
1273
- * aggregate cells line up under the real columns.
1274
- */
1275
- groupDisplayMode?: GroupDisplayType;
1276
- /** Header for the combined `singleColumn` auto-group column. Default `"Group"`. */
1277
- autoGroupColumnHeader?: string;
1278
- /** Width (px) of each auto-group column. Default `220`. */
1279
- autoGroupColumnWidth?: number;
1280
- /**
1281
- * Show the pagination footer. Alias of `showPagination`, and wins over it
1282
- * when both are set. Page size starts at `pageSize` (default 10).
1283
- *
1284
- * <SvGrid {data} {columns} pageable pageSize={25} />
1285
- */
1286
- pageable?: boolean;
1287
- /**
1288
- * Show the loading state instead of the rows. By default this replaces the
1289
- * grid body with "Loading..."; set `loadingOverlay` to keep the current rows
1290
- * visible under a dimmed overlay instead, which is what you usually want for
1291
- * a server-paged grid.
1292
- */
1293
- loading?: boolean;
1294
- /**
1295
- * Render `loading` as a non-blocking overlay instead of replacing the
1296
- * whole grid: the current rows stay visible (dimmed, with a top progress
1297
- * bar) during a refetch, and the first load shows shimmer skeleton rows.
1298
- * Ideal for server-paged grids so paging/sorting doesn't flash. Defaults
1299
- * to `false` (the classic full "Loading..." replacement).
1300
- */
1301
- loadingOverlay?: boolean;
1302
- /** Skeleton placeholder rows to show on first load. Defaults to 8. */
1303
- loadingSkeletonRows?: number;
1304
- /**
1305
- * Render an error message in place of the rows. `null` or omitted means no
1306
- * error. Takes precedence over `loading` and over the empty state.
1307
- */
1308
- error?: string | null;
1309
- /**
1310
- * Text shown when there are no rows to display - either the data is empty or
1311
- * a filter matched nothing. Defaults to the localized `noRows` string, so
1312
- * prefer `localization.text.noRows` when you are translating the whole grid.
1313
- */
1314
- emptyMessage?: string;
1315
- /**
1316
- * The single place to localize the grid. One object with two fields:
1317
- *
1318
- * - `locale` - BCP-47 tag(s) for the DATA: accent/case-insensitive filter
1319
- * matching AND every column's number / currency / percent / date formatting
1320
- * (when the column's own `format.locales` is unset). The default for
1321
- * `filterLocale` and per-column format locales.
1322
- * - `text` - overrides for the grid's own UI STRINGS (empty state, tool panel,
1323
- * pager, status bar, filter operator labels, context-menu items, upsell
1324
- * notes). Any subset overrides the English defaults; unset keys stay English.
1325
- *
1326
- * ```svelte
1327
- * <SvGrid localization={{ locale: 'fr-FR', text: { noRows: 'Aucune ligne' } }} />
1328
- * ```
1329
- *
1330
- * Omitting it (or any field) is a no-op. See {@link GridMessages}.
1331
- */
1332
- localization?: GridLocalization;
1333
- /**
1334
- * Show the single search box that filters across every column. Explicitly
1335
- * setting this wins over `filterMode`; leaving it unset means it appears only
1336
- * when `filterMode` is `'global'`.
1337
- */
1338
- showGlobalFilter?: boolean;
1339
- /**
1340
- * Show the filter section inside each column's menu. Explicitly setting this
1341
- * wins over `filterMode`; unset, it follows `filterMode` (default `'menu'`,
1342
- * so this is normally on).
1343
- *
1344
- * Setting it `true` also adds the inline "floating filter" input under each
1345
- * header - that surface requires the explicit opt-in, since it otherwise
1346
- * duplicates the menu's own filter popover.
1347
- */
1348
- showColumnFilters?: boolean;
1349
- /**
1350
- * Quick way to pick a single filtering UI. When set it controls which of
1351
- * the three filter surfaces appears (and is overridden per-surface by the
1352
- * `showGlobalFilter` / `showColumnFilters` / `showFilterRow` props).
1353
- * Defaults to `'menu'` (only the column menu's filter section is shown).
1354
- */
1355
- filterMode?: "row" | "menu" | "global" | "none";
1356
- /**
1357
- * Show the grouping affordances (the column menu's "Group by this column",
1358
- * and the group panel). The `groupable` shortcut sets this and registers the
1359
- * grouping feature in one go; prefer that unless you have already registered
1360
- * `columnGroupingFeature` yourself.
1361
- */
1362
- showGroupingControls?: boolean;
1363
- /**
1364
- * Show the row-selection checkbox column, including the select-all checkbox
1365
- * in the header. Unset, it follows `selectionMode` (default `'both'`, so
1366
- * row selection is on).
1367
- */
1368
- showRowSelection?: boolean;
1369
- /**
1370
- * Show the pagination footer. Off by default. `pageable` is the shortcut
1371
- * alias and wins when both are set.
1372
- */
1373
- showPagination?: boolean;
1374
- /** Initial page size when pagination is enabled. Defaults to 10. */
1375
- pageSize?: number;
1376
- /** Page-size choices shown in the footer's selector. Defaults to `[10, 25, 50, 100]`. */
1377
- pageSizeOptions?: number[];
1378
- /**
1379
- * Where the pagination footer sits: `'bottom'` (default), `'top'`, or `'both'`.
1380
- * The status bar (when enabled) always stays at the bottom.
1381
- */
1382
- paginationPosition?: 'top' | 'bottom' | 'both';
1383
- /**
1384
- * Server-side pagination. When `true`, the grid renders its native
1385
- * pagination footer from the `rowCount` / `pageIndex` you provide (rather
1386
- * than counting the local rows), does NOT slice `data` (the rows you pass are
1387
- * treated as the current page), and emits `onPaginationChange` when the user
1388
- * pages or changes page size. Pair with `externalSort` / `externalFilter`
1389
- * and a server data source. Requires `showPagination` / `pageable` to show
1390
- * the footer. Controlled: you own `pageIndex` + `pageSize` + `rowCount`.
1391
- */
1392
- externalPagination?: boolean;
1393
- /** Total rows on the server, for the footer's range + page count. Used with `externalPagination`. */
1394
- rowCount?: number;
1395
- /** Current 0-based page index. Used with `externalPagination` (controlled). */
1396
- pageIndex?: number;
1397
- /**
1398
- * Fires when the user changes page or page size while `externalPagination`
1399
- * is on. Fetch that page and update `data` / `rowCount` / `pageIndex`.
1400
- */
1401
- onPaginationChange?: (pagination: { pageIndex: number; pageSize: number }) => void;
1402
- /**
1403
- * Render only the rows in view instead of all of them. **On by default** -
1404
- * this is what keeps a 100,000-row grid responsive.
1405
- *
1406
- * Turn it off when a row's height cannot be known up front and must not be
1407
- * clipped, such as a variable-height master-detail panel. Expect the DOM to
1408
- * hold every row when you do.
1409
- */
1410
- virtualization?: boolean;
1411
- /** Row height in pixels. Pass a function `(rowIndex) => px` for
1412
- * per-row variable heights (e.g. an interactive row-resize feature).
1413
- * Defaults to 30. */
1414
- rowHeight?: number | ((rowIndex: number) => number);
1415
- /**
1416
- * Size each row to its own content instead of a fixed height: cell text wraps
1417
- * and the row grows to fit the tallest cell. Rows are measured after they
1418
- * render, so this works with virtualization - `rowHeight` (or 30) is the
1419
- * estimate used before a row has been measured, which keeps the scrollbar
1420
- * stable while you scroll into new rows.
1421
- *
1422
- * Costs a measurement pass per row, so prefer a fixed `rowHeight` when your
1423
- * content is uniform. Ignored when `rowHeight` is a function (you are already
1424
- * supplying per-row heights).
1425
- */
1426
- autoRowHeight?: boolean;
1427
- /**
1428
- * Let the user drag a row's bottom edge to change its height. **Off by
1429
- * default**, because a resizable row needs somewhere to grab and most grids
1430
- * do not want a drag target on every row.
1431
- *
1432
- * The grid remembers the heights itself, so this works as a bare boolean -
1433
- * no `rowHeight` function required. Drag, or focus the grip and use Up/Down
1434
- * (Shift for 1px steps).
1435
- *
1436
- * Turning this on also turns on the **row header column** ({@link
1437
- * showRowNumbers}), because that is where the grip lives and where a
1438
- * spreadsheet puts it - a drag target on the edge of a data cell works but
1439
- * reads as an accident. An explicit `showRowNumbers={false}` still wins; the
1440
- * grip then falls back to the row's first cell, and a column of your own
1441
- * carrying `cellClass: 'sv-row-gutter'` is used ahead of either.
1442
- *
1443
- * Ignored under `autoRowHeight`, where the content decides the height and a
1444
- * manual one would immediately be overwritten. For full control of the
1445
- * heights - persisting them, sharing them between grids - pass a
1446
- * function-valued {@link rowHeight} and use the `rowResize` action directly.
1447
- */
1448
- rowResize?: boolean;
1449
- /**
1450
- * Height (px) of a single column-header level row. With multi-level
1451
- * (grouped) headers the total header height is `levels * headerHeight`,
1452
- * since each level renders as its own row. When omitted, header rows size
1453
- * to their content (the default). Does not affect the filter row.
1454
- */
1455
- headerHeight?: number;
1456
- /**
1457
- * Extra rows rendered above and below the viewport, so fast scrolling does
1458
- * not reach empty space before the next batch renders. Defaults to 8.
1459
- * Raise it for very tall rows, lower it to trim DOM work.
1460
- */
1461
- overscan?: number;
1462
- /**
1463
- * Height of the grid's scrollable shell. A number is treated as pixels;
1464
- * a string is used as-is, so callers can pass `'100%'` or `'auto'` to
1465
- * make the grid fill its parent. Defaults to 520 px.
1466
- */
1467
- containerHeight?: number | string;
1468
- /**
1469
- * Render only the columns in view, the horizontal counterpart of
1470
- * `virtualization`. **On by default**, which is what makes a 100-column grid
1471
- * scroll smoothly.
1472
- *
1473
- * It recycles column DOM nodes, so it cannot coexist with sticky pinned
1474
- * columns - turn it off if you need pinning to survive horizontal scrolling.
1475
- */
1476
- columnVirtualization?: boolean;
1477
- /**
1478
- * Extra columns rendered either side of the viewport when
1479
- * `columnVirtualization` is on. Defaults to 3.
1480
- */
1481
- columnOverscan?: number;
1482
- /**
1483
- * Fallback width in pixels for columns whose `ColumnDef` sets no `width`.
1484
- * Defaults to 140.
1485
- */
1486
- columnWidth?: number;
1487
- /**
1488
- * Columns pinned to the left/right edge on mount. Each entry is a
1489
- * column id (matches `ColumnDef.field` when no explicit id is set).
1490
- * The internal pinning state is seeded once at mount; user-driven
1491
- * pinning via the column menu still works and overrides this default.
1492
- * Requires `columnVirtualization={false}` to be visible in the menu
1493
- * UI (sticky positioning can't co-exist with column virtualization
1494
- * since the virtualizer recycles DOM nodes).
1495
- */
1496
- initialColumnPinning?: {
1497
- left?: ReadonlyArray<string>;
1498
- right?: ReadonlyArray<string>;
1499
- };
1500
- /**
1501
- * When `true`, columns are scaled proportionally so their total width
1502
- * fills the viewport (no empty space on the right). Disabled by
1503
- * default - explicit `width` values are used as-is. User resizes still
1504
- * win once they happen.
1505
- */
1506
- fitColumns?: boolean;
1507
- /**
1508
- * Let the user drag a column's edge to change its width. **Off by default**,
1509
- * so `width` means the width you asked for until you say otherwise.
1510
- *
1511
- * Turn it on for grids the reader is meant to arrange - a spreadsheet, a
1512
- * dense report, anything with columns whose content varies in length. Leave
1513
- * it off for layouts you control, and for columns that must keep their size:
1514
- * a row-number gutter, a checkbox column, an icon column.
1515
- *
1516
- * It is grid-wide rather than per-column: there is no `resizable: false` on a
1517
- * single column definition. `api.autosizeColumn()`, `fitColumns` and
1518
- * programmatic width changes work either way - this only governs the drag
1519
- * handle.
1520
- *
1521
- * The handles come from the `columnResize` action, loaded on demand: a grid
1522
- * that leaves this off never fetches that code.
1523
- */
1524
- columnResize?: boolean;
1525
- /**
1526
- * Make the grid usable on narrow screens. When the grid's own width drops
1527
- * below the breakpoint (default `640`px), pinned columns are un-pinned so the
1528
- * whole grid pans, `fitColumns` scaling is suspended (columns keep their
1529
- * natural widths and scroll), touch panning is smoothed, and columns whose
1530
- * `hideBelow` exceeds the width are hidden. `true` uses the default
1531
- * breakpoint; pass `{ breakpoint }` to change it. Off by default.
1532
- */
1533
- responsive?: boolean | { breakpoint?: number };
1534
- /**
1535
- * @deprecated Has no effect - nothing in the grid reads this prop. It is kept
1536
- * only so existing code keeps compiling. The column menu's filter section is
1537
- * controlled by `showColumnFilters`, or by `filterMode="menu"` (the default).
1538
- */
1539
- showFilterMenu?: boolean;
1540
- /**
1541
- * Show the always-visible filter row under the header. Explicitly setting
1542
- * this wins over `filterMode`; unset, it appears only when `filterMode` is
1543
- * `'row'`.
1544
- */
1545
- showFilterRow?: boolean;
1546
- /**
1547
- * Cell selection - click to select, drag or shift-click to extend to a range,
1548
- * which is what clipboard copy and the range fill handle operate on. Unset,
1549
- * it follows `selectionMode` (default `'both'`, so this is on). `selectable`
1550
- * is the shortcut alias and wins over it.
1551
- */
1552
- enableCellSelection?: boolean;
1553
- /**
1554
- * Excel-style drag-and-drop of a selected cell range: grab the range's
1555
- * border and drag it somewhere else to MOVE the values there, or hold
1556
- * Ctrl (Cmd on macOS) to COPY them instead. The modifier is read at drop
1557
- * time, so it can be pressed or released mid-drag.
1558
- *
1559
- * On by default whenever cell selection is on, matching the fill handle.
1560
- * Set `false` to keep a border pointerdown starting a fresh selection, which
1561
- * is what it did before this existed.
1562
- *
1563
- * The grab strip is the outer 4px of the range border, so a pointerdown
1564
- * anywhere further inside still starts a new selection. A drop is refused
1565
- * outright - nothing changes - when the destination would fall outside the
1566
- * grid, or when any source or destination cell is read-only. It does not
1567
- * move the part that fits and silently drop the rest.
1568
- */
1569
- moveCells?: boolean;
1570
- /**
1571
- * Highlight the row under the pointer. Default **false** - the hover tint can
1572
- * compete with the cell selection / fill marquee. Set `true` to opt in; when
1573
- * on, the hover no longer paints over selected cells so the selection stays
1574
- * visible.
1575
- */
1576
- enableRowHover?: boolean;
1577
- /**
1578
- * Prepend a header row (the column labels) to copied cell ranges, so pasting
1579
- * into Excel / Sheets includes the headers. Applies per copied range.
1580
- */
1581
- copyHeadersToClipboard?: boolean;
1582
- /**
1583
- * Transform each cell value on its way to the clipboard - e.g. strip
1584
- * currency symbols, expand codes to labels, or redact. Receives the display
1585
- * value plus the row/column context; return the string (or value) to copy.
1586
- */
1587
- processCellForClipboard?: (params: {
1588
- value: unknown;
1589
- column: unknown;
1590
- row: TData;
1591
- rowIndex: number;
1592
- columnId: string;
1593
- }) => unknown;
1594
- /**
1595
- * Inline cell editing: F2 or double-click opens an editor in the active cell,
1596
- * Enter commits, Esc cancels. Off by default.
1597
- *
1598
- * A column still needs an `editorType` to pick its editor (text, number,
1599
- * date, checkbox, list, ...); without one it gets a plain text editor.
1600
- * `editable` is the shortcut alias and wins over this.
1601
- */
1602
- enableInlineEditing?: boolean;
1603
- /**
1604
- * Full-row editing. When `true`, starting an edit puts the WHOLE row into
1605
- * edit mode - every editable cell shows an inline editor at once - and a
1606
- * single Enter (or focus leaving the row) commits all of them; Esc cancels
1607
- * the whole row. Requires `enableInlineEditing`. The full-row editor covers
1608
- * text / number / date / datetime / checkbox / list-select editor types.
1609
- */
1610
- fullRowEditing?: boolean;
1611
- /**
1612
- * Append a sticky footer row aggregating every filtered row: the sum of a
1613
- * numeric column, `Count: N` otherwise. Choose a different aggregate per
1614
- * column with that column's own `summary` option, or set it to `false` there
1615
- * to leave the cell blank.
1616
- *
1617
- * Off by default. `summary` is the shortcut alias and wins when both are set.
1618
- *
1619
- * <SvGrid {data} {columns} summary />
1620
- */
1621
- enableRowSummaries?: boolean;
1622
- /**
1623
- * Shortcut alias for {@link enableRowSummaries}. Wins over it when both are
1624
- * set, the same precedence `selectable` has over `enableCellSelection`.
1625
- */
1626
- summary?: boolean;
1627
- /**
1628
- * Excel-style status bar under the grid showing live aggregates of the
1629
- * selected cell range (count, numeric count, sum, average, min, max).
1630
- * `true` shows the default set; pass `{ aggregates: [...] }` to choose
1631
- * which. Requires `enableCellSelection`.
1632
- */
1633
- statusBar?:
1634
- | boolean
1635
- | {
1636
- aggregates?: ReadonlyArray<
1637
- "count" | "numericCount" | "sum" | "avg" | "min" | "max"
1638
- >;
1639
- };
1640
- /**
1641
- * Show the docked tool panel - the enterprise sidebar with Columns and
1642
- * Filters tabs. A "Columns & Filters" button appears in a toolbar above the
1643
- * grid; the panel docks on the right edge.
1644
- */
1645
- toolPanel?: boolean;
1646
- /**
1647
- * Integrated charting: `true` for the zero-config docked chart panel, or a
1648
- * {@link ChartingConfig} object to author defaults + advanced options.
1649
- */
1650
- charting?: boolean | ChartingConfig<TData>;
1651
- /**
1652
- * Render the header column menu (⋮) as a tabbed popover - **General**,
1653
- * **Filter**, and **Columns** tabs (the tabbed layout). Defaults to `false`,
1654
- * which keeps the flat menu (actions list + "Choose columns" submenu).
1655
- */
1656
- columnMenuTabs?: boolean;
1657
- /** Open the tool panel on first render (instead of collapsed). */
1658
- toolPanelDefaultOpen?: boolean;
1659
- /** Which tab the tool panel starts on. Defaults to `'columns'`. */
1660
- toolPanelDefaultTab?: "columns" | "filters";
1661
- /**
1662
- * Quick way to pick which selection surfaces are active. `'row'` shows the
1663
- * selection checkbox column only, `'cell'` allows rectangle/range cell
1664
- * selection only, `'both'` (default) enables both, `'none'` disables both.
1665
- * Overridden per-surface by `showRowSelection` / `enableCellSelection`.
1666
- */
1667
- selectionMode?: "row" | "cell" | "both" | "none";
1668
- /**
1669
- * Render a leading row-number column (1-based) before any selection
1670
- * column. Useful as a permanent anchor when scrolling wide grids.
1671
- */
1672
- showRowNumbers?: boolean;
1673
- /**
1674
- * Paint alternating data rows with the `--sg-row-alt-bg` color (zebra
1675
- * striping). Only data rows stripe - pinned, group, detail, and summary
1676
- * rows keep their single background. Defaults to `false`.
1677
- */
1678
- zebraRows?: boolean;
1679
- /**
1680
- * Width (px) of the row-number column. Defaults to 56, which fits up
1681
- * to "99,999"; bump this when the dataset crosses six digits so the
1682
- * largest row number stays fully visible at the bottom of a scroll.
1683
- */
1684
- rowNumberWidth?: number;
1685
- /** Receives the imperative grid API once the component has mounted. */
1686
- onApiReady?: (api: SvGridApi<TFeatures, TData>) => void;
1687
- /**
1688
- * Fires whenever the row-selection state changes. The first argument
1689
- * is the new selection record `{ [rowId]: true }`; the second is the
1690
- * array of selected `TData` rows.
1691
- */
1692
- onRowSelectionChange?: (
1693
- selection: Record<string, boolean>,
1694
- rows: TData[],
1695
- ) => void;
1696
- /**
1697
- * Fires whenever the cell-selection rectangle changes (mouse, keyboard,
1698
- * or `api.selectCells()`). `ranges` matches `api.getSelected()` -
1699
- * `[rowStart, colStart, rowEnd, colEnd]` rectangles in grid coords.
1700
- * Empty array when the user clears the selection.
1701
- */
1702
- onCellSelectionChange?: (
1703
- ranges: Array<[number, number, number, number]>,
1704
- ) => void;
1705
- /**
1706
- * When `true`, the grid records sort state (and renders sort indicators
1707
- * + cycling on headers) but does NOT actually re-order the rows. The
1708
- * consumer is expected to sort `data` themselves - typically via
1709
- * `onSortingChange`. Use this for tree/hierarchical data, where a flat
1710
- * global sort would break parent-child adjacency. Defaults to `false`.
1711
- */
1712
- externalSort?: boolean;
1713
- /**
1714
- * Fires whenever the sort clauses change. Receives the new array of
1715
- * `{ id, desc }` entries. Pair with `externalSort={true}` when the
1716
- * consumer wants to own the row ordering.
1717
- */
1718
- onSortingChange?: (sorting: Array<{ id: string; desc: boolean }>) => void;
1719
- /**
1720
- * The sort state to start in - `{ id, desc }` entries. Use with `externalSort`
1721
- * when the initial ordering is decided server-side (e.g. a URL `?sort=` param
1722
- * read in a SvelteKit `load`), so the header sort indicators match the already-
1723
- * sorted data on first render. Applied once at mount; user sorting takes over.
1724
- */
1725
- initialSorting?: Array<{ id: string; desc: boolean }>;
1726
- /**
1727
- * The advanced-filter expression to start in (Pro). Applied once at mount;
1728
- * change it afterwards through `api.setAdvancedFilter()`.
1729
- *
1730
- * Filtering only happens once `@svgrid/enterprise`'s `enableAdvancedFilter()`
1731
- * has registered a compiler - without it the expression is stored and
1732
- * reported but no rows are removed, so the free grid degrades to a no-op
1733
- * rather than to a wrong row set.
1734
- */
1735
- initialAdvancedFilter?: GridPredicateExpr | null;
1736
- /**
1737
- * Fires whenever the advanced-filter expression changes, whatever changed it:
1738
- * `api.setAdvancedFilter()`, `clearAllFilters()`, or the toolbar's clear
1739
- * control.
1740
- *
1741
- * The panel that authors the expression is mounted by you, outside the grid,
1742
- * so it cannot see a change the grid made on its own. Without this, clearing
1743
- * from the toolbar leaves that panel showing a filter the grid is no longer
1744
- * applying. Feed this back into the panel's `expression` prop to keep them
1745
- * agreeing.
1746
- */
1747
- onAdvancedFilterChange?: (expr: GridPredicateExpr | null) => void;
1748
- /**
1749
- * When `true`, the grid still records column-filter / global-filter /
1750
- * facet state (so the menu UI works and indicators light up) but does
1751
- * NOT actually filter the rows. The consumer is expected to fetch / sort
1752
- * / filter the data themselves - typically via `onFiltersChange`. Used
1753
- * by server-side data sources. Defaults to `false`.
1754
- */
1755
- externalFilter?: boolean;
1756
- /**
1757
- * Fires whenever any of the in-grid filter state changes - global
1758
- * search, per-column operator filters, or facet (value-checklist)
1759
- * filters. Pair with `externalFilter={true}` when the consumer wants to
1760
- * push the query to the server.
1761
- */
1762
- onFiltersChange?: (filters: {
1763
- global: string;
1764
- columns: Array<{
1765
- id: string;
1766
- operator: FilterOperator;
1767
- value: string;
1768
- /**
1769
- * Upper bound for the `between` operator. Only set when
1770
- * `operator === 'between'` AND the user has typed both values.
1771
- */
1772
- valueTo?: string;
1773
- selectedValues?: Array<string>;
1774
- }>;
1775
- }) => void;
1776
- /**
1777
- * Fires when an inline edit is committed (Enter / Tab / blur). Useful
1778
- * for cascade-recompute pipelines: a parent listens, then refreshes
1779
- * derived columns or aggregates. The wrapper has already written the
1780
- * parsed value back into the row by the time this fires.
1781
- */
1782
- /**
1783
- * Resolve a stable id per row. Drives selection, expansion, edit,
1784
- * and active-cell state. When omitted, the row's array index is
1785
- * used - fine for read-only views but the wrong choice if `data`
1786
- * gets reordered or filtered outside the grid (selection would
1787
- * follow positions, not actual rows). Use a database PK, a UUID,
1788
- * or any stable string.
1789
- */
1790
- getRowId?: (row: TData, index: number) => string;
1791
- /**
1792
- * Conditional class(es) added to every `<tr>` body row. Receives
1793
- * the row's `original` data + its data-array index. Return a
1794
- * string, an array of strings, or an object mapping class names to
1795
- * booleans. Useful for "highlight overdue rows", "tint cancelled
1796
- * orders", and similar row-level state mappings.
1797
- */
1798
- rowClass?: (ctx: {
1799
- row: TData;
1800
- rowIndex: number;
1801
- }) => string | ReadonlyArray<string> | Record<string, boolean> | undefined | null;
1802
- /**
1803
- * Per-cell notes - longer free-form comments shown as a corner
1804
- * indicator + tooltip on hover. Keyed by row id then column id;
1805
- * empty / missing entries mean "no note". The grid owns rendering;
1806
- * you own storage (write your own callbacks to add / edit notes).
1807
- */
1808
- notes?: Record<string, Record<string, string>>;
1809
- /**
1810
- * Allow editing per-cell notes/comments through the UI: the context menu
1811
- * gains an "Edit comment" item that opens a popover editor. Edits are
1812
- * applied to an internal overlay for immediate feedback and emitted via
1813
- * `onNoteChange` so you can persist them back into `notes`.
1814
- */
1815
- editableComments?: boolean;
1816
- /** Fires when a comment is saved or removed (removed = empty `note`). */
1817
- onNoteChange?: (event: { rowId: string; columnId: string; note: string }) => void;
1818
- /**
1819
- * Excel-style conditional formatting. A list of value-driven rules that
1820
- * color cells: `colorScale` (gradient across the column range),
1821
- * `dataBar` (in-cell proportional bar), `iconSet` (arrows / traffic /
1822
- * triangles by threshold), and `rule` (apply a style when a predicate
1823
- * matches). Scope a format to specific columns with `columns: [...]`,
1824
- * or omit it to apply to every column. Later entries win on conflict.
1825
- */
1826
- conditionalFormats?: ReadonlyArray<ConditionalFormat<TData>>;
1827
- /**
1828
- * Which rows feed the min/max range that `colorScale` / `dataBar` formats
1829
- * scale against.
1830
- *
1831
- * - `filtered` (default): every row that survives the filters, ignoring the
1832
- * page slice. The scale follows what you filtered to but does not shift
1833
- * when you page, so the same value keeps the same colour on page 1 and
1834
- * page 2.
1835
- * - `visible`: only the rows currently on screen. Rescales per page - use it
1836
- * when you want each page's heat map normalized to that page.
1837
- * - `all`: the full unfiltered dataset, for a scale that stays put as you
1838
- * filter.
1839
- */
1840
- conditionalStatScope?: "filtered" | "visible" | "all";
1841
- /**
1842
- * Fires after an inline edit commits, with the cell's old and new value and
1843
- * the row it belongs to. This is where you persist the change.
1844
- *
1845
- * The grid has already applied the edit to its own state by the time this
1846
- * runs, so it is a notification, not a veto - reject a value with the
1847
- * column's `valueParser` or a validation rule instead.
1848
- */
1849
- onCellValueChange?: (event: {
1850
- rowIndex: number;
1851
- columnId: string;
1852
- oldValue: unknown;
1853
- newValue: unknown;
1854
- row: TData;
1855
- }) => void;
1856
- /**
1857
- * Fires whenever the active cell changes - click, keyboard move,
1858
- * tab, page-up/down, etc. Consumers (toolbars, ribbon UIs) use this
1859
- * to stay synced with the grid's selection without polling the DOM.
1860
- */
1861
- onActiveCellChange?: (cell: {
1862
- rowIndex: number;
1863
- colIndex: number;
1864
- columnId: string;
1865
- }) => void;
1866
- /**
1867
- * Fires when a data cell (and therefore a row) is single-clicked.
1868
- * Group-header rows are excluded. `value` is the displayed cell value.
1869
- */
1870
- onCellClick?: (event: {
1871
- rowIndex: number;
1872
- colIndex: number;
1873
- columnId: string;
1874
- value: unknown;
1875
- row: TData;
1876
- }) => void;
1877
- /** Fires when a data row is single-clicked (any cell). Group rows excluded. */
1878
- onRowClick?: (event: {
1879
- rowIndex: number;
1880
- columnId: string;
1881
- row: TData;
1882
- }) => void;
1883
- /**
1884
- * Fires when a data cell is double-clicked - independent of whether the
1885
- * cell is editable, so it fires even on read-only grids. Group rows excluded.
1886
- */
1887
- onCellDoubleClick?: (event: {
1888
- rowIndex: number;
1889
- colIndex: number;
1890
- columnId: string;
1891
- value: unknown;
1892
- row: TData;
1893
- }) => void;
1894
- /** Fires when a data row is double-clicked (any cell). Group rows excluded. */
1895
- onRowDoubleClick?: (event: {
1896
- rowIndex: number;
1897
- columnId: string;
1898
- row: TData;
1899
- }) => void;
1900
- /**
1901
- * Fires once each time the body is scrolled to (within ~32px of) the
1902
- * bottom. Re-arms after the user scrolls back up. The canonical hook for
1903
- * infinite / lazy loading - append more rows to `data` when it fires.
1904
- */
1905
- onScrollBottomReached?: (event: {
1906
- scrollTop: number;
1907
- scrollHeight: number;
1908
- clientHeight: number;
1909
- }) => void;
1910
- /**
1911
- * Marks a row as an expandable "detail row". When this returns true the
1912
- * grid renders that row as a SINGLE full-width cell (colspan across every
1913
- * column) using `renderDetailRow`, instead of the normal per-column cells
1914
- * - the canonical Stripe / GitHub "expand a rich panel beneath the row"
1915
- * pattern. Insert the detail rows into `data` yourself (typically right
1916
- * after the row they belong to) and toggle them with your own expanded
1917
- * state. Pair with `virtualization={false}` so the variable-height detail
1918
- * isn't clipped by the fixed-row-height virtualizer.
1919
- */
1920
- isDetailRow?: (row: TData, rowIndex: number) => boolean;
1921
- /**
1922
- * Snippet rendered inside the full-width detail cell for rows where
1923
- * `isDetailRow` is true. Receives the row's data and its index.
1924
- */
1925
- renderDetailRow?: Snippet<[{ row: TData; rowIndex: number }]>;
1926
- /**
1927
- * Server-side group / tree keyboard + accessibility, built into the grid. When
1928
- * set, the grid uses the treegrid role and marks matching rows with
1929
- * `aria-level` / `aria-expanded`, and ArrowRight / ArrowLeft expand / collapse
1930
- * the focused group row (no app-level key handling). Pair with `serverGroupRows`
1931
- * + `SvGroupCell` for the visual expander. Every accessor receives the row data.
1932
- */
1933
- serverGroup?: {
1934
- /** Whether a row is an expandable group / branch. */
1935
- isGroup: (row: TData) => boolean;
1936
- /** Tree depth of the row (0 = top level), for `aria-level`. */
1937
- level: (row: TData) => number;
1938
- /** Whether an expandable row is currently expanded. */
1939
- expanded?: (row: TData) => boolean;
1940
- /** Expand / collapse a group row. Called on ArrowRight / ArrowLeft. */
1941
- onToggle: (row: TData) => void;
1942
- };
1943
- /**
1944
- * Server-side set-filter values. When set, a column's filter checklist is
1945
- * populated by fetching the distinct values from the server (once per column,
1946
- * cached) instead of deriving them from the loaded page - so the checklist
1947
- * shows every value, not just those on screen. Return the distinct string
1948
- * values for the column id.
1949
- */
1950
- serverFilterValues?: (columnId: string) => Promise<string[]>;
1951
- /**
1952
- * Rows to pin to the TOP of the grid - rendered above the regular
1953
- * rows and sticky-positioned so they stay visible while the user
1954
- * scrolls. Typical use: a "totals" or "headline" row that should
1955
- * always be in view. Rows are read-only (no inline editing, no
1956
- * row-selection checkbox). They share the column schema with the
1957
- * main grid; field/format/cell/cellClass all apply.
1958
- */
1959
- pinnedTopRows?: ReadonlyArray<TData>;
1960
- /**
1961
- * Rows to pin to the BOTTOM of the grid - rendered below the regular
1962
- * rows and sticky-positioned (sticks to the bottom of the viewport
1963
- * while the user scrolls). Typical use: a "page totals" or "grand
1964
- * total" row computed from `getDisplayedRows()`.
1965
- */
1966
- pinnedBottomRows?: ReadonlyArray<TData>;
1967
- /**
1968
- * Enables drag-to-reorder on the grid's column headers. When `true`,
1969
- * every header gets `draggable=true` and a drop indicator paints
1970
- * between headers during a drag. On drop the grid mutates its
1971
- * internal column order and fires `onColumnOrderChange` with the
1972
- * new order. Defaults to `false`.
1973
- */
1974
- enableColumnReorder?: boolean;
1975
- /**
1976
- * Initial column order, by `id` (falls back to `field`). When the
1977
- * user reorders columns, this is the starting state. After mount,
1978
- * the grid owns the order internally and emits `onColumnOrderChange`
1979
- * on every change - persist that to `localStorage` to restore.
1980
- */
1981
- columnOrder?: ReadonlyArray<string>;
1982
- /** Fires every time the column order changes (drag or `api.setColumnOrder`). */
1983
- onColumnOrderChange?: (order: ReadonlyArray<string>) => void;
1984
- /**
1985
- * Infer each column's data type (number / boolean / date / ISO date-string /
1986
- * text) from the first data row, for columns that declare neither an
1987
- * explicit `editorType` nor a `cellDataType`. Sets the matching editor,
1988
- * alignment, date format, and filter operators automatically. Explicit
1989
- * column config always wins. Defaults to `false`.
1990
- */
1991
- inferColumnTypes?: boolean;
1992
- /**
1993
- * Enables managed row dragging. When `true`, every row becomes a drag
1994
- * source (grab cursor + a grip in the row-number cell) and a drop
1995
- * indicator paints between rows during a drag. On drop the grid mutates
1996
- * its own internal data - reordering within the grid, or moving the row
1997
- * across grids that share the same {@link rowDragGroup}. Defaults to
1998
- * `false`.
1999
- */
2000
- rowDragManaged?: boolean;
2001
- /**
2002
- * Connection group for cross-grid row dragging. Grids that share the same
2003
- * non-empty `rowDragGroup` string (and have `rowDragManaged` on) can
2004
- * exchange rows: dragging a row out of one and dropping it into another
2005
- * removes it from the source and inserts it into the target. Omit to keep
2006
- * dragging confined to reordering within a single grid.
2007
- */
2008
- rowDragGroup?: string;
2009
- /**
2010
- * Fires on the TARGET grid after a managed row drag settles, with the
2011
- * moved row, its landing index, whether it stayed in the same grid, and
2012
- * the source / target grid ids. Use it to mirror the move into your own
2013
- * state (persistence, server sync). The grid has already applied the
2014
- * change to its internal data by the time this fires.
2015
- */
2016
- onRowDragEnd?: (event: {
2017
- row: TData;
2018
- toIndex: number;
2019
- sameGrid: boolean;
2020
- fromGridId: number;
2021
- toGridId: number;
2022
- }) => void;
2023
- /**
2024
- * Align this grid with others that share the same non-empty
2025
- * `alignedGridGroup` string: horizontal scroll and column-resize widths are
2026
- * kept in lockstep across every grid in the group. Use for a totals/header
2027
- * grid above a body grid, or side-by-side comparison grids that must line up.
2028
- * The grids should declare the same columns (matched by id) for widths to map.
2029
- */
2030
- alignedGridGroup?: string;
2031
- /**
2032
- * BCP-47 locale tag (or array of fallbacks) used for accent- and
2033
- * case-insensitive text filtering / sorting / search. Powered by
2034
- * `Intl.Collator` with `sensitivity: 'base'`, so "cafe", "Café"
2035
- * and "CAFÉ" all match "cafe" without strain. Defaults to the
2036
- * browser's locale.
2037
- */
2038
- filterLocale?: string | ReadonlyArray<string>;
2039
- };
2040
-
2041
- /**
2042
- * The grid's single localization surface (see {@link Props.localization}):
2043
- * `locale` handles the data (filter matching + number/date formatting) and
2044
- * `text` handles the UI strings.
2045
- */
2046
- export type GridLocalization = {
2047
- /** BCP-47 tag(s) for filter matching + number / date formatting. */
2048
- locale?: string | ReadonlyArray<string>;
2049
- /** Overrides for the grid's own UI strings. */
2050
- text?: Partial<GridMessages>;
2051
- };
2052
-
2053
- export type SelectionPoint = { rowIndex: number; colIndex: number };
2054
- export type SelectionRange = {
2055
- anchor: SelectionPoint | null;
2056
- focus: SelectionPoint | null;
2057
- };
2058
- export type CellEditState = {
2059
- rowId: string;
2060
- columnId: string;
2061
- editorType: CellEditorType;
2062
- value: unknown;
2063
- /**
2064
- * The row's underlying data object, captured when the edit started. The
2065
- * commit path resolves the row by id first; this is the fallback for when
2066
- * the row has left the row model mid-edit (a filter typed into the filter
2067
- * row while an editor is open), so the typed value still lands instead of
2068
- * being silently dropped.
2069
- */
2070
- rowRef?: unknown;
2071
- } | null;
2072
- export type FilterOperator =
2073
- | "contains"
2074
- | "notContains"
2075
- | "equals"
2076
- | "notEquals"
2077
- | "startsWith"
2078
- | "endsWith"
2079
- | "regex"
2080
- | "in"
2081
- | "notIn"
2082
- | "greaterThan"
2083
- | "lessThan"
2084
- | "between"
2085
- | "isBlank"
2086
- | "isNotBlank";
2087
- export type FilterOption = {
2088
- value: FilterOperator;
2089
- label: string;
2090
- iconName: string;
2091
- };
2092
- export type MenuPosition = { x: number; y: number };
1
+ // Type definitions extracted from SvGrid.svelte. These are compile-time
2
+ // only - moving them out keeps the component's <script> focused on logic.
3
+ import type { Snippet } from "svelte";
4
+ import type {
5
+ CellEditorType,
6
+ ColumnDef,
7
+ RowData,
8
+ SvGridApi,
9
+ TableFeatures,
10
+ } from "./index";
11
+ import type { ConditionalFormat } from "./conditional-formatting";
12
+ import type { GroupDisplayType } from "./group-display";
13
+ import type { GridMessages } from "./grid-messages";
14
+ import type { GridPivotConfig } from "./pivot-view.svelte";
15
+ import type { GridPredicateExpr } from "./filtering/predicate-expr";
16
+ import type { MenuItem } from "./SvMenuList.svelte";
17
+
18
+ /** The calendar views the scheduler can render. {@link SchedulerConfig}. The
19
+ * `timeline*` views are horizontal: time runs left→right and resources are
20
+ * rows (a single "All" row without `resourceField`). */
21
+ export type SchedulerView =
22
+ | "month"
23
+ | "week"
24
+ | "day"
25
+ | "agenda"
26
+ | "timelineDay"
27
+ | "timelineWeek"
28
+ | "timelineMonth"
29
+ | "timelineYear";
30
+
31
+ /**
32
+ * How overlapping ("colliding") time-grid events are laid out:
33
+ * - `split` - every collision divides the column width evenly (default).
34
+ * - `cap` - show up to `maxColumns` columns; the rest collapse into a
35
+ * clickable `+N more` overflow tile.
36
+ * - `stack` - overlapping events overlap with a horizontal offset + z-order
37
+ * instead of shrinking, so each stays readable (hover to raise).
38
+ */
39
+ export type SchedulerCollisionMode = "split" | "cap" | "stack";
40
+
41
+ /** A scheduler resource - a person / room / machine an event can be assigned to. */
42
+ export type SchedulerResource = {
43
+ id: string;
44
+ title?: string;
45
+ color?: string;
46
+ /**
47
+ * This resource's own working windows (hours), optionally per weekday - e.g. a
48
+ * doctor available Mon/Wed/Fri 9-13 and Tue/Thu 14-18. Overrides the global
49
+ * `businessHours` / `nonWorkingDays` for this resource's columns: time outside
50
+ * every matching window is shaded, and (with `restrictToBusinessHours`)
51
+ * non-bookable. A weekday with no matching window is a full day off.
52
+ */
53
+ availability?: ReadonlyArray<{ days?: ReadonlyArray<number>; start: number; end: number }>;
54
+ /**
55
+ * Per-date overrides to this resource's weekly `availability` - a specific day
56
+ * off (`off: true`, e.g. vacation) or custom hours (`windows`) for that one
57
+ * date. Matched by calendar date; takes precedence over `availability` for the
58
+ * matching day.
59
+ */
60
+ dateOverrides?: ReadonlyArray<{
61
+ date: Date | number | string;
62
+ off?: boolean;
63
+ windows?: ReadonlyArray<{ start: number; end: number }>;
64
+ }>;
65
+ };
66
+ import type {
67
+ ChartType,
68
+ ChartSpec,
69
+ ChartAnnotation,
70
+ ChartReferenceLine,
71
+ ChartValueFormat,
72
+ } from "./chart";
73
+
74
+ /** One aggregated bucket returned by a server-side `getAggregate`. */
75
+ export type ChartAggregateBucket = { category: string; series?: string; value: number };
76
+ /** The request a server-side `getAggregate` receives (whole-dataset charting). */
77
+ export type ChartAggregateRequest = {
78
+ dimension: string | undefined;
79
+ measure: string | null;
80
+ series?: string;
81
+ reduce: "sum" | "avg" | "count";
82
+ filterModel: Record<string, unknown>;
83
+ };
84
+
85
+ /**
86
+ * Config for the built-in `charting` prop. All fields optional and additive;
87
+ * `charting={true}` is the zero-config form. Column references are column
88
+ * field names / ids.
89
+ */
90
+ export type ChartingConfig<TData extends RowData = RowData> = {
91
+ /** Right-side drawer (default) or bottom dock. */
92
+ position?: "bottom" | "right";
93
+ /** Open the panel on first render. */
94
+ defaultOpen?: boolean;
95
+ /** Initial chart type. */
96
+ defaultType?: ChartType;
97
+ /** Docked-bottom height (px). */
98
+ height?: number;
99
+ /** Drawer width (px). */
100
+ width?: number;
101
+ /** Clicking a chart category filters the grid on the charted dimension. */
102
+ crossFilter?: boolean;
103
+ /** Group-by column. */
104
+ dimension?: string;
105
+ /** Split-by column: one series per distinct value. */
106
+ series?: string;
107
+ /** Measure column, or several for a multi-series chart. */
108
+ measures?: string | string[];
109
+ reduce?: "sum" | "avg" | "count";
110
+ stacked?: boolean;
111
+ stacked100?: boolean;
112
+ /** Per-series-label type override (combo). */
113
+ seriesTypes?: Record<string, "bar" | "line" | "area">;
114
+ /** Per-series-label axis override (dual axis). */
115
+ seriesAxes?: Record<string, "left" | "right">;
116
+ referenceLines?: ChartReferenceLine[];
117
+ averageLine?: boolean;
118
+ trend?: "sma" | "ema" | "linear";
119
+ annotations?: ChartAnnotation[];
120
+ yScale?: "linear" | "log";
121
+ timeAxis?: boolean;
122
+ valueFormat?: "number" | "currency" | "percent" | "compact";
123
+ smooth?: boolean;
124
+ orientation?: "vertical" | "horizontal";
125
+ donut?: number | boolean;
126
+ palette?: string[];
127
+ patternFallback?: boolean;
128
+ topN?: number;
129
+ otherLabel?: string;
130
+ sort?: "value-desc" | "value-asc" | "category" | "none";
131
+ dataLabels?: boolean;
132
+ zoom?: boolean;
133
+ brush?: boolean;
134
+ /** Show the chart's PNG/SVG export toolbar. */
135
+ export?: boolean;
136
+ /** Escape hatch: build a fully custom ChartSpec from the (scoped) rows. */
137
+ buildSpec?: (rows: TData[]) => ChartSpec | null;
138
+ /** Server-side aggregation: chart the whole dataset, not just loaded rows. */
139
+ getAggregate?: (
140
+ request: ChartAggregateRequest,
141
+ ) => Promise<ReadonlyArray<ChartAggregateBucket>>;
142
+ /** Bump to force a server-side refetch. */
143
+ refreshKey?: unknown;
144
+ };
145
+
146
+ /**
147
+ * The built-in card detail drawer. Set `board.drawer` (`true` for all fields,
148
+ * or this object to customize) and opening a card shows a drawer with an
149
+ * `SvForm` of its fields, rendered with the UI-kit editors.
150
+ */
151
+ export type BoardDrawerConfig<TData extends RowData = RowData> = {
152
+ /** Fields to show, in order. Omit for every column that has a `field`. */
153
+ fields?: ReadonlyArray<keyof TData & string>;
154
+ /** Drawer title - a string or derived from the row. Defaults to the title field. */
155
+ title?: string | ((row: TData) => string);
156
+ /** Which edge the drawer opens from. Defaults to `'right'`. */
157
+ side?: "right" | "left" | "top" | "bottom";
158
+ /** Drawer size (any CSS length). Defaults to `'380px'`. */
159
+ size?: string;
160
+ /** Save button label. Defaults to `'Save'`. */
161
+ submitLabel?: string;
162
+ /** Form columns inside the drawer. Defaults to `1`. */
163
+ columns?: number;
164
+ };
165
+
166
+ /** Board-native helpers passed to `board.cardMenu` for building context items. */
167
+ export type BoardMenuContext<TData extends RowData = RowData> = {
168
+ /** The board's lanes (id + title). */
169
+ lanes: BoardLane[];
170
+ /** Move this card to a lane (board-native; fires onCardMove). */
171
+ moveTo: (laneId: string) => void;
172
+ /** Open this card's editor (inline, or your `onCardEdit`). */
173
+ edit: () => void;
174
+ };
175
+
176
+ /** Board-native helpers passed to `board.laneMenu` for building lane context items. */
177
+ export type BoardLaneMenuContext<TData extends RowData = RowData> = {
178
+ /** The lane's id. */
179
+ laneId: string;
180
+ /** The lane's current cards (this swimlane's, if any). */
181
+ cards: TData[];
182
+ /** Whether the lane is collapsed. */
183
+ collapsed: boolean;
184
+ /** Collapse / expand the lane (needs `collapsibleLanes`). */
185
+ toggleCollapse: () => void;
186
+ /** Add a card to the lane (fires `onCardAdd`). */
187
+ addCard: (title?: string) => void;
188
+ };
189
+
190
+ /** The cell a context menu was opened on. Passed to every item's callbacks. */
191
+ export type ContextMenuTarget<TData extends RowData = RowData> = {
192
+ rowIndex: number;
193
+ colIndex: number;
194
+ columnId: string;
195
+ /** Stable row id (from getRowId / row model), for keying notes etc. */
196
+ rowId: string;
197
+ row: TData | null;
198
+ };
199
+
200
+ /**
201
+ * A context-menu entry. Either a built-in action key, the `"separator"`
202
+ * divider, or a custom item. Built-in keys: `"copy" | "cut" | "paste" |
203
+ * "clear" | "row_above" | "row_below" | "remove_row" | "remove_col" |
204
+ * "chart"`. The `"chart"` item (chart the selected range) is only shown when
205
+ * `charting` is enabled; it is appended to the default menu automatically.
206
+ */
207
+ export type ContextMenuItem<TData extends RowData = RowData> =
208
+ | string
209
+ | {
210
+ key: string;
211
+ label: string;
212
+ /** Hide the item entirely for this target. */
213
+ hidden?: (target: ContextMenuTarget<TData>) => boolean;
214
+ /** Render the item greyed-out and non-clickable for this target. */
215
+ disabled?: (target: ContextMenuTarget<TData>) => boolean;
216
+ /** Invoked on click. The menu closes afterwards. */
217
+ action: (target: ContextMenuTarget<TData>) => void;
218
+ };
219
+
220
+ /** What a {@link SelectionBarAction} is handed when it runs. */
221
+ export type SelectionBarTarget<TData extends RowData = RowData> = {
222
+ /** The selected rows, in the grid's current display order. */
223
+ rows: TData[];
224
+ /** Their row ids, same order as `rows`. */
225
+ ids: string[];
226
+ };
227
+
228
+ /**
229
+ * One button on the selection bar. Same shape as {@link ContextMenuItem}'s
230
+ * object form - key, label, optional hidden/disabled predicates, and an action -
231
+ * except everything here is handed the whole SELECTION rather than one cell.
232
+ */
233
+ export type SelectionBarAction<TData extends RowData = RowData> = {
234
+ key: string;
235
+ label: string;
236
+ /**
237
+ * Inline SVG path data (the `d` of a single 24x24 path) drawn to the left of
238
+ * the label. A string rather than a component so an action array stays plain
239
+ * data that can live in a `.ts` module next to the columns.
240
+ */
241
+ icon?: string;
242
+ /** Render in the destructive style (red). Does not add a confirmation. */
243
+ danger?: boolean;
244
+ /** Hide the button entirely for this selection. */
245
+ hidden?: (target: SelectionBarTarget<TData>) => boolean;
246
+ /** Render greyed-out and non-clickable for this selection. */
247
+ disabled?: (target: SelectionBarTarget<TData>) => boolean;
248
+ /** Invoked on click. The bar stays open; clear the selection yourself if the
249
+ * action should dismiss it. */
250
+ action: (target: SelectionBarTarget<TData>) => void;
251
+ };
252
+
253
+ /**
254
+ * A built-in bar button, named by key - the same convention
255
+ * {@link ContextMenuItem} uses for its string form.
256
+ *
257
+ * - `'selectAll'` selects every row in the current view.
258
+ * - `'editFields'` opens the bulk-edit dialog: pick a field, set one value,
259
+ * apply it to every selected row in a single undo step.
260
+ * - `'separator'` draws a divider.
261
+ */
262
+ export type SelectionBarBuiltin = "selectAll" | "editFields" | "separator";
263
+
264
+ /**
265
+ * Full form of the {@link SvGridProps.selectionBar} prop, for when the array
266
+ * shorthand is not enough.
267
+ */
268
+ export type SelectionBarConfig<TData extends RowData = RowData> = {
269
+ /**
270
+ * The buttons, left to right. Strings are {@link SelectionBarBuiltin} keys,
271
+ * objects are your own actions - so a Jira-shaped bar is
272
+ * `['selectAll', 'editFields', 'separator', myAction]`.
273
+ */
274
+ actions?: ReadonlyArray<SelectionBarAction<TData> | SelectionBarBuiltin>;
275
+ /**
276
+ * Which edge of the grid the bar floats against. Default `'bottom'`, where
277
+ * the eye is already going after ticking a checkbox and where it covers the
278
+ * rows a user is least likely to be reading.
279
+ */
280
+ position?: "bottom" | "top";
281
+ /**
282
+ * How many actions stay on the bar before the rest collapse into an overflow
283
+ * menu. Default 6, which fits a full issue-tracker set (select all, edit,
284
+ * status, watch, delete) without collapsing. A bar wide enough to need
285
+ * horizontal scrolling is a bar whose last button nobody finds.
286
+ */
287
+ maxVisible?: number;
288
+ /** Hide the trailing clear (x) button. Default false. */
289
+ hideClear?: boolean;
290
+ };
291
+
292
+ /** A single Kanban lane (board column). {@link BoardConfig}. */
293
+ export type BoardLane = {
294
+ /** Lane id - equals the `groupBy` field value of the cards it holds. */
295
+ id: string;
296
+ /** Header title. Defaults to the id (or `(empty)` for a blank value). */
297
+ title?: string;
298
+ /** Accent color (any CSS color) for the lane header bar + card ring. */
299
+ color?: string;
300
+ /**
301
+ * Soft max number of cards. When exceeded the lane header is flagged
302
+ * over-limit. Enforcement/styling is an enterprise concern; the count is
303
+ * always shown.
304
+ */
305
+ wipLimit?: number;
306
+ };
307
+
308
+ /** A checklist item inside a card. See {@link BoardConfig.subtasks}. */
309
+ export type BoardSubtask = {
310
+ id: string | number;
311
+ title: string;
312
+ done: boolean;
313
+ };
314
+
315
+ /** A comment on a card. See {@link BoardConfig.commentsField}. */
316
+ export type BoardComment = {
317
+ id: string | number;
318
+ text: string;
319
+ author?: string;
320
+ /** Timestamp label (any string). */
321
+ at?: string;
322
+ };
323
+
324
+ /**
325
+ * The serializable board layout - the per-card position/edit overlay plus
326
+ * collapsed lanes. Persisted by `board.persistKey` and passed to
327
+ * `board.onLayoutChange`.
328
+ */
329
+ export type BoardLayout = {
330
+ /** rowId -> lane id. */
331
+ laneOf?: Record<string, string>;
332
+ /** rowId -> sort order within its lane. */
333
+ orderOf?: Record<string, number>;
334
+ /** rowId -> swimlane id. */
335
+ swimOf?: Record<string, string>;
336
+ /** rowId -> edited field values. */
337
+ edits?: Record<string, Record<string, unknown>>;
338
+ /** lane id -> collapsed. */
339
+ collapsed?: Record<string, boolean>;
340
+ /** swimlane id -> collapsed. */
341
+ collapsedSwim?: Record<string, boolean>;
342
+ /** Explicit lane order (ids), when lanes have been drag-reordered. */
343
+ laneOrder?: string[];
344
+ /** rowId -> subtaskId -> done override. */
345
+ subDone?: Record<string, Record<string, boolean>>;
346
+ /** rowId -> subtasks added on the card. */
347
+ subAdded?: Record<string, BoardSubtask[]>;
348
+ };
349
+
350
+ /** Emitted when a card's built-in editor is saved. */
351
+ export type BoardCardCommitEvent<TData extends RowData = RowData> = {
352
+ /** The edited row. */
353
+ row: TData;
354
+ /** Only the fields that changed, `{ field: newValue }`. */
355
+ changes: Record<string, unknown>;
356
+ /** The full set of edited field values. */
357
+ values: Record<string, unknown>;
358
+ };
359
+
360
+ /** Emitted when a card is dragged to a new lane and/or position. */
361
+ export type BoardCardMoveEvent<TData extends RowData = RowData> = {
362
+ /** The dragged row. */
363
+ row: TData;
364
+ /** Lane the card came from. */
365
+ fromLane: string;
366
+ /** Lane the card was dropped on. */
367
+ toLane: string;
368
+ /** Insertion index within the destination lane. */
369
+ toIndex: number;
370
+ /** Swimlane the card came from (only when `swimlaneBy` is set). */
371
+ fromSwimlane?: string;
372
+ /** Swimlane the card was dropped on (only when `swimlaneBy` is set). */
373
+ toSwimlane?: string;
374
+ };
375
+
376
+ /**
377
+ * Turns the grid into a Kanban board. Set `board` and the grid renders its
378
+ * rows as cards in horizontal lanes (bucketed by the `groupBy` field) instead
379
+ * of a table. Dragging a card between lanes fires {@link BoardConfig.onCardMove}
380
+ * where you reassign the `groupBy` field on your own data.
381
+ */
382
+ /**
383
+ * Chart view of the grid. Setting the `chart` prop on `<SvGrid>` swaps the table
384
+ * for a chart driven by the grid's FILTERED + SORTED rows - so the search box,
385
+ * column filters and sort all flow through to the chart. Unlike the board and
386
+ * scheduler views, the renderer is free: the grid lazy-loads a built-in
387
+ * `SvChart` view unless a host overrides it via `registerChartView`.
388
+ *
389
+ * The config maps directly onto `rowsToChartSpec` - one row field for the
390
+ * category axis, one or more for the value series (or a `series` field to pivot
391
+ * one series per distinct value).
392
+ *
393
+ * ```svelte
394
+ * <SvGrid {data} {columns}
395
+ * chart={{ type: 'bar', category: 'month', value: 'revenue', reduce: 'sum' }} />
396
+ * ```
397
+ */
398
+ export type ChartViewConfig<
399
+ TFeatures extends TableFeatures = TableFeatures,
400
+ TData extends RowData = RowData,
401
+ > = {
402
+ /** Chart type. Default `'bar'`. */
403
+ type?: ChartType;
404
+ /** Row field for the category (x) axis. */
405
+ category: keyof TData & string;
406
+ /** Row field(s) for the value (y) series. */
407
+ value: (keyof TData & string) | Array<keyof TData & string>;
408
+ /** Pivot dimension: one series per distinct value of this field. */
409
+ series?: keyof TData & string;
410
+ /** Aggregation when several rows share a category. Default `'sum'`. */
411
+ reduce?: "sum" | "avg" | "count";
412
+ /** Stack bar / area series instead of grouping them. */
413
+ stacked?: boolean;
414
+ /** Stack to 100% (implies `stacked`). */
415
+ stacked100?: boolean;
416
+ /** Order categories. Default: insertion order (value-desc when `topN` is set). */
417
+ sort?: "value-desc" | "value-asc" | "category" | "none";
418
+ /** Keep only the top N categories; bucket the rest into "Other". */
419
+ topN?: number;
420
+ /** Palette for series without an explicit colour. */
421
+ palette?: string[];
422
+ /** Number format for the value axis, tooltips and data labels. */
423
+ valueFormat?: ChartValueFormat;
424
+ /** Show the clickable legend. Default `true`. */
425
+ legend?: boolean;
426
+ /** Draw the value on each bar / point / slice. Default `false`. */
427
+ dataLabels?: boolean;
428
+ /** Show the search box above the chart (filters rows first). Default `true`. */
429
+ searchable?: boolean;
430
+ /** Placeholder for the search box. */
431
+ searchPlaceholder?: string;
432
+ };
433
+
434
+ export type BoardConfig<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> = {
435
+ /** Field whose value buckets each row into a lane. */
436
+ groupBy: keyof TData & string;
437
+ /**
438
+ * Explicit, ordered lanes. Omit to derive lanes from the distinct
439
+ * `groupBy` values found in the data (first-seen order).
440
+ */
441
+ lanes?: ReadonlyArray<BoardLane>;
442
+ /** Custom card body. Receives the row. Omit for the built-in default card. */
443
+ card?: Snippet<[TData]>;
444
+ /**
445
+ * Fired when a card is dragged to a new lane/position. Update your data
446
+ * here (reassign the `groupBy` field, and optionally reorder). Without it
447
+ * the board is display-only.
448
+ */
449
+ onCardMove?: (event: BoardCardMoveEvent<TData>) => void;
450
+ /**
451
+ * Add-card affordance. A `+` in the lane header (or, with `composer`, a
452
+ * type-a-title box at the bottom of the lane) fires this with the lane id
453
+ * and - from the composer - the typed title.
454
+ */
455
+ onCardAdd?: (laneId: string, title?: string) => void;
456
+ /**
457
+ * Show a quick-add composer at the bottom of each lane (a "+ Add a card"
458
+ * button that opens an inline title input; Enter calls `onCardAdd(lane,
459
+ * title)`). Without it, `onCardAdd` shows a plain `+` in the header.
460
+ */
461
+ composer?: boolean;
462
+ /**
463
+ * Field holding a card's checklist of sub-tasks (`BoardSubtask[]`). The card
464
+ * shows a progress chip + bar and expands to an inline checklist with a
465
+ * quick-add. Toggles/adds run through an overlay (never mutating your data)
466
+ * and fire the callbacks below.
467
+ */
468
+ subtasks?: keyof TData & string;
469
+ /** Fired when a sub-task checkbox is toggled. */
470
+ onSubtaskToggle?: (row: TData, subtaskId: string | number, done: boolean) => void;
471
+ /** Fired when a sub-task is added from the card. */
472
+ onSubtaskAdd?: (row: TData, title: string) => void;
473
+ /**
474
+ * Field holding label/tag strings (or `{ text, color }`) shown as chips on
475
+ * the default card's badge row.
476
+ */
477
+ labelsField?: keyof TData & string;
478
+ /** Field holding a due date (Date | ISO string); shown as a badge, red when overdue. */
479
+ dueField?: keyof TData & string;
480
+ /**
481
+ * Field holding one or more assignee names (string | string[]); shown as
482
+ * avatar(s) on the default card's badge row.
483
+ */
484
+ assigneesField?: keyof TData & string;
485
+ /**
486
+ * Enable the built-in card editor: double-click a card (or press F2 while
487
+ * it is focused) to edit its fields inline. Fields are rendered from the
488
+ * columns that declare an `editorType` (or all fields if none do). Ignored
489
+ * when `onCardEdit` is set.
490
+ */
491
+ editable?: boolean;
492
+ /**
493
+ * Open your own editor instead of the built-in one. Called on double-click /
494
+ * F2 with the row; you might open a drawer or route to a detail screen.
495
+ */
496
+ onCardEdit?: (row: TData) => void;
497
+ /**
498
+ * Built-in **detail drawer**: opening a card (double-click / F2) shows an
499
+ * `SvDrawer` with an `SvForm` of its fields (kit editors). `true` = all
500
+ * fields; pass a {@link BoardDrawerConfig} to pick a subset / customize.
501
+ * Ignored when `onCardEdit` is set.
502
+ */
503
+ drawer?: boolean | BoardDrawerConfig<TData>;
504
+ /** Fired when the built-in editor is saved. Persist / mirror the changes. */
505
+ onCardCommit?: (event: BoardCardCommitEvent<TData>) => void;
506
+ /** Field used as the card title. Defaults to the first column's field. */
507
+ titleField?: keyof TData & string;
508
+ /**
509
+ * Column fields shown as label:value meta lines on the default card
510
+ * (max 4). Defaults to the first few non-title, non-groupBy columns.
511
+ */
512
+ cardFields?: ReadonlyArray<keyof TData & string>;
513
+ /**
514
+ * Second grouping axis: split the board into horizontal **swimlanes** by
515
+ * this field. Each swimlane band shows the full lane set with only its own
516
+ * cards. Dragging a card into another band reassigns this field too.
517
+ */
518
+ swimlaneBy?: keyof TData & string;
519
+ /** Let users collapse a swimlane band via its header chevron. */
520
+ collapsibleSwimlanes?: boolean;
521
+ /**
522
+ * Field holding a card's comments - `BoardComment[]` (or plain strings, or a
523
+ * number for a count only). Renders a comment-count badge that expands to a
524
+ * thread; provide the callbacks below to let users write / delete comments.
525
+ */
526
+ commentsField?: keyof TData & string;
527
+ /** Fired when a comment is added on the card; append it to your data. */
528
+ onCommentAdd?: (row: TData, text: string) => void;
529
+ /** Fired when a comment's delete button is pressed; remove it from your data. */
530
+ onCommentDelete?: (row: TData, commentId: string | number) => void;
531
+ /**
532
+ * Field holding a card's attachments - an array or a number. Renders an
533
+ * attachment-count badge on the default card.
534
+ */
535
+ attachmentsField?: keyof TData & string;
536
+ /**
537
+ * Field holding a cover colour (any CSS colour string) shown as a strip
538
+ * across the top of the default card.
539
+ */
540
+ coverField?: keyof TData & string;
541
+ /**
542
+ * Enforce `wipLimit`: reject a drop / keyboard move that would push a lane
543
+ * past its limit (the card snaps back). Off by default (the limit is a
544
+ * soft, visual flag only).
545
+ */
546
+ enforceWip?: boolean;
547
+ /** Let users collapse a lane to a slim strip by clicking its header. */
548
+ collapsibleLanes?: boolean;
549
+ /** Let users drag lane headers to reorder lanes (persisted with `persistKey`). */
550
+ reorderableLanes?: boolean;
551
+ /** Fired after a lane drag-reorder, with the new ordered lane ids. */
552
+ onLaneReorder?: (orderedIds: string[]) => void;
553
+ /**
554
+ * Enable inline lane rename: double-click a lane title to edit it. Fires
555
+ * with the lane id and new title - update your own lane config / data.
556
+ */
557
+ onLaneRename?: (laneId: string, title: string) => void;
558
+ /**
559
+ * Per-swimlane summary shown in the band header (e.g. a points/$ total or a
560
+ * WIP count). Receives the swimlane's cards and its id; return a short string.
561
+ */
562
+ swimlaneSummary?: (rows: TData[], swimId: string) => string;
563
+ /**
564
+ * Right-click (or long-press) a card to open a context menu. Return the
565
+ * menu items for that card; `ctx` gives board-native `moveTo(laneId)` and
566
+ * `edit()` helpers plus the lane list. Return empty/undefined for no menu.
567
+ */
568
+ cardMenu?: (row: TData, ctx: BoardMenuContext<TData>) => ReadonlyArray<MenuItem> | undefined;
569
+ /** Right-click a lane header for a lane context menu (rename / clear / add / collapse). */
570
+ laneMenu?: (laneId: string, ctx: BoardLaneMenuContext<TData>) => ReadonlyArray<MenuItem> | undefined;
571
+ /**
572
+ * Truthy field marks a card as **blocked** (waiting on a dependency): a red
573
+ * corner + a "Blocked" badge on the card. If the value is a non-empty string
574
+ * it is used as the blocked **reason** (shown in the badge tooltip). A blocked
575
+ * card is **locked from moving** (drag + keyboard) until it is unblocked - set
576
+ * {@link BoardConfig.flagBlocksMoves} `false` for a purely visual flag.
577
+ */
578
+ flagField?: keyof TData & string;
579
+ /** Whether a blocked (`flagField`) card is locked from moving. Defaults to `true`. */
580
+ flagBlocksMoves?: boolean;
581
+ /**
582
+ * Field holding a created/started date (Date | ISO string); shown as a
583
+ * relative **age** badge (e.g. `3d`).
584
+ */
585
+ ageField?: keyof TData & string;
586
+ /**
587
+ * Fields to expose as a **facet filter bar** above the board - a chip per
588
+ * distinct value; selecting chips filters the visible cards.
589
+ */
590
+ facets?: ReadonlyArray<keyof TData & string>;
591
+ /**
592
+ * Enable card **multi-select**: click to select, Ctrl/Cmd-click to toggle,
593
+ * and dragging a selected card moves the whole selection. Fires
594
+ * `onSelectionChange`.
595
+ */
596
+ selectable?: boolean;
597
+ /** Fired when the selection changes, with the selected rows. */
598
+ onSelectionChange?: (rows: TData[]) => void;
599
+ /**
600
+ * Field holding a card's **child rows** (`TData[]`) - the card gets a
601
+ * children count and expands to show them as nested mini-cards (epic ->
602
+ * stories). Each child renders its title and, if present, its `groupBy` value.
603
+ */
604
+ childrenField?: keyof TData & string;
605
+ /**
606
+ * Optional per-lane summary shown in the lane header (e.g. a story-point or
607
+ * dollar total). Receives the lane's cards (the current swimlane's, when
608
+ * `swimlaneBy` is set) and the lane id; return a short string.
609
+ */
610
+ laneSummary?: (rows: TData[], laneId: string) => string;
611
+ /** Show the built-in card search box (default `true`). */
612
+ searchable?: boolean;
613
+ /** Placeholder for the search box. Defaults to `"Search cards..."`. */
614
+ searchPlaceholder?: string;
615
+ /**
616
+ * Virtualize each lane so only the cards in view are in the DOM - for boards
617
+ * with thousands of cards per lane. Assumes roughly uniform card height; set
618
+ * `cardHeight` to match your cards.
619
+ */
620
+ virtualized?: boolean;
621
+ /** Estimated card height in px used by `virtualized` windowing (default 76). */
622
+ cardHeight?: number;
623
+ /**
624
+ * Persist the board layout (card positions, edits, collapsed lanes) to
625
+ * `localStorage` under this key, restored on load. Requires `getRowId` for
626
+ * stable identity across reloads.
627
+ */
628
+ persistKey?: string;
629
+ /** Called whenever the board layout changes, with the serializable state. */
630
+ onLayoutChange?: (layout: BoardLayout) => void;
631
+ };
632
+
633
+ /**
634
+ * The built-in event detail drawer for the scheduler. Set `scheduler.drawer`
635
+ * (`true` for all fields, or this object) and clicking an event opens a drawer
636
+ * with an `SvForm` of its fields. Mirrors {@link BoardDrawerConfig}.
637
+ */
638
+ export type SchedulerDrawerConfig<TData extends RowData = RowData> = {
639
+ /** Fields to show, in order. Omit for every column that has a `field`. */
640
+ fields?: ReadonlyArray<keyof TData & string>;
641
+ /** Drawer title - a string or derived from the row. Defaults to the title field. */
642
+ title?: string | ((row: TData) => string);
643
+ /** Which edge the drawer opens from. Defaults to `'right'`. */
644
+ side?: "right" | "left" | "top" | "bottom";
645
+ /** Drawer size (any CSS length). Defaults to `'380px'`. */
646
+ size?: string;
647
+ /** Save button label. Defaults to `'Save'`. */
648
+ submitLabel?: string;
649
+ /** Form columns inside the drawer. Defaults to `1`. */
650
+ columns?: number;
651
+ };
652
+
653
+ /** Emitted when an event is dragged to a new time (and/or resource). */
654
+ export type SchedulerEventMoveEvent<TData extends RowData = RowData> = {
655
+ /** The dragged row. */
656
+ row: TData;
657
+ /** New start / end after the move. */
658
+ start: Date;
659
+ end: Date;
660
+ /** Whether the event is all-day after the move. */
661
+ allDay: boolean;
662
+ /** Resource it came from (only with `resourceField`). */
663
+ fromResource?: string;
664
+ /** Resource it was dropped on (only with `resourceField`). */
665
+ toResource?: string;
666
+ };
667
+
668
+ /** Emitted when an event's start or end edge is dragged to resize it. */
669
+ export type SchedulerEventResizeEvent<TData extends RowData = RowData> = {
670
+ row: TData;
671
+ start: Date;
672
+ end: Date;
673
+ };
674
+
675
+ /**
676
+ * A drag-selected range (see `rangeSelectable`). `start`/`end` are a single
677
+ * CONTINUOUS datetime range - dragging across days makes it a longer span, not a
678
+ * per-day rectangle. `days` / `resourceIds` list the days / resources the range
679
+ * touched (for reference); `allDay` is true when the all-day row was dragged.
680
+ */
681
+ export type SchedulerRangeSelection = {
682
+ start: Date;
683
+ end: Date;
684
+ allDay?: boolean;
685
+ /** Every day the range touched (one entry for a within-a-day drag). */
686
+ days: Date[];
687
+ /** Every resource the range touched (empty without `resourceField`). */
688
+ resourceIds: string[];
689
+ };
690
+
691
+ /** Emitted when an event's built-in editor/drawer is saved. */
692
+ export type SchedulerEventCommitEvent<TData extends RowData = RowData> = {
693
+ row: TData;
694
+ /** Only the fields that changed, `{ field: newValue }`. */
695
+ changes: Record<string, unknown>;
696
+ /** The full set of edited field values. */
697
+ values: Record<string, unknown>;
698
+ };
699
+
700
+ /**
701
+ * One override of a single occurrence of a recurring event (stored in the row's
702
+ * `recurrenceExceptionsField`). `occurrenceStart` identifies the occurrence (its
703
+ * original start, like an iCal `RECURRENCE-ID`); `deleted` removes just that one,
704
+ * otherwise the given fields override it. Times are the same ISO / Date shape you
705
+ * store on the row.
706
+ */
707
+ export type SchedulerException = {
708
+ occurrenceStart: string | number | Date;
709
+ deleted?: boolean;
710
+ start?: string | number | Date;
711
+ end?: string | number | Date;
712
+ title?: string;
713
+ allDay?: boolean;
714
+ /**
715
+ * Per-occurrence overrides for ANY other field (e.g. attendees, calendar,
716
+ * color, resource). Merged over the row for just this occurrence, so "This
717
+ * event" can change fields beyond start / end / title / all-day.
718
+ */
719
+ fields?: Record<string, unknown>;
720
+ };
721
+
722
+ /** How a change to a recurring event should apply. */
723
+ export type SchedulerEditScope = "occurrence" | "following" | "series";
724
+
725
+ /**
726
+ * Fired when a single occurrence of a recurring event is edited or deleted (the
727
+ * user chose "This event"). Append/merge `exception` into the row's
728
+ * `recurrenceExceptionsField`; for `deleted` it carries `{ deleted: true }`.
729
+ */
730
+ export type SchedulerOccurrenceChangeEvent<TData extends RowData = RowData> = {
731
+ row: TData;
732
+ /** The occurrence's original start (its identity within the series). */
733
+ occurrenceStart: Date;
734
+ /** The override to store (already in real-instant time). */
735
+ exception: SchedulerException;
736
+ /**
737
+ * Which scope the user chose. `'occurrence'` (default): merge `exception` into
738
+ * the row. `'following'` ("this and all following"): split the series - stop
739
+ * the original series before `occurrenceStart` and start a NEW series at it
740
+ * carrying `exception`'s start/end/deleted. `'series'` never reaches here (it
741
+ * edits the base row directly). Handle `'following'` in your own data.
742
+ */
743
+ scope: SchedulerEditScope;
744
+ };
745
+
746
+ /**
747
+ * Turns the grid into a calendar / scheduler. Set `scheduler` and the grid
748
+ * renders its rows as events on a Month / Week / Day / Agenda calendar (bucketed
749
+ * by time, and optionally split into per-resource columns) instead of a table.
750
+ * Dragging an event fires {@link SchedulerConfig.onEventMove} where you reassign
751
+ * the start / end (and resource) on your own data. Like the Kanban board, it is
752
+ * a pure *view of the grid*: it renders the grid's filtered + sorted rows and
753
+ * writes back only through callbacks, never mutating your data.
754
+ */
755
+ export type SchedulerConfig<
756
+ TFeatures extends TableFeatures = TableFeatures,
757
+ TData extends RowData = RowData,
758
+ > = {
759
+ /** Field holding each event's start (`Date` | epoch-ms | ISO string). Required. */
760
+ startField: keyof TData & string;
761
+ /** Field holding the end. Omit to use `defaultDurationMin` from the start. */
762
+ endField?: keyof TData & string;
763
+ /** Boolean field marking an event as all-day (rendered in the all-day row). */
764
+ allDayField?: keyof TData & string;
765
+ /** Field for the event title. Defaults to the first column's field. */
766
+ titleField?: keyof TData & string;
767
+ /** Field holding a per-event accent color (any CSS color). Else `color`. */
768
+ colorField?: keyof TData & string;
769
+ /** Fallback accent color for every event. */
770
+ color?: string;
771
+ /**
772
+ * Field holding a SECONDARY accent color, rendered as a strip on the LEFT edge
773
+ * of the event - distinct from the main `colorField`. Lets an event encode two
774
+ * dimensions at once (e.g. main color = person, left strip = role).
775
+ */
776
+ secondaryColorField?: keyof TData & string;
777
+ /**
778
+ * Field holding a free/busy status that drives a distinct visual treatment
779
+ * (Outlook-style): `'busy'` (default solid), `'free'` (hollow / outline),
780
+ * `'tentative'` (hatched), `'oof'` / `'outOfOffice'` (distinct tint). Ties to
781
+ * iCal `STATUS`. Unrecognised values render as busy.
782
+ */
783
+ statusField?: keyof TData & string;
784
+ /**
785
+ * Field holding minutes-before-start for a reminder. When set (and the event
786
+ * is upcoming) the scheduler fires `onReminder` once as that lead time is
787
+ * crossed - pair it with a toast. Ties to iCal `VALARM`.
788
+ */
789
+ reminderField?: keyof TData & string;
790
+ /** Fired once when an event's reminder lead time is crossed (see `reminderField`). */
791
+ onReminder?: (row: TData, minutesUntil: number) => void;
792
+ /**
793
+ * Field holding a {@link RecurrenceRule} (or array) - the row renders as one
794
+ * event per matching day in view, keeping its time-of-day + duration.
795
+ */
796
+ recurrenceField?: keyof TData & string;
797
+ /**
798
+ * Field holding an array of {@link SchedulerException} - per-occurrence
799
+ * overrides of a recurring event (a moved / edited / deleted single instance).
800
+ * When set, editing a recurring occurrence offers "This event" vs "All events"
801
+ * and "This event" fires {@link onOccurrenceChange}.
802
+ */
803
+ recurrenceExceptionsField?: keyof TData & string;
804
+ /** Event length in minutes when a row has a start but no `endField`. Default 60. */
805
+ defaultDurationMin?: number;
806
+
807
+ /** Which views to offer in the toolbar. Default all four. */
808
+ views?: ReadonlyArray<SchedulerView>;
809
+ /** The view shown first. Default `'month'`. */
810
+ initialView?: SchedulerView;
811
+ /** The date the calendar opens on. Defaults to "today". */
812
+ initialDate?: Date | number | string;
813
+ /**
814
+ * Controlled anchor date - when this changes the calendar navigates to it (a
815
+ * mini date-picker or external "go to" can drive the view). Pair with
816
+ * {@link onNavigate} for two-way sync.
817
+ */
818
+ date?: Date | number | string;
819
+ /** Fired when the visible date changes (prev / next / today). */
820
+ onNavigate?: (date: Date) => void;
821
+ /** First day of the week, 0-6 (0 = Sunday). Default 0. */
822
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
823
+ /** Time-grid slot size in minutes (week / day snap granularity). Default 30. */
824
+ slotMinutes?: number;
825
+ /**
826
+ * Slot sizes (minutes) offered as a runtime picker in the Week / Day time-grid
827
+ * ruler, e.g. `[60, 30, 15, 5]`. When set, a size selector appears in the
828
+ * toolbar and the ruler subdivides accordingly; the active size starts at
829
+ * `slotMinutes`. Omit to hide the picker (the ruler still uses `slotMinutes`).
830
+ */
831
+ slotSizes?: ReadonlyArray<number>;
832
+ /** First / last hour shown in the time-grid band (0-24). Default 0..24. */
833
+ dayStartHour?: number;
834
+ dayEndHour?: number;
835
+
836
+ // --- booking rules: working hours, non-working days, conflicts -------------
837
+ /**
838
+ * Working-hours window (hours, e.g. `{ start: 9, end: 17 }`). Time outside it
839
+ * is shaded in the Week / Day time-grid. Visual only - see `disableConflicts`
840
+ * to enforce.
841
+ */
842
+ businessHours?: { start: number; end: number };
843
+ /** Weekday numbers (0 = Sun … 6 = Sat) shaded as non-working (e.g. `[0, 6]`). */
844
+ nonWorkingDays?: ReadonlyArray<number>;
845
+ /** Shade elapsed time on today's column (the past is "used up"). */
846
+ shadeUntilNow?: boolean;
847
+ /**
848
+ * Enforce the shaded time: reject a drag / resize / create that lands outside
849
+ * `businessHours` or on a `nonWorkingDays` day (snap back + flash). Without
850
+ * this the shading is a visual hint only.
851
+ */
852
+ restrictToBusinessHours?: boolean;
853
+ /**
854
+ * Prevent double-booking: dragging / resizing / creating an event so it
855
+ * overlaps another event **on the same resource** is rejected and reverted.
856
+ */
857
+ disableConflicts?: boolean;
858
+ /**
859
+ * Hard-blocked hour bands (e.g. a daily maintenance window `[{ start: 12, end: 13 }]`).
860
+ * Unlike `businessHours` these are ALWAYS non-bookable (drop / create rejected,
861
+ * no opt-in needed) and rendered as a distinct restricted (hatched) band.
862
+ */
863
+ restrictedHours?: ReadonlyArray<{ start: number; end: number }>;
864
+ /** Specific calendar dates that are fully blocked (no bookings) - e.g. closures. */
865
+ restrictedDates?: ReadonlyArray<Date | number | string>;
866
+ /**
867
+ * Highlighted dates (holidays, launches …) - a coloured strip + optional label
868
+ * on that day's column / month cell. Decorative; does not block booking.
869
+ */
870
+ specialDates?: ReadonlyArray<{ date: Date | number | string; label?: string; color?: string }>;
871
+ /** Earliest navigable / bookable date. Prev-nav stops here and creates are blocked before it. */
872
+ minDate?: Date | number | string;
873
+ /** Latest navigable / bookable date. Next-nav stops here and creates are blocked after it. */
874
+ maxDate?: Date | number | string;
875
+ /**
876
+ * Cap concurrent events per resource at any moment: a drag / resize / create
877
+ * that would make more than N events overlap on the same resource is rejected.
878
+ */
879
+ maxEventsPerSlot?: number;
880
+ /**
881
+ * Enable **undo / redo** of drag-move + resize with `Ctrl/Cmd+Z` and
882
+ * `Ctrl/Cmd+Shift+Z` (or `Ctrl+Y`). The scheduler re-emits the move/resize
883
+ * callbacks with the reversed values, so your data follows.
884
+ */
885
+ history?: boolean;
886
+ /**
887
+ * Show the current-time indicator - a line across today's column(s) in the
888
+ * Week / Day time-grid and the Day timeline, tracking the local time. On by
889
+ * default; set to `false` to hide it.
890
+ */
891
+ nowIndicator?: boolean;
892
+ /**
893
+ * IANA time zone (e.g. `'America/New_York'`) the whole calendar is shown in -
894
+ * the hour ruler, event positions, day boundaries, all-day grouping and the
895
+ * now-line. Defaults to the browser's local zone. Event `start`/`end` must be
896
+ * instant-unambiguous (UTC / offset ISO or epoch ms) for this to be correct;
897
+ * bare local strings are read as wall-clock in this zone.
898
+ */
899
+ timeZone?: string;
900
+ /**
901
+ * Extra read-only hour rulers for other zones (a "world clock"), shown left of
902
+ * the primary ruler in the Week / Day time-grid. Each entry's `label` heads its
903
+ * column (defaults to a short zone abbreviation).
904
+ */
905
+ secondaryTimeZones?: ReadonlyArray<{ id: string; label?: string }>;
906
+ /**
907
+ * How overlapping time-grid events are laid out. `split` (default) divides the
908
+ * width evenly per collision; `cap` shows up to `maxColumns` then a clickable
909
+ * `+N more` tile; `stack` overlaps them with an offset instead of shrinking.
910
+ */
911
+ collisionMode?: SchedulerCollisionMode;
912
+ /** For `collisionMode: 'cap'`: max side-by-side columns before overflow (min 2). Default 3. */
913
+ maxColumns?: number;
914
+ /** How many days the agenda view spans. Default 30. */
915
+ agendaDays?: number;
916
+
917
+ /**
918
+ * Field whose value groups events by resource (people, rooms, machines). In
919
+ * the Week / Day time-grid the columns split into resource x day groups; a
920
+ * resource filter/legend appears in every view. See {@link SchedulerResource}.
921
+ */
922
+ resourceField?: keyof TData & string;
923
+ /** Explicit, ordered resources (with colors). Omit to derive from the data. */
924
+ resources?: ReadonlyArray<SchedulerResource>;
925
+ /**
926
+ * Time-grid resource grouping order. `false` (default) groups by resource then
927
+ * day (resource-major); `true` groups by day then resource (date-major), like
928
+ * Smart's `groupByDate`. Only affects Week / Day when `resourceField` is set.
929
+ */
930
+ groupByDate?: boolean;
931
+
932
+ /** Timeline views only: width (px) of the left resource-label gutter. Default 160. */
933
+ resourceAreaWidth?: number;
934
+ /** `timelineDay` tick size + move/resize snap, in minutes. Default = `slotMinutes`. */
935
+ timelineSlotMinutes?: number;
936
+ /** Timeline views only: height (px) of one event lane inside a resource row. Default 26. */
937
+ timelineLaneHeight?: number;
938
+
939
+ /** Enable drag-to-move and edge-resize. Without it the calendar is read-only. */
940
+ editable?: boolean;
941
+ /** Fired when an event is dragged to a new time / resource. */
942
+ onEventMove?: (event: SchedulerEventMoveEvent<TData>) => void;
943
+ /** Fired when an event edge is dragged to resize it. */
944
+ onEventResize?: (event: SchedulerEventResizeEvent<TData>) => void;
945
+ /**
946
+ * Fired to create an event - double-clicking an empty slot, or confirming a
947
+ * pending range when no {@link onRangeSelect} is set. `allDay` is `true` when
948
+ * the slot / range is an all-day one (the all-day row, a month day cell, or a
949
+ * multi-day timeline zoom), so the handler can set the `allDayField`.
950
+ */
951
+ onEventAdd?: (start: Date, end: Date, resourceId?: string, allDay?: boolean) => void;
952
+ /**
953
+ * Fired when the event's Delete button is used. Setting this shows a Delete
954
+ * button in the detail drawer (and a `Delete` item is easy to add via
955
+ * `eventMenu`). Remove the row from your data in the handler.
956
+ */
957
+ onEventDelete?: (row: TData) => void;
958
+ /**
959
+ * Fired when a single occurrence of a recurring event is moved / resized /
960
+ * deleted with scope "This event". Merge `event.exception` into the row's
961
+ * `recurrenceExceptionsField` array (keyed by `occurrenceStart`).
962
+ */
963
+ onOccurrenceChange?: (event: SchedulerOccurrenceChangeEvent<TData>) => void;
964
+
965
+ /**
966
+ * Selecting empty cells: click or drag across the time-grid / timeline to mark
967
+ * a time range (and, across days / resources, a rectangle of cells). Arrow keys
968
+ * move the selection and `Shift`+arrows extend it. Marking only *marks* the
969
+ * range - it does NOT create anything. The event is created on an explicit
970
+ * confirm: press `Enter`, or right-click the selection and choose "Add Event".
971
+ * Confirming fires {@link onRangeSelect}, or falls back to `onEventAdd` for the
972
+ * first cell; `Escape` cancels the marker.
973
+ *
974
+ * On by default; set to `false` to disable.
975
+ */
976
+ rangeSelectable?: boolean;
977
+ /**
978
+ * Fired when a pending cell range is confirmed with `Enter` or the "Add Event"
979
+ * context menu (see {@link rangeSelectable}) - not on drag release.
980
+ */
981
+ onRangeSelect?: (selection: SchedulerRangeSelection) => void;
982
+ /**
983
+ * Multi-selecting existing events: Ctrl/Cmd-click toggles, Shift-click
984
+ * range-selects; a plain click clears. Selected events move together when one
985
+ * is dragged, and `Delete` removes them (via `onEventDelete`).
986
+ *
987
+ * On by default; set to `false` to disable.
988
+ */
989
+ eventSelectable?: boolean;
990
+ /** Fired when the set of multi-selected events changes. */
991
+ onEventSelectionChange?: (rows: TData[]) => void;
992
+
993
+ /**
994
+ * An "unscheduled" backlog list shown beside the Week / Day grid: drag an item
995
+ * onto the calendar to schedule it. Each item is `{ id, title, durationMin?,
996
+ * color? }`. Dropping fires {@link onSchedule} with the drop time + resource.
997
+ */
998
+ unscheduled?: ReadonlyArray<{ id: string; title: string; durationMin?: number; color?: string }>;
999
+ /** Optional heading for the unscheduled backlog panel. Default "Unscheduled". */
1000
+ backlogTitle?: string;
1001
+ /** Fired when an unscheduled item is dropped on the grid - create an event from it. */
1002
+ onSchedule?: (item: { id: string; title: string; durationMin?: number; color?: string }, start: Date, resourceId?: string) => void;
1003
+ /**
1004
+ * Fired when an event is dragged OFF the calendar onto the backlog panel -
1005
+ * remove it from the schedule (and typically push it back to `unscheduled`).
1006
+ * Requires the backlog panel (an `unscheduled` list) to be visible.
1007
+ */
1008
+ onUnschedule?: (row: TData) => void;
1009
+
1010
+ /** Custom event body. Receives the row. Omit for the built-in default (title). */
1011
+ event?: Snippet<[TData]>;
1012
+ /**
1013
+ * Hover tooltip for an event. Set a `Snippet<[TData]>` for custom content, or
1014
+ * `true` for the built-in tooltip (title + time + resource). Omit to disable.
1015
+ */
1016
+ tooltip?: boolean | Snippet<[TData]>;
1017
+ /** Delay (ms) before the hover tooltip opens. Default 400. */
1018
+ tooltipDelay?: number;
1019
+ /** Built-in detail drawer: `true` for all fields, or a config object. */
1020
+ drawer?: boolean | SchedulerDrawerConfig<TData>;
1021
+ /** Fired when the drawer / editor is saved. */
1022
+ onEventCommit?: (event: SchedulerEventCommitEvent<TData>) => void;
1023
+ /** Right-click menu for an event. Return items or `undefined` to suppress. */
1024
+ eventMenu?: (row: TData) => MenuItem[] | undefined;
1025
+
1026
+ /** Show the search box (binds to the grid's global filter). Default `true`. */
1027
+ searchable?: boolean;
1028
+ searchPlaceholder?: string;
1029
+ };
1030
+
1031
+ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> = {
1032
+ data: ReadonlyArray<TData>;
1033
+ columns: Array<ColumnDef<TFeatures, TData>>;
1034
+ /**
1035
+ * Kanban board mode. When set, the grid renders its rows as cards in
1036
+ * horizontal lanes (bucketed by `board.groupBy`) instead of a table. See
1037
+ * {@link BoardConfig}.
1038
+ */
1039
+ board?: BoardConfig<TFeatures, TData>;
1040
+ /**
1041
+ * Scheduler / calendar mode. When set, the grid renders its rows as events on
1042
+ * a Month / Week / Day / Agenda calendar instead of a table. See
1043
+ * {@link SchedulerConfig}.
1044
+ */
1045
+ scheduler?: SchedulerConfig<TFeatures, TData>;
1046
+ /**
1047
+ * Chart view. When set, the grid renders its FILTERED + SORTED rows as a chart
1048
+ * instead of a table (search / filters / sort flow through). Unlike board and
1049
+ * scheduler, the renderer is free - the grid lazy-loads a built-in `SvChart`
1050
+ * view, overridable via `registerChartView`. See {@link ChartViewConfig}.
1051
+ */
1052
+ chart?: ChartViewConfig<TFeatures, TData>;
1053
+ /**
1054
+ * Pivot mode. When set (and `pivotMode` is on), the grid renders its rows as a
1055
+ * pivot table in place - the same grid, aggregated across `pivot.rows` /
1056
+ * `pivot.cols` with nested column headers - instead of the flat table. The
1057
+ * pivot ENGINE ships in `@svgrid/enterprise`; call `enablePivot()` (or
1058
+ * `installEnterprise(api)`) to register it, otherwise an upsell note shows.
1059
+ * See {@link GridPivotConfig}.
1060
+ */
1061
+ pivot?: GridPivotConfig<TData>;
1062
+ /**
1063
+ * Whether pivot mode is currently active. Defaults to `true` when `pivot` is
1064
+ * set. Bindable so a toolbar toggle can flip between the pivot and the flat
1065
+ * table over the same data.
1066
+ */
1067
+ pivotMode?: boolean;
1068
+ /** Fired when the in-grid Pivot toggle flips `pivotMode`. */
1069
+ onPivotModeChange?: (on: boolean) => void;
1070
+ /**
1071
+ * Right-click context menu. `true` shows the default item set (copy, cut,
1072
+ * paste, clear, insert row above/below, remove row, remove column). Pass an
1073
+ * array to customize: strings are built-in keys, `"separator"` is a divider,
1074
+ * and objects are custom items. Omitted/`false` disables the menu (native
1075
+ * browser menu shows instead).
1076
+ */
1077
+ contextMenu?: boolean | ReadonlyArray<ContextMenuItem<TData>>;
1078
+ /**
1079
+ * Floating bar that appears over the grid while rows are selected, showing
1080
+ * the count and the actions that apply to the whole selection - the pattern
1081
+ * an issue tracker uses for bulk edit.
1082
+ *
1083
+ * `true` gives the count and a Clear button. An array is the shorthand for
1084
+ * `{ actions }`. Pass {@link SelectionBarConfig} to also set `position`
1085
+ * (`'bottom'` default, or `'top'`), `maxVisible` and `hideClear`. Omitted /
1086
+ * `false` is off.
1087
+ *
1088
+ * Default **off**. This is chrome that floats over your content, not a
1089
+ * gesture: it overlaps a row, and what belongs on it is specific to the app.
1090
+ *
1091
+ * **The prop and its types are free; the bar itself is an Enterprise
1092
+ * feature.** Install `@svgrid/enterprise` and call `enableSelectionBar()`
1093
+ * (or `installEnterprise`, which does it for you) to render it - without
1094
+ * that the grid shows a short upsell note in its place, the same way the
1095
+ * scheduler and board views do.
1096
+ */
1097
+ selectionBar?:
1098
+ | boolean
1099
+ | ReadonlyArray<SelectionBarAction<TData> | SelectionBarBuiltin>
1100
+ | SelectionBarConfig<TData>;
1101
+ /**
1102
+ * The feature set built with `tableFeatures({ ... })`. Optional - the
1103
+ * `sortable` / `filterable` / `groupable` shortcuts below inject the
1104
+ * matching feature for you, so a grid can be configured entirely from
1105
+ * the boolean shortcuts without importing the feature constants.
1106
+ */
1107
+ features?: TFeatures;
1108
+ /**
1109
+ * Convenience shortcuts to switch a whole capability on without wiring
1110
+ * `features` or the finer-grained props by hand. Every capability is OFF
1111
+ * by default - a bare grid is a plain read-only table - so set the
1112
+ * shortcut `true` to opt in. (`false` / omitted both leave it off; the
1113
+ * shortcut is mainly there to turn things ON.)
1114
+ *
1115
+ * `sortable` - column sorting (injects `rowSortingFeature`)
1116
+ * `filterable` - column filtering (injects `columnFilteringFeature`)
1117
+ * `editable` - inline cell editing (alias of `enableInlineEditing`)
1118
+ * `selectable` - cell selection (alias of `enableCellSelection`)
1119
+ * `groupable` - row grouping controls(alias of `showGroupingControls`,
1120
+ * also injects `columnGroupingFeature`)
1121
+ * `pageable` - pagination footer (alias of `showPagination`)
1122
+ *
1123
+ * Fine-grained props (`enableInlineEditing`, `showPagination`, ...) still
1124
+ * work; the shortcut wins only when it is explicitly set.
1125
+ */
1126
+ sortable?: boolean;
1127
+ /**
1128
+ * Click a header to filter that column. Injects `columnFilteringFeature`,
1129
+ * so you do not import it yourself. Which filter surface appears is a
1130
+ * separate question - see `filterMode` (default `'menu'`).
1131
+ *
1132
+ * <SvGrid {data} {columns} filterable />
1133
+ */
1134
+ filterable?: boolean;
1135
+ /**
1136
+ * Inline cell editing. Alias of `enableInlineEditing`, and wins over it when
1137
+ * both are set. A column also needs an `editorType` to be editable; without
1138
+ * one it falls back to a text editor.
1139
+ *
1140
+ * <SvGrid {data} {columns} editable />
1141
+ */
1142
+ editable?: boolean;
1143
+ /**
1144
+ * Cell selection - click a cell to select it, drag or shift-click to extend
1145
+ * the selection to a range. Alias of `enableCellSelection`, and the highest
1146
+ * priority of the three inputs that decide it:
1147
+ * `selectable` -> `enableCellSelection` -> `selectionMode`.
1148
+ *
1149
+ * NOTE the asymmetry with its siblings, which are all off until you opt in:
1150
+ * this one is **ON by default**, because `selectionMode` defaults to
1151
+ * `'both'`. It is named here so the capability is discoverable next to the
1152
+ * other shortcuts, and so `selectable={false}` is a one-word way to turn
1153
+ * cell selection off (the longhand being `selectionMode="none"`, which also
1154
+ * removes the row-selection surface).
1155
+ *
1156
+ * This is the CELL surface only. The selection **checkbox column** is the
1157
+ * other half of `selectionMode`, controlled by `showRowSelection` - also on
1158
+ * by default, and it needs no feature import (verified: the column renders
1159
+ * and toggles rows with an empty `features` set). Use `selectionMode` when
1160
+ * you want to move both surfaces at once.
1161
+ */
1162
+ selectable?: boolean;
1163
+ /**
1164
+ * Client-side tree data: nest rows into a hierarchy by parent id.
1165
+ *
1166
+ * ```svelte
1167
+ * <SvGrid {data} {columns} treeData={{ parentField: 'managerId', column: 'name' }} />
1168
+ * ```
1169
+ *
1170
+ * Unlike grouping, tree rows are real data rows - they keep their cells,
1171
+ * editing and selection, and only gain an expander plus indentation in
1172
+ * `column`. Rows whose parent is missing become roots rather than vanishing.
1173
+ *
1174
+ * For NESTED source data (`children: [...]`), flatten it first with
1175
+ * `flattenTreeData(data, { childrenField: 'children' })` and point
1176
+ * `parentField` at the `__parentId` it stamps on.
1177
+ *
1178
+ * Setting this replaces row grouping - a row cannot be both.
1179
+ */
1180
+ treeData?: {
1181
+ /** Field holding each row's parent id. */
1182
+ parentField: string;
1183
+ /** Field holding the row's own id. Defaults to `'id'`. */
1184
+ idField?: string;
1185
+ /**
1186
+ * Column id that carries the expander + indentation. Defaults to the first
1187
+ * visible column.
1188
+ */
1189
+ column?: string;
1190
+ /** Indent per depth level, in px. Default `12`. */
1191
+ indentPx?: number;
1192
+ };
1193
+ /**
1194
+ * Show the grouping controls: "Group by this column" in the column menu, and
1195
+ * the group panel when `showGroupPanel` is on. Alias of
1196
+ * `showGroupingControls`, and also injects `columnGroupingFeature`.
1197
+ *
1198
+ * This turns on the UI for grouping. To group without asking the user, set
1199
+ * `groupBy` instead.
1200
+ *
1201
+ * <SvGrid {data} {columns} groupable />
1202
+ */
1203
+ groupable?: boolean;
1204
+ /**
1205
+ * Group the rows by these column ids, outermost first - `['region',
1206
+ * 'country']` rolls country up inside region.
1207
+ *
1208
+ * ```svelte
1209
+ * <SvGrid {data} {columns} {features} groupBy={['department']} />
1210
+ * ```
1211
+ *
1212
+ * The prop seeds the group-by list and re-applies whenever it changes, so it
1213
+ * works both as initial state and as a controlled value. The column menu and
1214
+ * `api.setGroupBy()` write the same state; a change from either survives
1215
+ * until this prop's own value changes.
1216
+ *
1217
+ * Ignored when `treeData` is set - a row cannot be both a hierarchy node and
1218
+ * bucketed under a group banner.
1219
+ */
1220
+ groupBy?: ReadonlyArray<string>;
1221
+ /**
1222
+ * Which group / tree rows are expanded, keyed by row id.
1223
+ *
1224
+ * Expansion is owned by the engine by default; pass this prop to hoist it
1225
+ * (saved views, "expand everything on load", persisted UI state). Like
1226
+ * `groupBy` it seeds the state and re-applies whenever it changes.
1227
+ *
1228
+ * Group row ids are built from the grouping path, not the display label:
1229
+ * `group_department_Engineering`, and one level deeper
1230
+ * `group_department_Engineering_role_Senior`. Tree rows key off the engine's
1231
+ * row id instead (set `getRowId` to make that your own id). Prefer capturing
1232
+ * the map from `onExpandedChange` over hand-building these keys.
1233
+ */
1234
+ expanded?: Record<string, boolean>;
1235
+ /**
1236
+ * Fired whenever the expanded set changes - chevron clicks,
1237
+ * `api.setRowExpanded()`, `expandAllGroups()` / `collapseAllGroups()`.
1238
+ * Receives the full next map, so it can be written straight back into
1239
+ * `expanded` for a controlled setup.
1240
+ */
1241
+ onExpandedChange?: (expanded: Record<string, boolean>) => void;
1242
+ /**
1243
+ * Render a subtotal row after each group's children, carrying that group's
1244
+ * aggregate values under the columns they belong to (the columns with an
1245
+ * `aggregate` set). Off by default.
1246
+ *
1247
+ * Footers are inserted after paging, so they never count against `pageSize` -
1248
+ * a page shows its `pageSize` data rows plus whatever footers close on it.
1249
+ */
1250
+ groupFooters?: boolean;
1251
+ /**
1252
+ * Append a grand-total row at the very end, aggregating the whole filtered
1253
+ * set (not just the current page) with each column's `aggregate` function.
1254
+ *
1255
+ * Independent of `groupFooters`: use it on a flat grid for a bottom totals
1256
+ * line, or alongside group subtotals for both. Like group footers it is
1257
+ * appended after paging, so it never counts against `pageSize` - but it is
1258
+ * only appended on the LAST page, so a total never appears mid-dataset.
1259
+ * Columns without an `aggregate` are left blank.
1260
+ */
1261
+ grandTotalRow?: boolean;
1262
+ /**
1263
+ * How grouped rows are displayed.
1264
+ *
1265
+ * - `groupRows` (default): a full-width banner row per group. Unchanged
1266
+ * behaviour - existing grids are untouched.
1267
+ * - `singleColumn`: one synthetic "Group" column holding every level,
1268
+ * indented by depth.
1269
+ * - `multipleColumns`: one synthetic column per grouped field.
1270
+ *
1271
+ * Both column modes hide the grouped source columns, since their values move
1272
+ * into the auto column(s), and render group rows as ordinary rows so their
1273
+ * aggregate cells line up under the real columns.
1274
+ */
1275
+ groupDisplayMode?: GroupDisplayType;
1276
+ /** Header for the combined `singleColumn` auto-group column. Default `"Group"`. */
1277
+ autoGroupColumnHeader?: string;
1278
+ /** Width (px) of each auto-group column. Default `220`. */
1279
+ autoGroupColumnWidth?: number;
1280
+ /**
1281
+ * Show the pagination footer. Alias of `showPagination`, and wins over it
1282
+ * when both are set. Page size starts at `pageSize` (default 10).
1283
+ *
1284
+ * <SvGrid {data} {columns} pageable pageSize={25} />
1285
+ */
1286
+ pageable?: boolean;
1287
+ /**
1288
+ * Show the loading state instead of the rows. By default this replaces the
1289
+ * grid body with "Loading..."; set `loadingOverlay` to keep the current rows
1290
+ * visible under a dimmed overlay instead, which is what you usually want for
1291
+ * a server-paged grid.
1292
+ */
1293
+ loading?: boolean;
1294
+ /**
1295
+ * Render `loading` as a non-blocking overlay instead of replacing the
1296
+ * whole grid: the current rows stay visible (dimmed, with a top progress
1297
+ * bar) during a refetch, and the first load shows shimmer skeleton rows.
1298
+ * Ideal for server-paged grids so paging/sorting doesn't flash. Defaults
1299
+ * to `false` (the classic full "Loading..." replacement).
1300
+ */
1301
+ loadingOverlay?: boolean;
1302
+ /** Skeleton placeholder rows to show on first load. Defaults to 8. */
1303
+ loadingSkeletonRows?: number;
1304
+ /**
1305
+ * Render an error message in place of the rows. `null` or omitted means no
1306
+ * error. Takes precedence over `loading` and over the empty state.
1307
+ */
1308
+ error?: string | null;
1309
+ /**
1310
+ * Text shown when there are no rows to display - either the data is empty or
1311
+ * a filter matched nothing. Defaults to the localized `noRows` string, so
1312
+ * prefer `localization.text.noRows` when you are translating the whole grid.
1313
+ */
1314
+ emptyMessage?: string;
1315
+ /**
1316
+ * The single place to localize the grid. One object with two fields:
1317
+ *
1318
+ * - `locale` - BCP-47 tag(s) for the DATA: accent/case-insensitive filter
1319
+ * matching AND every column's number / currency / percent / date formatting
1320
+ * (when the column's own `format.locales` is unset). The default for
1321
+ * `filterLocale` and per-column format locales.
1322
+ * - `text` - overrides for the grid's own UI STRINGS (empty state, tool panel,
1323
+ * pager, status bar, filter operator labels, context-menu items, upsell
1324
+ * notes). Any subset overrides the English defaults; unset keys stay English.
1325
+ *
1326
+ * ```svelte
1327
+ * <SvGrid localization={{ locale: 'fr-FR', text: { noRows: 'Aucune ligne' } }} />
1328
+ * ```
1329
+ *
1330
+ * Omitting it (or any field) is a no-op. See {@link GridMessages}.
1331
+ */
1332
+ localization?: GridLocalization;
1333
+ /**
1334
+ * Show the single search box that filters across every column. Explicitly
1335
+ * setting this wins over `filterMode`; leaving it unset means it appears only
1336
+ * when `filterMode` is `'global'`.
1337
+ */
1338
+ showGlobalFilter?: boolean;
1339
+ /**
1340
+ * Show the filter section inside each column's menu. Explicitly setting this
1341
+ * wins over `filterMode`; unset, it follows `filterMode` (default `'menu'`,
1342
+ * so this is normally on).
1343
+ *
1344
+ * Setting it `true` also adds the inline "floating filter" input under each
1345
+ * header - that surface requires the explicit opt-in, since it otherwise
1346
+ * duplicates the menu's own filter popover.
1347
+ */
1348
+ showColumnFilters?: boolean;
1349
+ /**
1350
+ * Quick way to pick a single filtering UI. When set it controls which of
1351
+ * the three filter surfaces appears (and is overridden per-surface by the
1352
+ * `showGlobalFilter` / `showColumnFilters` / `showFilterRow` props).
1353
+ * Defaults to `'menu'` (only the column menu's filter section is shown).
1354
+ */
1355
+ filterMode?: "row" | "menu" | "global" | "none";
1356
+ /**
1357
+ * Show the grouping affordances (the column menu's "Group by this column",
1358
+ * and the group panel). The `groupable` shortcut sets this and registers the
1359
+ * grouping feature in one go; prefer that unless you have already registered
1360
+ * `columnGroupingFeature` yourself.
1361
+ */
1362
+ showGroupingControls?: boolean;
1363
+ /**
1364
+ * Show the row-selection checkbox column, including the select-all checkbox
1365
+ * in the header. Unset, it follows `selectionMode` (default `'both'`, so
1366
+ * row selection is on).
1367
+ */
1368
+ showRowSelection?: boolean;
1369
+ /**
1370
+ * Show the pagination footer. Off by default. `pageable` is the shortcut
1371
+ * alias and wins when both are set.
1372
+ */
1373
+ showPagination?: boolean;
1374
+ /** Initial page size when pagination is enabled. Defaults to 10. */
1375
+ pageSize?: number;
1376
+ /** Page-size choices shown in the footer's selector. Defaults to `[10, 25, 50, 100]`. */
1377
+ pageSizeOptions?: number[];
1378
+ /**
1379
+ * Where the pagination footer sits: `'bottom'` (default), `'top'`, or `'both'`.
1380
+ * The status bar (when enabled) always stays at the bottom.
1381
+ */
1382
+ paginationPosition?: 'top' | 'bottom' | 'both';
1383
+ /**
1384
+ * Server-side pagination. When `true`, the grid renders its native
1385
+ * pagination footer from the `rowCount` / `pageIndex` you provide (rather
1386
+ * than counting the local rows), does NOT slice `data` (the rows you pass are
1387
+ * treated as the current page), and emits `onPaginationChange` when the user
1388
+ * pages or changes page size. Pair with `externalSort` / `externalFilter`
1389
+ * and a server data source. Requires `showPagination` / `pageable` to show
1390
+ * the footer. Controlled: you own `pageIndex` + `pageSize` + `rowCount`.
1391
+ */
1392
+ externalPagination?: boolean;
1393
+ /** Total rows on the server, for the footer's range + page count. Used with `externalPagination`. */
1394
+ rowCount?: number;
1395
+ /** Current 0-based page index. Used with `externalPagination` (controlled). */
1396
+ pageIndex?: number;
1397
+ /**
1398
+ * Fires when the user changes page or page size while `externalPagination`
1399
+ * is on. Fetch that page and update `data` / `rowCount` / `pageIndex`.
1400
+ */
1401
+ onPaginationChange?: (pagination: { pageIndex: number; pageSize: number }) => void;
1402
+ /**
1403
+ * Render only the rows in view instead of all of them. **On by default** -
1404
+ * this is what keeps a 100,000-row grid responsive.
1405
+ *
1406
+ * Turn it off when a row's height cannot be known up front and must not be
1407
+ * clipped, such as a variable-height master-detail panel. Expect the DOM to
1408
+ * hold every row when you do.
1409
+ */
1410
+ virtualization?: boolean;
1411
+ /** Row height in pixels. Pass a function `(rowIndex) => px` for
1412
+ * per-row variable heights (e.g. an interactive row-resize feature).
1413
+ * Defaults to 30. */
1414
+ rowHeight?: number | ((rowIndex: number) => number);
1415
+ /**
1416
+ * Size each row to its own content instead of a fixed height: cell text wraps
1417
+ * and the row grows to fit the tallest cell. Rows are measured after they
1418
+ * render, so this works with virtualization - `rowHeight` (or 30) is the
1419
+ * estimate used before a row has been measured, which keeps the scrollbar
1420
+ * stable while you scroll into new rows.
1421
+ *
1422
+ * Costs a measurement pass per row, so prefer a fixed `rowHeight` when your
1423
+ * content is uniform. Ignored when `rowHeight` is a function (you are already
1424
+ * supplying per-row heights).
1425
+ */
1426
+ autoRowHeight?: boolean;
1427
+ /**
1428
+ * Let the user drag a row's bottom edge to change its height. **Off by
1429
+ * default**, because a resizable row needs somewhere to grab and most grids
1430
+ * do not want a drag target on every row.
1431
+ *
1432
+ * The grid remembers the heights itself, so this works as a bare boolean -
1433
+ * no `rowHeight` function required. Drag, or focus the grip and use Up/Down
1434
+ * (Shift for 1px steps).
1435
+ *
1436
+ * Turning this on also turns on the **row header column** ({@link
1437
+ * showRowNumbers}), because that is where the grip lives and where a
1438
+ * spreadsheet puts it - a drag target on the edge of a data cell works but
1439
+ * reads as an accident. An explicit `showRowNumbers={false}` still wins; the
1440
+ * grip then falls back to the row's first cell, and a column of your own
1441
+ * carrying `cellClass: 'sv-row-gutter'` is used ahead of either.
1442
+ *
1443
+ * Ignored under `autoRowHeight`, where the content decides the height and a
1444
+ * manual one would immediately be overwritten. For full control of the
1445
+ * heights - persisting them, sharing them between grids - pass a
1446
+ * function-valued {@link rowHeight} and use the `rowResize` action directly.
1447
+ */
1448
+ rowResize?: boolean;
1449
+ /**
1450
+ * Height (px) of a single column-header level row. With multi-level
1451
+ * (grouped) headers the total header height is `levels * headerHeight`,
1452
+ * since each level renders as its own row. When omitted, header rows size
1453
+ * to their content (the default). Does not affect the filter row.
1454
+ */
1455
+ headerHeight?: number;
1456
+ /**
1457
+ * Extra rows rendered above and below the viewport, so fast scrolling does
1458
+ * not reach empty space before the next batch renders. Defaults to 8.
1459
+ * Raise it for very tall rows, lower it to trim DOM work.
1460
+ */
1461
+ overscan?: number;
1462
+ /**
1463
+ * Height of the grid's scrollable shell. A number is treated as pixels;
1464
+ * a string is used as-is, so callers can pass `'100%'` or `'auto'` to
1465
+ * make the grid fill its parent. Defaults to 520 px.
1466
+ */
1467
+ containerHeight?: number | string;
1468
+ /**
1469
+ * Render only the columns in view, the horizontal counterpart of
1470
+ * `virtualization`. **On by default**, which is what makes a 100-column grid
1471
+ * scroll smoothly.
1472
+ *
1473
+ * It recycles column DOM nodes, so it cannot coexist with sticky pinned
1474
+ * columns - turn it off if you need pinning to survive horizontal scrolling.
1475
+ */
1476
+ columnVirtualization?: boolean;
1477
+ /**
1478
+ * Extra columns rendered either side of the viewport when
1479
+ * `columnVirtualization` is on. Defaults to 3.
1480
+ */
1481
+ columnOverscan?: number;
1482
+ /**
1483
+ * Fallback width in pixels for columns whose `ColumnDef` sets no `width`.
1484
+ * Defaults to 140.
1485
+ */
1486
+ columnWidth?: number;
1487
+ /**
1488
+ * Columns pinned to the left/right edge on mount. Each entry is a
1489
+ * column id (matches `ColumnDef.field` when no explicit id is set).
1490
+ * The internal pinning state is seeded once at mount; user-driven
1491
+ * pinning via the column menu still works and overrides this default.
1492
+ * Requires `columnVirtualization={false}` to be visible in the menu
1493
+ * UI (sticky positioning can't co-exist with column virtualization
1494
+ * since the virtualizer recycles DOM nodes).
1495
+ */
1496
+ initialColumnPinning?: {
1497
+ left?: ReadonlyArray<string>;
1498
+ right?: ReadonlyArray<string>;
1499
+ };
1500
+ /**
1501
+ * When `true`, columns are scaled proportionally so their total width
1502
+ * fills the viewport (no empty space on the right). Disabled by
1503
+ * default - explicit `width` values are used as-is. User resizes still
1504
+ * win once they happen.
1505
+ */
1506
+ fitColumns?: boolean;
1507
+ /**
1508
+ * Let the user drag a column's edge to change its width. **Off by default**,
1509
+ * so `width` means the width you asked for until you say otherwise.
1510
+ *
1511
+ * Turn it on for grids the reader is meant to arrange - a spreadsheet, a
1512
+ * dense report, anything with columns whose content varies in length. Leave
1513
+ * it off for layouts you control, and for columns that must keep their size:
1514
+ * a row-number gutter, a checkbox column, an icon column.
1515
+ *
1516
+ * It is grid-wide rather than per-column: there is no `resizable: false` on a
1517
+ * single column definition. `api.autosizeColumn()`, `fitColumns` and
1518
+ * programmatic width changes work either way - this only governs the drag
1519
+ * handle.
1520
+ *
1521
+ * The handles come from the `columnResize` action, loaded on demand: a grid
1522
+ * that leaves this off never fetches that code.
1523
+ */
1524
+ columnResize?: boolean;
1525
+ /**
1526
+ * Make the grid usable on narrow screens. When the grid's own width drops
1527
+ * below the breakpoint (default `640`px), pinned columns are un-pinned so the
1528
+ * whole grid pans, `fitColumns` scaling is suspended (columns keep their
1529
+ * natural widths and scroll), touch panning is smoothed, and columns whose
1530
+ * `hideBelow` exceeds the width are hidden. `true` uses the default
1531
+ * breakpoint; pass `{ breakpoint }` to change it. Off by default.
1532
+ */
1533
+ responsive?: boolean | { breakpoint?: number };
1534
+ /**
1535
+ * @deprecated Has no effect - nothing in the grid reads this prop. It is kept
1536
+ * only so existing code keeps compiling. The column menu's filter section is
1537
+ * controlled by `showColumnFilters`, or by `filterMode="menu"` (the default).
1538
+ */
1539
+ showFilterMenu?: boolean;
1540
+ /**
1541
+ * Show the always-visible filter row under the header. Explicitly setting
1542
+ * this wins over `filterMode`; unset, it appears only when `filterMode` is
1543
+ * `'row'`.
1544
+ */
1545
+ showFilterRow?: boolean;
1546
+ /**
1547
+ * Cell selection - click to select, drag or shift-click to extend to a range,
1548
+ * which is what clipboard copy and the range fill handle operate on. Unset,
1549
+ * it follows `selectionMode` (default `'both'`, so this is on). `selectable`
1550
+ * is the shortcut alias and wins over it.
1551
+ */
1552
+ enableCellSelection?: boolean;
1553
+ /**
1554
+ * Excel-style drag-and-drop of a selected cell range: grab the range's
1555
+ * border and drag it somewhere else to MOVE the values there, or hold
1556
+ * Ctrl (Cmd on macOS) to COPY them instead. The modifier is read at drop
1557
+ * time, so it can be pressed or released mid-drag.
1558
+ *
1559
+ * On by default whenever cell selection is on, matching the fill handle.
1560
+ * Set `false` to keep a border pointerdown starting a fresh selection, which
1561
+ * is what it did before this existed.
1562
+ *
1563
+ * The grab strip is the outer 4px of the range border, so a pointerdown
1564
+ * anywhere further inside still starts a new selection. A drop is refused
1565
+ * outright - nothing changes - when the destination would fall outside the
1566
+ * grid, or when any source or destination cell is read-only. It does not
1567
+ * move the part that fits and silently drop the rest.
1568
+ */
1569
+ moveCells?: boolean;
1570
+ /**
1571
+ * Highlight the row under the pointer. Default **false** - the hover tint can
1572
+ * compete with the cell selection / fill marquee. Set `true` to opt in; when
1573
+ * on, the hover no longer paints over selected cells so the selection stays
1574
+ * visible.
1575
+ */
1576
+ enableRowHover?: boolean;
1577
+ /**
1578
+ * Prepend a header row (the column labels) to copied cell ranges, so pasting
1579
+ * into Excel / Sheets includes the headers. Applies per copied range.
1580
+ */
1581
+ copyHeadersToClipboard?: boolean;
1582
+ /**
1583
+ * Transform each cell value on its way to the clipboard - e.g. strip
1584
+ * currency symbols, expand codes to labels, or redact. Receives the display
1585
+ * value plus the row/column context; return the string (or value) to copy.
1586
+ */
1587
+ processCellForClipboard?: (params: {
1588
+ value: unknown;
1589
+ column: unknown;
1590
+ row: TData;
1591
+ rowIndex: number;
1592
+ columnId: string;
1593
+ }) => unknown;
1594
+ /**
1595
+ * Inline cell editing: F2 or double-click opens an editor in the active cell,
1596
+ * Enter commits, Esc cancels. Off by default.
1597
+ *
1598
+ * A column still needs an `editorType` to pick its editor (text, number,
1599
+ * date, checkbox, list, ...); without one it gets a plain text editor.
1600
+ * `editable` is the shortcut alias and wins over this.
1601
+ */
1602
+ enableInlineEditing?: boolean;
1603
+ /**
1604
+ * Full-row editing. When `true`, starting an edit puts the WHOLE row into
1605
+ * edit mode - every editable cell shows an inline editor at once - and a
1606
+ * single Enter (or focus leaving the row) commits all of them; Esc cancels
1607
+ * the whole row. Requires `enableInlineEditing`. The full-row editor covers
1608
+ * text / number / date / datetime / checkbox / list-select editor types.
1609
+ */
1610
+ fullRowEditing?: boolean;
1611
+ /**
1612
+ * Append a sticky footer row aggregating every filtered row: the sum of a
1613
+ * numeric column, `Count: N` otherwise. Choose a different aggregate per
1614
+ * column with that column's own `summary` option, or set it to `false` there
1615
+ * to leave the cell blank.
1616
+ *
1617
+ * Off by default. `summary` is the shortcut alias and wins when both are set.
1618
+ *
1619
+ * <SvGrid {data} {columns} summary />
1620
+ */
1621
+ enableRowSummaries?: boolean;
1622
+ /**
1623
+ * Shortcut alias for {@link enableRowSummaries}. Wins over it when both are
1624
+ * set, the same precedence `selectable` has over `enableCellSelection`.
1625
+ */
1626
+ summary?: boolean;
1627
+ /**
1628
+ * Excel-style status bar under the grid showing live aggregates of the
1629
+ * selected cell range (count, numeric count, sum, average, min, max).
1630
+ * `true` shows the default set; pass `{ aggregates: [...] }` to choose
1631
+ * which. Requires `enableCellSelection`.
1632
+ */
1633
+ statusBar?:
1634
+ | boolean
1635
+ | {
1636
+ aggregates?: ReadonlyArray<
1637
+ "count" | "numericCount" | "sum" | "avg" | "min" | "max"
1638
+ >;
1639
+ };
1640
+ /**
1641
+ * Show the docked tool panel - the enterprise sidebar with Columns and
1642
+ * Filters tabs. A "Columns & Filters" button appears in a toolbar above the
1643
+ * grid; the panel docks on the right edge.
1644
+ */
1645
+ toolPanel?: boolean;
1646
+ /**
1647
+ * Integrated charting: `true` for the zero-config docked chart panel, or a
1648
+ * {@link ChartingConfig} object to author defaults + advanced options.
1649
+ */
1650
+ charting?: boolean | ChartingConfig<TData>;
1651
+ /**
1652
+ * Render the header column menu (⋮) as a tabbed popover - **General**,
1653
+ * **Filter**, and **Columns** tabs (the tabbed layout). Defaults to `false`,
1654
+ * which keeps the flat menu (actions list + "Choose columns" submenu).
1655
+ */
1656
+ columnMenuTabs?: boolean;
1657
+ /** Open the tool panel on first render (instead of collapsed). */
1658
+ toolPanelDefaultOpen?: boolean;
1659
+ /** Which tab the tool panel starts on. Defaults to `'columns'`. */
1660
+ toolPanelDefaultTab?: "columns" | "filters";
1661
+ /**
1662
+ * Quick way to pick which selection surfaces are active. `'row'` shows the
1663
+ * selection checkbox column only, `'cell'` allows rectangle/range cell
1664
+ * selection only, `'both'` (default) enables both, `'none'` disables both.
1665
+ * Overridden per-surface by `showRowSelection` / `enableCellSelection`.
1666
+ */
1667
+ selectionMode?: "row" | "cell" | "both" | "none";
1668
+ /**
1669
+ * Render a leading row-number column (1-based) before any selection
1670
+ * column. Useful as a permanent anchor when scrolling wide grids.
1671
+ */
1672
+ showRowNumbers?: boolean;
1673
+ /**
1674
+ * Paint alternating data rows with the `--sg-row-alt-bg` color (zebra
1675
+ * striping). Only data rows stripe - pinned, group, detail, and summary
1676
+ * rows keep their single background. Defaults to `false`.
1677
+ */
1678
+ zebraRows?: boolean;
1679
+ /**
1680
+ * Width (px) of the row-number column. Defaults to 56, which fits up
1681
+ * to "99,999"; bump this when the dataset crosses six digits so the
1682
+ * largest row number stays fully visible at the bottom of a scroll.
1683
+ */
1684
+ rowNumberWidth?: number;
1685
+ /** Receives the imperative grid API once the component has mounted. */
1686
+ onApiReady?: (api: SvGridApi<TFeatures, TData>) => void;
1687
+ /**
1688
+ * Fires whenever the row-selection state changes. The first argument
1689
+ * is the new selection record `{ [rowId]: true }`; the second is the
1690
+ * array of selected `TData` rows.
1691
+ */
1692
+ onRowSelectionChange?: (
1693
+ selection: Record<string, boolean>,
1694
+ rows: TData[],
1695
+ ) => void;
1696
+ /**
1697
+ * Fires whenever the cell-selection rectangle changes (mouse, keyboard,
1698
+ * or `api.selectCells()`). `ranges` matches `api.getSelected()` -
1699
+ * `[rowStart, colStart, rowEnd, colEnd]` rectangles in grid coords.
1700
+ * Empty array when the user clears the selection.
1701
+ */
1702
+ onCellSelectionChange?: (
1703
+ ranges: Array<[number, number, number, number]>,
1704
+ ) => void;
1705
+ /**
1706
+ * When `true`, the grid records sort state (and renders sort indicators
1707
+ * + cycling on headers) but does NOT actually re-order the rows. The
1708
+ * consumer is expected to sort `data` themselves - typically via
1709
+ * `onSortingChange`. Use this for tree/hierarchical data, where a flat
1710
+ * global sort would break parent-child adjacency. Defaults to `false`.
1711
+ */
1712
+ externalSort?: boolean;
1713
+ /**
1714
+ * Fires whenever the sort clauses change. Receives the new array of
1715
+ * `{ id, desc }` entries. Pair with `externalSort={true}` when the
1716
+ * consumer wants to own the row ordering.
1717
+ */
1718
+ onSortingChange?: (sorting: Array<{ id: string; desc: boolean }>) => void;
1719
+ /**
1720
+ * The sort state to start in - `{ id, desc }` entries. Use with `externalSort`
1721
+ * when the initial ordering is decided server-side (e.g. a URL `?sort=` param
1722
+ * read in a SvelteKit `load`), so the header sort indicators match the already-
1723
+ * sorted data on first render. Applied once at mount; user sorting takes over.
1724
+ */
1725
+ initialSorting?: Array<{ id: string; desc: boolean }>;
1726
+ /**
1727
+ * The advanced-filter expression to start in (Pro). Applied once at mount;
1728
+ * change it afterwards through `api.setAdvancedFilter()`.
1729
+ *
1730
+ * Filtering only happens once `@svgrid/enterprise`'s `enableAdvancedFilter()`
1731
+ * has registered a compiler - without it the expression is stored and
1732
+ * reported but no rows are removed, so the free grid degrades to a no-op
1733
+ * rather than to a wrong row set.
1734
+ */
1735
+ initialAdvancedFilter?: GridPredicateExpr | null;
1736
+ /**
1737
+ * Fires whenever the advanced-filter expression changes, whatever changed it:
1738
+ * `api.setAdvancedFilter()`, `clearAllFilters()`, or the toolbar's clear
1739
+ * control.
1740
+ *
1741
+ * The panel that authors the expression is mounted by you, outside the grid,
1742
+ * so it cannot see a change the grid made on its own. Without this, clearing
1743
+ * from the toolbar leaves that panel showing a filter the grid is no longer
1744
+ * applying. Feed this back into the panel's `expression` prop to keep them
1745
+ * agreeing.
1746
+ */
1747
+ onAdvancedFilterChange?: (expr: GridPredicateExpr | null) => void;
1748
+ /**
1749
+ * When `true`, the grid still records column-filter / global-filter /
1750
+ * facet state (so the menu UI works and indicators light up) but does
1751
+ * NOT actually filter the rows. The consumer is expected to fetch / sort
1752
+ * / filter the data themselves - typically via `onFiltersChange`. Used
1753
+ * by server-side data sources. Defaults to `false`.
1754
+ */
1755
+ externalFilter?: boolean;
1756
+ /**
1757
+ * Fires whenever any of the in-grid filter state changes - global
1758
+ * search, per-column operator filters, or facet (value-checklist)
1759
+ * filters. Pair with `externalFilter={true}` when the consumer wants to
1760
+ * push the query to the server.
1761
+ */
1762
+ onFiltersChange?: (filters: {
1763
+ global: string;
1764
+ columns: Array<{
1765
+ id: string;
1766
+ operator: FilterOperator;
1767
+ value: string;
1768
+ /**
1769
+ * Upper bound for the `between` operator. Only set when
1770
+ * `operator === 'between'` AND the user has typed both values.
1771
+ */
1772
+ valueTo?: string;
1773
+ selectedValues?: Array<string>;
1774
+ }>;
1775
+ }) => void;
1776
+ /**
1777
+ * Fires when an inline edit is committed (Enter / Tab / blur). Useful
1778
+ * for cascade-recompute pipelines: a parent listens, then refreshes
1779
+ * derived columns or aggregates. The wrapper has already written the
1780
+ * parsed value back into the row by the time this fires.
1781
+ */
1782
+ /**
1783
+ * Resolve a stable id per row. Drives selection, expansion, edit,
1784
+ * and active-cell state. When omitted, the row's array index is
1785
+ * used - fine for read-only views but the wrong choice if `data`
1786
+ * gets reordered or filtered outside the grid (selection would
1787
+ * follow positions, not actual rows). Use a database PK, a UUID,
1788
+ * or any stable string.
1789
+ */
1790
+ getRowId?: (row: TData, index: number) => string;
1791
+ /**
1792
+ * Conditional class(es) added to every `<tr>` body row. Receives
1793
+ * the row's `original` data + its data-array index. Return a
1794
+ * string, an array of strings, or an object mapping class names to
1795
+ * booleans. Useful for "highlight overdue rows", "tint cancelled
1796
+ * orders", and similar row-level state mappings.
1797
+ */
1798
+ rowClass?: (ctx: {
1799
+ row: TData;
1800
+ rowIndex: number;
1801
+ }) => string | ReadonlyArray<string> | Record<string, boolean> | undefined | null;
1802
+ /**
1803
+ * Per-cell notes - longer free-form comments shown as a corner
1804
+ * indicator + tooltip on hover. Keyed by row id then column id;
1805
+ * empty / missing entries mean "no note". The grid owns rendering;
1806
+ * you own storage (write your own callbacks to add / edit notes).
1807
+ */
1808
+ notes?: Record<string, Record<string, string>>;
1809
+ /**
1810
+ * Allow editing per-cell notes/comments through the UI: the context menu
1811
+ * gains an "Edit comment" item that opens a popover editor. Edits are
1812
+ * applied to an internal overlay for immediate feedback and emitted via
1813
+ * `onNoteChange` so you can persist them back into `notes`.
1814
+ */
1815
+ editableComments?: boolean;
1816
+ /** Fires when a comment is saved or removed (removed = empty `note`). */
1817
+ onNoteChange?: (event: { rowId: string; columnId: string; note: string }) => void;
1818
+ /**
1819
+ * Excel-style conditional formatting. A list of value-driven rules that
1820
+ * color cells: `colorScale` (gradient across the column range),
1821
+ * `dataBar` (in-cell proportional bar), `iconSet` (arrows / traffic /
1822
+ * triangles by threshold), and `rule` (apply a style when a predicate
1823
+ * matches). Scope a format to specific columns with `columns: [...]`,
1824
+ * or omit it to apply to every column. Later entries win on conflict.
1825
+ */
1826
+ conditionalFormats?: ReadonlyArray<ConditionalFormat<TData>>;
1827
+ /**
1828
+ * Which rows feed the min/max range that `colorScale` / `dataBar` formats
1829
+ * scale against.
1830
+ *
1831
+ * - `filtered` (default): every row that survives the filters, ignoring the
1832
+ * page slice. The scale follows what you filtered to but does not shift
1833
+ * when you page, so the same value keeps the same colour on page 1 and
1834
+ * page 2.
1835
+ * - `visible`: only the rows currently on screen. Rescales per page - use it
1836
+ * when you want each page's heat map normalized to that page.
1837
+ * - `all`: the full unfiltered dataset, for a scale that stays put as you
1838
+ * filter.
1839
+ */
1840
+ conditionalStatScope?: "filtered" | "visible" | "all";
1841
+ /**
1842
+ * Fires after an inline edit commits, with the cell's old and new value and
1843
+ * the row it belongs to. This is where you persist the change.
1844
+ *
1845
+ * The grid has already applied the edit to its own state by the time this
1846
+ * runs, so it is a notification, not a veto - reject a value with the
1847
+ * column's `valueParser` or a validation rule instead.
1848
+ */
1849
+ onCellValueChange?: (event: {
1850
+ rowIndex: number;
1851
+ columnId: string;
1852
+ oldValue: unknown;
1853
+ newValue: unknown;
1854
+ row: TData;
1855
+ }) => void;
1856
+ /**
1857
+ * Fires whenever the active cell changes - click, keyboard move,
1858
+ * tab, page-up/down, etc. Consumers (toolbars, ribbon UIs) use this
1859
+ * to stay synced with the grid's selection without polling the DOM.
1860
+ */
1861
+ onActiveCellChange?: (cell: {
1862
+ rowIndex: number;
1863
+ colIndex: number;
1864
+ columnId: string;
1865
+ }) => void;
1866
+ /**
1867
+ * Fires when a data cell (and therefore a row) is single-clicked.
1868
+ * Group-header rows are excluded. `value` is the displayed cell value.
1869
+ */
1870
+ onCellClick?: (event: {
1871
+ rowIndex: number;
1872
+ colIndex: number;
1873
+ columnId: string;
1874
+ value: unknown;
1875
+ row: TData;
1876
+ }) => void;
1877
+ /** Fires when a data row is single-clicked (any cell). Group rows excluded. */
1878
+ onRowClick?: (event: {
1879
+ rowIndex: number;
1880
+ columnId: string;
1881
+ row: TData;
1882
+ }) => void;
1883
+ /**
1884
+ * Fires when a data cell is double-clicked - independent of whether the
1885
+ * cell is editable, so it fires even on read-only grids. Group rows excluded.
1886
+ */
1887
+ onCellDoubleClick?: (event: {
1888
+ rowIndex: number;
1889
+ colIndex: number;
1890
+ columnId: string;
1891
+ value: unknown;
1892
+ row: TData;
1893
+ }) => void;
1894
+ /** Fires when a data row is double-clicked (any cell). Group rows excluded. */
1895
+ onRowDoubleClick?: (event: {
1896
+ rowIndex: number;
1897
+ columnId: string;
1898
+ row: TData;
1899
+ }) => void;
1900
+ /**
1901
+ * Fires once each time the body is scrolled to (within ~32px of) the
1902
+ * bottom. Re-arms after the user scrolls back up. The canonical hook for
1903
+ * infinite / lazy loading - append more rows to `data` when it fires.
1904
+ */
1905
+ onScrollBottomReached?: (event: {
1906
+ scrollTop: number;
1907
+ scrollHeight: number;
1908
+ clientHeight: number;
1909
+ }) => void;
1910
+ /**
1911
+ * Marks a row as an expandable "detail row". When this returns true the
1912
+ * grid renders that row as a SINGLE full-width cell (colspan across every
1913
+ * column) using `renderDetailRow`, instead of the normal per-column cells
1914
+ * - the canonical Stripe / GitHub "expand a rich panel beneath the row"
1915
+ * pattern. Insert the detail rows into `data` yourself (typically right
1916
+ * after the row they belong to) and toggle them with your own expanded
1917
+ * state. Pair with `virtualization={false}` so the variable-height detail
1918
+ * isn't clipped by the fixed-row-height virtualizer.
1919
+ */
1920
+ isDetailRow?: (row: TData, rowIndex: number) => boolean;
1921
+ /**
1922
+ * Snippet rendered inside the full-width detail cell for rows where
1923
+ * `isDetailRow` is true. Receives the row's data and its index.
1924
+ */
1925
+ renderDetailRow?: Snippet<[{ row: TData; rowIndex: number }]>;
1926
+ /**
1927
+ * Server-side group / tree keyboard + accessibility, built into the grid. When
1928
+ * set, the grid uses the treegrid role and marks matching rows with
1929
+ * `aria-level` / `aria-expanded`, and ArrowRight / ArrowLeft expand / collapse
1930
+ * the focused group row (no app-level key handling). Pair with `serverGroupRows`
1931
+ * + `SvGroupCell` for the visual expander. Every accessor receives the row data.
1932
+ */
1933
+ serverGroup?: {
1934
+ /** Whether a row is an expandable group / branch. */
1935
+ isGroup: (row: TData) => boolean;
1936
+ /** Tree depth of the row (0 = top level), for `aria-level`. */
1937
+ level: (row: TData) => number;
1938
+ /** Whether an expandable row is currently expanded. */
1939
+ expanded?: (row: TData) => boolean;
1940
+ /** Expand / collapse a group row. Called on ArrowRight / ArrowLeft. */
1941
+ onToggle: (row: TData) => void;
1942
+ };
1943
+ /**
1944
+ * Server-side set-filter values. When set, a column's filter checklist is
1945
+ * populated by fetching the distinct values from the server (once per column,
1946
+ * cached) instead of deriving them from the loaded page - so the checklist
1947
+ * shows every value, not just those on screen. Return the distinct string
1948
+ * values for the column id.
1949
+ */
1950
+ serverFilterValues?: (columnId: string) => Promise<string[]>;
1951
+ /**
1952
+ * Rows to pin to the TOP of the grid - rendered above the regular
1953
+ * rows and sticky-positioned so they stay visible while the user
1954
+ * scrolls. Typical use: a "totals" or "headline" row that should
1955
+ * always be in view. Rows are read-only (no inline editing, no
1956
+ * row-selection checkbox). They share the column schema with the
1957
+ * main grid; field/format/cell/cellClass all apply.
1958
+ */
1959
+ pinnedTopRows?: ReadonlyArray<TData>;
1960
+ /**
1961
+ * Rows to pin to the BOTTOM of the grid - rendered below the regular
1962
+ * rows and sticky-positioned (sticks to the bottom of the viewport
1963
+ * while the user scrolls). Typical use: a "page totals" or "grand
1964
+ * total" row computed from `getDisplayedRows()`.
1965
+ */
1966
+ pinnedBottomRows?: ReadonlyArray<TData>;
1967
+ /**
1968
+ * Enables drag-to-reorder on the grid's column headers. When `true`,
1969
+ * every header gets `draggable=true` and a drop indicator paints
1970
+ * between headers during a drag. On drop the grid mutates its
1971
+ * internal column order and fires `onColumnOrderChange` with the
1972
+ * new order. Defaults to `false`.
1973
+ */
1974
+ enableColumnReorder?: boolean;
1975
+ /**
1976
+ * Initial column order, by `id` (falls back to `field`). When the
1977
+ * user reorders columns, this is the starting state. After mount,
1978
+ * the grid owns the order internally and emits `onColumnOrderChange`
1979
+ * on every change - persist that to `localStorage` to restore.
1980
+ */
1981
+ columnOrder?: ReadonlyArray<string>;
1982
+ /** Fires every time the column order changes (drag or `api.setColumnOrder`). */
1983
+ onColumnOrderChange?: (order: ReadonlyArray<string>) => void;
1984
+ /**
1985
+ * Infer each column's data type (number / boolean / date / ISO date-string /
1986
+ * text) from the first data row, for columns that declare neither an
1987
+ * explicit `editorType` nor a `cellDataType`. Sets the matching editor,
1988
+ * alignment, date format, and filter operators automatically. Explicit
1989
+ * column config always wins. Defaults to `false`.
1990
+ */
1991
+ inferColumnTypes?: boolean;
1992
+ /**
1993
+ * Enables managed row dragging. When `true`, every row becomes a drag
1994
+ * source (grab cursor + a grip in the row-number cell) and a drop
1995
+ * indicator paints between rows during a drag. On drop the grid mutates
1996
+ * its own internal data - reordering within the grid, or moving the row
1997
+ * across grids that share the same {@link rowDragGroup}. Defaults to
1998
+ * `false`.
1999
+ */
2000
+ rowDragManaged?: boolean;
2001
+ /**
2002
+ * Connection group for cross-grid row dragging. Grids that share the same
2003
+ * non-empty `rowDragGroup` string (and have `rowDragManaged` on) can
2004
+ * exchange rows: dragging a row out of one and dropping it into another
2005
+ * removes it from the source and inserts it into the target. Omit to keep
2006
+ * dragging confined to reordering within a single grid.
2007
+ */
2008
+ rowDragGroup?: string;
2009
+ /**
2010
+ * Fires on the TARGET grid after a managed row drag settles, with the
2011
+ * moved row, its landing index, whether it stayed in the same grid, and
2012
+ * the source / target grid ids. Use it to mirror the move into your own
2013
+ * state (persistence, server sync). The grid has already applied the
2014
+ * change to its internal data by the time this fires.
2015
+ */
2016
+ onRowDragEnd?: (event: {
2017
+ row: TData;
2018
+ toIndex: number;
2019
+ sameGrid: boolean;
2020
+ fromGridId: number;
2021
+ toGridId: number;
2022
+ }) => void;
2023
+ /**
2024
+ * Align this grid with others that share the same non-empty
2025
+ * `alignedGridGroup` string: horizontal scroll and column-resize widths are
2026
+ * kept in lockstep across every grid in the group. Use for a totals/header
2027
+ * grid above a body grid, or side-by-side comparison grids that must line up.
2028
+ * The grids should declare the same columns (matched by id) for widths to map.
2029
+ */
2030
+ alignedGridGroup?: string;
2031
+ /**
2032
+ * BCP-47 locale tag (or array of fallbacks) used for accent- and
2033
+ * case-insensitive text filtering / sorting / search. Powered by
2034
+ * `Intl.Collator` with `sensitivity: 'base'`, so "cafe", "Café"
2035
+ * and "CAFÉ" all match "cafe" without strain. Defaults to the
2036
+ * browser's locale.
2037
+ */
2038
+ filterLocale?: string | ReadonlyArray<string>;
2039
+ };
2040
+
2041
+ /**
2042
+ * The grid's single localization surface (see {@link Props.localization}):
2043
+ * `locale` handles the data (filter matching + number/date formatting) and
2044
+ * `text` handles the UI strings.
2045
+ */
2046
+ export type GridLocalization = {
2047
+ /** BCP-47 tag(s) for filter matching + number / date formatting. */
2048
+ locale?: string | ReadonlyArray<string>;
2049
+ /** Overrides for the grid's own UI strings. */
2050
+ text?: Partial<GridMessages>;
2051
+ };
2052
+
2053
+ export type SelectionPoint = { rowIndex: number; colIndex: number };
2054
+ export type SelectionRange = {
2055
+ anchor: SelectionPoint | null;
2056
+ focus: SelectionPoint | null;
2057
+ };
2058
+ export type CellEditState = {
2059
+ rowId: string;
2060
+ columnId: string;
2061
+ editorType: CellEditorType;
2062
+ value: unknown;
2063
+ /**
2064
+ * The row's underlying data object, captured when the edit started. The
2065
+ * commit path resolves the row by id first; this is the fallback for when
2066
+ * the row has left the row model mid-edit (a filter typed into the filter
2067
+ * row while an editor is open), so the typed value still lands instead of
2068
+ * being silently dropped.
2069
+ */
2070
+ rowRef?: unknown;
2071
+ } | null;
2072
+ export type FilterOperator =
2073
+ | "contains"
2074
+ | "notContains"
2075
+ | "equals"
2076
+ | "notEquals"
2077
+ | "startsWith"
2078
+ | "endsWith"
2079
+ | "regex"
2080
+ | "in"
2081
+ | "notIn"
2082
+ | "greaterThan"
2083
+ | "lessThan"
2084
+ | "between"
2085
+ | "isBlank"
2086
+ | "isNotBlank";
2087
+ export type FilterOption = {
2088
+ value: FilterOperator;
2089
+ label: string;
2090
+ iconName: string;
2091
+ };
2092
+ export type MenuPosition = { x: number; y: number };