@svgrid/grid 2.6.17 → 2.6.18

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