@svgrid/grid 2.6.19 → 2.6.21

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 (65) hide show
  1. package/dist/SvGrid.controller.svelte.d.ts +1 -0
  2. package/dist/SvGrid.controller.svelte.js +64 -2
  3. package/dist/SvGrid.svelte +2 -1
  4. package/dist/SvGrid.types.d.ts +150 -0
  5. package/dist/ai.d.ts +28 -0
  6. package/dist/ai.js +6 -0
  7. package/dist/cdn/{GridMenus-B0F9iBrG.js → GridMenus-BfTAKn84.js} +1 -1
  8. package/dist/cdn/{GridMenus-IHK_l7m6.js → GridMenus-C3bJd7w8.js} +1 -1
  9. package/dist/cdn/{src-Cd0tearp.js → src-BYq-qyrp.js} +1012 -999
  10. package/dist/cdn/{src-B1TdiyS8.js → src-DBel9wRZ.js} +1324 -1311
  11. package/dist/cdn/svgrid.js +1 -1
  12. package/dist/cdn/svgrid.svelte-external.js +1 -1
  13. package/dist/cdn/validate-_CDJzgIo.js +75 -0
  14. package/dist/cell-formatting.d.ts +2 -0
  15. package/dist/cell-formatting.js +2 -0
  16. package/dist/chart-export.d.ts +1 -0
  17. package/dist/chart.d.ts +31 -5
  18. package/dist/chart.js +9 -3
  19. package/dist/core.d.ts +197 -0
  20. package/dist/core.js +72 -0
  21. package/dist/createTree.svelte.d.ts +3 -0
  22. package/dist/createTree.svelte.js +1 -0
  23. package/dist/datetime/date-core.d.ts +2 -0
  24. package/dist/datetime/date-restrict.d.ts +1 -0
  25. package/dist/datetime/timezone.d.ts +1 -0
  26. package/dist/dock-manager-model.d.ts +3 -0
  27. package/dist/dock-manager-model.js +1 -0
  28. package/dist/dock-model.d.ts +6 -0
  29. package/dist/dock-model.js +3 -0
  30. package/dist/editor-contract.d.ts +1 -0
  31. package/dist/list-option.d.ts +1 -0
  32. package/dist/positioning.d.ts +2 -0
  33. package/dist/scheduler-ical.d.ts +1 -0
  34. package/dist/scheduler-model.d.ts +1 -0
  35. package/dist/summaries.js +22 -0
  36. package/dist/svgrid-wrapper.types.d.ts +5 -0
  37. package/dist/toast-store.svelte.d.ts +4 -0
  38. package/dist/validate.d.ts +50 -0
  39. package/dist/validate.js +187 -0
  40. package/package.json +4 -1
  41. package/src/SvGrid.controller.svelte.ts +68 -2
  42. package/src/SvGrid.svelte +2 -1
  43. package/src/SvGrid.types.ts +150 -0
  44. package/src/ai.ts +28 -0
  45. package/src/cell-formatting.ts +2 -0
  46. package/src/chart-export.ts +1 -0
  47. package/src/chart.ts +31 -5
  48. package/src/core.ts +207 -0
  49. package/src/createTree.svelte.ts +3 -0
  50. package/src/datetime/date-core.ts +2 -0
  51. package/src/datetime/date-restrict.ts +1 -0
  52. package/src/datetime/timezone.ts +1 -0
  53. package/src/dock-manager-model.ts +3 -0
  54. package/src/dock-model.ts +6 -0
  55. package/src/editor-contract.ts +1 -0
  56. package/src/list-option.ts +1 -0
  57. package/src/positioning.ts +2 -0
  58. package/src/scheduler-ical.ts +1 -0
  59. package/src/scheduler-model.ts +1 -0
  60. package/src/summaries.ts +21 -0
  61. package/src/svgrid-wrapper.types.ts +5 -0
  62. package/src/svgrid.summaries.test.ts +217 -0
  63. package/src/toast-store.svelte.ts +4 -0
  64. package/src/validate.test.ts +207 -0
  65. package/src/validate.ts +269 -0
@@ -160,6 +160,7 @@ export declare function createSvGridController<TFeatures extends TableFeatures =
160
160
  readonly showColumnFiltersEffective: boolean;
161
161
  readonly showInlineColumnFilterEffective: boolean;
162
162
  readonly showRowSelectionEffective: boolean;
163
+ readonly rowSummariesEnabled: boolean;
163
164
  readonly enableCellSelectionEffective: boolean;
164
165
  readonly flushScheduledScrollSync: () => void;
165
166
  readonly scheduleScrollSync: (scrollTop: number, scrollLeft: number) => void;
@@ -1,6 +1,7 @@
1
1
  import { applyGroupAggregate, applyRowPredicate, compileExcelFilter, getAdvancedFilterEngine, normalizeForFilter, createColumnVirtualizer, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createTreeRowModel, createSvelteVirtualizer, createSortedRowModel, createSvGrid, getGridCellDomId, sortFns, } from "./index.js";
2
2
  import { createRowScrollScaling, resolveMaxDomHeight, } from "./virtualization/scroll-scaling.js";
3
3
  import { buildPreMeasureItems } from "./virtualization/virtualizer.js";
4
+ import { DEV } from "esm-env";
4
5
  import "./sv-grid-scrollbar.js";
5
6
  import { computeColumnStat, formatsNeedingStats, formatNeedsStats, } from "./conditional-formatting.js";
6
7
  import { rawToNumber, } from "./SvGrid.helpers.js";
@@ -407,6 +408,14 @@ export function createSvGridController(rawProps, domIdBase) {
407
408
  props.enableCellSelection ??
408
409
  ((props.selectionMode ?? "both") === "cell" ||
409
410
  (props.selectionMode ?? "both") === "both"));
411
+ // The aggregate footer row. `summary` is the shortcut alias, so it wins over
412
+ // the fine-grained prop - the same precedence `selectable` uses.
413
+ //
414
+ // It starts OFF. It used to default ON, which meant a plain
415
+ // `<SvGrid {data} {columns} />` grew a totals row nobody asked for, and every
416
+ // caller that did not want one had to say so: 375 call sites in this repo
417
+ // passed `enableRowSummaries={false}` against 6 that opted in.
418
+ const rowSummariesEnabled = $derived(props.summary ?? props.enableRowSummaries ?? false);
410
419
  // Internal source-of-truth for data and column defs. Seeded from props and
411
420
  // re-synced whenever the parent passes a new array; the imperative API
412
421
  // mutates these so add/remove operations don't need a callback round-trip.
@@ -2216,7 +2225,7 @@ export function createSvGridController(rawProps, domIdBase) {
2216
2225
  const eagerSummaries = $derived.by(() => {
2217
2226
  if (!summarize)
2218
2227
  return null;
2219
- if (!(props.enableRowSummaries ?? true))
2228
+ if (!rowSummariesEnabled)
2220
2229
  return null;
2221
2230
  const rows = allRows;
2222
2231
  const columns = allColumns;
@@ -2241,7 +2250,7 @@ export function createSvGridController(rawProps, domIdBase) {
2241
2250
  void editedCellValues;
2242
2251
  const rows = allRows;
2243
2252
  const columns = allColumns;
2244
- if (!(props.enableRowSummaries ?? true)) {
2253
+ if (!rowSummariesEnabled) {
2245
2254
  deferredSummaries = {};
2246
2255
  return;
2247
2256
  }
@@ -3012,6 +3021,7 @@ export function createSvGridController(rawProps, domIdBase) {
3012
3021
  get showColumnFiltersEffective() { return showColumnFiltersEffective; },
3013
3022
  get showInlineColumnFilterEffective() { return showInlineColumnFilterEffective; },
3014
3023
  get showRowSelectionEffective() { return showRowSelectionEffective; },
3024
+ get rowSummariesEnabled() { return rowSummariesEnabled; },
3015
3025
  get enableCellSelectionEffective() { return enableCellSelectionEffective; },
3016
3026
  get flushScheduledScrollSync() { return flushScheduledScrollSync; },
3017
3027
  get scheduleScrollSync() { return scheduleScrollSync; },
@@ -3460,6 +3470,58 @@ export function createSvGridController(rawProps, domIdBase) {
3460
3470
  const { register: registerAlignedGrid, broadcastScroll: broadcastAlignedScroll, broadcastWidths: broadcastAlignedWidths } = createAlignedGrids(ctx);
3461
3471
  const { buildApi } = createGridApi(ctx);
3462
3472
  const { readCellRaw, writeCellRaw, applyFillPattern, clearSelectedCellValues, startFillDrag, onFillPointerMove, onFillPointerUp, toggleBooleanCell, copySelectionToClipboard, clearSelectedCells, cutSelectionToClipboard } = createClipboard(ctx);
3473
+ // Dev-time configuration checks. Silent misconfiguration was the grid's
3474
+ // biggest usability gap - a misspelled `field` rendered a column of blank
3475
+ // cells and printed nothing, and an inert `pageSize` was simply ignored.
3476
+ //
3477
+ // `validateGridConfig` is pure (see validate.ts) so it can be unit-tested;
3478
+ // this only decides when to run it, and prints each distinct message once.
3479
+ //
3480
+ // It is loaded with `import()` rather than a static import so the checks live
3481
+ // in a lazy chunk. The base bundle is size-budgeted and already sits at its
3482
+ // limit, so a static import cost ~1 KB gzip that a production app would carry
3483
+ // and never execute.
3484
+ //
3485
+ // `DEV` comes from `esm-env` because the alternatives do not work here:
3486
+ // `process.env.NODE_ENV` is undefined in Vite's browser runtime (the checks
3487
+ // silently never ran), and Vite's own flag makes svelte-package warn that it
3488
+ // only works for Vite consumers. esm-env resolves through export conditions,
3489
+ // so it is correct in dev and folds to `false` in a production build. It is
3490
+ // already a direct dependency of Svelte, so it adds nothing to an install.
3491
+ if (DEV) {
3492
+ const warnedConfig = new Set();
3493
+ $effect(() => {
3494
+ // Read the reactive values synchronously so the effect tracks them; the
3495
+ // module load below is async and would otherwise register no dependencies.
3496
+ const snapshot = {
3497
+ data: internalData,
3498
+ columns: internalColumns,
3499
+ features: resolveEffectiveFeatures(),
3500
+ sortable: props.sortable,
3501
+ pageable: props.pageable,
3502
+ showPagination: props.showPagination,
3503
+ pageSize: props.pageSize,
3504
+ groupBy: props.groupBy,
3505
+ treeData: props.treeData,
3506
+ initialColumnPinning: props.initialColumnPinning,
3507
+ columnVirtualization: props.columnVirtualization,
3508
+ externalPagination: props.externalPagination,
3509
+ rowCount: props.rowCount,
3510
+ externalSort: props.externalSort,
3511
+ onSortingChange: props.onSortingChange,
3512
+ externalFilter: props.externalFilter,
3513
+ onFiltersChange: props.onFiltersChange,
3514
+ };
3515
+ void import("./validate.js").then(({ validateGridConfig }) => {
3516
+ for (const message of validateGridConfig(snapshot)) {
3517
+ if (warnedConfig.has(message))
3518
+ continue;
3519
+ warnedConfig.add(message);
3520
+ console.warn(message);
3521
+ }
3522
+ });
3523
+ });
3524
+ }
3463
3525
  // Aligned grids: register in the shared group on mount, and mirror column
3464
3526
  // resizes to peers whenever columnWidths changes. Horizontal-scroll mirroring
3465
3527
  // is driven from onBodyScroll (via ctx.broadcastAlignedScroll).
@@ -184,6 +184,7 @@
184
184
  ctrl.showInlineColumnFilterEffective,
185
185
  );
186
186
  const showRowSelectionEffective = $derived(ctrl.showRowSelectionEffective);
187
+ const rowSummariesEnabled = $derived(ctrl.rowSummariesEnabled);
187
188
  const grid = $derived(ctrl.grid);
188
189
  const allColumns = $derived(ctrl.allColumns);
189
190
  const headerGroups = $derived(ctrl.headerGroups);
@@ -2519,7 +2520,7 @@
2519
2520
  {/each}
2520
2521
  </tbody>
2521
2522
  {/if}
2522
- {#if opt.enableRowSummaries ?? true}
2523
+ {#if rowSummariesEnabled}
2523
2524
  <!-- svelte-ignore a11y_no_redundant_roles -->
2524
2525
  <tfoot class="sv-grid-foot" role="rowgroup">
2525
2526
  <tr
@@ -993,7 +993,21 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
993
993
  * work; the shortcut wins only when it is explicitly set.
994
994
  */
995
995
  sortable?: boolean;
996
+ /**
997
+ * Click a header to filter that column. Injects `columnFilteringFeature`,
998
+ * so you do not import it yourself. Which filter surface appears is a
999
+ * separate question - see `filterMode` (default `'menu'`).
1000
+ *
1001
+ * <SvGrid {data} {columns} filterable />
1002
+ */
996
1003
  filterable?: boolean;
1004
+ /**
1005
+ * Inline cell editing. Alias of `enableInlineEditing`, and wins over it when
1006
+ * both are set. A column also needs an `editorType` to be editable; without
1007
+ * one it falls back to a text editor.
1008
+ *
1009
+ * <SvGrid {data} {columns} editable />
1010
+ */
997
1011
  editable?: boolean;
998
1012
  /**
999
1013
  * Cell selection - click a cell to select it, drag or shift-click to extend
@@ -1045,6 +1059,16 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1045
1059
  /** Indent per depth level, in px. Default `12`. */
1046
1060
  indentPx?: number;
1047
1061
  };
1062
+ /**
1063
+ * Show the grouping controls: "Group by this column" in the column menu, and
1064
+ * the group panel when `showGroupPanel` is on. Alias of
1065
+ * `showGroupingControls`, and also injects `columnGroupingFeature`.
1066
+ *
1067
+ * This turns on the UI for grouping. To group without asking the user, set
1068
+ * `groupBy` instead.
1069
+ *
1070
+ * <SvGrid {data} {columns} groupable />
1071
+ */
1048
1072
  groupable?: boolean;
1049
1073
  /**
1050
1074
  * Group the rows by these column ids, outermost first - `['region',
@@ -1122,7 +1146,19 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1122
1146
  autoGroupColumnHeader?: string;
1123
1147
  /** Width (px) of each auto-group column. Default `220`. */
1124
1148
  autoGroupColumnWidth?: number;
1149
+ /**
1150
+ * Show the pagination footer. Alias of `showPagination`, and wins over it
1151
+ * when both are set. Page size starts at `pageSize` (default 10).
1152
+ *
1153
+ * <SvGrid {data} {columns} pageable pageSize={25} />
1154
+ */
1125
1155
  pageable?: boolean;
1156
+ /**
1157
+ * Show the loading state instead of the rows. By default this replaces the
1158
+ * grid body with "Loading..."; set `loadingOverlay` to keep the current rows
1159
+ * visible under a dimmed overlay instead, which is what you usually want for
1160
+ * a server-paged grid.
1161
+ */
1126
1162
  loading?: boolean;
1127
1163
  /**
1128
1164
  * Render `loading` as a non-blocking overlay instead of replacing the
@@ -1134,7 +1170,16 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1134
1170
  loadingOverlay?: boolean;
1135
1171
  /** Skeleton placeholder rows to show on first load. Defaults to 8. */
1136
1172
  loadingSkeletonRows?: number;
1173
+ /**
1174
+ * Render an error message in place of the rows. `null` or omitted means no
1175
+ * error. Takes precedence over `loading` and over the empty state.
1176
+ */
1137
1177
  error?: string | null;
1178
+ /**
1179
+ * Text shown when there are no rows to display - either the data is empty or
1180
+ * a filter matched nothing. Defaults to the localized `noRows` string, so
1181
+ * prefer `localization.text.noRows` when you are translating the whole grid.
1182
+ */
1138
1183
  emptyMessage?: string;
1139
1184
  /**
1140
1185
  * The single place to localize the grid. One object with two fields:
@@ -1154,7 +1199,21 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1154
1199
  * Omitting it (or any field) is a no-op. See {@link GridMessages}.
1155
1200
  */
1156
1201
  localization?: GridLocalization;
1202
+ /**
1203
+ * Show the single search box that filters across every column. Explicitly
1204
+ * setting this wins over `filterMode`; leaving it unset means it appears only
1205
+ * when `filterMode` is `'global'`.
1206
+ */
1157
1207
  showGlobalFilter?: boolean;
1208
+ /**
1209
+ * Show the filter section inside each column's menu. Explicitly setting this
1210
+ * wins over `filterMode`; unset, it follows `filterMode` (default `'menu'`,
1211
+ * so this is normally on).
1212
+ *
1213
+ * Setting it `true` also adds the inline "floating filter" input under each
1214
+ * header - that surface requires the explicit opt-in, since it otherwise
1215
+ * duplicates the menu's own filter popover.
1216
+ */
1158
1217
  showColumnFilters?: boolean;
1159
1218
  /**
1160
1219
  * Quick way to pick a single filtering UI. When set it controls which of
@@ -1163,8 +1222,23 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1163
1222
  * Defaults to `'menu'` (only the column menu's filter section is shown).
1164
1223
  */
1165
1224
  filterMode?: "row" | "menu" | "global" | "none";
1225
+ /**
1226
+ * Show the grouping affordances (the column menu's "Group by this column",
1227
+ * and the group panel). The `groupable` shortcut sets this and registers the
1228
+ * grouping feature in one go; prefer that unless you have already registered
1229
+ * `columnGroupingFeature` yourself.
1230
+ */
1166
1231
  showGroupingControls?: boolean;
1232
+ /**
1233
+ * Show the row-selection checkbox column, including the select-all checkbox
1234
+ * in the header. Unset, it follows `selectionMode` (default `'both'`, so
1235
+ * row selection is on).
1236
+ */
1167
1237
  showRowSelection?: boolean;
1238
+ /**
1239
+ * Show the pagination footer. Off by default. `pageable` is the shortcut
1240
+ * alias and wins when both are set.
1241
+ */
1168
1242
  showPagination?: boolean;
1169
1243
  /** Initial page size when pagination is enabled. Defaults to 10. */
1170
1244
  pageSize?: number;
@@ -1197,6 +1271,14 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1197
1271
  pageIndex: number;
1198
1272
  pageSize: number;
1199
1273
  }) => void;
1274
+ /**
1275
+ * Render only the rows in view instead of all of them. **On by default** -
1276
+ * this is what keeps a 100,000-row grid responsive.
1277
+ *
1278
+ * Turn it off when a row's height cannot be known up front and must not be
1279
+ * clipped, such as a variable-height master-detail panel. Expect the DOM to
1280
+ * hold every row when you do.
1281
+ */
1200
1282
  virtualization?: boolean;
1201
1283
  /** Row height in pixels. Pass a function `(rowIndex) => px` for
1202
1284
  * per-row variable heights (e.g. an interactive row-resize feature).
@@ -1221,6 +1303,11 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1221
1303
  * to their content (the default). Does not affect the filter row.
1222
1304
  */
1223
1305
  headerHeight?: number;
1306
+ /**
1307
+ * Extra rows rendered above and below the viewport, so fast scrolling does
1308
+ * not reach empty space before the next batch renders. Defaults to 8.
1309
+ * Raise it for very tall rows, lower it to trim DOM work.
1310
+ */
1224
1311
  overscan?: number;
1225
1312
  /**
1226
1313
  * Height of the grid's scrollable shell. A number is treated as pixels;
@@ -1228,8 +1315,24 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1228
1315
  * make the grid fill its parent. Defaults to 520 px.
1229
1316
  */
1230
1317
  containerHeight?: number | string;
1318
+ /**
1319
+ * Render only the columns in view, the horizontal counterpart of
1320
+ * `virtualization`. **On by default**, which is what makes a 100-column grid
1321
+ * scroll smoothly.
1322
+ *
1323
+ * It recycles column DOM nodes, so it cannot coexist with sticky pinned
1324
+ * columns - turn it off if you need pinning to survive horizontal scrolling.
1325
+ */
1231
1326
  columnVirtualization?: boolean;
1327
+ /**
1328
+ * Extra columns rendered either side of the viewport when
1329
+ * `columnVirtualization` is on. Defaults to 3.
1330
+ */
1232
1331
  columnOverscan?: number;
1332
+ /**
1333
+ * Fallback width in pixels for columns whose `ColumnDef` sets no `width`.
1334
+ * Defaults to 140.
1335
+ */
1233
1336
  columnWidth?: number;
1234
1337
  /**
1235
1338
  * Columns pinned to the left/right edge on mount. Each entry is a
@@ -1262,8 +1365,24 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1262
1365
  responsive?: boolean | {
1263
1366
  breakpoint?: number;
1264
1367
  };
1368
+ /**
1369
+ * @deprecated Has no effect - nothing in the grid reads this prop. It is kept
1370
+ * only so existing code keeps compiling. The column menu's filter section is
1371
+ * controlled by `showColumnFilters`, or by `filterMode="menu"` (the default).
1372
+ */
1265
1373
  showFilterMenu?: boolean;
1374
+ /**
1375
+ * Show the always-visible filter row under the header. Explicitly setting
1376
+ * this wins over `filterMode`; unset, it appears only when `filterMode` is
1377
+ * `'row'`.
1378
+ */
1266
1379
  showFilterRow?: boolean;
1380
+ /**
1381
+ * Cell selection - click to select, drag or shift-click to extend to a range,
1382
+ * which is what clipboard copy and the range fill handle operate on. Unset,
1383
+ * it follows `selectionMode` (default `'both'`, so this is on). `selectable`
1384
+ * is the shortcut alias and wins over it.
1385
+ */
1267
1386
  enableCellSelection?: boolean;
1268
1387
  /**
1269
1388
  * Highlight the row under the pointer. Default **false** - the hover tint can
@@ -1289,6 +1408,14 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1289
1408
  rowIndex: number;
1290
1409
  columnId: string;
1291
1410
  }) => unknown;
1411
+ /**
1412
+ * Inline cell editing: F2 or double-click opens an editor in the active cell,
1413
+ * Enter commits, Esc cancels. Off by default.
1414
+ *
1415
+ * A column still needs an `editorType` to pick its editor (text, number,
1416
+ * date, checkbox, list, ...); without one it gets a plain text editor.
1417
+ * `editable` is the shortcut alias and wins over this.
1418
+ */
1292
1419
  enableInlineEditing?: boolean;
1293
1420
  /**
1294
1421
  * Full-row editing. When `true`, starting an edit puts the WHOLE row into
@@ -1298,7 +1425,22 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1298
1425
  * text / number / date / datetime / checkbox / list-select editor types.
1299
1426
  */
1300
1427
  fullRowEditing?: boolean;
1428
+ /**
1429
+ * Append a sticky footer row aggregating every filtered row: the sum of a
1430
+ * numeric column, `Count: N` otherwise. Choose a different aggregate per
1431
+ * column with that column's own `summary` option, or set it to `false` there
1432
+ * to leave the cell blank.
1433
+ *
1434
+ * Off by default. `summary` is the shortcut alias and wins when both are set.
1435
+ *
1436
+ * <SvGrid {data} {columns} summary />
1437
+ */
1301
1438
  enableRowSummaries?: boolean;
1439
+ /**
1440
+ * Shortcut alias for {@link enableRowSummaries}. Wins over it when both are
1441
+ * set, the same precedence `selectable` has over `enableCellSelection`.
1442
+ */
1443
+ summary?: boolean;
1302
1444
  /**
1303
1445
  * Excel-style status bar under the grid showing live aggregates of the
1304
1446
  * selected cell range (count, numeric count, sum, average, min, max).
@@ -1514,6 +1656,14 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
1514
1656
  * filter.
1515
1657
  */
1516
1658
  conditionalStatScope?: "filtered" | "visible" | "all";
1659
+ /**
1660
+ * Fires after an inline edit commits, with the cell's old and new value and
1661
+ * the row it belongs to. This is where you persist the change.
1662
+ *
1663
+ * The grid has already applied the edit to its own state by the time this
1664
+ * runs, so it is a notification, not a veto - reject a value with the
1665
+ * column's `valueParser` or a validation rule instead.
1666
+ */
1517
1667
  onCellValueChange?: (event: {
1518
1668
  rowIndex: number;
1519
1669
  columnId: string;
package/dist/ai.d.ts CHANGED
@@ -34,6 +34,7 @@ type ExportFormat = 'xlsx' | 'xls' | 'pdf' | 'csv' | 'tsv' | 'html' | 'json' | '
34
34
  * provider eventually returns a string we can parse.
35
35
  */
36
36
  export type AIProvider = (request: AIRequest) => Promise<string>;
37
+ /** One call out to the model, as the grid builds it. Providers receive this. */
37
38
  export type AIRequest = {
38
39
  /** Full prompt the grid built for the model. Already includes column
39
40
  * schema and any sampled rows where applicable. */
@@ -51,6 +52,7 @@ export type AIRequest = {
51
52
  * Useful for routing small jobs to a cheaper model. */
52
53
  maxOutputTokens?: number;
53
54
  };
55
+ /** Which helper produced a request - carried on {@link AIRequest} for routing and telemetry. */
54
56
  export type AITask = 'filter' | 'smart-fill' | 'summarize' | 'classify' | 'export' | 'anomaly' | 'chart';
55
57
  /**
56
58
  * Register the model adapter every AI call will route through. Call once
@@ -58,17 +60,22 @@ export type AITask = 'filter' | 'smart-fill' | 'summarize' | 'classify' | 'expor
58
60
  * throwing "no provider" errors.
59
61
  */
60
62
  export declare function setAIProvider(p: AIProvider | null): void;
63
+ /** The provider registered with `setAIProvider`, or null when none is. */
61
64
  export declare function getAIProvider(): AIProvider | null;
65
+ /** Whether an AI provider is registered. Gate AI affordances on this so the UI stays honest. */
62
66
  export declare function hasAIProvider(): boolean;
67
+ /** One condition in a filter plan: a column, a comparison, and the value to match. */
63
68
  export type AIFilterClause = {
64
69
  field: string;
65
70
  operator: 'contains' | 'equals' | 'startsWith' | 'greaterThan' | 'lessThan' | 'isBlank';
66
71
  value?: string;
67
72
  };
73
+ /** One ordering clause in a filter plan. */
68
74
  export type AISortClause = {
69
75
  field: string;
70
76
  desc: boolean;
71
77
  };
78
+ /** A natural-language query turned into filters and sorting, plus the model's reasoning. */
72
79
  export type AIFilterResult = {
73
80
  filters: AIFilterClause[];
74
81
  sort: AISortClause[];
@@ -76,6 +83,7 @@ export type AIFilterResult = {
76
83
  * Surface this in the UI so the user can confirm or undo. */
77
84
  rationale: string;
78
85
  };
86
+ /** Options for `aiFilter` - preview the plan, or apply it straight to the grid. */
79
87
  export type AIFilterOptions = {
80
88
  /**
81
89
  * When true, the helper not only RETURNS the plan but also applies it
@@ -92,10 +100,12 @@ export type AIFilterOptions = {
92
100
  * names without hallucinating.
93
101
  */
94
102
  export declare function aiFilter<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, query: string, opts?: AIFilterOptions): Promise<AIFilterResult>;
103
+ /** One worked example teaching smart-fill what to produce for a row. */
95
104
  export type AISmartFillExample = {
96
105
  input: Record<string, unknown>;
97
106
  output: unknown;
98
107
  };
108
+ /** Proposed values for the blank cells of one column, each with a confidence score. */
99
109
  export type AISmartFillResult<TValue = unknown> = {
100
110
  field: string;
101
111
  predictions: Array<{
@@ -105,6 +115,7 @@ export type AISmartFillResult<TValue = unknown> = {
105
115
  }>;
106
116
  rationale: string;
107
117
  };
118
+ /** Options for `aiSmartFill` - which column to fill, which rows, and the examples to learn from. */
108
119
  export type AISmartFillOptions = {
109
120
  /** Target column - the one whose values we want filled. */
110
121
  field: string;
@@ -128,6 +139,7 @@ export type AISmartFillOptions = {
128
139
  * accept-per-cell UX with confidence-coloured highlights.
129
140
  */
130
141
  export declare function aiSmartFill<TFeatures extends TableFeatures, TData extends RowData, TValue = unknown>(api: SvGridApi<TFeatures, TData>, opts: AISmartFillOptions): Promise<AISmartFillResult<TValue>>;
142
+ /** What to summarise: one row, the selection, a group, or the whole set. */
131
143
  export type AISummarizeTarget = {
132
144
  kind: 'row';
133
145
  rowIndex: number;
@@ -141,6 +153,7 @@ export type AISummarizeTarget = {
141
153
  field: string;
142
154
  value: unknown;
143
155
  };
156
+ /** A generated summary: prose, bullets, and the columns the model leaned on. */
144
157
  export type AISummary = {
145
158
  text: string;
146
159
  bullets: string[];
@@ -148,6 +161,7 @@ export type AISummary = {
148
161
  * story it just told. UI can highlight those columns. */
149
162
  highlightedFields: string[];
150
163
  };
164
+ /** Options for `aiSummarize` - the target, and optionally the question to answer. */
151
165
  export type AISummarizeOptions = {
152
166
  target: AISummarizeTarget;
153
167
  /** Optional question the user is trying to answer. Helps the model
@@ -161,6 +175,7 @@ export type AISummarizeOptions = {
161
175
  * summary stays representative without blowing the context window.
162
176
  */
163
177
  export declare function aiSummarize<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, opts: AISummarizeOptions): Promise<AISummary>;
178
+ /** Options for `aiClassify` - the column to label and the categories to choose from. */
164
179
  export type AIClassifyOptions = {
165
180
  /** Column whose free-text we're classifying. */
166
181
  inputField: string;
@@ -174,6 +189,7 @@ export type AIClassifyOptions = {
174
189
  targetRowIndices?: number[];
175
190
  signal?: AbortSignal;
176
191
  };
192
+ /** Proposed category labels per row, with the model's reasoning. */
177
193
  export type AIClassifyResult = {
178
194
  inputField: string;
179
195
  outputField: string;
@@ -190,6 +206,7 @@ export type AIClassifyResult = {
190
206
  * values it can write straight back into the grid.
191
207
  */
192
208
  export declare function aiClassify<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, opts: AIClassifyOptions): Promise<AIClassifyResult>;
209
+ /** An export the model derived from a request: format, columns, and scope. */
193
210
  export type AIExportPlan = {
194
211
  format: ExportFormat;
195
212
  filters: AIFilterClause[];
@@ -198,6 +215,7 @@ export type AIExportPlan = {
198
215
  /** Plain-English explanation of how the model read the request. */
199
216
  rationale: string;
200
217
  };
218
+ /** Options for `aiExport` - preview the plan, or run the export it describes. */
201
219
  export type AIExportOptions = {
202
220
  /**
203
221
  * Also apply the filter / sort / grouping to the grid (mutating the view) so
@@ -219,6 +237,7 @@ export type AIExportOptions = {
219
237
  * so the UI can show what it did (or preview it first with `run: false`).
220
238
  */
221
239
  export declare function aiExport<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, query: string, opts?: AIExportOptions): Promise<AIExportPlan>;
240
+ /** One flagged value, with why it stands out and how strongly. */
222
241
  export type AIAnomaly = {
223
242
  /** Index into the SCANNED rows (target order), when the model pins one row. */
224
243
  rowIndex?: number;
@@ -227,10 +246,12 @@ export type AIAnomaly = {
227
246
  reason: string;
228
247
  severity: 'low' | 'medium' | 'high';
229
248
  };
249
+ /** Everything an anomaly scan flagged across the rows it looked at. */
230
250
  export type AIAnomalyResult = {
231
251
  anomalies: AIAnomaly[];
232
252
  summary: string;
233
253
  };
254
+ /** Options for `aiFindAnomalies` - which rows and columns to scan. */
234
255
  export type AIAnomalyOptions = {
235
256
  /** Which rows to scan. Defaults to the whole dataset. */
236
257
  target?: AISummarizeTarget;
@@ -245,7 +266,9 @@ export type AIAnomalyOptions = {
245
266
  * export just those".
246
267
  */
247
268
  export declare function aiFindAnomalies<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, opts?: AIAnomalyOptions): Promise<AIAnomalyResult>;
269
+ /** Chart shapes the model may choose from when planning a visualisation. */
248
270
  export type AIChartType = 'bar' | 'line' | 'area' | 'pie';
271
+ /** A chart the model proposed: its type, and the fields to plot. */
249
272
  export type AIChartPlan = {
250
273
  type: AIChartType;
251
274
  /** Group-by (category-axis) column field, or null. */
@@ -261,6 +284,7 @@ export type AIChartPlan = {
261
284
  valueFormat: 'number' | 'currency' | 'percent';
262
285
  rationale: string;
263
286
  };
287
+ /** Options for `aiChart` - preview the plan, or render it into the grid. */
264
288
  export type AIChartOptions = {
265
289
  /** Apply the plan to the grid's chart panel (open + configure). Default false. */
266
290
  apply?: boolean;
@@ -279,6 +303,10 @@ export declare function aiChart<TFeatures extends TableFeatures, TData extends R
279
303
  * calls this for you.
280
304
  */
281
305
  export declare function enableAiCharting<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>): void;
306
+ /**
307
+ * Remove the natural-language chart handler, hiding the AI button in the chart
308
+ * panel. The inverse of `enableAiCharting`; safe to call when none was set.
309
+ */
282
310
  export declare function disableAiCharting<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>): void;
283
311
  /**
284
312
  * A deterministic provider that returns canned, schema-shaped responses
package/dist/ai.js CHANGED
@@ -34,9 +34,11 @@ let provider = null;
34
34
  export function setAIProvider(p) {
35
35
  provider = p;
36
36
  }
37
+ /** The provider registered with `setAIProvider`, or null when none is. */
37
38
  export function getAIProvider() {
38
39
  return provider;
39
40
  }
41
+ /** Whether an AI provider is registered. Gate AI affordances on this so the UI stays honest. */
40
42
  export function hasAIProvider() {
41
43
  return provider != null;
42
44
  }
@@ -590,6 +592,10 @@ export function enableAiCharting(api) {
590
592
  };
591
593
  });
592
594
  }
595
+ /**
596
+ * Remove the natural-language chart handler, hiding the AI button in the chart
597
+ * panel. The inverse of `enableAiCharting`; safe to call when none was set.
598
+ */
593
599
  export function disableAiCharting(api) {
594
600
  const hook = api;
595
601
  hook.setChartAiHandler?.(null);
@@ -1,4 +1,4 @@
1
- import { Kn as e, co as t, so as n } from "./src-Cd0tearp.js";
1
+ import { Kn as e, co as t, so as n } from "./src-BYq-qyrp.js";
2
2
  import { E as r, F as i, G as a, H as o, I as s, L as c, N as l, Q as u, U as d, V as f, X as p, Y as m, Z as h, _ as g, d as _, et as v, f as y, ft as b, g as x, h as S, j as C, k as w, lt as T, m as E, mt as D, nt as O, o as k, pt as A, st as j, t as M, tt as N, u as P, ut as F, v as I } from "./disclose-version-Dr7rEVv-.js";
3
3
  import { b as ee } from "./editor-registry-CiI0xlKg.js";
4
4
  import { l as te } from "./SvDateTimePicker-CRQH_U7E.js";
@@ -1,4 +1,4 @@
1
- import { Kn as e, co as t, so as n } from "./src-B1TdiyS8.js";
1
+ import { Kn as e, co as t, so as n } from "./src-DBel9wRZ.js";
2
2
  import { b as r } from "./editor-registry-CiI0xlKg.js";
3
3
  import { l as i } from "./SvDateTimePicker-CHnUkWcH.js";
4
4
  import * as a from "svelte/internal/client";