@svgrid/mcp 3.0.45 → 3.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/data.js CHANGED
@@ -4604,7 +4604,7 @@ export const docs = [
4604
4604
  "path": "docs/changelog.md",
4605
4605
  "title": "Changelog",
4606
4606
  "section": "Overview",
4607
- "markdown": "# Changelog\n\nThe user-facing log of what shipped. Format follows\n[Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/);\nversioning follows [Semantic Versioning](https://semver.org/).\n\nEvery release has up to six sections:\n- **Added** - new features\n- **Changed** - existing functionality, behaviour changes\n- **Deprecated** - soon-to-be-removed features\n- **Removed** - features removed in this release\n- **Fixed** - bug fixes\n- **Security** - vulnerability patches (with CVE ids when applicable)\n\nPre-release entries live under `## [Unreleased]`. They graduate to a\ndated heading on publish via `pnpm changeset version` (see\n[.changeset/README.md](../.changeset/README.md)).\n\nFor machine-readable releases, fetch\n[`/changelog.json`](/changelog.json) - same content, parseable shape.\n\n## [Unreleased]\n\n### @svgrid/grid\n\n#### Added\n\n- **`trustedHtml(html)`.** `sanitizeHtml`, ready for an HTML sink on a page that requires Trusted\n Types: there it is a `TrustedHTML` of the `svgrid` policy, elsewhere the same string.\n\n- **`toggleOnSecondClick` on a checkbox column.** The first click selects the cell, a click on the selected cell toggles it, and a finger toggles on the tap. Off by default.\n\n- **`parseClipboardText`, and more for the fill and paste hooks.** `parseClipboardText(text)` splits a\n paste into rows of cells, for a consumer whose copy quotes a cell. `processCellForFill` also gets\n `sources` and `index`, and `processCellFromClipboard` gets `cell`, the place in the pasted block.\n Left out, a grid fills and pastes as it did.\n\n- **`keepFocus`.** When the focused control of a region is removed or disabled, focus\n moves to the control now in its place, not to the body. `createFocusTrap` and\n `menuFocus` use it, so dialogs, drawers and menus have it. `use:keepFocus` gives it\n to any other region.\n- **`describedBy` on `SvModal`.** The id of what a dialog says, read with its title.\n\n- **`holdRowsOnWrite`.** A paste, a clear or a fill changes rows where they stand, as a\n typed edit does, for an app that orders the view itself when the person moves on.\n- **`onPasteOverflow`.** The lines of a paste past the last row, split into cells, inside\n the paste's undo step. Without it they are dropped, as before.\n- **`gridLabel`.** The accessible name of the grid, on its table element. SvGrid Base\n passes the table's name.\n- **Very long grids scroll true at both ends.** Past the height a browser paints\n cleanly the grid now scales its scroll, with a pixel staying a pixel near each end,\n so the rows past about 560,000 of a million draw as they should and Ctrl+End\n reaches the last row.\n- **`onColumnVisibilityChange` and `onColumnPinningChange`.** Hiding,\n showing, pinning or unpinning a column, from the column menu, the api\n setters or `api.setState`, now calls back with the hidden ids or the\n `{ left, right }` pinning, the same shapes `api.getState()` reports. Both\n are deduped on the value and do not fire on mount. An app saving the\n layout no longer has to poll `getState()` to notice either. The\n `<sv-grid>` element fires `columnvisibilitychange` and\n `columnpinningchange`.\n\n- **`SvGridProps` is exported.** The full prop type, for a wrapper that\n forwards a typed options bag to `<SvGrid>`. Without it a wrapper had to\n hand-write a `declare module \"@svgrid/grid\"` stub, which shadows the\n package's own types.\n\n- **`chartSpecToTable`.** The rows and columns a spec amounts to, in the\n shape `SvGrid` takes: one row per category with a column per series (a\n grouped axis adds a Group column, a histogram From and To, candles their\n four prices, a box plot its five numbers), per point for a scatter, per\n link for a sankey or chord, per leaf for a tree map or sunburst with a\n column per level, per day for a calendar, one row for a gauge. Number\n columns carry the chart's format (a right-axis series its axis's) and a\n date axis is a date column. The gallery demos' Chart | Grid switch is this\n behind a sortable grid.\n\n- **The Chart panel charts the pivot in pivot mode.** With `pivot` and\n `charting` on one grid, the pivot bar carries the Chart toggle and the\n panel draws the pivot on screen: row groups as categories (nested rows a\n grouped axis), column groups as series, the measures' format on the axis,\n totals left out. The data pickers step aside with a note and the Type\n select keeps the shapes a pivot can take; Stacked, 100%, Horizontal, the\n Format tab, the builder, saved charts, export and Describe still apply. A\n click on a bar filters the innermost row dimension when the grid has a\n column for it, which re-runs the pivot. It used to chart the source rows by\n the source columns whatever was on screen. The mapping is\n `pivotResultToChartSpec` (with `pivotChartType`, `pivotFilterColumn`)\n in the lazy chart engine; enterprise's `pivotToChartSpec` is the same\n function. `bucketsToChartSpec` (server aggregates as a spec) moved there\n from the controller, out of the base bundle.\n\n- **Scatter points select.** A click or Enter on a scatter or bubble point\n selects it the way a bar selects: the point's `label` (or its series) is\n the category, its y the value, and `selectable`, `bind:selected`,\n `onSelectionChange` and `onSelect` all apply. The dots had no click\n handler, so on a scatter chart those props did nothing.\n- **`ChartPointRef.index`.** A selected bar carries its category index\n beside its label, and two refs with an index match only on the same one.\n A grouped axis repeats its leaf labels (Q1 to Q4 under each year), so a\n click on the second Q2 used to select the first Q2 with it. A ref written\n without an index still matches by label.\n- **Data labels on a 100% chart read the share.** Under `stacked100` the\n axis is already a share whatever `valueFormat` says; the labels on the\n bars now say \"18%\" as well, rather than \"$18\", or \"1800%\" when the format\n was percent. A `dataLabels.formatter` still receives the raw value and the\n tooltip keeps it.\n- **A series on the right axis reads in that axis's format.** The tooltip,\n the screen-reader table, the live region and the data labels format a\n series with `axis: 'right'` through `y2Axis.format` or `formatter`, so a\n margin of 0.29 beside a revenue in dollars reads \"29%\" and not \"$0.29\".\n Without a format of its own the right axis is plain numbers, as its ticks\n are.\n- **The breadcrumb survives `toolbar={false}`.** A drilled sunburst, tree\n map or pie with the toolbar off still shows its breadcrumb in a strip of\n its own; it used to have no way back up.\n- **Chart axis model.** `xAxis`, `yAxis` and `y2Axis` on a spec take\n `min`, `max`, `nice`, `tickCount`, `tickInterval`, `format` or a\n `formatter`, `title`, `gridLines`, `labelRotation`, `reversed` and, for\n the x axis, `type: 'number'` for a numeric axis that spreads categories by\n value. `referenceBands` shade a range on either axis, `referenceLines` can\n be vertical, `title` / `subtitle` / `caption` frame the chart. Series\n gained `marker` shapes and per-point `markers` / `colors`, `strokeWidth`,\n `dash`, `opacity`, `gradient`, `step` lines, `connectNulls` and a\n `nullAs` policy; `dataLabels` takes a placement, a formatter and overlap\n hiding; the component takes a `tooltip` snippet, `tooltipFormat`,\n `tooltipMode: 'single'`, a `legend` side and a `legendItem` snippet, and\n `autosize`. `rowsToChartSpec` reduces with `min`, `max`, `median`,\n `first`, `last`, `countDistinct` and `pN` and buckets a date dimension by\n `day` / `week` / `month` / `quarter` / `year`.\n- **Decimation for long series.** `decimate: 'auto'` (the default) thins a\n line or area with more points than pixels through LTTB, which keeps the\n shape; `{ method: 'minmax' }` keeps every spike. Zoom is applied first, so\n zooming into 300 of 100,000 points shows all 300. `lttb`, `minMaxIndices`,\n `decimateSpec` and `pickCategories` are exported.\n- **Thirteen more chart types**: `histogram` (with `binValues` and\n `rowsToHistogramSpec`), `range-bar`, `range-area`, `lollipop`,\n `dumbbell`, `pareto` (`paretoSpec`), `stream` (`stackOffset: 'wiggle'` or\n `'silhouette'`), `sunburst`, `radial-bar`, `radial-column`,\n `nightingale`, `chord` and `bullet`; plus hollow and Heikin-Ashi candles\n (`candleStyle`) and pyramid / cone funnels (`funnelShape`). All of them are\n in the grid panel's picker, gated on what the current columns can feed.\n- **Zoom, pan and presets.** `zoomable` takes an object: `wheel` (`true` or\n `'modifier'` for Ctrl + wheel), `pinch`, `pan` (`'shift'`, `'mode'` or\n both) and `axis` (`'x'`, `'y'`, `'xy'`). The window is a bindable\n `zoom` prop of category indices with `zoomTo` / `resetZoom` on the\n component and an `onZoom` callback; `rangePresets` puts 1W / 1M / 3M / 6M /\n YTD / 1Y / All in the toolbar on a time axis.\n- **Synchronized charts.** Charts with the same `syncGroup` share their\n crosshair and zoom window, matched by label and then by date. The grid\n panel's `syncTabs` keeps one window across its chart tabs.\n- **Context menu, animation, drilldown, selection, keyboard.** `contextMenu`\n (built-in export / zoom / series items, your own `MenuItem`s, or a function\n of the clicked point; Shift + F10 opens it), `animate` (a data-update tween\n and `'fade'` / `'grow'` / `'wipe'` enter effects, off under reduced\n motion), `drillable` + `drillPath` for tree maps and sunbursts with a\n breadcrumb, `selectable` + `selected` + `onSelectionChange` for point\n selection with dimming, Up / Down stepping through series with a polite live\n region (`announce`).\n- **Financial toolkit.** `bollingerBands`, `rsi`, `macd`, `vwap`, `atr`,\n `stochastic`, `wma` and `obv`, NaN-padded like the moving averages;\n `'wma:N'`, `'bb:N:K'` (a shaded band) and `'vwap'` overlays;\n `indicatorPane` and `SvChartPanes`, which stacks indicator panes under a\n price chart with one x axis, one gutter and one crosshair; `rowsToOhlcSpec`\n and `resampleOhlc` (daily bars to weeks / months); `lastPriceLine`;\n annotation `shape` (`'flag'`, `'pin'`, `'square'`) with a tooltip\n `text`; `volumes` on a series.\n- **Drawing tools.** `drawable` puts trend line, horizontal ray, Fibonacci\n retracement, rectangle, arrow and note tools in the toolbar; the drawings\n are data points (`spec.drawings`, `onDrawingsChange`) so they survive a\n zoom, a resize or new data. A selected drawing has draggable handles and\n Delete removes it.\n- **PDF and print** with no PDF library: `chartToPdfBlob`, `downloadChartPdf`\n (a one-page A4 or Letter PDF with the chart as a JPEG and the titles as\n text) and `printChart`, in the toolbar, the context menu and the panel's\n export menu.\n- **Chart builder in the grid panel.** The Build button opens a modal with a\n type gallery (a live thumbnail per type), the data pickers and a Format tab\n (titles, legend and label placement, axis title / min / max / format / grid\n lines, per-series colour / type / axis / marker / width). The format is\n `ChartFormatState` on the chart tab, applied by `applyChartFormat` to every\n derived spec, saved with the view and reachable through\n `configureChart({ format })`. A link toggle unlinks a chart from the grid\n (`configureChart({ frozen: true })`) so it keeps its data while you filter.\n `charting.onChartCreated` / `onChartChanged` report the panel's lifecycle;\n `charting` also takes `zoom`, `rangePresets`, `syncGroup`, `syncTabs`,\n `contextMenu` and `animate`.\n- **Candlesticks from the grid panel.** Pick Candlestick or OHLC bars and the\n panel finds the Date, Open, High, Low, Close and Volume columns by name;\n Indicators chips add panes and overlays; `configureChart({ ohlc,\n indicators })` and the AI chart plan reach the same thing.\n- **A scatter series' `overlay` is a regression of y on x.** Until now the\n scatter layout ignored `overlay` (the fits ran on the index, which a\n scatter has no use for). The regressions (`linearFit`, `polynomialFit`,\n `exponentialFit`, `logarithmicFit`, `powerFit`) take an optional `xs`\n and return `predict(x)`; `regressionFit(values, overlay, xs)` names one by\n its overlay string; a scatter series with `overlay` gets the curve drawn\n across the plot (sampled evenly in log space on a log axis) and its\n equation and R-squared in the point tooltip.\n- **Chart gallery: fourteen full-size demos, one per family, and a docs page\n for them.** Bars, lines, areas, pie / donut / sunburst, scatter and bubble,\n combination, histogram and box plot, heat map and calendar, radar and\n radial, tree map and sunburst, sankey and chord, waterfall / funnel /\n pareto, gauges and bullets, and an annotated chart (demos 438 to 451),\n each with its own data and the switches that family needs, embedded on\n `help/charts/gallery` and the type pages.\n- **Grid chart panel: a deeper Format tab, one set of pickers, a\n localized panel and saved charts.** The builder's Format tab adds series\n labels, the crosshair's axis pills, a compact rule below a width\n (`compactBelow`, through `CHART_RESPONSIVE_PRESETS.compact`), a stack\n group per bar or area series and the chart's font, size, background and\n text colour (`ChartFormatState.seriesLabels` / `crosshairLabels` /\n `compactBelow` / `series[].stack` / `style`). The panel's pickers and the\n builder's Data tab are one component (`SvGridChartPickers`), so the two\n cannot disagree about what a type needs. Every string the panel and the\n builder show is a `chart*` key on `localization.text`\n (`GridChartPanelMessages`, loaded with the panel; `GridMessages` is now\n the chrome map and the panel map together). `api.saveChart(name)`,\n `applySavedChart`, `removeSavedChart`, `getSavedCharts` and\n `configureChart({ saved })` keep a tab's whole configuration under a name;\n the panel has a popover for them and `getState()` carries `savedCharts`\n when there are any.\n- **Chart diagnostics, a plain-language description, live feeds and a JSON\n schema.** `validateChartSpec` returns what is off about a spec (unknown\n keys with the nearest name, an unknown type, a series short of the\n categories, a log axis at zero, an overlay the engine does not read, an\n anchor naming no category, and more); `SvChart` logs the findings once per\n spec in development, `aiChart` attaches the errors to its plan, and the\n MCP server's `svgrid_check_code` applies the rules to a static spec\n literal with a rename for a misspelt key. `chartSummary` reads a chart in\n a sentence (trend, extremes, shares, correlation, last close) and\n `SvChart` hands it to assistive technology as `aria-description` and the\n table caption (`describe`), the context menu and the panel copy it, and\n `aiExplainChart` grounds an Explain button on it. `appendPoints` builds\n the next spec of a feed with every per-category array kept in step and a\n rolling window, and `live` on the chart skips the tween and enter effect.\n `docs/schemas/chart-spec.json` is generated from the types, served at\n svgrid.com/schemas and by `svgrid_get`, and a test keeps it equal to the\n validator's lists.\n- **Series and interaction depth.** Areas join `stack` groups like bars\n (`stacked100` and `stackOffset` run per pile); a numeric x axis takes\n `scale: 'log'` (even decades, 2 / 5 minors, non-positive categories\n dropped, decimation in log positions); regression overlays `poly:N`,\n `exp`, `log` and `power` next to `linear`, each carrying `r2` and\n `equation` on the overlay line and read in the tooltip, with\n `linearFit` / `polynomialFit` / `exponentialFit` / `logarithmicFit` /\n `powerFit` / `rSquared` / `computeOverlayFit` / `overlayName` exported\n and `charting.trend` accepting the new names; hovering a mark dims the\n other series (`hoverHighlight`, on by default, snapping within 18px) and\n `onHover` reports the point once per change; `tooltipPosition` parks the\n tooltip in a plot corner and `tooltipSticky` pins it on a click; data\n labels take `rotation` and `connector` (pushed clear of a collision with\n a leader line); `spec.style` sets a chart's font, size, background and\n text / grid colours over the tokens (`chartStyleVars`), honoured by the\n exports.\n- **Accessibility pass on the chart.** Every non-cartesian family (pie,\n sunburst and the radial charts, heat map, calendar, tree map, funnel,\n sankey nodes and links, radar, scatter) is one Tab stop with a roving\n focus: arrows walk the marks (a heat map by row and column, a calendar by\n day and week), Home / End / PageUp / PageDown jump, the focused mark\n raises its tooltip, Enter / Space select or drill, and every mark is named\n and has a focus ring. Zoom from the keyboard: `+` / `-` / `0` on a\n focused category and Shift + arrows to pan, and the brush is a `slider`\n (arrows pan and resize, Home / End, `0`). The toolbar is a `toolbar`, the\n tooltip a `tooltip`, decorative icons are hidden from the tree. Forced\n colors (Windows High Contrast) keep the data colours and repaint the\n chrome with the system palette. `localeText` on `SvChart` (and\n `charting.localeText` for the grid panel) translates every string the\n chart renders itself, with `ChartMessages`, `defaultChartMessages`,\n `resolveChartMessages` and `chartMessage` exported. A new\n `tests/e2e/chart-a11y.spec.ts` runs axe-core against the rendered chart\n on three demos and drives the keyboard model in a real browser.\n- **Stack groups, series labels, responsive rules, pie callouts.** `stack`\n on a bar series names the pile it joins, so plan and actual stack side by\n side in each category and the axis fits the tallest stack; `seriesLabels`\n names each line at its last point in a reserved gutter, pushed apart where\n lines end together; `responsive` patches the spec by the rendered size\n (axes merge one level deep, a rule's `legend` moves or hides the\n component's legend; `resolveResponsive` and `matchResponsiveRules` are\n exported); `dataLabels: { placement: 'outside' }` on a pie draws callout\n labels with leaders instead of percentages, and a spec can carry its own\n `dataLabels`; `visible: false` starts a series hidden with its legend chip\n dimmed; the crosshair reads off the axes with a category pill and a value\n pill (`crosshairLabels={false}` turns them off).\n- **`moveCells` - drag a selected range to move or copy it.** Grab a selected\n range by its border and drop it somewhere else. Move by default, copy with\n Ctrl / Cmd, and the modifier is read at DROP time so it can be pressed or\n released mid-drag. On whenever cell selection is on; `moveCells={false}`\n opts out. A drop is refused outright - nothing changes - when it would land\n off-grid or when any source or destination cell is read-only, rather than\n moving the part that fits and silently dropping the rest.\n- **`selectionBar` - a floating bar over the grid while rows are selected**,\n showing the count and the actions that apply to the whole selection. `true`\n gives the count and a Clear button; an array is shorthand for `{ actions }`;\n the object form also sets `position` (`'bottom'` default, or `'top'`),\n `maxVisible` and `hideClear`. The prop and its types are free; the bar\n itself is an Enterprise renderer, and without it the grid shows a short upsell\n in its place, the same way the scheduler and board views do.\n- **Edge auto-scroll for every drag that extends a rectangle** - the fill\n handle, the range move, and plain drag-select. All three were previously\n capped at whatever was already on screen when the drag began, which on a grid\n built for 100k rows meant the gesture mostly did not work. One shared rAF loop\n scrolls the container when the pointer is inside a 40px edge band, on a linear\n ramp to 20px/frame, in both axes. It keeps scrolling with the pointer parked\n still, which is the whole point of holding at an edge.\n- **Row and column resizing, both opt-in** (`rowResize`, `columnResize`).\n `columnResize` gives every header a drag handle: drag the edge, double-click\n it to size the column to its content, or focus it and use Left/Right (Shift\n for a 1px step). `rowResize` does the same vertically and brings the\n row-header column with it, since that is where the grip belongs; the grid\n stores the heights itself, so neither needs a function-valued `rowHeight`.\n Both load their code on demand, so a grid that leaves them off downloads\n neither.\n- **`ColumnDef.resizable`** - per-column opt-out, consulted only when the grid\n has `columnResize` on. `resizable: false` removes that column's handle\n entirely, so the drag, the arrow keys and double-click-to-autosize all go with\n it, and the column menu drops its Autosize item. For the columns whose width\n is part of the layout: a row-number gutter, a checkbox column, a fixed icon\n column. Programmatic sizing (`api.setColumnWidth`, `api.autosizeColumn`,\n `fitColumns`) still applies.\n- **`SvGridViewState` is exported.** It is the return type of the public\n `api.getState()`, so writing a typed \"named views\" feature previously meant\n either re-declaring the shape or reaching into an internal path.\n- **Form layer depth in `SvForm` / `createForm`.** Schema-driven forms gained:\n conditional / dependent fields (`visible` and `disabled` accept a\n `(values) => boolean` predicate; hidden fields drop out of validation and the\n submit payload), grouped **sections** and a multi-step **wizard** (`stepper`,\n with per-step validation gating), repeatable **field arrays**\n (`type: 'array'` with `itemFields`, plus `addItem` / `removeItem` / `moveItem`),\n **async validation** (debounced, stale-response-guarded, per-field\n `validating` state), **dirty tracking + `reset()`**, and **submit states**\n (`isSubmitting`, an async `onSubmit`, and `setErrors()` for server-side field\n errors). New demos: dynamic form, wizard, and field array.\n- **Public headless cores for the menu / select family** (`createMenu`,\n `createPopoverSelect`, shared `list-nav`), so the popup pickers can be driven\n headlessly and composed into custom UI.\n- **`color` on `ListOption`** - render a small color swatch before the label in\n `SvListBox` and `SvDropDownList`.\n- **`block` on `SvDateTimePicker`** - stretch the field to fill its container\n (100% width), so it fills a grid cell when used as an editor.\n- **`onClosed` on `SvDrawer`** - fires after the exit animation ends and the\n drawer leaves the DOM.\n- **`loading` on `SvField`**, and **`locked`** on `SvDockLayout` /\n `SvDockManager`.\n- **`summary` on `<SvGrid>`** - shortcut alias for `enableRowSummaries`,\n which turns on the footer row that aggregates every filtered row. It wins\n when both are set, the same precedence `selectable` has over\n `enableCellSelection`.\n- **`summary` on a column** - choose that column's footer aggregate\n (`'sum'`, `'avg'`, `'min'`, `'max'`, `'count'`, `'countDistinct'`,\n `'extent'`, `'first'`, or a custom function), or `false` to leave the cell\n blank. Without it a column keeps the old default: sum a numeric column,\n `Count: N` otherwise.\n- **Development-time configuration checks.** The grid used to fail silently on\n the most common mistakes - a misspelled `field` rendered a column of blank\n cells and printed nothing. It now warns once per problem, in dev builds only:\n\n - a column `field`, `groupBy` entry, `treeData.parentField` / `idField` or\n `treeData.column` that does not exist (with a \"did you mean\" for near misses),\n - two columns resolving to the same id,\n - `pageSize` set when pagination was never turned on,\n - a column marked `sortable` while sorting is not enabled,\n - `initialColumnPinning` while column virtualization is on, which silently\n prevents the columns from sticking,\n - `externalPagination` without `rowCount`, `externalSort` without\n `onSortingChange`, and `externalFilter` without `onFiltersChange`.\n\n The checks live in a lazy chunk behind a dev-only branch, so a production\n build never loads them and the base bundle is unchanged.\n\n#### Changed\n\n- **`showColumnFilters` no longer puts an input in the header.** Set to\n `true`, it also drew a plain \"Filter\" text box in every header cell,\n which with `showFilterRow` made two filter inputs per column. It now\n only turns on the column menu's filter section, as documented. For\n always-visible inputs use the filter row: `showFilterRow` or\n `filterMode=\"row\"`.\n- **The find bar loads on the first Ctrl+F.** It is its own chunk now, so a\n grid nobody searches does not carry it; the first open shows the bar once\n the chunk has loaded.\n- **`alignedGridGroup` loads its module on demand.** The shared group that\n mirrors horizontal scroll and column widths between grids is now a lazy\n chunk, fetched by the first grid that sets the prop, the way managed row\n drag is. A grid outside a group no longer carries it, which kept the base\n bundle under its 100 KB budget after this release's scroll and mount\n changes. Mirroring starts once the chunk has loaded, a frame on a warm\n cache.\n- **BREAKING: column resizing is now off by default.** Every column used to have\n a drag handle unconditionally - there was no prop, no per-column option and no\n way to turn it off, so a `width` you set was only ever a starting value a user\n could drag away. Set `columnResize` to get the handles back; the 241 demos in\n this repo that want them now say so. Sorting and filtering have always been\n opt-in behind `sortable` / `filterable`, and resizing was the odd one out.\n- **BREAKING: the footer summary row is now off by default.**\n `enableRowSummaries` used to default to `true`, so a plain\n `<SvGrid {data} {columns} />` grew an aggregate footer nobody asked for and\n every caller that did not want one had to opt out - 375 call sites in this\n repo passed `enableRowSummaries={false}` against 6 that opted in, and the\n API reference already documented the default as `false`. If you were\n relying on the old behaviour, add `summary` (or `enableRowSummaries`).\n- **Ember is now the default theme preset** (`defaultThemePreset` in\n `@svgrid/grid/themes`). It is what the demo gallery and svgrid.com open on, so\n a scaffolded or Studio-generated app now looks like the demos unless you pick\n a preset. Previously the default was Tailwind.\n- **Popup editors keep themselves on screen.** `SvAutoComplete`, `SvComboBox`,\n `SvDropDownList` and the date pickers now measure the space to the viewport\n edge: the panel flips up when there is not enough room below and clamps its\n `max-height` to the available height, so a picker opened near the bottom of the\n window no longer spills off screen.\n- **Dock manager pop-out to a new window is now off by default**\n (`allowPopout={false}`); opt in explicitly. Added a dedicated pop-out demo.\n\n#### Fixed\n\n- **`fitColumns` with `responsive` fills the row when a `hideBelow` column is hidden.** The fit still\n counted the hidden column's width, so the shown columns stopped short and left a blank strip that\n wide at the right edge.\n- **Cut clears only what reached the clipboard.** Ctrl+X, the Cut menu item and the cut command\n cleared the cells at once, before the clipboard write had finished, so a write the browser refused\n (a page without focus, a denied permission) lost the values. The clear now waits for the write, and\n runs only if the text landed and the selection has not moved meanwhile.\n `copySelectionToClipboard()` returns a promise of whether the text landed.\n- **The pinned-column divider in a contrast theme.** Forced colors keep a fill's alpha, so the\n `pinSplitter` divider stayed a faint line and vanished on `Canvas`. It is drawn in `CanvasText`,\n and in `Highlight` under the pointer, with focus and while dragged.\n- **Chart panel: an Export item that is off looks off.** The PDF item that cannot draw the chart's\n text said why but looked like the items that work; it is dimmed as an off CSV item is.\n- **Scheduler model: a day the clocks change is drawn by the clock.** `layoutDayEvents` placed an\n event by the real minutes since midnight, so on a 25-hour day every event sat an hour below the\n row its time is labelled with, and on a 23-hour day an hour above; an event in the last hour of a\n band fell out of it. It now counts wall-clock minutes (`wallMinutes`, `atWallMinute`, both new\n exports). On a week that starts on a 23-hour Sunday, `monthWeekSegments` put Monday's bars under\n Sunday. `timelineAxis` for `timelineDay` ends the band at its hour by the clock and names each\n real hour by its clock (a 25-hour day shows 1 AM twice), where it left a gap or an overlap.\n- **A menu item that is off keeps the arrow keys.** `menuFocus`, `createMenu` (`SvMenu`,\n `SvContextMenu`, `SvMenuList`) and the column and context menus mark it `aria-disabled` and keep\n it in the arrow-key and first-letter order, as the ARIA menu pattern does, so a screen reader\n hears it and why it is off. Its click does nothing. Before, the arrows skipped it.\n- **Forced colors: the header checkbox of a part-selected grid keeps its dash.** The dash was a\n fill, which a contrast theme removes, so the box read as empty.\n- **A chart's PDF refusal is seen at the toolbar and in the grid's chart panel.** For a title the\n PDF's font cannot draw, the toolbar's PDF button did nothing on screen: the reason went to the\n screen reader only. It is now marked off (`aria-disabled`, the reason as its tooltip) once it is\n pointed at or focused, and a press shows the reason in the button. The chart panel's Export menu\n wrote no file and said nothing; its PDF item now reads the reason and is off.\n- **The chart panel's Export menu takes the keyboard.** Arrow keys, Home, End and first letters move\n in it, focus goes to its first item when it opens and back to Export when it closes (it fell to the\n page). Its CSV item, when the chart has no table of values, stays focusable and says why.\n- **Rich text renders under Trusted Types.** `SvRichCell`, `SvRichText` and the sanitizer passed plain\n strings to `DOMParser`, `{@html}` and `innerHTML`, so a page with `require-trusted-types-for 'script'`\n threw and drew nothing. They now go through one policy, `svgrid`, made only where the browser has\n `trustedTypes`. A CSP with a policy list needs `trusted-types svgrid svelte-trusted-html`\n ([SECURITY.md](https://github.com/sv-grid/sv-grid/blob/main/SECURITY.md#trusted-types)).\n- **Chart Print runs under Trusted Types.** `printChart` built its window with `document.write`; it\n now builds it node by node and draws the chart as a `data:` image.\n- **A chart PDF never writes `?` for a letter.** Its text is in the PDF's built-in Helvetica, which\n has Western European letters only. The euro sign, curly quotes and dashes now come out right. A\n title, subtitle or caption with other letters (Cyrillic, Greek, CJK, Hebrew, emoji) is refused: the\n menu's PDF item says which text and points to PNG or SVG, and `chartToPdfBlob` and `buildChartPdf`\n throw a `ChartPdfTextError` naming it. `pdfUndrawable()` tells beforehand.\n\n- **A block cache that refreshes a block still being read frees that read's slot.** `refresh()`,\n `applyRows` and an insert or remove gave up a read in flight without counting it as done, so\n `loading` stayed true for good, and with `maxConcurrentRequests` reached no block loaded again.\n\n- **The \"Could not load these rows.\" line of a failed run sits on the first row wholly on screen.**\n It sat on the first rendered row, which overscan puts above the screen, so a person scrolled\n into a failed block saw a tinted band and no words.\n\n- **An edit deep in a server row model no longer walks the rows.** `find`, `findIndex`, `some` and `indexOf` on windowed\n data read only what is loaded, a paste, clear or fill over rows held in place copies only those, and `cellEdited`\n hands over `rowId`.\n\n- **A filter's count is said once.** Opening or closing a group under a filter no longer repeats\n it, and a closed group counts the records the filter keeps: it read \"28 of 30\" with 24 shown.\n- **`createFocusTrap` and `menuFocus` never drop focus to the body.** An opener that left the page,\n or turned disabled or hidden, hands focus to what held it. A dialog opened from a menu item goes\n back to what the menu went back to. A tooltip closes with Escape.\n\n- **CSV: a cell that starts with a line feed is guarded.** Tab and carriage return were,\n and a spreadsheet reads `\\n=1+1` as a formula too.\n- **A commit keeps the keyboard in the grid.** A pick in a select or dropdown cell, or\n Escape on a multi select, left focus on the body and arrows dead. Tab in a dropdown\n cell left the grid; it now commits and moves on, as the docs say.\n- **Group rows follow their state.** `aria-expanded`, the chevron and the button's\n label went stale until the row was drawn again.\n- **A grouped grid behaves as a treegrid.** Left and Right close and open a group, Enter\n and Space toggle it, and rows of records carry `aria-level`. Enter on a group's row\n used to move down.\n- **The filter count counts records.** \"28 of 34 rows match\" included group headers.\n- **A menu scrolls to the item the keyboard moved to.**\n- **A first click on the cell seeded on mount selects it.** It used to open the editor.\n- **Moving a column by hand is an undo step**, as a resize is. The api's setter records none.\n- **\"Add condition\" in the filter menu keeps focus**, and closing that menu goes back\n to the funnel.\n\n- **Keyboard and focus.** The Menu key and Shift+F10 open the context menu of the\n active cell. The column and context menus take focus, walk with the arrows, Home,\n End and first letters, and give focus back. `menuFocus` gives a menu of your own\n the same. The find bar takes focus when opened from a focused control.\n- **Focus stays in view.** Moving the active cell, or tabbing to a header control,\n stops clear of pinned columns on either side and above a sticky footer.\n- **Right to left.** The left and right arrows go where they point, horizontal\n scrolling to the active cell works, and the pin splitter follows the pinned columns.\n- **A grouped grid is a `treegrid`**, and a group row's cell is the active descendant.\n- **Menus, filter panel and find bar translate** through `localization.text`, as do\n the row number, select row, column menu, filter and resize names. `setModalCloseLabel`\n names the x on every `SvModal`.\n- **Ember**'s muted text reaches 4.5:1 on a pinned header. The column menu button is\n 24 px.\n- **IME.** A key of a composition no longer moves the cell or commits the editor.\n- **Smaller base bundle.** What a fill or a range move writes when the drag ends loads\n with the drag (`range-commit.ts`).\n- **`SvRichText` sanitizes its value.** It wrote `value` to `innerHTML`, so a stored string ran\n its handlers. `value` now goes through `sanitizeHtml` on the way in and out, and `sanitizeHtml`\n keeps a text alignment, rebuilt from scratch, so the alignment buttons survive it.\n- **CSV injection through a list.** `escapeFormulas` guarded strings only, so a multi-select value\n `=1+1` written with `rawValues: true` reached the file as a formula. It now guards everything\n but numbers.\n- **Open groups stay open.** In a grid with no `expanded` prop, a change to any other\n prop, such as new `data`, folded every group the person had opened.\n- **A row model that groups on the server is not grouped again in the page.**\n With `rowModel` from `createServerRowModel` and a grouping in the grid's\n state (a view, `groupBy`), the grid bucketed the rows it had loaded under\n its own group rows. A model with `group` accessors now hands over its rows\n as they are; the grouping state stays for whatever shows it.\n\n- **A `rowModel` set after mount still sorts and filters on the server.**\n The grid read `externalSort` and `externalFilter` once, at mount. A model\n handed over later (one loaded on demand) was sorted and filtered again in\n the page, placeholders included: with a million rows behind it, a view\n filter held the page for seconds. The grid now follows the model's\n `setSort` and `setFilter` whenever it arrives.\n\n- **`SvRichText` lists had no bullets or numbers in apps with a CSS reset.**\n Tailwind's preflight sets `list-style: none` on every list, so a bulleted\n list in the editor read as plain lines. The editor now sets `disc` and\n `decimal` itself.\n\n- **A custom column header did not sort when its label was clicked, and did\n not see the sort change.** The header wrapper is itself `role=\"button\"`, so\n the check meant to skip clicks on buttons inside a custom header matched the\n wrapper and skipped every click on the header's own text; only a click on\n empty header background sorted. The `header:` callback also ran once, so\n `ctx.column.getIsSorted()` kept its first value. Both are fixed: a click on\n the label sorts, a button inside the header still gets its own click, and\n the callback runs again when the column's sort changes.\n- **Grouping five million rows ran out of memory.** Every group row carried\n ten closures and a Map of its ancestors' values, and a million rows grouped\n five deep make about a million group rows. Group rows now share their\n methods and keep their state in one object. Grouping 1,000,000 rows that\n way adds about 500 MB instead of 785 MB, and 5,000,000 rows group in 56 s\n on a laptop within Chrome's default heap.\n- **Every selection change serialized the whole selection.** Deciding\n whether to call `onRowSelectionChange` ran `JSON.stringify` over the\n selection state; selecting half of a 5,000,000-row grid built a string of\n tens of megabytes per change. The two states are now compared key by key.\n- **A mount built rows nobody could see, and laid the grid out five\n times.** The first paint now draws the rows on screen and at most two\n overscan rows, and the rest of `overscan` follows a frame after that paint:\n a 520 px grid built 26 rows to show 14. Reading the scroll position of the\n container the grid had just created, and each scrollbar measuring its\n track on connect and on every attribute change, forced four layouts of the\n half-built grid before it painted. The position is now confirmed on the\n next frame and the track is measured by the scrollbar's resize observer;\n the one forced layout left is the container size the windows need.\n- **The scrollbar thumb trailed the rows by a frame.** The custom scrollbar\n read the scroll position on the frame after the scroll flush, so the thumb\n moved one frame late and each scroll step paid a second style pass and\n paint for it. The flush now hands the scrollbar the position it already\n has, and the scrollbar keeps its measured track instead of measuring it\n inside the flush.\n- **A vertical scroll frame repainted every rendered row.** Body rows were\n not positioned, so on any frame that moved or rewrote a row Chrome painted\n every rendered row again cell by cell. Flex-layout body rows are now\n `position: relative` (no z-index, no clip), which lets the browser reuse an\n unchanged row's paint whole. In six interleaved rounds of the 100,000-row\n browser bench, a 60 px scroll step went from 4.05 to 3.68 ms of\n main-thread work (median). Sticky frozen and group rows keep\n `position: sticky`.\n- **Expanding one group re-grouped every row.** A toggle re-ran the row\n pipeline, and the grouping stage bucketed all rows again although only the\n expansion had changed. It now keeps its groups while its input rows,\n grouping and columns are the same. On a 100,000-row grid grouped by five\n columns, one expand went from 521 to 98 ms, and expanding or collapsing\n every group from 473 to 82 ms.\n- **A calendar date with `timeZone: 'UTC'` showed the day before.** A\n bare date string such as `'2026-10-07'` is read as local midnight, so a\n date `format` whose `options` carried `timeZone: 'UTC'` (the usual fix\n from when such strings were read as UTC) showed October 6th anywhere east\n of UTC. A calendar date has no zone: `timeZone` is now ignored for one,\n on screen and in exports.\n- **A cell note's corner marker sat at the grid's corner.** The marker is\n positioned against its cell, but a cell with a note was not positioned, so\n it anchored to the grid. A cell with a note is now a positioning context,\n like the active cell.\n- **A sort or filter kept every column's value on every row.** Reading one\n column built and cached an array of all of a row's values, so sorting a\n 1,000,000-row grid by one column left 1,000,000 of them behind. A plain\n `field` column is now read from the data; a computed (`fieldFn`) column\n still builds the array. The heap a sorted and filtered 1,000,000 x 9 grid\n adds went from 196 MB to 128 MB in the browser harness.\n- **`applyTransaction({ remove })` scanned the data once per row object.**\n Removing 10,000 row objects from 1,000,000 rows took about 1.8 s to find\n them; past eight objects the transaction now builds one identity map.\n- **Group footer and grand-total rows drew checkboxes.** With\n `showRowSelection`, each totals row had a row-selection checkbox, and\n ticking it selected the synthetic row. A checkbox column with no `aggregate`\n showed a checkbox too, holding a leaf's value carried over from the group\n row. Totals rows keep the selection cell for alignment but leave it empty,\n and a boolean column without an aggregate renders nothing there.\n- **Toggling a checkbox cell did not fire `onCellValueChange`.** A click or\n Space on a checkbox cell wrote the row and stopped, so an app that saves\n edits from `onCellValueChange` lost every checkbox change, and Ctrl+Z could\n not take one back. The toggle now takes the inline editor's commit path:\n one undo step, then `onCellValueChange` with the old and new value and the\n row's position in `data`.\n\n- **Arrow keys lagged whenever the active cell had to scroll.** On the\n 10,000 x 53 large-dataset demo one ArrowDown at the bottom of the viewport\n cost about 37 ms of main-thread work and painted over two frames; it is now\n about 8 ms and paints once. Five things added up. Every rendered row was\n measured with `getBoundingClientRect` on each scroll tick, on a grid that\n had no `autoRowHeight` to use the number for, which forced a table layout\n per row (about 30 per key press). The scroll geometry the custom scrollbar\n reads was pulled inside a derived at the start of the flush, forcing a\n second full table layout that the row writes then invalidated. The\n virtualizer keyed rows by their position in the window, so a one-row\n scroll rewrote all ~30 rows x every rendered column; rows are now keyed\n `index mod windowLength`, so the rows that stay keep their `<tr>` untouched\n and the one that entered is moved with a single `insertBefore`. The row\n window only updated after the browser's `scroll` event and a\n `requestAnimationFrame`, a frame after the key press; keyboard navigation\n now syncs the virtualizer inline, since it knows where it scrolled. And\n each cell carried three selection-dependent deriveds plus the fill handle's\n `{#if}`, re-marked on every move; they are one `{@const}` now, `null` for\n a plain cell. Also closed on the way: `key in editedCellValues` on a deep\n `$state` proxy created a signal per rendered cell that never went away, and\n the header checkbox's tri-state walked every row on each arrow key.\n\n- **A heat map drew a series legend in colours its cells never use.** The\n ramp on the right is its key; the row of palette chips under it (and a\n calendar's) is gone.\n\n- **A time axis put its ticks on nothing in particular.** `xType: 'time'`\n stepped a fixed 30 or 365 days from the Unix epoch, so a tick labelled\n \"2025\" stood weeks from New Year, a \"Jun 25\" tick sat mid-June, and a\n thirty-month axis carried two labels on a plot with room for eight. Ticks\n now land on calendar boundaries in UTC (days, Mondays, the first of a\n month, quarter or year, or every few years) at about one label per 90px,\n and each label is sized to the gap between ticks rather than the axis span,\n so a quarterly axis no longer reads \"2024, 2024, 2024, 2025\". The labels\n are read in UTC too: a local-time read of a 'YYYY-MM-DD' category in the\n Americas labelled every tick with the day before.\n- **The tooltip echoed the ISO date.** On a time or ordinal-time axis the\n tooltip title, the crosshair pill and the live region wrote \"2025-06-01\";\n they write \"Jun 2025\" when every category is the first of a month, \"2025\"\n when every one is New Year, and \"Jun 1, 2025\" otherwise, through\n `xAxis.formatter` when one is set. A calendar cell names its day the same\n way. The category in `onHover`, `onSelect` and `selected` is unchanged.\n- **The screen-reader table and the CSV read \"NaN\".** A NaN gap (the way a\n forecast series marks the months before it starts) wrote the word \"NaN\"\n into the hidden data table and the CSV export, and a `null` fell back to\n 0, which told a screen reader the outage month had no sign-ups. Both are\n empty cells now.\n- **\"Double-click again to clear\" left a legend chip isolated and hidden.**\n A double-click arrives as click, click, dblclick: with a chip isolated the\n first click cleared the isolation, the second hid the chip and the dblclick\n isolated it again. A click that clears an isolation is remembered for a\n moment, and the double-click that follows it on the same chip clears; on\n another chip it moves the isolation there.\n- **A radar ignored `yAxis.min` / `max`.** The rim was always the data\n maximum, so scores out of 100 filled the dial to whatever the best score\n was and two radars could not be compared. The rim honours a pinned axis,\n a value past it sits on it, and a pinned minimum is the centre.\n- **A pie sized its gutters by the widest label on either side.** Small\n slices with long names on the left kept the same room on the right for a\n \"Chrome 62%\", and the pie drew at half the radius the pane had. The\n gutters are per side, the pie sits centred in what they leave, the floor\n radius is a quarter of the short side, and each side truncates to its own\n room.\n- **A waterfall tooltip read \"$0\" on a total.** A total bar holds 0 in the\n data and its running sum in the geometry; the tooltip and the\n screen-reader table now read the drawn value. Its x labels also tilt by\n the same fit rule as a bar chart's, with the angle the renderer needs:\n they were flagged as rotated with no angle and drew truncated instead.\n- **Histogram edges read \"1.3k, 1.3k\".** Bin edges are written at the\n precision their width needs (whole numbers with separators for a 44ms\n bin, two decimals for a 0.2 bin) rather than in the compact tick form that\n gave two neighbouring edges one label.\n- **A heat map ignored `dataLabels` in the spec.** The cell label read the\n component prop alone, so `dataLabels: { show: true }` in the spec drew\n nothing. Colour legends on heat maps and calendars also round their steps\n to the precision the range earns (\"20, 94, 167\", not \"20, 93.5, 167\").\n- **The range area read as three lines.** Its band filled at the wash an\n area under a line gets, with both edges at full stroke. The band is the\n mark: it fills at 0.35 and its edges are thin.\n- **Annotate mode pinned a tooltip instead of a note** when `tooltipSticky`\n was on too; the annotate click now owns the click.\n- **Drawings on a time axis warned on every point.** The drawing tools write\n a timestamp for every pointer position, and the spec validator matched\n those against the category list. It skips the check on a time or number\n axis, as it already did for reference lines and annotations.\n- **The panel's export menu and saved-charts dialog ignored Escape.** Both\n close on Escape and hand focus back to the button that opened them.\n- **A gauge wrote \"99.2 %\".** A symbol unit (%, degrees) hugs the number; a\n word unit (\"ms\") keeps its space.\n- **The right axis title was clipped.** Its glyphs point outward under the\n rotation and ran past the edge of the SVG.\n- **Pie callout labels ran off the chart in a narrow pane.** The pie kept a\n fixed 34px margin for its outside labels whatever their length, so a\n \"Samsung Internet 3%\" in a 380px pane was clipped to \"%\" and \"Cl\". The\n radius now makes room for the widest label on each side, keeps at least a\n fifth of the short side, and hands the renderer a per-side character\n budget to truncate to when even that is not enough.\n- **The brush strip inherited the chart's titles, axis labels and marks.**\n A title and subtitle took 45 of the strip's 88 pixels and the x labels\n another 30, leaving the mini-map a five-pixel smear under an empty band.\n The brush spec now mutes titles, axis titles and labels, reference lines\n and bands, annotations, drawings, series labels and data labels.\n- **A category chart tilted its x labels by count, not by fit.** More than\n eight categories, or any label over nine characters, tilted every label\n to -40 degrees even on a thousand-pixel chart with room to spare. `auto`\n now tilts only when the widest label does not fit its slot.\n- **A heat map wrote every column label whatever the cell width**, so\n twenty-four hours at 33px a cell read \"00:0001:0002:00\". The column\n labels thin out the way a bar chart's do.\n- **A calendar labelled the padding days of the next year.** The grid pads\n the range to a full week, and a December ending on a Thursday picked up a\n \"Jan\" tick for the two padding days. Month labels stay inside the range.\n- **A waterfall could not open on a value.** A total bar always read the\n running sum, so \"Revenue 4300\" marked as a total drew as zero and every\n bar after it hung below the axis. A total with a value now sets the sum;\n a total with 0 still reads it.\n- **`rowsToChartSpec` with `topN` duplicated a category called \"Other\".**\n A real \"Other\" in the data came out beside the folded one, two categories\n with one name, which the renderer threw on as a duplicate key. The tail\n now folds into that category.\n- **A pin annotation showed \"O…\" and nothing else.** The head held\n `truncate(label, 2)`, an initial plus an ellipsis, and no label was written\n beside it. The head carries the initial and the label sits beside the pin\n like a dot's does.\n- **A chart's hidden data table took up to 17,000px of scrollable space.**\n The screen-reader table (one row per category, capped at 1,000) carried the\n visually-hidden recipe itself, but on a `<table>` `height: 1px` and\n `width: 1px` are minimums and `overflow: hidden` does not clip, so the\n table was invisible and as tall as its rows, and every scroll container\n around a chart (the demo pages first of all) scrolled on through that much\n empty space. The clip now sits on a wrapping div; the table keeps its id,\n which the svg still points at.\n- **Two ARIA faults the axe audit found.** The chart's SVG was\n `role=\"img\"`, whose children are presentational to assistive technology,\n so the focusable marks inside it (category zones, slices, a drawing) were\n a nested-interactive violation and could be skipped by a screen reader; an\n interactive chart is a labelled `group` now (a thumbnail with\n `interactive={false}` stays an image). Sankey links carried an\n `aria-label` with no role, which ARIA prohibits; they are named images in\n the focus order.\n- **A tree map ignored `spec.tree`.** The field is documented as an alias of\n `treemap` and the sunburst honoured it; the tree map read only `treemap`.\n- **An autosized chart with a side legend grew without end in a plain block.**\n `legend=\"left\"` / `\"right\"` lays the chart out as a three-row grid, and a\n grid puts a gap between every track whether or not the toolbar and brush\n rows have anything in them. The autosize maths counted a gap only for the\n chrome that existed, so in a parent that does not pin the height, the host\n measured 8 or 16px taller than the plot it was told to fit, the plot grew\n into it, and the next measurement grew again - a few hundred pixels a\n second until the page ran out. Hiding the legend at runtime had the\n opposite fault: a dimension binding keeps its last value once its element\n is gone, so the vanished legend went on being subtracted and the plot\n ratcheted down to its 120px floor. Both fixed; a fixed-height parent hid\n them, which is why the docs' sizing example never showed either.\n- **`block` did nothing on eight editors.** The prop is declared once in\n `SvEditorProps`, and its own doc comment describes the symptom: \"in a form\n grid a row of inputs each stopping at a different width reads as broken\".\n `SvDropDownList`, `SvComboBox`, `SvMultiSelect`, `SvTreeSelect`,\n `SvGridSelect`, `SvAutoComplete`, `SvTextArea` and `SvDateRangeInput`\n accepted it by type and ignored it, so they stopped at their own 200-280px\n default while the text inputs beside them filled the row. `<SvForm>` was\n also not passing it to seven of the controls it mounts - both halves had to be\n fixed for a form row to line up.\n- **`cellDataType: 'dateString'` stored a timestamp after an edit.**\n Committing ran through the shared date coercion (`new Date(v).toISOString()`),\n so picking Christmas stored `2026-12-25T01:00:00.000Z` and the cell showed a\n timestamp beside neighbours showing plain dates - on a calendar day that\n depended on the user's timezone, since the conversion went through UTC. The\n picked date is now kept as the picked date.\n- **The filter row mounted a native date input** while the cell editor mounted\n the grid's own picker, so one column looked like two different products\n depending on where you touched it. Both use the grid's picker now.\n- **`editorType: 'number'` dropped the character you were typing.** The\n editor mounted `<input type=\"number\">`, whose value sanitization reports\n `\"\"` for anything not already a valid float - so `12.` read as empty, and\n typing `12.5` produced `125`. Same for a lone `-` and `1e`. It is a\n text input with `inputmode=\"decimal\"` and a digit filter now; the trade is\n the native spinner.\n- **Cell context menus and the comment editor floated at stale coordinates\n after a scroll.** Both are positioned at raw cursor coordinates and rendered\n `position: fixed`, but neither was in the scroll effect's gate, so they hung\n over unrelated cells. The comment editor SAVES on scroll rather than\n discarding - backdrop-click and Escape are the gestures that mean \"throw this\n away\"; a scroll is not, and must not destroy typed text.\n- **The footer summary row server-rendered as empty cells.** The totals were\n assigned from an `$effect`, and effects never run during SSR - so the server\n emitted a summary row that took up space and drew its border but held no\n numbers. They appeared only after hydration (a visible pop-in), and never at\n all for a reader with JavaScript off. A grid under the aggregation cell\n limit now derives its totals synchronously, so they ship with the HTML; a\n very large grid keeps the rAF-deferred effect so it still paints before it\n totals. `pnpm ssr:check` asserts the real aggregate now.\n- **The grid painted one unmeasured frame on every mount.** `hasMeasured`\n gates the custom scrollbars, the 16px scrollbar gutter on a trailing\n right-aligned column and the top pager (which carries a `border-top`), but\n it only flipped inside the `ResizeObserver` callback - and that callback is\n deliberately deferred by one `requestAnimationFrame`, so the browser was\n guaranteed to paint a frame with those missing and correct it on the next.\n On a first load that was the \"flashing scrollbar\"; in an app that recreates\n the grid per navigation (a `{#key}` around it, or a route that remounts) it\n showed up as the grid flashing on every sort / filter / page change, with a\n stray border line. The container is now measured synchronously in the mount\n effect - before the first paint - and the observer still handles later\n resizes. Covered by an e2e regression test, since jsdom has no layout to\n miss a paint with.\n- **Pager page-size trigger rendered as a stock button until first click.** The\n closed trigger is a placeholder until the lazy dropdown chunk loads, but its\n box styling only existed in that chunk's scoped CSS, so server-rendered and\n freshly-mounted pagers showed a UA-bordered, left-hugging `<button>` inside the\n bordered box. The placeholder now gets the same rules from `SvGrid.css`.\n- **Virtualized lists no longer flash blank on a fast scrollbar-thumb drag.**\n A fast drag can move the viewport into the windowed list's off-screen padding\n faster than JS can re-render the rows there; the padding now paints faint row\n skeletons, so `SvListBox` / `SvDropDownList` stay visually filled at any scroll\n speed. Also removed an app-wide `flushSync` from the scroll handler that could\n stall the very first scroll.\n- **Dock manager auto-hide now shows every tab of a multi-tab leaf.** Sending a\n leaf with two or more tabs to auto-hide created a single edge tab; it now\n creates one edge tab per pane.\n- **Ticking one row in a large grid took over a second.** Once any row was\n selected, every change walked all rows through the lazy row list to work out\n the header checkbox. At 1,000,000 rows (jsdom) one tick went from 1.3-1.8 s\n to 4-36 ms, and select-all from 4.2 s to 0.4 s.\n- **Tab never left the grid.** Every Tab was consumed and the cursor clamped\n at the last cell, so no key moved focus out (WCAG 2.1.2). Tab on the last\n cell and Shift+Tab on the first now leave the grid.\n- **No focus indicator when the grid is reached by Tab, or under forced\n colors.** The active-cell ring stayed hidden until a click, and Windows High\n Contrast removed it (it is a box-shadow). It now shows on keyboard focus, and\n forced colors get a `Highlight` outline.\n- **The cell editor had no accessible name.** The text, number and multi-line\n editors are now labelled with their column's header.\n\n#### Security\n\n- **CSV / formula injection in exports.** `exportCsv`, `exportTsv` and the\n chart's CSV download wrote text such as `=HYPERLINK(...)` as is, which a\n spreadsheet runs as a formula. Text starting with `=`, `+`, `-`, `@`, a tab\n or a carriage return is now written with a leading `'`; numbers and signed\n numbers in text form (`-12.50`) are unchanged. `escapeFormulas: false` turns\n it off; `copyToClipboard` takes `escapeFormulas: true` to turn it on.\n\n### @svgrid/enterprise\n\n#### Added\n\n- **SvGrid Base: Delete forever can be one transaction.** `transaction` next to `execute` on\n `createSqlDataSource`, `createBaseEndpoint` and `baseFromDatabase`, and `linkedFrom` on\n `createKitHandlers`, make it one server step. See Undo, trash and import for each driver.\n\n- **SvGrid Base: Edit fields says what it sets off.** Past 10,000 records its question gives the\n number of automation runs the change can start, and \"Also run automations\" can be unticked.\n\n- **SvGrid Base: a comment not sent stays with its record.** Stepping to another record no longer\n carries it into that record's box, and closing the record keeps it and says so.\n\n- **SvGrid Base: `baseFromEndpoint` takes a live feed.** `realtime: (table, apply) => stop` is called per\n table and per junction table.\n\n- **Gantt: `pickUpToMove` and `text`.** Keyboard moves in the scheduler's way, and every\n word of the view for a page in another language. Base uses both.\n\n- **SvGrid Base: soft delete.** `softDelete: 'deleted_at'` on `createSqlDataSource` and\n `createSupabaseDataSource` marks a record instead of removing it. Reads, counts, groups,\n totals, lookups and rollups skip it, a restore clears the mark and rewrites nothing, and\n emptying the trash is the real delete. `createKitHandlers` takes `restore` and `purge`,\n inside the tenant's `scope`.\n- **SvGrid Base: a view always gets its answer.** When a data source cannot run a\n filter, sort, group or total on a computed field, or fails on one, the page reads\n the table a block at a time, works the field out with the cells' code and serves\n the view by id, with the count in the tab bar. A record that changes is updated\n where it stands, and taking the sort or filter away stops the read. `computes` on\n `baseSource` says what the source can work out itself; a `queryRecords` backend\n needs `computes: () => true` to keep those requests in the database.\n- **SvGrid Base: \"+\" opens a draft.** On a big table a new record is stored at its\n first value and not at the click, so one closed empty leaves nothing behind. It\n starts with the values of the view's filter, what the database fills in comes back\n into it, and one the database refuses keeps its values and tries again. \"+\" is in\n every view of records, and Ctrl+Z takes a stored record out again.\n- **SvGrid Base: add a field from the header.** `columnAdder` is on by default for\n whoever may change the schema, and the \"+\" stays at the right edge of a wide\n table. `createSqlDataSource` with `schemaChanges` adds the column on Postgres,\n MySQL and SQLite, `addField` on `baseSource` does it on your own source, and a\n source that cannot shows the `ALTER TABLE` to run. A new field never takes over a\n column already in the table.\n- **SvGrid Base: Undo keeps what it cannot write.** A record goes back with every column\n read, and a column the database generates is left to the database, on any engine.\n- **SvGrid Base, in use.** A record's position is the view's own (\"1 of 1,000,000\"),\n and Next and Previous read past what is loaded. A click or Enter opens a Board card.\n Ctrl K works from anywhere on the page. A group of mixed ticks shows as mixed, group\n headers show what the cell shows, and a field deleted from a view's filter leaves it\n (undo brings the condition back). A record outside the view's filter says so.\n- **SvGrid Base: select all means all.** On a big table the header checkbox selects\n every record of the view as a rule, and the count says so. The selection bar's\n Delete reads what the rule covers, asks with the exact number, and deletes in\n blocks with a Stop button. Up to 10,000 can be undone, in one write.\n- **Block writes.** `ServerDataSource` gains optional `createRows` and `deleteRows`;\n `createSqlDataSource` and `createSupabaseDataSource` implement both.\n- **`filterModel.searchIn`.** The fields a global search may look in. A base sets it\n so that a field hidden by a share or a permission cannot be probed by searching.\n- **Server row model:** `pin` and `unpin` show a row above the list that no block\n holds, outside the count, and `leafTotal` gives a grouped view its true size.\n- **Computed SQL:** dates, `MAX` and `MIN` on MySQL and SQLite, `FIND` on MySQL, and\n `ROUND` and `INT` on SQLite.\n- **SvGrid Base: a table has no size limit.** A table used to stop at `limit`\n records, 10,000 by default, and a table on `serverRows` kept that many in the\n page for everything but its grid views. Now no read stops short. A table that\n outgrows the page (`holdInPage`, the new name of `limit`) is read from the\n database a part at a time, by itself, and the page holds none of its records.\n Links, lookups and rollups read records by id, and a rollup over a link stored\n on the big table is added up by the server: in demo 723, a table of 200\n customers shows each one's orders and revenue over a million. The link picker,\n search across tables and the grid's search box search the whole table.\n Automations run on any record, and a scheduled one on every match. Share\n links show the whole table. A new record's autonumber is the table's next.\n New in the data source contract: `groupRawKeys`, for a link grouped by id.\n\n- **SvGrid Base: `createSqlDataSource` runs a view's filter.** It used to leave\n `filterModel.expression` out, so a filtered view on a SQL table showed every\n record. It also filters, sorts, groups and adds up on formulas, lookups and\n rollups now: `computedSql` (`@svgrid/enterprise/base/compute`) turns them into\n SQL, or says it cannot rather than answer differently from the cell.\n\n- **SvGrid Base: formulas in SQL say what a cell says.** More functions translate\n (`SWITCH`, text slices, `MOD`, `POWER`, `SQRT`, days and weeks on dates), and\n each is checked against a cell on real Postgres, MySQL and SQLite over blanks,\n negatives and quotes. `generatedColumnSql` writes a formula as a generated\n column for Supabase, and `generated` makes a filter read it.\n\n- **SvGrid Base: `schemaChanges` on `createSqlDataSource`.** On Postgres a field's\n type change is one `ALTER` and a table's copy one `CREATE`. Off by default.\n Without it, a big table's values are rewritten sixteen writes at a time.\n\n- **SvGrid Base: Supabase with aggregates off.** How a project starts. Kanban\n lanes and link counts now read their size with plain counts, and a total that\n needs aggregates says how to turn them on (`AggregatesOffError`).\n\n- **SvGrid Base: a link edits from either side of a big table.** A customer's\n orders tick in the picker, and each tick writes that order. Names pasted into\n a link cell are found on the server.\n\n- **SvGrid Base: changing a field's type on a big table converts its values.**\n It asks first, then uses `convertField` or rewrites them a block at a time.\n\n- **SvGrid Base: Download as SQL writes every record of a big table,** a block\n at a time. Duplicate table copies records that fit in the page, or in the\n database with the `duplicate` option.\n\n- **SvGrid Base: a Kanban lane keeps its order.** Sorted by a number field, a\n card dropped elsewhere in its lane writes that number.\n\n- **SvGrid Base: every view reads a whole table of millions.** Views other than\n grids used to show the first records of a big table.\n Now a Kanban lane shows its true size and reads its cards as they scroll by;\n a calendar reads the dates on screen, with each busy day's size and a \"+N\n more\" that lists all of that day; a Gantt reads its rows by start date; a\n gallery, list and inbox draw and read what is in sight; a chart and a\n dashboard have the server add up. It is the same `getRows` request a grid view\n sends, so a source that answers a grid view answers these. `queryRecords` now\n answers `aggregations` and `needsGrandTotal`. In demo 723 (a dev build, one\n laptop), each view of the million opens in under a second.\n\n- **SvGrid Base: a Rich text field type (`fieldType: 'richText'`).** It edits\n in a panel over the cell with a formatting toolbar: bold, italic, underline,\n strikethrough, bullet and numbered lists, links and clear formatting.\n `fieldProps: { toolbar: 'full' }` adds headings, quotes, code blocks, undo\n and redo. Ctrl+B / I / U format the selection and Ctrl+K adds a link;\n Ctrl+Enter, Tab or a click outside saves and Escape cancels. The value is\n HTML, sanitized when it is stored and again before it is drawn. A grid row\n shows the formatting on one line, a taller row height as lines, and the\n expanded record and the form show all of it. Search, the filter, sorting,\n copy, lookups and formulas read the words without the markup. Converting\n from long text renders its Markdown; converting back keeps a line per\n paragraph and list item. Demo 722 (release notes) shows both toolbars, a\n filter view and a formula over a note; demo 511 (content calendar) uses it\n for the brief. The long text option that renders Markdown is now labelled \"Format\n with Markdown\", to tell the two apart.\n\n- **SvGrid Base in your language.** Every word a base shows (the tab bar,\n the view bar and its panels, the record view, forms, the field editor and\n the field types, menus, notices, color and icon names) comes from one table\n of about 1,100 messages. `setBaseMessages(words)`, `<SvBase messages>` or\n `<sv-base>`'s `messages` property hand over the words you have; the rest\n stay English. Counts take `.one` / `.other` forms, and a `plural` rule\n for languages with more. `BASE_MESSAGES` lists every key with its English.\n A trash item for a table with one record now reads \"1 record\", not\n \"1 records\".\n\n- **SvGrid Base: Vote and Sparkline field types.** A vote field keeps who\n voted (user ids): a click on the cell, Enter or Space adds the signed-in\n person's vote or takes it back, through the grid's edit path, so undo and\n protected fields hold. It sorts by the count and filters as people (\"has any\n of me\"). A sparkline field draws a list of numbers as a line, area or column\n chart, typed and pasted as `3, 7, 4, 9`, sorted by the last value.\n\n- **SvGrid Base: a trash kept in your backend.** `<SvBase trashStore={{ list, add,\n remove }}>` reads the trash when the base opens and tells the store of every\n item deleted, restored, undone or emptied, so it survives a reload and is\n the same for everyone.\n\n- **SvGrid Base on a phone: boards and calendars.** A Kanban lane takes the\n table's width and snaps into place as you swipe; a calendar opens in its\n agenda. Gallery cards and forms were one column already.\n\n- **SvGrid Base: tables of millions of records.** `baseSource(ds, { serverRows: true })`\n has a table's grid views read it a block at a time through the server row\n model, with the view's filter (`filterModel.expression`), sort, groups and\n search sent to the server, and its edits, new records and deletes written by\n id. Kanban, calendar, gallery and the other views show the first `limit`\n records, and say so. Grouped views get one row per key with its count from\n the server, and the view bar counts the server's records. `queryRecords`\n answers such a request over records a Node server holds,\n `fieldFilterToSql` turns a view's filter into a `WHERE` clause for\n Postgres, MySQL or SQLite, and `fieldFilterToPostgrest` /\n `supabaseFieldFilter` into a PostgREST filter: `createSupabaseDataSource`\n has a new `expression` hook, and `baseFromSupabase` a `serverRows`\n option. A link edited there changes the field that links back for that\n record only (`linkChanged`), not for the records the page never loaded.\n Demo 723 pages through 1,000,000 orders.\n\n- **SvGrid Base: formulas on a server (`@svgrid/enterprise/base/compute`).**\n `computeRecords(tables, tableId)` works out every formula, lookup, rollup\n and count with the grid's own engine, and `evaluateFilter` /\n `filterRecords` test records against a view's filter, with no DOM and no\n Svelte, so an API, an AI tool or a report sees the values people see. A\n test works out a base both ways and compares them record by record.\n\n- **SvGrid Base: permissions.** `<SvBase permissions>` (and a table's own\n `permissions`) take `canEdit`, `canCreate`, `canDelete`,\n `canEditSchema`, `canEditViews`, `canComment`, `fields` (`'hidden'` or\n `'readOnly'` per field) and `viewsOnly`. The screen offers only what the\n person may do: no \"+\" row or Insert record without `canCreate`, no field\n editor or table menu without `canEditSchema`, view changes kept in the page\n without `canEditViews`. A hidden field takes the formulas, lookups and\n rollups that read it along, and the stored records and columns are never\n changed by what a person is not shown. `<sv-base>` takes the same as its\n `permissions` attribute.\n\n- **SvGrid Base: realtime changes update only what changed.** The\n `realtime` callback's `apply(changes)` takes inserts, updates (the whole\n record or just the changed columns) and deletes, or Supabase Realtime events\n as they come, and updates those records in place, a burst at once, with the\n same highlight and credit as before. `baseFromSupabase` uses it. `apply()`\n with nothing still reads the table again.\n\n- **SvGrid Base: a record history that lasts.** `setRecordHistory({ list, add })`\n reads a record's history from your audit log each time it is opened (a\n promise is fine) and hands it each change made in the page.\n\n- **Change review in the record view.** An expanded record lists its pending\n proposals under their fields, with Accept and Reject per field and for the\n record. `review.acceptRecord`, `rejectRecord`, `pendingIn`, `sources`,\n `pendingFrom` and `revertSource` (everything one agent did, across its\n sets) are new, and the panel has a From picker when more than one source\n has proposals.\n\n- **SvGrid Base: undo for tables, form footers and link allowlists.** Adding,\n renaming, duplicating, deleting and importing a table are undo steps.\n `formPrefill` takes a list of the fields a link may fill\n (`prefillFields` on `SvBaseForm`), and a form view takes `formFooter`\n text or `<SvBase formFooter>` as a snippet. `<SvBase onMention>` hears\n mentions. `<sv-base>` fires `cellchange`, `recordadd`, `recordsdelete`,\n `trashchange` and `mention`, and takes a `read-only` attribute.\n\n- **A grouped grid prints its groups.** `print()` printed a grouped grid's\n leaf rows only. It now prints a header row above each group, \"Region: EU\n (12)\", indented by level; `groupRows: false` leaves them out.\n\n- **`print({ open: false })` returns the printable document.** `print()` and\n `printGrid()` now resolve to the HTML they built, and `open: false` skips\n the print window and dialog, for a preview pane or anything that times the\n printable view. It is a plain table, not the grid.\n\n- **PDF: `pdf.fit`, `pdf.repeatColumns` and `pdf.font`.** `fit` chooses what\n happens when the columns do not fit across the page (shrink the text, split\n the columns over pages, or both, the default); `repeatColumns` says how many\n leading columns repeat on each page of a split. `font` prints with a font\n you supply, base64 or a URL, for scripts Roboto lacks (Chinese, Japanese,\n Korean, Arabic, Hebrew, Thai, Indic, emoji); without one the export now\n warns when it sees them.\n- **PDF export in a worker: `pdf.worker` and `@svgrid/enterprise/pdf-worker`.**\n pdfmake renders in one synchronous run, about a second per thousand rows on\n a desktop machine, and on the page that froze the tab. With\n `pdf.worker: () => new Worker(...)` and a worker script that calls\n `servePdfWorker()`, the document goes to the worker as data and the page\n stays responsive: a 5,000-row export took about two seconds while the page\n kept drawing at 60 fps, with progress through `onProgress` and an abort that\n terminates the worker. A PDF of more than 2,000 rows rendered on the page now\n logs a warning that points here. `buildPdfDocData` and `hydratePdfDoc` split\n the document builder for this; `buildPdfDocDefinition` works as before.\n- **Grouped PDFs total like the grid.** Subtotals use each column's\n `aggregate` (avg, min, max, count, countDistinct, a function) instead of\n always summing, a total row closes the table (`pdf.grandTotal: false` to\n leave it out), and group names are formatted as on screen. `getColumns()` in\n `@svgrid/grid` now reports each column's `aggregate` for this.\n- **PDF: `pdf.labels`, `pdf.watermark`, `pdf.author`.** Replace the footer's\n page and date text and the subtotal and total labels; print a faint\n watermark across every page; and fill the document properties, so a viewer\n shows the report's title rather than the file name.\n- **PDF column widths follow the text.** Each column gets at least its\n longest word and the rest of the page goes to the columns with the most to\n say, instead of equal widths: a 60-row, 8-column order list went from three\n pages to two.\n- **The pivot designer's Chart view grew up.** It offers every shape a pivot\n can take (bar, line, area, lollipop, pareto, the three radial forms, pie,\n funnel, waterfall, radar, heat map, stream) in the panel's groups, with\n Stacked, 100% and Horizontal where the type uses them, the chart's own\n toolbar (PNG, SVG, PDF, print, copy), its spoken summary and a legend\n under the plot. It had six types and a Stacked box.\n\n- **`pivotToChartSpec` carries the measure's format and name.** Pass the\n value chip's `format` and the chart reads \"$470k\" on the axis and\n \"$469,662\" in the tooltip, in the measure's currency and locale; percentage\n points get a formatter that appends the sign. With one measure the value\n axis is named after it (`yAxisTitle` overrides, `null` for none). The\n designer's Chart view passes the format when its measures agree, and\n formats plainly when a layout mixes a currency and a count.\n\n- **PDF export with charts and a KPI strip.** `pdf.charts` prints charts with\n the table: a rendered chart's element is rasterised on export through the\n grid chart's PNG path, or pass an image data URL; each takes a title, a\n caption and a width, and goes above the table or below it\n (`chartsPosition`). `pdf.kpis` prints a strip of headline numbers, each a\n label over a big value with an optional coloured delta line. Roadmap\n discussion 36.\n- **The selection bar renderer, plus bulk edit.** `enableSelectionBar()`\n (or `installEnterprise`) registers the renderer behind the free\n `selectionBar` prop. The bar carries a count chip, your actions, an overflow\n menu past `maxVisible`, and Clear; at phone width it collapses to icons and\n keeps an accessible name on each. **Edit fields** opens a drawer that edits\n one or many rows at once: a field the selection disagrees on opens blank and\n stays per-row unless you touch it, so applying to 40 rows does not flatten the\n values you did not mean to change.\n- **Scheduler booking rules and conflict detection.** New model helpers\n (`overlapCount` for per-resource overlaps, `overlapsBands` for working-hours\n bands) back resource double-booking checks and business-hours enforcement.\n New demos: booking rules, financial trading hours, and HR shift coverage.\n\n#### Fixed\n\n- **SvGrid Base: one Undo or Redo at a time.** Redo pressed while a range Undo on a paged table was\n still writing read the records before the Undo's later blocks landed: the data ended undone or half\n pasted while the page said \"Redone: edit 6,000 records\". Now a second Undo or Redo while one runs is\n refused with \"Undo is still running.\" and the buttons show it busy. An Undo or Redo of more than one\n block runs in the paste's dialog with its count and Stop, leaving the page asks first, and what it did\n is said when it ends, with the records or cells it changed (not those a teammate kept, a deleted\n record or a refused write). A small paste's count is said once its writes have answered.\n The dialog covers every Undo and Redo of more than a block: a delete (its Undo says the records\n it put back, not those a teammate restored first), the records a paste added, and more than\n 1,000 cells of a table the page holds. A cell undo of a record the view no longer shows holds its\n turn until that record's write has answered.\n- **SvGrid Base: Undo of a new record before its insert answers.** The step was a cell edit until the\n database answered, so Undo wrote an empty name and the record stayed. The \"add record\" step now\n exists from the moment the row does, what is typed into the record folds into it, and Undo waits for\n the insert, then takes the record out. A refused new record's Activity no longer shows what was typed.\n- **SvGrid Base: Try again from a record that fell to the end.** It wrote the first line into that\n record and offered to add the rest as new records. Now it writes nothing and says how many rows stand\n below the record against how many the first try covered; the dialog of a Try again names the rows it\n writes, which it covers on screen.\n- **SvGrid Base: a range over 1,000 records on Supabase or PostgREST is written.** The ids check read the\n whole range in one request, and a server that answers 1,000 rows at most (`db-max-rows`, the Supabase\n default) gave fewer back: every paste, clear, fill, one value or copy of more than 1,000 records said\n \"Records moved\" and wrote nothing. A short answer now reads on, a page of the server's own size at a\n time, and only a different id sequence counts as moved; a source with no cap still answers each check in\n one request. These checks select the key alone on Supabase and PostgREST. A download, a duplicated table\n and a view's group reads from a source that sends no count also read on past a short answer.\n- **SvGrid Base: a Cut the browser refused says so.** It did nothing in silence; now \"The browser would\n not put the cells on the clipboard, so nothing was cut.\"\n- **SvGrid Base: a notice that stays no longer covers \"+ Add record\" or a record's Delete and Close.**\n Notices in the bottom-right corner start above the button, or an open record's footer, where they\n meet.\n- **SvGrid Base: a table named by its key keeps its records.** A table with no text column shows\n its key as its first field. A record added there was deleted and created again under a new key at\n the next change of any record, a tab switch or a sort, on Postgres, MySQL and SQL Server: a foreign\n key with `ON DELETE CASCADE` took its children with it, \"record created\" automations ran each time\n and a table that marks deletes filled its trash. Edit field on the key could change its type, which\n wrote every record again under a new key, and offered \"Who can edit its values\". With a feed, a new\n record's key stayed blank and the page counted its own insert as a teammate's change. The key field\n now holds the key the database gave the record, in the key's own type, from a read, a write's answer\n or a feed; no edit, paste, fill, undo or field change writes it. Edit field on it changes its name\n and description only, and Duplicate field makes an ordinary field. A key column named `id` is the\n field `id_key` in the table's description, which `rename` maps back to `id`.\n- **SvGrid Base: a table with `customer` and `customer_id` opens.** The link from `customer_id`\n took the name `customer`, so two fields shared one id: the tab threw, showed the previous\n table's records, and the link and its field back were lost. Two keys that read as one name\n (`owner` and `owner_id`) did the same. Now a link whose name is taken keeps its column's name as\n its id and is headed \"Customer (link)\", or by its column when both are links (\"Owner id\"); both\n fields show, and each link keeps its field back.\n- **SvGrid Base: a client's filter on the tenant column is combined with the scope.** The scope\n replaced it, so `tenant_id = 2` asked by tenant 1 answered all of tenant 1's rows, and an\n `updateWhere` with that filter changed them. The two are combined now: another tenant's value\n finds no rows and changes none.\n- **SvGrid Base: a refused write names the record as stored.** A refused edit of the name field\n named the record by the value that was refused (\"Could not save Label of boom\"). A refusal by a\n foreign key of three columns named no field when the edit was to one of them: it names the key's\n fields now. The top bar's \"Not saved\" names them too.\n- **SvGrid Base: the status line opened in full shows no transport text.** It showed\n `svgrid kit: 409 Conflict - {json}` after the reason. It shows the reason, and the server's own\n words when it sent some that the reason does not say. A line with nothing more still opens, to read a\n reason the bar cuts short. Notices that quoted an error (a delete, a copy, a bulk edit, the\n trash) say the reason in words in place of the endpoint's or the REST API's status and body.\n- **SvGrid Base: a new record of a table whose database makes the key is read by no one before it\n has its key.** On a paged table, a draft (or a record whose insert was on its way) was asked for\n by its page id, and so were the records linking to it: Postgres refused the read on an integer\n key (\"invalid input syntax for type integer\"), and that text showed as a notice. Such a record is\n left out of those reads until the database has given it its key. A read that fails says so in\n words; the driver's text goes to the browser console.\n- **SvGrid Base: Duplicate field on a database table the base cannot add a column to copies\n nothing.** It copied the values into a column that was not there, so their writes could not land.\n It now says the copy needs a column and gives the statement that adds it.\n- **SvGrid Base on a REST API: the API's reason is shown, and a refusal of the values offers no Try\n again.** `createRestDataSource` passes `{ error }` or `{ message }` on as the reason, so a `422`\n says \"The server said: Amount must be 0 or more.\" where it said that no reason came. A server's\n words that do not end a sentence get a full stop, so \"You entered: -500\" after them reads apart. A `400`,\n `409` or `422` from any source offers no Try again, which would send the same values.\n- **SvGrid Base on Postgres: a foreign key to a table of another schema on the search path is a\n link.** `public.notes.task_id -> app.tasks` stayed plain text with both schemas on the path and\n both tables in the base. A key now links when its table is the one its bare name reaches. A key\n to a table that an earlier schema's table of that name hides stays plain, in its own schema too.\n- **SvGrid Base: a grouped paged view shows your own changes in its open groups.** Round 7 made a\n teammate's change read every open group again; every other refresh still read only the group\n rows. With no feed, a record you deleted stayed listed in its open group (and typing into it said\n it no longer exists), a record you restored from the trash or brought back with Undo did not show,\n and a new record, an edit that moved a record to another group, a renamed option, a converted field\n and the read after \"Records moved\" left the open groups as they were, while the counts changed.\n The server row model's `refresh()` with no route now reads the group rows and the loaded records of\n every open group on a grouped view, as `refresh({ all: true })` does, so every caller gets it.\n `refresh({ route: [] })` still reads the top level alone. On a grouped view or tree data an app's\n own `refresh()` now also reads the loaded blocks of each open group or node.\n- **SvGrid Base: a teammate's change to a sorted field takes its place in a paged view.** A feed that\n sends the row patched it where it stood, so a record whose sorted field changed stayed out of order\n until something else read the view. A change to a field the view sorts or groups by now reads the\n view again (every open group, when grouped); a change to any other field still patches the row and\n reads nothing. A view sorted or grouped by a formula or lookup reads again on any change, since a\n change to a field it reads moves it too.\n- **SvGrid Base: a face is never another person's while it loads.** User, created-by and\n last-modified-by cells reuse their faces by position on a scroll, and the browser kept drawing the\n last person's picture beside the new name until the new picture loaded. Another picture now gets\n a new `<img>`, empty until it loads, as attachment thumbnails do; the same picture keeps its\n element. The attachment preview's Next and Previous do the same.\n- **SvGrid Base: a checkbox cell is named by its field.** It read \"Checked\" or \"Not checked\" in\n English whatever `setBaseMessages` set, and a screen reader heard the state twice. Its name is the\n field's name (`fields.typeCheckbox` when the field has none), and `aria-checked` says the state.\n- **SvGrid Base: an image in rich text stays on the cell's line.** Under a reset that makes `img` a\n block (Tailwind's preflight), an image in a rich text cell took a line of its own: the text after it\n was cut off, or ran into the next row.\n- **Scheduler: a move keeps the event's length by the clock.** A drag, a keyboard carry, a timeline\n drag, the other selected events of a move, a series edit, Duplicate and a new event at a slot\n added real minutes to the start. On the night the clocks go back a one-hour event dropped on 1 am\n read and was stored as 1am - 1am, and a 45-minute one dropped on 1:30 ended at 1:15. The end is\n now the start plus the event's length by the clock, the length it had when picked up. An end the\n clocks skip lands after the skip, as a start does: on the night they go forward a one-hour event\n dropped on 1:30 reads 1:30am - 3:30am, one hour in real time. A timeline month drag over a\n 25-hour day ended an hour past midnight; a new all-day event on a timeline month was 24 hours,\n not one day. Both now keep whole days.\n- **Scheduler: the Agenda and the tooltip say when an event over several days ends.** A timed event\n from Monday to Friday read \"12am - 12am\"; it reads \"12am - Oct 30, 12am\". An all-day one over several\n days shows its first and last day instead of \"all day\".\n- **Scheduler: a keyboard carry lands at the time carried.** Each arrow stepped from where the last\n one landed, so an event picked up on Saturday at 2:30 am showed 3:30 am on the Sunday the clocks\n skip 2:30, and stayed at 3:30 am on Monday and after. Every step now counts from where the event\n was picked up (days by the calendar, slots by the clock), and a slot step always goes the way\n pressed. With 15-minute slots a step down from 1:45 am on that night landed at 3:45 am; it lands\n at 3:00 am.\n- **Scheduler: the event in hand stays in view.** A carry by the arrow keys never scrolled the\n calendar: the event went under the sticky header and out of sight. The day, week and timeline\n views now scroll with it, and a Gantt chart scrolls with a bar moved by the arrows.\n- **Scheduler: the top edge of an event that ends at midnight resizes it.** Dragged from 11 pm to\n 10 pm, an 11pm - 12am event became 12am - 12am, a whole day, and was written so. Its end is now\n read as 24:00 of its day.\n- **Scheduler: Duplicate can copy the event.** It called `onEventAdd` with the times alone, so the\n copy was a blank \"New event\". `onEventDuplicate(source, start, end, resourceId, allDay)` gets the\n event it copies. In a base Duplicate on a calendar event copies the record, as a card's Duplicate\n does. A whole-day event with no end field copied onto its own day; it copies onto the day after.\n- **SvGrid Base: keyboard focus shows on menu items under forced colours.** The \"All tables\" menu,\n the table menu and a summary's menu drew focus as a tint, which a contrast theme removes. They draw\n a `Highlight` outline there.\n- **SvGrid Base: a checkbox change is said in words.** A screen reader heard \"Done changed to true\";\n it hears \"Done changed to checked\" (`viewbar.valueChecked` and `viewbar.valueUnchecked`), and the\n record's Activity and the Inbox read the same words. A checkbox cell is `aria-readonly` only when it\n cannot be changed.\n- **SvGrid Base: the tenant column never names a record.** A table under `tenantColumn` with no\n `name` column took its first text column, the tenant, as every record's name: link chips all read\n \"A\" and errors said \"Could not save Site id of A\". The primary field is now the first text column\n that is not the tenant, not a key column and not a foreign key column (one that links nothing, a key\n of three columns or into another schema, included). With none, the record's key names it and shows\n as the first column, read-only, pinned and never hidden, moved or deleted, as any primary field is;\n links, errors and the record view read that name. An integer `tenant_id` placed first is passed over\n the same way, and the tenant is never the first column. `EntitySchema.foreignKeyColumns` lists every\n foreign key column a database read found.\n- **SvGrid Base: an empty database opens as \"No tables yet\".** `createBaseEndpoint` with `allTables`\n answered a database with no tables with a `403`, which the scaffolded page read as \"set\n `authorize`\", in development too. It now answers `200` with no tables and reads the database again\n on the next request, so tables made by `db:setup` show on a reload. On Postgres `allTables` listed\n only `public` while every query reached tables through the search path: it now lists the tables of\n `current_schemas(false)`, the first of a name winning as `to_regclass` resolves it, and the svgrid\n comments, the key default and the column types of a table come from that same table.\n- **SvGrid Base: a refused write says what is known.** A foreign key refusing a write (a value naming\n a record that is not there) read \"Other records depend on it.\" with Try again: it now reads \"The\n record Site id points to is not there.\" with no Try again, and the endpoint sends `409` with\n `code: 'link-missing'` and the key's `fields` when the database says which. A delete keeps\n `linked`. A write the server answered with an error (`request-failed`, a trigger's `RAISE\n EXCEPTION`) read \"The server gave no reason, so it may not have been stored.\"; it now reads \"Not\n saved: The server answered with an error. Whoever runs it can see why in its log.\" Only a write\n with no answer says \"may not have been stored\". New messages `shell.why.linkMissing`,\n `shell.why.linkMissingField`, `shell.why.linkMissingFields` and `shell.why.serverError`;\n `shell.why.unknown` has new words.\n- **SvGrid Base: a new record the database refused takes no second create.** Add row opens the new\n record's first cell; when its insert failed (an id column too narrow, say) while that cell was open,\n the row waited for the editor, and what was typed into it sent a create again (in a browser on\n MySQL, two more), each failing with its own notice. What is typed now goes with the failed record,\n for its Try again where there is one, the notice says \"Could not add\" with the name typed and the\n reason, and the row goes when the editor closes. A refused new record that stays listed (while another\n editor is open, or a draft on a table read a part at a time whose refusal no retry can change, such\n as an id column too narrow) takes no edit: a click, a double\n click, a typed key or a paste on it shows its notice instead of an editor, so nothing typed into it\n is dropped. An editor open on it when the refusal comes is closed with what it holds, which the\n notice names. A draft refused for a reason a retry may get past (no answer, a server error) keeps\n taking edits, and its next edit sends it again, as before.\n- **SvGrid Base: a query with no `pageSize` is a `400`.** It was a `500` (\"planToSql: limit must be a\n non-negative integer\"). `pageSize`, and `startRow` and `endRow` when given, must be whole numbers of\n 0 or more, or their digits; the answer says so.\n- **SvGrid Base: two foreign keys to one table give fields back named for their keys.** Customers got\n \"Orders\" and \"Orders 2\" for `customer_id` and `rev_customer_id`; they are now \"Orders (Customer)\"\n and \"Orders (Rev customer)\". One key alone keeps the plain name.\n- **`npx @svgrid/create`: the base template asks for current packages and has a favicon.** Its\n `package.json` asked for `@svgrid/grid ^3.0.11` and `@svgrid/enterprise ^3.1.16`, and it had no\n favicon, so the browser's request for one was a 404 on every page. It now has the SvGrid icon\n (`favicon.ico`, 16 and 32 pixel PNGs, and an Apple touch icon). The pivot dashboard and\n SvelteKit templates' floors moved up too.\n- **SvGrid Base: three records that move at once during a range read stop it.** On a sorted paged\n view, one teammate's edit that moved a record from the part read to past the end, one from the part\n not read into the part read, and one from past the end into the part not read, left every block's\n seam, the far end and the count as they were and repeated no record. A 6,000-line paste then wrote\n about 500 lines to the record beside the right one and said \"Changed 6,000 of 6,000 records\". The\n whole id sequence is checked now, in requests that ask for ids alone: a range longer than a block\n reads its ids first, in place of the record at the far end, and each block must bring the same ids\n in the same places; once the last block is read, the ids of the whole range are read again and must\n be the very ids read, in the same order. Any difference writes nothing. This holds for a range of\n one block too, and for copy, clear, one value and fill. A teammate's move inside the part already\n read now stops the job too, where before the paste went ahead. `createSqlDataSource` reads ids\n alone for these requests (`idsOnly`); a source that does not know the hint sends whole rows.\n- **SvGrid Base: Try again after \"Records moved\" goes from the first record selected.** In the same\n view it pasted by position: after a teammate's edit moved a record above the selection, every line\n landed one record down, a selected record got nothing and one outside the selection got a line. Try\n again now finds the first record selected by its id, goes from there over as many rows below it as\n before, as the list stands at the click, and selects those rows first so the screen shows what it\n writes. The notice says so: \"Records moved while this was read. Nothing was changed. Try again\n pastes from \"Acme\" down over the rows as they are now.\" If that record is gone or no longer\n among the rows shown, Try again writes nothing and says so. Opening or closing a group since counts\n as a change of the view. Paste, one value, clear, fill and copy alike. Messages `shell.rangeMoved`\n and `shell.copyMoved` are replaced by `shell.rangeMovedPaste`, `shell.rangeMovedValue`,\n `shell.rangeMovedClear`, `shell.rangeMovedFill` and `shell.copyMovedFrom` (with `{name}`): a\n `setBaseMessages` override of the old keys needs the new ones.\n- **SvGrid Base: Undo and Redo of a range say how many records kept a teammate's value.** Undo of\n a 2,500-record paste where a teammate had changed one record said \"Someone has changed this cell\n since\" before its blocks were written. It now says \"Someone has changed 1 of these records since,\n so it keeps their value.\" once the blocks are done. A small range undone cell by cell says \"1 of\n these cells\" in the same case, after its checks.\n- **SvGrid Base: a grouped paged view shows a teammate's change in its open groups.** A change from\n the feed re-read only the group rows: an open group kept showing old values with no sign they were\n old, a record moved to another group stayed listed under the old one, and with the changed fields in\n the feed the counts did not follow either. The group rows and the loaded records of every open group\n are now read again, so a value shows in place, a record whose group changed moves to its new group,\n and the counts follow. A feed that sends the changed fields patches the row at once and reads the\n groups again only when a grouped field changed. A group closed at the time reads again when it is\n opened. A read that fails keeps every group's rows and says so in the top bar, as an ungrouped view\n does. The server row model's `refresh({ all: true })` is what does it.\n- **SvGrid Base: Retry in a failed block takes the pointer under the pinned column divider.** Over\n the button the divider showed its resize cursor and its line, and the click relied on being passed\n on. The divider now lets the pointer through to the button while it is over it, and is the divider\n again once the pointer leaves. Its line is no longer drawn across a failed block's band, so the\n words and Retry are clear of it; everywhere else the line is as it was, under forced colours too.\n- **SvGrid Base: the top bar's full reason can be read on any device.** A narrow window cut the line\n short with an ellipsis, and the tooltip held only the server's own words, which a touch screen\n cannot show. A line with a reason is now a button: a tap, a click or Enter opens it in full,\n wrapped, with the server's words under it, and the bar grows only while it is open. Another press,\n or the notice going, closes it. The tooltip holds the whole line, then the server's words. A screen\n reader hears the line and the server's words once, from the button, which carries `aria-expanded`.\n- **SvGrid Base: each Restore in the trash is named by its record.** A screen reader heard a list of\n \"Restore\" buttons; it hears \"Restore Task 4\", as Delete forever already said \"Delete Task 4\n forever\". New message `shell.restoreItem`.\n- **SvGrid Base: \"All tables\" says which table is shown.** Its tables are radio items now, the shown\n one checked, so the tick is announced as well as drawn.\n- **Calendar: Day and Week on a day the clocks change.** Events were drawn an hour off their rows on\n a 25- or 23-hour day, in the page and in Base, and a drop or a slot wrote the time of the wrong\n row. They are drawn, dropped and written by the clock now. A carry by the arrow keys steps by the\n clock too: the night the clocks go back, 1:30 and one step is 2:00, not the second 1:00, and the\n event keeps its length. A Pro timeline's working hours on such a day, and the days after it, start\n at their hour; they were an hour early, and on a 25-hour day one day was counted twice.\n- **Calendar: an event over several days says its last day.** Its name gave the first day only, so a\n bar from Monday to Thursday was heard as a Monday event.\n- **SvGrid Base, WebKit with a finger: a tap beside a link selects, as everywhere else.** WebKit sends\n the press of a tap to the cell and its click to a link, chip or star a few pixels away. That\n click followed the link, opened the linked record or set the rating on the first tap. A click\n now acts only when the press began on the same thing; on a cell already selected a tap beside a\n link does what a mouse click there does, which opens the cell's editor, and does not follow it.\n- **SvGrid Base, forced colors: a ticked checkbox shows its tick.** The white tick sat on a fill that\n a contrast theme removes, so every ticked box read as empty. The tick, a given rating icon and\n your vote are drawn in the theme's text color.\n- **SvGrid Base: a menu item that is off is heard with why.** Download as Excel without jszip, and\n Delete table on the last table, are in the arrow-key order of their menu (`aria-disabled`).\n- **SvGrid Base: deleting the last record of a group in a list keeps focus among the records.**\n Focus went up to the group's header. It goes to the record after it, the first of the next group,\n or to the record before it when it was the last of the list.\n- **SvGrid Base: two records that trade places during a range read stop it.** A paste, copy, clear,\n one value or fill on a sorted paged view checked the ends of each block it read. When a teammate's\n edit moved one record into the part read and another out of it, the ends stayed put: one record was\n read twice, the other never, and the paste wrote a line to the wrong record and said \"Changed 6,000\n of 6,000 records\". A record read twice now counts as moved, and nothing is written.\n- **SvGrid Base: Try again after \"Records moved\" acts only in the view it came from.** Pressed after\n a switch to another view of the table, it pasted into the records at the same positions there,\n which nobody had selected. It now writes nothing if the view, its sort, filter, groups or shown\n fields changed, and says \"That view is no longer open, so nothing was changed.\" or \"The view has\n changed since, so nothing was changed.\" The same holds for the answer to a job's question: past\n 10,000 records, new records past the last row, and a delete.\n- **SvGrid Base: the read count of a range goes up a block at a time.** It read \"2,000\", \"3,999\",\n \"5,998\" records so far: each block after the first read one record of the last again and counted\n one less. Each block now brings 2,000 new records.\n- **SvGrid Base: the notice of a save that stopped part way goes with its Undo.** It stayed after the\n Undo and still said \"Undo takes these back.\"\n- **SvGrid Base: a bulk delete that finds records gone says so in one notice.** \"Deleted 2,598\n records\" with Restore and \"Deleted 2,598 of 2,600 records\" came together; now the notice with\n Restore says \"Deleted 2,598 of 2,600 records\".\n- **SvGrid Base: an edit of a record a teammate deleted reads \"This record no longer exists.\"** It\n read \"The record is no longer there, or you may not change it.\", which suggested a permission\n problem.\n- **SvGrid Base: records that link to each other in a circle delete in one go.** A delete block of\n `n1 -> n3 -> n2 -> n1` went level by level and found no record to start from, so Postgres and SQL\n Server answered \"Other records depend on this one\". Records in a circle now go in one statement,\n which Postgres, SQL Server and SQLite take. MySQL checks each row as it deletes and refuses them;\n the page says so in words, and that the link of one of them must be emptied first. Delete forever\n out of the trash does the same.\n- **SvGrid Base on SQL Server: the trash asked with no limit is its count alone.** It read one record\n where Postgres and MySQL read none.\n- **SvGrid Base on Postgres: a foreign key of two columns links again.** The catalog query paired\n every column of a key with every referenced one, so `(tenant, order_id) -> orders(tenant, id)` read\n as four keys: links showed empty and valid ones were refused. Keys are now read column by column in\n key order on every database, and only within the schema the base reads (a table of the same name in\n another schema, or a key into one, is no longer mixed in, on Postgres, MySQL and SQL Server). A key\n of the tenant column and one more is a link through that one within the tenant, and the tenant\n column stays the read-only tenant instead of an empty link field. Any other key of more than one\n column links nothing and is named in the log. On Supabase, PostgREST does not describe a key of two\n columns, so neither column is a link there.\n- **SvGrid Base: every link through a pair table, and the field that links back, is named for its\n pair table** once the plain name is taken: \"Tags (Ot rev)\", never \"Tags 2\".\n- **SvGrid Base: the All tables menu never squeezes an item.** With many tables, or with the Excel item\n that says jszip is missing, items shrank into each other; the menu now scrolls instead.\n- **SvGrid Base: importing an .xlsx without jszip says so in plain words**, as the Excel download\n does, instead of the developer's install command. `importData` and `readImportMatrix` reject with\n `code: 'no-jszip'`.\n- **Scaffold: dialogs, menus and the rich text editor use the app's font.** The `base`, `sveltekit`\n and `pivot-dashboard` templates set the font on the layout only, and what moves to `<body>` was in\n the browser's serif.\n- **SvGrid Base: a cold automation server judges every record of a block by what it held before.**\n The first write after the server started read the tables after that write, so a pasted block of 45\n \"Won\" ran the rule for one record, and could run it for a record that was Won already. The `audit`\n hook now has a `before` that `createKitHandlers` awaits before each write, so the first read lands\n first. Pass your own audit hook as `automations.audit('tasks', yourHook)` to keep it; a hook you wrap\n yourself loses `before`, and then each record of the first request goes by the fields the write named.\n- **SvGrid Base: a paged view whose read after a teammate's change fails keeps its rows.** One failed\n refresh replaced every loaded row with \"Could not load these rows\". The rows stay, the top bar says\n the table could not be read, and Try again reads them again. New on the server row model:\n `keepRowsOnRefreshError` and `staleBlocks` on each level. The top bar's Try again no longer slides out\n of sight on a narrow window, and a failed block's Retry under the pinned columns' divider takes the click.\n- **SvGrid Base: one feed for a base on an endpoint.** The docs showed one `EventSource` per table and\n junction table. On HTTP/1.1, which a Vite or Node dev server speaks, a browser opens at most six\n connections to a host, so a base of six tables left no connection for a write: \"Still saving\" for\n good. `baseFromEndpoint` takes `feed: (apply) => stop`, one connection whose messages name their\n table, and `createBaseFeed` shares one connection among `baseSource`s.\n- **SvGrid Base: the trash of the person who deleted follows a teammate.** A teammate's Restore and\n Delete forever left the record in the deleter's trash and its count, open or closed.\n- **SvGrid Base: focus stays off another record's Restore.** When a teammate's change took away the item\n holding focus in the trash, or turned its Restore off, focus moved to the next record's Restore, and\n Enter restored a record nobody chose. It goes to the list.\n- **SvGrid Base: a failed write gives the reason the server sent.** An endpoint that answered\n `{ \"error\": \"...\" }` without a code read as \"The server gave no reason\". The page now says \"The server\n said: ...\" for a write and \"The server answered with an error: ...\" for a read. The endpoint's own\n 500 sends `code: 'request-failed'` and keeps the driver's words in its log, as before.\n- **SvGrid Base: a range on a sorted paged view writes nothing when a teammate moves a record under it.**\n A paste, one value, Delete, a fill and a copy read the range a block at a time, by place in the view.\n A teammate's edit that moved one record during the read shifted the next block by one, so lines\n landed on the neighbours and one could land outside the selection, while the page said \"Changed 6,000\n of 6,000 records\". Each block now reads the last record of the one before again and checks it, and\n the record at the far end is read first and checked at the end. If one moved, nothing is written or\n copied, the page says \"Records moved while this was read. Nothing was changed. Try again.\", and Try\n again does the same action on the same cells, on the rows as they stand then. A double click on the\n fill handle that finds records moved says so too; it stopped in silence.\n- **SvGrid Base: new records keep the order they were made in.** `newRecordId()` put two random\n characters before its count, and its clock part ran over every 16.8 hours, so a paste past the last\n row of a paged table showed its new records shuffled. An id is now `rec`, the whole time, a count\n within the millisecond and four random characters: 19 characters, in creation order, and it never\n runs over. Ids made before stay as they are. **Breaking:** ids were 12 characters, so a text id\n column narrower than 19 (`varchar(12)`, `varchar(16)`) now refuses every new record. Widen it to\n 19 or more before you upgrade. The base says so in words: \"Record ids need 19 characters; this\n table's id column holds 16.\"\n- **SvGrid Base: the screen shows a range job when it says it is done.** After a range job or its Undo\n on a paged table, \"Changed 3,000 of 3,000 records\" came while the cells on screen kept their old\n values for a second or two. The rows on screen now take each block as it lands, also the blocks that\n landed before one failed.\n- **SvGrid Base: a record a teammate deleted no longer fails a scoped block on a table without soft\n delete.** Under a `scope`, a key no tenant holds, live or in a trash, is gone: a block skips it and\n finishes, one record by itself answers \"This record no longer exists\", and the key is not sent to\n the source. Another tenant's record, live or in its trash, is still a 403.\n- **SvGrid Base on MySQL: a parent deletes with its children.** Delete, and Delete forever, of a block\n holding records of a table linked to itself and the records that link to them failed on MySQL with\n \"Other records depend on it\". The block now goes a level at a time, the records that link first.\n- **SvGrid Base: a block's answer is used.** A paste whose values a server hook changed read each\n record again, a request a record: 400 for a 400-line paste. The answer is now followed in one step,\n and what a lookup needs of those records is read in one request.\n- **SvGrid Base: a rich text field renders under Trusted Types.** It was a blank page under\n `require-trusted-types-for 'script'`. A base with a field of every type now renders there, with its\n record view and rich text editor (`base-trusted-types.spec.ts`). The paths that still do not run\n under it are listed in SECURITY.md.\n- **SvGrid Base: \"Download this view as Excel\" says why when it cannot run.** Without the `jszip`\n package the item did nothing. It now says the app needs jszip, and a download that fails says so.\n- **SvGrid Base: a checkbox is a real TRUE or FALSE in Excel**, not the words `true` and `false`.\n `exportGrid` with `rawValues` writes a boolean value as a boolean cell too.\n- **SvGrid Base: a \"Could not delete\" notice goes once its records are deleted after all**, instead of\n staying beside \"Deleted 3 records\".\n- **SvGrid Base: two pair tables between the same two tables are two fields with two names.** Both were\n named after the other table, and a third got the second's field id. The second is now named for its\n pair table, as \"Tags (Order tags t)\".\n- **SvGrid Base on Supabase: `date` and `timestamptz` columns are date fields**, read by the Postgres\n type PostgREST names, as on the other databases. They were text.\n\n- **SvGrid Base: a keyboard move in a month calendar stays in sight.** A month drawn in five weeks reads a sixth\n that is not drawn. An event carried into it went out of sight, focus went to another record, Space picked that\n one up, and the first showed on a date it did not hold. The view now goes to the next month with the event, and\n a key on another event while one is in hand acts on the one in hand. An arrow across a change of the clocks moves\n a whole day: a week down used to land an all-day event on the evening before.\n\n- **SvGrid Base: a finger follows the mouse in a cell.** A tap on a link, email, phone or URL cell selects it, and\n the next tap follows the link, so on a tablet such a cell can be selected, copied and edited. A tap beside a\n checkbox's box or on a checklist selects the cell. A tap on the box, a star, a vote or a button acts at once.\n\n- **SvGrid Base: a selected list row or gallery card no longer looks focused.** It has the grid's selected-row fill\n and a tick by its title; the ring is focus alone. Under forced colors the tick stays.\n\n- **SvGrid Base: focus stays with the record.** After Undo of a board move focus goes with the card, not to the card\n that took its place, on a board read from a server too. After a confirmed Delete from a list it goes to the next\n record, not to its group. A note on why a record stays open (a comment not sent or not saved) is said aloud.\n\n- **SvGrid Base: group totals of a paged grouped view are right after each write.** After a\n read that a slow backend had not answered when the next write asked for another, every\n later write kept the old rows and totals on screen for 10 seconds, so the totals showed\n the write before. The block cache now frees a read's slot when it gives that read up (in\n `@svgrid/grid`, below).\n\n- **SvGrid Base: a paged view that cannot read its next part says so in view.** The tab bar\n says \"Could not load *table*\" with the reason and Try again, as a table read whole does,\n and the grid's \"Could not load these rows.\" with Retry sits on the first row wholly on\n screen, not on a row above it.\n\n- **SvGrid Base: a cold automation server sees its first change whatever the row carries.**\n An endpoint's row with a column no field names (a tenant, a sequence) made the first\n change after a start look like a change of nothing, and no rule ran.\n\n- **SvGrid Base: a paged group of records that link to nothing reads \"Empty\"**, as a lookup\n group does, instead of a blank label.\n\n- **SvGrid Base: an open trash follows a teammate's Delete forever and Restore.** It reads\n the table's trash again when the feed reports a change, and a record whose Delete forever\n stopped half way no longer reads \"just now\".\n\n- **SvGrid Base: `queryRecords` counts from the other side of a link again, and its \"is\n empty\" agrees with its groups.** A count or rollup over records that point at a\n customer read 0 when the tables given to `queryRecords` held no such customer. A link\n grouped by id now groups by the id it stores. A view filter \"is empty\" on a link now takes\n a key to a record the linked table does not hold, as the Empty group and the cell do.\n- **SvGrid Base: a paged table whose database stops answering no longer leaves an unhandled\n rejection behind.** The count read beside a grouped view's groups, the record read for a\n feed that sent only the changed fields, and the count read of a dashboard or calendar each\n failed with nothing waiting for them. A feed's record that cannot be read now makes the\n view read it again later, and an Undo of a cell the grid no longer holds says the database\n could not be reached instead of doing nothing in silence.\n- **SvGrid Base: a block write of 20 records or more on a table the page holds offers Try again,\n and shows what the server stored.** A paste, a clear or an Undo of that many records that\n failed said so with no Try again, and two failed blocks of 1,500 records read as \"2 changes\". Now the notice\n counts records and Try again reads them first, sends what is still as it was, and says how\n many cells and records it left. Each block's records are read back once it lands, so a\n trigger's or a hook's value shows at once, and Undo finds it.\n- **SvGrid Base: a new record not stored yet inside a range is no longer passed over in\n silence.** A range job left it out with no word, a paste over it shifted every line up a\n row, a fill from it emptied the cells it reached, and a copy dropped its line. Now the job\n says how many it left, a paste keeps its line for it, a fill takes its value, and a copy\n has its line.\n- **SvGrid Base: a range job on Supabase or PostgREST counts and stops within 200 records,\n and stops when a record fails.** Differing values go one request each there, and a block of\n 1,000 held the count and Stop for 1,000 requests. A failed request now stops the other\n fifteen at once, so the count of what landed is what the database holds, and a record a\n row level policy skipped is a failure, not a write that passed.\n- **SvGrid Base: Delete or Backspace in an open single select empties it.** A click on a\n selected select cell opens it, and the key then did nothing.\n- **SvGrid Base: Undo of a range or Edit fields on a server with a hook takes back what the\n hook stored.** It took the stored value for a teammate's and left it.\n- **SvGrid Base: an undo no longer writes over a teammate's change made a moment after yours.**\n On SQL Server and MySQL a write is read back with a second statement, and a teammate's write\n landing between the two was taken for the answer to yours: Undo then thought the cell still\n yours and put your old value over theirs. SQL Server now writes and reads in one transaction\n of one batch. MySQL does with the source's `transaction`; without one the gap stays, and the\n docs say so.\n\n- **SvGrid Base: day filters and a chart's months follow the viewer.** On `timestamptz` and\n `datetimeoffset` columns \"is 8 March\", \"today\" and a chart's months were the database's days.\n The page now sends each date condition with the moments its days start and end where the\n person is, and a chart reads each part of the span with one UTC offset in that offset. A date\n and a wall clock read as before.\n\n- **SvGrid Base: a table keyed by both ends is a link to many.** A pair table with both key columns foreign keys is a link on SQL and Supabase, under a scope too, and a removed link deletes that one pair. Before, on Supabase it was a tab whose delete took every pair sharing the first column, and on SQL it stopped the whole base. Any other composite key, or no key, leaves that table out with a log line and the rest opens. `keys` names a unique column for such a table or a view. A table or view with no declared key, even with a column called `id`, is now left out until you do.\n- **SvGrid Base: the page shows what the server stored.** After a typed edit, paste, Add row, record edit or undo the cell holds the row the server answered: a hook's value, a stamped tenant, a default. Undo goes back from that value. The tenant column shows and takes no edit, and hiding it no longer makes the table a `403`.\n- **SvGrid Base: a self-linked record and its parent come back together.** The link check of a block counts the keys in that block, and a block writes parents first.\n- **SvGrid Base: lists in `json` and `jsonb` columns.** A multi select, a vote or a sparkline saves on `pg`, `postgres.js`, MySQL, SQL Server and SQLite, cast by what the column is.\n- **SvGrid Base: SQL Server sorts, filters and groups on formulas and lookups in SQL.** What it cannot say is refused at once, where the table used to be read into the page.\n- **SvGrid Base: `maxPageSize` below 1,000 works.** The page follows the server's limit, on reads and on blocks.\n- **SvGrid Base: Edit fields on Supabase is a request per 200 records** for records given one value, and a row level policy that skips a record stops the block and says so.\n- **SvGrid Base: small server fixes.** A bad page or a private field name in a request is a `400`. A MySQL key past 2^53 links. A cross-site browser request is not believed for its `X-Forwarded-Host`. `isSecretColumn` knows `pass`, `userpassword`, `adminpass`, `apikeys`, `secretkey`, `pwhash`, `database_url`, `dsn` and `webhook_url`. The evaluation card builds no HTML string, so Trusted Types pass. A scaffold's theme script is a file, so a strict CSP passes. A PDF preview gives the focus back with the pointer over the file.\n- **Compliance docs.** No GPG fingerprint is claimed, one security address, canvas use and the print popup stated as they are.\n- **SvGrid Base: a table that cannot be read says so and stays said.** Where the records would be: \"Could not load Deals\", why, and Try again. No empty table, Add row or \"Not saved\" on the way.\n- **SvGrid Base: Excel files hold real cells.** Numbers, percents, dates and times are numbers with the field's format, whatever a database driver gave as text: on Postgres, MySQL and SQL Server, held or paged, with lookups and rollups. A yes or no field reads the same word on every driver. A link, a select or a person with a number for a key reads by name, in CSV too.\n- **SvGrid Base: a click to select a cell changes nothing.** The first click on a link, email or phone selects the cell, and the next one follows it. Ctrl or Cmd click follows at once and a double-click edits. A click on a checkbox's box, a star, a vote or a button acts at once; a click on the rest of the cell only selects it. A finger's tap follows the same rules.\n- **SvGrid Base: a calendar's day sizes are the viewer's days.** On a column of moments (`timestamptz`, `datetimeoffset`) the sizes and each day's list follow the page's zone, across a change of the clocks. A date or a wall clock reads the same everywhere and is told as it reads.\n- **SvGrid Base: a big change's automations show and stop.** The Edit fields question says how long the runs will likely take and what a closed tab means. The bar shows how far they are, with Stop, and the tab warns before it closes. Waiting runs no longer hold their records, runs on records in the page leave the tab its turns, and a run that cannot read its record no longer stops the ones after it.\n- **SvGrid Base: memory comes back after a bulk edit.** The page keeps the changes of the latest 20,000 records of a table, and no key per record written.\n- **SvGrid Base: a grouped view on a table read by parts reads like one in the page.** Groups in option order, drawn as the field draws them, with the records they hold at every level (a driver's COUNT as text included), and totals for the fields with a sum, an average, a lowest or a highest in the footer.\n- **SvGrid Base: Undo says what a drag did.** A bar and the bars it pushed are one step, and a card or a bar reads \"Undo move record\". \"Generate for all\" on an AI field asks first when records hold values, and one Undo takes the whole run back.\n- **SvGrid Base: a link kept in a `text[]`, `jsonb` or MySQL `json` column.** An `in` filter on one asks whether any value matches, so opening a Gantt on a self link no longer raises `malformed array literal`.\n- **SvGrid Base: nothing shows under Apply in Edit fields.** The row now covers the drawer's padding.\n- **SvGrid Base: a multi-column paste, clear or fill on a paged table writes every column.** It\n wrote the first column of each row and put the old value back in the others, with no message.\n- **SvGrid Base: a range on a paged table is the whole range.** Paste, one value over a range,\n Delete, fill and Ctrl+Enter reach every record the selection covers, loaded or not, through the\n Edit fields dialog: read and written in blocks, with progress, Stop, a count at the end and one\n Undo step. They used to reach only the rows the page held, and \"All changes saved\" said nothing\n of the rest. Up to 200 cells of loaded rows stay instant, with no dialog.\n- **SvGrid Base: a copy of rows not loaded reads them first.** It wrote blank lines and a $0.00\n for each. Up to 2,000,000 cells it reads with progress; past that it copies nothing, says the\n number, and points to Download.\n- **SvGrid Base: Undo and Redo of a range do not freeze the tab.** A big range is one step that\n reads and writes in blocks, and on rows held in the page a step's cells go back in one pass.\n- **SvGrid Base: a paste past the last row.** A line where no value fits makes no record. Past 10\n new records it asks first, with the number. They go in one block, and Undo takes them out in one.\n- **SvGrid Base: a paste while a view reloads makes no record.** It says the view is loading. A\n write that reads the view again leaves the rows on screen until the new ones arrive.\n- **SvGrid Base: a paste and a clear stamp last modified fields and the record's activity**, as a\n typed edit and a fill do.\n- **SvGrid Base: Undo takes back the Try again of what it undid.** A press on that button wrote\n the undone value, with no step to undo. Esc during a drag of the fill handle or a range now\n cancels it.\n- **SvGrid Base: Delete forever no longer cuts links on a record that comes back.** A teammate's\n Restore during the purge, a server failure at any step or a closed page could leave a restored\n record with its foreign keys empty, and a failed purge could overwrite a teammate's new link. The\n record is now claimed first, so no restore meets a half done purge, the keys are written only\n where they still hold what was expected, and the purge reports the ids it deleted.\n\n- **SvGrid Base: a restore is not a creation.** Restore and Undo of a delete ran \"record created\"\n server automations, which rewrote the record. The first change after the automation server starts\n is seen too.\n\n- **SvGrid Base: a record a teammate trashed no longer fails a block with \"no permission\".** Under a\n `scope`, a block skips it and finishes, as it does with no scope, and one record says it is gone.\n The audit log and `afterDelete` no longer name a record the delete did not change.\n\n- **SvGrid Base: a link to a trashed record is empty everywhere.** \"Is empty\", \"is not empty\", one\n Empty group with no raw key, sort, count and the picker, on held and paged tables. An undo to a\n record deleted forever says so, with no key and no Try again, and a link written to a trashed\n record says why it shows empty.\n\n- **SvGrid Base: your own edit with a lost answer is yours.** A read finds it landed: no failure, no\n Try again and no \"changed by someone else\". Undo of a hard delete no longer asks for a restore the\n table cannot do, and a write that was refused or found its record gone leaves no undo step.\n\n- **Board: a keyboard move writes once, on the drop.** The arrows only show where a card is going, and\n `onCardMove` and `onCardReorder` fire when it is dropped, from where it was picked up. Escape used to put the\n card back on screen while the record kept the new lane. Tab or a click elsewhere puts it back too, focus stays on\n the card, and on a `server` board the drop marker shows the way until the drop.\n- **Scheduler: Escape works past the edge of a view.** A carried event used to leave the view and take Escape with\n it. The view now follows the event, and Escape brings both back.\n- **Scheduler: an all-day bar in Week or Day takes the keyboard.** Space opened it instead of picking it up, and it had\n no name with its date. It now moves as any event does; up and down move it a week.\n- **SvGrid Base: a list read from a server takes Tab.** Flat or grouped it is one stop, on the record you were last\n on, and the arrows walk records, not the row buttons. Grouped lists read from a server also take Home, End, Right\n and Left. Right and Left swap in a right-to-left page.\n- **SvGrid Base: Enter on a list row's button opens its menu**, not the record, and a selected row shows it and\n says \"Selected\".\n- **SvGrid Base: focus no longer falls to the page.** The selection bar goes back to Delete after its question, and to\n where you were after Clear, Escape or a confirmed Delete. A sent form puts focus on its thank-you and says it. A\n dashboard tile moved by its buttons keeps focus on the button pressed, which at either end is off, so a second\n Enter does nothing.\n- **SvGrid Base: a comment's question and Next.** Escape on \"Delete this comment?\" leaves the question, not the\n record, and focus starts on Cancel. Next and Previous wait for a comment being changed, and say so, instead of\n dropping the text. A click outside a record with text not sent says why it stays open.\n- **SvGrid Base: small accessibility fixes.** A link chip in a list row is no longer a button inside a button, Add\n table keeps its 26 px on a phone, a mail link in a record is 24 px tall, and the Menu key cannot open the browser's\n menu over a card's. A record with no name reads \"Untitled\" everywhere.\n- **Edit fields on a big table no longer freezes the page.** It runs in the dialog a delete uses, with progress and\n Stop. Past 10,000 records it asks first, with the exact number. A failure part way stops there, reads the block back,\n says how many records changed, and keeps Undo for those; it used to carry on, say none were saved and leave no Undo.\n- **Bulk writes through `createBaseEndpoint` go in blocks.** `createMany`, `updateMany` and `deleteMany` carry up to\n 1,000 records a request, and records given the same values are one statement. `authorize`, `scope`, `validate`,\n `checkWrite`, hooks and `audit` hold for each record as on a one-record write.\n- **An edit, a paste, an undo or a redo deep in a big table is as quick as one at the top.** Each walked every row\n before it, several times over.\n- **A calendar on a date-with-time field groups by day in the database** (`groupDays`, on every dialect), and a month\n moved past stops sending its days. `groupMonths` works on SQL Server and SQLite too.\n- **`createSqlDataSource`: `updateRows` keeps the time** of a schema `date` over a timestamp on Postgres, where a cast\n dropped it, and writes records given the same values without a CASE. A block's statements carry the tenant.\n- **The link picker's Enter waits for the server's answer.** On a table a server searches it took a row of the last\n search, or made a record whose name was there.\n- **A table read a part at a time asks for 200 records a block by default,** not 100: a sorted read costs a sort of the\n table whatever it returns.\n\n- **`createBaseEndpoint`: a junction table under a tenant `scope`.** A junction holding the tenant\n stays a link to many with `tenantColumn`, and one holding none takes `{ through: 'order_id' }`, so\n a pair belongs to the tenant of that record on every path. A `null` for a junction between scoped\n tables used to share every tenant's pairs: it is now a `403`, and the log says what to do.\n\n- **`createBaseEndpoint`: a link stays inside the tenant.** A foreign key written through the route\n must name a record inside its table's `scope`, in blocks too. Another tenant's record and no\n record get the same `409` with `code: 'link-refused'`. Before, a tenant could point at another's\n record, block its delete, and learn which keys exist.\n\n- **Base: a table keyed by a secret does not start.** A key named like a credential reached every\n reader, because a key cannot be hidden. Such a table is now left out, the log says why, and\n `exposeSecretKeys` serves it by name. A foreign key holding that value stays out too.\n `isSecretColumn` also knows `passcode`, `user_pass`, `session_key`, `activation_key`,\n `remember_digest`, `hashed_pw` and `mfa_seed`.\n\n- **`baseFromSupabase` asks only for what it shows.** It read `*`, so a column `hide` held back still\n reached the page, and a table with a column `anon` may not read failed. `createSupabaseDataSource` takes\n `schemaColumns`, and a base sets it. A record brought back by undo gets a hidden column's default.\n\n- **Escape closes a PDF preview.** Chrome's viewer took the focus as it loaded, and keys pressed there\n never reached the page. The focus now comes back to the dialog, unless a person went into the file.\n\n- **`createKitHandlers` takes JSON from its own site only.** A `POST` that is not\n `application/json` is a `415`, and one from another site a `403`, on `vite dev` as well as in a\n build. A page on another host goes in `origins`. A caller of `handle` that sent no content type\n must now send one.\n\n- **Server logs hold no value a driver quoted.** The handlers log codes and names, and take the value\n out of the text: a SQL Server or MySQL duplicate key, a Postgres `detail`, mysql2's `sql`.\n\n- **A color from data cannot reach a style.** An option's color, a record's value used as a color and\n a label's color now go through `safeColor` on the Board, the scheduler, the Gantt, `SvBoard`,\n `SvRecordDetail`, `SvSchedule` and the automations dialog, and a spreadsheet file's formats through\n `entryToStyle`.\n\n- **`GET` keeps an automation's outbound details from those who do not need them.** A webhook or\n an email is described only to a person `authorize` lets change the table, and an automation that\n runs on the server sends no URL, header or address to any page. `sharedTables` drops them too,\n with what a view said of a hidden field.\n\n- **Print and the HTML export run no script.** A cell's link is `http`, `https`, `mailto`, `tel` or\n `blob` only, a rule's color cannot leave its attribute, and the document carries `script-src 'none'`.\n\n- **`baseToSql` keeps a title inside its comment.** A table named with a line break could start a\n statement of its own in the downloaded file.\n\n- **Compliance pages.** `gdpr.md`, `hipaa.md`, `soc2.md` and the compliance overview now say what\n holds for `@svgrid/grid` and what SvGrid Base adds. The doc site's host was wrong in `gdpr.md`.\n\n- **SvGrid Base: the fill handle fills by the field, not by the look of the stored value.** One\n source cell copies in every field, so a person, an option, a color or a time no longer counts up\n to the next one. Two or more source cells continue a series in number and date fields and repeat\n in every other. A value the field cannot hold is not written, and the page says so. Ctrl+D copies\n down, and is one undo step.\n- **SvGrid Base: a copy writes what the cell shows, and a paste brings the same value back.** Percent,\n duration, currency, date and time cells copy as shown, so Excel gets `50%` and `1:30`, and a paste no\n longer turns 50% into 1%. Inside a page the stored value comes back in full: 12.5% shown as 13%,\n bold in rich text, the right one of two people with one name.\n- **SvGrid Base: one multi-line cell in is one cell out.** Copy quotes a cell holding a line break or\n a tab, and a paste reads quoted text, Excel's included, so the record below is left alone.\n- **SvGrid Base: import keeps what a file says.** A date keeps its calendar day in every time zone, a\n percent reads as the grid reads it, a person matches by name or email, and a name that matches\n nobody is no longer stored as a person. Link fields can be mapped by the linked record's name. The\n dialog says how many cells it could not match. A type change from text to a date or a person reads\n the same way, and a rating stays within the field's maximum.\n- **SvGrid Base: a downloaded view reads back to the same values.** A percent is written `12.5%` and a\n duration `1:30:15`, where the stored 0.125 and 5400 would read as something else in an import, and a\n name with a comma in a list is quoted. In Excel a percent stays a number with a percent format, and\n an import reads an Excel cell as it shows: a percent as a percent, a date cell as that date. A select\n option is known by its label as well as its value, so an import adds no copy of it.\n- **SvGrid Base shows its own notices.** A host with no `<SvToaster />` now sees every failure, refusal\n and Restore. A host that has one keeps it, and nothing shows twice.\n- **SvGrid Base: Add record in a grouped view goes to the new record's first cell.** A new record in a\n group of its own opened no editor, so typing pressed the button again and made blank records.\n- **SvGrid Base: undoing a delete after a restore on another tab keeps both sides of a link.** Roll-ups\n on the other table were left short.\n- **SvGrid Base: smaller things.** Space on a Vote cell votes. A click beside the number in a record's\n number editor keeps the edit. Enter in the new view's name closes the view menu. The undo button and\n the screen-reader message name a fill, a paste or a bulk edit by its cells, and a redo is said as a redo.\n\n- **SvGrid Base: focus no longer falls to the page.** A dialog or menu whose opener went, or\n cannot take focus (a menu item, a row button hidden under the dialog, a field just deleted),\n hands focus to what held it, which is the grid, or to the next card. Pin, Hide field, Delete\n field, Expand record, Comment, a deleted card or calendar event, and Undo or Redo on the last\n step all leave the keyboard in place.\n- **SvGrid Base: Remove on a dashboard tile takes the keyboard to its question,** which is read\n out. A second Enter cancels; it no longer lands on the next tile's buttons.\n- **SvGrid Base: Escape in a comment keeps the text.** It leaves the box, and acts as Cancel on\n a comment being changed. Text not sent holds the record open against Escape, which then says\n why, and against a click outside.\n- **SvGrid Base: cards and list rows keep the record's actions.** At a phone's width, in a\n gallery and in a list, the Menu key, Shift+F10, a long press and a button on the card open\n expand, comment, select, insert, duplicate and delete. Selection shows on the card and in the\n selection bar. `gallery.cardMenu`, `gallery.isSelected` and `gallery.text` are new.\n- **Board:** \"Add card to Lead\" and \"+ Add a card\" show the focus ring. An empty lane no longer\n says it is a list. **Link preview, tooltips:** Escape closes a link preview, a grid tooltip, and\n a calendar or Gantt tooltip with the pointer still on it, and a pointer crossing the gap to a\n link preview keeps it open.\n- **SvGrid Base:** a rating cell's name and a gallery's name are translated. Run now with no\n record writes \"(no record)\" for a field token, not the raw `{Deal}`. A view bar button reached\n at a phone's width comes fully into sight. A percent bar keeps its fill under forced colors.\n\n- **SvGrid Base: a tenant's trash on MySQL and SQLite.** With `scope` and `softDelete` the tenant\n was bound before the ids, and `?` is matched by position, so Undo, Restore and Delete forever\n found nothing: a restore said the record was deleted forever, and a Delete forever reported\n success and left the row.\n- **SvGrid Base: a soft delete leaves foreign keys alone.** It used to clear them in other tables,\n and a restore after a reload or by a teammate never brought them back. The clearing now happens\n at Delete forever, in the tables of the base. A hard delete is as it was.\n- **SvGrid Base: a database's numbers show as stored.** Introspection reads a column's scale:\n `numeric(12,2)` holding 19.99 shows `$19.99`, not `$20`, and an integer shows no decimals. A column\n with no declared scale takes the places its values show. On SQL Server `money` has four. MySQL's\n `tinyint(1)` is a checkbox, a `time` column a time of day and never a select, and a Postgres\n `text[]` a multiple select that can be edited.\n- **SvGrid Base: an insert whose answer was lost.** A read says whether it landed: the record is\n taken, what was typed goes to it, and nothing false is said. A key the database makes is found by\n the record's values, in a table the page holds. A 5xx with no code now says the server did not\n answer, not that the database refused, and a delete or an edit that landed is not told as a failure\n or as a teammate's change.\n- **SvGrid Base: a refused undo shows the value it found.** Without a feed the cell kept the value the\n database no longer held.\n- **SvGrid Base: JSON keeps every digit.** A `json` or `jsonb` column is read and written as text, so\n a number past 2^53 is not rounded by a read, an undo or an edit.\n- **SvGrid Base: a notice goes with its base.** The toast queue belongs to the page, so a \"Deleted ... Restore\" or a Try again\n outlived the base that made it, and the next base on the page drew a button that did nothing. Restore now goes with its base, and a\n failure keeps its words, what was typed included, with no button.\n- **SvGrid Base: smaller things from teams.** Someone who may not delete hears no error from the trash,\n and the panel says why it is empty. A permission refusal offers no Try again and leaves no undo step. A\n paged view with a filter drops a record a teammate moved out of it. A teammate's restore lands at the\n record's place. A Delete forever takes the \"Deleted ... Restore\" notice with it, and a number deleted\n in this page is not given to the next record while it stays open.\n\n- **BREAKING: `scope` refuses an empty tenant.** A value of `''` used to drop the predicate,\n so a person with no organisation read, rewrote and deleted every tenant's rows. Now a\n resolver that returns nothing, or a rule whose value is empty, blank or not a single value,\n is a `403` on every read and write, and `createBaseEndpoint` leaves the table out of `GET`.\n Only `null` means no scope. `scope: (table) => ...` must return `null` for a table every\n tenant shares: returning nothing now closes it.\n- **SQL Server runs.** `dialect: 'mssql'` wrote `LIMIT` and `RETURNING`, so nothing could. It\n now pages with `OFFSET ... FETCH`, reads a key back with `OUTPUT INSERTED ... INTO` (a table\n with triggers works), writes an identity key under `IDENTITY_INSERT`, stays under 2,100\n parameters and 1,000 rows, and keeps `datetime`, `datetimeoffset`, `bigint` and `decimal`\n exact. Run against SQL Server 2022. Formulas are worked out in the page there. Studio's\n connection string for it was a URL the `mssql` driver cannot read.\n- **BREAKING: a PDF preview frames only bytes it read.** A file on another origin went into the\n frame as it was, and could draw a sign-in form under the base's own title and move the tab.\n A file the page cannot read, because its host sends no CORS headers, now offers a download.\n- **An id from a client reaches the source as text.** A number was bound as a number, and on\n MySQL with a loose `sql_mode` `id = 0` matched every id not starting with a digit. An empty\n id is a `400`.\n- **`patch: { id }` no longer changes a record's key.**\n- **A webhook connects to the address it checked.** A name could answer one way for the check\n and another for the connection. On Node the call now goes to the checked addresses, and a\n name that does not resolve is not sent. More ranges are refused: `192.0.0.0/24`,\n `198.18.0.0/15`, the documentation blocks, `fec0::/10`, and IPv6 forms wrapping an internal\n address (`::a.b.c.d`, NAT64, 6to4, Teredo).\n- **`isSecretColumn` knows more names.** Any `token` (`remember_token`, `token_hash`),\n `pass_hash`, `password1`, `pin`, `recovery_codes`, `credit_card`, `iban` and others. It reads\n the name only, and the docs now say that is a default, not a guarantee.\n- **`createBaseEndpoint` takes `validate`, `hooks` and `maxPageSize`.** Writes through it could\n not be checked on the server. `validate: true` asks nothing of a `NOT NULL` column with a\n default, and a schema read from a database no longer marks such a column required.\n- **A refused write says why, through an endpoint too.** A constraint was a `500` and \"The\n database refused it\". It is now a `409` with a `code`, and the person reads which rule it\n was, without the driver's words. An autonumber clash through an endpoint now takes the\n next number, as it does on a direct source.\n- **Thrown text stays on the server.** A message thrown by `authorize` or `scope` reached the\n client, connection strings included. It now reads `forbidden`, unless the `Error` has\n `expose: true`.\n- **A read has a ceiling.** `createKitHandlers` returns at most `maxPageSize` rows (20,000 by\n default) with the true count, so `pageSize: 1000000000` no longer reads a table in one go.\n- **An alert rule's style is a color.** `red;background-image:url(...)` fired a request to\n another host each time a cell painted.\n- **A group key that is an object is refused.** A driver could write one as SQL of its own.\n- **A filter on a number past 15 digits compares exactly.** Rounded, a tenant id could be\n someone else's.\n- **A scaffold's production build says what is closed.** It read \"The database did not answer:\n 403. Is DATABASE_URL set\", which sent you to the wrong fix.\n- **Two dev console warnings are gone**: `state_proxy_equality_mismatch`, once for each field\n of each table, and `ownership_invalid_binding` on `views`.\n- **\"Not in view (1 record)\".** It read \"1 records\".\n- **Forms take the mouse again.** Typed boxes ignored a click or a tap, and so did an\n open editor in a record. A star clicked in a form is now the answer; it used to open\n the editor.\n- **A record's Account picker no longer links what nobody chose.** Enter on the list as it\n opened ticked its first record, and Done saved it. Enter now closes it unchanged, and\n a picker left as it opened writes nothing.\n- **Focus no longer falls to the page.** Comments, a form's pickers, the form builder,\n dashboards, filter conditions, automations, attachments, import, the inbox and the\n field editor keep the keyboard on the logical next control, and comment changes,\n tile moves and form builder moves are said aloud.\n- **Base has the fill handle its docs promise.**\n- **The form builder's field list holds still.** A field turned off keeps its row, and back\n on it takes the place the row shows.\n- **Timeline.** Delete on a bar asks first, as does Delete in a calendar's menu. A bar moves by\n Space and the arrows with one write, stands clear of the task table when focused, opens\n its menu with Shift+F10 with focus in it, reads as a table, keeps its shape in forced\n colors, and every word goes through the base's messages. A drop on a weekend stays\n there.\n- **Attachments: Enter on Remove removes the file.** It opened the preview.\n- **Dashboards ask before a tile is removed.**\n- **Form number boxes read as the field does** (\"25%\", \"$1,250.50\") and edit in its units.\n- **Escape in a number or a rating in a record leaves the box.** It closed the record.\n- **Typing on a focused record field starts the edit**, and Enter in the field type search\n takes the first type.\n- **A double-click on a week's all-day row adds an all-day record.**\n- **Automations:** step buttons name their step, moves are said, and the open automation\n carries `aria-current`. **Delete record** ties its text to the dialog.\n- **SvGrid Base: Edit fields writes to the ticked records and nobody else.** In a sorted,\n filtered or grouped view each value that landed moved its row, and the next one went to\n whatever had taken its place, so records nobody ticked changed and Undo wrote more wrong\n values. Every cell is now worked out first and written by record, in one write and one\n undo step, on tables in the page, on SQL tables and on tables read a part at a time,\n where Edit fields did nothing at all before. Text a field cannot read, such as `abc` in a\n number, stops the form with a message and writes nothing.\n- **SvGrid Base: Delete, paste and fill stay on their records.** A row held under a typed\n edit but moved at once under Delete or a paste, so a second press hit another record.\n The row now holds until the cursor moves on, whatever wrote it.\n- **SvGrid Base: a paste past the last row adds records,** as one undo step with the cells\n it wrote. It used to drop those lines without a word.\n- **SvGrid Base: one rule for pasted values a field cannot read.** A number, a select, a\n date, a person, a link, a rating or a checkbox given text it cannot read keeps its value,\n and one notice says so. An unknown link name no longer wipes the link, and an unknown\n name no longer lands in a person field as a person nobody has.\n- **SvGrid Base: a write with no answer is not given up on.** A write past `writeTimeout`\n stays out: later writes to its record wait behind it, writes to other records go on, and\n the status says so. It can no longer land late over a newer value, a late insert leaves\n no second record behind a Try again, and a late delete keeps its copy in the trash until\n the outcome is known. A rollback now leaves a value written after the failed one.\n- **SvGrid Base: the undo guard fails closed.** A cell undo reads the record first, with a\n feed or without one, and is refused with a message when that read fails, so a feed down\n without a word can no longer take a teammate's value out. The step stays the next to try.\n- **SvGrid Base: Try again checks first.** It reads the record, leaves a value that changed\n since, whoever changed it, and says so, also when the record was deleted.\n- **SvGrid Base: a failed read before a delete stops the delete.** That block stays, and\n the person is told, instead of going ahead on a stale copy.\n- **SvGrid Base: editors in a record are held for.** A teammate's change waits while a field\n of the record view is being edited, as it does for a cell.\n- **SvGrid Base: fewer false \"changed by someone else\".** A number the database rounded, a\n person's own undo on a table read a part at a time, and a feed's word on an earlier write\n of the same record are no longer reported as a teammate's. A read that started before a\n write no longer puts the old value back. Undo refused \"alone\" after 1.234 in a column of\n two decimals goes through.\n- **SvGrid Base: undo and redo run no automation.** A redo of a status change added its\n checklist items again on every press.\n- **SvGrid Base: a second restorer is told nothing is wrong.** Two people restoring the same\n record at once: the second sees it back, not \"Another record already has this value\".\n- **SvGrid Base: wrong words on the history.** A column resize read \"Undo cell edit\", and a\n redo was logged as \"undid\".\n- **SvGrid Base: soft delete keeps a record's junction links.** A delete of a record marked\n with `softDelete` dropped its junction rows and a restore did not put them back, so tags\n were gone after a reload. Junction rows now stay, at either end of the link, and a restore\n writes nothing. A marked record shows in no link. Delete forever removes them with the row.\n- **SvGrid Base: Delete forever is final, and only once the database says so.** A purge the\n database refused left the record marked with no way to reach it, under a notice saying it\n was in the table. The item now stays in the trash until the purge is confirmed, the notice\n says so, and in one Empty trash the free records still go. Ctrl+Z could put a purged record\n back from the page's copy: the undo step now ends, and a stale undo in another window\n refuses. A single Delete forever now asks first, as Empty trash does.\n- **SvGrid Base: the trash of a soft delete table reads the table.** Marked rows show after a\n reload with no trash store, for whoever may delete. **Behaviour change:** those rows appear\n in the trash, those marked by other tools too. They do not age out: `trashDays` still only\n purges what the page's trash holds.\n- **SvGrid Base: `softDelete` on `createBaseEndpoint`, `baseFromDatabase` and\n `baseFromSupabase`.** The endpoint could not use soft delete at all. The column stays out\n of the fields, and the description tells the page.\n- **SvGrid Base: the mark cannot be written.** With the column on the schema a client could\n create a record already deleted, or mark one through an update. `createSqlDataSource`,\n `createSupabaseDataSource` and `createKitHandlers` now leave it out of every write.\n- **SvGrid Base: teammates hear of soft deletes.** A restored record reached a table read a\n part at a time only on a reload-style feed, and a delete through `createKitDataSource` stayed\n on teammates' screens. `createKitHandlers` now says which column marks records and the page\n learns it. `apply({ type: 'update', id })` reads that one record, which is how a feed reports\n a junction change; `baseFromSupabase` listens to junction tables by itself.\n- **SvGrid Base: a new record does not take a marked record's number.** On a table the page\n holds it did, and the restored record was renumbered. Autonumber now reads past marked rows\n on Kit and Supabase too.\n- **SvGrid Base: a very large soft delete purges a block at a time.** Closing the page used to\n leave everything not yet purged marked.\n- **`createKitHandlers`: restore and purge tell the server what happened.** **Behaviour\n change:** the `audit` hook now gets `restore` and `purge` actions, one entry per record that\n really changed, in place of `update` and `delete` with ids joined by commas, and a purge of\n another tenant's id logs nothing. `beforeDelete` and `afterDelete` run on a purge with\n `purge: true`, and `beforeRestore` and `afterRestore` are new. On a table with no `softDelete`\n `restore` and `purge` answer 405.\n- **SvGrid Base: formulas and lookups through `createBaseEndpoint` run in the database.**\n A sort on a formula read the whole table into the page, because the server's source\n was never told the base's fields. It now works from the fields the server holds (the\n `svgrid:` comments, or the new `computed` option for MySQL and SQLite) and says which it\n works out in `serverComputes`. A request names a field and brings no definition. A link\n is followed only for a person who may read the other table, and not into a table\n `scope` covers. A field changed in the page goes back to being worked out in the page.\n- **SvGrid Base: a sort, group or negative filter on a lookup reads the other table once.**\n Sorts and groups use a `LEFT JOIN`, and \"does not contain\", \"is not\", \"is empty\", \"is\n none of\" and \"not equal\" a `NOT EXISTS`, in place of a subquery per record. A record with no\n link, or a link to a record marked deleted, matches as it did.\n- **SvGrid Base: a view counts once per query.** A block read asks for rows alone once the\n view has its count. The count is read again after a write through the page, a change\n from a feed, a block that does not fit it, or 30 seconds. With no feed, a teammate's new\n record reaches the count in that time, at the next read.\n- **SvGrid Base: blocks read their keys first.** A read with text copies or a join finds the\n block's keys, then reads those rows, so a sort or an `OFFSET` no longer carries whole rows.\n- **SvGrid Base: a date condition compares the column to a range** on Postgres and MySQL,\n so an index on it serves a calendar and a filter. `DATE(col)` and `col::date` could not\n use one. SQLite keeps `DATE()`, which reads the offsets in its text.\n- **SvGrid Base: a read nobody waits for stops.** `execute` gets `{ signal }` on reads, no\n further statement of a stopped read is sent, and `createKitHandlers` passes\n `request.signal` on.\n- **SvGrid Base: a chart on dates is one grouped statement**, and group charts, board lanes\n and calendar days no longer run a count they do not use. A dashboard reads its tiles\n once as it opens, and tiles on one query share its count.\n- **SvGrid Base: a view switch shows no old count or rows** under the new view's name.\n- **SvGrid Base: a bulk delete reads by key** in place of a growing `OFFSET`, with a count at\n each end of the read.\n- **SvGrid Base on MySQL: a descending sort reads an index backwards.** Its tie-break on the\n key follows the sort's direction there, so records with the same date now come newest\n key first. `date DESC, id ASC` sorted every row.\n- **`baseFromDatabase` and `createBaseEndpoint` open a MySQL database.** The column read used\n `generated`, a reserved word, as a bare alias, and MySQL refused the statement.\n- **`createBaseEndpoint`: the first description no longer groups a unique column.** A column\n that shows more than 12 different values in a sample of 5,000 rows cannot be a select.\n\n- **Server row model: a drag of the scrollbar reads where it stops.** A jump of more\n than a block waits for the viewport to stand still (`leapPauseMs`, default 60), a\n read the viewport has left stops through `request.signal`, and the rows on screen\n go first in the queue. Placeholder rows keep their row number and line up with the\n columns.\n- **SvGrid Base: Gallery, List, Inbox, Board lanes and the Timeline read ahead of a\n scroll,** further the faster it goes and the slower the source, and a drag of the\n scrollbar reads where it stops.\n- **SvGrid Base: a typed column or view filter waits for a pause,** as the search box\n does; a pick from a list applies at once.\n- **SvGrid Base: a busy calendar asks for its days' sizes in one grouped request.** It\n skips empty days, and after a write reads only the days whose size moved. A record\n with an end date, or a backend that does not group, stays a read per day.\n- **SvGrid Base: reading a table through in the page keeps 4 requests open** past the\n first blocks, instead of waiting for one at a time.\n- **SvGrid Base: a Calendar and a Timeline no longer stay in memory after a view\n switch** on a Svelte older than 5.57.2 by these two routes. Svelte 5.55 to 5.57.1\n keep other parts of a destroyed grid linked as well: use 5.57.2 or later.\n- **SvGrid Base: every record action from the keyboard and on touch.** The Menu key\n and Shift+F10 open the record menu with focus in it, the row number has an actions\n button on a touch screen, a long press opens the menu, and the record view can\n delete its record. The field menu and the table menus take focus, walk with the\n arrows and give focus back. A field moves from its menu or from Hide fields.\n- **SvGrid Base: the rows are one tab stop.** Tab goes on to the header and footer\n controls; it walks cells after a click or in an open editor, and says the way out.\n- **SvGrid Base: forms have real inputs.** Typed fields are labelled inputs with\n required and invalid states and autofill; a failed submit goes to the first error\n and reads it out.\n- **SvGrid Base: what changes is said aloud.** Edits, clears, pastes, undo and redo\n reach a screen reader, and a calendar event moves only once picked up with Space.\n- **SvGrid Base: contrast.** Text on a filled accent control now follows\n `--sg-on-accent`, and accent-colored text in the chrome is plain ink. Text on a colored\n pill or bar stays white on saturated colors, by design; the VPAT gives the ratios.\n- **SvGrid Base: forced colors, right to left, translation.** Switches, the active\n tab and view and the \"+\" keep their state under forced colors. Arrow keys and the\n pin line follow `dir=\"rtl\"`. `setBaseMessages` now reaches the grid's own menus,\n find bar and labels (`grid.*`) and the calendar (`viewbar.calendar.*`).\n- **SvGrid Base: smaller fixes.** Focus stays in the grid after a delete, panels hold\n Tab, Search moves into the find bar, targets are 24 px, an IME composition keeps\n its Enter, and a calendar on a phone keeps its title on one line.\n- **SvGrid Base: a select option has an identity.** Renaming one in the field editor renames it on every\n record, in a multi select too, keeps its cards in their lane, and reaches the view filters, condition colors,\n form logic, dashboard tiles, automations and the field's default that name it. Removing one says how many\n records hold it, next to Save, and clears them. Undo takes it all back. On a table in a database it is a write\n to each record holding it, a block at a time. A card whose value is no option goes to Uncategorized, not off\n the board.\n- **SvGrid Base: views show the data.** A board, calendar, timeline and gallery follow an undo and a record edit\n at once. Calendars and timelines leave undo to the base, so a drag is one Ctrl+Z and not two that cancel out.\n- **SvGrid Base: sort, filter and group apply again after an edit**, holding a grid row only while it is the\n active row, and the count follows. An undo reaches a record the view no longer shows.\n- **SvGrid Base: the bulk bar is part of a base.** Ticking records shows it, with Delete, in every template,\n and never the developer note. `selectionBar={false}` turns it off.\n- **SvGrid Base: a formula reads names.** `{Account}` and `{Owner}` give what the cell shows, not record and\n user ids.\n- **SvGrid Base: deleting a field says what it drives**, by view and automation. A view asks in its own row, goes to\n the trash, and is one step of undo. A field deleted from a view no longer leaves it saying \"Colored by field\".\n- **SvGrid Base: columns resize and move by drag** by default, and a restored field goes back to its place.\n- **SvGrid Base: Hide fields keeps its rows still** while fields are switched.\n- **SvGrid Base: the warning for a type change sits next to Save**, in sight.\n- **SvGrid Base: comments can be edited and deleted by their author.** `update` and `remove` on a comment store.\n- **SvGrid Base: activity stays true.** An undo and a redo are noted, and a local edit shows old to new.\n- **SvGrid Base: Timeline is in Create in every base**, its renderer loading on demand, and the roadmap template's\n Timeline is one.\n- **SvGrid Base: a form builder.** \"Customize form\" sets the title, the words and the fields, their order and which\n are required. An empty form does not send.\n- **SvGrid Base: Space on a group row opens nothing**, where it opened an empty record that lost what was typed.\n- **SvGrid Base: smaller things.** The link picker takes arrows and Enter and keeps its size, and a second click no\n longer closes it. A link cell selects on the first click. One click sets a rating in a form. Next and Previous on a\n card walk the board. Find and the field type search take the focus. A\n header opens its menu on a right click. New groups start open. The row height menu marks the current height. A\n multi-day event's tooltip says its days.\n- **The schema is the whitelist, for reads and writes (breaking).** `createSqlDataSource` names\n the schema's columns in every `SELECT` and `RETURNING`, and drops every key off the schema\n from a write. A group level off the schema is refused with `leafCounts` too. A trusted\n source in the same process as the page can ask for the old behaviour with\n `wholeRecords: true`; `createKitHandlers` refuses to start on one.\n- **Nothing a client sends reaches a private key.** `createKitHandlers` strips `__svgrid*` keys,\n keys off the schema and `readonly` fields before `authorize`, `validate`, hooks and the\n source see the row, so a write can no longer cross a `scope` or swap a validated value. A\n write left with nothing is a 422. A `scope` field off the schema refuses the request.\n- **Handlers no longer send driver text (breaking).** A failure is logged on the server and the\n client gets a plain message. A record that is gone is a 404 with `code: 'row-not-found'`,\n which `createKitDataSource` keeps on its error. A request off the schema is a 400 that says so.\n- **`createBaseEndpoint` starts closed (breaking).** It refuses to start without `authorize` or\n `public: true`, and without `tables` or `allTables: true`, with a message that says what to do.\n `GET` asks `authorize` and describes only the tables it allows. A table `authorize` gives no\n guard for is closed. It takes `scope`. Columns named like a credential stay out of a base\n (`hide`, `isSecretColumn`): never the primary field, never sampled as options, and through the\n endpoint not read or written. A field with `hidden: true` is no field of a base.\n- **A record's text cannot name a secret.** A webhook fills its URL, headers and body in one pass,\n so `{secret:DATABASE_URL}` typed into a field goes out as that text.\n- **Server webhooks stay off internal addresses (breaking).** `createAutomationServer` refuses\n private, local and link-local addresses, by name and by what the name resolves to, and does not\n follow redirects. `allowInternalWebhooks: true` opts out.\n- **A PDF preview runs nothing.** A file is read first and framed as a copy typed by us, only if\n its bytes are a PDF. An HTML file calling itself a PDF offers a download.\n- **Hidden fields and tables stay out of search, Download as SQL and the row number tooltip.**\n `lockViews={false}` on `SvBase` is honoured with `tables`. `permittedRecords` is what to send\n from a server; `permittedTables` keeps hidden values in its records, and the docs no longer\n point at it for that.\n- **A CSV is read for what it is.** The separator and encoding are found and shown to change. A\n quote inside a word is text, and a quote never closed no longer swallows the file. Rows that do\n not fit the header, values a field cannot hold, records that repeat a name, a file that is not\n UTF-8 and one that is not text are all reported before the import. A decimal comma stays a\n decimal, and `1,50` is no longer read as 150. `readImportMatrix` returns `delimiter`,\n `encoding` and `warnings`. Errors from a bad .xlsx or JSON file read as sentences.\n- **Large tables.** Import, summaries, dashboards, chart axes, rollups, pivots and spreadsheet\n ranges no longer throw `Maximum call stack size exceeded` past about 120,000 values (`maxOf`,\n `minOf` in place of `Math.max(...values)`).\n- **Download a view.** The list of tables has CSV and Excel downloads of the shown view: its\n fields and records as they read on screen, formulas, links, people, checklists and attachments\n included. `recordsAsShown` gives the same in code.\n- **Smaller holes.** A protected field is not asked in a form of someone not on its list. A paste\n outside a select's options is not written. Rich text in a base keeps no `class`, and an image on\n another site becomes a link instead of a request. A color from data that is more than a color\n is dropped. JSON import no longer fills `constructor`-like columns from the prototype, and a key\n first seen late in a file is a column.\n- **SvGrid Base: opening a cell and leaving it writes nothing.** A number, bigint,\n time, timestamp, date or JSON value used to be rewritten as the editor showed it.\n- **SvGrid Base: a number is stored as typed.** 19.99 in a field that shows one\n decimal stays 19.99; only an integer field rounds. A number past 15 significant\n digits stays exact as text, in the cell, the box and the write. A rollup with a\n `precision` keeps the linked field's symbol.\n- **SvGrid Base: dates and times no longer change with the browser's zone.** Dates,\n times, bigints and decimals are read as the database writes them, so a naive\n timestamp shows one wall clock everywhere, a typed time keeps it, and an undo or\n restore writes back what was read. On PostgREST a bigint past 2^53 is read again as\n text.\n- **SvGrid Base: dates read as people type them.** `12/24/2026`, `2026-12-23`,\n `Dec 22, 2026` and `12/21` all work in the new date editor (`fieldDate`), and text\n that is no date says so.\n- **SvGrid Base: cell keys.** Enter on a selected cell opens its editor, a key typed on\n a date or link cell starts editing, and Space ticks a checkbox cell.\n- **SvGrid Base: JSON in a text field shows as JSON** instead of `[object Object]`, and\n the Delete key leaves NULL as NULL and empties a number or date column without an error.\n- **SvGrid Base: a record added or deleted survives a view switch.** On a table the page\n holds, the grid went back to its `data` on any option change, so records added (by the\n row, Duplicate, a Kanban card, a form) vanished and deleted ones came back. What the\n grid holds is now what it is handed.\n- **SvGrid Base: Undo and Redo leave a teammate's cell alone.** A cell changed since keeps\n the later value and the page says so, cell by cell in a paste. Without a live feed the\n page reads the record first.\n- **SvGrid Base: a record's way back is whole, and safe.** Undo and restore on a table the\n page holds write every column read, under the record's own key, and the record stays in\n the trash until the database has it; a failed undo can be pressed again. A restored\n record whose Autonumber was given out again takes the next one.\n- **SvGrid Base: the trash gets the record as it is at the delete.** A delete reads the\n records at that moment, also after a confirm dialog, and a record moved out of a bulk\n choice while the question stood stays.\n- **SvGrid Base: typing is safe from teammates.** Changes from others, by feed or by a read,\n wait while a cell editor is open, so what is typed is not cut short. If the record went\n meanwhile, the person is told, with their text.\n- **SvGrid Base: a delete that did not happen is not reported as done.** One a row-level\n policy skipped, or the database refused, stays in the table and out of the trash, and the\n notice comes after the delete, not before.\n- **SvGrid Base: failures a person can act on.** A failed write names the record and the\n field in plain words, shows what was entered and offers Try again; \"Not saved\" stays until\n that record is written. A write with no answer warns and then lets the rest go\n (`writeTimeout`).\n- **SvGrid Base: Ctrl+Z of a new record on `NOT NULL DEFAULT ''`.** An emptied cell goes back\n to what the database gave it, not to NULL.\n- **SvGrid Base: the trash tells the truth.** With nothing keeping it, the panel says items go\n with the page.\n- **Supabase: the find box takes `%`, `_`, commas, quotes and brackets as text**, and a table\n with text keys can add records with default options.\n- **SvGrid Base, smaller things.** The selection bar counts on a table the page holds, a draft\n shows no number until it has one, and a write coming back in the database's words (`5.00`\n for 5) is nobody else's change.\n- **SvGrid Base: a group on a date opens on its records.** On Postgres and MySQL the\n key of a date field's group went through a JS Date, so it lost what is past the\n millisecond and took the page's zone, and outside UTC the group read nothing. The key\n is now text the database writes and compares. A delete can also leave out any group\n at any level: every source reports a group's records as `leafCount` when a base asks.\n- **SvGrid Base: two people adding at once do not share an Autonumber.** They could get the\n same number. Each record is checked once stored and the later one moves on; a UNIQUE\n column refuses the second and the write tries the next number.\n- **SvGrid Base: Undo of an added record keeps a teammate's work.** One someone has\n changed since stays, with a message, and Redo does not add it twice. Redo of a delete\n puts the records in the trash as they are now, not as they were.\n- **SvGrid Base: Undo brings times back exactly.** A delete reads time columns as the\n database writes them, so microseconds and a local time the clocks skipped survive on\n every Postgres and MySQL driver. `dateStrings` is no longer needed.\n- **SvGrid Base: Undo works on a server in any language.** Generated columns are read\n from the schema and left out before a write, and a refusal is told by its error code.\n `createSupabaseDataSource` keeps the code on the errors it throws.\n- **SvGrid Base: Undo leaves other people's work alone.** Undoing a step on a table held\n in the page put back a snapshot of all its records, which took out whatever teammates\n had changed since, and wrote that to the database. A step now undoes what it did and\n nothing else, and a new record closed empty takes only itself out.\n- **`createSqlDataSource` on MySQL.** Writes ended in `RETURNING`, which MySQL does\n not have, unless you set `returning: false`. That is now the default there. A\n record with an auto-increment key now gets the key the insert made.\n- **Formula text in SQL.** A string in a formula could break out of its literal on\n MySQL through a backslash, and a pivot key from stored data the same way. Both are\n closed, on every dialect.\n- **Formulas in SQL say what a cell says, or leave it to the page.** Functions whose\n results differ between a database and a cell (`UPPER`, `FLOOR`, `TODAY` and others,\n listed in the docs) no longer run in SQL.\n- **`createSqlDataSource`:** a filter on a column the plan does not know is an error\n and not a wider answer; `in` with an empty list matches nothing; `notEquals`,\n `notContains`, `endsWith`, `isNotBlank` and `notIn` run as themselves and no longer\n as `contains`; a blank group key matches NULL and ''; `updateRow` on a record that\n is gone is an error with `code: 'row-not-found'`; `createRows` keeps a column's\n default. A filter or sort on a field added at run time works.\n- **SvGrid Base:** a write the database refused no longer reads as saved after a later\n edit; records in the trash leave it only once they are proven back, whole, with the\n columns the base shows no field for and under the key they had; times go back as they\n came on MySQL and on Postgres; junction links come back with a restored record and\n survive a refused delete; a table whose records have no id of their own no longer\n breaks the grid or the trash; writes still queued\n when the page leaves finish, and the browser asks first; a form says so when the\n database refused the record; a field named ID no longer writes over the record's\n key; a formula edited on a big table runs at once, in the database too.\n- **Scrolling a very long list.** In a gallery, list, board lane or timeline past the\n height a browser scrolls, the scrollbar and the list stopped agreeing near both\n ends. A scrollbar step there now moves the list by the same step.\n- **SvGrid Base: a table of a million records scrolls without stalls.** With\n `serverRows`, the view bar counted records by reading every row of the\n server row model, each one made on read, on every block that arrived; the\n record view looked for its record the same way. The count now comes from\n the server (`rowCount`, and the top groups' counts when grouped), and the\n record view looks near the row it was opened from first. Number, currency\n and date cells also keep their `Intl` formatters instead of building one\n per cell. In demo 723 (a dev build, one laptop), 40 wheel steps went from 9.3 s of blocked main\n thread to about 0.1 s, and opening the filtered view from 6.5 s to 0.5 s.\n\n- **SvGrid Base: switching views on a big table no longer freezes the page.**\n A grouped view on `serverRows` set a row height per row and opened its\n groups, and both read every row of the row model; now it keeps one height\n and leaves server groups closed, since each opens with a request. A board\n of more than 200 records draws only the cards in sight in each lane (the\n board measures a card when `cardHeight` is not set). The board also keeps\n each card's key instead of working it out on every read. In demo 723 (a dev\n build, one laptop), the slowest switch went from 3.2 s to 0.4 s.\n\n- **SvGrid Base: a view that left out part of its state kept the last view's.**\n A view declared with only `grouping` took over the sort, hidden fields and\n other state of the view before it. Whatever a view's `state` leaves out\n now starts plain. A saved view is unchanged: it stores all of it.\n\n- **SvGrid Gantt: the task table's header stays at the top.** It scrolled away\n with the rows in any plan taller than the chart.\n\n- **SvGrid Base: a record past what a table read was taken for a deleted one.**\n When a table on a `source` was read again at its limit, a record that had\n moved past the limit was dropped from the page and reported as deleted.\n A read at the limit now keeps the records it did not see.\n\n- **A pivot filtered its rows again for every column.** For each row group,\n `createPivotModel` went through the group's rows once per column-axis leaf.\n The rows are now bucketed by column path in one pass, in the same order,\n and the result is the same. On one laptop, a pivot of 100,000 rows over\n Year x Month went from 3.6 s to 0.6 s, and 1,000,000 rows from 147 s to\n 4 s.\n- **A grouped Excel export slowed down with the square of its rows.** The\n writer looked up each string cell's shared-string index, and checked the\n group rows already written, by scanning an array. Both are hash lookups\n now and the file is byte for byte the same. A 10,000-row export grouped by\n five columns went from 4.8 s to 0.45 s, and 100,000 rows finish in 9 s.\n- **A sheet chart hung below the window was not drawn until a scroll.** The\n sheet measured its objects once after mount, from their anchor cells, and\n the grid now adds most of its overscan rows a frame after its first paint;\n a chart hung from a row in between had no cell to measure. While an object\n has no box, rows the grid adds now measure it again.\n\n- **A wide grid lost columns in the PDF.** pdfmake sizes a column no narrower\n than its longest word, so a 22-column report ran off the right edge and only\n 15 columns printed, without a warning. The columns are now fitted to the\n page (see `pdf.fit` above).\n- **A row taller than a page was missing from the PDF.** Rows are kept whole\n on a page, and pdfmake drops a row that cannot fit on any page. Such a row\n now breaks across pages.\n- **Conditional-format icons printed as empty boxes in the PDF.** The arrow,\n triangle and traffic-light glyphs are not in Roboto; they are drawn as\n shapes now.\n- **The PDF footer could show yesterday's date.** It printed the UTC date, so\n an export after midnight east of Greenwich was dated the day before. It\n prints the local date, and the footer follows custom page margins.\n- **Grouped PDFs dropped conditional formatting and links.** They now carry\n both, as flat exports do.\n- **Booleans printed as \"true\" and \"false\" in the PDF.** They print a tick or\n nothing, like the grid's checkbox. An icon set's `iconOnly` is honoured too:\n it printed the value next to the icon.\n- **A number or date column passed in `columns` without `align` printed\n left-aligned in the PDF.** It right-aligns from its `format`, as on screen.\n- **A pivot chart drew an empty cell as a zero bar.** An average over no rows\n is `null` in the pivot and the bridge read it as 0; it is a gap on the\n chart now. A sum over no rows stays the 0 the engine wrote.\n\n- **PDF export depended on pdfmake's fonts registering themselves.**\n `pdfmake/build/vfs_fonts` registers its font map only as a side effect of\n being imported while a global `pdfMake` already exists, and the export's\n own lookup for the map never matched the shape the module has shipped since\n pdfmake 0.2.8 (the module is the map), so it registered nothing and relied\n on that side effect. Under a bundler the global can be a stale instance (a\n dev server re-optimising its dependencies mid-session is enough), and the\n export then failed with \"File 'Roboto-Medium.ttf' not found in virtual file\n system\" while its promise never settled. The map is now found in every\n shape the module has had (`resolvePdfVfs`) and handed to the instance that\n creates the document (`registerPdfFonts`, through `addVirtualFileSystem`\n and the `vfs` property), and an installed pdfmake whose fonts module has\n no map is reported instead of failing later.\n- **Studio emitted no theme for the fragment export and the CLI `add`\n scaffolds.** Only the full app's `+layout.svelte` carried the `--sg-*` tokens;\n `eject --fragment` (which drops that file) shipped an `app.css` with one\n hard-coded accent, and `svgrid-studio add` / `add --all` wrote none at all. The\n tokens now come from one helper (`themeTokenCss`): `src/app.css` carries them\n for the full app and the fragment, and the `add` scaffolds emit them in\n `<svelte:head>`. Drop-in outputs wrap them in `@layer svgrid-studio`, so a host\n app that already defines its own tokens keeps its look. `add` also honours\n `--theme` / `--dark`, and a project with no theme picked gets Ember (the demo\n theme) instead of Tailwind.\n- **Scheduler column alignment.** The all-day lane, day/time-grid header, and\n body columns now reserve the scrollbar width consistently, so the columns line\n up instead of drifting by the scrollbar's width.\n- **Excel export color-scale conditional formatting.** A color scale's `min` /\n `mid` / `max` are optional, so the export could build an `(string | undefined)[]`\n where a `string[]` was expected; it now falls back to the same `#ffffff` /\n `#000000` defaults the grid renders with. Because `@svgrid/enterprise` ships its\n `src`, this had surfaced as a stray `svelte-check` error in consuming apps - a\n clean app now type-checks with zero errors.\n\n#### Security\n\n- **SvGrid Base: a pair table with the tenant in its key could be read and changed by another tenant.**\n On `order_tags (tenant, order_id, tag_id)` with `tenantColumn` and a scope, the pair id a client sent\n overwrote the scope's tenant, so an editor of tenant B read tenant A's pairs by id and deleted them\n with `delete` and `deleteMany`, on Postgres, MySQL and SQL Server. The scope now wins: an id naming\n another tenant's pair reads nothing, and a delete of it is a `403`, as on a `{ through }` pair.\n- **SvGrid Base: a `{ through }` pair read could hand out another tenant's key.** A pair written\n straight into the database between tenant A's order and tenant B's tag reached A in raw rows. A read\n of a junction (a pair table, or one with its own key) now leaves out a row whose other end is a record\n of another tenant, where that end's table holds its own tenant column. Delete forever still clears\n such a row.\n\n- **A crafted .xlsx could crash the tab.** `importData` and the spreadsheet's\n File > Open filled every gap before a cell with blanks, sized by the cell\n reference in the file: `<c r=\"ZZZZZZZ1\">` asked for about eight billion.\n `importData` now rejects a cell past column XFD; the spreadsheet skips a cell\n outside the sheet, as it does other malformed parts. Both refuse a sheet that\n would need more than ten million blank cells to lay out.\n- **A zip bomb could exhaust the tab's memory.** Every .xlsx and .ods reader\n (`importData`, File > Open, `documentFromXlsx`, `documentFromOds`) unzipped\n each part whole before looking at it, so a small file whose parts inflate to\n gigabytes was read into memory first. Parts are now unzipped as a stream and\n counted as they inflate; a file whose parts pass 256 MB together is refused\n at that point.\n- **CSV and TSV from `exportData` neutralise formula-like text**, through the\n same `@svgrid/grid` serializer (see the grid's Security entry).\n\n### @svgrid/grid-wc\n\n#### Added\n\n- **`<sv-chart>`**, the standalone chart as a custom element, at\n `@svgrid/grid-wc/chart` with React (`/react/chart`), Vue (`/vue/chart`)\n and Angular (`SvChartComponent`) wrappers. Its surface is generated from\n `SvChart`'s own props type the way `<sv-grid>`'s is from the grid's, so the\n 26 props and 7 events stay in step; `spec` is a property, the primitives\n are attributes, and a prop that takes a boolean or a string (`legend`) keeps\n a string attribute where a bare attribute means true. Its own build in\n `dist/chart` carries none of the grid.\n- **Typed event handlers.** Each wrapper's `on<Event>` prop used to be\n `(detail: unknown) => void`, so reading `newValue` meant casting first -\n a poor advertisement for a typed wrapper. The detail type is now lifted from\n the grid's own callback signature, so 16 of the 19 events arrive fully typed\n (`TData` degrades to `Record<string, unknown>`; anything referring to a\n type that only exists inside `@svgrid/grid` stays `unknown` rather than\n naming something a consumer cannot resolve).\n\n- **React, Vue and Angular components**, as subpath imports:\n `@svgrid/grid-wc/react`, `/vue` and `/angular`. Each is generated from the\n same surface as the elements, so all 98 properties and 20 events are typed\n props on every one of them and none can drift from the grid. Each framework is\n an OPTIONAL peer dependency, so a plain-HTML consumer installs none of them,\n and the wrappers are 1.3-3.7 KB gzip because they reuse the one element bundle\n rather than shipping a second copy of the grid.\n\n They exist because a raw custom element is genuinely awkward in each:\n **React 18 and earlier stringify object props onto attributes**, so\n `columns={cols}` silently becomes `\"[object Object]\"` and the grid renders\n empty; **Vue** needs `isCustomElement` build config and a `.prop` modifier\n on every object binding; **Angular** needs `CUSTOM_ELEMENTS_SCHEMA` in every\n component that shows a grid, and gets no typed inputs. The Angular wrapper is\n compiled with ng-packagr in partial-Ivy mode, so it is consumable by a normal\n Angular build, and its selector is the element's own tag - `<sv-grid>` and\n `<sv-grid-shadow>` - with no template of its own, so there is no extra wrapper\n element in the DOM and the tag is the same one you write in plain HTML.\n\n All three also handle two ordering problems a hand-written wrapper meets:\n the element renders BEFORE a framework assigns properties in an effect, and\n `apiready` fires once during that first mount - before React can bind a\n listener at all. The handle is parked on the element and each wrapper replays\n it.\n- **The package ships TypeScript declarations.** It previously had none, so\n `import '@svgrid/grid-wc'` was an error under `moduleResolution: bundler`\n and `document.querySelector('sv-grid')` came back as a bare `Element`. The\n generated `.d.ts` augments `HTMLElementTagNameMap` and\n `HTMLElementEventMap`, so the element and its events are typed without\n hand-written declarations.\n- **`<sv-grid-shadow>` - the grid in an open shadow root**, so a host page's\n CSS cannot reach it. Same properties, attributes and events as `<sv-grid>`;\n a separate element rather than an attribute because Svelte resolves\n `customElement.shadow` at compile time, so no runtime flag can switch it.\n Isolation is one-directional and the docs say so: page CSS stops at the\n boundary, but the grid's own stylesheet is still injected into the document,\n because about twenty overlay surfaces portal to `document.body` on purpose\n to escape ancestor clipping. `--sg-*` theme tokens reach in unchanged,\n including a theme file's dark variant - custom properties are inherited, and\n inheritance crosses a shadow boundary.\n- **The elements now expose the whole grid.** `<sv-grid>` declared **7 props\n and 2 events** by hand against a `Props` type with 100 props and 19\n callbacks, so grouping, pagination, pinning, tree data, master/detail, board,\n scheduler and every Enterprise feature were unreachable from a non-Svelte\n host - while the docs said they \"all come along\". The surface is now\n **generated** from `<SvGrid>`'s own types: **98 properties** (72 with\n kebab-case attributes, 26 property-only) and **20 events**, with CI failing if\n the two drift. Costs 1.6 KiB gzip.\n- **Every grid callback is a DOM `CustomEvent`**, `detail` being the\n callback's argument - or, for the one callback taking two, an object keyed by\n its parameter names. `onApiReady` also parks the imperative handle on the\n element as `el.api`, because an event fires once and a host binding a\n listener later would otherwise never reach it.\n\n#### Fixed\n\n- **Importing the package on a server threw `customElements is not defined`.**\n Svelte registers each element with a bare top-level\n `customElements.define(...)`, so any server-rendered React app\n (TanStack Start, which Lovable now generates, Next.js, Remix) crashed on\n `import { SvGrid } from '@svgrid/grid-wc/react'`. The build now guards the\n registration; on a server the import is inert and SSR emits a plain\n `<sv-grid>` that upgrades on hydration. Guarded by `test/ssr.test.ts`.\n- **The React wrapper lost props the grid reads once at mount.** It wrote\n props in a passive `useEffect`, which runs after paint; the element mounts a\n microtask after insertion, so it had already mounted with defaults and\n `pageSize={25}` showed 10 rows a page (the wrapper's own pagination example\n did). Props are now written in a layout effect, before the element mounts.\n The same change in the `<sv-chart>` wrapper.\n- **`style` on the React wrappers took `Record<string, string | number>`,** so\n passing a React `CSSProperties` object failed to type-check. It is\n `CSSProperties` now.\n- **The React wrapper re-did all its work on every parent render.** Both of its\n effects had no dependency array, so any state change anywhere in the parent\n reassigned all 98 properties and rebound all 20 event listeners - 40 listener\n mutations per keystroke. It now writes only values that actually changed and\n binds listeners once through a handler ref. Measured: 20 no-op re-renders\n produce 0 listener adds, 0 removes and 0 property writes.\n\n- **The element threw when it rendered before its props were assigned.**\n Generating the prop list replaced the elements' own `data = []` /\n `columns = []` defaults with a bare `$props()`, so a consumer that assigns\n properties AFTER the element upgrades - which is what React and Angular both\n do, in an effect - got\n `TypeError: Cannot read properties of undefined (reading 'map')` and a grid\n that never rendered. Only a real framework app was late enough to reproduce\n it; an HTML fixture sets the properties in the same tick and never sees it.\n\n#### Changed\n\n- **Only arrays, objects and functions changed shape: they are property-only.**\n An HTML attribute is a string, so `columns='[object Object]'` cannot work\n and no attribute is offered for the 26 props that are not primitives. The\n published `rowclick` and `selectionchange` events keep the exact\n `detail` they shipped with, and `selectable` keeps meaning row-selection\n checkboxes - `<SvGrid>`'s prop of that name is an alias of\n `enableCellSelection`, and forwarding it would have silently repointed a\n published attribute at a different feature.\n- **Styles arrive with the code that needs them.** The build used to put every\n stylesheet in the bundle, lazy chunks included, into the entry, so a page\n that never opened the chart, a date picker or a menu still downloaded their\n CSS. Each chunk now carries its own styles and adds them to the document\n and to every open shadow root when it loads. `<sv-grid>`'s entry went from\n 107 KiB to 98.5 KiB gzip while the chart grew.\n\n### Tooling & docs\n\n#### Added\n\n- **Every chart gallery demo switches between Chart and Grid.** A segmented\n control first in each demo's toolbar flips every pane to a sortable grid\n of the rows the chart was drawn from, and back, the way the board demos\n switch Board and Table. The from-the-grid page shows the pattern in a\n runnable.\n\n- **Charting a pivot is documented.** The pivot page has a section on\n `pivotToChartSpec` (the mapping, every option, a runnable that pivots\n orders and charts them by quarter) and on the designer's Chart view\n (`chartable`, `defaultView`); the charts hub and the from-the-grid page\n link to it, the /api pivot section lists the function, and the generated\n reference covers `pivot-chart.ts`. Demo 359's data now puts every\n country in every quarter and category, so its groups are four bars, not\n one.\n\n- **27 runnable framework examples**, nine each for React, Vue and Angular:\n a first grid, sorting and filtering, editing and saving, row selection,\n grouping and totals, pagination, server-side data, theming, and Excel export\n from the Enterprise pack. Every one has\n an **Open in StackBlitz** button that boots a full editable project - no local\n install - and a new\n [React, Vue or Angular](/docs/help/web-components/frameworks) landing page\n puts the thirty-second path first.\n\n They are real apps in the repository (`packages/grid-wc/examples/`), not\n snippets, and CI compiles all of them with each framework's own compiler -\n including `ngc --strictTemplates`, so a wrong Angular binding fails the\n build. The doc listings are generated from those files, so a page cannot\n describe a version of an example that no longer exists.\n\n The Vue templates get an extra check of their own: Vue treats an unknown\n attribute as a legal fallthrough, so `<SvGrid sortabel />` type-checks\n cleanly and silently does nothing. Verified - the same typo fails the React\n and Angular compilers and passes `vue-tsc` - so the Vue examples are also\n checked against the generated surface.\n\n- **A Web Components docs category.** Eight pages under\n `help/web-components/` - quick start, a generated `<sv-grid>` reference,\n shadow DOM, React, Vue, Angular, TypeScript and limitations - replacing a\n single page that was filed under \"Layout & Styling\". The reference tables are\n generated from the grid's types, and a guard checks that the counts quoted in\n prose still match the surface.\n- **The docs run.** A `svelte` code fence tagged `{runnable}` is extracted at build time\n into a real component, so a doc page shows the source and the working result\n together rather than highlighted text. 504 examples across the corpus, taking\n the median doc page from 1 example to 3; each one is compiled by `svelte-check`\n in CI, so an example that stops working fails the build instead of rotting in\n place.\n- **`@svgrid/ui` recipe scaffolder** - `npx @svgrid/ui add <component>` drops a\n ready-to-edit starter (e.g. `add calendar`) into your app, complementing the\n shadcn-style component pages (Preview / Code, install tabs) across the UI kit.\n- **See a component before you wire it in** (`@svgrid/ui` 0.3.x).\n `npx @svgrid/ui try <component>` spins up a zero-setup Vite + Svelte sandbox and\n opens the component in your browser; `add --preview` writes a\n `src/routes/preview/<id>` route (plus a `/preview` index) in a SvelteKit app.\n `add` now installs `@svgrid/grid` by default (`--no-install` to opt out) and\n prints the exact `try` command for whatever you just added, so the \"see it\"\n step is never a dead end.\n- **AI coding Skill** (`skills/svgrid`, installable with\n `npx skills add sv-grid/sv-grid`) - an always-on house-style guidance layer\n that complements `@svgrid/mcp`.\n- **The rest of the toolkit is findable.** `packages/grid/README.md` gained an\n \"Also in the box\" section, and the site footer gained a **Toolkit** column\n (SvGrid UI, Kanban board, Scheduler, Dock layout, Studio, Web components).\n The 84 SvGrid UI components have always been exported from `@svgrid/grid`\n itself - `SvButton`, `SvCalendar`, `SvDateTimePicker`, `SvDockLayout`,\n `SvToaster` and the rest are already installed for every grid user - but\n nothing on the highest-traffic surfaces said so.\n\n#### Changed\n\n- **Doc examples show code and result at once.** The runnable card used to be a\n Preview / Code toggle with an in-page editor; it is now the source above the\n live example, both visible, with Copy. A tab hides half of a teaching example\n and makes comparing the two a click, and dropping the editor took the\n on-demand TypeScript compiler chunk off every docs page with it.\n- **`npm create @svgrid` starts on Ember** (the demo theme) instead of Tailwind,\n for every template; `--theme <id>` still picks any preset. The `sveltekit`\n template is now listed on the starters page, and the `sv add @svgrid` demo route\n imports the Ember stylesheet so it no longer renders unthemed.\n\n#### Fixed\n\n- **The base scaffold lists `jszip`**, so \"Download this view as Excel\" works in a new app. Its README no\n longer says a new table appears on reload with the Postgres setup: that route reads the tables once\n per server process, so restart it or call `refresh()`.\n\n- **14 doc examples drew an empty or broken box under their code.** Every\n `{runnable}` block was run against the published packages in a clean Vite\n app. Five needed a SvelteKit load, an `/api` server or a WebSocket (two\n showed \"This example failed to load.\" on svgrid.com) and one is a component\n file that needs props; they are now `{norun}`, a new fence flag: still\n type-checked, never mounted, never promoted back to runnable. The other\n eight now run: the custom header, the real-time cell flash, the\n inline-snippet cell renderer, and the alert, loading-overlay, scroll-area,\n sparkline and toaster examples. The toaster page also said hidden toasts\n appear as room frees; their timers keep running while hidden, which the\n page now says.\n- **`build:lib` in the enterprise package deleted the node bundle.**\n `svelte-package` wipes `dist/`, so a library build alone removed\n `dist/node/studio.js` and the MCP server failed to start until\n `build:node` was run by hand. The library build rebuilds the bundle it\n removed.\n\n- **Docs images and tutorial media 404'd under a site base.** The markdown\n writes them root-absolute (`/docs-media/...`, `/tutorials/...`), which is\n right at svgrid.com and wrong under the `/sv-grid/` base the e2e server\n uses: every docs image and tutorial poster was missing there. The page\n prefixes the base in the HTML before it paints, and an e2e spec loads a\n page with both and checks nothing under those roots 404s.\n\n- **Twenty-one links on the chart pages went to GitHub 404s.** The split\n wrote every cross-link with one `../` too many, and the site's link\n resolver falls back to a GitHub URL for a page it does not know. Fixed on\n the pages, and every relative link under docs/ is now a test\n (`tools/docs-relative-links.test.ts`); the link checker existed but only\n ran by hand before a release.\n- **Links into the generated reference tree went to GitHub too.** The tree\n is hidden from the docs routes; a link to it lands on the /api page, on the\n module's section where it has one.\n- **The chart gallery said \"the source is under each example\" and it was\n not.** Each gallery card now carries the demo's own script and markup on a\n Code tab, written by `tools/gallery-doc-code.mjs` from the demo file and\n guarded by a drift test, so the code beside a preview is the code that\n renders it.\n- **A demo page flattened a bulleted banner into one paragraph**, dashes and\n backticks included. The page reads the pitch as blocks: a list where the\n banner wrote one, `<code>` where it wrote backticks, on the prerendered\n and the hydrated page alike.\n- **`demo-doc-embed` skipped a demo the page only linked to**, so a\n placement for it never landed, and it opened a new \"More examples\" section\n below \"See also\", which the coverage test requires to be last. Present\n means embedded, and the section opens above \"See also\".\n- **Regenerating the doc snippets took the dev server's file watcher with\n it.** The extractor removed and recreated its output directory, and on\n Windows the watch did not re-attach, so an edited runnable kept serving\n its old chunk while the source beside it showed the new code. It writes in\n place and removes only what no longer belongs.\n- **The Getting started chart page had no live example.** Its code blocks\n were `ts` and a Svelte block referencing rows it never declared; four of\n them run now, and the hub's first example runs with its own rows and a\n filter row, so the chart is seen following the grid.\n\n- **The e2e suite adopted any server on :5180.** Playwright reuses whatever\n answers on the port, and a Vite dev server returns the app shell for any\n path, so a website dev server started by hand (base `/`) passed the\n readiness check and the fourteen path-routed and module-importing specs\n failed with nothing pointing at the server. The config now probes the port\n first (`tests/e2e/lib/site-server-probe.mjs` reads the base off Vite's\n client script tag), reuses a server that serves the site under `/sv-grid/`,\n skips one that serves anything else with a line saying so, and starts its\n own on the next free port; `SVGRID_E2E_PORT` pins one.\n- **The website dev server re-optimised dependencies mid-session.** The\n search index, the docs renderer, the /api runner's compilers, the PDF\n exporter and the grid's `esm-env` sit behind dynamic imports the start-up\n scan does not reach, so the first page to touch each one triggered\n \"optimized dependencies changed. reloading\" on every open page. In the e2e\n suite that reload landed mid-test on a cold cache and failed whichever spec\n was on a page at the time. They are pre-bundled at start-up now\n (`optimizeDeps.include`), and `esm-env` is a declared devDependency of the\n website so it resolves from there.\n- **The /api runner check sampled an example's outcome two frames after\n Run.** An example awaiting an export or a fetch was still running, so a\n failure that arrived later, or one thrown inside a library callback the\n runner's try/catch cannot see, passed. The check now waits for the runner\n to report an outcome and counts an uncaught error or rejection during the\n run as a failure of that example.\n- **181 doc pages had content stranded below \"See also\".** Authoring passes\n appended new sections to the end of the file, which buried them under what\n reads as the page footer: on `help/filtering/number-filter`, for instance, the\n `between` example sat below the link list and a reader would never reach it.\n The footer is back at the bottom on every page, and a test now fails if a\n section lands under it.\n- **The documented way to lock one column's width never worked.**\n `docs/help/columns/column-sizing.md` matched headers on `data-col-id`, which is\n the attribute on *body* cells - the selector matched nothing. Header cells\n carry `data-svgrid-header-col`. (`ColumnDef.resizable` is now the real answer.)\n- **`blockKey` was missing from `tools/lib/md-snippets.d.mts`.** The function was\n exported from the `.mjs` and worked at runtime, so nothing caught it until the\n website was type-checked.\n- **`@svgrid/mcp` reports its real version.** The MCP server's\n `serverInfo.version` was hardcoded to `0.1.0`; it now reads the package version.\n- **`@svgrid/create-studio` scaffold builds out of the box.** The generated app\n shipped an orphaned `/products` route referencing an entity that was never\n defined; the `Product` schema, seed, data source, nav, and home card are now\n complete, so `npm run build` succeeds on a fresh scaffold.\n- **API-docs accuracy pass across all 74 UI-component pages.** Corrected the\n `SvDockLayout`, `SvDockManager`, and `SvDateTimePicker` prop tables (added 13\n missing dock-layout props; removed a `size` prop `SvDateTimePicker` never had),\n and filled scattered gaps (`loading`, `onClosed`, `min` / `max`, `dir`,\n `width` / `height`, `ariaLabel`, and the shared field-contract on\n `SvFileUpload`).\n\n### @svgrid/mcp\n\n#### Changed\n\n- **A cold `npx -y @svgrid/mcp` installs 20 packages instead of 111.** The\n server speaks MCP over stdio itself instead of through\n `@modelcontextprotocol/sdk`, whose HTTP and OAuth dependencies (Express, Hono,\n JOSE, AJV) a stdio server never runs. On an empty npm cache the install took\n 6 to 8 seconds instead of 12, which had left little room under an MCP client's\n 30 second connect timeout. The protocol is unchanged: version negotiation,\n errors and every tool, resource and prompt answer as before.\n\n## [1.0.0] - 2026-06-16\n\nInitial public release - the Svelte 5-native data grid: `@svgrid/grid`\n(MIT core) and `@svgrid/enterprise` (the paid feature pack).\n\n### @svgrid/grid\n\n- **New** `onCellValueChange` callback on `<SvGrid>`. Fires after every\n inline edit commits with `{ rowIndex, columnId, oldValue, newValue,\n row }`. The recommended hook for server-side persistence and cascading\n recomputes; see demo `18-cascade-editing` and\n [Saving values](./help/editing/saving-values.md).\n- **New** `externalSort` + `externalFilter` props. Grid records the UI\n state but does NOT re-order / filter rows - the consumer owns the\n pipeline. Paired with `onSortingChange` / `onFiltersChange` for\n server-side data and tree-data scenarios.\n- **New** `onSortingChange(sorting)` / `onFiltersChange(filters)`\n callbacks. Fire on every change with the consolidated payload shapes\n documented in the [SvGrid reference](./reference/SvGrid.md).\n- **New** `onRowSelectionChange(selection, rows)` and\n `onActiveCellChange(cell)` callbacks.\n- **New** `fitColumns` prop. Scales column widths to fill the viewport,\n with rounding-residue absorbed in the last scalable column. Shrinks\n down to 85 % of natural widths; beyond that a horizontal scrollbar\n appears.\n- **New** `showRowNumbers` prop. Leading 1-based row-number column,\n rendered before any selection column.\n- **New** `pageSize` prop on `<SvGrid>`. Initial page size for the\n built-in pager.\n- **Improved** column virtualizer now detects per-item size changes,\n not just total size. Fixes a regression where resizing a column under\n `fitColumns` left other columns stale.\n- **Improved** the wrapper-managed filter pipeline no longer applies\n filters to the pre-paginated view - the filter UI always sees the\n full dataset, not just the visible page. (Removed\n `paginatedRowModel` from the engine pipeline; pagination is applied\n AFTER filters by the wrapper.)\n\n### @svgrid/enterprise\n\n- **New** package. The paid feature pack adds:\n - **Export** to xlsx / pdf / csv / tsv / html, with theme-matched\n styles, multi-sheet workbooks, header + footer with logo, embedded\n cell images. See [Export](./help/export.md).\n - **Print** with repeat-on-page headers, optional cover page,\n page-size + orientation.\n - **Import** from xlsx / csv / tsv / json with column mapping +\n per-row validation. See [Import](./help/import.md).\n - **AI assistant**: provider-agnostic helpers for natural-language\n filter, smart fill, summarize, and classify. Bring your own model\n adapter. See [AI](./help/ai.md).\n - **Pivot tables** via `createPivotModel(data, config)` and\n `pro.pivot.build(config)`. Row + column axes, 8 built-in\n aggregators or custom, grand-total row + column, subtotals,\n custom axis sort. See [Pivot tables](./help/pivot.md).\n- **New** `installEnterprise(api)` augments a `SvGridApi` with `exportData`,\n `print`, `importData`, `ai.*`, and `pivot.*` methods.\n- **Soft-gated licensing**: features run unlicensed but the grid shows\n a small watermark + a one-time console nudge. `setLicenseKey('SVENTERPRISE-…')`\n at app startup clears both.\n\n### Examples gallery\n\n- **New demos** (56-59): theme-matched export, branded export with\n header + footer + logo, export with cell images, multi-sheet export.\n- **New demos** (52-pivot-table, 51-ai-assistant, 53-excel-import):\n reference implementations for each Enterprise feature.\n- **New demos** for industry verticals: stock market (live ticks),\n HR team, finances ledger, industrial IoT, localization, CSP\n compliant, accessibility, cascade editing, server-side rendering,\n industrial dashboard, healthcare EMR, logistics, compliance queue,\n field service, gantt, scheduler, CRM, admin dashboard, seller panel.\n- **New** \"Source\" button on every demo opens the raw `.svelte` file\n in a modal with a Copy-to-clipboard button. Wired via\n `import.meta.glob('../demos/*.svelte', { query: '?raw' })` so it\n picks up new demos automatically.\n\n### Docs\n\n- **New** [Enterprise feature pack](./enterprise/README.md) landing page.\n- **New** [API reference](./reference/index.md) with hand-curated\n pages for `<SvGrid>`, `SvGridApi`, `ColumnDef`, features, and the\n full Enterprise surface.\n- **New** [Why headless?](./why-headless.md) explains the layered\n architecture and when to drop down to the headless core.\n- **New** [Tailwind integration](./help/tailwind.md) walks the\n `--sg-*` token surface, dark-mode wiring via `data-theme`, and the\n override hooks for the stable `.sv-grid-*` class names.\n- **Split** [Getting started](./getting-started.md) into six short\n pages (install / first-grid / data-and-columns / features /\n theme-and-density / going-to-production); the old single-page\n version is preserved at\n [getting-started-full.md](./getting-started-full.md).\n- **Cleaned** every code sample against the live library surface.\n Removed phantom APIs: `state={...}`, `rowModels={...}`,\n `initialState={...}`, `manualFiltering`, `manualSorting`,\n `manualPagination`, `onColumnFiltersChange`, the wrapper `getRowId`\n prop, per-column `enableSorting` / `enableColumnFilter` /\n `enableGrouping` flags, the never-shipped\n `@svgrid/grid/themes/default.css` import.\n- **Em-dashes globally swept to hyphens** (`-` → `-`) across all\n source-controlled text. Codified as a rule for new content.\n\n## How we version\n\n| Tier | What it means |\n| ----------------- | -------------------------------------------------------------------------------------------------------------- |\n| **Major** (1.x) | Breaking change to a Stable API. Includes prop / method renames, type-narrowing, default-behaviour changes. |\n| **Minor** | New Stable API. New Experimental API. New demo. Doc rewrites that touch the public-facing claims. |\n| **Patch** | Bug fixes. Type-only fixes. Internal refactors with no public surface change. Doc typo fixes. |\n\nThe [API stability page](./help/api-stability.md) annotates each export\nwith its current tier (`Stable`, `Experimental`, `Internal`). As of 1.0,\n`Stable` APIs follow semver; `Experimental` APIs may still change in a\nminor release.\n"
4607
+ "markdown": "# Changelog\n\nThe user-facing log of what shipped. Format follows\n[Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/);\nversioning follows [Semantic Versioning](https://semver.org/).\n\nEvery release has up to six sections:\n- **Added** - new features\n- **Changed** - existing functionality, behaviour changes\n- **Deprecated** - soon-to-be-removed features\n- **Removed** - features removed in this release\n- **Fixed** - bug fixes\n- **Security** - vulnerability patches (with CVE ids when applicable)\n\nPre-release entries live under `## [Unreleased]`. They graduate to a\ndated heading on publish via `pnpm changeset version` (see\n[.changeset/README.md](../.changeset/README.md)).\n\nFor machine-readable releases, fetch\n[`/changelog.json`](/changelog.json) - same content, parseable shape.\n\n## [Unreleased]\n\n### @svgrid/grid\n\n#### Added\n\n- **`SvRichText` for pages and articles.** Four tools to list in `tools`: `image` (the file\n goes to `onImageUpload`, which resolves to the URL to insert; without it, a URL is asked\n for), `table`, `hr` and `source` (the HTML in a text area). `name` posts the value with a\n native form as a hidden input, and `sanitize` replaces the sanitizer for content the app\n trusts. The default toolbar is unchanged. `sanitizeHtml` now keeps tables (with `colspan`,\n `rowspan` and `scope`) and `<hr>`.\n\n- **`trustedHtml(html)`.** `sanitizeHtml`, ready for an HTML sink on a page that requires Trusted\n Types: there it is a `TrustedHTML` of the `svgrid` policy, elsewhere the same string.\n\n- **`toggleOnSecondClick` on a checkbox column.** The first click selects the cell, a click on the selected cell toggles it, and a finger toggles on the tap. Off by default.\n\n- **`parseClipboardText`, and more for the fill and paste hooks.** `parseClipboardText(text)` splits a\n paste into rows of cells, for a consumer whose copy quotes a cell. `processCellForFill` also gets\n `sources` and `index`, and `processCellFromClipboard` gets `cell`, the place in the pasted block.\n Left out, a grid fills and pastes as it did.\n\n- **`keepFocus`.** When the focused control of a region is removed or disabled, focus\n moves to the control now in its place, not to the body. `createFocusTrap` and\n `menuFocus` use it, so dialogs, drawers and menus have it. `use:keepFocus` gives it\n to any other region.\n- **`describedBy` on `SvModal`.** The id of what a dialog says, read with its title.\n\n- **`holdRowsOnWrite`.** A paste, a clear or a fill changes rows where they stand, as a\n typed edit does, for an app that orders the view itself when the person moves on.\n- **`onPasteOverflow`.** The lines of a paste past the last row, split into cells, inside\n the paste's undo step. Without it they are dropped, as before.\n- **`gridLabel`.** The accessible name of the grid, on its table element. SvGrid Base\n passes the table's name.\n- **Very long grids scroll true at both ends.** Past the height a browser paints\n cleanly the grid now scales its scroll, with a pixel staying a pixel near each end,\n so the rows past about 560,000 of a million draw as they should and Ctrl+End\n reaches the last row.\n- **`onColumnVisibilityChange` and `onColumnPinningChange`.** Hiding,\n showing, pinning or unpinning a column, from the column menu, the api\n setters or `api.setState`, now calls back with the hidden ids or the\n `{ left, right }` pinning, the same shapes `api.getState()` reports. Both\n are deduped on the value and do not fire on mount. An app saving the\n layout no longer has to poll `getState()` to notice either. The\n `<sv-grid>` element fires `columnvisibilitychange` and\n `columnpinningchange`.\n\n- **`SvGridProps` is exported.** The full prop type, for a wrapper that\n forwards a typed options bag to `<SvGrid>`. Without it a wrapper had to\n hand-write a `declare module \"@svgrid/grid\"` stub, which shadows the\n package's own types.\n\n- **`chartSpecToTable`.** The rows and columns a spec amounts to, in the\n shape `SvGrid` takes: one row per category with a column per series (a\n grouped axis adds a Group column, a histogram From and To, candles their\n four prices, a box plot its five numbers), per point for a scatter, per\n link for a sankey or chord, per leaf for a tree map or sunburst with a\n column per level, per day for a calendar, one row for a gauge. Number\n columns carry the chart's format (a right-axis series its axis's) and a\n date axis is a date column. The gallery demos' Chart | Grid switch is this\n behind a sortable grid.\n\n- **The Chart panel charts the pivot in pivot mode.** With `pivot` and\n `charting` on one grid, the pivot bar carries the Chart toggle and the\n panel draws the pivot on screen: row groups as categories (nested rows a\n grouped axis), column groups as series, the measures' format on the axis,\n totals left out. The data pickers step aside with a note and the Type\n select keeps the shapes a pivot can take; Stacked, 100%, Horizontal, the\n Format tab, the builder, saved charts, export and Describe still apply. A\n click on a bar filters the innermost row dimension when the grid has a\n column for it, which re-runs the pivot. It used to chart the source rows by\n the source columns whatever was on screen. The mapping is\n `pivotResultToChartSpec` (with `pivotChartType`, `pivotFilterColumn`)\n in the lazy chart engine; enterprise's `pivotToChartSpec` is the same\n function. `bucketsToChartSpec` (server aggregates as a spec) moved there\n from the controller, out of the base bundle.\n\n- **Scatter points select.** A click or Enter on a scatter or bubble point\n selects it the way a bar selects: the point's `label` (or its series) is\n the category, its y the value, and `selectable`, `bind:selected`,\n `onSelectionChange` and `onSelect` all apply. The dots had no click\n handler, so on a scatter chart those props did nothing.\n- **`ChartPointRef.index`.** A selected bar carries its category index\n beside its label, and two refs with an index match only on the same one.\n A grouped axis repeats its leaf labels (Q1 to Q4 under each year), so a\n click on the second Q2 used to select the first Q2 with it. A ref written\n without an index still matches by label.\n- **Data labels on a 100% chart read the share.** Under `stacked100` the\n axis is already a share whatever `valueFormat` says; the labels on the\n bars now say \"18%\" as well, rather than \"$18\", or \"1800%\" when the format\n was percent. A `dataLabels.formatter` still receives the raw value and the\n tooltip keeps it.\n- **A series on the right axis reads in that axis's format.** The tooltip,\n the screen-reader table, the live region and the data labels format a\n series with `axis: 'right'` through `y2Axis.format` or `formatter`, so a\n margin of 0.29 beside a revenue in dollars reads \"29%\" and not \"$0.29\".\n Without a format of its own the right axis is plain numbers, as its ticks\n are.\n- **The breadcrumb survives `toolbar={false}`.** A drilled sunburst, tree\n map or pie with the toolbar off still shows its breadcrumb in a strip of\n its own; it used to have no way back up.\n- **Chart axis model.** `xAxis`, `yAxis` and `y2Axis` on a spec take\n `min`, `max`, `nice`, `tickCount`, `tickInterval`, `format` or a\n `formatter`, `title`, `gridLines`, `labelRotation`, `reversed` and, for\n the x axis, `type: 'number'` for a numeric axis that spreads categories by\n value. `referenceBands` shade a range on either axis, `referenceLines` can\n be vertical, `title` / `subtitle` / `caption` frame the chart. Series\n gained `marker` shapes and per-point `markers` / `colors`, `strokeWidth`,\n `dash`, `opacity`, `gradient`, `step` lines, `connectNulls` and a\n `nullAs` policy; `dataLabels` takes a placement, a formatter and overlap\n hiding; the component takes a `tooltip` snippet, `tooltipFormat`,\n `tooltipMode: 'single'`, a `legend` side and a `legendItem` snippet, and\n `autosize`. `rowsToChartSpec` reduces with `min`, `max`, `median`,\n `first`, `last`, `countDistinct` and `pN` and buckets a date dimension by\n `day` / `week` / `month` / `quarter` / `year`.\n- **Decimation for long series.** `decimate: 'auto'` (the default) thins a\n line or area with more points than pixels through LTTB, which keeps the\n shape; `{ method: 'minmax' }` keeps every spike. Zoom is applied first, so\n zooming into 300 of 100,000 points shows all 300. `lttb`, `minMaxIndices`,\n `decimateSpec` and `pickCategories` are exported.\n- **Thirteen more chart types**: `histogram` (with `binValues` and\n `rowsToHistogramSpec`), `range-bar`, `range-area`, `lollipop`,\n `dumbbell`, `pareto` (`paretoSpec`), `stream` (`stackOffset: 'wiggle'` or\n `'silhouette'`), `sunburst`, `radial-bar`, `radial-column`,\n `nightingale`, `chord` and `bullet`; plus hollow and Heikin-Ashi candles\n (`candleStyle`) and pyramid / cone funnels (`funnelShape`). All of them are\n in the grid panel's picker, gated on what the current columns can feed.\n- **Zoom, pan and presets.** `zoomable` takes an object: `wheel` (`true` or\n `'modifier'` for Ctrl + wheel), `pinch`, `pan` (`'shift'`, `'mode'` or\n both) and `axis` (`'x'`, `'y'`, `'xy'`). The window is a bindable\n `zoom` prop of category indices with `zoomTo` / `resetZoom` on the\n component and an `onZoom` callback; `rangePresets` puts 1W / 1M / 3M / 6M /\n YTD / 1Y / All in the toolbar on a time axis.\n- **Synchronized charts.** Charts with the same `syncGroup` share their\n crosshair and zoom window, matched by label and then by date. The grid\n panel's `syncTabs` keeps one window across its chart tabs.\n- **Context menu, animation, drilldown, selection, keyboard.** `contextMenu`\n (built-in export / zoom / series items, your own `MenuItem`s, or a function\n of the clicked point; Shift + F10 opens it), `animate` (a data-update tween\n and `'fade'` / `'grow'` / `'wipe'` enter effects, off under reduced\n motion), `drillable` + `drillPath` for tree maps and sunbursts with a\n breadcrumb, `selectable` + `selected` + `onSelectionChange` for point\n selection with dimming, Up / Down stepping through series with a polite live\n region (`announce`).\n- **Financial toolkit.** `bollingerBands`, `rsi`, `macd`, `vwap`, `atr`,\n `stochastic`, `wma` and `obv`, NaN-padded like the moving averages;\n `'wma:N'`, `'bb:N:K'` (a shaded band) and `'vwap'` overlays;\n `indicatorPane` and `SvChartPanes`, which stacks indicator panes under a\n price chart with one x axis, one gutter and one crosshair; `rowsToOhlcSpec`\n and `resampleOhlc` (daily bars to weeks / months); `lastPriceLine`;\n annotation `shape` (`'flag'`, `'pin'`, `'square'`) with a tooltip\n `text`; `volumes` on a series.\n- **Drawing tools.** `drawable` puts trend line, horizontal ray, Fibonacci\n retracement, rectangle, arrow and note tools in the toolbar; the drawings\n are data points (`spec.drawings`, `onDrawingsChange`) so they survive a\n zoom, a resize or new data. A selected drawing has draggable handles and\n Delete removes it.\n- **PDF and print** with no PDF library: `chartToPdfBlob`, `downloadChartPdf`\n (a one-page A4 or Letter PDF with the chart as a JPEG and the titles as\n text) and `printChart`, in the toolbar, the context menu and the panel's\n export menu.\n- **Chart builder in the grid panel.** The Build button opens a modal with a\n type gallery (a live thumbnail per type), the data pickers and a Format tab\n (titles, legend and label placement, axis title / min / max / format / grid\n lines, per-series colour / type / axis / marker / width). The format is\n `ChartFormatState` on the chart tab, applied by `applyChartFormat` to every\n derived spec, saved with the view and reachable through\n `configureChart({ format })`. A link toggle unlinks a chart from the grid\n (`configureChart({ frozen: true })`) so it keeps its data while you filter.\n `charting.onChartCreated` / `onChartChanged` report the panel's lifecycle;\n `charting` also takes `zoom`, `rangePresets`, `syncGroup`, `syncTabs`,\n `contextMenu` and `animate`.\n- **Candlesticks from the grid panel.** Pick Candlestick or OHLC bars and the\n panel finds the Date, Open, High, Low, Close and Volume columns by name;\n Indicators chips add panes and overlays; `configureChart({ ohlc,\n indicators })` and the AI chart plan reach the same thing.\n- **A scatter series' `overlay` is a regression of y on x.** Until now the\n scatter layout ignored `overlay` (the fits ran on the index, which a\n scatter has no use for). The regressions (`linearFit`, `polynomialFit`,\n `exponentialFit`, `logarithmicFit`, `powerFit`) take an optional `xs`\n and return `predict(x)`; `regressionFit(values, overlay, xs)` names one by\n its overlay string; a scatter series with `overlay` gets the curve drawn\n across the plot (sampled evenly in log space on a log axis) and its\n equation and R-squared in the point tooltip.\n- **Chart gallery: fourteen full-size demos, one per family, and a docs page\n for them.** Bars, lines, areas, pie / donut / sunburst, scatter and bubble,\n combination, histogram and box plot, heat map and calendar, radar and\n radial, tree map and sunburst, sankey and chord, waterfall / funnel /\n pareto, gauges and bullets, and an annotated chart (demos 438 to 451),\n each with its own data and the switches that family needs, embedded on\n `help/charts/gallery` and the type pages.\n- **Grid chart panel: a deeper Format tab, one set of pickers, a\n localized panel and saved charts.** The builder's Format tab adds series\n labels, the crosshair's axis pills, a compact rule below a width\n (`compactBelow`, through `CHART_RESPONSIVE_PRESETS.compact`), a stack\n group per bar or area series and the chart's font, size, background and\n text colour (`ChartFormatState.seriesLabels` / `crosshairLabels` /\n `compactBelow` / `series[].stack` / `style`). The panel's pickers and the\n builder's Data tab are one component (`SvGridChartPickers`), so the two\n cannot disagree about what a type needs. Every string the panel and the\n builder show is a `chart*` key on `localization.text`\n (`GridChartPanelMessages`, loaded with the panel; `GridMessages` is now\n the chrome map and the panel map together). `api.saveChart(name)`,\n `applySavedChart`, `removeSavedChart`, `getSavedCharts` and\n `configureChart({ saved })` keep a tab's whole configuration under a name;\n the panel has a popover for them and `getState()` carries `savedCharts`\n when there are any.\n- **Chart diagnostics, a plain-language description, live feeds and a JSON\n schema.** `validateChartSpec` returns what is off about a spec (unknown\n keys with the nearest name, an unknown type, a series short of the\n categories, a log axis at zero, an overlay the engine does not read, an\n anchor naming no category, and more); `SvChart` logs the findings once per\n spec in development, `aiChart` attaches the errors to its plan, and the\n MCP server's `svgrid_check_code` applies the rules to a static spec\n literal with a rename for a misspelt key. `chartSummary` reads a chart in\n a sentence (trend, extremes, shares, correlation, last close) and\n `SvChart` hands it to assistive technology as `aria-description` and the\n table caption (`describe`), the context menu and the panel copy it, and\n `aiExplainChart` grounds an Explain button on it. `appendPoints` builds\n the next spec of a feed with every per-category array kept in step and a\n rolling window, and `live` on the chart skips the tween and enter effect.\n `docs/schemas/chart-spec.json` is generated from the types, served at\n svgrid.com/schemas and by `svgrid_get`, and a test keeps it equal to the\n validator's lists.\n- **Series and interaction depth.** Areas join `stack` groups like bars\n (`stacked100` and `stackOffset` run per pile); a numeric x axis takes\n `scale: 'log'` (even decades, 2 / 5 minors, non-positive categories\n dropped, decimation in log positions); regression overlays `poly:N`,\n `exp`, `log` and `power` next to `linear`, each carrying `r2` and\n `equation` on the overlay line and read in the tooltip, with\n `linearFit` / `polynomialFit` / `exponentialFit` / `logarithmicFit` /\n `powerFit` / `rSquared` / `computeOverlayFit` / `overlayName` exported\n and `charting.trend` accepting the new names; hovering a mark dims the\n other series (`hoverHighlight`, on by default, snapping within 18px) and\n `onHover` reports the point once per change; `tooltipPosition` parks the\n tooltip in a plot corner and `tooltipSticky` pins it on a click; data\n labels take `rotation` and `connector` (pushed clear of a collision with\n a leader line); `spec.style` sets a chart's font, size, background and\n text / grid colours over the tokens (`chartStyleVars`), honoured by the\n exports.\n- **Accessibility pass on the chart.** Every non-cartesian family (pie,\n sunburst and the radial charts, heat map, calendar, tree map, funnel,\n sankey nodes and links, radar, scatter) is one Tab stop with a roving\n focus: arrows walk the marks (a heat map by row and column, a calendar by\n day and week), Home / End / PageUp / PageDown jump, the focused mark\n raises its tooltip, Enter / Space select or drill, and every mark is named\n and has a focus ring. Zoom from the keyboard: `+` / `-` / `0` on a\n focused category and Shift + arrows to pan, and the brush is a `slider`\n (arrows pan and resize, Home / End, `0`). The toolbar is a `toolbar`, the\n tooltip a `tooltip`, decorative icons are hidden from the tree. Forced\n colors (Windows High Contrast) keep the data colours and repaint the\n chrome with the system palette. `localeText` on `SvChart` (and\n `charting.localeText` for the grid panel) translates every string the\n chart renders itself, with `ChartMessages`, `defaultChartMessages`,\n `resolveChartMessages` and `chartMessage` exported. A new\n `tests/e2e/chart-a11y.spec.ts` runs axe-core against the rendered chart\n on three demos and drives the keyboard model in a real browser.\n- **Stack groups, series labels, responsive rules, pie callouts.** `stack`\n on a bar series names the pile it joins, so plan and actual stack side by\n side in each category and the axis fits the tallest stack; `seriesLabels`\n names each line at its last point in a reserved gutter, pushed apart where\n lines end together; `responsive` patches the spec by the rendered size\n (axes merge one level deep, a rule's `legend` moves or hides the\n component's legend; `resolveResponsive` and `matchResponsiveRules` are\n exported); `dataLabels: { placement: 'outside' }` on a pie draws callout\n labels with leaders instead of percentages, and a spec can carry its own\n `dataLabels`; `visible: false` starts a series hidden with its legend chip\n dimmed; the crosshair reads off the axes with a category pill and a value\n pill (`crosshairLabels={false}` turns them off).\n- **`moveCells` - drag a selected range to move or copy it.** Grab a selected\n range by its border and drop it somewhere else. Move by default, copy with\n Ctrl / Cmd, and the modifier is read at DROP time so it can be pressed or\n released mid-drag. On whenever cell selection is on; `moveCells={false}`\n opts out. A drop is refused outright - nothing changes - when it would land\n off-grid or when any source or destination cell is read-only, rather than\n moving the part that fits and silently dropping the rest.\n- **`selectionBar` - a floating bar over the grid while rows are selected**,\n showing the count and the actions that apply to the whole selection. `true`\n gives the count and a Clear button; an array is shorthand for `{ actions }`;\n the object form also sets `position` (`'bottom'` default, or `'top'`),\n `maxVisible` and `hideClear`. The prop and its types are free; the bar\n itself is an Enterprise renderer, and without it the grid shows a short upsell\n in its place, the same way the scheduler and board views do.\n- **Edge auto-scroll for every drag that extends a rectangle** - the fill\n handle, the range move, and plain drag-select. All three were previously\n capped at whatever was already on screen when the drag began, which on a grid\n built for 100k rows meant the gesture mostly did not work. One shared rAF loop\n scrolls the container when the pointer is inside a 40px edge band, on a linear\n ramp to 20px/frame, in both axes. It keeps scrolling with the pointer parked\n still, which is the whole point of holding at an edge.\n- **Row and column resizing, both opt-in** (`rowResize`, `columnResize`).\n `columnResize` gives every header a drag handle: drag the edge, double-click\n it to size the column to its content, or focus it and use Left/Right (Shift\n for a 1px step). `rowResize` does the same vertically and brings the\n row-header column with it, since that is where the grip belongs; the grid\n stores the heights itself, so neither needs a function-valued `rowHeight`.\n Both load their code on demand, so a grid that leaves them off downloads\n neither.\n- **`ColumnDef.resizable`** - per-column opt-out, consulted only when the grid\n has `columnResize` on. `resizable: false` removes that column's handle\n entirely, so the drag, the arrow keys and double-click-to-autosize all go with\n it, and the column menu drops its Autosize item. For the columns whose width\n is part of the layout: a row-number gutter, a checkbox column, a fixed icon\n column. Programmatic sizing (`api.setColumnWidth`, `api.autosizeColumn`,\n `fitColumns`) still applies.\n- **`SvGridViewState` is exported.** It is the return type of the public\n `api.getState()`, so writing a typed \"named views\" feature previously meant\n either re-declaring the shape or reaching into an internal path.\n- **Form layer depth in `SvForm` / `createForm`.** Schema-driven forms gained:\n conditional / dependent fields (`visible` and `disabled` accept a\n `(values) => boolean` predicate; hidden fields drop out of validation and the\n submit payload), grouped **sections** and a multi-step **wizard** (`stepper`,\n with per-step validation gating), repeatable **field arrays**\n (`type: 'array'` with `itemFields`, plus `addItem` / `removeItem` / `moveItem`),\n **async validation** (debounced, stale-response-guarded, per-field\n `validating` state), **dirty tracking + `reset()`**, and **submit states**\n (`isSubmitting`, an async `onSubmit`, and `setErrors()` for server-side field\n errors). New demos: dynamic form, wizard, and field array.\n- **Public headless cores for the menu / select family** (`createMenu`,\n `createPopoverSelect`, shared `list-nav`), so the popup pickers can be driven\n headlessly and composed into custom UI.\n- **`color` on `ListOption`** - render a small color swatch before the label in\n `SvListBox` and `SvDropDownList`.\n- **`block` on `SvDateTimePicker`** - stretch the field to fill its container\n (100% width), so it fills a grid cell when used as an editor.\n- **`onClosed` on `SvDrawer`** - fires after the exit animation ends and the\n drawer leaves the DOM.\n- **`loading` on `SvField`**, and **`locked`** on `SvDockLayout` /\n `SvDockManager`.\n- **`summary` on `<SvGrid>`** - shortcut alias for `enableRowSummaries`,\n which turns on the footer row that aggregates every filtered row. It wins\n when both are set, the same precedence `selectable` has over\n `enableCellSelection`.\n- **`summary` on a column** - choose that column's footer aggregate\n (`'sum'`, `'avg'`, `'min'`, `'max'`, `'count'`, `'countDistinct'`,\n `'extent'`, `'first'`, or a custom function), or `false` to leave the cell\n blank. Without it a column keeps the old default: sum a numeric column,\n `Count: N` otherwise.\n- **Development-time configuration checks.** The grid used to fail silently on\n the most common mistakes - a misspelled `field` rendered a column of blank\n cells and printed nothing. It now warns once per problem, in dev builds only:\n\n - a column `field`, `groupBy` entry, `treeData.parentField` / `idField` or\n `treeData.column` that does not exist (with a \"did you mean\" for near misses),\n - two columns resolving to the same id,\n - `pageSize` set when pagination was never turned on,\n - a column marked `sortable` while sorting is not enabled,\n - `initialColumnPinning` while column virtualization is on, which silently\n prevents the columns from sticking,\n - `externalPagination` without `rowCount`, `externalSort` without\n `onSortingChange`, and `externalFilter` without `onFiltersChange`.\n\n The checks live in a lazy chunk behind a dev-only branch, so a production\n build never loads them and the base bundle is unchanged.\n\n#### Changed\n\n- **`showColumnFilters` no longer puts an input in the header.** Set to\n `true`, it also drew a plain \"Filter\" text box in every header cell,\n which with `showFilterRow` made two filter inputs per column. It now\n only turns on the column menu's filter section, as documented. For\n always-visible inputs use the filter row: `showFilterRow` or\n `filterMode=\"row\"`.\n- **The find bar loads on the first Ctrl+F.** It is its own chunk now, so a\n grid nobody searches does not carry it; the first open shows the bar once\n the chunk has loaded.\n- **`alignedGridGroup` loads its module on demand.** The shared group that\n mirrors horizontal scroll and column widths between grids is now a lazy\n chunk, fetched by the first grid that sets the prop, the way managed row\n drag is. A grid outside a group no longer carries it, which kept the base\n bundle under its 100 KB budget after this release's scroll and mount\n changes. Mirroring starts once the chunk has loaded, a frame on a warm\n cache.\n- **BREAKING: column resizing is now off by default.** Every column used to have\n a drag handle unconditionally - there was no prop, no per-column option and no\n way to turn it off, so a `width` you set was only ever a starting value a user\n could drag away. Set `columnResize` to get the handles back; the 241 demos in\n this repo that want them now say so. Sorting and filtering have always been\n opt-in behind `sortable` / `filterable`, and resizing was the odd one out.\n- **BREAKING: the footer summary row is now off by default.**\n `enableRowSummaries` used to default to `true`, so a plain\n `<SvGrid {data} {columns} />` grew an aggregate footer nobody asked for and\n every caller that did not want one had to opt out - 375 call sites in this\n repo passed `enableRowSummaries={false}` against 6 that opted in, and the\n API reference already documented the default as `false`. If you were\n relying on the old behaviour, add `summary` (or `enableRowSummaries`).\n- **Ember is now the default theme preset** (`defaultThemePreset` in\n `@svgrid/grid/themes`). It is what the demo gallery and svgrid.com open on, so\n a scaffolded or Studio-generated app now looks like the demos unless you pick\n a preset. Previously the default was Tailwind.\n- **Popup editors keep themselves on screen.** `SvAutoComplete`, `SvComboBox`,\n `SvDropDownList` and the date pickers now measure the space to the viewport\n edge: the panel flips up when there is not enough room below and clamps its\n `max-height` to the available height, so a picker opened near the bottom of the\n window no longer spills off screen.\n- **Dock manager pop-out to a new window is now off by default**\n (`allowPopout={false}`); opt in explicitly. Added a dedicated pop-out demo.\n\n#### Fixed\n\n- **`fitColumns` with `responsive` fills the row when a `hideBelow` column is hidden.** The fit still\n counted the hidden column's width, so the shown columns stopped short and left a blank strip that\n wide at the right edge.\n- **Cut clears only what reached the clipboard.** Ctrl+X, the Cut menu item and the cut command\n cleared the cells at once, before the clipboard write had finished, so a write the browser refused\n (a page without focus, a denied permission) lost the values. The clear now waits for the write, and\n runs only if the text landed and the selection has not moved meanwhile.\n `copySelectionToClipboard()` returns a promise of whether the text landed.\n- **The pinned-column divider in a contrast theme.** Forced colors keep a fill's alpha, so the\n `pinSplitter` divider stayed a faint line and vanished on `Canvas`. It is drawn in `CanvasText`,\n and in `Highlight` under the pointer, with focus and while dragged.\n- **Chart panel: an Export item that is off looks off.** The PDF item that cannot draw the chart's\n text said why but looked like the items that work; it is dimmed as an off CSV item is.\n- **Scheduler model: a day the clocks change is drawn by the clock.** `layoutDayEvents` placed an\n event by the real minutes since midnight, so on a 25-hour day every event sat an hour below the\n row its time is labelled with, and on a 23-hour day an hour above; an event in the last hour of a\n band fell out of it. It now counts wall-clock minutes (`wallMinutes`, `atWallMinute`, both new\n exports). On a week that starts on a 23-hour Sunday, `monthWeekSegments` put Monday's bars under\n Sunday. `timelineAxis` for `timelineDay` ends the band at its hour by the clock and names each\n real hour by its clock (a 25-hour day shows 1 AM twice), where it left a gap or an overlap.\n- **A menu item that is off keeps the arrow keys.** `menuFocus`, `createMenu` (`SvMenu`,\n `SvContextMenu`, `SvMenuList`) and the column and context menus mark it `aria-disabled` and keep\n it in the arrow-key and first-letter order, as the ARIA menu pattern does, so a screen reader\n hears it and why it is off. Its click does nothing. Before, the arrows skipped it.\n- **Forced colors: the header checkbox of a part-selected grid keeps its dash.** The dash was a\n fill, which a contrast theme removes, so the box read as empty.\n- **A chart's PDF refusal is seen at the toolbar and in the grid's chart panel.** For a title the\n PDF's font cannot draw, the toolbar's PDF button did nothing on screen: the reason went to the\n screen reader only. It is now marked off (`aria-disabled`, the reason as its tooltip) once it is\n pointed at or focused, and a press shows the reason in the button. The chart panel's Export menu\n wrote no file and said nothing; its PDF item now reads the reason and is off.\n- **The chart panel's Export menu takes the keyboard.** Arrow keys, Home, End and first letters move\n in it, focus goes to its first item when it opens and back to Export when it closes (it fell to the\n page). Its CSV item, when the chart has no table of values, stays focusable and says why.\n- **Rich text renders under Trusted Types.** `SvRichCell`, `SvRichText` and the sanitizer passed plain\n strings to `DOMParser`, `{@html}` and `innerHTML`, so a page with `require-trusted-types-for 'script'`\n threw and drew nothing. They now go through one policy, `svgrid`, made only where the browser has\n `trustedTypes`. A CSP with a policy list needs `trusted-types svgrid svelte-trusted-html`\n ([SECURITY.md](https://github.com/sv-grid/sv-grid/blob/main/SECURITY.md#trusted-types)).\n- **Chart Print runs under Trusted Types.** `printChart` built its window with `document.write`; it\n now builds it node by node and draws the chart as a `data:` image.\n- **A chart PDF never writes `?` for a letter.** Its text is in the PDF's built-in Helvetica, which\n has Western European letters only. The euro sign, curly quotes and dashes now come out right. A\n title, subtitle or caption with other letters (Cyrillic, Greek, CJK, Hebrew, emoji) is refused: the\n menu's PDF item says which text and points to PNG or SVG, and `chartToPdfBlob` and `buildChartPdf`\n throw a `ChartPdfTextError` naming it. `pdfUndrawable()` tells beforehand.\n\n- **A block cache that refreshes a block still being read frees that read's slot.** `refresh()`,\n `applyRows` and an insert or remove gave up a read in flight without counting it as done, so\n `loading` stayed true for good, and with `maxConcurrentRequests` reached no block loaded again.\n\n- **The \"Could not load these rows.\" line of a failed run sits on the first row wholly on screen.**\n It sat on the first rendered row, which overscan puts above the screen, so a person scrolled\n into a failed block saw a tinted band and no words.\n\n- **An edit deep in a server row model no longer walks the rows.** `find`, `findIndex`, `some` and `indexOf` on windowed\n data read only what is loaded, a paste, clear or fill over rows held in place copies only those, and `cellEdited`\n hands over `rowId`.\n\n- **A filter's count is said once.** Opening or closing a group under a filter no longer repeats\n it, and a closed group counts the records the filter keeps: it read \"28 of 30\" with 24 shown.\n- **`createFocusTrap` and `menuFocus` never drop focus to the body.** An opener that left the page,\n or turned disabled or hidden, hands focus to what held it. A dialog opened from a menu item goes\n back to what the menu went back to. A tooltip closes with Escape.\n\n- **CSV: a cell that starts with a line feed is guarded.** Tab and carriage return were,\n and a spreadsheet reads `\\n=1+1` as a formula too.\n- **A commit keeps the keyboard in the grid.** A pick in a select or dropdown cell, or\n Escape on a multi select, left focus on the body and arrows dead. Tab in a dropdown\n cell left the grid; it now commits and moves on, as the docs say.\n- **Group rows follow their state.** `aria-expanded`, the chevron and the button's\n label went stale until the row was drawn again.\n- **A grouped grid behaves as a treegrid.** Left and Right close and open a group, Enter\n and Space toggle it, and rows of records carry `aria-level`. Enter on a group's row\n used to move down.\n- **The filter count counts records.** \"28 of 34 rows match\" included group headers.\n- **A menu scrolls to the item the keyboard moved to.**\n- **A first click on the cell seeded on mount selects it.** It used to open the editor.\n- **Moving a column by hand is an undo step**, as a resize is. The api's setter records none.\n- **\"Add condition\" in the filter menu keeps focus**, and closing that menu goes back\n to the funnel.\n\n- **Keyboard and focus.** The Menu key and Shift+F10 open the context menu of the\n active cell. The column and context menus take focus, walk with the arrows, Home,\n End and first letters, and give focus back. `menuFocus` gives a menu of your own\n the same. The find bar takes focus when opened from a focused control.\n- **Focus stays in view.** Moving the active cell, or tabbing to a header control,\n stops clear of pinned columns on either side and above a sticky footer.\n- **Right to left.** The left and right arrows go where they point, horizontal\n scrolling to the active cell works, and the pin splitter follows the pinned columns.\n- **A grouped grid is a `treegrid`**, and a group row's cell is the active descendant.\n- **Menus, filter panel and find bar translate** through `localization.text`, as do\n the row number, select row, column menu, filter and resize names. `setModalCloseLabel`\n names the x on every `SvModal`.\n- **Ember**'s muted text reaches 4.5:1 on a pinned header. The column menu button is\n 24 px.\n- **IME.** A key of a composition no longer moves the cell or commits the editor.\n- **Smaller base bundle.** What a fill or a range move writes when the drag ends loads\n with the drag (`range-commit.ts`).\n- **`SvRichText` sanitizes its value.** It wrote `value` to `innerHTML`, so a stored string ran\n its handlers. `value` now goes through `sanitizeHtml` on the way in and out, and `sanitizeHtml`\n keeps a text alignment, rebuilt from scratch, so the alignment buttons survive it.\n- **CSV injection through a list.** `escapeFormulas` guarded strings only, so a multi-select value\n `=1+1` written with `rawValues: true` reached the file as a formula. It now guards everything\n but numbers.\n- **Open groups stay open.** In a grid with no `expanded` prop, a change to any other\n prop, such as new `data`, folded every group the person had opened.\n- **A row model that groups on the server is not grouped again in the page.**\n With `rowModel` from `createServerRowModel` and a grouping in the grid's\n state (a view, `groupBy`), the grid bucketed the rows it had loaded under\n its own group rows. A model with `group` accessors now hands over its rows\n as they are; the grouping state stays for whatever shows it.\n\n- **A `rowModel` set after mount still sorts and filters on the server.**\n The grid read `externalSort` and `externalFilter` once, at mount. A model\n handed over later (one loaded on demand) was sorted and filtered again in\n the page, placeholders included: with a million rows behind it, a view\n filter held the page for seconds. The grid now follows the model's\n `setSort` and `setFilter` whenever it arrives.\n\n- **`SvRichText` lists had no bullets or numbers in apps with a CSS reset.**\n Tailwind's preflight sets `list-style: none` on every list, so a bulleted\n list in the editor read as plain lines. The editor now sets `disc` and\n `decimal` itself.\n\n- **A custom column header did not sort when its label was clicked, and did\n not see the sort change.** The header wrapper is itself `role=\"button\"`, so\n the check meant to skip clicks on buttons inside a custom header matched the\n wrapper and skipped every click on the header's own text; only a click on\n empty header background sorted. The `header:` callback also ran once, so\n `ctx.column.getIsSorted()` kept its first value. Both are fixed: a click on\n the label sorts, a button inside the header still gets its own click, and\n the callback runs again when the column's sort changes.\n- **Grouping five million rows ran out of memory.** Every group row carried\n ten closures and a Map of its ancestors' values, and a million rows grouped\n five deep make about a million group rows. Group rows now share their\n methods and keep their state in one object. Grouping 1,000,000 rows that\n way adds about 500 MB instead of 785 MB, and 5,000,000 rows group in 56 s\n on a laptop within Chrome's default heap.\n- **Every selection change serialized the whole selection.** Deciding\n whether to call `onRowSelectionChange` ran `JSON.stringify` over the\n selection state; selecting half of a 5,000,000-row grid built a string of\n tens of megabytes per change. The two states are now compared key by key.\n- **A mount built rows nobody could see, and laid the grid out five\n times.** The first paint now draws the rows on screen and at most two\n overscan rows, and the rest of `overscan` follows a frame after that paint:\n a 520 px grid built 26 rows to show 14. Reading the scroll position of the\n container the grid had just created, and each scrollbar measuring its\n track on connect and on every attribute change, forced four layouts of the\n half-built grid before it painted. The position is now confirmed on the\n next frame and the track is measured by the scrollbar's resize observer;\n the one forced layout left is the container size the windows need.\n- **The scrollbar thumb trailed the rows by a frame.** The custom scrollbar\n read the scroll position on the frame after the scroll flush, so the thumb\n moved one frame late and each scroll step paid a second style pass and\n paint for it. The flush now hands the scrollbar the position it already\n has, and the scrollbar keeps its measured track instead of measuring it\n inside the flush.\n- **A vertical scroll frame repainted every rendered row.** Body rows were\n not positioned, so on any frame that moved or rewrote a row Chrome painted\n every rendered row again cell by cell. Flex-layout body rows are now\n `position: relative` (no z-index, no clip), which lets the browser reuse an\n unchanged row's paint whole. In six interleaved rounds of the 100,000-row\n browser bench, a 60 px scroll step went from 4.05 to 3.68 ms of\n main-thread work (median). Sticky frozen and group rows keep\n `position: sticky`.\n- **Expanding one group re-grouped every row.** A toggle re-ran the row\n pipeline, and the grouping stage bucketed all rows again although only the\n expansion had changed. It now keeps its groups while its input rows,\n grouping and columns are the same. On a 100,000-row grid grouped by five\n columns, one expand went from 521 to 98 ms, and expanding or collapsing\n every group from 473 to 82 ms.\n- **A calendar date with `timeZone: 'UTC'` showed the day before.** A\n bare date string such as `'2026-10-07'` is read as local midnight, so a\n date `format` whose `options` carried `timeZone: 'UTC'` (the usual fix\n from when such strings were read as UTC) showed October 6th anywhere east\n of UTC. A calendar date has no zone: `timeZone` is now ignored for one,\n on screen and in exports.\n- **A cell note's corner marker sat at the grid's corner.** The marker is\n positioned against its cell, but a cell with a note was not positioned, so\n it anchored to the grid. A cell with a note is now a positioning context,\n like the active cell.\n- **A sort or filter kept every column's value on every row.** Reading one\n column built and cached an array of all of a row's values, so sorting a\n 1,000,000-row grid by one column left 1,000,000 of them behind. A plain\n `field` column is now read from the data; a computed (`fieldFn`) column\n still builds the array. The heap a sorted and filtered 1,000,000 x 9 grid\n adds went from 196 MB to 128 MB in the browser harness.\n- **`applyTransaction({ remove })` scanned the data once per row object.**\n Removing 10,000 row objects from 1,000,000 rows took about 1.8 s to find\n them; past eight objects the transaction now builds one identity map.\n- **Group footer and grand-total rows drew checkboxes.** With\n `showRowSelection`, each totals row had a row-selection checkbox, and\n ticking it selected the synthetic row. A checkbox column with no `aggregate`\n showed a checkbox too, holding a leaf's value carried over from the group\n row. Totals rows keep the selection cell for alignment but leave it empty,\n and a boolean column without an aggregate renders nothing there.\n- **Toggling a checkbox cell did not fire `onCellValueChange`.** A click or\n Space on a checkbox cell wrote the row and stopped, so an app that saves\n edits from `onCellValueChange` lost every checkbox change, and Ctrl+Z could\n not take one back. The toggle now takes the inline editor's commit path:\n one undo step, then `onCellValueChange` with the old and new value and the\n row's position in `data`.\n\n- **Arrow keys lagged whenever the active cell had to scroll.** On the\n 10,000 x 53 large-dataset demo one ArrowDown at the bottom of the viewport\n cost about 37 ms of main-thread work and painted over two frames; it is now\n about 8 ms and paints once. Five things added up. Every rendered row was\n measured with `getBoundingClientRect` on each scroll tick, on a grid that\n had no `autoRowHeight` to use the number for, which forced a table layout\n per row (about 30 per key press). The scroll geometry the custom scrollbar\n reads was pulled inside a derived at the start of the flush, forcing a\n second full table layout that the row writes then invalidated. The\n virtualizer keyed rows by their position in the window, so a one-row\n scroll rewrote all ~30 rows x every rendered column; rows are now keyed\n `index mod windowLength`, so the rows that stay keep their `<tr>` untouched\n and the one that entered is moved with a single `insertBefore`. The row\n window only updated after the browser's `scroll` event and a\n `requestAnimationFrame`, a frame after the key press; keyboard navigation\n now syncs the virtualizer inline, since it knows where it scrolled. And\n each cell carried three selection-dependent deriveds plus the fill handle's\n `{#if}`, re-marked on every move; they are one `{@const}` now, `null` for\n a plain cell. Also closed on the way: `key in editedCellValues` on a deep\n `$state` proxy created a signal per rendered cell that never went away, and\n the header checkbox's tri-state walked every row on each arrow key.\n\n- **A heat map drew a series legend in colours its cells never use.** The\n ramp on the right is its key; the row of palette chips under it (and a\n calendar's) is gone.\n\n- **A time axis put its ticks on nothing in particular.** `xType: 'time'`\n stepped a fixed 30 or 365 days from the Unix epoch, so a tick labelled\n \"2025\" stood weeks from New Year, a \"Jun 25\" tick sat mid-June, and a\n thirty-month axis carried two labels on a plot with room for eight. Ticks\n now land on calendar boundaries in UTC (days, Mondays, the first of a\n month, quarter or year, or every few years) at about one label per 90px,\n and each label is sized to the gap between ticks rather than the axis span,\n so a quarterly axis no longer reads \"2024, 2024, 2024, 2025\". The labels\n are read in UTC too: a local-time read of a 'YYYY-MM-DD' category in the\n Americas labelled every tick with the day before.\n- **The tooltip echoed the ISO date.** On a time or ordinal-time axis the\n tooltip title, the crosshair pill and the live region wrote \"2025-06-01\";\n they write \"Jun 2025\" when every category is the first of a month, \"2025\"\n when every one is New Year, and \"Jun 1, 2025\" otherwise, through\n `xAxis.formatter` when one is set. A calendar cell names its day the same\n way. The category in `onHover`, `onSelect` and `selected` is unchanged.\n- **The screen-reader table and the CSV read \"NaN\".** A NaN gap (the way a\n forecast series marks the months before it starts) wrote the word \"NaN\"\n into the hidden data table and the CSV export, and a `null` fell back to\n 0, which told a screen reader the outage month had no sign-ups. Both are\n empty cells now.\n- **\"Double-click again to clear\" left a legend chip isolated and hidden.**\n A double-click arrives as click, click, dblclick: with a chip isolated the\n first click cleared the isolation, the second hid the chip and the dblclick\n isolated it again. A click that clears an isolation is remembered for a\n moment, and the double-click that follows it on the same chip clears; on\n another chip it moves the isolation there.\n- **A radar ignored `yAxis.min` / `max`.** The rim was always the data\n maximum, so scores out of 100 filled the dial to whatever the best score\n was and two radars could not be compared. The rim honours a pinned axis,\n a value past it sits on it, and a pinned minimum is the centre.\n- **A pie sized its gutters by the widest label on either side.** Small\n slices with long names on the left kept the same room on the right for a\n \"Chrome 62%\", and the pie drew at half the radius the pane had. The\n gutters are per side, the pie sits centred in what they leave, the floor\n radius is a quarter of the short side, and each side truncates to its own\n room.\n- **A waterfall tooltip read \"$0\" on a total.** A total bar holds 0 in the\n data and its running sum in the geometry; the tooltip and the\n screen-reader table now read the drawn value. Its x labels also tilt by\n the same fit rule as a bar chart's, with the angle the renderer needs:\n they were flagged as rotated with no angle and drew truncated instead.\n- **Histogram edges read \"1.3k, 1.3k\".** Bin edges are written at the\n precision their width needs (whole numbers with separators for a 44ms\n bin, two decimals for a 0.2 bin) rather than in the compact tick form that\n gave two neighbouring edges one label.\n- **A heat map ignored `dataLabels` in the spec.** The cell label read the\n component prop alone, so `dataLabels: { show: true }` in the spec drew\n nothing. Colour legends on heat maps and calendars also round their steps\n to the precision the range earns (\"20, 94, 167\", not \"20, 93.5, 167\").\n- **The range area read as three lines.** Its band filled at the wash an\n area under a line gets, with both edges at full stroke. The band is the\n mark: it fills at 0.35 and its edges are thin.\n- **Annotate mode pinned a tooltip instead of a note** when `tooltipSticky`\n was on too; the annotate click now owns the click.\n- **Drawings on a time axis warned on every point.** The drawing tools write\n a timestamp for every pointer position, and the spec validator matched\n those against the category list. It skips the check on a time or number\n axis, as it already did for reference lines and annotations.\n- **The panel's export menu and saved-charts dialog ignored Escape.** Both\n close on Escape and hand focus back to the button that opened them.\n- **A gauge wrote \"99.2 %\".** A symbol unit (%, degrees) hugs the number; a\n word unit (\"ms\") keeps its space.\n- **The right axis title was clipped.** Its glyphs point outward under the\n rotation and ran past the edge of the SVG.\n- **Pie callout labels ran off the chart in a narrow pane.** The pie kept a\n fixed 34px margin for its outside labels whatever their length, so a\n \"Samsung Internet 3%\" in a 380px pane was clipped to \"%\" and \"Cl\". The\n radius now makes room for the widest label on each side, keeps at least a\n fifth of the short side, and hands the renderer a per-side character\n budget to truncate to when even that is not enough.\n- **The brush strip inherited the chart's titles, axis labels and marks.**\n A title and subtitle took 45 of the strip's 88 pixels and the x labels\n another 30, leaving the mini-map a five-pixel smear under an empty band.\n The brush spec now mutes titles, axis titles and labels, reference lines\n and bands, annotations, drawings, series labels and data labels.\n- **A category chart tilted its x labels by count, not by fit.** More than\n eight categories, or any label over nine characters, tilted every label\n to -40 degrees even on a thousand-pixel chart with room to spare. `auto`\n now tilts only when the widest label does not fit its slot.\n- **A heat map wrote every column label whatever the cell width**, so\n twenty-four hours at 33px a cell read \"00:0001:0002:00\". The column\n labels thin out the way a bar chart's do.\n- **A calendar labelled the padding days of the next year.** The grid pads\n the range to a full week, and a December ending on a Thursday picked up a\n \"Jan\" tick for the two padding days. Month labels stay inside the range.\n- **A waterfall could not open on a value.** A total bar always read the\n running sum, so \"Revenue 4300\" marked as a total drew as zero and every\n bar after it hung below the axis. A total with a value now sets the sum;\n a total with 0 still reads it.\n- **`rowsToChartSpec` with `topN` duplicated a category called \"Other\".**\n A real \"Other\" in the data came out beside the folded one, two categories\n with one name, which the renderer threw on as a duplicate key. The tail\n now folds into that category.\n- **A pin annotation showed \"O…\" and nothing else.** The head held\n `truncate(label, 2)`, an initial plus an ellipsis, and no label was written\n beside it. The head carries the initial and the label sits beside the pin\n like a dot's does.\n- **A chart's hidden data table took up to 17,000px of scrollable space.**\n The screen-reader table (one row per category, capped at 1,000) carried the\n visually-hidden recipe itself, but on a `<table>` `height: 1px` and\n `width: 1px` are minimums and `overflow: hidden` does not clip, so the\n table was invisible and as tall as its rows, and every scroll container\n around a chart (the demo pages first of all) scrolled on through that much\n empty space. The clip now sits on a wrapping div; the table keeps its id,\n which the svg still points at.\n- **Two ARIA faults the axe audit found.** The chart's SVG was\n `role=\"img\"`, whose children are presentational to assistive technology,\n so the focusable marks inside it (category zones, slices, a drawing) were\n a nested-interactive violation and could be skipped by a screen reader; an\n interactive chart is a labelled `group` now (a thumbnail with\n `interactive={false}` stays an image). Sankey links carried an\n `aria-label` with no role, which ARIA prohibits; they are named images in\n the focus order.\n- **A tree map ignored `spec.tree`.** The field is documented as an alias of\n `treemap` and the sunburst honoured it; the tree map read only `treemap`.\n- **An autosized chart with a side legend grew without end in a plain block.**\n `legend=\"left\"` / `\"right\"` lays the chart out as a three-row grid, and a\n grid puts a gap between every track whether or not the toolbar and brush\n rows have anything in them. The autosize maths counted a gap only for the\n chrome that existed, so in a parent that does not pin the height, the host\n measured 8 or 16px taller than the plot it was told to fit, the plot grew\n into it, and the next measurement grew again - a few hundred pixels a\n second until the page ran out. Hiding the legend at runtime had the\n opposite fault: a dimension binding keeps its last value once its element\n is gone, so the vanished legend went on being subtracted and the plot\n ratcheted down to its 120px floor. Both fixed; a fixed-height parent hid\n them, which is why the docs' sizing example never showed either.\n- **`block` did nothing on eight editors.** The prop is declared once in\n `SvEditorProps`, and its own doc comment describes the symptom: \"in a form\n grid a row of inputs each stopping at a different width reads as broken\".\n `SvDropDownList`, `SvComboBox`, `SvMultiSelect`, `SvTreeSelect`,\n `SvGridSelect`, `SvAutoComplete`, `SvTextArea` and `SvDateRangeInput`\n accepted it by type and ignored it, so they stopped at their own 200-280px\n default while the text inputs beside them filled the row. `<SvForm>` was\n also not passing it to seven of the controls it mounts - both halves had to be\n fixed for a form row to line up.\n- **`cellDataType: 'dateString'` stored a timestamp after an edit.**\n Committing ran through the shared date coercion (`new Date(v).toISOString()`),\n so picking Christmas stored `2026-12-25T01:00:00.000Z` and the cell showed a\n timestamp beside neighbours showing plain dates - on a calendar day that\n depended on the user's timezone, since the conversion went through UTC. The\n picked date is now kept as the picked date.\n- **The filter row mounted a native date input** while the cell editor mounted\n the grid's own picker, so one column looked like two different products\n depending on where you touched it. Both use the grid's picker now.\n- **`editorType: 'number'` dropped the character you were typing.** The\n editor mounted `<input type=\"number\">`, whose value sanitization reports\n `\"\"` for anything not already a valid float - so `12.` read as empty, and\n typing `12.5` produced `125`. Same for a lone `-` and `1e`. It is a\n text input with `inputmode=\"decimal\"` and a digit filter now; the trade is\n the native spinner.\n- **Cell context menus and the comment editor floated at stale coordinates\n after a scroll.** Both are positioned at raw cursor coordinates and rendered\n `position: fixed`, but neither was in the scroll effect's gate, so they hung\n over unrelated cells. The comment editor SAVES on scroll rather than\n discarding - backdrop-click and Escape are the gestures that mean \"throw this\n away\"; a scroll is not, and must not destroy typed text.\n- **The footer summary row server-rendered as empty cells.** The totals were\n assigned from an `$effect`, and effects never run during SSR - so the server\n emitted a summary row that took up space and drew its border but held no\n numbers. They appeared only after hydration (a visible pop-in), and never at\n all for a reader with JavaScript off. A grid under the aggregation cell\n limit now derives its totals synchronously, so they ship with the HTML; a\n very large grid keeps the rAF-deferred effect so it still paints before it\n totals. `pnpm ssr:check` asserts the real aggregate now.\n- **The grid painted one unmeasured frame on every mount.** `hasMeasured`\n gates the custom scrollbars, the 16px scrollbar gutter on a trailing\n right-aligned column and the top pager (which carries a `border-top`), but\n it only flipped inside the `ResizeObserver` callback - and that callback is\n deliberately deferred by one `requestAnimationFrame`, so the browser was\n guaranteed to paint a frame with those missing and correct it on the next.\n On a first load that was the \"flashing scrollbar\"; in an app that recreates\n the grid per navigation (a `{#key}` around it, or a route that remounts) it\n showed up as the grid flashing on every sort / filter / page change, with a\n stray border line. The container is now measured synchronously in the mount\n effect - before the first paint - and the observer still handles later\n resizes. Covered by an e2e regression test, since jsdom has no layout to\n miss a paint with.\n- **Pager page-size trigger rendered as a stock button until first click.** The\n closed trigger is a placeholder until the lazy dropdown chunk loads, but its\n box styling only existed in that chunk's scoped CSS, so server-rendered and\n freshly-mounted pagers showed a UA-bordered, left-hugging `<button>` inside the\n bordered box. The placeholder now gets the same rules from `SvGrid.css`.\n- **Virtualized lists no longer flash blank on a fast scrollbar-thumb drag.**\n A fast drag can move the viewport into the windowed list's off-screen padding\n faster than JS can re-render the rows there; the padding now paints faint row\n skeletons, so `SvListBox` / `SvDropDownList` stay visually filled at any scroll\n speed. Also removed an app-wide `flushSync` from the scroll handler that could\n stall the very first scroll.\n- **Dock manager auto-hide now shows every tab of a multi-tab leaf.** Sending a\n leaf with two or more tabs to auto-hide created a single edge tab; it now\n creates one edge tab per pane.\n- **Ticking one row in a large grid took over a second.** Once any row was\n selected, every change walked all rows through the lazy row list to work out\n the header checkbox. At 1,000,000 rows (jsdom) one tick went from 1.3-1.8 s\n to 4-36 ms, and select-all from 4.2 s to 0.4 s.\n- **Tab never left the grid.** Every Tab was consumed and the cursor clamped\n at the last cell, so no key moved focus out (WCAG 2.1.2). Tab on the last\n cell and Shift+Tab on the first now leave the grid.\n- **No focus indicator when the grid is reached by Tab, or under forced\n colors.** The active-cell ring stayed hidden until a click, and Windows High\n Contrast removed it (it is a box-shadow). It now shows on keyboard focus, and\n forced colors get a `Highlight` outline.\n- **The cell editor had no accessible name.** The text, number and multi-line\n editors are now labelled with their column's header.\n\n#### Security\n\n- **CSV / formula injection in exports.** `exportCsv`, `exportTsv` and the\n chart's CSV download wrote text such as `=HYPERLINK(...)` as is, which a\n spreadsheet runs as a formula. Text starting with `=`, `+`, `-`, `@`, a tab\n or a carriage return is now written with a leading `'`; numbers and signed\n numbers in text form (`-12.50`) are unchanged. `escapeFormulas: false` turns\n it off; `copyToClipboard` takes `escapeFormulas: true` to turn it on.\n\n### @svgrid/enterprise\n\n#### Fixed\n\n- **Export on a page with no global `Smart`.** A bundler that inlines dynamic imports ran the\n vendored exporter at page load, before its namespace shim, and the whole bundle threw\n \"Smart is not defined\". The exporter now loads through an entry that installs the shim first.\n\n#### Added\n\n- **SvGrid Base: Delete forever can be one transaction.** `transaction` next to `execute` on\n `createSqlDataSource`, `createBaseEndpoint` and `baseFromDatabase`, and `linkedFrom` on\n `createKitHandlers`, make it one server step. See Undo, trash and import for each driver.\n\n- **SvGrid Base: Edit fields says what it sets off.** Past 10,000 records its question gives the\n number of automation runs the change can start, and \"Also run automations\" can be unticked.\n\n- **SvGrid Base: a comment not sent stays with its record.** Stepping to another record no longer\n carries it into that record's box, and closing the record keeps it and says so.\n\n- **SvGrid Base: `baseFromEndpoint` takes a live feed.** `realtime: (table, apply) => stop` is called per\n table and per junction table.\n\n- **Gantt: `pickUpToMove` and `text`.** Keyboard moves in the scheduler's way, and every\n word of the view for a page in another language. Base uses both.\n\n- **SvGrid Base: soft delete.** `softDelete: 'deleted_at'` on `createSqlDataSource` and\n `createSupabaseDataSource` marks a record instead of removing it. Reads, counts, groups,\n totals, lookups and rollups skip it, a restore clears the mark and rewrites nothing, and\n emptying the trash is the real delete. `createKitHandlers` takes `restore` and `purge`,\n inside the tenant's `scope`.\n- **SvGrid Base: a view always gets its answer.** When a data source cannot run a\n filter, sort, group or total on a computed field, or fails on one, the page reads\n the table a block at a time, works the field out with the cells' code and serves\n the view by id, with the count in the tab bar. A record that changes is updated\n where it stands, and taking the sort or filter away stops the read. `computes` on\n `baseSource` says what the source can work out itself; a `queryRecords` backend\n needs `computes: () => true` to keep those requests in the database.\n- **SvGrid Base: \"+\" opens a draft.** On a big table a new record is stored at its\n first value and not at the click, so one closed empty leaves nothing behind. It\n starts with the values of the view's filter, what the database fills in comes back\n into it, and one the database refuses keeps its values and tries again. \"+\" is in\n every view of records, and Ctrl+Z takes a stored record out again.\n- **SvGrid Base: add a field from the header.** `columnAdder` is on by default for\n whoever may change the schema, and the \"+\" stays at the right edge of a wide\n table. `createSqlDataSource` with `schemaChanges` adds the column on Postgres,\n MySQL and SQLite, `addField` on `baseSource` does it on your own source, and a\n source that cannot shows the `ALTER TABLE` to run. A new field never takes over a\n column already in the table.\n- **SvGrid Base: Undo keeps what it cannot write.** A record goes back with every column\n read, and a column the database generates is left to the database, on any engine.\n- **SvGrid Base, in use.** A record's position is the view's own (\"1 of 1,000,000\"),\n and Next and Previous read past what is loaded. A click or Enter opens a Board card.\n Ctrl K works from anywhere on the page. A group of mixed ticks shows as mixed, group\n headers show what the cell shows, and a field deleted from a view's filter leaves it\n (undo brings the condition back). A record outside the view's filter says so.\n- **SvGrid Base: select all means all.** On a big table the header checkbox selects\n every record of the view as a rule, and the count says so. The selection bar's\n Delete reads what the rule covers, asks with the exact number, and deletes in\n blocks with a Stop button. Up to 10,000 can be undone, in one write.\n- **Block writes.** `ServerDataSource` gains optional `createRows` and `deleteRows`;\n `createSqlDataSource` and `createSupabaseDataSource` implement both.\n- **`filterModel.searchIn`.** The fields a global search may look in. A base sets it\n so that a field hidden by a share or a permission cannot be probed by searching.\n- **Server row model:** `pin` and `unpin` show a row above the list that no block\n holds, outside the count, and `leafTotal` gives a grouped view its true size.\n- **Computed SQL:** dates, `MAX` and `MIN` on MySQL and SQLite, `FIND` on MySQL, and\n `ROUND` and `INT` on SQLite.\n- **SvGrid Base: a table has no size limit.** A table used to stop at `limit`\n records, 10,000 by default, and a table on `serverRows` kept that many in the\n page for everything but its grid views. Now no read stops short. A table that\n outgrows the page (`holdInPage`, the new name of `limit`) is read from the\n database a part at a time, by itself, and the page holds none of its records.\n Links, lookups and rollups read records by id, and a rollup over a link stored\n on the big table is added up by the server: in demo 723, a table of 200\n customers shows each one's orders and revenue over a million. The link picker,\n search across tables and the grid's search box search the whole table.\n Automations run on any record, and a scheduled one on every match. Share\n links show the whole table. A new record's autonumber is the table's next.\n New in the data source contract: `groupRawKeys`, for a link grouped by id.\n\n- **SvGrid Base: `createSqlDataSource` runs a view's filter.** It used to leave\n `filterModel.expression` out, so a filtered view on a SQL table showed every\n record. It also filters, sorts, groups and adds up on formulas, lookups and\n rollups now: `computedSql` (`@svgrid/enterprise/base/compute`) turns them into\n SQL, or says it cannot rather than answer differently from the cell.\n\n- **SvGrid Base: formulas in SQL say what a cell says.** More functions translate\n (`SWITCH`, text slices, `MOD`, `POWER`, `SQRT`, days and weeks on dates), and\n each is checked against a cell on real Postgres, MySQL and SQLite over blanks,\n negatives and quotes. `generatedColumnSql` writes a formula as a generated\n column for Supabase, and `generated` makes a filter read it.\n\n- **SvGrid Base: `schemaChanges` on `createSqlDataSource`.** On Postgres a field's\n type change is one `ALTER` and a table's copy one `CREATE`. Off by default.\n Without it, a big table's values are rewritten sixteen writes at a time.\n\n- **SvGrid Base: Supabase with aggregates off.** How a project starts. Kanban\n lanes and link counts now read their size with plain counts, and a total that\n needs aggregates says how to turn them on (`AggregatesOffError`).\n\n- **SvGrid Base: a link edits from either side of a big table.** A customer's\n orders tick in the picker, and each tick writes that order. Names pasted into\n a link cell are found on the server.\n\n- **SvGrid Base: changing a field's type on a big table converts its values.**\n It asks first, then uses `convertField` or rewrites them a block at a time.\n\n- **SvGrid Base: Download as SQL writes every record of a big table,** a block\n at a time. Duplicate table copies records that fit in the page, or in the\n database with the `duplicate` option.\n\n- **SvGrid Base: a Kanban lane keeps its order.** Sorted by a number field, a\n card dropped elsewhere in its lane writes that number.\n\n- **SvGrid Base: every view reads a whole table of millions.** Views other than\n grids used to show the first records of a big table.\n Now a Kanban lane shows its true size and reads its cards as they scroll by;\n a calendar reads the dates on screen, with each busy day's size and a \"+N\n more\" that lists all of that day; a Gantt reads its rows by start date; a\n gallery, list and inbox draw and read what is in sight; a chart and a\n dashboard have the server add up. It is the same `getRows` request a grid view\n sends, so a source that answers a grid view answers these. `queryRecords` now\n answers `aggregations` and `needsGrandTotal`. In demo 723 (a dev build, one\n laptop), each view of the million opens in under a second.\n\n- **SvGrid Base: a Rich text field type (`fieldType: 'richText'`).** It edits\n in a panel over the cell with a formatting toolbar: bold, italic, underline,\n strikethrough, bullet and numbered lists, links and clear formatting.\n `fieldProps: { toolbar: 'full' }` adds headings, quotes, code blocks, undo\n and redo. Ctrl+B / I / U format the selection and Ctrl+K adds a link;\n Ctrl+Enter, Tab or a click outside saves and Escape cancels. The value is\n HTML, sanitized when it is stored and again before it is drawn. A grid row\n shows the formatting on one line, a taller row height as lines, and the\n expanded record and the form show all of it. Search, the filter, sorting,\n copy, lookups and formulas read the words without the markup. Converting\n from long text renders its Markdown; converting back keeps a line per\n paragraph and list item. Demo 722 (release notes) shows both toolbars, a\n filter view and a formula over a note; demo 511 (content calendar) uses it\n for the brief. The long text option that renders Markdown is now labelled \"Format\n with Markdown\", to tell the two apart.\n\n- **SvGrid Base in your language.** Every word a base shows (the tab bar,\n the view bar and its panels, the record view, forms, the field editor and\n the field types, menus, notices, color and icon names) comes from one table\n of about 1,100 messages. `setBaseMessages(words)`, `<SvBase messages>` or\n `<sv-base>`'s `messages` property hand over the words you have; the rest\n stay English. Counts take `.one` / `.other` forms, and a `plural` rule\n for languages with more. `BASE_MESSAGES` lists every key with its English.\n A trash item for a table with one record now reads \"1 record\", not\n \"1 records\".\n\n- **SvGrid Base: Vote and Sparkline field types.** A vote field keeps who\n voted (user ids): a click on the cell, Enter or Space adds the signed-in\n person's vote or takes it back, through the grid's edit path, so undo and\n protected fields hold. It sorts by the count and filters as people (\"has any\n of me\"). A sparkline field draws a list of numbers as a line, area or column\n chart, typed and pasted as `3, 7, 4, 9`, sorted by the last value.\n\n- **SvGrid Base: a trash kept in your backend.** `<SvBase trashStore={{ list, add,\n remove }}>` reads the trash when the base opens and tells the store of every\n item deleted, restored, undone or emptied, so it survives a reload and is\n the same for everyone.\n\n- **SvGrid Base on a phone: boards and calendars.** A Kanban lane takes the\n table's width and snaps into place as you swipe; a calendar opens in its\n agenda. Gallery cards and forms were one column already.\n\n- **SvGrid Base: tables of millions of records.** `baseSource(ds, { serverRows: true })`\n has a table's grid views read it a block at a time through the server row\n model, with the view's filter (`filterModel.expression`), sort, groups and\n search sent to the server, and its edits, new records and deletes written by\n id. Kanban, calendar, gallery and the other views show the first `limit`\n records, and say so. Grouped views get one row per key with its count from\n the server, and the view bar counts the server's records. `queryRecords`\n answers such a request over records a Node server holds,\n `fieldFilterToSql` turns a view's filter into a `WHERE` clause for\n Postgres, MySQL or SQLite, and `fieldFilterToPostgrest` /\n `supabaseFieldFilter` into a PostgREST filter: `createSupabaseDataSource`\n has a new `expression` hook, and `baseFromSupabase` a `serverRows`\n option. A link edited there changes the field that links back for that\n record only (`linkChanged`), not for the records the page never loaded.\n Demo 723 pages through 1,000,000 orders.\n\n- **SvGrid Base: formulas on a server (`@svgrid/enterprise/base/compute`).**\n `computeRecords(tables, tableId)` works out every formula, lookup, rollup\n and count with the grid's own engine, and `evaluateFilter` /\n `filterRecords` test records against a view's filter, with no DOM and no\n Svelte, so an API, an AI tool or a report sees the values people see. A\n test works out a base both ways and compares them record by record.\n\n- **SvGrid Base: permissions.** `<SvBase permissions>` (and a table's own\n `permissions`) take `canEdit`, `canCreate`, `canDelete`,\n `canEditSchema`, `canEditViews`, `canComment`, `fields` (`'hidden'` or\n `'readOnly'` per field) and `viewsOnly`. The screen offers only what the\n person may do: no \"+\" row or Insert record without `canCreate`, no field\n editor or table menu without `canEditSchema`, view changes kept in the page\n without `canEditViews`. A hidden field takes the formulas, lookups and\n rollups that read it along, and the stored records and columns are never\n changed by what a person is not shown. `<sv-base>` takes the same as its\n `permissions` attribute.\n\n- **SvGrid Base: realtime changes update only what changed.** The\n `realtime` callback's `apply(changes)` takes inserts, updates (the whole\n record or just the changed columns) and deletes, or Supabase Realtime events\n as they come, and updates those records in place, a burst at once, with the\n same highlight and credit as before. `baseFromSupabase` uses it. `apply()`\n with nothing still reads the table again.\n\n- **SvGrid Base: a record history that lasts.** `setRecordHistory({ list, add })`\n reads a record's history from your audit log each time it is opened (a\n promise is fine) and hands it each change made in the page.\n\n- **Change review in the record view.** An expanded record lists its pending\n proposals under their fields, with Accept and Reject per field and for the\n record. `review.acceptRecord`, `rejectRecord`, `pendingIn`, `sources`,\n `pendingFrom` and `revertSource` (everything one agent did, across its\n sets) are new, and the panel has a From picker when more than one source\n has proposals.\n\n- **SvGrid Base: undo for tables, form footers and link allowlists.** Adding,\n renaming, duplicating, deleting and importing a table are undo steps.\n `formPrefill` takes a list of the fields a link may fill\n (`prefillFields` on `SvBaseForm`), and a form view takes `formFooter`\n text or `<SvBase formFooter>` as a snippet. `<SvBase onMention>` hears\n mentions. `<sv-base>` fires `cellchange`, `recordadd`, `recordsdelete`,\n `trashchange` and `mention`, and takes a `read-only` attribute.\n\n- **A grouped grid prints its groups.** `print()` printed a grouped grid's\n leaf rows only. It now prints a header row above each group, \"Region: EU\n (12)\", indented by level; `groupRows: false` leaves them out.\n\n- **`print({ open: false })` returns the printable document.** `print()` and\n `printGrid()` now resolve to the HTML they built, and `open: false` skips\n the print window and dialog, for a preview pane or anything that times the\n printable view. It is a plain table, not the grid.\n\n- **PDF: `pdf.fit`, `pdf.repeatColumns` and `pdf.font`.** `fit` chooses what\n happens when the columns do not fit across the page (shrink the text, split\n the columns over pages, or both, the default); `repeatColumns` says how many\n leading columns repeat on each page of a split. `font` prints with a font\n you supply, base64 or a URL, for scripts Roboto lacks (Chinese, Japanese,\n Korean, Arabic, Hebrew, Thai, Indic, emoji); without one the export now\n warns when it sees them.\n- **PDF export in a worker: `pdf.worker` and `@svgrid/enterprise/pdf-worker`.**\n pdfmake renders in one synchronous run, about a second per thousand rows on\n a desktop machine, and on the page that froze the tab. With\n `pdf.worker: () => new Worker(...)` and a worker script that calls\n `servePdfWorker()`, the document goes to the worker as data and the page\n stays responsive: a 5,000-row export took about two seconds while the page\n kept drawing at 60 fps, with progress through `onProgress` and an abort that\n terminates the worker. A PDF of more than 2,000 rows rendered on the page now\n logs a warning that points here. `buildPdfDocData` and `hydratePdfDoc` split\n the document builder for this; `buildPdfDocDefinition` works as before.\n- **Grouped PDFs total like the grid.** Subtotals use each column's\n `aggregate` (avg, min, max, count, countDistinct, a function) instead of\n always summing, a total row closes the table (`pdf.grandTotal: false` to\n leave it out), and group names are formatted as on screen. `getColumns()` in\n `@svgrid/grid` now reports each column's `aggregate` for this.\n- **PDF: `pdf.labels`, `pdf.watermark`, `pdf.author`.** Replace the footer's\n page and date text and the subtotal and total labels; print a faint\n watermark across every page; and fill the document properties, so a viewer\n shows the report's title rather than the file name.\n- **PDF column widths follow the text.** Each column gets at least its\n longest word and the rest of the page goes to the columns with the most to\n say, instead of equal widths: a 60-row, 8-column order list went from three\n pages to two.\n- **The pivot designer's Chart view grew up.** It offers every shape a pivot\n can take (bar, line, area, lollipop, pareto, the three radial forms, pie,\n funnel, waterfall, radar, heat map, stream) in the panel's groups, with\n Stacked, 100% and Horizontal where the type uses them, the chart's own\n toolbar (PNG, SVG, PDF, print, copy), its spoken summary and a legend\n under the plot. It had six types and a Stacked box.\n\n- **`pivotToChartSpec` carries the measure's format and name.** Pass the\n value chip's `format` and the chart reads \"$470k\" on the axis and\n \"$469,662\" in the tooltip, in the measure's currency and locale; percentage\n points get a formatter that appends the sign. With one measure the value\n axis is named after it (`yAxisTitle` overrides, `null` for none). The\n designer's Chart view passes the format when its measures agree, and\n formats plainly when a layout mixes a currency and a count.\n\n- **PDF export with charts and a KPI strip.** `pdf.charts` prints charts with\n the table: a rendered chart's element is rasterised on export through the\n grid chart's PNG path, or pass an image data URL; each takes a title, a\n caption and a width, and goes above the table or below it\n (`chartsPosition`). `pdf.kpis` prints a strip of headline numbers, each a\n label over a big value with an optional coloured delta line. Roadmap\n discussion 36.\n- **The selection bar renderer, plus bulk edit.** `enableSelectionBar()`\n (or `installEnterprise`) registers the renderer behind the free\n `selectionBar` prop. The bar carries a count chip, your actions, an overflow\n menu past `maxVisible`, and Clear; at phone width it collapses to icons and\n keeps an accessible name on each. **Edit fields** opens a drawer that edits\n one or many rows at once: a field the selection disagrees on opens blank and\n stays per-row unless you touch it, so applying to 40 rows does not flatten the\n values you did not mean to change.\n- **Scheduler booking rules and conflict detection.** New model helpers\n (`overlapCount` for per-resource overlaps, `overlapsBands` for working-hours\n bands) back resource double-booking checks and business-hours enforcement.\n New demos: booking rules, financial trading hours, and HR shift coverage.\n\n#### Fixed\n\n- **SvGrid Base: one Undo or Redo at a time.** Redo pressed while a range Undo on a paged table was\n still writing read the records before the Undo's later blocks landed: the data ended undone or half\n pasted while the page said \"Redone: edit 6,000 records\". Now a second Undo or Redo while one runs is\n refused with \"Undo is still running.\" and the buttons show it busy. An Undo or Redo of more than one\n block runs in the paste's dialog with its count and Stop, leaving the page asks first, and what it did\n is said when it ends, with the records or cells it changed (not those a teammate kept, a deleted\n record or a refused write). A small paste's count is said once its writes have answered.\n The dialog covers every Undo and Redo of more than a block: a delete (its Undo says the records\n it put back, not those a teammate restored first), the records a paste added, and more than\n 1,000 cells of a table the page holds. A cell undo of a record the view no longer shows holds its\n turn until that record's write has answered.\n- **SvGrid Base: Undo of a new record before its insert answers.** The step was a cell edit until the\n database answered, so Undo wrote an empty name and the record stayed. The \"add record\" step now\n exists from the moment the row does, what is typed into the record folds into it, and Undo waits for\n the insert, then takes the record out. A refused new record's Activity no longer shows what was typed.\n- **SvGrid Base: Try again from a record that fell to the end.** It wrote the first line into that\n record and offered to add the rest as new records. Now it writes nothing and says how many rows stand\n below the record against how many the first try covered; the dialog of a Try again names the rows it\n writes, which it covers on screen.\n- **SvGrid Base: a range over 1,000 records on Supabase or PostgREST is written.** The ids check read the\n whole range in one request, and a server that answers 1,000 rows at most (`db-max-rows`, the Supabase\n default) gave fewer back: every paste, clear, fill, one value or copy of more than 1,000 records said\n \"Records moved\" and wrote nothing. A short answer now reads on, a page of the server's own size at a\n time, and only a different id sequence counts as moved; a source with no cap still answers each check in\n one request. These checks select the key alone on Supabase and PostgREST. A download, a duplicated table\n and a view's group reads from a source that sends no count also read on past a short answer.\n- **SvGrid Base: a Cut the browser refused says so.** It did nothing in silence; now \"The browser would\n not put the cells on the clipboard, so nothing was cut.\"\n- **SvGrid Base: a notice that stays no longer covers \"+ Add record\" or a record's Delete and Close.**\n Notices in the bottom-right corner start above the button, or an open record's footer, where they\n meet.\n- **SvGrid Base: a table named by its key keeps its records.** A table with no text column shows\n its key as its first field. A record added there was deleted and created again under a new key at\n the next change of any record, a tab switch or a sort, on Postgres, MySQL and SQL Server: a foreign\n key with `ON DELETE CASCADE` took its children with it, \"record created\" automations ran each time\n and a table that marks deletes filled its trash. Edit field on the key could change its type, which\n wrote every record again under a new key, and offered \"Who can edit its values\". With a feed, a new\n record's key stayed blank and the page counted its own insert as a teammate's change. The key field\n now holds the key the database gave the record, in the key's own type, from a read, a write's answer\n or a feed; no edit, paste, fill, undo or field change writes it. Edit field on it changes its name\n and description only, and Duplicate field makes an ordinary field. A key column named `id` is the\n field `id_key` in the table's description, which `rename` maps back to `id`.\n- **SvGrid Base: a table with `customer` and `customer_id` opens.** The link from `customer_id`\n took the name `customer`, so two fields shared one id: the tab threw, showed the previous\n table's records, and the link and its field back were lost. Two keys that read as one name\n (`owner` and `owner_id`) did the same. Now a link whose name is taken keeps its column's name as\n its id and is headed \"Customer (link)\", or by its column when both are links (\"Owner id\"); both\n fields show, and each link keeps its field back.\n- **SvGrid Base: a client's filter on the tenant column is combined with the scope.** The scope\n replaced it, so `tenant_id = 2` asked by tenant 1 answered all of tenant 1's rows, and an\n `updateWhere` with that filter changed them. The two are combined now: another tenant's value\n finds no rows and changes none.\n- **SvGrid Base: a refused write names the record as stored.** A refused edit of the name field\n named the record by the value that was refused (\"Could not save Label of boom\"). A refusal by a\n foreign key of three columns named no field when the edit was to one of them: it names the key's\n fields now. The top bar's \"Not saved\" names them too.\n- **SvGrid Base: the status line opened in full shows no transport text.** It showed\n `svgrid kit: 409 Conflict - {json}` after the reason. It shows the reason, and the server's own\n words when it sent some that the reason does not say. A line with nothing more still opens, to read a\n reason the bar cuts short. Notices that quoted an error (a delete, a copy, a bulk edit, the\n trash) say the reason in words in place of the endpoint's or the REST API's status and body.\n- **SvGrid Base: a new record of a table whose database makes the key is read by no one before it\n has its key.** On a paged table, a draft (or a record whose insert was on its way) was asked for\n by its page id, and so were the records linking to it: Postgres refused the read on an integer\n key (\"invalid input syntax for type integer\"), and that text showed as a notice. Such a record is\n left out of those reads until the database has given it its key. A read that fails says so in\n words; the driver's text goes to the browser console.\n- **SvGrid Base: Duplicate field on a database table the base cannot add a column to copies\n nothing.** It copied the values into a column that was not there, so their writes could not land.\n It now says the copy needs a column and gives the statement that adds it.\n- **SvGrid Base on a REST API: the API's reason is shown, and a refusal of the values offers no Try\n again.** `createRestDataSource` passes `{ error }` or `{ message }` on as the reason, so a `422`\n says \"The server said: Amount must be 0 or more.\" where it said that no reason came. A server's\n words that do not end a sentence get a full stop, so \"You entered: -500\" after them reads apart. A `400`,\n `409` or `422` from any source offers no Try again, which would send the same values.\n- **SvGrid Base on Postgres: a foreign key to a table of another schema on the search path is a\n link.** `public.notes.task_id -> app.tasks` stayed plain text with both schemas on the path and\n both tables in the base. A key now links when its table is the one its bare name reaches. A key\n to a table that an earlier schema's table of that name hides stays plain, in its own schema too.\n- **SvGrid Base: a grouped paged view shows your own changes in its open groups.** Round 7 made a\n teammate's change read every open group again; every other refresh still read only the group\n rows. With no feed, a record you deleted stayed listed in its open group (and typing into it said\n it no longer exists), a record you restored from the trash or brought back with Undo did not show,\n and a new record, an edit that moved a record to another group, a renamed option, a converted field\n and the read after \"Records moved\" left the open groups as they were, while the counts changed.\n The server row model's `refresh()` with no route now reads the group rows and the loaded records of\n every open group on a grouped view, as `refresh({ all: true })` does, so every caller gets it.\n `refresh({ route: [] })` still reads the top level alone. On a grouped view or tree data an app's\n own `refresh()` now also reads the loaded blocks of each open group or node.\n- **SvGrid Base: a teammate's change to a sorted field takes its place in a paged view.** A feed that\n sends the row patched it where it stood, so a record whose sorted field changed stayed out of order\n until something else read the view. A change to a field the view sorts or groups by now reads the\n view again (every open group, when grouped); a change to any other field still patches the row and\n reads nothing. A view sorted or grouped by a formula or lookup reads again on any change, since a\n change to a field it reads moves it too.\n- **SvGrid Base: a face is never another person's while it loads.** User, created-by and\n last-modified-by cells reuse their faces by position on a scroll, and the browser kept drawing the\n last person's picture beside the new name until the new picture loaded. Another picture now gets\n a new `<img>`, empty until it loads, as attachment thumbnails do; the same picture keeps its\n element. The attachment preview's Next and Previous do the same.\n- **SvGrid Base: a checkbox cell is named by its field.** It read \"Checked\" or \"Not checked\" in\n English whatever `setBaseMessages` set, and a screen reader heard the state twice. Its name is the\n field's name (`fields.typeCheckbox` when the field has none), and `aria-checked` says the state.\n- **SvGrid Base: an image in rich text stays on the cell's line.** Under a reset that makes `img` a\n block (Tailwind's preflight), an image in a rich text cell took a line of its own: the text after it\n was cut off, or ran into the next row.\n- **Scheduler: a move keeps the event's length by the clock.** A drag, a keyboard carry, a timeline\n drag, the other selected events of a move, a series edit, Duplicate and a new event at a slot\n added real minutes to the start. On the night the clocks go back a one-hour event dropped on 1 am\n read and was stored as 1am - 1am, and a 45-minute one dropped on 1:30 ended at 1:15. The end is\n now the start plus the event's length by the clock, the length it had when picked up. An end the\n clocks skip lands after the skip, as a start does: on the night they go forward a one-hour event\n dropped on 1:30 reads 1:30am - 3:30am, one hour in real time. A timeline month drag over a\n 25-hour day ended an hour past midnight; a new all-day event on a timeline month was 24 hours,\n not one day. Both now keep whole days.\n- **Scheduler: the Agenda and the tooltip say when an event over several days ends.** A timed event\n from Monday to Friday read \"12am - 12am\"; it reads \"12am - Oct 30, 12am\". An all-day one over several\n days shows its first and last day instead of \"all day\".\n- **Scheduler: a keyboard carry lands at the time carried.** Each arrow stepped from where the last\n one landed, so an event picked up on Saturday at 2:30 am showed 3:30 am on the Sunday the clocks\n skip 2:30, and stayed at 3:30 am on Monday and after. Every step now counts from where the event\n was picked up (days by the calendar, slots by the clock), and a slot step always goes the way\n pressed. With 15-minute slots a step down from 1:45 am on that night landed at 3:45 am; it lands\n at 3:00 am.\n- **Scheduler: the event in hand stays in view.** A carry by the arrow keys never scrolled the\n calendar: the event went under the sticky header and out of sight. The day, week and timeline\n views now scroll with it, and a Gantt chart scrolls with a bar moved by the arrows.\n- **Scheduler: the top edge of an event that ends at midnight resizes it.** Dragged from 11 pm to\n 10 pm, an 11pm - 12am event became 12am - 12am, a whole day, and was written so. Its end is now\n read as 24:00 of its day.\n- **Scheduler: Duplicate can copy the event.** It called `onEventAdd` with the times alone, so the\n copy was a blank \"New event\". `onEventDuplicate(source, start, end, resourceId, allDay)` gets the\n event it copies. In a base Duplicate on a calendar event copies the record, as a card's Duplicate\n does. A whole-day event with no end field copied onto its own day; it copies onto the day after.\n- **SvGrid Base: keyboard focus shows on menu items under forced colours.** The \"All tables\" menu,\n the table menu and a summary's menu drew focus as a tint, which a contrast theme removes. They draw\n a `Highlight` outline there.\n- **SvGrid Base: a checkbox change is said in words.** A screen reader heard \"Done changed to true\";\n it hears \"Done changed to checked\" (`viewbar.valueChecked` and `viewbar.valueUnchecked`), and the\n record's Activity and the Inbox read the same words. A checkbox cell is `aria-readonly` only when it\n cannot be changed.\n- **SvGrid Base: the tenant column never names a record.** A table under `tenantColumn` with no\n `name` column took its first text column, the tenant, as every record's name: link chips all read\n \"A\" and errors said \"Could not save Site id of A\". The primary field is now the first text column\n that is not the tenant, not a key column and not a foreign key column (one that links nothing, a key\n of three columns or into another schema, included). With none, the record's key names it and shows\n as the first column, read-only, pinned and never hidden, moved or deleted, as any primary field is;\n links, errors and the record view read that name. An integer `tenant_id` placed first is passed over\n the same way, and the tenant is never the first column. `EntitySchema.foreignKeyColumns` lists every\n foreign key column a database read found.\n- **SvGrid Base: an empty database opens as \"No tables yet\".** `createBaseEndpoint` with `allTables`\n answered a database with no tables with a `403`, which the scaffolded page read as \"set\n `authorize`\", in development too. It now answers `200` with no tables and reads the database again\n on the next request, so tables made by `db:setup` show on a reload. On Postgres `allTables` listed\n only `public` while every query reached tables through the search path: it now lists the tables of\n `current_schemas(false)`, the first of a name winning as `to_regclass` resolves it, and the svgrid\n comments, the key default and the column types of a table come from that same table.\n- **SvGrid Base: a refused write says what is known.** A foreign key refusing a write (a value naming\n a record that is not there) read \"Other records depend on it.\" with Try again: it now reads \"The\n record Site id points to is not there.\" with no Try again, and the endpoint sends `409` with\n `code: 'link-missing'` and the key's `fields` when the database says which. A delete keeps\n `linked`. A write the server answered with an error (`request-failed`, a trigger's `RAISE\n EXCEPTION`) read \"The server gave no reason, so it may not have been stored.\"; it now reads \"Not\n saved: The server answered with an error. Whoever runs it can see why in its log.\" Only a write\n with no answer says \"may not have been stored\". New messages `shell.why.linkMissing`,\n `shell.why.linkMissingField`, `shell.why.linkMissingFields` and `shell.why.serverError`;\n `shell.why.unknown` has new words.\n- **SvGrid Base: a new record the database refused takes no second create.** Add row opens the new\n record's first cell; when its insert failed (an id column too narrow, say) while that cell was open,\n the row waited for the editor, and what was typed into it sent a create again (in a browser on\n MySQL, two more), each failing with its own notice. What is typed now goes with the failed record,\n for its Try again where there is one, the notice says \"Could not add\" with the name typed and the\n reason, and the row goes when the editor closes. A refused new record that stays listed (while another\n editor is open, or a draft on a table read a part at a time whose refusal no retry can change, such\n as an id column too narrow) takes no edit: a click, a double\n click, a typed key or a paste on it shows its notice instead of an editor, so nothing typed into it\n is dropped. An editor open on it when the refusal comes is closed with what it holds, which the\n notice names. A draft refused for a reason a retry may get past (no answer, a server error) keeps\n taking edits, and its next edit sends it again, as before.\n- **SvGrid Base: a query with no `pageSize` is a `400`.** It was a `500` (\"planToSql: limit must be a\n non-negative integer\"). `pageSize`, and `startRow` and `endRow` when given, must be whole numbers of\n 0 or more, or their digits; the answer says so.\n- **SvGrid Base: two foreign keys to one table give fields back named for their keys.** Customers got\n \"Orders\" and \"Orders 2\" for `customer_id` and `rev_customer_id`; they are now \"Orders (Customer)\"\n and \"Orders (Rev customer)\". One key alone keeps the plain name.\n- **`npx @svgrid/create`: the base template asks for current packages and has a favicon.** Its\n `package.json` asked for `@svgrid/grid ^3.0.11` and `@svgrid/enterprise ^3.1.16`, and it had no\n favicon, so the browser's request for one was a 404 on every page. It now has the SvGrid icon\n (`favicon.ico`, 16 and 32 pixel PNGs, and an Apple touch icon). The pivot dashboard and\n SvelteKit templates' floors moved up too.\n- **SvGrid Base: three records that move at once during a range read stop it.** On a sorted paged\n view, one teammate's edit that moved a record from the part read to past the end, one from the part\n not read into the part read, and one from past the end into the part not read, left every block's\n seam, the far end and the count as they were and repeated no record. A 6,000-line paste then wrote\n about 500 lines to the record beside the right one and said \"Changed 6,000 of 6,000 records\". The\n whole id sequence is checked now, in requests that ask for ids alone: a range longer than a block\n reads its ids first, in place of the record at the far end, and each block must bring the same ids\n in the same places; once the last block is read, the ids of the whole range are read again and must\n be the very ids read, in the same order. Any difference writes nothing. This holds for a range of\n one block too, and for copy, clear, one value and fill. A teammate's move inside the part already\n read now stops the job too, where before the paste went ahead. `createSqlDataSource` reads ids\n alone for these requests (`idsOnly`); a source that does not know the hint sends whole rows.\n- **SvGrid Base: Try again after \"Records moved\" goes from the first record selected.** In the same\n view it pasted by position: after a teammate's edit moved a record above the selection, every line\n landed one record down, a selected record got nothing and one outside the selection got a line. Try\n again now finds the first record selected by its id, goes from there over as many rows below it as\n before, as the list stands at the click, and selects those rows first so the screen shows what it\n writes. The notice says so: \"Records moved while this was read. Nothing was changed. Try again\n pastes from \"Acme\" down over the rows as they are now.\" If that record is gone or no longer\n among the rows shown, Try again writes nothing and says so. Opening or closing a group since counts\n as a change of the view. Paste, one value, clear, fill and copy alike. Messages `shell.rangeMoved`\n and `shell.copyMoved` are replaced by `shell.rangeMovedPaste`, `shell.rangeMovedValue`,\n `shell.rangeMovedClear`, `shell.rangeMovedFill` and `shell.copyMovedFrom` (with `{name}`): a\n `setBaseMessages` override of the old keys needs the new ones.\n- **SvGrid Base: Undo and Redo of a range say how many records kept a teammate's value.** Undo of\n a 2,500-record paste where a teammate had changed one record said \"Someone has changed this cell\n since\" before its blocks were written. It now says \"Someone has changed 1 of these records since,\n so it keeps their value.\" once the blocks are done. A small range undone cell by cell says \"1 of\n these cells\" in the same case, after its checks.\n- **SvGrid Base: a grouped paged view shows a teammate's change in its open groups.** A change from\n the feed re-read only the group rows: an open group kept showing old values with no sign they were\n old, a record moved to another group stayed listed under the old one, and with the changed fields in\n the feed the counts did not follow either. The group rows and the loaded records of every open group\n are now read again, so a value shows in place, a record whose group changed moves to its new group,\n and the counts follow. A feed that sends the changed fields patches the row at once and reads the\n groups again only when a grouped field changed. A group closed at the time reads again when it is\n opened. A read that fails keeps every group's rows and says so in the top bar, as an ungrouped view\n does. The server row model's `refresh({ all: true })` is what does it.\n- **SvGrid Base: Retry in a failed block takes the pointer under the pinned column divider.** Over\n the button the divider showed its resize cursor and its line, and the click relied on being passed\n on. The divider now lets the pointer through to the button while it is over it, and is the divider\n again once the pointer leaves. Its line is no longer drawn across a failed block's band, so the\n words and Retry are clear of it; everywhere else the line is as it was, under forced colours too.\n- **SvGrid Base: the top bar's full reason can be read on any device.** A narrow window cut the line\n short with an ellipsis, and the tooltip held only the server's own words, which a touch screen\n cannot show. A line with a reason is now a button: a tap, a click or Enter opens it in full,\n wrapped, with the server's words under it, and the bar grows only while it is open. Another press,\n or the notice going, closes it. The tooltip holds the whole line, then the server's words. A screen\n reader hears the line and the server's words once, from the button, which carries `aria-expanded`.\n- **SvGrid Base: each Restore in the trash is named by its record.** A screen reader heard a list of\n \"Restore\" buttons; it hears \"Restore Task 4\", as Delete forever already said \"Delete Task 4\n forever\". New message `shell.restoreItem`.\n- **SvGrid Base: \"All tables\" says which table is shown.** Its tables are radio items now, the shown\n one checked, so the tick is announced as well as drawn.\n- **Calendar: Day and Week on a day the clocks change.** Events were drawn an hour off their rows on\n a 25- or 23-hour day, in the page and in Base, and a drop or a slot wrote the time of the wrong\n row. They are drawn, dropped and written by the clock now. A carry by the arrow keys steps by the\n clock too: the night the clocks go back, 1:30 and one step is 2:00, not the second 1:00, and the\n event keeps its length. A Pro timeline's working hours on such a day, and the days after it, start\n at their hour; they were an hour early, and on a 25-hour day one day was counted twice.\n- **Calendar: an event over several days says its last day.** Its name gave the first day only, so a\n bar from Monday to Thursday was heard as a Monday event.\n- **SvGrid Base, WebKit with a finger: a tap beside a link selects, as everywhere else.** WebKit sends\n the press of a tap to the cell and its click to a link, chip or star a few pixels away. That\n click followed the link, opened the linked record or set the rating on the first tap. A click\n now acts only when the press began on the same thing; on a cell already selected a tap beside a\n link does what a mouse click there does, which opens the cell's editor, and does not follow it.\n- **SvGrid Base, forced colors: a ticked checkbox shows its tick.** The white tick sat on a fill that\n a contrast theme removes, so every ticked box read as empty. The tick, a given rating icon and\n your vote are drawn in the theme's text color.\n- **SvGrid Base: a menu item that is off is heard with why.** Download as Excel without jszip, and\n Delete table on the last table, are in the arrow-key order of their menu (`aria-disabled`).\n- **SvGrid Base: deleting the last record of a group in a list keeps focus among the records.**\n Focus went up to the group's header. It goes to the record after it, the first of the next group,\n or to the record before it when it was the last of the list.\n- **SvGrid Base: two records that trade places during a range read stop it.** A paste, copy, clear,\n one value or fill on a sorted paged view checked the ends of each block it read. When a teammate's\n edit moved one record into the part read and another out of it, the ends stayed put: one record was\n read twice, the other never, and the paste wrote a line to the wrong record and said \"Changed 6,000\n of 6,000 records\". A record read twice now counts as moved, and nothing is written.\n- **SvGrid Base: Try again after \"Records moved\" acts only in the view it came from.** Pressed after\n a switch to another view of the table, it pasted into the records at the same positions there,\n which nobody had selected. It now writes nothing if the view, its sort, filter, groups or shown\n fields changed, and says \"That view is no longer open, so nothing was changed.\" or \"The view has\n changed since, so nothing was changed.\" The same holds for the answer to a job's question: past\n 10,000 records, new records past the last row, and a delete.\n- **SvGrid Base: the read count of a range goes up a block at a time.** It read \"2,000\", \"3,999\",\n \"5,998\" records so far: each block after the first read one record of the last again and counted\n one less. Each block now brings 2,000 new records.\n- **SvGrid Base: the notice of a save that stopped part way goes with its Undo.** It stayed after the\n Undo and still said \"Undo takes these back.\"\n- **SvGrid Base: a bulk delete that finds records gone says so in one notice.** \"Deleted 2,598\n records\" with Restore and \"Deleted 2,598 of 2,600 records\" came together; now the notice with\n Restore says \"Deleted 2,598 of 2,600 records\".\n- **SvGrid Base: an edit of a record a teammate deleted reads \"This record no longer exists.\"** It\n read \"The record is no longer there, or you may not change it.\", which suggested a permission\n problem.\n- **SvGrid Base: records that link to each other in a circle delete in one go.** A delete block of\n `n1 -> n3 -> n2 -> n1` went level by level and found no record to start from, so Postgres and SQL\n Server answered \"Other records depend on this one\". Records in a circle now go in one statement,\n which Postgres, SQL Server and SQLite take. MySQL checks each row as it deletes and refuses them;\n the page says so in words, and that the link of one of them must be emptied first. Delete forever\n out of the trash does the same.\n- **SvGrid Base on SQL Server: the trash asked with no limit is its count alone.** It read one record\n where Postgres and MySQL read none.\n- **SvGrid Base on Postgres: a foreign key of two columns links again.** The catalog query paired\n every column of a key with every referenced one, so `(tenant, order_id) -> orders(tenant, id)` read\n as four keys: links showed empty and valid ones were refused. Keys are now read column by column in\n key order on every database, and only within the schema the base reads (a table of the same name in\n another schema, or a key into one, is no longer mixed in, on Postgres, MySQL and SQL Server). A key\n of the tenant column and one more is a link through that one within the tenant, and the tenant\n column stays the read-only tenant instead of an empty link field. Any other key of more than one\n column links nothing and is named in the log. On Supabase, PostgREST does not describe a key of two\n columns, so neither column is a link there.\n- **SvGrid Base: every link through a pair table, and the field that links back, is named for its\n pair table** once the plain name is taken: \"Tags (Ot rev)\", never \"Tags 2\".\n- **SvGrid Base: the All tables menu never squeezes an item.** With many tables, or with the Excel item\n that says jszip is missing, items shrank into each other; the menu now scrolls instead.\n- **SvGrid Base: importing an .xlsx without jszip says so in plain words**, as the Excel download\n does, instead of the developer's install command. `importData` and `readImportMatrix` reject with\n `code: 'no-jszip'`.\n- **Scaffold: dialogs, menus and the rich text editor use the app's font.** The `base`, `sveltekit`\n and `pivot-dashboard` templates set the font on the layout only, and what moves to `<body>` was in\n the browser's serif.\n- **SvGrid Base: a cold automation server judges every record of a block by what it held before.**\n The first write after the server started read the tables after that write, so a pasted block of 45\n \"Won\" ran the rule for one record, and could run it for a record that was Won already. The `audit`\n hook now has a `before` that `createKitHandlers` awaits before each write, so the first read lands\n first. Pass your own audit hook as `automations.audit('tasks', yourHook)` to keep it; a hook you wrap\n yourself loses `before`, and then each record of the first request goes by the fields the write named.\n- **SvGrid Base: a paged view whose read after a teammate's change fails keeps its rows.** One failed\n refresh replaced every loaded row with \"Could not load these rows\". The rows stay, the top bar says\n the table could not be read, and Try again reads them again. New on the server row model:\n `keepRowsOnRefreshError` and `staleBlocks` on each level. The top bar's Try again no longer slides out\n of sight on a narrow window, and a failed block's Retry under the pinned columns' divider takes the click.\n- **SvGrid Base: one feed for a base on an endpoint.** The docs showed one `EventSource` per table and\n junction table. On HTTP/1.1, which a Vite or Node dev server speaks, a browser opens at most six\n connections to a host, so a base of six tables left no connection for a write: \"Still saving\" for\n good. `baseFromEndpoint` takes `feed: (apply) => stop`, one connection whose messages name their\n table, and `createBaseFeed` shares one connection among `baseSource`s.\n- **SvGrid Base: the trash of the person who deleted follows a teammate.** A teammate's Restore and\n Delete forever left the record in the deleter's trash and its count, open or closed.\n- **SvGrid Base: focus stays off another record's Restore.** When a teammate's change took away the item\n holding focus in the trash, or turned its Restore off, focus moved to the next record's Restore, and\n Enter restored a record nobody chose. It goes to the list.\n- **SvGrid Base: a failed write gives the reason the server sent.** An endpoint that answered\n `{ \"error\": \"...\" }` without a code read as \"The server gave no reason\". The page now says \"The server\n said: ...\" for a write and \"The server answered with an error: ...\" for a read. The endpoint's own\n 500 sends `code: 'request-failed'` and keeps the driver's words in its log, as before.\n- **SvGrid Base: a range on a sorted paged view writes nothing when a teammate moves a record under it.**\n A paste, one value, Delete, a fill and a copy read the range a block at a time, by place in the view.\n A teammate's edit that moved one record during the read shifted the next block by one, so lines\n landed on the neighbours and one could land outside the selection, while the page said \"Changed 6,000\n of 6,000 records\". Each block now reads the last record of the one before again and checks it, and\n the record at the far end is read first and checked at the end. If one moved, nothing is written or\n copied, the page says \"Records moved while this was read. Nothing was changed. Try again.\", and Try\n again does the same action on the same cells, on the rows as they stand then. A double click on the\n fill handle that finds records moved says so too; it stopped in silence.\n- **SvGrid Base: new records keep the order they were made in.** `newRecordId()` put two random\n characters before its count, and its clock part ran over every 16.8 hours, so a paste past the last\n row of a paged table showed its new records shuffled. An id is now `rec`, the whole time, a count\n within the millisecond and four random characters: 19 characters, in creation order, and it never\n runs over. Ids made before stay as they are. **Breaking:** ids were 12 characters, so a text id\n column narrower than 19 (`varchar(12)`, `varchar(16)`) now refuses every new record. Widen it to\n 19 or more before you upgrade. The base says so in words: \"Record ids need 19 characters; this\n table's id column holds 16.\"\n- **SvGrid Base: the screen shows a range job when it says it is done.** After a range job or its Undo\n on a paged table, \"Changed 3,000 of 3,000 records\" came while the cells on screen kept their old\n values for a second or two. The rows on screen now take each block as it lands, also the blocks that\n landed before one failed.\n- **SvGrid Base: a record a teammate deleted no longer fails a scoped block on a table without soft\n delete.** Under a `scope`, a key no tenant holds, live or in a trash, is gone: a block skips it and\n finishes, one record by itself answers \"This record no longer exists\", and the key is not sent to\n the source. Another tenant's record, live or in its trash, is still a 403.\n- **SvGrid Base on MySQL: a parent deletes with its children.** Delete, and Delete forever, of a block\n holding records of a table linked to itself and the records that link to them failed on MySQL with\n \"Other records depend on it\". The block now goes a level at a time, the records that link first.\n- **SvGrid Base: a block's answer is used.** A paste whose values a server hook changed read each\n record again, a request a record: 400 for a 400-line paste. The answer is now followed in one step,\n and what a lookup needs of those records is read in one request.\n- **SvGrid Base: a rich text field renders under Trusted Types.** It was a blank page under\n `require-trusted-types-for 'script'`. A base with a field of every type now renders there, with its\n record view and rich text editor (`base-trusted-types.spec.ts`). The paths that still do not run\n under it are listed in SECURITY.md.\n- **SvGrid Base: \"Download this view as Excel\" says why when it cannot run.** Without the `jszip`\n package the item did nothing. It now says the app needs jszip, and a download that fails says so.\n- **SvGrid Base: a checkbox is a real TRUE or FALSE in Excel**, not the words `true` and `false`.\n `exportGrid` with `rawValues` writes a boolean value as a boolean cell too.\n- **SvGrid Base: a \"Could not delete\" notice goes once its records are deleted after all**, instead of\n staying beside \"Deleted 3 records\".\n- **SvGrid Base: two pair tables between the same two tables are two fields with two names.** Both were\n named after the other table, and a third got the second's field id. The second is now named for its\n pair table, as \"Tags (Order tags t)\".\n- **SvGrid Base on Supabase: `date` and `timestamptz` columns are date fields**, read by the Postgres\n type PostgREST names, as on the other databases. They were text.\n\n- **SvGrid Base: a keyboard move in a month calendar stays in sight.** A month drawn in five weeks reads a sixth\n that is not drawn. An event carried into it went out of sight, focus went to another record, Space picked that\n one up, and the first showed on a date it did not hold. The view now goes to the next month with the event, and\n a key on another event while one is in hand acts on the one in hand. An arrow across a change of the clocks moves\n a whole day: a week down used to land an all-day event on the evening before.\n\n- **SvGrid Base: a finger follows the mouse in a cell.** A tap on a link, email, phone or URL cell selects it, and\n the next tap follows the link, so on a tablet such a cell can be selected, copied and edited. A tap beside a\n checkbox's box or on a checklist selects the cell. A tap on the box, a star, a vote or a button acts at once.\n\n- **SvGrid Base: a selected list row or gallery card no longer looks focused.** It has the grid's selected-row fill\n and a tick by its title; the ring is focus alone. Under forced colors the tick stays.\n\n- **SvGrid Base: focus stays with the record.** After Undo of a board move focus goes with the card, not to the card\n that took its place, on a board read from a server too. After a confirmed Delete from a list it goes to the next\n record, not to its group. A note on why a record stays open (a comment not sent or not saved) is said aloud.\n\n- **SvGrid Base: group totals of a paged grouped view are right after each write.** After a\n read that a slow backend had not answered when the next write asked for another, every\n later write kept the old rows and totals on screen for 10 seconds, so the totals showed\n the write before. The block cache now frees a read's slot when it gives that read up (in\n `@svgrid/grid`, below).\n\n- **SvGrid Base: a paged view that cannot read its next part says so in view.** The tab bar\n says \"Could not load *table*\" with the reason and Try again, as a table read whole does,\n and the grid's \"Could not load these rows.\" with Retry sits on the first row wholly on\n screen, not on a row above it.\n\n- **SvGrid Base: a cold automation server sees its first change whatever the row carries.**\n An endpoint's row with a column no field names (a tenant, a sequence) made the first\n change after a start look like a change of nothing, and no rule ran.\n\n- **SvGrid Base: a paged group of records that link to nothing reads \"Empty\"**, as a lookup\n group does, instead of a blank label.\n\n- **SvGrid Base: an open trash follows a teammate's Delete forever and Restore.** It reads\n the table's trash again when the feed reports a change, and a record whose Delete forever\n stopped half way no longer reads \"just now\".\n\n- **SvGrid Base: `queryRecords` counts from the other side of a link again, and its \"is\n empty\" agrees with its groups.** A count or rollup over records that point at a\n customer read 0 when the tables given to `queryRecords` held no such customer. A link\n grouped by id now groups by the id it stores. A view filter \"is empty\" on a link now takes\n a key to a record the linked table does not hold, as the Empty group and the cell do.\n- **SvGrid Base: a paged table whose database stops answering no longer leaves an unhandled\n rejection behind.** The count read beside a grouped view's groups, the record read for a\n feed that sent only the changed fields, and the count read of a dashboard or calendar each\n failed with nothing waiting for them. A feed's record that cannot be read now makes the\n view read it again later, and an Undo of a cell the grid no longer holds says the database\n could not be reached instead of doing nothing in silence.\n- **SvGrid Base: a block write of 20 records or more on a table the page holds offers Try again,\n and shows what the server stored.** A paste, a clear or an Undo of that many records that\n failed said so with no Try again, and two failed blocks of 1,500 records read as \"2 changes\". Now the notice\n counts records and Try again reads them first, sends what is still as it was, and says how\n many cells and records it left. Each block's records are read back once it lands, so a\n trigger's or a hook's value shows at once, and Undo finds it.\n- **SvGrid Base: a new record not stored yet inside a range is no longer passed over in\n silence.** A range job left it out with no word, a paste over it shifted every line up a\n row, a fill from it emptied the cells it reached, and a copy dropped its line. Now the job\n says how many it left, a paste keeps its line for it, a fill takes its value, and a copy\n has its line.\n- **SvGrid Base: a range job on Supabase or PostgREST counts and stops within 200 records,\n and stops when a record fails.** Differing values go one request each there, and a block of\n 1,000 held the count and Stop for 1,000 requests. A failed request now stops the other\n fifteen at once, so the count of what landed is what the database holds, and a record a\n row level policy skipped is a failure, not a write that passed.\n- **SvGrid Base: Delete or Backspace in an open single select empties it.** A click on a\n selected select cell opens it, and the key then did nothing.\n- **SvGrid Base: Undo of a range or Edit fields on a server with a hook takes back what the\n hook stored.** It took the stored value for a teammate's and left it.\n- **SvGrid Base: an undo no longer writes over a teammate's change made a moment after yours.**\n On SQL Server and MySQL a write is read back with a second statement, and a teammate's write\n landing between the two was taken for the answer to yours: Undo then thought the cell still\n yours and put your old value over theirs. SQL Server now writes and reads in one transaction\n of one batch. MySQL does with the source's `transaction`; without one the gap stays, and the\n docs say so.\n\n- **SvGrid Base: day filters and a chart's months follow the viewer.** On `timestamptz` and\n `datetimeoffset` columns \"is 8 March\", \"today\" and a chart's months were the database's days.\n The page now sends each date condition with the moments its days start and end where the\n person is, and a chart reads each part of the span with one UTC offset in that offset. A date\n and a wall clock read as before.\n\n- **SvGrid Base: a table keyed by both ends is a link to many.** A pair table with both key columns foreign keys is a link on SQL and Supabase, under a scope too, and a removed link deletes that one pair. Before, on Supabase it was a tab whose delete took every pair sharing the first column, and on SQL it stopped the whole base. Any other composite key, or no key, leaves that table out with a log line and the rest opens. `keys` names a unique column for such a table or a view. A table or view with no declared key, even with a column called `id`, is now left out until you do.\n- **SvGrid Base: the page shows what the server stored.** After a typed edit, paste, Add row, record edit or undo the cell holds the row the server answered: a hook's value, a stamped tenant, a default. Undo goes back from that value. The tenant column shows and takes no edit, and hiding it no longer makes the table a `403`.\n- **SvGrid Base: a self-linked record and its parent come back together.** The link check of a block counts the keys in that block, and a block writes parents first.\n- **SvGrid Base: lists in `json` and `jsonb` columns.** A multi select, a vote or a sparkline saves on `pg`, `postgres.js`, MySQL, SQL Server and SQLite, cast by what the column is.\n- **SvGrid Base: SQL Server sorts, filters and groups on formulas and lookups in SQL.** What it cannot say is refused at once, where the table used to be read into the page.\n- **SvGrid Base: `maxPageSize` below 1,000 works.** The page follows the server's limit, on reads and on blocks.\n- **SvGrid Base: Edit fields on Supabase is a request per 200 records** for records given one value, and a row level policy that skips a record stops the block and says so.\n- **SvGrid Base: small server fixes.** A bad page or a private field name in a request is a `400`. A MySQL key past 2^53 links. A cross-site browser request is not believed for its `X-Forwarded-Host`. `isSecretColumn` knows `pass`, `userpassword`, `adminpass`, `apikeys`, `secretkey`, `pwhash`, `database_url`, `dsn` and `webhook_url`. The evaluation card builds no HTML string, so Trusted Types pass. A scaffold's theme script is a file, so a strict CSP passes. A PDF preview gives the focus back with the pointer over the file.\n- **Compliance docs.** No GPG fingerprint is claimed, one security address, canvas use and the print popup stated as they are.\n- **SvGrid Base: a table that cannot be read says so and stays said.** Where the records would be: \"Could not load Deals\", why, and Try again. No empty table, Add row or \"Not saved\" on the way.\n- **SvGrid Base: Excel files hold real cells.** Numbers, percents, dates and times are numbers with the field's format, whatever a database driver gave as text: on Postgres, MySQL and SQL Server, held or paged, with lookups and rollups. A yes or no field reads the same word on every driver. A link, a select or a person with a number for a key reads by name, in CSV too.\n- **SvGrid Base: a click to select a cell changes nothing.** The first click on a link, email or phone selects the cell, and the next one follows it. Ctrl or Cmd click follows at once and a double-click edits. A click on a checkbox's box, a star, a vote or a button acts at once; a click on the rest of the cell only selects it. A finger's tap follows the same rules.\n- **SvGrid Base: a calendar's day sizes are the viewer's days.** On a column of moments (`timestamptz`, `datetimeoffset`) the sizes and each day's list follow the page's zone, across a change of the clocks. A date or a wall clock reads the same everywhere and is told as it reads.\n- **SvGrid Base: a big change's automations show and stop.** The Edit fields question says how long the runs will likely take and what a closed tab means. The bar shows how far they are, with Stop, and the tab warns before it closes. Waiting runs no longer hold their records, runs on records in the page leave the tab its turns, and a run that cannot read its record no longer stops the ones after it.\n- **SvGrid Base: memory comes back after a bulk edit.** The page keeps the changes of the latest 20,000 records of a table, and no key per record written.\n- **SvGrid Base: a grouped view on a table read by parts reads like one in the page.** Groups in option order, drawn as the field draws them, with the records they hold at every level (a driver's COUNT as text included), and totals for the fields with a sum, an average, a lowest or a highest in the footer.\n- **SvGrid Base: Undo says what a drag did.** A bar and the bars it pushed are one step, and a card or a bar reads \"Undo move record\". \"Generate for all\" on an AI field asks first when records hold values, and one Undo takes the whole run back.\n- **SvGrid Base: a link kept in a `text[]`, `jsonb` or MySQL `json` column.** An `in` filter on one asks whether any value matches, so opening a Gantt on a self link no longer raises `malformed array literal`.\n- **SvGrid Base: nothing shows under Apply in Edit fields.** The row now covers the drawer's padding.\n- **SvGrid Base: a multi-column paste, clear or fill on a paged table writes every column.** It\n wrote the first column of each row and put the old value back in the others, with no message.\n- **SvGrid Base: a range on a paged table is the whole range.** Paste, one value over a range,\n Delete, fill and Ctrl+Enter reach every record the selection covers, loaded or not, through the\n Edit fields dialog: read and written in blocks, with progress, Stop, a count at the end and one\n Undo step. They used to reach only the rows the page held, and \"All changes saved\" said nothing\n of the rest. Up to 200 cells of loaded rows stay instant, with no dialog.\n- **SvGrid Base: a copy of rows not loaded reads them first.** It wrote blank lines and a $0.00\n for each. Up to 2,000,000 cells it reads with progress; past that it copies nothing, says the\n number, and points to Download.\n- **SvGrid Base: Undo and Redo of a range do not freeze the tab.** A big range is one step that\n reads and writes in blocks, and on rows held in the page a step's cells go back in one pass.\n- **SvGrid Base: a paste past the last row.** A line where no value fits makes no record. Past 10\n new records it asks first, with the number. They go in one block, and Undo takes them out in one.\n- **SvGrid Base: a paste while a view reloads makes no record.** It says the view is loading. A\n write that reads the view again leaves the rows on screen until the new ones arrive.\n- **SvGrid Base: a paste and a clear stamp last modified fields and the record's activity**, as a\n typed edit and a fill do.\n- **SvGrid Base: Undo takes back the Try again of what it undid.** A press on that button wrote\n the undone value, with no step to undo. Esc during a drag of the fill handle or a range now\n cancels it.\n- **SvGrid Base: Delete forever no longer cuts links on a record that comes back.** A teammate's\n Restore during the purge, a server failure at any step or a closed page could leave a restored\n record with its foreign keys empty, and a failed purge could overwrite a teammate's new link. The\n record is now claimed first, so no restore meets a half done purge, the keys are written only\n where they still hold what was expected, and the purge reports the ids it deleted.\n\n- **SvGrid Base: a restore is not a creation.** Restore and Undo of a delete ran \"record created\"\n server automations, which rewrote the record. The first change after the automation server starts\n is seen too.\n\n- **SvGrid Base: a record a teammate trashed no longer fails a block with \"no permission\".** Under a\n `scope`, a block skips it and finishes, as it does with no scope, and one record says it is gone.\n The audit log and `afterDelete` no longer name a record the delete did not change.\n\n- **SvGrid Base: a link to a trashed record is empty everywhere.** \"Is empty\", \"is not empty\", one\n Empty group with no raw key, sort, count and the picker, on held and paged tables. An undo to a\n record deleted forever says so, with no key and no Try again, and a link written to a trashed\n record says why it shows empty.\n\n- **SvGrid Base: your own edit with a lost answer is yours.** A read finds it landed: no failure, no\n Try again and no \"changed by someone else\". Undo of a hard delete no longer asks for a restore the\n table cannot do, and a write that was refused or found its record gone leaves no undo step.\n\n- **Board: a keyboard move writes once, on the drop.** The arrows only show where a card is going, and\n `onCardMove` and `onCardReorder` fire when it is dropped, from where it was picked up. Escape used to put the\n card back on screen while the record kept the new lane. Tab or a click elsewhere puts it back too, focus stays on\n the card, and on a `server` board the drop marker shows the way until the drop.\n- **Scheduler: Escape works past the edge of a view.** A carried event used to leave the view and take Escape with\n it. The view now follows the event, and Escape brings both back.\n- **Scheduler: an all-day bar in Week or Day takes the keyboard.** Space opened it instead of picking it up, and it had\n no name with its date. It now moves as any event does; up and down move it a week.\n- **SvGrid Base: a list read from a server takes Tab.** Flat or grouped it is one stop, on the record you were last\n on, and the arrows walk records, not the row buttons. Grouped lists read from a server also take Home, End, Right\n and Left. Right and Left swap in a right-to-left page.\n- **SvGrid Base: Enter on a list row's button opens its menu**, not the record, and a selected row shows it and\n says \"Selected\".\n- **SvGrid Base: focus no longer falls to the page.** The selection bar goes back to Delete after its question, and to\n where you were after Clear, Escape or a confirmed Delete. A sent form puts focus on its thank-you and says it. A\n dashboard tile moved by its buttons keeps focus on the button pressed, which at either end is off, so a second\n Enter does nothing.\n- **SvGrid Base: a comment's question and Next.** Escape on \"Delete this comment?\" leaves the question, not the\n record, and focus starts on Cancel. Next and Previous wait for a comment being changed, and say so, instead of\n dropping the text. A click outside a record with text not sent says why it stays open.\n- **SvGrid Base: small accessibility fixes.** A link chip in a list row is no longer a button inside a button, Add\n table keeps its 26 px on a phone, a mail link in a record is 24 px tall, and the Menu key cannot open the browser's\n menu over a card's. A record with no name reads \"Untitled\" everywhere.\n- **Edit fields on a big table no longer freezes the page.** It runs in the dialog a delete uses, with progress and\n Stop. Past 10,000 records it asks first, with the exact number. A failure part way stops there, reads the block back,\n says how many records changed, and keeps Undo for those; it used to carry on, say none were saved and leave no Undo.\n- **Bulk writes through `createBaseEndpoint` go in blocks.** `createMany`, `updateMany` and `deleteMany` carry up to\n 1,000 records a request, and records given the same values are one statement. `authorize`, `scope`, `validate`,\n `checkWrite`, hooks and `audit` hold for each record as on a one-record write.\n- **An edit, a paste, an undo or a redo deep in a big table is as quick as one at the top.** Each walked every row\n before it, several times over.\n- **A calendar on a date-with-time field groups by day in the database** (`groupDays`, on every dialect), and a month\n moved past stops sending its days. `groupMonths` works on SQL Server and SQLite too.\n- **`createSqlDataSource`: `updateRows` keeps the time** of a schema `date` over a timestamp on Postgres, where a cast\n dropped it, and writes records given the same values without a CASE. A block's statements carry the tenant.\n- **The link picker's Enter waits for the server's answer.** On a table a server searches it took a row of the last\n search, or made a record whose name was there.\n- **A table read a part at a time asks for 200 records a block by default,** not 100: a sorted read costs a sort of the\n table whatever it returns.\n\n- **`createBaseEndpoint`: a junction table under a tenant `scope`.** A junction holding the tenant\n stays a link to many with `tenantColumn`, and one holding none takes `{ through: 'order_id' }`, so\n a pair belongs to the tenant of that record on every path. A `null` for a junction between scoped\n tables used to share every tenant's pairs: it is now a `403`, and the log says what to do.\n\n- **`createBaseEndpoint`: a link stays inside the tenant.** A foreign key written through the route\n must name a record inside its table's `scope`, in blocks too. Another tenant's record and no\n record get the same `409` with `code: 'link-refused'`. Before, a tenant could point at another's\n record, block its delete, and learn which keys exist.\n\n- **Base: a table keyed by a secret does not start.** A key named like a credential reached every\n reader, because a key cannot be hidden. Such a table is now left out, the log says why, and\n `exposeSecretKeys` serves it by name. A foreign key holding that value stays out too.\n `isSecretColumn` also knows `passcode`, `user_pass`, `session_key`, `activation_key`,\n `remember_digest`, `hashed_pw` and `mfa_seed`.\n\n- **`baseFromSupabase` asks only for what it shows.** It read `*`, so a column `hide` held back still\n reached the page, and a table with a column `anon` may not read failed. `createSupabaseDataSource` takes\n `schemaColumns`, and a base sets it. A record brought back by undo gets a hidden column's default.\n\n- **Escape closes a PDF preview.** Chrome's viewer took the focus as it loaded, and keys pressed there\n never reached the page. The focus now comes back to the dialog, unless a person went into the file.\n\n- **`createKitHandlers` takes JSON from its own site only.** A `POST` that is not\n `application/json` is a `415`, and one from another site a `403`, on `vite dev` as well as in a\n build. A page on another host goes in `origins`. A caller of `handle` that sent no content type\n must now send one.\n\n- **Server logs hold no value a driver quoted.** The handlers log codes and names, and take the value\n out of the text: a SQL Server or MySQL duplicate key, a Postgres `detail`, mysql2's `sql`.\n\n- **A color from data cannot reach a style.** An option's color, a record's value used as a color and\n a label's color now go through `safeColor` on the Board, the scheduler, the Gantt, `SvBoard`,\n `SvRecordDetail`, `SvSchedule` and the automations dialog, and a spreadsheet file's formats through\n `entryToStyle`.\n\n- **`GET` keeps an automation's outbound details from those who do not need them.** A webhook or\n an email is described only to a person `authorize` lets change the table, and an automation that\n runs on the server sends no URL, header or address to any page. `sharedTables` drops them too,\n with what a view said of a hidden field.\n\n- **Print and the HTML export run no script.** A cell's link is `http`, `https`, `mailto`, `tel` or\n `blob` only, a rule's color cannot leave its attribute, and the document carries `script-src 'none'`.\n\n- **`baseToSql` keeps a title inside its comment.** A table named with a line break could start a\n statement of its own in the downloaded file.\n\n- **Compliance pages.** `gdpr.md`, `hipaa.md`, `soc2.md` and the compliance overview now say what\n holds for `@svgrid/grid` and what SvGrid Base adds. The doc site's host was wrong in `gdpr.md`.\n\n- **SvGrid Base: the fill handle fills by the field, not by the look of the stored value.** One\n source cell copies in every field, so a person, an option, a color or a time no longer counts up\n to the next one. Two or more source cells continue a series in number and date fields and repeat\n in every other. A value the field cannot hold is not written, and the page says so. Ctrl+D copies\n down, and is one undo step.\n- **SvGrid Base: a copy writes what the cell shows, and a paste brings the same value back.** Percent,\n duration, currency, date and time cells copy as shown, so Excel gets `50%` and `1:30`, and a paste no\n longer turns 50% into 1%. Inside a page the stored value comes back in full: 12.5% shown as 13%,\n bold in rich text, the right one of two people with one name.\n- **SvGrid Base: one multi-line cell in is one cell out.** Copy quotes a cell holding a line break or\n a tab, and a paste reads quoted text, Excel's included, so the record below is left alone.\n- **SvGrid Base: import keeps what a file says.** A date keeps its calendar day in every time zone, a\n percent reads as the grid reads it, a person matches by name or email, and a name that matches\n nobody is no longer stored as a person. Link fields can be mapped by the linked record's name. The\n dialog says how many cells it could not match. A type change from text to a date or a person reads\n the same way, and a rating stays within the field's maximum.\n- **SvGrid Base: a downloaded view reads back to the same values.** A percent is written `12.5%` and a\n duration `1:30:15`, where the stored 0.125 and 5400 would read as something else in an import, and a\n name with a comma in a list is quoted. In Excel a percent stays a number with a percent format, and\n an import reads an Excel cell as it shows: a percent as a percent, a date cell as that date. A select\n option is known by its label as well as its value, so an import adds no copy of it.\n- **SvGrid Base shows its own notices.** A host with no `<SvToaster />` now sees every failure, refusal\n and Restore. A host that has one keeps it, and nothing shows twice.\n- **SvGrid Base: Add record in a grouped view goes to the new record's first cell.** A new record in a\n group of its own opened no editor, so typing pressed the button again and made blank records.\n- **SvGrid Base: undoing a delete after a restore on another tab keeps both sides of a link.** Roll-ups\n on the other table were left short.\n- **SvGrid Base: smaller things.** Space on a Vote cell votes. A click beside the number in a record's\n number editor keeps the edit. Enter in the new view's name closes the view menu. The undo button and\n the screen-reader message name a fill, a paste or a bulk edit by its cells, and a redo is said as a redo.\n\n- **SvGrid Base: focus no longer falls to the page.** A dialog or menu whose opener went, or\n cannot take focus (a menu item, a row button hidden under the dialog, a field just deleted),\n hands focus to what held it, which is the grid, or to the next card. Pin, Hide field, Delete\n field, Expand record, Comment, a deleted card or calendar event, and Undo or Redo on the last\n step all leave the keyboard in place.\n- **SvGrid Base: Remove on a dashboard tile takes the keyboard to its question,** which is read\n out. A second Enter cancels; it no longer lands on the next tile's buttons.\n- **SvGrid Base: Escape in a comment keeps the text.** It leaves the box, and acts as Cancel on\n a comment being changed. Text not sent holds the record open against Escape, which then says\n why, and against a click outside.\n- **SvGrid Base: cards and list rows keep the record's actions.** At a phone's width, in a\n gallery and in a list, the Menu key, Shift+F10, a long press and a button on the card open\n expand, comment, select, insert, duplicate and delete. Selection shows on the card and in the\n selection bar. `gallery.cardMenu`, `gallery.isSelected` and `gallery.text` are new.\n- **Board:** \"Add card to Lead\" and \"+ Add a card\" show the focus ring. An empty lane no longer\n says it is a list. **Link preview, tooltips:** Escape closes a link preview, a grid tooltip, and\n a calendar or Gantt tooltip with the pointer still on it, and a pointer crossing the gap to a\n link preview keeps it open.\n- **SvGrid Base:** a rating cell's name and a gallery's name are translated. Run now with no\n record writes \"(no record)\" for a field token, not the raw `{Deal}`. A view bar button reached\n at a phone's width comes fully into sight. A percent bar keeps its fill under forced colors.\n\n- **SvGrid Base: a tenant's trash on MySQL and SQLite.** With `scope` and `softDelete` the tenant\n was bound before the ids, and `?` is matched by position, so Undo, Restore and Delete forever\n found nothing: a restore said the record was deleted forever, and a Delete forever reported\n success and left the row.\n- **SvGrid Base: a soft delete leaves foreign keys alone.** It used to clear them in other tables,\n and a restore after a reload or by a teammate never brought them back. The clearing now happens\n at Delete forever, in the tables of the base. A hard delete is as it was.\n- **SvGrid Base: a database's numbers show as stored.** Introspection reads a column's scale:\n `numeric(12,2)` holding 19.99 shows `$19.99`, not `$20`, and an integer shows no decimals. A column\n with no declared scale takes the places its values show. On SQL Server `money` has four. MySQL's\n `tinyint(1)` is a checkbox, a `time` column a time of day and never a select, and a Postgres\n `text[]` a multiple select that can be edited.\n- **SvGrid Base: an insert whose answer was lost.** A read says whether it landed: the record is\n taken, what was typed goes to it, and nothing false is said. A key the database makes is found by\n the record's values, in a table the page holds. A 5xx with no code now says the server did not\n answer, not that the database refused, and a delete or an edit that landed is not told as a failure\n or as a teammate's change.\n- **SvGrid Base: a refused undo shows the value it found.** Without a feed the cell kept the value the\n database no longer held.\n- **SvGrid Base: JSON keeps every digit.** A `json` or `jsonb` column is read and written as text, so\n a number past 2^53 is not rounded by a read, an undo or an edit.\n- **SvGrid Base: a notice goes with its base.** The toast queue belongs to the page, so a \"Deleted ... Restore\" or a Try again\n outlived the base that made it, and the next base on the page drew a button that did nothing. Restore now goes with its base, and a\n failure keeps its words, what was typed included, with no button.\n- **SvGrid Base: smaller things from teams.** Someone who may not delete hears no error from the trash,\n and the panel says why it is empty. A permission refusal offers no Try again and leaves no undo step. A\n paged view with a filter drops a record a teammate moved out of it. A teammate's restore lands at the\n record's place. A Delete forever takes the \"Deleted ... Restore\" notice with it, and a number deleted\n in this page is not given to the next record while it stays open.\n\n- **BREAKING: `scope` refuses an empty tenant.** A value of `''` used to drop the predicate,\n so a person with no organisation read, rewrote and deleted every tenant's rows. Now a\n resolver that returns nothing, or a rule whose value is empty, blank or not a single value,\n is a `403` on every read and write, and `createBaseEndpoint` leaves the table out of `GET`.\n Only `null` means no scope. `scope: (table) => ...` must return `null` for a table every\n tenant shares: returning nothing now closes it.\n- **SQL Server runs.** `dialect: 'mssql'` wrote `LIMIT` and `RETURNING`, so nothing could. It\n now pages with `OFFSET ... FETCH`, reads a key back with `OUTPUT INSERTED ... INTO` (a table\n with triggers works), writes an identity key under `IDENTITY_INSERT`, stays under 2,100\n parameters and 1,000 rows, and keeps `datetime`, `datetimeoffset`, `bigint` and `decimal`\n exact. Run against SQL Server 2022. Formulas are worked out in the page there. Studio's\n connection string for it was a URL the `mssql` driver cannot read.\n- **BREAKING: a PDF preview frames only bytes it read.** A file on another origin went into the\n frame as it was, and could draw a sign-in form under the base's own title and move the tab.\n A file the page cannot read, because its host sends no CORS headers, now offers a download.\n- **An id from a client reaches the source as text.** A number was bound as a number, and on\n MySQL with a loose `sql_mode` `id = 0` matched every id not starting with a digit. An empty\n id is a `400`.\n- **`patch: { id }` no longer changes a record's key.**\n- **A webhook connects to the address it checked.** A name could answer one way for the check\n and another for the connection. On Node the call now goes to the checked addresses, and a\n name that does not resolve is not sent. More ranges are refused: `192.0.0.0/24`,\n `198.18.0.0/15`, the documentation blocks, `fec0::/10`, and IPv6 forms wrapping an internal\n address (`::a.b.c.d`, NAT64, 6to4, Teredo).\n- **`isSecretColumn` knows more names.** Any `token` (`remember_token`, `token_hash`),\n `pass_hash`, `password1`, `pin`, `recovery_codes`, `credit_card`, `iban` and others. It reads\n the name only, and the docs now say that is a default, not a guarantee.\n- **`createBaseEndpoint` takes `validate`, `hooks` and `maxPageSize`.** Writes through it could\n not be checked on the server. `validate: true` asks nothing of a `NOT NULL` column with a\n default, and a schema read from a database no longer marks such a column required.\n- **A refused write says why, through an endpoint too.** A constraint was a `500` and \"The\n database refused it\". It is now a `409` with a `code`, and the person reads which rule it\n was, without the driver's words. An autonumber clash through an endpoint now takes the\n next number, as it does on a direct source.\n- **Thrown text stays on the server.** A message thrown by `authorize` or `scope` reached the\n client, connection strings included. It now reads `forbidden`, unless the `Error` has\n `expose: true`.\n- **A read has a ceiling.** `createKitHandlers` returns at most `maxPageSize` rows (20,000 by\n default) with the true count, so `pageSize: 1000000000` no longer reads a table in one go.\n- **An alert rule's style is a color.** `red;background-image:url(...)` fired a request to\n another host each time a cell painted.\n- **A group key that is an object is refused.** A driver could write one as SQL of its own.\n- **A filter on a number past 15 digits compares exactly.** Rounded, a tenant id could be\n someone else's.\n- **A scaffold's production build says what is closed.** It read \"The database did not answer:\n 403. Is DATABASE_URL set\", which sent you to the wrong fix.\n- **Two dev console warnings are gone**: `state_proxy_equality_mismatch`, once for each field\n of each table, and `ownership_invalid_binding` on `views`.\n- **\"Not in view (1 record)\".** It read \"1 records\".\n- **Forms take the mouse again.** Typed boxes ignored a click or a tap, and so did an\n open editor in a record. A star clicked in a form is now the answer; it used to open\n the editor.\n- **A record's Account picker no longer links what nobody chose.** Enter on the list as it\n opened ticked its first record, and Done saved it. Enter now closes it unchanged, and\n a picker left as it opened writes nothing.\n- **Focus no longer falls to the page.** Comments, a form's pickers, the form builder,\n dashboards, filter conditions, automations, attachments, import, the inbox and the\n field editor keep the keyboard on the logical next control, and comment changes,\n tile moves and form builder moves are said aloud.\n- **Base has the fill handle its docs promise.**\n- **The form builder's field list holds still.** A field turned off keeps its row, and back\n on it takes the place the row shows.\n- **Timeline.** Delete on a bar asks first, as does Delete in a calendar's menu. A bar moves by\n Space and the arrows with one write, stands clear of the task table when focused, opens\n its menu with Shift+F10 with focus in it, reads as a table, keeps its shape in forced\n colors, and every word goes through the base's messages. A drop on a weekend stays\n there.\n- **Attachments: Enter on Remove removes the file.** It opened the preview.\n- **Dashboards ask before a tile is removed.**\n- **Form number boxes read as the field does** (\"25%\", \"$1,250.50\") and edit in its units.\n- **Escape in a number or a rating in a record leaves the box.** It closed the record.\n- **Typing on a focused record field starts the edit**, and Enter in the field type search\n takes the first type.\n- **A double-click on a week's all-day row adds an all-day record.**\n- **Automations:** step buttons name their step, moves are said, and the open automation\n carries `aria-current`. **Delete record** ties its text to the dialog.\n- **SvGrid Base: Edit fields writes to the ticked records and nobody else.** In a sorted,\n filtered or grouped view each value that landed moved its row, and the next one went to\n whatever had taken its place, so records nobody ticked changed and Undo wrote more wrong\n values. Every cell is now worked out first and written by record, in one write and one\n undo step, on tables in the page, on SQL tables and on tables read a part at a time,\n where Edit fields did nothing at all before. Text a field cannot read, such as `abc` in a\n number, stops the form with a message and writes nothing.\n- **SvGrid Base: Delete, paste and fill stay on their records.** A row held under a typed\n edit but moved at once under Delete or a paste, so a second press hit another record.\n The row now holds until the cursor moves on, whatever wrote it.\n- **SvGrid Base: a paste past the last row adds records,** as one undo step with the cells\n it wrote. It used to drop those lines without a word.\n- **SvGrid Base: one rule for pasted values a field cannot read.** A number, a select, a\n date, a person, a link, a rating or a checkbox given text it cannot read keeps its value,\n and one notice says so. An unknown link name no longer wipes the link, and an unknown\n name no longer lands in a person field as a person nobody has.\n- **SvGrid Base: a write with no answer is not given up on.** A write past `writeTimeout`\n stays out: later writes to its record wait behind it, writes to other records go on, and\n the status says so. It can no longer land late over a newer value, a late insert leaves\n no second record behind a Try again, and a late delete keeps its copy in the trash until\n the outcome is known. A rollback now leaves a value written after the failed one.\n- **SvGrid Base: the undo guard fails closed.** A cell undo reads the record first, with a\n feed or without one, and is refused with a message when that read fails, so a feed down\n without a word can no longer take a teammate's value out. The step stays the next to try.\n- **SvGrid Base: Try again checks first.** It reads the record, leaves a value that changed\n since, whoever changed it, and says so, also when the record was deleted.\n- **SvGrid Base: a failed read before a delete stops the delete.** That block stays, and\n the person is told, instead of going ahead on a stale copy.\n- **SvGrid Base: editors in a record are held for.** A teammate's change waits while a field\n of the record view is being edited, as it does for a cell.\n- **SvGrid Base: fewer false \"changed by someone else\".** A number the database rounded, a\n person's own undo on a table read a part at a time, and a feed's word on an earlier write\n of the same record are no longer reported as a teammate's. A read that started before a\n write no longer puts the old value back. Undo refused \"alone\" after 1.234 in a column of\n two decimals goes through.\n- **SvGrid Base: undo and redo run no automation.** A redo of a status change added its\n checklist items again on every press.\n- **SvGrid Base: a second restorer is told nothing is wrong.** Two people restoring the same\n record at once: the second sees it back, not \"Another record already has this value\".\n- **SvGrid Base: wrong words on the history.** A column resize read \"Undo cell edit\", and a\n redo was logged as \"undid\".\n- **SvGrid Base: soft delete keeps a record's junction links.** A delete of a record marked\n with `softDelete` dropped its junction rows and a restore did not put them back, so tags\n were gone after a reload. Junction rows now stay, at either end of the link, and a restore\n writes nothing. A marked record shows in no link. Delete forever removes them with the row.\n- **SvGrid Base: Delete forever is final, and only once the database says so.** A purge the\n database refused left the record marked with no way to reach it, under a notice saying it\n was in the table. The item now stays in the trash until the purge is confirmed, the notice\n says so, and in one Empty trash the free records still go. Ctrl+Z could put a purged record\n back from the page's copy: the undo step now ends, and a stale undo in another window\n refuses. A single Delete forever now asks first, as Empty trash does.\n- **SvGrid Base: the trash of a soft delete table reads the table.** Marked rows show after a\n reload with no trash store, for whoever may delete. **Behaviour change:** those rows appear\n in the trash, those marked by other tools too. They do not age out: `trashDays` still only\n purges what the page's trash holds.\n- **SvGrid Base: `softDelete` on `createBaseEndpoint`, `baseFromDatabase` and\n `baseFromSupabase`.** The endpoint could not use soft delete at all. The column stays out\n of the fields, and the description tells the page.\n- **SvGrid Base: the mark cannot be written.** With the column on the schema a client could\n create a record already deleted, or mark one through an update. `createSqlDataSource`,\n `createSupabaseDataSource` and `createKitHandlers` now leave it out of every write.\n- **SvGrid Base: teammates hear of soft deletes.** A restored record reached a table read a\n part at a time only on a reload-style feed, and a delete through `createKitDataSource` stayed\n on teammates' screens. `createKitHandlers` now says which column marks records and the page\n learns it. `apply({ type: 'update', id })` reads that one record, which is how a feed reports\n a junction change; `baseFromSupabase` listens to junction tables by itself.\n- **SvGrid Base: a new record does not take a marked record's number.** On a table the page\n holds it did, and the restored record was renumbered. Autonumber now reads past marked rows\n on Kit and Supabase too.\n- **SvGrid Base: a very large soft delete purges a block at a time.** Closing the page used to\n leave everything not yet purged marked.\n- **`createKitHandlers`: restore and purge tell the server what happened.** **Behaviour\n change:** the `audit` hook now gets `restore` and `purge` actions, one entry per record that\n really changed, in place of `update` and `delete` with ids joined by commas, and a purge of\n another tenant's id logs nothing. `beforeDelete` and `afterDelete` run on a purge with\n `purge: true`, and `beforeRestore` and `afterRestore` are new. On a table with no `softDelete`\n `restore` and `purge` answer 405.\n- **SvGrid Base: formulas and lookups through `createBaseEndpoint` run in the database.**\n A sort on a formula read the whole table into the page, because the server's source\n was never told the base's fields. It now works from the fields the server holds (the\n `svgrid:` comments, or the new `computed` option for MySQL and SQLite) and says which it\n works out in `serverComputes`. A request names a field and brings no definition. A link\n is followed only for a person who may read the other table, and not into a table\n `scope` covers. A field changed in the page goes back to being worked out in the page.\n- **SvGrid Base: a sort, group or negative filter on a lookup reads the other table once.**\n Sorts and groups use a `LEFT JOIN`, and \"does not contain\", \"is not\", \"is empty\", \"is\n none of\" and \"not equal\" a `NOT EXISTS`, in place of a subquery per record. A record with no\n link, or a link to a record marked deleted, matches as it did.\n- **SvGrid Base: a view counts once per query.** A block read asks for rows alone once the\n view has its count. The count is read again after a write through the page, a change\n from a feed, a block that does not fit it, or 30 seconds. With no feed, a teammate's new\n record reaches the count in that time, at the next read.\n- **SvGrid Base: blocks read their keys first.** A read with text copies or a join finds the\n block's keys, then reads those rows, so a sort or an `OFFSET` no longer carries whole rows.\n- **SvGrid Base: a date condition compares the column to a range** on Postgres and MySQL,\n so an index on it serves a calendar and a filter. `DATE(col)` and `col::date` could not\n use one. SQLite keeps `DATE()`, which reads the offsets in its text.\n- **SvGrid Base: a read nobody waits for stops.** `execute` gets `{ signal }` on reads, no\n further statement of a stopped read is sent, and `createKitHandlers` passes\n `request.signal` on.\n- **SvGrid Base: a chart on dates is one grouped statement**, and group charts, board lanes\n and calendar days no longer run a count they do not use. A dashboard reads its tiles\n once as it opens, and tiles on one query share its count.\n- **SvGrid Base: a view switch shows no old count or rows** under the new view's name.\n- **SvGrid Base: a bulk delete reads by key** in place of a growing `OFFSET`, with a count at\n each end of the read.\n- **SvGrid Base on MySQL: a descending sort reads an index backwards.** Its tie-break on the\n key follows the sort's direction there, so records with the same date now come newest\n key first. `date DESC, id ASC` sorted every row.\n- **`baseFromDatabase` and `createBaseEndpoint` open a MySQL database.** The column read used\n `generated`, a reserved word, as a bare alias, and MySQL refused the statement.\n- **`createBaseEndpoint`: the first description no longer groups a unique column.** A column\n that shows more than 12 different values in a sample of 5,000 rows cannot be a select.\n\n- **Server row model: a drag of the scrollbar reads where it stops.** A jump of more\n than a block waits for the viewport to stand still (`leapPauseMs`, default 60), a\n read the viewport has left stops through `request.signal`, and the rows on screen\n go first in the queue. Placeholder rows keep their row number and line up with the\n columns.\n- **SvGrid Base: Gallery, List, Inbox, Board lanes and the Timeline read ahead of a\n scroll,** further the faster it goes and the slower the source, and a drag of the\n scrollbar reads where it stops.\n- **SvGrid Base: a typed column or view filter waits for a pause,** as the search box\n does; a pick from a list applies at once.\n- **SvGrid Base: a busy calendar asks for its days' sizes in one grouped request.** It\n skips empty days, and after a write reads only the days whose size moved. A record\n with an end date, or a backend that does not group, stays a read per day.\n- **SvGrid Base: reading a table through in the page keeps 4 requests open** past the\n first blocks, instead of waiting for one at a time.\n- **SvGrid Base: a Calendar and a Timeline no longer stay in memory after a view\n switch** on a Svelte older than 5.57.2 by these two routes. Svelte 5.55 to 5.57.1\n keep other parts of a destroyed grid linked as well: use 5.57.2 or later.\n- **SvGrid Base: every record action from the keyboard and on touch.** The Menu key\n and Shift+F10 open the record menu with focus in it, the row number has an actions\n button on a touch screen, a long press opens the menu, and the record view can\n delete its record. The field menu and the table menus take focus, walk with the\n arrows and give focus back. A field moves from its menu or from Hide fields.\n- **SvGrid Base: the rows are one tab stop.** Tab goes on to the header and footer\n controls; it walks cells after a click or in an open editor, and says the way out.\n- **SvGrid Base: forms have real inputs.** Typed fields are labelled inputs with\n required and invalid states and autofill; a failed submit goes to the first error\n and reads it out.\n- **SvGrid Base: what changes is said aloud.** Edits, clears, pastes, undo and redo\n reach a screen reader, and a calendar event moves only once picked up with Space.\n- **SvGrid Base: contrast.** Text on a filled accent control now follows\n `--sg-on-accent`, and accent-colored text in the chrome is plain ink. Text on a colored\n pill or bar stays white on saturated colors, by design; the VPAT gives the ratios.\n- **SvGrid Base: forced colors, right to left, translation.** Switches, the active\n tab and view and the \"+\" keep their state under forced colors. Arrow keys and the\n pin line follow `dir=\"rtl\"`. `setBaseMessages` now reaches the grid's own menus,\n find bar and labels (`grid.*`) and the calendar (`viewbar.calendar.*`).\n- **SvGrid Base: smaller fixes.** Focus stays in the grid after a delete, panels hold\n Tab, Search moves into the find bar, targets are 24 px, an IME composition keeps\n its Enter, and a calendar on a phone keeps its title on one line.\n- **SvGrid Base: a select option has an identity.** Renaming one in the field editor renames it on every\n record, in a multi select too, keeps its cards in their lane, and reaches the view filters, condition colors,\n form logic, dashboard tiles, automations and the field's default that name it. Removing one says how many\n records hold it, next to Save, and clears them. Undo takes it all back. On a table in a database it is a write\n to each record holding it, a block at a time. A card whose value is no option goes to Uncategorized, not off\n the board.\n- **SvGrid Base: views show the data.** A board, calendar, timeline and gallery follow an undo and a record edit\n at once. Calendars and timelines leave undo to the base, so a drag is one Ctrl+Z and not two that cancel out.\n- **SvGrid Base: sort, filter and group apply again after an edit**, holding a grid row only while it is the\n active row, and the count follows. An undo reaches a record the view no longer shows.\n- **SvGrid Base: the bulk bar is part of a base.** Ticking records shows it, with Delete, in every template,\n and never the developer note. `selectionBar={false}` turns it off.\n- **SvGrid Base: a formula reads names.** `{Account}` and `{Owner}` give what the cell shows, not record and\n user ids.\n- **SvGrid Base: deleting a field says what it drives**, by view and automation. A view asks in its own row, goes to\n the trash, and is one step of undo. A field deleted from a view no longer leaves it saying \"Colored by field\".\n- **SvGrid Base: columns resize and move by drag** by default, and a restored field goes back to its place.\n- **SvGrid Base: Hide fields keeps its rows still** while fields are switched.\n- **SvGrid Base: the warning for a type change sits next to Save**, in sight.\n- **SvGrid Base: comments can be edited and deleted by their author.** `update` and `remove` on a comment store.\n- **SvGrid Base: activity stays true.** An undo and a redo are noted, and a local edit shows old to new.\n- **SvGrid Base: Timeline is in Create in every base**, its renderer loading on demand, and the roadmap template's\n Timeline is one.\n- **SvGrid Base: a form builder.** \"Customize form\" sets the title, the words and the fields, their order and which\n are required. An empty form does not send.\n- **SvGrid Base: Space on a group row opens nothing**, where it opened an empty record that lost what was typed.\n- **SvGrid Base: smaller things.** The link picker takes arrows and Enter and keeps its size, and a second click no\n longer closes it. A link cell selects on the first click. One click sets a rating in a form. Next and Previous on a\n card walk the board. Find and the field type search take the focus. A\n header opens its menu on a right click. New groups start open. The row height menu marks the current height. A\n multi-day event's tooltip says its days.\n- **The schema is the whitelist, for reads and writes (breaking).** `createSqlDataSource` names\n the schema's columns in every `SELECT` and `RETURNING`, and drops every key off the schema\n from a write. A group level off the schema is refused with `leafCounts` too. A trusted\n source in the same process as the page can ask for the old behaviour with\n `wholeRecords: true`; `createKitHandlers` refuses to start on one.\n- **Nothing a client sends reaches a private key.** `createKitHandlers` strips `__svgrid*` keys,\n keys off the schema and `readonly` fields before `authorize`, `validate`, hooks and the\n source see the row, so a write can no longer cross a `scope` or swap a validated value. A\n write left with nothing is a 422. A `scope` field off the schema refuses the request.\n- **Handlers no longer send driver text (breaking).** A failure is logged on the server and the\n client gets a plain message. A record that is gone is a 404 with `code: 'row-not-found'`,\n which `createKitDataSource` keeps on its error. A request off the schema is a 400 that says so.\n- **`createBaseEndpoint` starts closed (breaking).** It refuses to start without `authorize` or\n `public: true`, and without `tables` or `allTables: true`, with a message that says what to do.\n `GET` asks `authorize` and describes only the tables it allows. A table `authorize` gives no\n guard for is closed. It takes `scope`. Columns named like a credential stay out of a base\n (`hide`, `isSecretColumn`): never the primary field, never sampled as options, and through the\n endpoint not read or written. A field with `hidden: true` is no field of a base.\n- **A record's text cannot name a secret.** A webhook fills its URL, headers and body in one pass,\n so `{secret:DATABASE_URL}` typed into a field goes out as that text.\n- **Server webhooks stay off internal addresses (breaking).** `createAutomationServer` refuses\n private, local and link-local addresses, by name and by what the name resolves to, and does not\n follow redirects. `allowInternalWebhooks: true` opts out.\n- **A PDF preview runs nothing.** A file is read first and framed as a copy typed by us, only if\n its bytes are a PDF. An HTML file calling itself a PDF offers a download.\n- **Hidden fields and tables stay out of search, Download as SQL and the row number tooltip.**\n `lockViews={false}` on `SvBase` is honoured with `tables`. `permittedRecords` is what to send\n from a server; `permittedTables` keeps hidden values in its records, and the docs no longer\n point at it for that.\n- **A CSV is read for what it is.** The separator and encoding are found and shown to change. A\n quote inside a word is text, and a quote never closed no longer swallows the file. Rows that do\n not fit the header, values a field cannot hold, records that repeat a name, a file that is not\n UTF-8 and one that is not text are all reported before the import. A decimal comma stays a\n decimal, and `1,50` is no longer read as 150. `readImportMatrix` returns `delimiter`,\n `encoding` and `warnings`. Errors from a bad .xlsx or JSON file read as sentences.\n- **Large tables.** Import, summaries, dashboards, chart axes, rollups, pivots and spreadsheet\n ranges no longer throw `Maximum call stack size exceeded` past about 120,000 values (`maxOf`,\n `minOf` in place of `Math.max(...values)`).\n- **Download a view.** The list of tables has CSV and Excel downloads of the shown view: its\n fields and records as they read on screen, formulas, links, people, checklists and attachments\n included. `recordsAsShown` gives the same in code.\n- **Smaller holes.** A protected field is not asked in a form of someone not on its list. A paste\n outside a select's options is not written. Rich text in a base keeps no `class`, and an image on\n another site becomes a link instead of a request. A color from data that is more than a color\n is dropped. JSON import no longer fills `constructor`-like columns from the prototype, and a key\n first seen late in a file is a column.\n- **SvGrid Base: opening a cell and leaving it writes nothing.** A number, bigint,\n time, timestamp, date or JSON value used to be rewritten as the editor showed it.\n- **SvGrid Base: a number is stored as typed.** 19.99 in a field that shows one\n decimal stays 19.99; only an integer field rounds. A number past 15 significant\n digits stays exact as text, in the cell, the box and the write. A rollup with a\n `precision` keeps the linked field's symbol.\n- **SvGrid Base: dates and times no longer change with the browser's zone.** Dates,\n times, bigints and decimals are read as the database writes them, so a naive\n timestamp shows one wall clock everywhere, a typed time keeps it, and an undo or\n restore writes back what was read. On PostgREST a bigint past 2^53 is read again as\n text.\n- **SvGrid Base: dates read as people type them.** `12/24/2026`, `2026-12-23`,\n `Dec 22, 2026` and `12/21` all work in the new date editor (`fieldDate`), and text\n that is no date says so.\n- **SvGrid Base: cell keys.** Enter on a selected cell opens its editor, a key typed on\n a date or link cell starts editing, and Space ticks a checkbox cell.\n- **SvGrid Base: JSON in a text field shows as JSON** instead of `[object Object]`, and\n the Delete key leaves NULL as NULL and empties a number or date column without an error.\n- **SvGrid Base: a record added or deleted survives a view switch.** On a table the page\n holds, the grid went back to its `data` on any option change, so records added (by the\n row, Duplicate, a Kanban card, a form) vanished and deleted ones came back. What the\n grid holds is now what it is handed.\n- **SvGrid Base: Undo and Redo leave a teammate's cell alone.** A cell changed since keeps\n the later value and the page says so, cell by cell in a paste. Without a live feed the\n page reads the record first.\n- **SvGrid Base: a record's way back is whole, and safe.** Undo and restore on a table the\n page holds write every column read, under the record's own key, and the record stays in\n the trash until the database has it; a failed undo can be pressed again. A restored\n record whose Autonumber was given out again takes the next one.\n- **SvGrid Base: the trash gets the record as it is at the delete.** A delete reads the\n records at that moment, also after a confirm dialog, and a record moved out of a bulk\n choice while the question stood stays.\n- **SvGrid Base: typing is safe from teammates.** Changes from others, by feed or by a read,\n wait while a cell editor is open, so what is typed is not cut short. If the record went\n meanwhile, the person is told, with their text.\n- **SvGrid Base: a delete that did not happen is not reported as done.** One a row-level\n policy skipped, or the database refused, stays in the table and out of the trash, and the\n notice comes after the delete, not before.\n- **SvGrid Base: failures a person can act on.** A failed write names the record and the\n field in plain words, shows what was entered and offers Try again; \"Not saved\" stays until\n that record is written. A write with no answer warns and then lets the rest go\n (`writeTimeout`).\n- **SvGrid Base: Ctrl+Z of a new record on `NOT NULL DEFAULT ''`.** An emptied cell goes back\n to what the database gave it, not to NULL.\n- **SvGrid Base: the trash tells the truth.** With nothing keeping it, the panel says items go\n with the page.\n- **Supabase: the find box takes `%`, `_`, commas, quotes and brackets as text**, and a table\n with text keys can add records with default options.\n- **SvGrid Base, smaller things.** The selection bar counts on a table the page holds, a draft\n shows no number until it has one, and a write coming back in the database's words (`5.00`\n for 5) is nobody else's change.\n- **SvGrid Base: a group on a date opens on its records.** On Postgres and MySQL the\n key of a date field's group went through a JS Date, so it lost what is past the\n millisecond and took the page's zone, and outside UTC the group read nothing. The key\n is now text the database writes and compares. A delete can also leave out any group\n at any level: every source reports a group's records as `leafCount` when a base asks.\n- **SvGrid Base: two people adding at once do not share an Autonumber.** They could get the\n same number. Each record is checked once stored and the later one moves on; a UNIQUE\n column refuses the second and the write tries the next number.\n- **SvGrid Base: Undo of an added record keeps a teammate's work.** One someone has\n changed since stays, with a message, and Redo does not add it twice. Redo of a delete\n puts the records in the trash as they are now, not as they were.\n- **SvGrid Base: Undo brings times back exactly.** A delete reads time columns as the\n database writes them, so microseconds and a local time the clocks skipped survive on\n every Postgres and MySQL driver. `dateStrings` is no longer needed.\n- **SvGrid Base: Undo works on a server in any language.** Generated columns are read\n from the schema and left out before a write, and a refusal is told by its error code.\n `createSupabaseDataSource` keeps the code on the errors it throws.\n- **SvGrid Base: Undo leaves other people's work alone.** Undoing a step on a table held\n in the page put back a snapshot of all its records, which took out whatever teammates\n had changed since, and wrote that to the database. A step now undoes what it did and\n nothing else, and a new record closed empty takes only itself out.\n- **`createSqlDataSource` on MySQL.** Writes ended in `RETURNING`, which MySQL does\n not have, unless you set `returning: false`. That is now the default there. A\n record with an auto-increment key now gets the key the insert made.\n- **Formula text in SQL.** A string in a formula could break out of its literal on\n MySQL through a backslash, and a pivot key from stored data the same way. Both are\n closed, on every dialect.\n- **Formulas in SQL say what a cell says, or leave it to the page.** Functions whose\n results differ between a database and a cell (`UPPER`, `FLOOR`, `TODAY` and others,\n listed in the docs) no longer run in SQL.\n- **`createSqlDataSource`:** a filter on a column the plan does not know is an error\n and not a wider answer; `in` with an empty list matches nothing; `notEquals`,\n `notContains`, `endsWith`, `isNotBlank` and `notIn` run as themselves and no longer\n as `contains`; a blank group key matches NULL and ''; `updateRow` on a record that\n is gone is an error with `code: 'row-not-found'`; `createRows` keeps a column's\n default. A filter or sort on a field added at run time works.\n- **SvGrid Base:** a write the database refused no longer reads as saved after a later\n edit; records in the trash leave it only once they are proven back, whole, with the\n columns the base shows no field for and under the key they had; times go back as they\n came on MySQL and on Postgres; junction links come back with a restored record and\n survive a refused delete; a table whose records have no id of their own no longer\n breaks the grid or the trash; writes still queued\n when the page leaves finish, and the browser asks first; a form says so when the\n database refused the record; a field named ID no longer writes over the record's\n key; a formula edited on a big table runs at once, in the database too.\n- **Scrolling a very long list.** In a gallery, list, board lane or timeline past the\n height a browser scrolls, the scrollbar and the list stopped agreeing near both\n ends. A scrollbar step there now moves the list by the same step.\n- **SvGrid Base: a table of a million records scrolls without stalls.** With\n `serverRows`, the view bar counted records by reading every row of the\n server row model, each one made on read, on every block that arrived; the\n record view looked for its record the same way. The count now comes from\n the server (`rowCount`, and the top groups' counts when grouped), and the\n record view looks near the row it was opened from first. Number, currency\n and date cells also keep their `Intl` formatters instead of building one\n per cell. In demo 723 (a dev build, one laptop), 40 wheel steps went from 9.3 s of blocked main\n thread to about 0.1 s, and opening the filtered view from 6.5 s to 0.5 s.\n\n- **SvGrid Base: switching views on a big table no longer freezes the page.**\n A grouped view on `serverRows` set a row height per row and opened its\n groups, and both read every row of the row model; now it keeps one height\n and leaves server groups closed, since each opens with a request. A board\n of more than 200 records draws only the cards in sight in each lane (the\n board measures a card when `cardHeight` is not set). The board also keeps\n each card's key instead of working it out on every read. In demo 723 (a dev\n build, one laptop), the slowest switch went from 3.2 s to 0.4 s.\n\n- **SvGrid Base: a view that left out part of its state kept the last view's.**\n A view declared with only `grouping` took over the sort, hidden fields and\n other state of the view before it. Whatever a view's `state` leaves out\n now starts plain. A saved view is unchanged: it stores all of it.\n\n- **SvGrid Gantt: the task table's header stays at the top.** It scrolled away\n with the rows in any plan taller than the chart.\n\n- **SvGrid Base: a record past what a table read was taken for a deleted one.**\n When a table on a `source` was read again at its limit, a record that had\n moved past the limit was dropped from the page and reported as deleted.\n A read at the limit now keeps the records it did not see.\n\n- **A pivot filtered its rows again for every column.** For each row group,\n `createPivotModel` went through the group's rows once per column-axis leaf.\n The rows are now bucketed by column path in one pass, in the same order,\n and the result is the same. On one laptop, a pivot of 100,000 rows over\n Year x Month went from 3.6 s to 0.6 s, and 1,000,000 rows from 147 s to\n 4 s.\n- **A grouped Excel export slowed down with the square of its rows.** The\n writer looked up each string cell's shared-string index, and checked the\n group rows already written, by scanning an array. Both are hash lookups\n now and the file is byte for byte the same. A 10,000-row export grouped by\n five columns went from 4.8 s to 0.45 s, and 100,000 rows finish in 9 s.\n- **A sheet chart hung below the window was not drawn until a scroll.** The\n sheet measured its objects once after mount, from their anchor cells, and\n the grid now adds most of its overscan rows a frame after its first paint;\n a chart hung from a row in between had no cell to measure. While an object\n has no box, rows the grid adds now measure it again.\n\n- **A wide grid lost columns in the PDF.** pdfmake sizes a column no narrower\n than its longest word, so a 22-column report ran off the right edge and only\n 15 columns printed, without a warning. The columns are now fitted to the\n page (see `pdf.fit` above).\n- **A row taller than a page was missing from the PDF.** Rows are kept whole\n on a page, and pdfmake drops a row that cannot fit on any page. Such a row\n now breaks across pages.\n- **Conditional-format icons printed as empty boxes in the PDF.** The arrow,\n triangle and traffic-light glyphs are not in Roboto; they are drawn as\n shapes now.\n- **The PDF footer could show yesterday's date.** It printed the UTC date, so\n an export after midnight east of Greenwich was dated the day before. It\n prints the local date, and the footer follows custom page margins.\n- **Grouped PDFs dropped conditional formatting and links.** They now carry\n both, as flat exports do.\n- **Booleans printed as \"true\" and \"false\" in the PDF.** They print a tick or\n nothing, like the grid's checkbox. An icon set's `iconOnly` is honoured too:\n it printed the value next to the icon.\n- **A number or date column passed in `columns` without `align` printed\n left-aligned in the PDF.** It right-aligns from its `format`, as on screen.\n- **A pivot chart drew an empty cell as a zero bar.** An average over no rows\n is `null` in the pivot and the bridge read it as 0; it is a gap on the\n chart now. A sum over no rows stays the 0 the engine wrote.\n\n- **PDF export depended on pdfmake's fonts registering themselves.**\n `pdfmake/build/vfs_fonts` registers its font map only as a side effect of\n being imported while a global `pdfMake` already exists, and the export's\n own lookup for the map never matched the shape the module has shipped since\n pdfmake 0.2.8 (the module is the map), so it registered nothing and relied\n on that side effect. Under a bundler the global can be a stale instance (a\n dev server re-optimising its dependencies mid-session is enough), and the\n export then failed with \"File 'Roboto-Medium.ttf' not found in virtual file\n system\" while its promise never settled. The map is now found in every\n shape the module has had (`resolvePdfVfs`) and handed to the instance that\n creates the document (`registerPdfFonts`, through `addVirtualFileSystem`\n and the `vfs` property), and an installed pdfmake whose fonts module has\n no map is reported instead of failing later.\n- **Studio emitted no theme for the fragment export and the CLI `add`\n scaffolds.** Only the full app's `+layout.svelte` carried the `--sg-*` tokens;\n `eject --fragment` (which drops that file) shipped an `app.css` with one\n hard-coded accent, and `svgrid-studio add` / `add --all` wrote none at all. The\n tokens now come from one helper (`themeTokenCss`): `src/app.css` carries them\n for the full app and the fragment, and the `add` scaffolds emit them in\n `<svelte:head>`. Drop-in outputs wrap them in `@layer svgrid-studio`, so a host\n app that already defines its own tokens keeps its look. `add` also honours\n `--theme` / `--dark`, and a project with no theme picked gets Ember (the demo\n theme) instead of Tailwind.\n- **Scheduler column alignment.** The all-day lane, day/time-grid header, and\n body columns now reserve the scrollbar width consistently, so the columns line\n up instead of drifting by the scrollbar's width.\n- **Excel export color-scale conditional formatting.** A color scale's `min` /\n `mid` / `max` are optional, so the export could build an `(string | undefined)[]`\n where a `string[]` was expected; it now falls back to the same `#ffffff` /\n `#000000` defaults the grid renders with. Because `@svgrid/enterprise` ships its\n `src`, this had surfaced as a stray `svelte-check` error in consuming apps - a\n clean app now type-checks with zero errors.\n\n#### Security\n\n- **SvGrid Base: a pair table with the tenant in its key could be read and changed by another tenant.**\n On `order_tags (tenant, order_id, tag_id)` with `tenantColumn` and a scope, the pair id a client sent\n overwrote the scope's tenant, so an editor of tenant B read tenant A's pairs by id and deleted them\n with `delete` and `deleteMany`, on Postgres, MySQL and SQL Server. The scope now wins: an id naming\n another tenant's pair reads nothing, and a delete of it is a `403`, as on a `{ through }` pair.\n- **SvGrid Base: a `{ through }` pair read could hand out another tenant's key.** A pair written\n straight into the database between tenant A's order and tenant B's tag reached A in raw rows. A read\n of a junction (a pair table, or one with its own key) now leaves out a row whose other end is a record\n of another tenant, where that end's table holds its own tenant column. Delete forever still clears\n such a row.\n\n- **A crafted .xlsx could crash the tab.** `importData` and the spreadsheet's\n File > Open filled every gap before a cell with blanks, sized by the cell\n reference in the file: `<c r=\"ZZZZZZZ1\">` asked for about eight billion.\n `importData` now rejects a cell past column XFD; the spreadsheet skips a cell\n outside the sheet, as it does other malformed parts. Both refuse a sheet that\n would need more than ten million blank cells to lay out.\n- **A zip bomb could exhaust the tab's memory.** Every .xlsx and .ods reader\n (`importData`, File > Open, `documentFromXlsx`, `documentFromOds`) unzipped\n each part whole before looking at it, so a small file whose parts inflate to\n gigabytes was read into memory first. Parts are now unzipped as a stream and\n counted as they inflate; a file whose parts pass 256 MB together is refused\n at that point.\n- **CSV and TSV from `exportData` neutralise formula-like text**, through the\n same `@svgrid/grid` serializer (see the grid's Security entry).\n\n### @svgrid/grid-wc\n\n#### Added\n\n- **`<sv-chart>`**, the standalone chart as a custom element, at\n `@svgrid/grid-wc/chart` with React (`/react/chart`), Vue (`/vue/chart`)\n and Angular (`SvChartComponent`) wrappers. Its surface is generated from\n `SvChart`'s own props type the way `<sv-grid>`'s is from the grid's, so the\n 26 props and 7 events stay in step; `spec` is a property, the primitives\n are attributes, and a prop that takes a boolean or a string (`legend`) keeps\n a string attribute where a bare attribute means true. Its own build in\n `dist/chart` carries none of the grid.\n- **Typed event handlers.** Each wrapper's `on<Event>` prop used to be\n `(detail: unknown) => void`, so reading `newValue` meant casting first -\n a poor advertisement for a typed wrapper. The detail type is now lifted from\n the grid's own callback signature, so 16 of the 19 events arrive fully typed\n (`TData` degrades to `Record<string, unknown>`; anything referring to a\n type that only exists inside `@svgrid/grid` stays `unknown` rather than\n naming something a consumer cannot resolve).\n\n- **React, Vue and Angular components**, as subpath imports:\n `@svgrid/grid-wc/react`, `/vue` and `/angular`. Each is generated from the\n same surface as the elements, so all 98 properties and 20 events are typed\n props on every one of them and none can drift from the grid. Each framework is\n an OPTIONAL peer dependency, so a plain-HTML consumer installs none of them,\n and the wrappers are 1.3-3.7 KB gzip because they reuse the one element bundle\n rather than shipping a second copy of the grid.\n\n They exist because a raw custom element is genuinely awkward in each:\n **React 18 and earlier stringify object props onto attributes**, so\n `columns={cols}` silently becomes `\"[object Object]\"` and the grid renders\n empty; **Vue** needs `isCustomElement` build config and a `.prop` modifier\n on every object binding; **Angular** needs `CUSTOM_ELEMENTS_SCHEMA` in every\n component that shows a grid, and gets no typed inputs. The Angular wrapper is\n compiled with ng-packagr in partial-Ivy mode, so it is consumable by a normal\n Angular build, and its selector is the element's own tag - `<sv-grid>` and\n `<sv-grid-shadow>` - with no template of its own, so there is no extra wrapper\n element in the DOM and the tag is the same one you write in plain HTML.\n\n All three also handle two ordering problems a hand-written wrapper meets:\n the element renders BEFORE a framework assigns properties in an effect, and\n `apiready` fires once during that first mount - before React can bind a\n listener at all. The handle is parked on the element and each wrapper replays\n it.\n- **The package ships TypeScript declarations.** It previously had none, so\n `import '@svgrid/grid-wc'` was an error under `moduleResolution: bundler`\n and `document.querySelector('sv-grid')` came back as a bare `Element`. The\n generated `.d.ts` augments `HTMLElementTagNameMap` and\n `HTMLElementEventMap`, so the element and its events are typed without\n hand-written declarations.\n- **`<sv-grid-shadow>` - the grid in an open shadow root**, so a host page's\n CSS cannot reach it. Same properties, attributes and events as `<sv-grid>`;\n a separate element rather than an attribute because Svelte resolves\n `customElement.shadow` at compile time, so no runtime flag can switch it.\n Isolation is one-directional and the docs say so: page CSS stops at the\n boundary, but the grid's own stylesheet is still injected into the document,\n because about twenty overlay surfaces portal to `document.body` on purpose\n to escape ancestor clipping. `--sg-*` theme tokens reach in unchanged,\n including a theme file's dark variant - custom properties are inherited, and\n inheritance crosses a shadow boundary.\n- **The elements now expose the whole grid.** `<sv-grid>` declared **7 props\n and 2 events** by hand against a `Props` type with 100 props and 19\n callbacks, so grouping, pagination, pinning, tree data, master/detail, board,\n scheduler and every Enterprise feature were unreachable from a non-Svelte\n host - while the docs said they \"all come along\". The surface is now\n **generated** from `<SvGrid>`'s own types: **98 properties** (72 with\n kebab-case attributes, 26 property-only) and **20 events**, with CI failing if\n the two drift. Costs 1.6 KiB gzip.\n- **Every grid callback is a DOM `CustomEvent`**, `detail` being the\n callback's argument - or, for the one callback taking two, an object keyed by\n its parameter names. `onApiReady` also parks the imperative handle on the\n element as `el.api`, because an event fires once and a host binding a\n listener later would otherwise never reach it.\n\n#### Fixed\n\n- **Importing the package on a server threw `customElements is not defined`.**\n Svelte registers each element with a bare top-level\n `customElements.define(...)`, so any server-rendered React app\n (TanStack Start, which Lovable now generates, Next.js, Remix) crashed on\n `import { SvGrid } from '@svgrid/grid-wc/react'`. The build now guards the\n registration; on a server the import is inert and SSR emits a plain\n `<sv-grid>` that upgrades on hydration. Guarded by `test/ssr.test.ts`.\n- **The React wrapper lost props the grid reads once at mount.** It wrote\n props in a passive `useEffect`, which runs after paint; the element mounts a\n microtask after insertion, so it had already mounted with defaults and\n `pageSize={25}` showed 10 rows a page (the wrapper's own pagination example\n did). Props are now written in a layout effect, before the element mounts.\n The same change in the `<sv-chart>` wrapper.\n- **`style` on the React wrappers took `Record<string, string | number>`,** so\n passing a React `CSSProperties` object failed to type-check. It is\n `CSSProperties` now.\n- **The React wrapper re-did all its work on every parent render.** Both of its\n effects had no dependency array, so any state change anywhere in the parent\n reassigned all 98 properties and rebound all 20 event listeners - 40 listener\n mutations per keystroke. It now writes only values that actually changed and\n binds listeners once through a handler ref. Measured: 20 no-op re-renders\n produce 0 listener adds, 0 removes and 0 property writes.\n\n- **The element threw when it rendered before its props were assigned.**\n Generating the prop list replaced the elements' own `data = []` /\n `columns = []` defaults with a bare `$props()`, so a consumer that assigns\n properties AFTER the element upgrades - which is what React and Angular both\n do, in an effect - got\n `TypeError: Cannot read properties of undefined (reading 'map')` and a grid\n that never rendered. Only a real framework app was late enough to reproduce\n it; an HTML fixture sets the properties in the same tick and never sees it.\n\n#### Changed\n\n- **Only arrays, objects and functions changed shape: they are property-only.**\n An HTML attribute is a string, so `columns='[object Object]'` cannot work\n and no attribute is offered for the 26 props that are not primitives. The\n published `rowclick` and `selectionchange` events keep the exact\n `detail` they shipped with, and `selectable` keeps meaning row-selection\n checkboxes - `<SvGrid>`'s prop of that name is an alias of\n `enableCellSelection`, and forwarding it would have silently repointed a\n published attribute at a different feature.\n- **Styles arrive with the code that needs them.** The build used to put every\n stylesheet in the bundle, lazy chunks included, into the entry, so a page\n that never opened the chart, a date picker or a menu still downloaded their\n CSS. Each chunk now carries its own styles and adds them to the document\n and to every open shadow root when it loads. `<sv-grid>`'s entry went from\n 107 KiB to 98.5 KiB gzip while the chart grew.\n\n### Tooling & docs\n\n#### Added\n\n- **Every chart gallery demo switches between Chart and Grid.** A segmented\n control first in each demo's toolbar flips every pane to a sortable grid\n of the rows the chart was drawn from, and back, the way the board demos\n switch Board and Table. The from-the-grid page shows the pattern in a\n runnable.\n\n- **Charting a pivot is documented.** The pivot page has a section on\n `pivotToChartSpec` (the mapping, every option, a runnable that pivots\n orders and charts them by quarter) and on the designer's Chart view\n (`chartable`, `defaultView`); the charts hub and the from-the-grid page\n link to it, the /api pivot section lists the function, and the generated\n reference covers `pivot-chart.ts`. Demo 359's data now puts every\n country in every quarter and category, so its groups are four bars, not\n one.\n\n- **27 runnable framework examples**, nine each for React, Vue and Angular:\n a first grid, sorting and filtering, editing and saving, row selection,\n grouping and totals, pagination, server-side data, theming, and Excel export\n from the Enterprise pack. Every one has\n an **Open in StackBlitz** button that boots a full editable project - no local\n install - and a new\n [React, Vue or Angular](/docs/help/web-components/frameworks) landing page\n puts the thirty-second path first.\n\n They are real apps in the repository (`packages/grid-wc/examples/`), not\n snippets, and CI compiles all of them with each framework's own compiler -\n including `ngc --strictTemplates`, so a wrong Angular binding fails the\n build. The doc listings are generated from those files, so a page cannot\n describe a version of an example that no longer exists.\n\n The Vue templates get an extra check of their own: Vue treats an unknown\n attribute as a legal fallthrough, so `<SvGrid sortabel />` type-checks\n cleanly and silently does nothing. Verified - the same typo fails the React\n and Angular compilers and passes `vue-tsc` - so the Vue examples are also\n checked against the generated surface.\n\n- **A Web Components docs category.** Eight pages under\n `help/web-components/` - quick start, a generated `<sv-grid>` reference,\n shadow DOM, React, Vue, Angular, TypeScript and limitations - replacing a\n single page that was filed under \"Layout & Styling\". The reference tables are\n generated from the grid's types, and a guard checks that the counts quoted in\n prose still match the surface.\n- **The docs run.** A `svelte` code fence tagged `{runnable}` is extracted at build time\n into a real component, so a doc page shows the source and the working result\n together rather than highlighted text. 504 examples across the corpus, taking\n the median doc page from 1 example to 3; each one is compiled by `svelte-check`\n in CI, so an example that stops working fails the build instead of rotting in\n place.\n- **`@svgrid/ui` recipe scaffolder** - `npx @svgrid/ui add <component>` drops a\n ready-to-edit starter (e.g. `add calendar`) into your app, complementing the\n shadcn-style component pages (Preview / Code, install tabs) across the UI kit.\n- **See a component before you wire it in** (`@svgrid/ui` 0.3.x).\n `npx @svgrid/ui try <component>` spins up a zero-setup Vite + Svelte sandbox and\n opens the component in your browser; `add --preview` writes a\n `src/routes/preview/<id>` route (plus a `/preview` index) in a SvelteKit app.\n `add` now installs `@svgrid/grid` by default (`--no-install` to opt out) and\n prints the exact `try` command for whatever you just added, so the \"see it\"\n step is never a dead end.\n- **AI coding Skill** (`skills/svgrid`, installable with\n `npx skills add sv-grid/sv-grid`) - an always-on house-style guidance layer\n that complements `@svgrid/mcp`.\n- **The rest of the toolkit is findable.** `packages/grid/README.md` gained an\n \"Also in the box\" section, and the site footer gained a **Toolkit** column\n (SvGrid UI, Kanban board, Scheduler, Dock layout, Studio, Web components).\n The 84 SvGrid UI components have always been exported from `@svgrid/grid`\n itself - `SvButton`, `SvCalendar`, `SvDateTimePicker`, `SvDockLayout`,\n `SvToaster` and the rest are already installed for every grid user - but\n nothing on the highest-traffic surfaces said so.\n\n#### Changed\n\n- **Doc examples show code and result at once.** The runnable card used to be a\n Preview / Code toggle with an in-page editor; it is now the source above the\n live example, both visible, with Copy. A tab hides half of a teaching example\n and makes comparing the two a click, and dropping the editor took the\n on-demand TypeScript compiler chunk off every docs page with it.\n- **`npm create @svgrid` starts on Ember** (the demo theme) instead of Tailwind,\n for every template; `--theme <id>` still picks any preset. The `sveltekit`\n template is now listed on the starters page, and the `sv add @svgrid` demo route\n imports the Ember stylesheet so it no longer renders unthemed.\n\n#### Fixed\n\n- **The base scaffold lists `jszip`**, so \"Download this view as Excel\" works in a new app. Its README no\n longer says a new table appears on reload with the Postgres setup: that route reads the tables once\n per server process, so restart it or call `refresh()`.\n\n- **14 doc examples drew an empty or broken box under their code.** Every\n `{runnable}` block was run against the published packages in a clean Vite\n app. Five needed a SvelteKit load, an `/api` server or a WebSocket (two\n showed \"This example failed to load.\" on svgrid.com) and one is a component\n file that needs props; they are now `{norun}`, a new fence flag: still\n type-checked, never mounted, never promoted back to runnable. The other\n eight now run: the custom header, the real-time cell flash, the\n inline-snippet cell renderer, and the alert, loading-overlay, scroll-area,\n sparkline and toaster examples. The toaster page also said hidden toasts\n appear as room frees; their timers keep running while hidden, which the\n page now says.\n- **`build:lib` in the enterprise package deleted the node bundle.**\n `svelte-package` wipes `dist/`, so a library build alone removed\n `dist/node/studio.js` and the MCP server failed to start until\n `build:node` was run by hand. The library build rebuilds the bundle it\n removed.\n\n- **Docs images and tutorial media 404'd under a site base.** The markdown\n writes them root-absolute (`/docs-media/...`, `/tutorials/...`), which is\n right at svgrid.com and wrong under the `/sv-grid/` base the e2e server\n uses: every docs image and tutorial poster was missing there. The page\n prefixes the base in the HTML before it paints, and an e2e spec loads a\n page with both and checks nothing under those roots 404s.\n\n- **Twenty-one links on the chart pages went to GitHub 404s.** The split\n wrote every cross-link with one `../` too many, and the site's link\n resolver falls back to a GitHub URL for a page it does not know. Fixed on\n the pages, and every relative link under docs/ is now a test\n (`tools/docs-relative-links.test.ts`); the link checker existed but only\n ran by hand before a release.\n- **Links into the generated reference tree went to GitHub too.** The tree\n is hidden from the docs routes; a link to it lands on the /api page, on the\n module's section where it has one.\n- **The chart gallery said \"the source is under each example\" and it was\n not.** Each gallery card now carries the demo's own script and markup on a\n Code tab, written by `tools/gallery-doc-code.mjs` from the demo file and\n guarded by a drift test, so the code beside a preview is the code that\n renders it.\n- **A demo page flattened a bulleted banner into one paragraph**, dashes and\n backticks included. The page reads the pitch as blocks: a list where the\n banner wrote one, `<code>` where it wrote backticks, on the prerendered\n and the hydrated page alike.\n- **`demo-doc-embed` skipped a demo the page only linked to**, so a\n placement for it never landed, and it opened a new \"More examples\" section\n below \"See also\", which the coverage test requires to be last. Present\n means embedded, and the section opens above \"See also\".\n- **Regenerating the doc snippets took the dev server's file watcher with\n it.** The extractor removed and recreated its output directory, and on\n Windows the watch did not re-attach, so an edited runnable kept serving\n its old chunk while the source beside it showed the new code. It writes in\n place and removes only what no longer belongs.\n- **The Getting started chart page had no live example.** Its code blocks\n were `ts` and a Svelte block referencing rows it never declared; four of\n them run now, and the hub's first example runs with its own rows and a\n filter row, so the chart is seen following the grid.\n\n- **The e2e suite adopted any server on :5180.** Playwright reuses whatever\n answers on the port, and a Vite dev server returns the app shell for any\n path, so a website dev server started by hand (base `/`) passed the\n readiness check and the fourteen path-routed and module-importing specs\n failed with nothing pointing at the server. The config now probes the port\n first (`tests/e2e/lib/site-server-probe.mjs` reads the base off Vite's\n client script tag), reuses a server that serves the site under `/sv-grid/`,\n skips one that serves anything else with a line saying so, and starts its\n own on the next free port; `SVGRID_E2E_PORT` pins one.\n- **The website dev server re-optimised dependencies mid-session.** The\n search index, the docs renderer, the /api runner's compilers, the PDF\n exporter and the grid's `esm-env` sit behind dynamic imports the start-up\n scan does not reach, so the first page to touch each one triggered\n \"optimized dependencies changed. reloading\" on every open page. In the e2e\n suite that reload landed mid-test on a cold cache and failed whichever spec\n was on a page at the time. They are pre-bundled at start-up now\n (`optimizeDeps.include`), and `esm-env` is a declared devDependency of the\n website so it resolves from there.\n- **The /api runner check sampled an example's outcome two frames after\n Run.** An example awaiting an export or a fetch was still running, so a\n failure that arrived later, or one thrown inside a library callback the\n runner's try/catch cannot see, passed. The check now waits for the runner\n to report an outcome and counts an uncaught error or rejection during the\n run as a failure of that example.\n- **181 doc pages had content stranded below \"See also\".** Authoring passes\n appended new sections to the end of the file, which buried them under what\n reads as the page footer: on `help/filtering/number-filter`, for instance, the\n `between` example sat below the link list and a reader would never reach it.\n The footer is back at the bottom on every page, and a test now fails if a\n section lands under it.\n- **The documented way to lock one column's width never worked.**\n `docs/help/columns/column-sizing.md` matched headers on `data-col-id`, which is\n the attribute on *body* cells - the selector matched nothing. Header cells\n carry `data-svgrid-header-col`. (`ColumnDef.resizable` is now the real answer.)\n- **`blockKey` was missing from `tools/lib/md-snippets.d.mts`.** The function was\n exported from the `.mjs` and worked at runtime, so nothing caught it until the\n website was type-checked.\n- **`@svgrid/mcp` reports its real version.** The MCP server's\n `serverInfo.version` was hardcoded to `0.1.0`; it now reads the package version.\n- **`@svgrid/create-studio` scaffold builds out of the box.** The generated app\n shipped an orphaned `/products` route referencing an entity that was never\n defined; the `Product` schema, seed, data source, nav, and home card are now\n complete, so `npm run build` succeeds on a fresh scaffold.\n- **API-docs accuracy pass across all 74 UI-component pages.** Corrected the\n `SvDockLayout`, `SvDockManager`, and `SvDateTimePicker` prop tables (added 13\n missing dock-layout props; removed a `size` prop `SvDateTimePicker` never had),\n and filled scattered gaps (`loading`, `onClosed`, `min` / `max`, `dir`,\n `width` / `height`, `ariaLabel`, and the shared field-contract on\n `SvFileUpload`).\n\n### @svgrid/mcp\n\n#### Changed\n\n- **A cold `npx -y @svgrid/mcp` installs 20 packages instead of 111.** The\n server speaks MCP over stdio itself instead of through\n `@modelcontextprotocol/sdk`, whose HTTP and OAuth dependencies (Express, Hono,\n JOSE, AJV) a stdio server never runs. On an empty npm cache the install took\n 6 to 8 seconds instead of 12, which had left little room under an MCP client's\n 30 second connect timeout. The protocol is unchanged: version negotiation,\n errors and every tool, resource and prompt answer as before.\n\n## [1.0.0] - 2026-06-16\n\nInitial public release - the Svelte 5-native data grid: `@svgrid/grid`\n(MIT core) and `@svgrid/enterprise` (the paid feature pack).\n\n### @svgrid/grid\n\n- **New** `onCellValueChange` callback on `<SvGrid>`. Fires after every\n inline edit commits with `{ rowIndex, columnId, oldValue, newValue,\n row }`. The recommended hook for server-side persistence and cascading\n recomputes; see demo `18-cascade-editing` and\n [Saving values](./help/editing/saving-values.md).\n- **New** `externalSort` + `externalFilter` props. Grid records the UI\n state but does NOT re-order / filter rows - the consumer owns the\n pipeline. Paired with `onSortingChange` / `onFiltersChange` for\n server-side data and tree-data scenarios.\n- **New** `onSortingChange(sorting)` / `onFiltersChange(filters)`\n callbacks. Fire on every change with the consolidated payload shapes\n documented in the [SvGrid reference](./reference/SvGrid.md).\n- **New** `onRowSelectionChange(selection, rows)` and\n `onActiveCellChange(cell)` callbacks.\n- **New** `fitColumns` prop. Scales column widths to fill the viewport,\n with rounding-residue absorbed in the last scalable column. Shrinks\n down to 85 % of natural widths; beyond that a horizontal scrollbar\n appears.\n- **New** `showRowNumbers` prop. Leading 1-based row-number column,\n rendered before any selection column.\n- **New** `pageSize` prop on `<SvGrid>`. Initial page size for the\n built-in pager.\n- **Improved** column virtualizer now detects per-item size changes,\n not just total size. Fixes a regression where resizing a column under\n `fitColumns` left other columns stale.\n- **Improved** the wrapper-managed filter pipeline no longer applies\n filters to the pre-paginated view - the filter UI always sees the\n full dataset, not just the visible page. (Removed\n `paginatedRowModel` from the engine pipeline; pagination is applied\n AFTER filters by the wrapper.)\n\n### @svgrid/enterprise\n\n- **New** package. The paid feature pack adds:\n - **Export** to xlsx / pdf / csv / tsv / html, with theme-matched\n styles, multi-sheet workbooks, header + footer with logo, embedded\n cell images. See [Export](./help/export.md).\n - **Print** with repeat-on-page headers, optional cover page,\n page-size + orientation.\n - **Import** from xlsx / csv / tsv / json with column mapping +\n per-row validation. See [Import](./help/import.md).\n - **AI assistant**: provider-agnostic helpers for natural-language\n filter, smart fill, summarize, and classify. Bring your own model\n adapter. See [AI](./help/ai.md).\n - **Pivot tables** via `createPivotModel(data, config)` and\n `pro.pivot.build(config)`. Row + column axes, 8 built-in\n aggregators or custom, grand-total row + column, subtotals,\n custom axis sort. See [Pivot tables](./help/pivot.md).\n- **New** `installEnterprise(api)` augments a `SvGridApi` with `exportData`,\n `print`, `importData`, `ai.*`, and `pivot.*` methods.\n- **Soft-gated licensing**: features run unlicensed but the grid shows\n a small watermark + a one-time console nudge. `setLicenseKey('SVENTERPRISE-…')`\n at app startup clears both.\n\n### Examples gallery\n\n- **New demos** (56-59): theme-matched export, branded export with\n header + footer + logo, export with cell images, multi-sheet export.\n- **New demos** (52-pivot-table, 51-ai-assistant, 53-excel-import):\n reference implementations for each Enterprise feature.\n- **New demos** for industry verticals: stock market (live ticks),\n HR team, finances ledger, industrial IoT, localization, CSP\n compliant, accessibility, cascade editing, server-side rendering,\n industrial dashboard, healthcare EMR, logistics, compliance queue,\n field service, gantt, scheduler, CRM, admin dashboard, seller panel.\n- **New** \"Source\" button on every demo opens the raw `.svelte` file\n in a modal with a Copy-to-clipboard button. Wired via\n `import.meta.glob('../demos/*.svelte', { query: '?raw' })` so it\n picks up new demos automatically.\n\n### Docs\n\n- **New** [Enterprise feature pack](./enterprise/README.md) landing page.\n- **New** [API reference](./reference/index.md) with hand-curated\n pages for `<SvGrid>`, `SvGridApi`, `ColumnDef`, features, and the\n full Enterprise surface.\n- **New** [Why headless?](./why-headless.md) explains the layered\n architecture and when to drop down to the headless core.\n- **New** [Tailwind integration](./help/tailwind.md) walks the\n `--sg-*` token surface, dark-mode wiring via `data-theme`, and the\n override hooks for the stable `.sv-grid-*` class names.\n- **Split** [Getting started](./getting-started.md) into six short\n pages (install / first-grid / data-and-columns / features /\n theme-and-density / going-to-production); the old single-page\n version is preserved at\n [getting-started-full.md](./getting-started-full.md).\n- **Cleaned** every code sample against the live library surface.\n Removed phantom APIs: `state={...}`, `rowModels={...}`,\n `initialState={...}`, `manualFiltering`, `manualSorting`,\n `manualPagination`, `onColumnFiltersChange`, the wrapper `getRowId`\n prop, per-column `enableSorting` / `enableColumnFilter` /\n `enableGrouping` flags, the never-shipped\n `@svgrid/grid/themes/default.css` import.\n- **Em-dashes globally swept to hyphens** (`-` → `-`) across all\n source-controlled text. Codified as a rule for new content.\n\n## How we version\n\n| Tier | What it means |\n| ----------------- | -------------------------------------------------------------------------------------------------------------- |\n| **Major** (1.x) | Breaking change to a Stable API. Includes prop / method renames, type-narrowing, default-behaviour changes. |\n| **Minor** | New Stable API. New Experimental API. New demo. Doc rewrites that touch the public-facing claims. |\n| **Patch** | Bug fixes. Type-only fixes. Internal refactors with no public surface change. Doc typo fixes. |\n\nThe [API stability page](./help/api-stability.md) annotates each export\nwith its current tier (`Stable`, `Experimental`, `Internal`). As of 1.0,\n`Stable` APIs follow semver; `Experimental` APIs may still change in a\nminor release.\n"
4608
4608
  },
4609
4609
  {
4610
4610
  "slug": "compliance/audit-log",
@@ -5178,28 +5178,28 @@ export const docs = [
5178
5178
  "path": "docs/help/base/automations.md",
5179
5179
  "title": "Automations",
5180
5180
  "section": "SvGrid Base",
5181
- "markdown": "# Automations\n\nAn automation does something on its own when something happens to a\nrecord: a task set to Done ticks its Done box, a new request goes to Todo, a\nblocked task tells its owner, a button starts the work. Each table of a base\nhas its own, under \"Automations\" in the view bar.\n\n<div data-docs-demo=\"504-project-tracker\" data-height=\"680\"></div>\n\nIn the demo, set a task's Status to Done, press Start in the Kick off\ncolumn, or send the Request a task form, then open \"5 automations\" and look\nat Runs.\n\n![An automation has three parts: when, only for records where, and do. What an action changes can set off other automations, up to four deep.](/docs-media/base-automation.svg)\n\n## Add one\n\nOpen \"Automations\" in the view bar and press \"+ New automation\". The dialog\nhas three parts:\n\n- **When**: what sets it off.\n- **Only for records where**: a condition written with the view bar's\n filter, so it compares a select's option, a person, a linked record's name\n or \"within the past week\" the way the filter does. Leave it empty for\n every record.\n- **Do**: the actions, in order.\n\n![The Automations dialog: the list of automations with an on/off switch each, and the one picked: when Status changes, only for records where Status is Done, do update the record and show a notice.](/docs-media/base-automations.png)\n\nEvery change is kept as you make it. \"Run now\" tries the automation on the\nrecord you pick, as if its trigger had happened.\n\n## When\n\n| Trigger | Runs |\n|---|---|\n| A record is created | When a record is added: \"+ Add row\", a form, a board lane, a calendar day, another automation. A record brought back by Restore or an undo of a delete is not created, and no rule runs for it |\n| A record changes | When a record is edited; pick fields to run only when one of them changes. A link made from the other table counts: adding a guest to an event from Guests changes the event's Guests field |\n| A record matches a condition | When a record starts to match the condition. It does not run again while the record keeps matching |\n| A form is sent | When a form view sends a record; pick the form, or any form of the table |\n| A button is pressed | When a Button field is pressed on a record |\n| At a scheduled time | Every day at 9, every Monday, every hour, or a cron expression: once for each record that matches the condition then, or once with no record |\n\nA paste or a fill that changes several cells of one record is one change to\nit. An undo or a redo is no change: it runs no automation.\n\n## Do\n\n| Action | What it does |\n|---|---|\n| Update the record | Sets fields of the record that set it off |\n| Create a record | Adds a record to any table of the base; \"Link it back\" fills a link field of the new record with the record that set it off |\n| Show a notice | A toast; `{Field name}` is that field of the record |\n| Color the record while it matches | Colors the whole row, or some fields, for as long as the record matches the condition |\n| Call a webhook | POSTs the record (or a body you write) to a URL: a team chat, your API. Secrets as `{secret:NAME}`, read on the server only |\n| Send an email | To, subject and text with field names; sent by the [server](#on-the-server) |\n| Your own actions | Anything the app adds with `registerAutomationAction` |\n\nA webhook's URL, headers and body name fields in braces, and secrets as\n`{secret:NAME}`; leave the body empty to send the record as JSON. A secret is\nnamed only by the automation: what a record holds is data, so `{secret:NAME}`\ntyped into a field goes out as that text.\n\nFrom the server a webhook does not call private or local addresses (`localhost`,\n`10.x`, `192.168.x`, `169.254.169.254`, a name that resolves to one, an IPv6 form\nthat wraps one) and does not follow redirects. On Node it connects to the\naddresses it checked, so a name cannot answer one way for the check and another\nfor the call; a name that does not resolve is not sent. A `fetch` of your own\npassed to `createAutomationServer` gets the check but not that pin, and neither\ndoes a runtime with no sockets of its own. For a webhook on your own network, set\n`allowInternalWebhooks: true` on `createAutomationServer`.\n\n\n![A server automation that calls a webhook: POST to https://chat.example.com/hooks/{secret:CHAT_HOOK} with the body {\"text\": \"{Task} is blocked. Assignee: {Assignee}\"}.](/docs-media/base-automation-webhook.png)\n\nValues are written as the field shows them:\n\n| Field | Write |\n|---|---|\n| Single or multiple select | The option's name: `Done`, `Bug, Risk` |\n| Person | The person's name: `Ana Ruiz` |\n| Checkbox | `true` or `false` |\n| Number | `42`; in a percent field, `100%` |\n| Date | `2026-11-01`, `today`, `today+7`, `today-1`, `now` |\n| Link | A record's name, several with commas, or `{record}` for the record that set it off |\n| Any text | Text with fields in braces: `{Task} follow-up` |\n| Any field | Nothing, to clear it |\n\n## Runs\n\nEvery run is listed under Runs, newest first, with what each action did and\nthe record it ran on. A failed action stops the run there and says why.\n\nEdit fields on more than 10,000 records asks first, and that question says how many\nruns the change can start in the page and how long they will likely take: at the rate\nruns went in this tab, or, before any did, from how long the server takes to answer. Untick\n\"Also run automations\" to make the change without them. The choice holds for that change\nonly. An automation that runs on the server is not counted and cannot be skipped from here.\n\nRuns in the page go one at a time, in the tab, after the change is saved. From 20 runs on, the top\nbar says how far they are and about how long is left, with a Stop button. Stop drops the runs\nnot started and says how many, and those do not run later. Runs left when the tab closes do\nnot happen either, so the browser asks before it closes. For a change of hundreds of thousands of records,\nrun the automation on the server (`runOn: 'server'`).\n\n![Runs: Task blocked on Paste URLs as attachments showed a notice; Done closes the task on Lightbox preview set Done to checked and Progress to 100%, then showed a notice; Start a task on Docs page set Status to In progress and Start to today.](/docs-media/base-automation-runs.png)\n\n## In code\n\nA table's automations are its `automations`, plain data you can store with\nthe rest of the table:\n\n```ts\nimport type { BaseAutomation } from '@svgrid/enterprise/base'\n\nconst statusIs = (value: string) => ({\n kind: 'fieldFilter' as const,\n conjunction: 'and' as const,\n conditions: [{ column: 'status', kind: 'select' as const, op: 'is' as const, value }],\n})\n\nexport const taskAutomations: BaseAutomation[] = [\n {\n id: 'done',\n name: 'Done closes the task',\n enabled: true,\n trigger: { type: 'recordUpdated', fields: ['status'] },\n condition: statusIs('Done'),\n actions: [\n { type: 'updateRecord', values: { done: 'true', progress: '100%' } },\n { type: 'notify', message: '{Task} is done', severity: 'success' },\n ],\n },\n {\n id: 'blocked',\n name: 'Open an issue for a blocked task',\n enabled: true,\n trigger: { type: 'recordMatches' },\n condition: statusIs('Blocked'),\n actions: [{ type: 'createRecord', table: 'issues', values: { title: 'Unblock {Task}', owner: '{Assignee}' }, linkField: 'task' }],\n },\n]\n```\n\n```svelte\n<script lang=\"ts\">\n import { SvToaster } from '@svgrid/grid'\n import { SvBase, enableBase, type BaseTable } from '@svgrid/enterprise/base'\n import { taskAutomations } from '$lib/automations'\n\n enableBase()\n let { tasks, issues }: { tasks: BaseTable; issues: BaseTable } = $props()\n let tables = $state.raw([{ ...tasks, automations: taskAutomations }, issues])\n</script>\n\n<SvBase bind:tables editable onTablesChange={(t) => console.log('save', t)} />\n<SvToaster />\n```\n\nAutomations edited in the dialog reach `onTablesChange` with the rest of the\ntable. Automations need `<SvBase tables>`; one table is a list of one.\nNotices show as a base's other notices do: see [Notices](./quick-start.md#notices).\n\n## Your own actions\n\n`registerAutomationAction` adds an action to the dialog's list. It runs in\nthe page, so call your own server for anything that needs a secret:\n\n```ts\nimport { registerAutomationAction } from '@svgrid/enterprise/base'\n\nregisterAutomationAction('post-to-chat', {\n label: 'Post to the team chat',\n run: async ({ record, text }) => {\n if (!record) return 'No record'\n const res = await fetch('/api/chat', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ message: `${text('Task')} needs a hand (${text('Assignee')})` }),\n })\n if (!res.ok) throw new Error(`Chat answered ${res.status}`)\n return 'Posted'\n },\n})\n```\n\nAn automation runs it with `{ type: 'run', action: 'post-to-chat' }`. What it\nreturns is the run's detail; what it throws is the run's error.\n\n## Where they run\n\nEach automation says where it runs, under \"Runs in\":\n\n- **This browser** (the default): in the page of the person who made the\n change, right away and once. A change that arrives from someone else\n through [realtime](./data.md#changes-made-elsewhere) does not run it again\n in your page. Scheduled ones run while the base is open.\n- **The server**: in your server, for every change to the database, whoever\n or whatever made it, with secrets and email. Set it up as below.\n\nEither way, a change an automation makes is an ordinary change: with a\n[source](./data.md), it is written to the database like an edit. What an\naction changes can set off other automations, up to four deep; past that the\nrun stops and says so, so two automations that answer each other cannot loop.\n\n## On the server\n\n![Automations on the server: the base writes through your endpoint to the database; the automation server hears each change through the endpoint's audit hook or a database webhook, writes back through the same sources, and calls webhooks and sends email with secrets that stay on the server.](/docs-media/base-automation-server.svg)\n\n`createAutomationServer` runs the automations set to \"The server\". It reads\nthe same tables, with the same automations, through sources of its own. It remembers\nthe last 10,000 records of a table it heard deleted: on a table with no `softDelete` an\nundo writes the record again, and only that memory tells it from a new one, so such an\nundo after a server restart reads as a creation.\nKeep the tables in one module both sides import, each side handing in its\nown way to reach the data:\n\n```ts\n// src/lib/tables.ts: the tables, for the browser and for the server.\nimport { baseSource, type BaseTable } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\nexport function trackerTables(source: (table: string) => ServerDataSource<Record<string, unknown>>): BaseTable[] {\n return [\n {\n id: 'tasks',\n name: 'Tasks',\n primaryField: 'name',\n data: [],\n columns: [\n { field: 'name', header: 'Task', fieldType: 'text' },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: [{ value: 'Todo' }, { value: 'Blocked' }, { value: 'Done' }] } },\n { field: 'owner_email', header: 'Owner email', fieldType: 'email' },\n ],\n automations: [\n {\n id: 'blocked',\n name: 'Tell the team about a blocked task',\n enabled: true,\n runOn: 'server',\n trigger: { type: 'recordMatches' },\n condition: { kind: 'fieldFilter', conjunction: 'and', conditions: [{ column: 'status', kind: 'select', op: 'is', value: 'Blocked' }] },\n actions: [\n { type: 'webhook', url: 'https://hooks.slack.com/services/{secret:SLACK_HOOK}', body: '{\"text\": \"{Task} is blocked\"}' },\n { type: 'email', to: '{Owner email}', subject: '{Task} is blocked', body: 'Someone marked {Task} as blocked.' },\n ],\n },\n ],\n source: baseSource(source('tasks')),\n },\n ]\n}\n```\n\nThe server side, in a SvelteKit app:\n\nThe code on this page is for SvelteKit 2. On SvelteKit 3,\n[these names differ](../../getting-started/sveltekit.md#on-sveltekit-3).\n\n```ts\n// src/lib/server/automations.ts\nimport pg from 'pg'\nimport { createAutomationServer } from '@svgrid/enterprise/base'\nimport { createSqlDataSource, type EntitySchema } from '@svgrid/enterprise'\nimport { env } from '$env/dynamic/private'\nimport { trackerTables } from '$lib/tables'\n\nconst pool = new pg.Pool({ connectionString: env.DATABASE_URL })\nconst schemas: Record<string, EntitySchema> = {\n tasks: {\n name: 'tasks',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'name', type: 'text' },\n { field: 'status', type: 'text' },\n { field: 'owner_email', type: 'text' },\n ],\n },\n}\n\n// Your mail provider's client.\ndeclare const mailer: { send: (m: { from: string; to: string[]; subject: string; text: string }) => Promise<unknown> }\n\nexport const automations = createAutomationServer({\n tables: trackerTables((table) =>\n createSqlDataSource({\n schema: schemas[table]!,\n table,\n dialect: { placeholders: '$', ilike: true },\n execute: async (sql, params) => (await pool.query(sql, params)).rows,\n }),\n ),\n // {secret:SLACK_HOOK} in a webhook reads this. List what automations may use:\n // whoever writes an automation can send any secret named here to any URL.\n secrets: { SLACK_HOOK: env.SLACK_HOOK },\n sendEmail: (m) => mailer.send({ from: 'tracker@example.com', ...m }),\n onRun: (run) => {\n if (run.status !== 'ok') console.error('automation failed', run)\n },\n})\n```\n\nThen tell it about changes, in whichever way fits your app:\n\n- **Through your endpoint.** Pass its `audit` hook to `createKitHandlers`:\n every create, update and delete through the endpoint reaches it, with the\n record as stored. It compares with what it read last, so it needs a server\n that stays up between requests. A server that has just started reads its\n tables before the first write reaches the database: the hook has a `before`\n that `createKitHandlers` waits for. So each record of a pasted block is\n judged by what it held, and a record the write left as it was runs nothing.\n Columns the row carries that no field names, such as a tenant, are not\n compared.\n\n To keep an audit hook of your own, pass it as the second argument,\n `automations.audit('tasks', (entry) => log(entry))`. It is called first with\n each entry. A hook that wraps this one loses `before`; then the server reads\n its tables after the first write, and each record of that request goes by\n the fields the write named.\n\n ```ts\n // src/routes/api/[table]/+server.ts\n import { createKitHandlers, createSqlDataSource, type EntitySchema } from '@svgrid/enterprise'\n import { automations } from '$lib/server/automations'\n\n declare const schema: EntitySchema\n declare const source: ReturnType<typeof createSqlDataSource>\n\n export const { POST } = createKitHandlers({ schema, source, audit: automations.audit('tasks') })\n ```\n\n- **From the database.** A Supabase database webhook, or a Postgres trigger\n that posts the old and new row, hands over both sides of the change.\n Nothing has to stay in memory, so it suits serverless hosts too:\n\n ```ts\n // src/routes/api/automations/changes/+server.ts\n import { error } from '@sveltejs/kit'\n import { env } from '$env/dynamic/private'\n import { automations } from '$lib/server/automations'\n\n export async function POST({ request }: { request: Request }) {\n if (request.headers.get('x-webhook-secret') !== env.WEBHOOK_SECRET) error(401, 'No')\n // Supabase sends { type, table, record, old_record }.\n const change = await request.json()\n await automations.recordChanged(change.table, { before: change.old_record, after: change.record })\n return new Response('ok')\n }\n ```\n\n- **By reading the table again**, when all you know is that it changed:\n `automations.tableChanged('tasks')`.\n\nScheduled automations run on `tick()`. Call it once a minute: from a cron\njob your host runs against an endpoint, or a timer in a long-running server.\nTwo ticks in one minute run them once.\n\n```ts\n// src/routes/api/automations/tick/+server.ts: called by your host's cron every minute.\nimport { automations } from '$lib/server/automations'\n\nexport async function POST() {\n const runs = await automations.tick()\n return new Response(JSON.stringify({ ran: runs.length }))\n}\n```\n\nThe server's runs show in the dialog next to the page's, tagged Server,\nwhen the base can fetch them:\n\n```ts\n// src/routes/api/automations/runs/+server.ts\nimport { json } from '@sveltejs/kit'\nimport { automations } from '$lib/server/automations'\n\nexport function GET() {\n return json(automations.runs)\n}\n```\n\n```svelte\n<SvBase bind:tables editable serverRuns={() => fetch('/api/automations/runs').then((r) => r.json())} />\n```\n\n![Runs with the server's among them: Tell the team about a blocked task, tagged Server, posted to chat.example.com; Email the lead, tagged Server, sent the email; Done ticks the box ran in the page.](/docs-media/base-automation-server-runs.png)\n\nThe server ignores the echo of its own writes (the webhook the database\nsends for a change it made), so one change runs each automation once.\n\nThe [Postgres demo](./postgres.md) runs a server in the page, standing in\nfor yours: set a task to Blocked and its chat message shows under \"Sent by\nthe server\"; run `update tasks set status = 'Blocked' where id = 't9'` and it\nruns for that change too.\n\n## See also\n\n- [Keep a base in a database](./data.md)\n- [Field types](../fields.md): the view bar's filter, which conditions use\n"
5181
+ "markdown": "# Automations\n\nAn automation does something on its own when something happens to a\nrecord: a task set to Done ticks its Done box, a new request goes to Todo, a\nblocked task tells its owner, a button starts the work. Each table of a base\nhas its own, under \"Automations\" in the view bar.\n\n<div data-docs-demo=\"504-project-tracker\" data-height=\"680\"></div>\n\nIn the demo, set a task's Status to Done, press Start in the Kick off\ncolumn, or send the Request a task form, then open \"5 automations\" and look\nat Runs.\n\n![An automation has three parts: when, only for records where, and do. What an action changes can set off other automations, up to four deep.](/docs-media/base-automation.svg)\n\n## Add one\n\nOpen \"Automations\" in the view bar and press \"+ New automation\". The dialog\nhas three parts:\n\n- **When**: what sets it off.\n- **Only for records where**: a condition written with the view bar's\n filter, so it compares a select's option, a person, a linked record's name\n or \"within the past week\" the way the filter does. Leave it empty for\n every record.\n- **Do**: the actions, in order.\n\n![The Automations dialog: the list of automations with an on/off switch each, and the one picked: when Status changes, only for records where Status is Done, do update the record and show a notice.](/docs-media/base-automations.png)\n\nEvery change is kept as you make it. \"Run now\" tries the automation on the\nrecord you pick, as if its trigger had happened.\n\n## When\n\n| Trigger | Runs |\n|---|---|\n| A record is created | When a record is added: \"+ Add row\", a form, a board lane, a calendar day, another automation. A record brought back by Restore or an undo of a delete is not created, and no rule runs for it |\n| A record changes | When a record is edited; pick fields to run only when one of them changes. A link made from the other table counts: adding a guest to an event from Guests changes the event's Guests field |\n| A record matches a condition | When a record starts to match the condition. It does not run again while the record keeps matching |\n| A form is sent | When a form view sends a record; pick the form, or any form of the table |\n| A button is pressed | When a Button field is pressed on a record |\n| At a scheduled time | Every day at 9, every Monday, every hour, or a cron expression: once for each record that matches the condition then, or once with no record |\n\nA paste or a fill that changes several cells of one record is one change to\nit. An undo or a redo is no change: it runs no automation.\n\n## Do\n\n| Action | What it does |\n|---|---|\n| Update the record | Sets fields of the record that set it off |\n| Create a record | Adds a record to any table of the base; \"Link it back\" fills a link field of the new record with the record that set it off |\n| Show a notice | A toast; `{Field name}` is that field of the record |\n| Color the record while it matches | Colors the whole row, or some fields, for as long as the record matches the condition |\n| Call a webhook | POSTs the record (or a body you write) to a URL: a team chat, your API. Secrets as `{secret:NAME}`, read on the server only |\n| Send an email | To, subject and text with field names; sent by the [server](#on-the-server) |\n| Your own actions | Anything the app adds with `registerAutomationAction` |\n\nA webhook's URL, headers and body name fields in braces, and secrets as\n`{secret:NAME}`; leave the body empty to send the record as JSON. A secret is\nnamed only by the automation: what a record holds is data, so `{secret:NAME}`\ntyped into a field goes out as that text.\n\nFrom the server a webhook does not call private or local addresses (`localhost`,\n`10.x`, `192.168.x`, `169.254.169.254`, a name that resolves to one, an IPv6 form\nthat wraps one) and does not follow redirects. On Node it connects to the\naddresses it checked, so a name cannot answer one way for the check and another\nfor the call; a name that does not resolve is not sent. A `fetch` of your own\npassed to `createAutomationServer` gets the check but not that pin, and neither\ndoes a runtime with no sockets of its own. For a webhook on your own network, set\n`allowInternalWebhooks: true` on `createAutomationServer`.\n\n\n![A server automation that calls a webhook: POST to https://chat.example.com/hooks/{secret:CHAT_HOOK} with the body {\"text\": \"{Task} is blocked. Assignee: {Assignee}\"}.](/docs-media/base-automation-webhook.png)\n\nValues are written as the field shows them:\n\n| Field | Write |\n|---|---|\n| Single or multiple select | The option's name: `Done`, `Bug, Risk` |\n| Person | The person's name: `Ana Ruiz` |\n| Checkbox | `true` or `false` |\n| Number | `42`; in a percent field, `100%` |\n| Date | `2026-11-01`, `today`, `today+7`, `today-1`, `now` |\n| Link | A record's name, several with commas, or `{record}` for the record that set it off |\n| Any text | Text with fields in braces: `{Task} follow-up` |\n| Any field | Nothing, to clear it |\n\n## Runs\n\nEvery run is listed under Runs, newest first, with what each action did and\nthe record it ran on. A failed action stops the run there and says why.\n\nEdit fields on more than 10,000 records asks first, and that question says how many\nruns the change can start in the page and how long they will likely take: at the rate\nruns went in this tab, or, before any did, from how long the server takes to answer. Untick\n\"Also run automations\" to make the change without them. The choice holds for that change\nonly. An automation that runs on the server is not counted and cannot be skipped from here.\n\nRuns in the page go one at a time, in the tab, after the change is saved. From 20 runs on, the top\nbar says how far they are and about how long is left, with a Stop button. Stop drops the runs\nnot started and says how many, and those do not run later. Runs left when the tab closes do\nnot happen either, so the browser asks before it closes. For a change of hundreds of thousands of records,\nrun the automation on the server (`runOn: 'server'`).\n\n![Runs: Task blocked on Paste URLs as attachments showed a notice; Done closes the task on Lightbox preview set Done to checked and Progress to 100%, then showed a notice; Start a task on Docs page set Status to In progress and Start to today.](/docs-media/base-automation-runs.png)\n\n## In code\n\nA table's automations are its `automations`, plain data you can store with\nthe rest of the table:\n\n```ts\nimport type { BaseAutomation } from '@svgrid/enterprise/base'\n\nconst statusIs = (value: string) => ({\n kind: 'fieldFilter' as const,\n conjunction: 'and' as const,\n conditions: [{ column: 'status', kind: 'select' as const, op: 'is' as const, value }],\n})\n\nexport const taskAutomations: BaseAutomation[] = [\n {\n id: 'done',\n name: 'Done closes the task',\n enabled: true,\n trigger: { type: 'recordUpdated', fields: ['status'] },\n condition: statusIs('Done'),\n actions: [\n { type: 'updateRecord', values: { done: 'true', progress: '100%' } },\n { type: 'notify', message: '{Task} is done', severity: 'success' },\n ],\n },\n {\n id: 'blocked',\n name: 'Open an issue for a blocked task',\n enabled: true,\n trigger: { type: 'recordMatches' },\n condition: statusIs('Blocked'),\n actions: [{ type: 'createRecord', table: 'issues', values: { title: 'Unblock {Task}', owner: '{Assignee}' }, linkField: 'task' }],\n },\n]\n```\n\n```svelte\n<script lang=\"ts\">\n import { SvToaster } from '@svgrid/grid'\n import { SvBase, enableBase, type BaseTable } from '@svgrid/enterprise/base'\n import { taskAutomations } from '$lib/automations'\n\n enableBase()\n let { tasks, issues }: { tasks: BaseTable; issues: BaseTable } = $props()\n let tables = $state.raw([{ ...tasks, automations: taskAutomations }, issues])\n</script>\n\n<SvBase bind:tables editable onTablesChange={(t) => console.log('save', t)} />\n<SvToaster />\n```\n\nAutomations edited in the dialog reach `onTablesChange` with the rest of the\ntable. Automations need `<SvBase tables>`; one table is a list of one.\nNotices show as a base's other notices do: see [Notices](./quick-start.md#notices).\n\n## Your own actions\n\n`registerAutomationAction` adds an action to the dialog's list. It runs in\nthe page, so call your own server for anything that needs a secret:\n\n```ts\nimport { registerAutomationAction } from '@svgrid/enterprise/base'\n\nregisterAutomationAction('post-to-chat', {\n label: 'Post to the team chat',\n run: async ({ record, text }) => {\n if (!record) return 'No record'\n const res = await fetch('/api/chat', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ message: `${text('Task')} needs a hand (${text('Assignee')})` }),\n })\n if (!res.ok) throw new Error(`Chat answered ${res.status}`)\n return 'Posted'\n },\n})\n```\n\nAn automation runs it with `{ type: 'run', action: 'post-to-chat' }`. What it\nreturns is the run's detail; what it throws is the run's error.\n\n## Where they run\n\nEach automation says where it runs, under \"Runs in\":\n\n- **This browser** (the default): in the page of the person who made the\n change, right away and once. A change that arrives from someone else\n through [realtime](./data.md#changes-made-elsewhere) does not run it again\n in your page. Scheduled ones run while the base is open.\n- **The server**: in your server, for every change to the database, whoever\n or whatever made it, with secrets and email. Set it up as below.\n\nEither way, a change an automation makes is an ordinary change: with a\n[source](./data.md), it is written to the database like an edit. What an\naction changes can set off other automations, up to four deep; past that the\nrun stops and says so, so two automations that answer each other cannot loop.\n\n## On the server\n\n![Automations on the server: the base writes through your endpoint to the database; the automation server hears each change through the endpoint's audit hook or a database webhook, writes back through the same sources, and calls webhooks and sends email with secrets that stay on the server.](/docs-media/base-automation-server.svg)\n\n`createAutomationServer` runs the automations set to \"The server\". It reads\nthe same tables, with the same automations, through sources of its own. It remembers\nthe last 10,000 records of a table it heard deleted: on a table with no `softDelete` an\nundo writes the record again, and only that memory tells it from a new one, so such an\nundo after a server restart reads as a creation.\nKeep the tables in one module both sides import, each side handing in its\nown way to reach the data:\n\n```ts\n// src/lib/tables.ts: the tables, for the browser and for the server.\nimport { baseSource, type BaseTable } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\nexport function trackerTables(source: (table: string) => ServerDataSource<Record<string, unknown>>): BaseTable[] {\n return [\n {\n id: 'tasks',\n name: 'Tasks',\n primaryField: 'name',\n data: [],\n columns: [\n { field: 'name', header: 'Task', fieldType: 'text' },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: [{ value: 'Todo' }, { value: 'Blocked' }, { value: 'Done' }] } },\n { field: 'owner_email', header: 'Owner email', fieldType: 'email' },\n ],\n automations: [\n {\n id: 'blocked',\n name: 'Tell the team about a blocked task',\n enabled: true,\n runOn: 'server',\n trigger: { type: 'recordMatches' },\n condition: { kind: 'fieldFilter', conjunction: 'and', conditions: [{ column: 'status', kind: 'select', op: 'is', value: 'Blocked' }] },\n actions: [\n { type: 'webhook', url: 'https://hooks.slack.com/services/{secret:SLACK_HOOK}', body: '{\"text\": \"{Task} is blocked\"}' },\n { type: 'email', to: '{Owner email}', subject: '{Task} is blocked', body: 'Someone marked {Task} as blocked.' },\n ],\n },\n ],\n source: baseSource(source('tasks')),\n },\n ]\n}\n```\n\nThe server side, in a SvelteKit app:\n\nThe code on this page is for SvelteKit 2. On SvelteKit 3,\n[these names differ](../../getting-started/sveltekit.md#on-sveltekit-3).\n\n```ts\n// src/lib/server/automations.ts\nimport pg from 'pg'\nimport { createAutomationServer } from '@svgrid/enterprise/base'\nimport { createSqlDataSource, type EntitySchema } from '@svgrid/enterprise'\nimport { env } from '$env/dynamic/private'\nimport { trackerTables } from '$lib/tables'\n\nconst pool = new pg.Pool({ connectionString: env.DATABASE_URL })\nconst schemas: Record<string, EntitySchema> = {\n tasks: {\n name: 'tasks',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'name', type: 'text' },\n { field: 'status', type: 'text' },\n { field: 'owner_email', type: 'text' },\n ],\n },\n}\n\n// Your mail provider's client.\ndeclare const mailer: { send: (m: { from: string; to: string[]; subject: string; text: string }) => Promise<unknown> }\n\nexport const automations = createAutomationServer({\n tables: trackerTables((table) =>\n createSqlDataSource({\n schema: schemas[table]!,\n table,\n dialect: { placeholders: '$', ilike: true },\n execute: async (sql, params) => (await pool.query(sql, params)).rows,\n }),\n ),\n // {secret:SLACK_HOOK} in a webhook reads this. List what automations may use:\n // whoever writes an automation can send any secret named here to any URL.\n secrets: { SLACK_HOOK: env.SLACK_HOOK },\n sendEmail: (m) => mailer.send({ from: 'tracker@example.com', ...m }),\n onRun: (run) => {\n if (run.status !== 'ok') console.error('automation failed', run)\n },\n})\n```\n\nThen tell it about changes, in whichever way fits your app:\n\n- **Through your endpoint.** Pass its `audit` hook to `createKitHandlers`:\n every create, update and delete through the endpoint reaches it, with the\n record as stored. It compares with what it read last, so it needs a server\n that stays up between requests. A server that has just started reads its\n tables before the first write reaches the database: the hook has a `before`\n that `createKitHandlers` waits for. So each record of a pasted block is\n judged by what it held, and a record the write left as it was runs nothing.\n Columns the row carries that no field names, such as a tenant, are not\n compared.\n\n To keep an audit hook of your own, pass it as the second argument,\n `automations.audit('tasks', (entry) => log(entry))`. It is called first with\n each entry. A hook that wraps this one loses `before`; then the server reads\n its tables after the first write, and each record of that request goes by\n the fields the write named.\n\n ```ts\n // src/routes/api/[table]/+server.ts\n import { createKitHandlers, createSqlDataSource, type EntitySchema } from '@svgrid/enterprise'\n import { automations } from '$lib/server/automations'\n\n declare const schema: EntitySchema\n declare const source: ReturnType<typeof createSqlDataSource>\n\n export const { POST } = createKitHandlers({ schema, source, audit: automations.audit('tasks') })\n ```\n\n- **From the database.** A Supabase database webhook, or a Postgres trigger\n that posts the old and new row, hands over both sides of the change.\n Nothing has to stay in memory, so it suits serverless hosts too:\n\n ```ts\n // src/routes/api/automations/changes/+server.ts\n import { error } from '@sveltejs/kit'\n import { env } from '$env/dynamic/private'\n import { automations } from '$lib/server/automations'\n\n export async function POST({ request }: { request: Request }) {\n if (request.headers.get('x-webhook-secret') !== env.WEBHOOK_SECRET) error(401, 'No')\n // Supabase sends { type, table, record, old_record }.\n const change = await request.json()\n await automations.recordChanged(change.table, { before: change.old_record, after: change.record })\n return new Response('ok')\n }\n ```\n\n- **By reading the table again**, when all you know is that it changed:\n `automations.tableChanged('tasks')`.\n\nScheduled automations run on `tick()`. Call it once a minute: from a cron\njob your host runs against an endpoint, or a timer in a long-running server.\nTwo ticks in one minute run them once.\n\n```ts\n// src/routes/api/automations/tick/+server.ts: called by your host's cron every minute.\nimport { automations } from '$lib/server/automations'\n\nexport async function POST() {\n const runs = await automations.tick()\n return new Response(JSON.stringify({ ran: runs.length }))\n}\n```\n\nThe server's runs show in the dialog next to the page's, tagged Server,\nwhen the base can fetch them:\n\n```ts\n// src/routes/api/automations/runs/+server.ts\nimport { json } from '@sveltejs/kit'\nimport { automations } from '$lib/server/automations'\n\nexport function GET() {\n return json(automations.runs)\n}\n```\n\n```svelte\n<SvBase bind:tables editable serverRuns={() => fetch('/api/automations/runs').then((r) => r.json())} />\n```\n\n![Runs with the server's among them: Tell the team about a blocked task, tagged Server, posted to chat.example.com; Email the lead, tagged Server, sent the email; Done ticks the box ran in the page.](/docs-media/base-automation-server-runs.png)\n\nThe server ignores the echo of its own writes (the webhook the database\nsends for a change it made), so one change runs each automation once.\n\nThe [Postgres demo](./postgres.md) runs a server in the page, standing in\nfor yours: set a task to Blocked and its chat message shows under \"Sent by\nthe server\"; run `update tasks set status = 'Blocked' where id = 't9'` and it\nruns for that change too.\n\n## Every automation on the server\n\nAn app whose server hears of every change (people, its API, AI agents)\ncan run all of a base's automations there and none in the page:\n\n```svelte\n<SvBase\n bind:tables\n editable\n automationsOnServer\n serverRuns={() => fetch('/api/automations/runs').then((r) => r.json())}\n runAutomation={(automation, tableId, recordId) =>\n fetch('/api/automations/run', { method: 'POST', body: JSON.stringify({ automation: automation.id, table: tableId, record: recordId }) })}\n/>\n```\n\nWith `automationsOnServer` the dialog offers no \"Runs in\", every\nautomation saved through it is `runOn: 'server'`, and none runs in the page.\n`runAutomation` is \"Run now\" in the dialog and what a Button field does:\nthe page asks the server to run the automation on that record (or on none),\nthen reads the server's runs. A Promise that rejects shows its message in\nthe dialog, or as a notice for a button. Without `runAutomation` the dialog\nsays the automation runs on the server, and a Button field that only server\nautomations listen to does nothing in the page.\n\n## See also\n\n- [Keep a base in a database](./data.md)\n- [Field types](../fields.md): the view bar's filter, which conditions use\n"
5182
5182
  },
5183
5183
  {
5184
5184
  "slug": "help/base/collaboration",
5185
5185
  "path": "docs/help/base/collaboration.md",
5186
5186
  "title": "People, comments and files",
5187
5187
  "section": "SvGrid Base",
5188
- "markdown": "# People, comments and files\n\nA tracker one person fills in needs a status column and little else. Once a\nteam uses it, people want to see who a task is assigned to, who changed the\nstatus and when, a thread of comments on the task, and the mockups attached\nto it, kept somewhere that survives a reload. This page adds those to the\ntask tracker from [Build a project tracker](./start.md).\n\n<div data-docs-demo=\"514-base-hiring-tracker\" data-height=\"680\"></div>\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\nIn the demo, double-click a candidate's card on the pipeline (or switch to\n\"All candidates\" and press Space on a row), change the Stage, leave a\ncomment, and watch the Activity column on the right of the record.\n\nThe base cannot know who your users are or where your files and comments\nlive. You tell it with four calls in the browser; the change log needs\nnothing:\n\n![Your users table goes to setFieldUsers and the session to setCurrentUser, which feed user cells, created by, last modified by and comment authors; setRecordComments connects the record view's Activity to your comments endpoint; setAttachmentUploader sends files to your storage through a presigned URL; the activity log is kept in the page](/docs-media/base-collaboration.svg)\n\nEach step below works on its own.\n\n## 1. List the people\n\nUser fields pick from one list of people that you hand to the base. A person\nis a `FieldUser`:\n\n```ts\nimport { setFieldUsers, type FieldUser } from '@svgrid/enterprise/base'\n\nconst team: FieldUser[] = [\n { id: 'u1', name: 'Ana Ruiz', email: 'ana@example.com', avatarUrl: 'https://cdn.example.com/ana.jpg' },\n { id: 'u2', name: 'Ben Okafor', email: 'ben@example.com' },\n { id: 'u3', name: 'Cleo Park', email: 'cleo@example.com' },\n]\n\n// In the browser only; step 2 shows where in SvelteKit.\nsetFieldUsers(team)\n```\n\nGive the tasks a `user` field for the owner and one with `multiple` for\nreviewers. The cell stores ids, never names, so renaming a person renames\nthem everywhere:\n\n```ts\nconst columns = [\n { field: 'task', header: 'Task', fieldType: 'text' },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: STATUS } },\n { field: 'assignee', header: 'Assignee', fieldType: 'user' },\n { field: 'reviewers', header: 'Reviewers', fieldType: 'user', fieldProps: { multiple: true } },\n]\n\nconst data = [\n { id: 't1', task: 'Write the brief', status: 'Todo', assignee: 'u1', reviewers: ['u2', 'u3'] },\n { id: 't2', task: 'Pick the fonts', status: 'In progress', assignee: 'u2', reviewers: [] },\n]\n```\n\nA cell draws an avatar and the name. With several people it overlaps up to\nfour avatars and writes the first name with a count: \"Ben Okafor +1\".\n`avatarUrl` is used when it is an `http(s):`, `blob:` or `data:image` URL;\nanything else, or no URL, draws the initials on a color worked out from the\nname, so a person keeps the same color on every page. An id that is not in\nthe list shows as the id itself.\n\nEditing a user cell opens a panel with a \"Find a person\" box and the people\nfrom the list, each with their avatar; typing filters them. If the list is\nempty the panel says \"No people (setFieldUsers)\". Text pasted or filled into\na user cell is matched against each person's id, name and email, ignoring\ncase; a multiple field takes them comma-separated and drops repeats. A name\nthat matches nobody is left out and the page says so, and with nobody left the\ncell keeps its value. With no list of people set the field takes what it is\ngiven. Copying a user cell writes the names, so a copy and paste between\nrecords keeps the people, and a copy in the same page keeps the very person when\ntwo share a name.\n`fieldProps.default` takes an id for new rows. The field reference has the\n[user field's properties](../fields.md#declare-columns-by-type).\n\nA Kanban view can stack by a single user field (`stackBy: 'assignee'`): one\nlane per person in the list, plus \"Uncategorized\" while some task has nobody.\nDragging a card to a lane reassigns the task through the grid's edit path,\nso it counts as an edit.\n\n## 2. Say who is signed in\n\n`setCurrentUser` names the person using the page. Several things read it:\n\n- `createdBy` fills new rows with their id, and `lastModifiedBy` writes it\n on every edit it watches.\n- Each comment is saved with their id as `by`.\n- Each change in a record's activity is noted with their id.\n- A filter condition with the value `'@me'` (`ME`) matches them.\n- Your own code can read it with `getCurrentUser()`.\n\nIn SvelteKit the session is on the server, so load the person and the team\nin a layout and hand both to the base in the browser:\n\n```ts\n// src/routes/(app)/+layout.server.ts\nimport { redirect } from '@sveltejs/kit'\nimport type { LayoutServerLoad } from './$types'\nimport { db } from '$lib/server/db'\n\nexport const load: LayoutServerLoad = async ({ locals }) => {\n if (!locals.user) redirect(303, '/login')\n const team = await db.query(\n 'select id, name, email, avatar_url as \"avatarUrl\" from users where team_id = $1 order by name',\n [locals.user.teamId],\n )\n return { me: { id: locals.user.id, name: locals.user.name }, team: team.rows }\n}\n```\n\n```svelte\n<!-- src/routes/(app)/+layout.svelte -->\n<script lang=\"ts\">\n import type { Snippet } from 'svelte'\n import { setCurrentUser, setFieldUsers, type FieldUser } from '@svgrid/enterprise/base'\n\n let { data, children }: { data: { me: FieldUser; team: FieldUser[] }; children: Snippet } = $props()\n\n // Again when the data changes: a sign-in as someone else.\n $effect.pre(() => {\n setFieldUsers(data.team)\n setCurrentUser(data.me)\n })\n</script>\n\n{@render children()}\n```\n\nThe four setters on this page write state shared by the whole module, so\ncall them in the browser only: an `$effect` as here (it does not run during\nserver rendering), `onMount`, or behind `browser` from `$app/environment`.\nCalled at the top of a component's `<script>`, they would also run on the\nserver and hand one request's team and user to the next. Cells and pickers\nread both values reactively, so the base can draw before they arrive. The signed-in person does not have to be in the team list for\ntheir name to show, but they only appear in the picker if they are.\n\nNow add who made each task and when, and give a new task to whoever adds it:\n\n```ts\nimport { getCurrentUser, type BaseTable } from '@svgrid/enterprise/base'\n\nconst tasks: BaseTable = {\n id: 'tasks',\n name: 'Tasks',\n primaryField: 'task',\n data,\n columns: [\n ...columns,\n { field: 'createdBy', header: 'Created by', fieldType: 'createdBy' },\n { field: 'createdAt', header: 'Created', fieldType: 'createdTime', fieldProps: { dateFormat: 'friendly' } },\n ],\n props: {\n rowAdder: { label: 'Add task', defaults: () => ({ status: 'Todo', assignee: getCurrentUser()?.id ?? null }) },\n },\n}\n```\n\nBoth fields are read-only. Every record the base makes gets the current user\nand the time: \"+ Add row\", a form, the record menu, \"+ Add a card\" on a\nKanban, a calendar day. Last modified fields start out the same way. Rows\nyou load keep whatever your database sends.\n\nOn sign-out, call `closeRecord()`, then `setCurrentUser(null)` and\n`setFieldUsers([])`.\n\n## 3. Add a \"My tasks\" view\n\nA filter condition on a user field compares it with a person's id. The value\n`'@me'` (exported as `ME`) stands for whoever is signed in when the filter\nruns, so one view works for everyone:\n\n```ts\nimport { ME, type FieldView } from '@svgrid/enterprise/base'\n\nconst views: FieldView[] = [\n {\n id: 'mine',\n name: 'My tasks',\n type: 'grid',\n state: {\n advancedFilter: {\n kind: 'fieldFilter',\n conjunction: 'or',\n conditions: [\n { column: 'assignee', kind: 'select', op: 'is', value: ME },\n { column: 'reviewers', kind: 'multi', op: 'hasAnyOf', value: [ME] },\n ],\n },\n },\n },\n { id: 'all', name: 'All tasks', type: 'grid' },\n]\n```\n\nIn the Filter panel the person picker lists \"Me\" first, so users can build\nthe same view themselves. The condition reads \"Assignee is me\".\n\nA single user field filters with the select operators (`is`, `isNot`,\n`isAnyOf`, `isNoneOf`), a multiple one with `hasAnyOf`, `hasAllOf`,\n`isExactly` and `hasNoneOf`; both also have `isEmpty` and `isNotEmpty`.\nCreated by and last modified by filter the same way, so \"Created by is me\"\nworks too. The [filter conditions](../fields.md#filter-conditions) table\nlists them all.\n\nThe view stores `'@me'`, not an id, so it can be saved with the other views\n(`onViewsChange`, or the `views` inside `onTablesChange`) and Ben sees his own\ntasks when he opens it.\n\n## 4. Open a record\n\n`expandRows` with `showRowNumbers` turns the row number into a checkbox and an\nexpand button:\n\n```svelte\n<SvBase bind:tables editable showRowNumbers expandRows onTablesChange={save} />\n```\n\nA record opens from the expand button, from Space on a selected cell (not a\ncheckbox cell, and only with `expandRows`), from \"Expand record\" in the\nright-click menu, from a gallery card, from a double click (or F2) on a\nKanban card, from a calendar event and from a Gantt task.\n\n![A candidate open as a record: each field with its type icon on the left, and the Activity column on the right with \"Ana Ruiz changed Stage\" to Offer, her comment below it and the comment box](/docs-media/base-collaboration.png)\n\nThe record shows:\n\n- The primary field as the title.\n- Every field with its type icon and name, drawn as its cell draws it. A click\n opens the cell's own editor; the value is written through the grid's edit\n path, so undo, validation, `onCellValueChange` and last-modified fields work\n the same as in the cell. Read-only fields say \"read-only\".\n- Fields hidden in the view, folded under \"Show N hidden fields\" and marked\n \"hidden in the grid\". They are read-only here.\n- Activity on the right: changes and comments, oldest first, with \"just now\",\n \"5 minutes ago\", \"3 hours ago\" or the date. The box under them takes a\n comment; Ctrl+Enter (Cmd+Enter) or Comment sends it. A base without\n `editable` still takes comments. Text not sent stays with its record until the\n page reloads: stepping to the next record leaves it behind, and coming back finds it.\n Closing the record says so.\n- Previous and next buttons that step through the rows in the view's order,\n and \"3 of 12\".\n\nA record with comments shows how many by its row number (the pointer over the\nrow swaps the count for the checkbox and expand button) and as a badge on its\nKanban card. The card's badge opens the record with the comment box focused,\nas does \"Comment\" in the right-click menu of a row or a card.\n\nOn a narrow screen the activity moves under the fields. If an edit makes the\nrecord leave the view's filter, the record says \"This row is not in the\ngrid's view any more.\" and the footer \"Not in view (12 records)\". Previous\nand next still work: they move to the records that were before and after it.\n\nApp code opens a record with the grid api that `onApiReady` hands it:\n\n```ts\nimport { openRecord, closeRecord } from '@svgrid/enterprise/base'\n\nlet api: unknown\n// <SvBase ... onApiReady={(a) => (api = a)} />\n\nopenRecord({ api, rowId: 't1' })\nopenRecord({ api, rowId: 't1', focus: 'comment' }) // with the comment box focused\ncloseRecord(api)\n```\n\n`closeRecord()` closes whatever record is open, from anywhere: call it on\nsign-out or when the route changes. `closeRecord(api)` closes it only when it\nis open on that grid. A custom field type's `cell` component gets the grid\nas `ctrl` (with `row.id`), and `openRecord({ ctrl, rowId })` takes that too.\nA button field's `fieldProps.onClick` receives `{ row, rowId, columnId, api }`,\nso a button can open its own record.\n\n## 5. Keep comments in your backend\n\nWithout a store, comments live in memory and are gone on reload. In\n`<SvBase tables>` they are kept by table id and record id for the whole\npage, so two bases that show the same table, or a base mounted again, show\nthe same comments. Give unrelated bases on one page different table ids.\nWith one table (`data` and `columns`) they are kept per grid. A comment is\na `RecordComment`, and a store is two functions:\n\n```ts {nocheck}\nexport type RecordComment = { id: string; rowId: string; tableId?: string; text: string; at: number; by?: string; mentions?: string[] }\n\nexport type RecordCommentContext = { tableId?: string; api: unknown }\n\nexport type RecordCommentStore = {\n list: (rowId: string, api: unknown, context: RecordCommentContext) => ReadonlyArray<RecordComment>\n add: (rowId: string, comment: RecordComment, api: unknown, context: RecordCommentContext) => void\n update?: (rowId: string, comment: RecordComment, api: unknown, context: RecordCommentContext) => void\n remove?: (rowId: string, commentId: string, api: unknown, context: RecordCommentContext) => void\n onMention?: (event: MentionEvent) => void\n}\n```\n\n`rowId` is the record's id (its `id`, or the table's `getRowId`). In\n`<SvBase tables>`, `context.tableId` (and the comment's `tableId`) names the\ntable, so Tasks `1` and Milestones `1` are two records; with one table it is\nundefined. `at` is milliseconds since 1970, `by` the id of the person who was\nsigned in. The record view makes `id`, `at` and `by` itself and calls `add`.\nA comment's author sees Edit and Delete under it, with no one signed in that is\nwhoever is at the page. An edited comment shows \"(edited)\" and carries `editedAt`;\nsomeone newly mentioned in it hears of it once. A store without `update` or\n`remove` offers neither.\nA store written for `list(rowId, api)` and `add(rowId, comment, api)` still\nworks.\n\nBoth functions are synchronous, and `list` runs often: for the open record,\nand for every row the grid draws (with `expandRows`) and every Kanban card,\nto show the comment count. So fetch a whole table's comments once into reactive state and answer\nfrom it. Because `list` runs inside the base's reactive code, the counts and\nthe record draw again when the fetch lands:\n\n```ts\n// src/lib/comments.svelte.ts\nimport { browser } from '$app/environment'\nimport { toast } from '@svgrid/grid'\nimport { setRecordComments, type RecordComment, type RecordCommentStore } from '@svgrid/enterprise/base'\n\ntype ByRecord = Record<string, ReadonlyArray<RecordComment>>\n\n// Each table's comments by record id, fetched once per table.\nlet byTable = $state.raw<Record<string, ByRecord>>({})\nconst asked = new Set<string>()\n\nfunction put(table: string, rowId: string, list: ReadonlyArray<RecordComment>) {\n byTable = { ...byTable, [table]: { ...byTable[table], [rowId]: list } }\n}\n\nasync function load(table: string) {\n asked.add(table)\n const res = await fetch(`/api/comments?table=${encodeURIComponent(table)}`)\n if (!res.ok) return void asked.delete(table)\n const grouped: Record<string, RecordComment[]> = {}\n for (const c of (await res.json()) as RecordComment[]) (grouped[c.rowId] ??= []).push(c)\n byTable = { ...byTable, [table]: grouped }\n}\n\n// `update` and `remove` are optional: without them a comment stays as it was written.\nconst store: RecordCommentStore = {\n list(rowId, _api, { tableId = '' }) {\n if (!asked.has(tableId)) void load(tableId)\n return byTable[tableId]?.[rowId] ?? []\n },\n add(rowId, comment, _api, { tableId = '' }) {\n const mine = () => byTable[tableId]?.[rowId] ?? []\n // Shown at once; the server's copy replaces it, or it goes away again.\n put(tableId, rowId, [...mine(), comment])\n fetch('/api/comments', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: comment.id, tableId, rowId, text: comment.text }),\n })\n .then(async (res) => {\n if (!res.ok) throw new Error(`HTTP ${res.status}`)\n const saved = (await res.json()) as RecordComment\n put(tableId, rowId, mine().map((c) => (c.id === comment.id ? saved : c)))\n })\n .catch(() => {\n put(tableId, rowId, mine().filter((c) => c.id !== comment.id))\n toast.error('Your comment was not saved')\n })\n },\n}\n\n// On the server this cache would be shared by every request.\nif (browser) setRecordComments(store)\n```\n\nImport the file once, in the page that shows the base. The failure notice shows\nas a base's other notices do: see [Notices](./quick-start.md#notices).\n`setRecordComments(null)` goes back to memory. For a table with a very large\ndiscussion, have the endpoint return counts per record and fetch a record's\ncomments when it opens.\n\nThe endpoint takes the author and the time from the server, never from the\nrequest body:\n\n```ts\n// src/routes/api/comments/+server.ts\nimport { error, json } from '@sveltejs/kit'\nimport type { RequestHandler } from './$types'\nimport { db } from '$lib/server/db'\n\nexport const GET: RequestHandler = async ({ url, locals }) => {\n if (!locals.user) error(401, 'Sign in first')\n const tableId = url.searchParams.get('table') ?? ''\n // `at` is a bigint column; the cast hands it back as a number, not a string.\n const { rows } = await db.query(\n 'select id, table_id as \"tableId\", row_id as \"rowId\", text, at::float8 as at, author as \"by\" from comments where team_id = $1 and table_id = $2 order by at',\n [locals.user.teamId, tableId],\n )\n return json(rows)\n}\n\nexport const POST: RequestHandler = async ({ request, locals }) => {\n if (!locals.user) error(401, 'Sign in first')\n const body = (await request.json()) as { id?: unknown; tableId?: unknown; rowId?: unknown; text?: unknown }\n const text = String(body.text ?? '').trim().slice(0, 4000)\n if (typeof body.id !== 'string' || typeof body.rowId !== 'string' || !text) error(400, 'Bad comment')\n const tableId = typeof body.tableId === 'string' ? body.tableId : ''\n const comment = { id: body.id, tableId, rowId: body.rowId, text, at: Date.now(), by: locals.user.id }\n await db.query(\n 'insert into comments (id, team_id, table_id, row_id, text, at, author) values ($1, $2, $3, $4, $5, $6, $7)',\n [comment.id, locals.user.teamId, comment.tableId, comment.rowId, comment.text, comment.at, comment.by],\n )\n return json(comment, { status: 201 })\n}\n```\n\nThe activity names the author from the people list: a `by` that is not in\n`setFieldUsers` (and is not the current user) shows as \"Someone\", and a\ncomment with no `by` shows as \"You\". Keep people who left the team in the\nlist, or return their name from your own data.\n\nComments other people add show once the cache changes. To see them while the\nbase is open, call `put` from your realtime channel or a poll.\n\n### Mentions\n\nTyping `@` in the comment box lists the people from `setFieldUsers`, narrowed\nby the letters after it (the start of any word of a name, or of an email).\nUp and Down move through the list, Enter or Tab picks, Escape closes the\nlist and leaves the record open. An `@` inside a word, as in an email\naddress, does not open it.\n\nEscape in the comment box leaves the box and keeps the text. On a comment\nbeing changed it is Cancel. While a comment has text not sent, or is being\nchanged, Escape does not close the record and says why, a click outside does\nnothing, and the Close button still closes it. An empty box holds nothing open.\n\nA mention is kept in the comment's `text` as a token, and its id in\n`mentions`:\n\n```ts {nocheck}\n{ text: 'Numbers match. @[Ana Ruiz](u1) can you get legal to sign off?', mentions: ['u1'] }\n```\n\nThe record view draws the token as a chip with the person's avatar and their\nname from the people list today, so renaming someone renames their mentions.\nA person no longer in the list shows with the name written in the token. The\nrest of the text is drawn as text, never as HTML. `mentionText(text)` turns\nthe tokens back into `@Ana Ruiz` for an email or a chat message, and\n`mentionIds(text)` reads the ids, for a server that does not trust the\n`mentions` the browser sent.\n\nTo send notifications, pass `onMention` to `<SvBase>`, give the store an\n`onMention` hook, or call `setMentionHandler` (they work with the in-memory\ndefault too). Each runs once\nper comment that mentions someone, after `add`:\n\n```ts\nimport { mentionText, setMentionHandler, type MentionEvent } from '@svgrid/enterprise/base'\n\nsetMentionHandler((e: MentionEvent) => {\n // e.comment, e.mentioned (FieldUser[]), e.rowId, e.tableId, e.record, e.api\n const to = e.mentioned.filter((p) => p.id !== e.comment.by && p.email).map((p) => p.email)\n if (!to.length) return\n void fetch('/api/notify', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ to, record: e.record?.task, text: mentionText(e.comment.text) }),\n })\n})\n```\n\n`mentioned` lists each person once, in the order they first appear,\nincluding the author when they mention themselves. Someone not in\n`setFieldUsers` comes with the name written in the token. A hook that throws\nis logged, and the comment stays. When your comments endpoint already saves\n`mentions`, sending from the server, where the author is known, is the safer\nplace for the email.\n\n<div data-docs-demo=\"712-base-mentions\" data-height=\"640\"></div>\n\n## 6. Upload files\n\nAn attachment cell holds an array of `Attachment`: `id`, `url`, `name`,\n`type` (the MIME type), and optional `size`, `width`, `height` and\n`thumbnailUrl` (a smaller image the cell uses instead of `url`). The\n[attachments section](../fields.md#attachments) of the field reference has\nan example value.\n\nWithout an uploader, added files stay in the page as `blob:` URLs and are\ngone on reload. `setAttachmentUploader` sets the function every attachment\ncolumn uses. It gets the `File` and an `AttachmentUploadContext`: `row` (the\nrecord), `columnId`, a `signal` that aborts when the user removes the file\nor closes the dialog, and `onProgress(fraction)` with a value from 0 to 1.\nIt returns the attachment.\n\nThis one asks your server for a presigned URL and sends the bytes straight\nto object storage. It uses `XMLHttpRequest` because `fetch` reports no upload\nprogress:\n\n```ts\n// src/lib/uploads.ts\nimport { browser } from '$app/environment'\nimport { setAttachmentUploader, type AttachmentUploader } from '@svgrid/enterprise/base'\n\nconst upload: AttachmentUploader = async (file, { columnId, signal, onProgress }) => {\n const res = await fetch('/api/uploads', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ name: file.name, type: file.type, size: file.size, columnId }),\n signal,\n })\n if (!res.ok) throw new Error(res.status === 413 ? 'File is too large' : `Upload refused (${res.status})`)\n const { id, uploadUrl, fileUrl } = (await res.json()) as { id: string; uploadUrl: string; fileUrl: string }\n\n await new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest()\n xhr.open('PUT', uploadUrl)\n xhr.setRequestHeader('content-type', file.type || 'application/octet-stream')\n xhr.upload.onprogress = (e) => e.lengthComputable && onProgress(e.loaded / e.total)\n xhr.onload = () => (xhr.status < 300 ? resolve() : reject(new Error(`Storage said ${xhr.status}`)))\n xhr.onerror = () => reject(new Error('Network error'))\n xhr.onabort = () => reject(new Error('Cancelled'))\n signal.addEventListener('abort', () => xhr.abort(), { once: true })\n xhr.send(file)\n })\n\n return { id, url: fileUrl, name: file.name, type: file.type, size: file.size }\n}\n\nif (browser) setAttachmentUploader(upload)\n```\n\nThe message of the error you throw is what the user reads on the failed tile,\nnext to Retry and Remove, so write it for them.\n\nThe server checks the user and the size, signs a URL for one key, and keeps\na row per file:\n\n```ts\n// src/routes/api/uploads/+server.ts\nimport { error, json } from '@sveltejs/kit'\nimport type { RequestHandler } from './$types'\nimport { db } from '$lib/server/db'\nimport { presignPut } from '$lib/server/storage'\n\nconst MAX = 25 * 1024 * 1024\n\nexport const POST: RequestHandler = async ({ request, locals, url }) => {\n if (!locals.user) error(401, 'Sign in first')\n const { name, type, size } = (await request.json()) as { name: string; type: string; size: number }\n if (!(size > 0 && size <= MAX)) error(413, 'File is too large')\n const id = crypto.randomUUID()\n const safe = String(name).replace(/[^\\w.-]+/g, '_')\n const key = `${locals.user.teamId}/${id}/${safe}`\n await db.query('insert into files (id, team_id, key, type) values ($1, $2, $3, $4)', [id, locals.user.teamId, key, type])\n return json({ id, uploadUrl: await presignPut(key, type), fileUrl: `${url.origin}/api/files/${id}/${safe}` })\n}\n```\n\n`fileUrl` points at your app, not at the bucket. A presigned read URL\nexpires, and a cell keeps its URL for as long as the record exists. Serve\n`/api/files/[id]/[name]` with a `GET` that checks the user and the team,\nlooks up the key by `id` and answers `redirect(303, signedReadUrl)`:\nthumbnails, the preview and Download all follow the redirect, and old records\nkeep working.\n\nThe URL is absolute and ends in the file name for the sake of copy and\npaste. Copying an attachment cell writes the files' URLs, and a paste\nattaches each `http(s)` URL it finds, taking the name from the path and the\ntype from its extension. A relative URL would show fine in the cell but be\ndropped on paste, and a URL without the name would come back as a file named\nby its id, an image drawn as a chip.\n\nThe column limits what the dialog takes with\n[`AttachmentFieldProps`](../fields.md#attachments): `accept` (as for\n`<input accept>`, such as `'image/*,.pdf'`), `maxFiles` (default 20) and\n`maxSize` in bytes (default 25 MB). A file over a limit is listed under the\ntiles with the reason, such as \"At most 1 file\", \"Larger than 2 MB\" or \"Not\nan accepted type\". A URL added in the dialog, and text pasted into a cell,\nare checked the same way, their type read from the extension: what fails is\ndropped, the rest is kept. The field editor offers `accept` and `maxFiles`;\n`maxSize` is set in code:\n\n```ts\nconst photo = {\n field: 'photo',\n header: 'Photo',\n fieldType: 'attachment',\n fieldProps: { accept: 'image/*', maxFiles: 1, maxSize: 2 * 1024 * 1024 },\n}\n```\n\n`fieldProps.upload` sets an uploader for one column instead of the app's.\n\n### What the user sees\n\nThe cell shows images as thumbnails and other files as chips with the\nextension and the name, as many as the column width holds, then \"+N\". Enter\nor a double click opens the dialog: add files with \"Add files\", by dropping,\nby pasting files, or by pasting a URL into \"or paste a URL\". Each upload is a\ntile with its percent and a bar; Done reads \"Uploading 2...\" and stays\ndisabled until they finish. Tiles can be dragged to reorder, or moved with\nAlt+Left and Alt+Right; Delete removes one. Cancel or Escape leaves the cell\nas it was and aborts the uploads still running.\n\nFiles can also be dropped straight on a cell. Each one uploads on its own,\nwith a thin progress bar along the bottom of the cell, and the ones that\nupload are written to the cell in one edit. A file over a limit shows in a\n\"Not added\" toast and an upload that throws in an \"Upload failed\" toast, each\nwith the file name and the reason; the others still land. The toasts need\nthe same `<SvToaster />` as the comment store. Uploads still running when the\ncell goes away (scrolled out, or the table switched) are aborted through\n`signal`.\n\nEnter on a tile, or a click on its picture, opens the preview: images inline,\nPDFs in an iframe, anything else as its name with a Download link. Left and\nRight step through the files. A PDF is framed only when the page could read its\nbytes and they are a PDF, so your storage has to allow the page's origin with CORS\n(`Access-Control-Allow-Origin`). A file it cannot read, or one that is not a PDF\nwhatever it calls itself, offers its Download link instead.\n\n## 7. Track who changed what\n\n`lastModifiedTime` and `lastModifiedBy` change on every edit to the record by\ndefault. With `watch: 'specific'` they change only when one of `watchFields`\ndoes, which turns them into \"status changed at\" and \"status changed by\":\n\n```ts\nconst stamps = [\n { field: 'updatedAt', header: 'Last modified', fieldType: 'lastModifiedTime', fieldProps: { dateFormat: 'friendly' } },\n { field: 'statusAt', header: 'Status changed', fieldType: 'lastModifiedTime', fieldProps: { watch: 'specific', watchFields: ['status'] } },\n { field: 'statusBy', header: 'Status changed by', fieldType: 'lastModifiedBy', fieldProps: { watch: 'specific', watchFields: ['status'] } },\n]\n```\n\n`watchFields` holds column ids: the column's `id`, or its `field` when it has\nnone. The time is an ISO string; the person is the current user's id. With\nnobody signed in, the time still moves and the person stays as it was. A\ncommit that leaves the value as it was (an editor opened and closed with\nEnter) is not an edit: nothing is stamped and `onCellValueChange` does not\nfire. An automation's `updateRecord` moves the time but not the person.\n\nThe stamp is written into the row before `onCellValueChange` fires, so the\nevent's `row` already holds it. If you save cell by cell, the event names\nonly the edited column: send the stamps along, or have the server write\n`updated_at` and `updated_by` from its own clock and session, which a\nbrowser cannot fake. With `onTablesChange` or a table `source` ([Keep a base\nin a database](./data.md)) the stamps travel with the rest of the row.\n\n## Protected fields\n\nA protected field takes edits from the people it lists. Everyone else sees\nit read-only, with a lock after its name that says who can edit it:\n\n```ts\nconst columns = [\n { field: 'priority', header: 'Priority', fieldType: 'singleSelect', fieldProps: { options: PRIORITY, editors: ['u1', 'u2'] } },\n { field: 'approved', header: 'Approved', fieldType: 'checkbox', fieldProps: { editors: [] } },\n]\n```\n\n`editors` holds user ids, matched against `setCurrentUser`. An empty list\nmeans nobody can edit the values, and with nobody signed in a protected\nfield is read-only. In the base, Edit field > Who can edit its values sets\nthe list: \"Only these people\" starts with the person setting it, so they do\nnot lock themselves out. `protectFields={false}` on `<SvBase>` takes that\nchoice away from someone your app does not let change it.\n\nWhat the protection covers, for the person in front of the page:\n\n- typing, pasting, the fill handle, Delete, and the record view;\n- a board stacked by the field (its cards do not move) and a calendar or\n timeline whose dates it holds (its events do not drag);\n- an import into the table, which does not offer the field as a target.\n\nA field's name, type and options stay editable: protection is about the\nvalues. A new record still takes its group's value, so \"+\" on a group still\nadds a record to it, and a form fills the fields its author put on it.\n\nWith roles of your own, pass a check in place of the lists. It decides for\nevery field of every base on the page; `defaultCanEditField` is the\n`editors` check, to fall back on:\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, defaultCanEditField, type CanEditField } from '@svgrid/enterprise/base'\n let { tables, role } = $props()\n // Admins edit everything; everyone else follows each field's editors.\n const canEditField: CanEditField = (field, user) => role === 'admin' || defaultCanEditField(field, user)\n</script>\n\n<SvBase bind:tables {canEditField} protectFields={role === 'admin'} editable />\n```\n\nThe browser enforces this. A base whose records live in a database still\nneeds the server to refuse a write to a protected field, as it would any\nwrite the person is not allowed.\n\n<div data-docs-demo=\"710-base-personal-locked-views\" data-height=\"620\"></div>\n\n## Share a base read-only\n\nFor people who may look but not change anything, such as a client opening a\nshare link your app serves, pass `readOnly`:\n\n```svelte\n<SvBase {tables} readOnly sortable expandRows fieldMenu />\n```\n\nWhat it closes:\n\n- cells and the record view: no typing, pasting, fill handle, Delete or\n checkbox clicks, and buttons do not run automations;\n- the record menu keeps Expand record and Copy; the field menu keeps Filter,\n Group, Hide and Color rows by this field;\n- no \"+ Add row\", no \"+\" column, no \"+\" on a group, and the selection bar\n drops Edit fields and Delete;\n- a board's cards do not move and its lanes add none; a calendar's or\n timeline's events do not drag, and a day picked adds no record;\n- the tab bar has no table menu, no renaming, no Add table, no import, no\n trash, no undo, and no Download as SQL; it shows a \"View only\" badge;\n- no Automations button, and scheduled automations do not run in the page;\n- comments are read, and the box to write one is gone;\n- form views are not shared.\n\nViewers still switch tables and views, search, filter, sort, group, and open\nrecords with their activity. What they change in a view (a sort, a filter,\na new view) stays in the page while it is open, also across table switches,\nand never reaches `onTablesChange` or a table's `source`.\n\nA share on the same page as the editing base (a preview, or the demo below)\nshows the comments written in the editor, with their counts on rows and\ncards: comments are kept by table id and record id, not by base. The\nchanges in a record's activity and the unseen marks stay with the base that\nnoted them. On a separate page, the share sees the comments your\n`setRecordComments` store returns; in-page comments do not travel between\nbrowsers.\n\nAn object picks what the share shows. Every list is optional:\n\n```svelte\n<SvBase\n {tables}\n readOnly={{\n tables: ['projects', 'clients'],\n views: ['all', 'board'],\n hideFields: ['budget', 'clients.notes'],\n }}\n/>\n```\n\n`tables` and `views` are ids; a table none of whose listed views exists\nshows its first view. `hideFields` takes a column id, which hides it in\nevery table, or `tableId.columnId`. The primary field always shows. A hidden\nfield takes along every field that would show what it holds: the formulas\nthat read it, a rollup or lookup of it in another table, and the lookups,\nrollups and counts of a link to a table the share leaves out.\n\nHiding is for display. A page handed the whole base still holds the hidden\nvalues in memory, so for anything secret build the shared copy on the server\nwith `sharedTables(tables, share)`, which also takes the hidden fields'\nvalues out of the records, and send only that.\n\n<div data-docs-demo=\"717-base-read-only-share\" data-height=\"620\"></div>\n\n## The activity log\n\nEvery edit through the grid is noted for the record: a typed value, a paste,\na fill, a clear, a checkbox click, a card dragged to another lane, an edit in\nthe record view, files added in the dialog or dropped on a cell. Each note\nholds the time, the current user's id, the column, the new value and the one\nbefore it, and the record view writes it as \"Ana Ruiz changed Status\" over the\nold value and the new one as the cell shows them, or \"(cleared)\". Undo and redo\nare noted too, as \"You undid a change to Status\" and \"You redid a change to\nStatus\", so the log ends on what the record holds. A field an automation's `updateRecord` sets is\nnoted under the automation's name: \"Automation: Done ticks the box changed\nDone\".\n\nA change someone else made in the database, read in through a table's\n`realtime` source, is noted too, under the name in the record's\n`lastModifiedBy` field, with the value before it: \"Triage agent changed\nPriority\", Low → Urgent. Until the record is opened, its changed cells are\ntinted and its row number has a dot. See [Changes made\nelsewhere](./data.md#changes-made-elsewhere).\n\nBy default the log lives in memory and keeps the latest 50 changes of each\nrecord, for the 20,000 records of a table changed longest ago last: a bulk edit of a\nmillion records does not stay in the tab. In `<SvBase tables>` it is kept by base, table and record id, so it\nsurvives switching tabs; with one table it is kept per grid. Changes made by\nyour code replacing `tables` or `data` are not noted.\n\n### A history that lasts\n\nYour audit log already has every change. `setRecordHistory` lets the record\nview read it, and hands it each change made in the page to keep:\n\n```ts\nimport { setRecordHistory, type RecordChange } from '@svgrid/enterprise/base'\n\nsetRecordHistory({\n // Each time a record is opened. A promise is fine: the activity says\n // \"Loading the history...\" until it settles.\n list: async (rowId, { tableId }) => {\n const res = await fetch(`/api/history/${tableId}/${rowId}`)\n return (await res.json()) as RecordChange[]\n },\n // Each change made in this page, as it is made.\n add: (rowId, change, { tableId }) => {\n void fetch(`/api/history/${tableId}/${rowId}`, { method: 'POST', body: JSON.stringify(change) })\n },\n})\n```\n\nA change is `{ at, by, columnId, value, from? }` (`at` in milliseconds,\n`by` a user id from `setFieldUsers`), plus `automation` for a change an\nautomation made and `via` for a proposal someone accepted. The record view\nshows what `list` gave with this session's changes it does not have yet;\ngive back the `at` that `add` received, and a change shows once. A change\nmade elsewhere and read in through `realtime` is not passed to `add`:\nwhoever made it keeps it.\n\n`historyOf(ctrl, rowId)` gives a record's history as the record view shows\nit, for a panel of your own. `setRecordHistory(null)` goes back to memory.\n\n## The record menu\n\nRight-click a record in a base's grid:\n\n| Item | What it does |\n| --- | --- |\n| Expand record | Opens the record, with or without `expandRows` |\n| Comment | Opens the record with the comment box focused |\n| Insert record above, Insert record below | A new record beside this one with the values of the fields the view groups by, so it stays in the group; editing starts on its first field |\n| Duplicate record | A copy below, with lists copied; autonumber, created and last modified fields get fresh values |\n| Copy, Paste | The grid's own cell copy and paste |\n| Delete record | Asks \"Delete record?\" (\"Write the brief is deleted, and its links from other records go with it.\"), then removes it and fires `onRowsDelete` |\n\nWithout `editable`, only Expand record, Comment and Copy show. A new record\nfrom the menu is made the way \"+ Add row\" makes one: the `rowAdder` defaults,\na new id, the next autonumber, the current user in created by, and `onRowAdd`\nfired, so a table with a database writes it. The grid scrolls to it. A Kanban\ncard's right-click menu has Expand record and Comment, and with `editable`\n\"Move to\" a lane, Duplicate record and Delete record. Passing your own\n`contextMenu` to `SvBase` replaces the grid's menu.\n\n## Pitfalls\n\n- **No current user, no author.** Without `setCurrentUser`, new rows get\n `null` in created by, and an edit leaves last modified by as it was, so\n the field names whoever edited last while signed in.\n- **People are page-wide.** `setFieldUsers` and `setCurrentUser` set one list\n and one person for every base on the page. Two bases for two teams on one\n page share them.\n- **Records need real ids.** Comments and the activity are keyed by row id:\n each record's `id`, or `getRowId`. With one table a record without an `id`\n falls back to its index, so its comments move to another record when a row\n above it is deleted. In `<SvBase tables>` every record without an `id`\n shares the id `''`, and with it one thread. Give every record an id.\n- **Your store tells tables apart by id only.** In memory, each `<SvBase>`\n keeps its own comments and activity, even when two bases on one page use\n the same table ids. Your comment store gets the table id and nothing about\n the base: if two bases share one store and their table ids, key the store\n by something of your own as well. With `serverIds: true` a new record\n keeps the page's id until the table loads again; re-key its comments when\n the insert returns.\n- **`'@me'` is whoever runs the filter.** Before `setCurrentUser` it\n matches no one; the grid filters again once a user is set. In an\n automation's condition it is the person whose edit set it off, and on the\n server runner, where nobody is signed in, it matches no one.\n- **A URL's type is its extension.** Under `accept: 'image/*'` a URL with no\n extension is refused, and a URL's size is checked only when it is known.\n The browser checks are for the user; check types and sizes on the server\n too.\n- **Storage keeps what the cell drops.** Removing a file, Cancel after an\n upload finished, or deleting the record leaves the object in the bucket.\n Clean up on the server, for example files no record has pointed at for a\n day.\n- **`fieldProps.upload` does not survive JSON.** A function in a column is\n lost when you store columns in a database through `onTablesChange`. Use\n `setAttachmentUploader` and branch on `columnId` instead.\n\n## Next\n\n- [Linked records](./linked-records.md): tasks that point at milestones,\n people that point at teams, and the records that link back.\n- [Formulas](./formulas.md): fields worked out from other fields.\n- [Views](./views.md): grids, boards, calendars and galleries over the same\n records.\n- [Forms](./forms.md): let people outside the team add records.\n- [Your own field type](./custom-field-type.md): a cell of your own, with the\n grid's `ctrl` to open records from it.\n- [Automations](./automations.md): tell the assignee when a task is blocked.\n"
5188
+ "markdown": "# People, comments and files\n\nA tracker one person fills in needs a status column and little else. Once a\nteam uses it, people want to see who a task is assigned to, who changed the\nstatus and when, a thread of comments on the task, and the mockups attached\nto it, kept somewhere that survives a reload. This page adds those to the\ntask tracker from [Build a project tracker](./start.md).\n\n<div data-docs-demo=\"514-base-hiring-tracker\" data-height=\"680\"></div>\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\nIn the demo, double-click a candidate's card on the pipeline (or switch to\n\"All candidates\" and press Space on a row), change the Stage, leave a\ncomment, and watch the Activity column on the right of the record.\n\nThe base cannot know who your users are or where your files and comments\nlive. You tell it with four calls in the browser; the change log needs\nnothing:\n\n![Your users table goes to setFieldUsers and the session to setCurrentUser, which feed user cells, created by, last modified by and comment authors; setRecordComments connects the record view's Activity to your comments endpoint; setAttachmentUploader sends files to your storage through a presigned URL; the activity log is kept in the page](/docs-media/base-collaboration.svg)\n\nEach step below works on its own.\n\n## 1. List the people\n\nUser fields pick from one list of people that you hand to the base. A person\nis a `FieldUser`:\n\n```ts\nimport { setFieldUsers, type FieldUser } from '@svgrid/enterprise/base'\n\nconst team: FieldUser[] = [\n { id: 'u1', name: 'Ana Ruiz', email: 'ana@example.com', avatarUrl: 'https://cdn.example.com/ana.jpg' },\n { id: 'u2', name: 'Ben Okafor', email: 'ben@example.com' },\n { id: 'u3', name: 'Cleo Park', email: 'cleo@example.com' },\n]\n\n// In the browser only; step 2 shows where in SvelteKit.\nsetFieldUsers(team)\n```\n\nGive the tasks a `user` field for the owner and one with `multiple` for\nreviewers. The cell stores ids, never names, so renaming a person renames\nthem everywhere:\n\n```ts\nconst columns = [\n { field: 'task', header: 'Task', fieldType: 'text' },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: STATUS } },\n { field: 'assignee', header: 'Assignee', fieldType: 'user' },\n { field: 'reviewers', header: 'Reviewers', fieldType: 'user', fieldProps: { multiple: true } },\n]\n\nconst data = [\n { id: 't1', task: 'Write the brief', status: 'Todo', assignee: 'u1', reviewers: ['u2', 'u3'] },\n { id: 't2', task: 'Pick the fonts', status: 'In progress', assignee: 'u2', reviewers: [] },\n]\n```\n\nA cell draws an avatar and the name. With several people it overlaps up to\nfour avatars and writes the first name with a count: \"Ben Okafor +1\".\n`avatarUrl` is used when it is an `http(s):`, `blob:` or `data:image` URL;\nanything else, or no URL, draws the initials on a color worked out from the\nname, so a person keeps the same color on every page. An id that is not in\nthe list shows as the id itself.\n\nEditing a user cell opens a panel with a \"Find a person\" box and the people\nfrom the list, each with their avatar; typing filters them. If the list is\nempty the panel says \"No people (setFieldUsers)\". Text pasted or filled into\na user cell is matched against each person's id, name and email, ignoring\ncase; a multiple field takes them comma-separated and drops repeats. A name\nthat matches nobody is left out and the page says so, and with nobody left the\ncell keeps its value. With no list of people set the field takes what it is\ngiven. Copying a user cell writes the names, so a copy and paste between\nrecords keeps the people, and a copy in the same page keeps the very person when\ntwo share a name.\n`fieldProps.default` takes an id for new rows. The field reference has the\n[user field's properties](../fields.md#declare-columns-by-type).\n\nA Kanban view can stack by a single user field (`stackBy: 'assignee'`): one\nlane per person in the list, plus \"Uncategorized\" while some task has nobody.\nDragging a card to a lane reassigns the task through the grid's edit path,\nso it counts as an edit.\n\n## 2. Say who is signed in\n\n`setCurrentUser` names the person using the page. Several things read it:\n\n- `createdBy` fills new rows with their id, and `lastModifiedBy` writes it\n on every edit it watches.\n- Each comment is saved with their id as `by`.\n- Each change in a record's activity is noted with their id.\n- A filter condition with the value `'@me'` (`ME`) matches them.\n- Your own code can read it with `getCurrentUser()`.\n\nIn SvelteKit the session is on the server, so load the person and the team\nin a layout and hand both to the base in the browser:\n\n```ts\n// src/routes/(app)/+layout.server.ts\nimport { redirect } from '@sveltejs/kit'\nimport type { LayoutServerLoad } from './$types'\nimport { db } from '$lib/server/db'\n\nexport const load: LayoutServerLoad = async ({ locals }) => {\n if (!locals.user) redirect(303, '/login')\n const team = await db.query(\n 'select id, name, email, avatar_url as \"avatarUrl\" from users where team_id = $1 order by name',\n [locals.user.teamId],\n )\n return { me: { id: locals.user.id, name: locals.user.name }, team: team.rows }\n}\n```\n\n```svelte\n<!-- src/routes/(app)/+layout.svelte -->\n<script lang=\"ts\">\n import type { Snippet } from 'svelte'\n import { setCurrentUser, setFieldUsers, type FieldUser } from '@svgrid/enterprise/base'\n\n let { data, children }: { data: { me: FieldUser; team: FieldUser[] }; children: Snippet } = $props()\n\n // Again when the data changes: a sign-in as someone else.\n $effect.pre(() => {\n setFieldUsers(data.team)\n setCurrentUser(data.me)\n })\n</script>\n\n{@render children()}\n```\n\nThe four setters on this page write state shared by the whole module, so\ncall them in the browser only: an `$effect` as here (it does not run during\nserver rendering), `onMount`, or behind `browser` from `$app/environment`.\nCalled at the top of a component's `<script>`, they would also run on the\nserver and hand one request's team and user to the next. Cells and pickers\nread both values reactively, so the base can draw before they arrive. The signed-in person does not have to be in the team list for\ntheir name to show, but they only appear in the picker if they are.\n\nNow add who made each task and when, and give a new task to whoever adds it:\n\n```ts\nimport { getCurrentUser, type BaseTable } from '@svgrid/enterprise/base'\n\nconst tasks: BaseTable = {\n id: 'tasks',\n name: 'Tasks',\n primaryField: 'task',\n data,\n columns: [\n ...columns,\n { field: 'createdBy', header: 'Created by', fieldType: 'createdBy' },\n { field: 'createdAt', header: 'Created', fieldType: 'createdTime', fieldProps: { dateFormat: 'friendly' } },\n ],\n props: {\n rowAdder: { label: 'Add task', defaults: () => ({ status: 'Todo', assignee: getCurrentUser()?.id ?? null }) },\n },\n}\n```\n\nBoth fields are read-only. Every record the base makes gets the current user\nand the time: \"+ Add row\", a form, the record menu, \"+ Add a card\" on a\nKanban, a calendar day. Last modified fields start out the same way. Rows\nyou load keep whatever your database sends.\n\nOn sign-out, call `closeRecord()`, then `setCurrentUser(null)` and\n`setFieldUsers([])`.\n\n## 3. Add a \"My tasks\" view\n\nA filter condition on a user field compares it with a person's id. The value\n`'@me'` (exported as `ME`) stands for whoever is signed in when the filter\nruns, so one view works for everyone:\n\n```ts\nimport { ME, type FieldView } from '@svgrid/enterprise/base'\n\nconst views: FieldView[] = [\n {\n id: 'mine',\n name: 'My tasks',\n type: 'grid',\n state: {\n advancedFilter: {\n kind: 'fieldFilter',\n conjunction: 'or',\n conditions: [\n { column: 'assignee', kind: 'select', op: 'is', value: ME },\n { column: 'reviewers', kind: 'multi', op: 'hasAnyOf', value: [ME] },\n ],\n },\n },\n },\n { id: 'all', name: 'All tasks', type: 'grid' },\n]\n```\n\nIn the Filter panel the person picker lists \"Me\" first, so users can build\nthe same view themselves. The condition reads \"Assignee is me\".\n\nA single user field filters with the select operators (`is`, `isNot`,\n`isAnyOf`, `isNoneOf`), a multiple one with `hasAnyOf`, `hasAllOf`,\n`isExactly` and `hasNoneOf`; both also have `isEmpty` and `isNotEmpty`.\nCreated by and last modified by filter the same way, so \"Created by is me\"\nworks too. The [filter conditions](../fields.md#filter-conditions) table\nlists them all.\n\nThe view stores `'@me'`, not an id, so it can be saved with the other views\n(`onViewsChange`, or the `views` inside `onTablesChange`) and Ben sees his own\ntasks when he opens it.\n\n## 4. Open a record\n\n`expandRows` with `showRowNumbers` turns the row number into a checkbox and an\nexpand button:\n\n```svelte\n<SvBase bind:tables editable showRowNumbers expandRows onTablesChange={save} />\n```\n\nA record opens from the expand button, from Space on a selected cell (not a\ncheckbox cell, and only with `expandRows`), from \"Expand record\" in the\nright-click menu, from a gallery card, from a double click (or F2) on a\nKanban card, from a calendar event and from a Gantt task.\n\n![A candidate open as a record: each field with its type icon on the left, and the Activity column on the right with \"Ana Ruiz changed Stage\" to Offer, her comment below it and the comment box](/docs-media/base-collaboration.png)\n\nThe record shows:\n\n- The primary field as the title.\n- Every field with its type icon and name, drawn as its cell draws it. A click\n opens the cell's own editor; the value is written through the grid's edit\n path, so undo, validation, `onCellValueChange` and last-modified fields work\n the same as in the cell. Read-only fields say \"read-only\".\n- Fields hidden in the view, folded under \"Show N hidden fields\" and marked\n \"hidden in the grid\". They are read-only here.\n- Activity on the right: changes and comments, oldest first, with \"just now\",\n \"5 minutes ago\", \"3 hours ago\" or the date. The box under them takes a\n comment; Ctrl+Enter (Cmd+Enter) or Comment sends it. A base without\n `editable` still takes comments. Text not sent stays with its record until the\n page reloads: stepping to the next record leaves it behind, and coming back finds it.\n Closing the record says so.\n- Previous and next buttons that step through the rows in the view's order,\n and \"3 of 12\".\n\nA record with comments shows how many by its row number (the pointer over the\nrow swaps the count for the checkbox and expand button) and as a badge on its\nKanban card. The card's badge opens the record with the comment box focused,\nas does \"Comment\" in the right-click menu of a row or a card.\n\nOn a narrow screen the activity moves under the fields. If an edit makes the\nrecord leave the view's filter, the record says \"This row is not in the\ngrid's view any more.\" and the footer \"Not in view (12 records)\". Previous\nand next still work: they move to the records that were before and after it.\n\nApp code opens a record with the grid api that `onApiReady` hands it:\n\n```ts\nimport { openRecord, closeRecord } from '@svgrid/enterprise/base'\n\nlet api: unknown\n// <SvBase ... onApiReady={(a) => (api = a)} />\n\nopenRecord({ api, rowId: 't1' })\nopenRecord({ api, rowId: 't1', focus: 'comment' }) // with the comment box focused\ncloseRecord(api)\n```\n\n`closeRecord()` closes whatever record is open, from anywhere: call it on\nsign-out or when the route changes. `closeRecord(api)` closes it only when it\nis open on that grid. A custom field type's `cell` component gets the grid\nas `ctrl` (with `row.id`), and `openRecord({ ctrl, rowId })` takes that too.\nA button field's `fieldProps.onClick` receives `{ row, rowId, columnId, api }`,\nso a button can open its own record.\n\n## 5. Keep comments in your backend\n\nWithout a store, comments live in memory and are gone on reload. In\n`<SvBase tables>` they are kept by table id and record id for the whole\npage, so two bases that show the same table, or a base mounted again, show\nthe same comments. Give unrelated bases on one page different table ids.\nWith one table (`data` and `columns`) they are kept per grid. A comment is\na `RecordComment`, and a store is two functions:\n\n```ts {nocheck}\nexport type RecordComment = { id: string; rowId: string; tableId?: string; text: string; at: number; by?: string; mentions?: string[] }\n\nexport type RecordCommentContext = { tableId?: string; api: unknown }\n\nexport type RecordCommentStore = {\n list: (rowId: string, api: unknown, context: RecordCommentContext) => ReadonlyArray<RecordComment>\n add: (rowId: string, comment: RecordComment, api: unknown, context: RecordCommentContext) => void\n update?: (rowId: string, comment: RecordComment, api: unknown, context: RecordCommentContext) => void\n remove?: (rowId: string, commentId: string, api: unknown, context: RecordCommentContext) => void\n onMention?: (event: MentionEvent) => void\n}\n```\n\n`rowId` is the record's id (its `id`, or the table's `getRowId`). In\n`<SvBase tables>`, `context.tableId` (and the comment's `tableId`) names the\ntable, so Tasks `1` and Milestones `1` are two records; with one table it is\nundefined. `at` is milliseconds since 1970, `by` the id of the person who was\nsigned in. The record view makes `id`, `at` and `by` itself and calls `add`.\nA comment's author sees Edit and Delete under it, with no one signed in that is\nwhoever is at the page. An edited comment shows \"(edited)\" and carries `editedAt`;\nsomeone newly mentioned in it hears of it once. A store without `update` or\n`remove` offers neither.\nA store written for `list(rowId, api)` and `add(rowId, comment, api)` still\nworks.\n\nBoth functions are synchronous, and `list` runs often: for the open record,\nand for every row the grid draws (with `expandRows`) and every Kanban card,\nto show the comment count. So fetch a whole table's comments once into reactive state and answer\nfrom it. Because `list` runs inside the base's reactive code, the counts and\nthe record draw again when the fetch lands:\n\n```ts\n// src/lib/comments.svelte.ts\nimport { browser } from '$app/environment'\nimport { toast } from '@svgrid/grid'\nimport { setRecordComments, type RecordComment, type RecordCommentStore } from '@svgrid/enterprise/base'\n\ntype ByRecord = Record<string, ReadonlyArray<RecordComment>>\n\n// Each table's comments by record id, fetched once per table.\nlet byTable = $state.raw<Record<string, ByRecord>>({})\nconst asked = new Set<string>()\n\nfunction put(table: string, rowId: string, list: ReadonlyArray<RecordComment>) {\n byTable = { ...byTable, [table]: { ...byTable[table], [rowId]: list } }\n}\n\nasync function load(table: string) {\n asked.add(table)\n const res = await fetch(`/api/comments?table=${encodeURIComponent(table)}`)\n if (!res.ok) return void asked.delete(table)\n const grouped: Record<string, RecordComment[]> = {}\n for (const c of (await res.json()) as RecordComment[]) (grouped[c.rowId] ??= []).push(c)\n byTable = { ...byTable, [table]: grouped }\n}\n\n// `update` and `remove` are optional: without them a comment stays as it was written.\nconst store: RecordCommentStore = {\n list(rowId, _api, { tableId = '' }) {\n if (!asked.has(tableId)) void load(tableId)\n return byTable[tableId]?.[rowId] ?? []\n },\n add(rowId, comment, _api, { tableId = '' }) {\n const mine = () => byTable[tableId]?.[rowId] ?? []\n // Shown at once; the server's copy replaces it, or it goes away again.\n put(tableId, rowId, [...mine(), comment])\n fetch('/api/comments', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: comment.id, tableId, rowId, text: comment.text }),\n })\n .then(async (res) => {\n if (!res.ok) throw new Error(`HTTP ${res.status}`)\n const saved = (await res.json()) as RecordComment\n put(tableId, rowId, mine().map((c) => (c.id === comment.id ? saved : c)))\n })\n .catch(() => {\n put(tableId, rowId, mine().filter((c) => c.id !== comment.id))\n toast.error('Your comment was not saved')\n })\n },\n}\n\n// On the server this cache would be shared by every request.\nif (browser) setRecordComments(store)\n```\n\nImport the file once, in the page that shows the base. The failure notice shows\nas a base's other notices do: see [Notices](./quick-start.md#notices).\n`setRecordComments(null)` goes back to memory. For a table with a very large\ndiscussion, have the endpoint return counts per record and fetch a record's\ncomments when it opens.\n\nThe endpoint takes the author and the time from the server, never from the\nrequest body:\n\n```ts\n// src/routes/api/comments/+server.ts\nimport { error, json } from '@sveltejs/kit'\nimport type { RequestHandler } from './$types'\nimport { db } from '$lib/server/db'\n\nexport const GET: RequestHandler = async ({ url, locals }) => {\n if (!locals.user) error(401, 'Sign in first')\n const tableId = url.searchParams.get('table') ?? ''\n // `at` is a bigint column; the cast hands it back as a number, not a string.\n const { rows } = await db.query(\n 'select id, table_id as \"tableId\", row_id as \"rowId\", text, at::float8 as at, author as \"by\" from comments where team_id = $1 and table_id = $2 order by at',\n [locals.user.teamId, tableId],\n )\n return json(rows)\n}\n\nexport const POST: RequestHandler = async ({ request, locals }) => {\n if (!locals.user) error(401, 'Sign in first')\n const body = (await request.json()) as { id?: unknown; tableId?: unknown; rowId?: unknown; text?: unknown }\n const text = String(body.text ?? '').trim().slice(0, 4000)\n if (typeof body.id !== 'string' || typeof body.rowId !== 'string' || !text) error(400, 'Bad comment')\n const tableId = typeof body.tableId === 'string' ? body.tableId : ''\n const comment = { id: body.id, tableId, rowId: body.rowId, text, at: Date.now(), by: locals.user.id }\n await db.query(\n 'insert into comments (id, team_id, table_id, row_id, text, at, author) values ($1, $2, $3, $4, $5, $6, $7)',\n [comment.id, locals.user.teamId, comment.tableId, comment.rowId, comment.text, comment.at, comment.by],\n )\n return json(comment, { status: 201 })\n}\n```\n\nThe activity names the author from the people list: a `by` that is not in\n`setFieldUsers` (and is not the current user) shows as \"Someone\", and a\ncomment with no `by` shows as \"You\". Keep people who left the team in the\nlist, or return their name from your own data.\n\nComments other people add show once the cache changes. To see them while the\nbase is open, call `put` from your realtime channel or a poll.\n\n### Mentions\n\nTyping `@` in the comment box lists the people from `setFieldUsers`, narrowed\nby the letters after it (the start of any word of a name, or of an email).\nUp and Down move through the list, Enter or Tab picks, Escape closes the\nlist and leaves the record open. An `@` inside a word, as in an email\naddress, does not open it.\n\nEscape in the comment box leaves the box and keeps the text. On a comment\nbeing changed it is Cancel. While a comment has text not sent, or is being\nchanged, Escape does not close the record and says why, a click outside does\nnothing, and the Close button still closes it. An empty box holds nothing open.\n\nA mention is kept in the comment's `text` as a token, and its id in\n`mentions`:\n\n```ts {nocheck}\n{ text: 'Numbers match. @[Ana Ruiz](u1) can you get legal to sign off?', mentions: ['u1'] }\n```\n\nThe record view draws the token as a chip with the person's avatar and their\nname from the people list today, so renaming someone renames their mentions.\nA person no longer in the list shows with the name written in the token. The\nrest of the text is drawn as text, never as HTML. `mentionText(text)` turns\nthe tokens back into `@Ana Ruiz` for an email or a chat message, and\n`mentionIds(text)` reads the ids, for a server that does not trust the\n`mentions` the browser sent.\n\nTo send notifications, pass `onMention` to `<SvBase>`, give the store an\n`onMention` hook, or call `setMentionHandler` (they work with the in-memory\ndefault too). Each runs once\nper comment that mentions someone, after `add`:\n\n```ts\nimport { mentionText, setMentionHandler, type MentionEvent } from '@svgrid/enterprise/base'\n\nsetMentionHandler((e: MentionEvent) => {\n // e.comment, e.mentioned (FieldUser[]), e.rowId, e.tableId, e.record, e.api\n const to = e.mentioned.filter((p) => p.id !== e.comment.by && p.email).map((p) => p.email)\n if (!to.length) return\n void fetch('/api/notify', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ to, record: e.record?.task, text: mentionText(e.comment.text) }),\n })\n})\n```\n\n`mentioned` lists each person once, in the order they first appear,\nincluding the author when they mention themselves. Someone not in\n`setFieldUsers` comes with the name written in the token. A hook that throws\nis logged, and the comment stays. When your comments endpoint already saves\n`mentions`, sending from the server, where the author is known, is the safer\nplace for the email.\n\n<div data-docs-demo=\"712-base-mentions\" data-height=\"640\"></div>\n\n## 6. Upload files\n\nAn attachment cell holds an array of `Attachment`: `id`, `url`, `name`,\n`type` (the MIME type), and optional `size`, `width`, `height` and\n`thumbnailUrl` (a smaller image the cell uses instead of `url`). The\n[attachments section](../fields.md#attachments) of the field reference has\nan example value.\n\nWithout an uploader, added files stay in the page as `blob:` URLs and are\ngone on reload. `setAttachmentUploader` sets the function every attachment\ncolumn uses. It gets the `File` and an `AttachmentUploadContext`: `row` (the\nrecord), `columnId`, a `signal` that aborts when the user removes the file\nor closes the dialog, and `onProgress(fraction)` with a value from 0 to 1.\nIt returns the attachment.\n\nThis one asks your server for a presigned URL and sends the bytes straight\nto object storage. It uses `XMLHttpRequest` because `fetch` reports no upload\nprogress:\n\n```ts\n// src/lib/uploads.ts\nimport { browser } from '$app/environment'\nimport { setAttachmentUploader, type AttachmentUploader } from '@svgrid/enterprise/base'\n\nconst upload: AttachmentUploader = async (file, { columnId, signal, onProgress }) => {\n const res = await fetch('/api/uploads', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ name: file.name, type: file.type, size: file.size, columnId }),\n signal,\n })\n if (!res.ok) throw new Error(res.status === 413 ? 'File is too large' : `Upload refused (${res.status})`)\n const { id, uploadUrl, fileUrl } = (await res.json()) as { id: string; uploadUrl: string; fileUrl: string }\n\n await new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest()\n xhr.open('PUT', uploadUrl)\n xhr.setRequestHeader('content-type', file.type || 'application/octet-stream')\n xhr.upload.onprogress = (e) => e.lengthComputable && onProgress(e.loaded / e.total)\n xhr.onload = () => (xhr.status < 300 ? resolve() : reject(new Error(`Storage said ${xhr.status}`)))\n xhr.onerror = () => reject(new Error('Network error'))\n xhr.onabort = () => reject(new Error('Cancelled'))\n signal.addEventListener('abort', () => xhr.abort(), { once: true })\n xhr.send(file)\n })\n\n return { id, url: fileUrl, name: file.name, type: file.type, size: file.size }\n}\n\nif (browser) setAttachmentUploader(upload)\n```\n\nThe message of the error you throw is what the user reads on the failed tile,\nnext to Retry and Remove, so write it for them.\n\nThe server checks the user and the size, signs a URL for one key, and keeps\na row per file:\n\n```ts\n// src/routes/api/uploads/+server.ts\nimport { error, json } from '@sveltejs/kit'\nimport type { RequestHandler } from './$types'\nimport { db } from '$lib/server/db'\nimport { presignPut } from '$lib/server/storage'\n\nconst MAX = 25 * 1024 * 1024\n\nexport const POST: RequestHandler = async ({ request, locals, url }) => {\n if (!locals.user) error(401, 'Sign in first')\n const { name, type, size } = (await request.json()) as { name: string; type: string; size: number }\n if (!(size > 0 && size <= MAX)) error(413, 'File is too large')\n const id = crypto.randomUUID()\n const safe = String(name).replace(/[^\\w.-]+/g, '_')\n const key = `${locals.user.teamId}/${id}/${safe}`\n await db.query('insert into files (id, team_id, key, type) values ($1, $2, $3, $4)', [id, locals.user.teamId, key, type])\n return json({ id, uploadUrl: await presignPut(key, type), fileUrl: `${url.origin}/api/files/${id}/${safe}` })\n}\n```\n\n`fileUrl` points at your app, not at the bucket. A presigned read URL\nexpires, and a cell keeps its URL for as long as the record exists. Serve\n`/api/files/[id]/[name]` with a `GET` that checks the user and the team,\nlooks up the key by `id` and answers `redirect(303, signedReadUrl)`:\nthumbnails, the preview and Download all follow the redirect, and old records\nkeep working.\n\nThe URL is absolute and ends in the file name for the sake of copy and\npaste. Copying an attachment cell writes the files' URLs, and a paste\nattaches each `http(s)` URL it finds, taking the name from the path and the\ntype from its extension. A relative URL would show fine in the cell but be\ndropped on paste, and a URL without the name would come back as a file named\nby its id, an image drawn as a chip.\n\nThe column limits what the dialog takes with\n[`AttachmentFieldProps`](../fields.md#attachments): `accept` (as for\n`<input accept>`, such as `'image/*,.pdf'`), `maxFiles` (default 20) and\n`maxSize` in bytes (default 25 MB). A file over a limit is listed under the\ntiles with the reason, such as \"At most 1 file\", \"Larger than 2 MB\" or \"Not\nan accepted type\". A URL added in the dialog, and text pasted into a cell,\nare checked the same way, their type read from the extension: what fails is\ndropped, the rest is kept. The field editor offers `accept` and `maxFiles`;\n`maxSize` is set in code:\n\n```ts\nconst photo = {\n field: 'photo',\n header: 'Photo',\n fieldType: 'attachment',\n fieldProps: { accept: 'image/*', maxFiles: 1, maxSize: 2 * 1024 * 1024 },\n}\n```\n\n`fieldProps.upload` sets an uploader for one column instead of the app's.\n\n### What the user sees\n\nThe cell shows images as thumbnails and other files as chips with the\nextension and the name, as many as the column width holds, then \"+N\". Enter\nor a double click opens the dialog: add files with \"Add files\", by dropping,\nby pasting files, or by pasting a URL into \"or paste a URL\". Each upload is a\ntile with its percent and a bar; Done reads \"Uploading 2...\" and stays\ndisabled until they finish. Tiles can be dragged to reorder, or moved with\nAlt+Left and Alt+Right; Delete removes one. Cancel or Escape leaves the cell\nas it was and aborts the uploads still running.\n\nFiles can also be dropped straight on a cell. Each one uploads on its own,\nwith a thin progress bar along the bottom of the cell, and the ones that\nupload are written to the cell in one edit. A file over a limit shows in a\n\"Not added\" toast and an upload that throws in an \"Upload failed\" toast, each\nwith the file name and the reason; the others still land. The toasts need\nthe same `<SvToaster />` as the comment store. Uploads still running when the\ncell goes away (scrolled out, or the table switched) are aborted through\n`signal`.\n\nEnter on a tile, or a click on its picture, opens the preview: images inline,\nPDFs in an iframe, anything else as its name with a Download link. Left and\nRight step through the files. A PDF is framed only when the page could read its\nbytes and they are a PDF, so your storage has to allow the page's origin with CORS\n(`Access-Control-Allow-Origin`). A file it cannot read, or one that is not a PDF\nwhatever it calls itself, offers its Download link instead.\n\n## 7. Track who changed what\n\n`lastModifiedTime` and `lastModifiedBy` change on every edit to the record by\ndefault. With `watch: 'specific'` they change only when one of `watchFields`\ndoes, which turns them into \"status changed at\" and \"status changed by\":\n\n```ts\nconst stamps = [\n { field: 'updatedAt', header: 'Last modified', fieldType: 'lastModifiedTime', fieldProps: { dateFormat: 'friendly' } },\n { field: 'statusAt', header: 'Status changed', fieldType: 'lastModifiedTime', fieldProps: { watch: 'specific', watchFields: ['status'] } },\n { field: 'statusBy', header: 'Status changed by', fieldType: 'lastModifiedBy', fieldProps: { watch: 'specific', watchFields: ['status'] } },\n]\n```\n\n`watchFields` holds column ids: the column's `id`, or its `field` when it has\nnone. The time is an ISO string; the person is the current user's id. With\nnobody signed in, the time still moves and the person stays as it was. A\ncommit that leaves the value as it was (an editor opened and closed with\nEnter) is not an edit: nothing is stamped and `onCellValueChange` does not\nfire. An automation's `updateRecord` moves the time but not the person.\n\nThe stamp is written into the row before `onCellValueChange` fires, so the\nevent's `row` already holds it. If you save cell by cell, the event names\nonly the edited column: send the stamps along, or have the server write\n`updated_at` and `updated_by` from its own clock and session, which a\nbrowser cannot fake. With `onTablesChange` or a table `source` ([Keep a base\nin a database](./data.md)) the stamps travel with the rest of the row.\n\n## Protected fields\n\nA protected field takes edits from the people it lists. Everyone else sees\nit read-only, with a lock after its name that says who can edit it:\n\n```ts\nconst columns = [\n { field: 'priority', header: 'Priority', fieldType: 'singleSelect', fieldProps: { options: PRIORITY, editors: ['u1', 'u2'] } },\n { field: 'approved', header: 'Approved', fieldType: 'checkbox', fieldProps: { editors: [] } },\n]\n```\n\n`editors` holds user ids, matched against `setCurrentUser`. An empty list\nmeans nobody can edit the values, and with nobody signed in a protected\nfield is read-only. In the base, Edit field > Who can edit its values sets\nthe list: \"Only these people\" starts with the person setting it, so they do\nnot lock themselves out. `protectFields={false}` on `<SvBase>` takes that\nchoice away from someone your app does not let change it.\n\nWhat the protection covers, for the person in front of the page:\n\n- typing, pasting, the fill handle, Delete, and the record view;\n- a board stacked by the field (its cards do not move) and a calendar or\n timeline whose dates it holds (its events do not drag);\n- an import into the table, which does not offer the field as a target.\n\nA field's name, type and options stay editable: protection is about the\nvalues. A new record still takes its group's value, so \"+\" on a group still\nadds a record to it, and a form fills the fields its author put on it.\n\nWith roles of your own, pass a check in place of the lists. It decides for\nevery field of every base on the page; `defaultCanEditField` is the\n`editors` check, to fall back on:\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, defaultCanEditField, type CanEditField } from '@svgrid/enterprise/base'\n let { tables, role } = $props()\n // Admins edit everything; everyone else follows each field's editors.\n const canEditField: CanEditField = (field, user) => role === 'admin' || defaultCanEditField(field, user)\n</script>\n\n<SvBase bind:tables {canEditField} protectFields={role === 'admin'} editable />\n```\n\nThe browser enforces this. A base whose records live in a database still\nneeds the server to refuse a write to a protected field, as it would any\nwrite the person is not allowed.\n\n<div data-docs-demo=\"710-base-personal-locked-views\" data-height=\"620\"></div>\n\n## Share a base read-only\n\nFor people who may look but not change anything, such as a client opening a\nshare link your app serves, pass `readOnly`:\n\n```svelte\n<SvBase {tables} readOnly sortable expandRows fieldMenu />\n```\n\nWhat it closes:\n\n- cells and the record view: no typing, pasting, fill handle, Delete or\n checkbox clicks, and buttons do not run automations;\n- the record menu keeps Expand record and Copy; the field menu keeps Filter,\n Group, Hide and Color rows by this field;\n- no \"+ Add row\", no \"+\" column, no \"+\" on a group, and the selection bar\n drops Edit fields and Delete;\n- a board's cards do not move and its lanes add none; a calendar's or\n timeline's events do not drag, and a day picked adds no record;\n- the tab bar has no table menu, no renaming, no Add table, no import, no\n trash, no undo, and no Download as SQL; it shows a \"View only\" badge;\n- no Automations button, and scheduled automations do not run in the page;\n- comments are read, and the box to write one is gone;\n- form views are not shared.\n\nViewers still switch tables and views, search, filter, sort, group, and open\nrecords with their activity. What they change in a view (a sort, a filter,\na new view) stays in the page while it is open, also across table switches,\nand never reaches `onTablesChange` or a table's `source`.\n\nA share on the same page as the editing base (a preview, or the demo below)\nshows the comments written in the editor, with their counts on rows and\ncards: comments are kept by table id and record id, not by base. The\nchanges in a record's activity and the unseen marks stay with the base that\nnoted them. On a separate page, the share sees the comments your\n`setRecordComments` store returns; in-page comments do not travel between\nbrowsers.\n\nAn object picks what the share shows. Every list is optional:\n\n```svelte\n<SvBase\n {tables}\n readOnly={{\n tables: ['projects', 'clients'],\n views: ['all', 'board'],\n hideFields: ['budget', 'clients.notes'],\n }}\n/>\n```\n\n`tables` and `views` are ids; a table none of whose listed views exists\nshows its first view. `hideFields` takes a column id, which hides it in\nevery table, or `tableId.columnId`. The primary field always shows. A hidden\nfield takes along every field that would show what it holds: the formulas\nthat read it, a rollup or lookup of it in another table, and the lookups,\nrollups and counts of a link to a table the share leaves out.\n\nHiding is for display. A page handed the whole base still holds the hidden\nvalues in memory, so for anything secret build the shared copy on the server\nwith `sharedTables(tables, share)`, which also takes the hidden fields'\nvalues out of the records, and send only that.\n\n<div data-docs-demo=\"717-base-read-only-share\" data-height=\"620\"></div>\n\n## The activity log\n\nEvery edit through the grid is noted for the record: a typed value, a paste,\na fill, a clear, a checkbox click, a card dragged to another lane, an edit in\nthe record view, files added in the dialog or dropped on a cell. Each note\nholds the time, the current user's id, the column, the new value and the one\nbefore it, and the record view writes it as \"Ana Ruiz changed Status\" over the\nold value and the new one as the cell shows them, or \"(cleared)\". Undo and redo\nare noted too, as \"You undid a change to Status\" and \"You redid a change to\nStatus\", so the log ends on what the record holds. A field an automation's `updateRecord` sets is\nnoted under the automation's name: \"Automation: Done ticks the box changed\nDone\".\n\nA change someone else made in the database, read in through a table's\n`realtime` source, is noted too, under the name in the record's\n`lastModifiedBy` field, with the value before it: \"Triage agent changed\nPriority\", Low → Urgent. Until the record is opened, its changed cells are\ntinted and its row number has a dot. See [Changes made\nelsewhere](./data.md#changes-made-elsewhere).\n\nBy default the log lives in memory and keeps the latest 50 changes of each\nrecord, for the 20,000 records of a table changed longest ago last: a bulk edit of a\nmillion records does not stay in the tab. In `<SvBase tables>` it is kept by base, table and record id, so it\nsurvives switching tabs; with one table it is kept per grid. Changes made by\nyour code replacing `tables` or `data` are not noted.\n\n### A history that lasts\n\nYour audit log already has every change. `setRecordHistory` lets the record\nview read it, and hands it each change made in the page to keep:\n\n```ts\nimport { setRecordHistory, type RecordChange } from '@svgrid/enterprise/base'\n\nsetRecordHistory({\n // Each time a record is opened. A promise is fine: the activity says\n // \"Loading the history...\" until it settles.\n list: async (rowId, { tableId }) => {\n const res = await fetch(`/api/history/${tableId}/${rowId}`)\n return (await res.json()) as RecordChange[]\n },\n // Each change made in this page, as it is made.\n add: (rowId, change, { tableId }) => {\n void fetch(`/api/history/${tableId}/${rowId}`, { method: 'POST', body: JSON.stringify(change) })\n },\n})\n```\n\nA change is `{ at, by, columnId, value, from? }` (`at` in milliseconds,\n`by` a user id from `setFieldUsers`), plus `automation` for a change an\nautomation made, `via` for a proposal someone accepted (\"CRM agent (accepted\nby Ana)\"), and `through` for a change a person made through an app as\nthemselves, an AI chat client say (\"Ana via Claude\"). The record view\nshows what `list` gave with this session's changes it does not have yet;\ngive back the `at` that `add` received, and a change shows once. A change\nmade elsewhere and read in through `realtime` is not passed to `add`:\nwhoever made it keeps it.\n\n`historyOf(ctrl, rowId)` gives a record's history as the record view shows\nit, for a panel of your own. `setRecordHistory(null)` goes back to memory.\n\n## The record menu\n\nRight-click a record in a base's grid:\n\n| Item | What it does |\n| --- | --- |\n| Expand record | Opens the record, with or without `expandRows` |\n| Comment | Opens the record with the comment box focused |\n| Insert record above, Insert record below | A new record beside this one with the values of the fields the view groups by, so it stays in the group; editing starts on its first field |\n| Duplicate record | A copy below, with lists copied; autonumber, created and last modified fields get fresh values |\n| Copy, Paste | The grid's own cell copy and paste |\n| Delete record | Asks \"Delete record?\" (\"Write the brief is deleted, and its links from other records go with it.\"), then removes it and fires `onRowsDelete` |\n\nWithout `editable`, only Expand record, Comment and Copy show. A new record\nfrom the menu is made the way \"+ Add row\" makes one: the `rowAdder` defaults,\na new id, the next autonumber, the current user in created by, and `onRowAdd`\nfired, so a table with a database writes it. The grid scrolls to it. A Kanban\ncard's right-click menu has Expand record and Comment, and with `editable`\n\"Move to\" a lane, Duplicate record and Delete record. Passing your own\n`contextMenu` to `SvBase` replaces the grid's menu.\n\n## Pitfalls\n\n- **No current user, no author.** Without `setCurrentUser`, new rows get\n `null` in created by, and an edit leaves last modified by as it was, so\n the field names whoever edited last while signed in.\n- **People are page-wide.** `setFieldUsers` and `setCurrentUser` set one list\n and one person for every base on the page. Two bases for two teams on one\n page share them.\n- **Records need real ids.** Comments and the activity are keyed by row id:\n each record's `id`, or `getRowId`. With one table a record without an `id`\n falls back to its index, so its comments move to another record when a row\n above it is deleted. In `<SvBase tables>` every record without an `id`\n shares the id `''`, and with it one thread. Give every record an id.\n- **Your store tells tables apart by id only.** In memory, each `<SvBase>`\n keeps its own comments and activity, even when two bases on one page use\n the same table ids. Your comment store gets the table id and nothing about\n the base: if two bases share one store and their table ids, key the store\n by something of your own as well. With `serverIds: true` a new record\n keeps the page's id until the table loads again; re-key its comments when\n the insert returns.\n- **`'@me'` is whoever runs the filter.** Before `setCurrentUser` it\n matches no one; the grid filters again once a user is set. In an\n automation's condition it is the person whose edit set it off, and on the\n server runner, where nobody is signed in, it matches no one.\n- **A URL's type is its extension.** Under `accept: 'image/*'` a URL with no\n extension is refused, and a URL's size is checked only when it is known.\n The browser checks are for the user; check types and sizes on the server\n too.\n- **Storage keeps what the cell drops.** Removing a file, Cancel after an\n upload finished, or deleting the record leaves the object in the bucket.\n Clean up on the server, for example files no record has pointed at for a\n day.\n- **`fieldProps.upload` does not survive JSON.** A function in a column is\n lost when you store columns in a database through `onTablesChange`. Use\n `setAttachmentUploader` and branch on `columnId` instead.\n\n## Next\n\n- [Linked records](./linked-records.md): tasks that point at milestones,\n people that point at teams, and the records that link back.\n- [Formulas](./formulas.md): fields worked out from other fields.\n- [Views](./views.md): grids, boards, calendars and galleries over the same\n records.\n- [Forms](./forms.md): let people outside the team add records.\n- [Your own field type](./custom-field-type.md): a cell of your own, with the\n grid's `ctrl` to open records from it.\n- [Automations](./automations.md): tell the assignee when a task is blocked.\n"
5189
5189
  },
5190
5190
  {
5191
5191
  "slug": "help/base/custom-field-type",
5192
5192
  "path": "docs/help/base/custom-field-type.md",
5193
5193
  "title": "Build your own field type",
5194
5194
  "section": "SvGrid Base",
5195
- "markdown": "# Build your own field type\n\nA field type decides what a column holds and how it behaves: what the cell\nshows, which editor opens, how pasted text is read, what the footer can sum.\nThe built-in types are registered with `registerFieldType`, the same call\nyou will use, so your type gets the field editor, the views and the\nexpanded record the way they do.\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\nThis page builds two types. **Phone (international)** stores numbers as\nE.164 text (`+14155550123`), shows them the local way, dials on click and\nreads whatever people paste. **Traffic light** stores a score from 0 to 100\nand draws a green, amber or red light with its own cell and its own editor.\nThe [field types page](../fields.md#your-own-field-type) has the short\nversion.\n\n![A FieldTypeDef on the left, where each member shows up on the right: id, label, icon and group in the type picker and the header; fill's formatter in cell text, footer summaries, group headers and cards; valueParser for typed edits, paste, forms and type changes; editorType for the editor; sortValue for sort order; cellDataType for filter operators, summary choices, sort labels and the SQL column type; cell and hasCell for grid cells, group headers, cards and the record view; properties and defaults in the Edit field dialog; newRowValue for new records; onCreate for existing rows when the field is created; copy: false for a duplicated record, which gets a new value from newRowValue](/docs-media/base-field-type.svg)\n\n## 1. Decide what the field stores\n\nSettle the stored value before you write the type. Filters, sorting, copy,\nthe database and your API all see the stored value; only the cell and the\nformatter see the text on screen. A phone number stored as `+14155550123`\ndials from any app, sorts by country and compares exactly.\n\n```ts\n// phone-field.ts\nexport type PhoneProps = { country: string; display: 'national' | 'international' }\n\nconst E164 = /^\\+[1-9]\\d{6,14}$/\n\n/** Typed or pasted text as E.164 (\"+14155550123\"), or null when it is no phone number. */\nexport function toE164(text: string, country: string): string | null {\n let s = text.trim().replace(/^tel:/i, '').replace(/[\\s().\\-\\/]/g, '')\n if (s.startsWith('00')) s = '+' + s.slice(2)\n if (!s.startsWith('+')) {\n // A national number: drop the trunk prefix (1 in North America, 0 elsewhere).\n s = country === '1' ? s.replace(/^1(?=\\d{10}$)/, '') : s.replace(/^0/, '')\n // North American numbers need all ten digits: no guessing an area code.\n if (country === '1' && !/^\\d{10}$/.test(s)) return null\n s = `+${country}${s}`\n }\n return E164.test(s) ? s : null\n}\n\n/** A stored value as the field shows it. A number from another country shows as stored. */\nexport function showPhone(value: unknown, p: PhoneProps): string {\n const s = value == null ? '' : String(value)\n const home = `+${p.country}`\n if (!E164.test(s) || !s.startsWith(home)) return s\n const rest = s.slice(home.length)\n if (p.country === '1' && rest.length === 10) {\n const local = `(${rest.slice(0, 3)}) ${rest.slice(3, 6)}-${rest.slice(6)}`\n return p.display === 'national' ? local : `+1 ${local}`\n }\n const grouped = rest.replace(/\\B(?=(\\d{4})+$)/g, ' ')\n return p.display === 'national' ? `0${grouped}` : `${home} ${grouped}`\n}\n```\n\n| Typed, home country | Stored | Shown (national) |\n|---|---|---|\n| `(415) 555-0123`, +1 | `+14155550123` | `(415) 555-0123` |\n| `1 415 555 0123`, +1 | `+14155550123` | `(415) 555-0123` |\n| `020 7946 0958`, +44 | `+442079460958` | `020 7946 0958` |\n| `0044 20 7946 0958`, +1 | `+442079460958` | `+442079460958` |\n| `555-0123`, +1 | refused | |\n| `n/a` | refused | |\n\nBoth are plain functions, so you can unit-test them without a grid.\n\n## 2. Register the type\n\n```ts\n// phone-field.ts, continued\nimport { registerFieldType, type FieldTypeDef } from '@svgrid/enterprise/base'\n\nexport const phoneType: FieldTypeDef<PhoneProps> = {\n id: 'intlPhone',\n label: 'Phone (international)',\n description: 'Stored as +14155550123, shown in the local format, dialed with a click.',\n icon: 'M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2',\n group: 'basic',\n width: 170,\n defaults: { country: '1', display: 'national' },\n fill: (def, props) => ({\n ...def,\n editorType: def.editorType ?? 'text',\n formatter: def.formatter ?? ((ctx: { value: unknown }) => showPhone(ctx.value, props)),\n // Typed and pasted text is stored as E.164; text that is no number keeps the old value.\n valueParser: def.valueParser ?? ((x: { newValue: unknown; oldValue: unknown; rawInput?: unknown }) => {\n const text = String((typeof x.rawInput === 'string' ? x.rawInput : x.newValue) ?? '').trim()\n if (!text) return null\n return toE164(text, props.country) ?? x.oldValue\n }),\n // Values that never went through the parser (loaded data, an API write) are flagged.\n validate: def.validate ?? ((ctx: { value: unknown }) =>\n ctx.value == null || ctx.value === '' || E164.test(String(ctx.value)) ? null : 'Not a +country phone number'),\n }),\n}\n\nregisterFieldType(phoneType)\n```\n\nImport the file once at app start, next to `enableBase()`, and name the type\nin a column:\n\n```ts\nimport { enableBase } from '@svgrid/enterprise/base'\nimport './phone-field'\n\nenableBase()\n\nconst columns = [\n { field: 'name', header: 'Name', fieldType: 'text' },\n { field: 'phone', header: 'Phone', fieldType: 'intlPhone', fieldProps: { country: '44' } },\n]\n```\n\n`fill` is where a type turns into grid behavior. It receives the column as\nthe app declared it, the type's `defaults` with the column's `fieldProps` on\ntop (`props`), and a context with every column. It returns the column the\ngrid sees: `editorType`, `formatter`, `valueParser`, `validate`, `align`,\n`cellDataType`, `sortValue`, `editable`. Write each key as\n`def.key ?? yours`, so a column that sets `formatter` itself keeps it. The\nbuilt-ins in `builtin-types.ts` follow that rule.\n\nWith this registered, the header shows the phone icon before \"Phone\", cells\nread `020 7946 0958`, and \"Phone (international)\" appears in the field\neditor's type picker under \"Fields\", with its description under the picker\nonce it is chosen. `width` is the width a new field of this type starts\nwith when someone adds it there.\n\n![The Add field dialog in a base, its type list scrolled to show the end of the Fields section (Phone number, Email, URL, Barcode, Button), then Numbers and time (Number, Duration, Rating) and Computed and automatic (Formula, Created time, Last modified time, Created by), with the chosen type's description and its Default value property below](/docs-media/base-field-type.png)\n\nThe picker draws a section per `group`, in a fixed order, and skips a\nsection no type uses. The built-ins fill only Fields, Numbers and time,\nComputed and automatic, and Other tables (Date and User sit under Fields),\nso \"Dates\" and \"People\" appear only once a type of yours names them. A\n`group` the list does not know puts the type under Fields. Once more than\neight types are on offer, a \"Find a type\" box sits above the list.\n\n## 3. Read what people type and paste\n\n`valueParser` gets `newValue` (after the grid's own coercion for the\neditor type), `oldValue`, `rawInput` (the text as typed or pasted), the\nrow as `data` and the `columnId`. It runs on a cell edit, a paste (one\nvalue pasted over a range included), a full-row edit, an edit in the\nexpanded record and a form field. Returning `oldValue` refuses the input:\npaste `n/a` over a number and the number stays, and the page says that\nvalue did not fit. The text editor\nopens on the stored `+442079460958`, and whatever the user leaves in it\ngoes back through the parser.\n\n`validate` runs for every rendered cell, so a bad value gets the red mark\nand the message as its tooltip even when it was loaded that way. While the\ncell's editor is open, it checks the draft before `valueParser` has read\nit, so `(415) 555-0123` shows red until Enter stores it as E.164. Add\n`rejectInvalid: def.rejectInvalid ?? true` to refuse a flagged edit\noutright; a paste is not checked against it, which is why the parser does\nthe refusing here.\n\nCheck the filled column without mounting anything:\n\n```ts\nimport { fillFieldColumn } from '@svgrid/enterprise/base'\n\nconst col = fillFieldColumn({ field: 'phone', fieldType: 'intlPhone', fieldProps: { country: '44' } })\nconst show = col.formatter as (ctx: { value: unknown }) => string\nconst parse = col.valueParser as (x: { newValue: unknown; oldValue: unknown; rawInput: string }) => unknown\n\nshow({ value: '+442079460958' }) // '020 7946 0958'\nparse({ newValue: '020 7946 0958', oldValue: null, rawInput: '020 7946 0958' }) // '+442079460958'\nparse({ newValue: 'n/a', oldValue: '+442079460958', rawInput: 'n/a' }) // '+442079460958'\n```\n\n## 4. Draw the cell\n\nWithout `cell`, the grid draws the formatter's text. A cell component can\ndraw anything; this one is a `tel:` link, so a click dials.\n\n```svelte\n<!-- PhoneCell.svelte -->\n<script lang=\"ts\">\n import { linkHref, type FieldCellProps } from '@svgrid/enterprise/base'\n import { showPhone, type PhoneProps } from './phone-field'\n\n let { value, props }: FieldCellProps<PhoneProps> = $props()\n // 'tel:+14155550123'; null unless the value is 3 to 20 digits with an optional +.\n const href = $derived(linkHref('phone', value))\n const text = $derived(showPhone(value, props))\n</script>\n\n{#if href}\n <!-- Stop pointerdown: a click on the number dials, a click beside it selects the cell. -->\n <a class=\"phone\" {href} onpointerdown={(e) => e.stopPropagation()}>{text}</a>\n{:else}\n <span class=\"phone is-bad\">{text}</span>\n{/if}\n\n<style>\n .phone { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }\n a.phone { text-decoration: underline; text-decoration-color: var(--sg-muted, #94a3b8); text-underline-offset: 2px; }\n .is-bad { color: var(--sg-muted, #64748b); }\n</style>\n```\n\n```ts\nimport { registerFieldType } from '@svgrid/enterprise/base'\nimport { phoneType } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nregisterFieldType({ ...phoneType, cell: PhoneCell })\n```\n\nRegistering an id again replaces the type and keeps its place in the\npicker; in your own file, add `cell: PhoneCell` to `phoneType` instead.\nThe cell receives `FieldCellProps`: `value`, `props` (defaults merged with\n`fieldProps`), `row` (`{ id, original }`), `column` (`{ id, columnDef }`)\nand `ctrl`, the grid. `linkHref` is the helper the built-in URL, email and\nphone cells use; it returns an href only for the scheme the kind allows,\nso a value like `javascript:alert(1)` never becomes a link.\n\n## 5. Add properties to the field editor\n\n`properties` is what \"Edit field\" shows for the type. Each property is\nkept under its `key` in the column's `fieldProps`.\n\n```ts\nimport { registerFieldType, type FieldPropertyDef } from '@svgrid/enterprise/base'\nimport { phoneType } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nexport const PHONE_PROPERTIES: FieldPropertyDef[] = [\n {\n key: 'country', label: 'Home country', kind: 'choice',\n choices: [\n { value: '1', label: 'United States, Canada (+1)' },\n { value: '44', label: 'United Kingdom (+44)' },\n { value: '49', label: 'Germany (+49)' },\n { value: '359', label: 'Bulgaria (+359)' },\n ],\n hint: 'Numbers typed without a + are read as this country\\'s.',\n },\n {\n key: 'display', label: 'Show numbers of that country', kind: 'segmented',\n choices: [{ value: 'national', label: '(415) 555-0123' }, { value: 'international', label: '+1 (415) 555-0123' }],\n },\n]\n\nregisterFieldType({ ...phoneType, cell: PhoneCell, properties: PHONE_PROPERTIES })\n```\n\nThe dialog draws a dropdown with the hint under it, then a row of two\nbuttons. A property the column has not set shows the type's default.\nPicking your type in the dialog starts the draft from your `defaults` and\nkeeps only the values of properties your type also lists, so a field made\nthere saves your defaults into its `fieldProps`; changing `defaults` later\ndoes not move it. On save, empty strings, empty lists (other than\n`options`) and `undefined` are dropped. A `choice` hands back the option's\n`value` string; a `number` hands back a number, or `undefined` when\ncleared.\n\n## 6. A type with its own cell: Traffic light\n\nThe second type stores a number and draws a light. Its properties set the\nthresholds, the direction and the green color.\n\n```ts\n// traffic-light.ts\nimport { registerFieldType, formatNumber, BRIGHT, type FieldTypeDef } from '@svgrid/enterprise/base'\nimport TrafficLightCell from './TrafficLightCell.svelte'\n\nexport type LightProps = {\n green: number\n amber: number\n higherIsBetter: boolean\n goodColor: string\n show: 'light' | 'number'\n showNumber: boolean\n default?: number | string\n}\n\nexport const LIGHT_DEFAULTS: LightProps = {\n green: 80, amber: 50, higherIsBetter: true, goodColor: '#20c933', show: 'light', showNumber: true,\n}\n\nexport type Light = { band: 'green' | 'amber' | 'red'; color: string; label: string }\n\n/** The light a score gets under the field's thresholds. */\nexport function lightOf(n: number, p: LightProps): Light {\n const reaches = (limit: number) => (p.higherIsBetter ? n >= limit : n <= limit)\n if (reaches(Number(p.green))) return { band: 'green', color: p.goodColor, label: 'On track' }\n if (reaches(Number(p.amber))) return { band: 'amber', color: '#fcb400', label: 'At risk' }\n return { band: 'red', color: '#f82b60', label: 'Off track' }\n}\n\n/** A stored value as a score, or null. Old data may hold \"72\" or \"72%\" as text. */\nexport function scoreOf(value: unknown): number | null {\n if (value == null || value === '') return null\n const n = typeof value === 'number' ? value : Number(String(value).replace(/[%\\s]/g, ''))\n return Number.isFinite(n) ? Math.max(0, Math.min(100, n)) : null\n}\n\nexport const trafficLightType: FieldTypeDef<LightProps> = {\n id: 'trafficLight',\n label: 'Traffic light',\n description: 'A score from 0 to 100, shown as a green, amber or red light.',\n icon: 'M9 2h6v20H9zM12 6h.01M12 12h.01M12 18h.01',\n group: 'number',\n width: 120,\n defaults: LIGHT_DEFAULTS,\n properties: [\n { key: 'green', label: 'Green at', kind: 'number', min: 0, max: 100, hint: 'With \"Higher is better\" off, green is at or below this value.' },\n { key: 'amber', label: 'Amber at', kind: 'number', min: 0, max: 100, hint: 'Past amber the light is red.' },\n {\n key: 'higherIsBetter', label: 'Higher is better', kind: 'checkbox',\n // Flipping the direction swaps the thresholds. `p` is the draft with\n // the type's defaults filled in, as `visible` sees it.\n alsoSets: (_v, p) => ({ green: p.amber, amber: p.green }),\n },\n { key: 'goodColor', label: 'Green color', kind: 'color', palette: BRIGHT },\n { key: 'show', label: 'Show as', kind: 'segmented', choices: [{ value: 'light', label: 'Light' }, { value: 'number', label: 'Number' }] },\n { key: 'showNumber', label: 'Number next to the light', kind: 'checkbox', visible: (p) => p.show !== 'number' },\n { key: 'default', label: 'Default value', kind: 'default', hint: 'New rows start with this score.' },\n ],\n fill: (def) => ({\n ...def,\n cellDataType: def.cellDataType ?? 'number',\n editorType: def.editorType ?? 'trafficLight',\n align: def.align ?? 'left',\n formatter: def.formatter ?? ((ctx: { value: unknown }) => {\n const n = scoreOf(ctx.value)\n return n == null ? '' : formatNumber(n, { precision: 0 })\n }),\n valueParser: def.valueParser ?? ((x: { newValue: unknown; oldValue: unknown; rawInput?: unknown }) => {\n if (typeof x.rawInput !== 'string') return scoreOf(x.newValue)\n if (!x.rawInput.trim()) return null\n return scoreOf(x.rawInput) ?? x.oldValue\n }),\n }),\n cell: TrafficLightCell,\n // \"Show as: Number\" hands the cell back to the grid, which draws the formatter's text.\n hasCell: (p) => p.show !== 'number',\n newRowValue: ({ props }) => (props.default == null ? undefined : scoreOf(props.default)),\n}\n\nregisterFieldType(trafficLightType)\n```\n\n```svelte\n<!-- TrafficLightCell.svelte -->\n<script lang=\"ts\">\n import type { FieldCellProps } from '@svgrid/enterprise/base'\n import { lightOf, scoreOf, type LightProps } from './traffic-light'\n\n let { value, props }: FieldCellProps<LightProps> = $props()\n const n = $derived(scoreOf(value))\n const light = $derived(n == null ? null : lightOf(n, props))\n const number = $derived(n == null ? '' : String(Math.round(n)))\n</script>\n\n{#if light}\n <span class=\"tl\" title={`${light.label}: ${number}`}>\n <span class=\"tl-dot\" style:background={light.color} role=\"img\" aria-label={light.label}></span>\n {#if props.showNumber}<span class=\"tl-num\">{number}</span>{/if}\n </span>\n{/if}\n\n<style>\n .tl { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }\n .tl-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }\n .tl-num { font-variant-numeric: tabular-nums; color: var(--sg-fg, #0f172a); }\n</style>\n```\n\n`cellDataType: 'number'` makes it a number column to the rest of the base:\nthe footer offers Sum, Average, Median, Min, Max and Range, each formatted\nby your `formatter`; the column menu labels its sorts \"1 → 9\" and\n\"9 → 1\"; the view bar filters it with =, <, > and the other number\noperators. The light has an `aria-label`, so a screen reader user gets the\nband as a word, not only a color.\n\nIn \"Edit field\" the type shows two number boxes, a checkbox, ten color\nswatches, a Light / Number switch, a second checkbox and the default box.\n\"Number next to the light\" disappears while the switch is on Number,\nbecause `visible` reads the draft. Group by this field and each score is a\ngroup of its own: the grid groups by the stored value, and the group\nheader draws its light.\n\nUntil step 7 registers an editor named `trafficLight`, the cell edits in a\nplain text box and the parser reads the text: type `72%` and 72 is stored.\n\n## 7. Give it its own editor\n\nAn editor is a Svelte component registered with `registerCellEditor` from\n`@svgrid/grid` under the name your `fill` puts in `editorType`.\n\n```svelte\n<!-- TrafficLightEditor.svelte -->\n<script lang=\"ts\">\n import { fieldPropsOf } from '@svgrid/enterprise/base'\n import { lightOf, scoreOf, type LightProps } from './traffic-light'\n\n let {\n value,\n columnDef,\n onChange,\n onCommit,\n onCommitAndMove,\n onCancel,\n }: {\n value: unknown\n columnDef?: Record<string, unknown>\n onChange: (v: unknown) => void\n onCommit: (v?: unknown) => void\n onCommitAndMove: (v: unknown, direction: 1 | -1) => void\n onCancel: () => void\n } = $props()\n\n // The column's properties: the type's defaults under its fieldProps.\n const props = $derived(fieldPropsOf(columnDef ?? {}) as LightProps)\n // svelte-ignore state_referenced_locally\n let n = $state(scoreOf(value) ?? 0)\n const light = $derived(lightOf(n, props))\n\n function focusOnMount(el: HTMLElement) {\n queueMicrotask(() => el.focus())\n }\n function slide(e: Event & { currentTarget: HTMLInputElement }) {\n n = Number(e.currentTarget.value)\n // Keep the grid's draft in step, so a click elsewhere saves what is shown.\n onChange(n)\n }\n function onKey(e: KeyboardEvent) {\n if (e.key.startsWith('Arrow') || e.key === 'Home' || e.key === 'End') {\n // The slider moves; the grid's active cell stays put.\n e.stopPropagation()\n return\n }\n if (e.key === 'Enter') onCommit(n)\n else if (e.key === 'Tab') onCommitAndMove(n, e.shiftKey ? -1 : 1)\n else if (e.key === 'Escape') onCancel()\n else return\n e.preventDefault()\n e.stopPropagation()\n }\n</script>\n\n<span class=\"tle\">\n <input type=\"range\" min=\"0\" max=\"100\" step=\"1\" value={n} aria-label=\"Score\"\n style:accent-color={light.color} use:focusOnMount oninput={slide} onkeydown={onKey} />\n <output>{n}</output>\n</span>\n\n<style>\n .tle { display: flex; align-items: center; gap: 8px; height: 100%; padding: 0 8px; background: var(--sg-bg, #fff); }\n .tle input { flex: 1; min-width: 0; }\n .tle output { width: 3ch; text-align: end; font-variant-numeric: tabular-nums; }\n</style>\n```\n\n```ts\nimport { registerCellEditor } from '@svgrid/grid'\nimport TrafficLightEditor from './TrafficLightEditor.svelte'\n\nregisterCellEditor('trafficLight', {\n component: TrafficLightEditor,\n props: (ctx) => ({\n value: ctx.value,\n columnDef: ctx.columnDef,\n onChange: ctx.onChange,\n onCommit: ctx.onCommit,\n onCommitAndMove: ctx.onCommitAndMove,\n onCancel: ctx.onCancel,\n }),\n typeToEdit: false,\n})\n```\n\nDouble-click or F2 opens the slider in the cell. Arrows move it, Enter\nsaves, Tab saves and moves to the next cell, Escape leaves the cell as it\nwas. `typeToEdit: false` keeps typed keys from opening it; a function such\nas `(c) => /^[0-9]$/.test(c)` would open it on a digit, with `typed: true`\nand the digit as `value` on the context. Without `props`, the grid passes\n`value`, `onChange`, `onCommit`, `onCancel`, `onCommitAndMove`,\n`onRequestClose` and `inCell`. The context also carries `rowId`,\n`columnId`, `columnDef`, `row`, `grid`, `typed` and `onCommitAndMoveDown`.\n\nThe expanded record and a form open the same registered editor, with\n`inCell: false`. A value from a registered editor reaches `valueParser` as\nit is, with `rawInput` set to that same value rather than to text.\n\n## 8. Values the type writes itself\n\n`newRowValue` gives each new row a value: from the row adder, a group's\n\"+\", a form, a board lane. Return `undefined` to fall back to the field's\n`default` property. `onCreate` fills every existing row once, when someone\ncreates the field in the field editor. Both get a `FieldRowContext`: the\nfield's `props`, its `field` key and the table's `rows`.\n\n```ts\nimport { registerFieldType } from '@svgrid/enterprise/base'\n\nconst ticket = (prefix: string, n: number) => `${prefix}${String(n).padStart(4, '0')}`\n/** The number in \"T-0042\", or 0. */\nconst numberIn = (v: unknown) => Number(/(\\d+)$/.exec(String(v ?? ''))?.[1] ?? 0)\n\nregisterFieldType({\n id: 'ticketId',\n label: 'Ticket ID',\n description: 'T-0001, T-0002 and on. Set automatically.',\n icon: 'M4 7h16v10H4zM9 7v10',\n group: 'computed',\n width: 100,\n defaults: { prefix: 'T-' },\n properties: [{ key: 'prefix', label: 'Prefix', kind: 'text', placeholder: 'T-' }],\n fill: (def) => ({ ...def, editable: def.editable ?? false }),\n onCreate: ({ rows, props }) => rows.map((_, i) => ticket(String(props.prefix), i + 1)),\n newRowValue: ({ rows, field, props }) =>\n ticket(String(props.prefix), rows.reduce((max, r) => Math.max(max, numberIn(r?.[field])), 0) + 1),\n copy: false,\n})\n```\n\nWhen `onCreate` returns values, `onColumnAdd` hands your app the new rows\nas `data` next to the columns, so store both. `editable: false` also keeps\nthe field out of a form. \"Duplicate record\" copies every stored field into\nthe copy. `copy: false` opts a type out: the copy gets a new value from\n`newRowValue` (the next ticket number here), or the field's `default` when\nthe type has no `newRowValue`. Leave it out and two records share a ticket\nnumber. The built-in autonumber, created and last-modified fields always\nget fresh values. The traffic light in step\n6 reads its `default` property in `newRowValue` because a `default`\nproperty on a custom type is drawn as a text box and saved as a string.\n\n## Replace a built-in type\n\nRegister a type with a built-in id before calling `enableBase()`:\n`enableBase()` registers each built-in only when no type has its id yet.\n\n```ts\nimport { enableBase, registerFieldType } from '@svgrid/enterprise/base'\nimport { phoneType, PHONE_PROPERTIES } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nregisterFieldType({ ...phoneType, id: 'phone', label: 'Phone number', cell: PhoneCell, properties: PHONE_PROPERTIES })\nenableBase()\n```\n\nEvery column with `fieldType: 'phone'` now uses yours, and it is listed\nfirst in its picker section, since the picker keeps registration order.\nSome behavior stays keyed to the id rather than to your definition: changing a\nfield to `phone` converts its values as text without your parser, the\nfilter treats it as text, and a form checks it as a phone number.\n`baseToSql` follows your `fill`'s `cellDataType`, as for any registered\ntype. Override a number type such as `rating` and the type change, the\nfilter and `baseToSql` keep treating it as a number.\n\n## Keep an old type id\n\nRename a type without breaking saved columns: register the old id with\n`editAs`, pointing at the new one.\n\n```ts\nimport { registerFieldType } from '@svgrid/enterprise/base'\nimport { phoneType } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nregisterFieldType({ ...phoneType, id: 'mobile', label: 'Mobile', cell: PhoneCell, editAs: { type: 'intlPhone', props: { display: 'international' } } })\n```\n\nColumns that say `fieldType: 'mobile'` still draw, and the type picker\nleaves `mobile` out. \"Edit field\" opens such a column as Phone\n(international) with `display: 'international'` on top of its properties.\nSaving writes `fieldType: 'intlPhone'` and converts the stored values as\nany type change does, through the `intlPhone` parser, which keeps every\nvalid E.164 number. The conversion starts from the stored type, `mobile`,\nso the editor warns before you save when it would clear cells: \"Mobile to\nPhone (international) converts the values. 2 cells will be cleared or cut\nshort.\" When\nevery value converts it says nothing, since you did not pick a new type.\nThe built-in Currency and Percent types work this way: both open as Number.\n\n## Where your type shows up\n\n| Place | What it uses |\n|---|---|\n| Grid cell | `cell` when `hasCell` allows it, else the filled column's `formatter` and `align` |\n| Header, type picker, record view and form labels, view bar panels, gallery labels | `icon`, drawn as a 24x24 stroke path |\n| Group header | `cell`, given the group's first record as `row`; else `formatter` |\n| Gallery and Kanban cards | `cell`, with `ctrl` the grid at the card's width and editing off; else `formatter` |\n| Expanded record | `cell` for a non-empty value; a click opens the editor `editorType` names (a registered one, the date picker or a text box) and saves through the grid, so `valueParser` and `rejectInvalid` apply |\n| Form view | The same cells and editors; the editor's value goes through the grid's coercion and `valueParser`, as in a cell edit. On submit the form runs `validate` and refuses the record while it fails, with or without `rejectInvalid` |\n| Footer summary | Number summaries for `cellDataType: 'number'`, date ones for `'date'` and `'dateString'`, checked, unchecked and percent checked for `'boolean'`, as a checkbox gets; counts for the rest; see [Summaries at the bottom](../fields.md#summaries-at-the-bottom) |\n| View bar filter | By the filled column's `cellDataType`: the number operators for `'number'`, the date ones for `'date'` and `'dateString'`, \"is\" checked / unchecked for `'boolean'`; otherwise the text operators (contains, does not contain, is, is not, is empty, is not empty) on the stored value |\n| Sort | The stored value; a `sortValue` in `fill` sorts by a number of your own, as a single select sorts by option order |\n| Copy | What the cell shows when your `valueParser` reads that text back to the same value. Otherwise `String(value)`: an array copies as `a,b`, an object as `[object Object]`, so keep stored values to strings, numbers and arrays of them. A paste of a copy made on the same page into the same type gets the stored value back, whatever the text says |\n| Fill handle | One source cell copies. Two or more repeat: a series is for number and date fields |\n| Paste | `valueParser` with the pasted text as `rawInput`; `rejectInvalid` does not refuse it |\n| Changing a field to your type | Each value as text through your `valueParser`, as a paste with `oldValue: null`; what it refuses or throws on is cleared and counted in the editor's warning. Without a parser, a list becomes its text and a plain value stays |\n| Changing your type to a built-in | The built-in's conversion, reading your value as text (`convertValue`) |\n| `baseToSql` | By the filled column's `cellDataType`, as the built-ins map: `double precision` for `'number'`, `boolean` for `'boolean'`, `timestamptz` for `'date'`, `date` for `'dateString'`; otherwise `text` |\n\n`convertValue(value, from, to, toProps)` and\n`countCleared(values, from, to, toProps)` are exported, so a migration\nscript can preview a type change the way the field editor's warning does.\n`toProps` is the new field's `fieldProps`, which your `fill` sees when the\nparser is made. `filterKindOf(def)` returns `'number'`, `'date'` or\n`'checkbox'` from the filled column's `cellDataType` for an id it does not\nknow, and `'text'` when `cellDataType` says nothing; formula, lookup and\nrollup fields follow their `cellDataType` the same way. `operatorsFor(kind)`\nlists the operators a kind offers.\n\n## FieldTypeDef\n\n| Member | Type | What it does |\n|---|---|---|\n| `id` | `string` | The name columns use in `fieldType` |\n| `label` | `string` | Name in the type picker; a new unnamed field is named after it |\n| `description` | `string` | One line under the type list once the type is chosen |\n| `icon` | `string` | SVG path data, 24x24 viewBox, drawn as a stroke |\n| `group` | `'basic' \\| 'number' \\| 'date' \\| 'people' \\| 'computed' \\| 'relation'` | Picker section, in this order: Fields, Numbers and time, Dates, People, Computed and automatic, Other tables; default `'basic'` |\n| `defaults` | `P` | Property values a column gets when its `fieldProps` leave them out |\n| `fill` | `(def, props: P, ctx: FieldFillContext) => Record<string, unknown>` | Turns the declared column into the column the grid sees. Optional: without it the column stays as declared and still gets its footer summary |\n| `cell` | `Component<FieldCellProps<P>>` | Draws the cell |\n| `hasCell` | `(props: P) => boolean` | Whether `cell` draws; default always |\n| `properties` | `ReadonlyArray<FieldPropertyDef>` | What the field editor lets a user set |\n| `width` | `number` | Width of a new field made in the field editor (else 150) |\n| `newRowValue` | `(ctx: FieldRowContext) => unknown` | The value a new row gets |\n| `onCreate` | `(ctx: FieldRowContext) => unknown[] \\| null` | Values for every existing row when the field is created |\n| `copy` | `false` | A duplicated record gets a new value from `newRowValue` (else the field's `default`) instead of a copy |\n| `editAs` | `{ type: string; props: Record<string, unknown> }` | Keeps an old id drawing; edited as `type` and left out of the picker |\n\n## Property kinds\n\nEvery `FieldPropertyDef` has `key`, `label` and `kind`, and may have\n`visible(props)` (shown only when it returns true), `hint` (a line under the\ncontrol, for every kind) and `alsoSets(value, props)` (other keys to change\nwith this one). `visible` and `alsoSets` get the same `props`: the draft\nwith the type's defaults filled in, before this change.\n\n| `kind` | Extra keys | Draws | Hands back |\n|---|---|---|---|\n| `number` | `min`, `max` | Number box | `number`, or `undefined` when cleared |\n| `text` | `placeholder` | Text box | `string` |\n| `checkbox` | | Checkbox with the label beside it | `boolean` |\n| `choice` | `choices`: a list, or `(ctx: FieldEditorContext) => list` | Dropdown, with \"Choose...\" while the value is not in the list | The option's `value` |\n| `segmented` | `choices` | Row of buttons | The option's `value` |\n| `color` | `palette` | Swatches; `BRIGHT` is the ten-color set the built-ins use | Hex string |\n| `icon` | `icons` (`value`, `label`, `path`) | Icon buttons, the picked one in the `color` property's color | The icon's `value` |\n| `options` | | The select options editor | Option list |\n| `default` | | A checkbox, select, person or number input for those built-in types; a text box for every other type, yours included | Depends on the type; a `string` for yours |\n| `formula` | | Formula box with field buttons, a functions list and error checking; a formula that does not compile blocks Save | `string` |\n| `columns` | | Chips for the other fields | Column ids |\n\nA `choice` whose options depend on the table passes a function, as the\nbuilt-in Lookup and Rollup do to list the table's link fields:\n\n```ts\nimport type { FieldEditorContext, FieldPropertyDef } from '@svgrid/enterprise/base'\n\nconst numberFields = (ctx: FieldEditorContext) =>\n ctx.columns.filter((c) => c.fieldType === 'number').map((c) => ({ value: String(c.id ?? c.field), label: String(c.header ?? c.field) }))\n\nexport const TARGET: FieldPropertyDef = { key: 'target', label: 'Compare with', kind: 'choice', choices: numberFields }\n```\n\n## The contexts\n\n| Type | Members | Given to |\n|---|---|---|\n| `FieldCellProps<P>` | `ctrl`, `row: { id, original }`, `column: { id, columnDef }`, `value`, `props: P` | `cell` |\n| `FieldEditorContext` | `ctrl`, `props` (draft with defaults), `columns` (every other field, as declared), `self` (the field's own key, id, saved header and draft name, which its formula may not read) | `choices` functions |\n| `FieldFillContext` | `columns` (every column, as declared, this one included) | `fill` |\n| `FieldRowContext` | `props`, `field`, `rows` | `newRowValue`, `onCreate` |\n\n## Look up registered types\n\n`getFieldType(id)` returns a registered type or `undefined`;\n`listFieldTypes()` returns them all in registration order. To offer only\nsome types in the \"+\" column, pass their ids; the picker lists them in\nthat order within each section:\n\n```svelte\n<SvBase data={rows} {columns} columnAdder={{ types: ['text', 'intlPhone', 'trafficLight', 'date'] }} fieldMenu editable />\n```\n\n## Pitfalls\n\n- **Always spread `def` in `fill`**, or the column loses its `field` and\n `fieldProps`.\n- **A formatter should read only `value`.** A grid cell passes\n `{ value, row, column, table }` with `row` the grid's row, and a pinned\n row passes `row: null`. The group header (its first record), the\n expanded record, a form, and gallery and Kanban cards pass\n `{ value, row, column }` with `row` shaped as the grid's,\n `{ id, original }`; in a form `id` is `''`. A linked record's preview,\n automation messages and alert text pass the plain record as `row`. The\n footer summary and the\n chart view's axis and tooltips pass `{ value }` alone.\n- **On a card, editing is off.** In a base's gallery and Kanban views,\n `ctrl` is the grid with the card's width as the column's (220 px on a\n Kanban card) and `editingEnabled` false: a cell that edits in place\n should check it, since the card opens its record for editing. A plain\n `<SvGrid>` gallery or board without a base passes a stand-in with only\n `getColumnWidth`. In a form, `row.original` is the record being filled in.\n- **Converting into your type is only as good as your parser.** Changing a\n text field to Phone stores `(415) 555-0123` as `+14155550123`; a multiple\n select changed to Traffic light reaches the parser as `\"Design, Backend\"`,\n which is no score, so the cell is cleared. Data loaded from elsewhere\n never goes through the parser: read stored values defensively, as\n `scoreOf` does.\n- **`onCreate` runs only when the field is created**, not when an existing\n field changes to your type.\n- **A numeric type needs `cellDataType`.** The filter, the footer\n summaries, the sort labels and `baseToSql` read it from the filled\n column. Without it, Traffic light filters as text, \"contains 7\" is what\n a user can write, and its Postgres column is `text`.\n\n## Next\n\n- [Field types](../fields.md): every built-in type and its properties.\n- [Linked records](./linked-records.md): fields that point at records of another table.\n- [Formulas](./formulas.md): computed fields written as formulas.\n- [Views](./views.md): grid, Kanban, calendar, gallery and chart views of the same records.\n- [Forms](./forms.md): a form view that adds records.\n- [Keep a base in a database](./data.md): load the tables and write every change back.\n"
5195
+ "markdown": "# Build your own field type\n\nA field type decides what a column holds and how it behaves: what the cell\nshows, which editor opens, how pasted text is read, what the footer can sum.\nThe built-in types are registered with `registerFieldType`, the same call\nyou will use, so your type gets the field editor, the views and the\nexpanded record the way they do.\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\nThis page builds two types. **Phone (international)** stores numbers as\nE.164 text (`+14155550123`), shows them the local way, dials on click and\nreads whatever people paste. **Traffic light** stores a score from 0 to 100\nand draws a green, amber or red light with its own cell and its own editor.\nThe [field types page](../fields.md#your-own-field-type) has the short\nversion.\n\n![A FieldTypeDef on the left, where each member shows up on the right: id, label, icon and group in the type picker and the header; fill's formatter in cell text, footer summaries, group headers and cards; valueParser for typed edits, paste, forms and type changes; editorType for the editor; sortValue for sort order; cellDataType for filter operators, summary choices, sort labels and the SQL column type; cell and hasCell for grid cells, group headers, cards and the record view; properties and defaults in the Edit field dialog; newRowValue for new records; onCreate for existing rows when the field is created; copy: false for a duplicated record, which gets a new value from newRowValue](/docs-media/base-field-type.svg)\n\n## 1. Decide what the field stores\n\nSettle the stored value before you write the type. Filters, sorting, copy,\nthe database and your API all see the stored value; only the cell and the\nformatter see the text on screen. A phone number stored as `+14155550123`\ndials from any app, sorts by country and compares exactly.\n\n```ts\n// phone-field.ts\nexport type PhoneProps = { country: string; display: 'national' | 'international' }\n\nconst E164 = /^\\+[1-9]\\d{6,14}$/\n\n/** Typed or pasted text as E.164 (\"+14155550123\"), or null when it is no phone number. */\nexport function toE164(text: string, country: string): string | null {\n let s = text.trim().replace(/^tel:/i, '').replace(/[\\s().\\-\\/]/g, '')\n if (s.startsWith('00')) s = '+' + s.slice(2)\n if (!s.startsWith('+')) {\n // A national number: drop the trunk prefix (1 in North America, 0 elsewhere).\n s = country === '1' ? s.replace(/^1(?=\\d{10}$)/, '') : s.replace(/^0/, '')\n // North American numbers need all ten digits: no guessing an area code.\n if (country === '1' && !/^\\d{10}$/.test(s)) return null\n s = `+${country}${s}`\n }\n return E164.test(s) ? s : null\n}\n\n/** A stored value as the field shows it. A number from another country shows as stored. */\nexport function showPhone(value: unknown, p: PhoneProps): string {\n const s = value == null ? '' : String(value)\n const home = `+${p.country}`\n if (!E164.test(s) || !s.startsWith(home)) return s\n const rest = s.slice(home.length)\n if (p.country === '1' && rest.length === 10) {\n const local = `(${rest.slice(0, 3)}) ${rest.slice(3, 6)}-${rest.slice(6)}`\n return p.display === 'national' ? local : `+1 ${local}`\n }\n const grouped = rest.replace(/\\B(?=(\\d{4})+$)/g, ' ')\n return p.display === 'national' ? `0${grouped}` : `${home} ${grouped}`\n}\n```\n\n| Typed, home country | Stored | Shown (national) |\n|---|---|---|\n| `(415) 555-0123`, +1 | `+14155550123` | `(415) 555-0123` |\n| `1 415 555 0123`, +1 | `+14155550123` | `(415) 555-0123` |\n| `020 7946 0958`, +44 | `+442079460958` | `020 7946 0958` |\n| `0044 20 7946 0958`, +1 | `+442079460958` | `+442079460958` |\n| `555-0123`, +1 | refused | |\n| `n/a` | refused | |\n\nBoth are plain functions, so you can unit-test them without a grid.\n\n## 2. Register the type\n\n```ts\n// phone-field.ts, continued\nimport { registerFieldType, type FieldTypeDef } from '@svgrid/enterprise/base'\n\nexport const phoneType: FieldTypeDef<PhoneProps> = {\n id: 'intlPhone',\n label: 'Phone (international)',\n description: 'Stored as +14155550123, shown in the local format, dialed with a click.',\n icon: 'M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2',\n group: 'basic',\n width: 170,\n defaults: { country: '1', display: 'national' },\n fill: (def, props) => ({\n ...def,\n editorType: def.editorType ?? 'text',\n formatter: def.formatter ?? ((ctx: { value: unknown }) => showPhone(ctx.value, props)),\n // Typed and pasted text is stored as E.164; text that is no number keeps the old value.\n valueParser: def.valueParser ?? ((x: { newValue: unknown; oldValue: unknown; rawInput?: unknown }) => {\n const text = String((typeof x.rawInput === 'string' ? x.rawInput : x.newValue) ?? '').trim()\n if (!text) return null\n return toE164(text, props.country) ?? x.oldValue\n }),\n // Values that never went through the parser (loaded data, an API write) are flagged.\n validate: def.validate ?? ((ctx: { value: unknown }) =>\n ctx.value == null || ctx.value === '' || E164.test(String(ctx.value)) ? null : 'Not a +country phone number'),\n }),\n}\n\nregisterFieldType(phoneType)\n```\n\nImport the file once at app start, next to `enableBase()`, and name the type\nin a column:\n\n```ts\nimport { enableBase } from '@svgrid/enterprise/base'\nimport './phone-field'\n\nenableBase()\n\nconst columns = [\n { field: 'name', header: 'Name', fieldType: 'text' },\n { field: 'phone', header: 'Phone', fieldType: 'intlPhone', fieldProps: { country: '44' } },\n]\n```\n\n`fill` is where a type turns into grid behavior. It receives the column as\nthe app declared it, the type's `defaults` with the column's `fieldProps` on\ntop (`props`), and a context with every column. It returns the column the\ngrid sees: `editorType`, `formatter`, `valueParser`, `validate`, `align`,\n`cellDataType`, `sortValue`, `editable`. Write each key as\n`def.key ?? yours`, so a column that sets `formatter` itself keeps it. The\nbuilt-ins in `builtin-types.ts` follow that rule.\n\nWith this registered, the header shows the phone icon before \"Phone\", cells\nread `020 7946 0958`, and \"Phone (international)\" appears in the field\neditor's type picker under \"Fields\", with its description under the picker\nonce it is chosen. `width` is the width a new field of this type starts\nwith when someone adds it there.\n\n![The Add field dialog in a base, its type list scrolled to show the end of the Fields section (Phone number, Email, URL, Barcode, Button), then Numbers and time (Number, Duration, Rating) and Computed and automatic (Formula, Created time, Last modified time, Created by), with the chosen type's description and its Default value property below](/docs-media/base-field-type.png)\n\nThe picker draws a section per `group`, in a fixed order, and skips a\nsection no type uses. The built-ins fill only Fields, Numbers and time,\nComputed and automatic, and Other tables (Date and User sit under Fields),\nso \"Dates\" and \"People\" appear only once a type of yours names them. A\n`group` the list does not know puts the type under Fields. Once more than\neight types are on offer, a \"Find a type\" box sits above the list.\n\n## 3. Read what people type and paste\n\n`valueParser` gets `newValue` (after the grid's own coercion for the\neditor type), `oldValue`, `rawInput` (the text as typed or pasted), the\nrow as `data` and the `columnId`. It runs on a cell edit, a paste (one\nvalue pasted over a range included), a full-row edit, an edit in the\nexpanded record and a form field. Returning `oldValue` refuses the input:\npaste `n/a` over a number and the number stays, and the page says that\nvalue did not fit. The text editor\nopens on the stored `+442079460958`, and whatever the user leaves in it\ngoes back through the parser.\n\n`validate` runs for every rendered cell, so a bad value gets the red mark\nand the message as its tooltip even when it was loaded that way. While the\ncell's editor is open, it checks the draft before `valueParser` has read\nit, so `(415) 555-0123` shows red until Enter stores it as E.164. Add\n`rejectInvalid: def.rejectInvalid ?? true` to refuse a flagged edit\noutright; a paste is not checked against it, which is why the parser does\nthe refusing here.\n\nCheck the filled column without mounting anything:\n\n```ts\nimport { fillFieldColumn } from '@svgrid/enterprise/base'\n\nconst col = fillFieldColumn({ field: 'phone', fieldType: 'intlPhone', fieldProps: { country: '44' } })\nconst show = col.formatter as (ctx: { value: unknown }) => string\nconst parse = col.valueParser as (x: { newValue: unknown; oldValue: unknown; rawInput: string }) => unknown\n\nshow({ value: '+442079460958' }) // '020 7946 0958'\nparse({ newValue: '020 7946 0958', oldValue: null, rawInput: '020 7946 0958' }) // '+442079460958'\nparse({ newValue: 'n/a', oldValue: '+442079460958', rawInput: 'n/a' }) // '+442079460958'\n```\n\n## 4. Draw the cell\n\nWithout `cell`, the grid draws the formatter's text. A cell component can\ndraw anything; this one is a `tel:` link, so a click dials.\n\n```svelte\n<!-- PhoneCell.svelte -->\n<script lang=\"ts\">\n import { linkHref, type FieldCellProps } from '@svgrid/enterprise/base'\n import { showPhone, type PhoneProps } from './phone-field'\n\n let { value, props }: FieldCellProps<PhoneProps> = $props()\n // 'tel:+14155550123'; null unless the value is 3 to 20 digits with an optional +.\n const href = $derived(linkHref('phone', value))\n const text = $derived(showPhone(value, props))\n</script>\n\n{#if href}\n <!-- Stop pointerdown: a click on the number dials, a click beside it selects the cell. -->\n <a class=\"phone\" {href} onpointerdown={(e) => e.stopPropagation()}>{text}</a>\n{:else}\n <span class=\"phone is-bad\">{text}</span>\n{/if}\n\n<style>\n .phone { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }\n a.phone { text-decoration: underline; text-decoration-color: var(--sg-muted, #94a3b8); text-underline-offset: 2px; }\n .is-bad { color: var(--sg-muted, #64748b); }\n</style>\n```\n\n```ts\nimport { registerFieldType } from '@svgrid/enterprise/base'\nimport { phoneType } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nregisterFieldType({ ...phoneType, cell: PhoneCell })\n```\n\nRegistering an id again replaces the type and keeps its place in the\npicker; in your own file, add `cell: PhoneCell` to `phoneType` instead.\nThe cell receives `FieldCellProps`: `value`, `props` (defaults merged with\n`fieldProps`), `row` (`{ id, original }`), `column` (`{ id, columnDef }`)\nand `ctrl`, the grid. `linkHref` is the helper the built-in URL, email and\nphone cells use; it returns an href only for the scheme the kind allows,\nso a value like `javascript:alert(1)` never becomes a link.\n\n## 5. Add properties to the field editor\n\n`properties` is what \"Edit field\" shows for the type. Each property is\nkept under its `key` in the column's `fieldProps`.\n\n```ts\nimport { registerFieldType, type FieldPropertyDef } from '@svgrid/enterprise/base'\nimport { phoneType } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nexport const PHONE_PROPERTIES: FieldPropertyDef[] = [\n {\n key: 'country', label: 'Home country', kind: 'choice',\n choices: [\n { value: '1', label: 'United States, Canada (+1)' },\n { value: '44', label: 'United Kingdom (+44)' },\n { value: '49', label: 'Germany (+49)' },\n { value: '359', label: 'Bulgaria (+359)' },\n ],\n hint: 'Numbers typed without a + are read as this country\\'s.',\n },\n {\n key: 'display', label: 'Show numbers of that country', kind: 'segmented',\n choices: [{ value: 'national', label: '(415) 555-0123' }, { value: 'international', label: '+1 (415) 555-0123' }],\n },\n]\n\nregisterFieldType({ ...phoneType, cell: PhoneCell, properties: PHONE_PROPERTIES })\n```\n\nThe dialog draws a dropdown with the hint under it, then a row of two\nbuttons. A property the column has not set shows the type's default.\nPicking your type in the dialog starts the draft from your `defaults` and\nkeeps only the values of properties your type also lists, so a field made\nthere saves your defaults into its `fieldProps`; changing `defaults` later\ndoes not move it. On save, empty strings, empty lists (other than\n`options`) and `undefined` are dropped. A `choice` hands back the option's\n`value` string; a `number` hands back a number, or `undefined` when\ncleared.\n\n## 6. A type with its own cell: Traffic light\n\nThe second type stores a number and draws a light. Its properties set the\nthresholds, the direction and the green color.\n\n```ts\n// traffic-light.ts\nimport { registerFieldType, formatNumber, BRIGHT, type FieldTypeDef } from '@svgrid/enterprise/base'\nimport TrafficLightCell from './TrafficLightCell.svelte'\n\nexport type LightProps = {\n green: number\n amber: number\n higherIsBetter: boolean\n goodColor: string\n show: 'light' | 'number'\n showNumber: boolean\n default?: number | string\n}\n\nexport const LIGHT_DEFAULTS: LightProps = {\n green: 80, amber: 50, higherIsBetter: true, goodColor: '#20c933', show: 'light', showNumber: true,\n}\n\nexport type Light = { band: 'green' | 'amber' | 'red'; color: string; label: string }\n\n/** The light a score gets under the field's thresholds. */\nexport function lightOf(n: number, p: LightProps): Light {\n const reaches = (limit: number) => (p.higherIsBetter ? n >= limit : n <= limit)\n if (reaches(Number(p.green))) return { band: 'green', color: p.goodColor, label: 'On track' }\n if (reaches(Number(p.amber))) return { band: 'amber', color: '#fcb400', label: 'At risk' }\n return { band: 'red', color: '#f82b60', label: 'Off track' }\n}\n\n/** A stored value as a score, or null. Old data may hold \"72\" or \"72%\" as text. */\nexport function scoreOf(value: unknown): number | null {\n if (value == null || value === '') return null\n const n = typeof value === 'number' ? value : Number(String(value).replace(/[%\\s]/g, ''))\n return Number.isFinite(n) ? Math.max(0, Math.min(100, n)) : null\n}\n\nexport const trafficLightType: FieldTypeDef<LightProps> = {\n id: 'trafficLight',\n label: 'Traffic light',\n description: 'A score from 0 to 100, shown as a green, amber or red light.',\n icon: 'M9 2h6v20H9zM12 6h.01M12 12h.01M12 18h.01',\n group: 'number',\n width: 120,\n defaults: LIGHT_DEFAULTS,\n properties: [\n { key: 'green', label: 'Green at', kind: 'number', min: 0, max: 100, hint: 'With \"Higher is better\" off, green is at or below this value.' },\n { key: 'amber', label: 'Amber at', kind: 'number', min: 0, max: 100, hint: 'Past amber the light is red.' },\n {\n key: 'higherIsBetter', label: 'Higher is better', kind: 'checkbox',\n // Flipping the direction swaps the thresholds. `p` is the draft with\n // the type's defaults filled in, as `visible` sees it.\n alsoSets: (_v, p) => ({ green: p.amber, amber: p.green }),\n },\n { key: 'goodColor', label: 'Green color', kind: 'color', palette: BRIGHT },\n { key: 'show', label: 'Show as', kind: 'segmented', choices: [{ value: 'light', label: 'Light' }, { value: 'number', label: 'Number' }] },\n { key: 'showNumber', label: 'Number next to the light', kind: 'checkbox', visible: (p) => p.show !== 'number' },\n { key: 'default', label: 'Default value', kind: 'default', hint: 'New rows start with this score.' },\n ],\n fill: (def) => ({\n ...def,\n cellDataType: def.cellDataType ?? 'number',\n editorType: def.editorType ?? 'trafficLight',\n align: def.align ?? 'left',\n formatter: def.formatter ?? ((ctx: { value: unknown }) => {\n const n = scoreOf(ctx.value)\n return n == null ? '' : formatNumber(n, { precision: 0 })\n }),\n valueParser: def.valueParser ?? ((x: { newValue: unknown; oldValue: unknown; rawInput?: unknown }) => {\n if (typeof x.rawInput !== 'string') return scoreOf(x.newValue)\n if (!x.rawInput.trim()) return null\n return scoreOf(x.rawInput) ?? x.oldValue\n }),\n }),\n cell: TrafficLightCell,\n // \"Show as: Number\" hands the cell back to the grid, which draws the formatter's text.\n hasCell: (p) => p.show !== 'number',\n newRowValue: ({ props }) => (props.default == null ? undefined : scoreOf(props.default)),\n}\n\nregisterFieldType(trafficLightType)\n```\n\n```svelte\n<!-- TrafficLightCell.svelte -->\n<script lang=\"ts\">\n import type { FieldCellProps } from '@svgrid/enterprise/base'\n import { lightOf, scoreOf, type LightProps } from './traffic-light'\n\n let { value, props }: FieldCellProps<LightProps> = $props()\n const n = $derived(scoreOf(value))\n const light = $derived(n == null ? null : lightOf(n, props))\n const number = $derived(n == null ? '' : String(Math.round(n)))\n</script>\n\n{#if light}\n <span class=\"tl\" title={`${light.label}: ${number}`}>\n <span class=\"tl-dot\" style:background={light.color} role=\"img\" aria-label={light.label}></span>\n {#if props.showNumber}<span class=\"tl-num\">{number}</span>{/if}\n </span>\n{/if}\n\n<style>\n .tl { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }\n .tl-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }\n .tl-num { font-variant-numeric: tabular-nums; color: var(--sg-fg, #0f172a); }\n</style>\n```\n\n`cellDataType: 'number'` makes it a number column to the rest of the base:\nthe footer offers Sum, Average, Median, Min, Max and Range, each formatted\nby your `formatter`; the column menu labels its sorts \"1 → 9\" and\n\"9 → 1\"; the view bar filters it with =, <, > and the other number\noperators. The light has an `aria-label`, so a screen reader user gets the\nband as a word, not only a color.\n\nIn \"Edit field\" the type shows two number boxes, a checkbox, ten color\nswatches, a Light / Number switch, a second checkbox and the default box.\n\"Number next to the light\" disappears while the switch is on Number,\nbecause `visible` reads the draft. Group by this field and each score is a\ngroup of its own: the grid groups by the stored value, and the group\nheader draws its light.\n\nUntil step 7 registers an editor named `trafficLight`, the cell edits in a\nplain text box and the parser reads the text: type `72%` and 72 is stored.\n\n## 7. Give it its own editor\n\nAn editor is a Svelte component registered with `registerCellEditor` from\n`@svgrid/grid` under the name your `fill` puts in `editorType`.\n\n```svelte\n<!-- TrafficLightEditor.svelte -->\n<script lang=\"ts\">\n import { fieldPropsOf } from '@svgrid/enterprise/base'\n import { lightOf, scoreOf, type LightProps } from './traffic-light'\n\n let {\n value,\n columnDef,\n onChange,\n onCommit,\n onCommitAndMove,\n onCancel,\n }: {\n value: unknown\n columnDef?: Record<string, unknown>\n onChange: (v: unknown) => void\n onCommit: (v?: unknown) => void\n onCommitAndMove: (v: unknown, direction: 1 | -1) => void\n onCancel: () => void\n } = $props()\n\n // The column's properties: the type's defaults under its fieldProps.\n const props = $derived(fieldPropsOf(columnDef ?? {}) as LightProps)\n // svelte-ignore state_referenced_locally\n let n = $state(scoreOf(value) ?? 0)\n const light = $derived(lightOf(n, props))\n\n function focusOnMount(el: HTMLElement) {\n queueMicrotask(() => el.focus())\n }\n function slide(e: Event & { currentTarget: HTMLInputElement }) {\n n = Number(e.currentTarget.value)\n // Keep the grid's draft in step, so a click elsewhere saves what is shown.\n onChange(n)\n }\n function onKey(e: KeyboardEvent) {\n if (e.key.startsWith('Arrow') || e.key === 'Home' || e.key === 'End') {\n // The slider moves; the grid's active cell stays put.\n e.stopPropagation()\n return\n }\n if (e.key === 'Enter') onCommit(n)\n else if (e.key === 'Tab') onCommitAndMove(n, e.shiftKey ? -1 : 1)\n else if (e.key === 'Escape') onCancel()\n else return\n e.preventDefault()\n e.stopPropagation()\n }\n</script>\n\n<span class=\"tle\">\n <input type=\"range\" min=\"0\" max=\"100\" step=\"1\" value={n} aria-label=\"Score\"\n style:accent-color={light.color} use:focusOnMount oninput={slide} onkeydown={onKey} />\n <output>{n}</output>\n</span>\n\n<style>\n .tle { display: flex; align-items: center; gap: 8px; height: 100%; padding: 0 8px; background: var(--sg-bg, #fff); }\n .tle input { flex: 1; min-width: 0; }\n .tle output { width: 3ch; text-align: end; font-variant-numeric: tabular-nums; }\n</style>\n```\n\n```ts\nimport { registerCellEditor } from '@svgrid/grid'\nimport TrafficLightEditor from './TrafficLightEditor.svelte'\n\nregisterCellEditor('trafficLight', {\n component: TrafficLightEditor,\n props: (ctx) => ({\n value: ctx.value,\n columnDef: ctx.columnDef,\n onChange: ctx.onChange,\n onCommit: ctx.onCommit,\n onCommitAndMove: ctx.onCommitAndMove,\n onCancel: ctx.onCancel,\n }),\n typeToEdit: false,\n})\n```\n\nDouble-click or F2 opens the slider in the cell. Arrows move it, Enter\nsaves, Tab saves and moves to the next cell, Escape leaves the cell as it\nwas. `typeToEdit: false` keeps typed keys from opening it; a function such\nas `(c) => /^[0-9]$/.test(c)` would open it on a digit, with `typed: true`\nand the digit as `value` on the context. Without `props`, the grid passes\n`value`, `onChange`, `onCommit`, `onCancel`, `onCommitAndMove`,\n`onRequestClose` and `inCell`. The context also carries `rowId`,\n`columnId`, `columnDef`, `row`, `grid`, `typed` and `onCommitAndMoveDown`.\n\nThe expanded record and a form open the same registered editor, with\n`inCell: false`. A value from a registered editor reaches `valueParser` as\nit is, with `rawInput` set to that same value rather than to text.\n\n## 8. Values the type writes itself\n\n`newRowValue` gives each new row a value: from the row adder, a group's\n\"+\", a form, a board lane. Return `undefined` to fall back to the field's\n`default` property. `onCreate` fills every existing row once, when someone\ncreates the field in the field editor. Without `onCreate`, a field created\nwith a default fills every existing row with it: a new field holds nothing\nyet, so nothing is overwritten. A default set on a field later fills only\nnew records. Both get a `FieldRowContext`: the\nfield's `props`, its `field` key and the table's `rows`.\n\n```ts\nimport { registerFieldType } from '@svgrid/enterprise/base'\n\nconst ticket = (prefix: string, n: number) => `${prefix}${String(n).padStart(4, '0')}`\n/** The number in \"T-0042\", or 0. */\nconst numberIn = (v: unknown) => Number(/(\\d+)$/.exec(String(v ?? ''))?.[1] ?? 0)\n\nregisterFieldType({\n id: 'ticketId',\n label: 'Ticket ID',\n description: 'T-0001, T-0002 and on. Set automatically.',\n icon: 'M4 7h16v10H4zM9 7v10',\n group: 'computed',\n width: 100,\n defaults: { prefix: 'T-' },\n properties: [{ key: 'prefix', label: 'Prefix', kind: 'text', placeholder: 'T-' }],\n fill: (def) => ({ ...def, editable: def.editable ?? false }),\n onCreate: ({ rows, props }) => rows.map((_, i) => ticket(String(props.prefix), i + 1)),\n newRowValue: ({ rows, field, props }) =>\n ticket(String(props.prefix), rows.reduce((max, r) => Math.max(max, numberIn(r?.[field])), 0) + 1),\n copy: false,\n})\n```\n\nWhen `onCreate` returns values, or the new field has a default,\n`onColumnAdd` hands your app the new rows as `data` next to the columns, so\nstore both. `editable: false` also keeps\nthe field out of a form. \"Duplicate record\" copies every stored field into\nthe copy. `copy: false` opts a type out: the copy gets a new value from\n`newRowValue` (the next ticket number here), or the field's `default` when\nthe type has no `newRowValue`. Leave it out and two records share a ticket\nnumber. The built-in autonumber, created and last-modified fields always\nget fresh values. The traffic light in step\n6 reads its `default` property in `newRowValue` because a `default`\nproperty on a custom type is drawn as a text box and saved as a string.\n\n## Replace a built-in type\n\nRegister a type with a built-in id before calling `enableBase()`:\n`enableBase()` registers each built-in only when no type has its id yet.\n\n```ts\nimport { enableBase, registerFieldType } from '@svgrid/enterprise/base'\nimport { phoneType, PHONE_PROPERTIES } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nregisterFieldType({ ...phoneType, id: 'phone', label: 'Phone number', cell: PhoneCell, properties: PHONE_PROPERTIES })\nenableBase()\n```\n\nEvery column with `fieldType: 'phone'` now uses yours, and it is listed\nfirst in its picker section, since the picker keeps registration order.\nSome behavior stays keyed to the id rather than to your definition: changing a\nfield to `phone` converts its values as text without your parser, the\nfilter treats it as text, and a form checks it as a phone number.\n`baseToSql` follows your `fill`'s `cellDataType`, as for any registered\ntype. Override a number type such as `rating` and the type change, the\nfilter and `baseToSql` keep treating it as a number.\n\n## Keep an old type id\n\nRename a type without breaking saved columns: register the old id with\n`editAs`, pointing at the new one.\n\n```ts\nimport { registerFieldType } from '@svgrid/enterprise/base'\nimport { phoneType } from './phone-field'\nimport PhoneCell from './PhoneCell.svelte'\n\nregisterFieldType({ ...phoneType, id: 'mobile', label: 'Mobile', cell: PhoneCell, editAs: { type: 'intlPhone', props: { display: 'international' } } })\n```\n\nColumns that say `fieldType: 'mobile'` still draw, and the type picker\nleaves `mobile` out. \"Edit field\" opens such a column as Phone\n(international) with `display: 'international'` on top of its properties.\nSaving writes `fieldType: 'intlPhone'` and converts the stored values as\nany type change does, through the `intlPhone` parser, which keeps every\nvalid E.164 number. The conversion starts from the stored type, `mobile`,\nso the editor warns before you save when it would clear cells: \"Mobile to\nPhone (international) converts the values. 2 cells will be cleared or cut\nshort.\" When\nevery value converts it says nothing, since you did not pick a new type.\nThe built-in Currency and Percent types work this way: both open as Number.\n\n## Where your type shows up\n\n| Place | What it uses |\n|---|---|\n| Grid cell | `cell` when `hasCell` allows it, else the filled column's `formatter` and `align` |\n| Header, type picker, record view and form labels, view bar panels, gallery labels | `icon`, drawn as a 24x24 stroke path |\n| Group header | `cell`, given the group's first record as `row`; else `formatter` |\n| Gallery and Kanban cards | `cell`, with `ctrl` the grid at the card's width and editing off; else `formatter` |\n| Expanded record | `cell` for a non-empty value; a click opens the editor `editorType` names (a registered one, the date picker or a text box) and saves through the grid, so `valueParser` and `rejectInvalid` apply |\n| Form view | The same cells and editors; the editor's value goes through the grid's coercion and `valueParser`, as in a cell edit. On submit the form runs `validate` and refuses the record while it fails, with or without `rejectInvalid` |\n| Footer summary | Number summaries for `cellDataType: 'number'`, date ones for `'date'` and `'dateString'`, checked, unchecked and percent checked for `'boolean'`, as a checkbox gets; counts for the rest; see [Summaries at the bottom](../fields.md#summaries-at-the-bottom) |\n| View bar filter | By the filled column's `cellDataType`: the number operators for `'number'`, the date ones for `'date'` and `'dateString'`, \"is\" checked / unchecked for `'boolean'`; otherwise the text operators (contains, does not contain, is, is not, is empty, is not empty) on the stored value |\n| Sort | The stored value; a `sortValue` in `fill` sorts by a number of your own, as a single select sorts by option order |\n| Copy | What the cell shows when your `valueParser` reads that text back to the same value. Otherwise `String(value)`: an array copies as `a,b`, an object as `[object Object]`, so keep stored values to strings, numbers and arrays of them. A paste of a copy made on the same page into the same type gets the stored value back, whatever the text says |\n| Fill handle | One source cell copies. Two or more repeat: a series is for number and date fields |\n| Paste | `valueParser` with the pasted text as `rawInput`; `rejectInvalid` does not refuse it |\n| Changing a field to your type | Each value as text through your `valueParser`, as a paste with `oldValue: null`; what it refuses or throws on is cleared and counted in the editor's warning. Without a parser, a list becomes its text and a plain value stays |\n| Changing your type to a built-in | The built-in's conversion, reading your value as text (`convertValue`) |\n| `baseToSql` | By the filled column's `cellDataType`, as the built-ins map: `double precision` for `'number'`, `boolean` for `'boolean'`, `timestamptz` for `'date'`, `date` for `'dateString'`; otherwise `text` |\n\n`convertValue(value, from, to, toProps)` and\n`countCleared(values, from, to, toProps)` are exported, so a migration\nscript can preview a type change the way the field editor's warning does.\n`toProps` is the new field's `fieldProps`, which your `fill` sees when the\nparser is made. `filterKindOf(def)` returns `'number'`, `'date'` or\n`'checkbox'` from the filled column's `cellDataType` for an id it does not\nknow, and `'text'` when `cellDataType` says nothing; formula, lookup and\nrollup fields follow their `cellDataType` the same way. `operatorsFor(kind)`\nlists the operators a kind offers.\n\n## FieldTypeDef\n\n| Member | Type | What it does |\n|---|---|---|\n| `id` | `string` | The name columns use in `fieldType` |\n| `label` | `string` | Name in the type picker; a new unnamed field is named after it |\n| `description` | `string` | One line under the type list once the type is chosen |\n| `icon` | `string` | SVG path data, 24x24 viewBox, drawn as a stroke |\n| `group` | `'basic' \\| 'number' \\| 'date' \\| 'people' \\| 'computed' \\| 'relation'` | Picker section, in this order: Fields, Numbers and time, Dates, People, Computed and automatic, Other tables; default `'basic'` |\n| `defaults` | `P` | Property values a column gets when its `fieldProps` leave them out |\n| `fill` | `(def, props: P, ctx: FieldFillContext) => Record<string, unknown>` | Turns the declared column into the column the grid sees. Optional: without it the column stays as declared and still gets its footer summary |\n| `cell` | `Component<FieldCellProps<P>>` | Draws the cell |\n| `hasCell` | `(props: P) => boolean` | Whether `cell` draws; default always |\n| `properties` | `ReadonlyArray<FieldPropertyDef>` | What the field editor lets a user set |\n| `width` | `number` | Width of a new field made in the field editor (else 150) |\n| `newRowValue` | `(ctx: FieldRowContext) => unknown` | The value a new row gets |\n| `onCreate` | `(ctx: FieldRowContext) => unknown[] \\| null` | Values for every existing row when the field is created |\n| `copy` | `false` | A duplicated record gets a new value from `newRowValue` (else the field's `default`) instead of a copy |\n| `editAs` | `{ type: string; props: Record<string, unknown> }` | Keeps an old id drawing; edited as `type` and left out of the picker |\n\n## Property kinds\n\nEvery `FieldPropertyDef` has `key`, `label` and `kind`, and may have\n`visible(props)` (shown only when it returns true), `hint` (a line under the\ncontrol, for every kind) and `alsoSets(value, props)` (other keys to change\nwith this one). `visible` and `alsoSets` get the same `props`: the draft\nwith the type's defaults filled in, before this change.\n\n| `kind` | Extra keys | Draws | Hands back |\n|---|---|---|---|\n| `number` | `min`, `max` | Number box | `number`, or `undefined` when cleared |\n| `text` | `placeholder` | Text box | `string` |\n| `checkbox` | | Checkbox with the label beside it | `boolean` |\n| `choice` | `choices`: a list, or `(ctx: FieldEditorContext) => list` | Dropdown, with \"Choose...\" while the value is not in the list | The option's `value` |\n| `segmented` | `choices` | Row of buttons | The option's `value` |\n| `color` | `palette` | Swatches; `BRIGHT` is the ten-color set the built-ins use | Hex string |\n| `icon` | `icons` (`value`, `label`, `path`) | Icon buttons, the picked one in the `color` property's color | The icon's `value` |\n| `options` | | The select options editor | Option list |\n| `default` | | A checkbox, select, person or number input for those built-in types; a text box for every other type, yours included | Depends on the type; a `string` for yours |\n| `formula` | | Formula box with field buttons, a functions list and error checking; a formula that does not compile blocks Save | `string` |\n| `columns` | | Chips for the other fields | Column ids |\n\nA `choice` whose options depend on the table passes a function, as the\nbuilt-in Lookup and Rollup do to list the table's link fields:\n\n```ts\nimport type { FieldEditorContext, FieldPropertyDef } from '@svgrid/enterprise/base'\n\nconst numberFields = (ctx: FieldEditorContext) =>\n ctx.columns.filter((c) => c.fieldType === 'number').map((c) => ({ value: String(c.id ?? c.field), label: String(c.header ?? c.field) }))\n\nexport const TARGET: FieldPropertyDef = { key: 'target', label: 'Compare with', kind: 'choice', choices: numberFields }\n```\n\n## The contexts\n\n| Type | Members | Given to |\n|---|---|---|\n| `FieldCellProps<P>` | `ctrl`, `row: { id, original }`, `column: { id, columnDef }`, `value`, `props: P` | `cell` |\n| `FieldEditorContext` | `ctrl`, `props` (draft with defaults), `columns` (every other field, as declared), `self` (the field's own key, id, saved header and draft name, which its formula may not read) | `choices` functions |\n| `FieldFillContext` | `columns` (every column, as declared, this one included) | `fill` |\n| `FieldRowContext` | `props`, `field`, `rows` | `newRowValue`, `onCreate` |\n\n## Look up registered types\n\n`getFieldType(id)` returns a registered type or `undefined`;\n`listFieldTypes()` returns them all in registration order. To offer only\nsome types in the \"+\" column, pass their ids; the picker lists them in\nthat order within each section:\n\n```svelte\n<SvBase data={rows} {columns} columnAdder={{ types: ['text', 'intlPhone', 'trafficLight', 'date'] }} fieldMenu editable />\n```\n\n## Pitfalls\n\n- **Always spread `def` in `fill`**, or the column loses its `field` and\n `fieldProps`.\n- **A formatter should read only `value`.** A grid cell passes\n `{ value, row, column, table }` with `row` the grid's row, and a pinned\n row passes `row: null`. The group header (its first record), the\n expanded record, a form, and gallery and Kanban cards pass\n `{ value, row, column }` with `row` shaped as the grid's,\n `{ id, original }`; in a form `id` is `''`. A linked record's preview,\n automation messages and alert text pass the plain record as `row`. The\n footer summary and the\n chart view's axis and tooltips pass `{ value }` alone.\n- **On a card, editing is off.** In a base's gallery and Kanban views,\n `ctrl` is the grid with the card's width as the column's (220 px on a\n Kanban card) and `editingEnabled` false: a cell that edits in place\n should check it, since the card opens its record for editing. A plain\n `<SvGrid>` gallery or board without a base passes a stand-in with only\n `getColumnWidth`. In a form, `row.original` is the record being filled in.\n- **Converting into your type is only as good as your parser.** Changing a\n text field to Phone stores `(415) 555-0123` as `+14155550123`; a multiple\n select changed to Traffic light reaches the parser as `\"Design, Backend\"`,\n which is no score, so the cell is cleared. Data loaded from elsewhere\n never goes through the parser: read stored values defensively, as\n `scoreOf` does.\n- **`onCreate` runs only when the field is created**, not when an existing\n field changes to your type.\n- **A numeric type needs `cellDataType`.** The filter, the footer\n summaries, the sort labels and `baseToSql` read it from the filled\n column. Without it, Traffic light filters as text, \"contains 7\" is what\n a user can write, and its Postgres column is `text`.\n\n## Next\n\n- [Field types](../fields.md): every built-in type and its properties.\n- [Linked records](./linked-records.md): fields that point at records of another table.\n- [Formulas](./formulas.md): computed fields written as formulas.\n- [Views](./views.md): grid, Kanban, calendar, gallery and chart views of the same records.\n- [Forms](./forms.md): a form view that adds records.\n- [Keep a base in a database](./data.md): load the tables and write every change back.\n"
5196
5196
  },
5197
5197
  {
5198
5198
  "slug": "help/base/data",
5199
5199
  "path": "docs/help/base/data.md",
5200
5200
  "title": "Keep a base in a database",
5201
5201
  "section": "SvGrid Base",
5202
- "markdown": "# Keep a base in a database\n\nA base can keep its records in your database instead of the page. Give a\ntable a `source` and `<SvBase>` loads the records from it when it opens, then\nwrites every change back: a cell edit, a pasted range, a new record, a\ndeleted one, a link made from either side. Postgres, MySQL, SQLite, Supabase\nand any REST API work the same way, because each is reached through the\ndata source contract the grid already uses.\n\n<div data-docs-demo=\"516-base-postgres\" data-height=\"760\"></div>\n\nThe demo above is SvGrid Base on a real Postgres database running in the\npage (PGlite). Change a status and the log shows the `UPDATE` it ran.\n\n## How it fits together\n\n![SvGrid Base keeps every record in the page. The writer compares the tables with what the database holds and sends inserts, updates and deletes through baseSource to a data source, which talks to Postgres, Supabase or your API.](/docs-media/base-data-flow.svg)\n\n- **The page holds every record of a table.** Views, filters, groups,\n summaries, colors and automations all work on those records, so they stay\n instant. A table with more records than the page should hold (10,000 by\n default) is read from the database a part at a time instead, by itself: see\n [A table of millions](#a-table-of-millions).\n- **The writer sends what changed.** After each change it compares the\n tables with what the database holds and queues an `INSERT` for a new\n record, an `UPDATE` with only the fields that changed, or a `DELETE`. The\n writes go one at a time, in order, so an update never overtakes the insert\n of its own record.\n- **A refused write goes back.** When the database says no (a constraint, a\n row level security policy, a network error), the cell returns to what the\n database holds, the end of the tab bar says why in plain words, and a notice\n names the record and the field. What the database said is in the tooltip, or\n through an endpoint in the server log, because it names tables and values:\n [what a person reads](./postgres.md#3-one-endpoint-per-table).\n- **Changes made elsewhere come in.** With `realtime`, the base reads a table\n again when someone else changed it and takes what moved, without writing\n anything back.\n\n## Give a table a source\n\n`baseSource` wraps any data source:\n\n```ts\nimport { baseSource, type BaseTable } from '@svgrid/enterprise/base'\nimport { createRestDataSource } from '@svgrid/enterprise'\n\nconst tasks: BaseTable = {\n id: 'tasks',\n name: 'Tasks',\n primaryField: 'name',\n data: [],\n columns: [\n { field: 'name', header: 'Task', fieldType: 'text' },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: [{ value: 'Todo' }, { value: 'Done' }] } },\n ],\n source: baseSource(createRestDataSource({ url: '/api/tasks' })),\n}\n```\n\n```svelte\n<script lang=\"ts\">\n import { SvToaster } from '@svgrid/grid'\n import { SvBase, enableBase, type BaseTable } from '@svgrid/enterprise/base'\n\n enableBase()\n let { tables }: { tables: BaseTable[] } = $props()\n</script>\n\n<SvBase bind:tables editable />\n<SvToaster />\n```\n\n`data` can start empty: the base fills it. A write that is refused shows a notice\nand the tab bar says so; see [Notices](./quick-start.md#notices).\n\nThe data sources that ship with `@svgrid/enterprise`:\n\n| Source | Talks to | Tutorial |\n|---|---|---|\n| `createSupabaseDataSource` | Supabase (PostgREST), from the browser | [Build a base on Supabase](./supabase.md) |\n| `createSqlDataSource` | Any SQL database, through an `execute(sql, params)` you write. It reads and writes the columns on its schema and no others; `wholeRecords: true` reads and writes every column, for a source in the same process as the page, and `createKitHandlers` refuses one | [Build a base on Postgres](./postgres.md) |\n| `createKitDataSource` | Your SvelteKit endpoint, which runs `createSqlDataSource` on the server | [Build a base on Postgres](./postgres.md) |\n| `createRestDataSource` | A JSON API: `GET`, `POST`, `PATCH`, `DELETE` | [Build a base on your API](./rest-api.md) |\n| `createInMemoryDataSource` | An array, for tests and prototypes | |\n\nYour own source works too: an object with `getRows`, `createRow`,\n`updateRow` and `deleteRow` (the grid's `ServerDataSource`).\n\n## Link fields\n\n![How link fields are stored. A link to one record is a foreign key column. A link to many records is a junction table with one row per pair. The field that links back is not stored.](/docs-media/base-links.svg)\n\nIn the page a link field holds record ids. `links` says how each one is kept:\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport { createRestDataSource } from '@svgrid/enterprise'\n\nconst taskTags = createRestDataSource({ url: '/api/task_tags' })\n\nconst source = baseSource(createRestDataSource({ url: '/api/tasks' }), {\n links: {\n // A link to one record: the column with the linked record's id.\n project: { column: 'project_id' },\n // A link to many records: a junction table, one row per pair.\n tags: { through: taskTags, from: 'task_id', to: 'tag_id' },\n },\n})\n```\n\nThe field that links back (a project's Tasks, when tasks have a Project\nfield) is worked out in the page from the other side and never stored. Link\na task from the project's side and the base writes that task's\n`project_id`. A link field that is neither in `links` nor the other side of\none is written as it is, a list of ids, which suits a Postgres `text[]` or a\n`jsonb` column.\n\nA list (a multiple select, a vote, a sparkline) goes to its column as that column takes\nit: an array to `text[]`, JSON to `json` and `jsonb`, and JSON text to a text column, on\nMySQL, SQL Server and SQLite too. It reads back as the list it was.\n\n## Keys the base can use\n\nA record needs one column that names it. When a base reads a database:\n\n- A table with a primary key of one column is a table.\n- A table keyed by both ends, `order_tags (order_id, tag_id, primary key (order_id, tag_id))`,\n with both columns foreign keys, is a link to many, like a junction with its own `id`. A\n link goes by the whole key, so removing a tag deletes that one pair. A tenant column in\n the key, named in `tenantColumn`, is part of the key and no end of the link. Other columns\n on such a table are not read and not written: a new link gives them their defaults, one\n that is `NOT NULL` with no default refuses the link, and the server log names them. A\n pair whose two ends the base does not hold, by their keys, is left out.\n- Any other table with a composite key, or with no primary key, is left out of the base, a\n view included. The rest of the base opens, and the log names the table and says why.\n Nothing runs on part of a key, because a delete by one column of two reaches every row\n that shares it.\n\n`keys` brings such a table in, when one of its columns is unique:\n\n```ts\nexport const { GET, POST } = createBaseEndpoint({ execute, allTables: true, public: true, keys: { v_orders: 'id' } })\n```\n\nThat is your word for it: nothing checks, and a delete reaches every row that holds the\nvalue. `baseFromDatabase` and `baseFromSupabase` take it too. On Supabase the key comes\nfrom the API description; a project that does not show that to the key in use has only a\ncolumn named `id` to go by.\n\n### Foreign keys of more than one column\n\nA foreign key of more than one column, as a database keeps tenants apart with,\n`foreign key (tenant, customer_id) references customers (tenant, id)`, is a link through\n`customer_id` to that tenant's customer, when `tenantColumn` names `tenant` on both tables.\nThe tenant column stays the read-only tenant, not a link. It works the same in a pair\ntable, `(tenant, order_id) -> orders (tenant, id)`. Any other key of more than one column,\nthree columns or two without the tenant, links nothing: its columns are plain values and\nthe log names the key. A key links only to a table its bare name reaches: on Postgres a\ntable of any schema on the search path, unless a table of that name in an earlier schema\nhides it (a key to a hidden table stays a plain value); on SQL Server the user's default\nschema; on MySQL the connected database. The other table still has to be one the base\nserves. Supabase does not describe a key of more than one column, so there\nneither column is a link.\n\n## Record ids\n\nA new record gets an id in the page at once, so it can be edited and linked\nbefore the database answers. By default that id is its key in the database\ntoo: give the key column a text type.\n\nWhen the database makes the key (a `serial` column, a `uuid` with a default),\nset `serverIds: true`. The record is inserted without the page's id, and the\nwriter keeps the page id for the grid and translates to the database id for\nevery later write and every link that points at the record.\n\n## What a write answers\n\nThe row a server answers is the truth. After a write the cell, the record and the views\nshow what was stored: a value a `before*` hook or a trigger changed, a tenant the scope\nstamped, a default on a new record. A number the column rounded shows rounded. Undo goes\nback from what was stored. A block of Edit fields or of a range on a big table answers with\nwhat hooks changed, and a trigger's work on such a block shows when the view reads the rows\nagain. On a table the page holds, a paste, a clear or an Undo of 20 records or more is\nwritten in blocks, and each block's records are read back once it lands, so a trigger's\nwork shows at once there too.\n\nThe answer is the row the write left, not a teammate's write a moment later. Postgres and\nSQLite say it in the write itself (`RETURNING`). SQL Server writes and reads it back in one\ntransaction of one batch. MySQL has no way to do either in one statement: give\n`createSqlDataSource` (or `baseFromDatabase`, `createBaseEndpoint`) its `transaction` and the\nwrite and its read go in one. Without it a teammate's write to the same cell in the moment\nbetween the two is taken for yours, and an Undo of yours can then write over theirs.\n\n## What is not written\n\nFields the page works out are never sent: formula, lookup, rollup, count and\nbutton fields, and the field that links back. Add any other field to `skip`\nto keep it in the page only.\n\n## What a cell holds\n\nA base reads dates, times, bigints and decimals as the database writes them, as\ntext. A SQL source asks for a text copy of each such column\n(`to_json(col) #>> '{}'` on Postgres, `CAST(col AS CHAR)` on MySQL) beside the\ncolumn itself, so sorting and filtering still use the real column.\n\n| Column | What the page holds | What people see |\n|---|---|---|\n| `date` | `2026-03-08` | That day, in any zone |\n| `timestamp`, `datetime` | `2026-03-08T02:30:00.123456` | That wall clock, in any zone |\n| MySQL `timestamp` | The wall clock of the connection's `time_zone` | That wall clock, in any zone |\n| `timestamptz` | `2026-03-14T22:00:00.654321+00:00` | That moment, in the viewer's zone |\n| `bigint`, `numeric`, `decimal` | Text past what a JS number holds | Every digit |\n| `json`, `jsonb` | The text the database writes | Every digit: a driver's `JSON.parse` would round a number past 2^53 |\n\nA time someone types keeps its wall clock on a column without a zone, and is that\nmoment on a `timestamptz`. An undo or a restore writes back the text it read, so\nnothing moves by a zone or loses digits past the millisecond.\n\nThe days of a filter and the months of a chart are the viewer's. On a column of moments\n(Postgres `timestamptz`, SQL Server `datetimeoffset`, SQLite text that ends in a zone)\n\"is 8 March\", \"today\" and \"within the past week\" keep the records whose moment falls on\nthose days where the person is, and a chart counts each record in the month it reads as\nthere, across a change of the clocks too. The page sends each date condition with the\nmoments its days start and end (`moments` on the condition), since a server has no zone\nof the viewer's, and `createSqlDataSource` compares them on such a column. A date and a\nwall clock, a MySQL `TIMESTAMP` among them, compare their days and read the same everywhere.\nOn Supabase, say which columns hold moments: `supabaseFieldFilter(columns, { moments: (def) => def.field === 'starts_at' })`.\nWithout that, a condition there compares the database's days.\n\nOver PostgREST (Supabase) a date already arrives as text. A JSON number cannot\ncarry more than about 15 digits, so the first read that shows a longer one reads\nthat column again with `col::text`, and later reads bring the copy along. A change\nthat arrives through Realtime is plain JSON: such a number in it is rounded until\nthe next read.\n\nJSON in a `text` or `longText` field shows as JSON text. A change goes back as\nJSON; text that is not valid JSON is refused with a message and the cell goes back. A\n`jsonb` column writes its own spaces and key order, and that is no change: nobody is told\nof one. Over PostgREST a JSON column arrives as JSON, so a number past 2^53 in it is rounded.\n\nOpening a cell and leaving it writes nothing, whatever the field shows.\n\n## Changes made elsewhere\n\n![An edit, step by step: Ana's base sends the field that changed, the database tells every subscriber, and Ben's base reads the table again and takes what moved.](/docs-media/base-realtime.svg)\n\n`realtime` takes a function that calls `apply` with what changed and returns a\nfunction that stops listening. With Supabase, hand it Realtime's events as\nthey come:\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport {\n createSupabaseDataSource,\n createSupabaseRealtime,\n type EntitySchema,\n type SupabaseClientLike,\n type SupabaseRealtimeClientLike,\n} from '@svgrid/enterprise'\n\n// Your supabase-js client: createClient(url, anonKey).\ndeclare const client: SupabaseClientLike & SupabaseRealtimeClientLike\ndeclare const schema: EntitySchema\n\nconst source = baseSource(createSupabaseDataSource({ client, table: 'tasks', schema }), {\n realtime: (apply) => createSupabaseRealtime({ client, table: 'tasks', onChange: apply }),\n})\n```\n\nThe base updates just the records a change names: the other records keep\ntheir objects, so the grid redraws one row, not 50,000, and the table is not\nread again. A burst of changes (an agent updating 200 records) goes into the\npage as one update.\n\nAny other feed works the same way: a WebSocket message, a server-sent event,\na poll. Call `apply` with the changes, as the database has the records\n(its column names, its ids):\n\n```ts\nimport { baseSource, type BaseChangeInput } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\ndeclare const tasksSource: ServerDataSource<Record<string, unknown>>\n\nconst source = baseSource(tasksSource, {\n realtime: (apply: (changes?: BaseChangeInput) => void) => {\n const socket = new WebSocket('wss://example.com/tasks')\n socket.onmessage = (m) => {\n const { type, id, row, changed } = JSON.parse(m.data)\n if (type === 'update' && changed) apply([{ type: 'update', id, fields: changed }])\n else if (type === 'delete') apply([{ type: 'delete', id }])\n else apply([{ type, record: row }])\n }\n return () => socket.close()\n },\n})\n```\n\n| A change | Carries |\n|---|---|\n| `{ type: 'insert', record }` | The new record, with its key column. |\n| `{ type: 'update', id, record }` | The whole record as it is now. |\n| `{ type: 'update', id, fields }` | Just the columns that changed. |\n| `{ type: 'delete', id }` | The key of the record that went. |\n\nA change that comes back from the page's own write (the database tells every\nlistener, the page that wrote it included) moves nothing and is not reported.\nAn update with `fields` for a record the page does not have, and `apply()`\nwith nothing, read the whole table again. An update with `id` alone reads that one record.\n\n### A feed on an endpoint\n\n`baseFromEndpoint` takes one `feed` for the whole base. It opens when the first table\nlistens and closes with the last. Each message names its table, a junction table\nincluded, and a change in a junction reaches the record it starts from:\n\n```ts\nimport { baseFromEndpoint } from '@svgrid/enterprise/base'\n\nconst tables = await baseFromEndpoint('/api/base', {\n feed: (apply) => {\n const events = new EventSource('/api/base/feed')\n events.onmessage = (e) => {\n // { \"table\": \"orders\", \"changes\": [{ \"type\": \"update\", \"id\": \"o1\", \"fields\": { \"status\": \"Paid\" } }] }\n const { table, changes } = JSON.parse(e.data)\n apply(table, changes)\n }\n // After a reconnect, changes may have been missed: every table reads again.\n let opened = false\n events.onopen = () => {\n if (opened) apply()\n opened = true\n }\n return () => events.close()\n },\n})\n```\n\n`apply(table)` with no changes reads that table again, and `apply()` reads every table again.\n\nKeep it to one connection. A browser opens at most six connections to one host over\nHTTP/1.1, which is what a Vite or Node dev server speaks, and a connection held open by a\nfeed is one of them. With a feed per table on a base of six tables and junctions, no write\nreaches the server. `realtime: (table, apply) => stop`, called per table, is still taken\nfor a feed that shares one connection itself, such as channels on one socket.\n\nThe feed is yours to write and yours to scope: with a tenant `scope`, send each person their\ntenant's rows only.\n\n### What a feed has to cover\n\nA feed is per table, and some of what a person changes is not in that table:\n\n- **A link to many lives in its junction table.** Adding a tag writes a row to `order_tags`\n and nothing to `orders`, so a feed of `orders` alone never tells teammates. Listen to the\n junction too, on the table that stores the link, and name the record it starts from:\n\n ```ts\n import { baseSource } from '@svgrid/enterprise/base'\n import type { ServerDataSource } from '@svgrid/grid'\n\n declare const ordersSource: ServerDataSource<Record<string, unknown>>\n declare const orderTags: ServerDataSource<Record<string, unknown>>\n // Your feed: calls back with what changed in that table, and returns how to stop.\n declare function listen(table: string, on: (change: any) => void): () => void\n\n const source = baseSource(ordersSource, {\n links: { tags: { through: orderTags, from: 'order_id', to: 'tag_id' } },\n realtime: (apply) => {\n const orders = listen('orders', (change) => apply(change))\n const pairs = listen('order_tags', (row) => apply(row?.order_id == null ? undefined : { type: 'update', id: row.order_id }))\n return () => { orders(); pairs() }\n },\n })\n ```\n\n A feed that only says \"something changed\" calls `apply()` for both. `baseFromSupabase`\n and `baseFromEndpoint` listen to the junction tables by themselves, and needs them in the `supabase_realtime`\n publication. A delete's event there has only the key unless the junction table has\n `REPLICA IDENTITY FULL`, so a removed link reads the table again.\n- **A soft delete reaches a feed as an update.** The base reads an update that sets the mark\n as a delete, so send the column. Through `createKitDataSource` the page learns the column\n from the server's first answer. A restore reads as an update of a record the page does not\n have. A page-held table takes it in, and reads the table if it has links through a junction.\n A table read a part at a time reads the rows on screen, at most once a second, because a\n feed cannot tell a restore from an edit of a record scrolled out of view.\n- **A feed that goes down says nothing.** Nothing here can tell silence from no changes.\n\n### What people see\n\nA change made elsewhere does not just appear. Until someone opens the record:\n\n- in a grid view, the cells that changed are tinted, and a record added\n elsewhere is tinted across the row (Kanban and gallery cards are not);\n- the row number has a dot; hover it for \"Ana Ruiz changed this record 2\n minutes ago\";\n- the view bar counts them, \"3 changed by Ana Ruiz\", and a click on the count\n marks them all seen.\n\nOpening the record clears its marks. Its activity lists each change as\n\"Ana Ruiz changed Priority\", with the value before crossed out and the value\nnow: Low → Urgent.\n\nThe name comes from the record itself: its `lastModifiedBy` field (for a\nrecord added elsewhere, `createdBy` first). Whoever writes to the database\nwrites their user id to that column, and the base looks it up in\n`setFieldUsers`. Without such a field the change is credited to \"Someone\nelse\". Your own writes are never reported back to you: the base compares what\nit reads with what it last wrote.\n\n### An AI agent writing to the base\n\nThe same path serves an agent: a script, a worker calling a model, or Claude\nCode with your database's MCP server. Give the agent a user id, add it to\n`setFieldUsers` with a name and an avatar, and have it set `modified_by` (or\nwhichever column your `lastModifiedBy` field reads) on every row it writes.\nPeople then see exactly what it changed, review it in a view filtered on a\n\"Needs review\" field, correct what it got wrong, and approve the rest with a\nbutton field and an automation.\n\n[Let an AI agent work in your base](./ai-agents.md) walks through it with\nClaude Code and Supabase, and [Review what an agent changed](./review-queue.md)\ncovers the review side on any database. Here the agent is a stand-in made of\nkeyword rules, so the demo runs without a model or a key. It writes to the database with SQL; press \"Run the triage\nagent\", then open a ticket.\n\n<div data-docs-demo=\"700-base-ai-triage\" data-height=\"900\"></div>\n\nTo act on changes made elsewhere in code (a notice, a log, a count of your\nown), pass `onRemoteChange` to `<SvBase>`. It gets each change once it is in\nthe page:\n\n```ts\nimport type { BaseRemoteChange } from '@svgrid/enterprise/base'\n\nfunction onRemoteChange(changes: BaseRemoteChange[]) {\n for (const c of changes) {\n // c.type: 'insert' | 'update' | 'delete'; c.table, c.id, c.record\n // c.fields (updates): [{ field: 'priority', from: 'Low', to: 'Urgent' }]\n if (c.type === 'update') console.log(c.id, c.fields)\n }\n}\n```\n\n## Status and errors\n\nThe end of the tab bar says what the base is doing:\n\n| It reads | When |\n|---|---|\n| Loading records... | The tables are loading |\n| Saving... | Writes are on their way |\n| Still saving: the server has not answered yet | A write has been waiting a while |\n| All changes saved | Every write went through |\n| Not saved: *reason* | A write was refused; the cell went back |\n\n![A refused write: the database rejects a status, the cell goes back, and the tab bar says the database does not accept this value.](/docs-media/base-refused-write.png)\n\nA table that cannot be read says so where its records would be, for as long as it lasts,\nwith why and a **Try again**. No empty table is shown for it, and nothing can be added to\nit. The other tables of the base open as usual.\n\nA table read a part at a time (`serverRows`) whose next part cannot be read says so in the\ntab bar, \"Could not load *table*: *reason*\", with **Try again**, for as long as a part of the\nview is unread, wherever it is scrolled to. The rows that did not come are a tinted band with\n\"Could not load these rows.\" and **Retry** on its first row on screen. A read again of rows\nalready on screen, after a teammate's change, that fails leaves those rows as they were: the\ntab bar says so with **Try again**, which reads them again.\n\nWhen the server sent a reason with its error (`{ \"error\": \"...\" }` and no `code`), that reason\nis what the notice says. `createRestDataSource` passes on an API's `{ \"error\" }` or\n`{ \"message\" }` the same way.\n\nA failed write is told in a notice that names the record and the field, says why in\nplain words and shows what was entered, with **Try again** where that can work. The record\nis named as it is stored, never by the value that was refused. A foreign key of more than one\nfield that refuses a write names all of its fields. The notice stays until it is dismissed,\nand \"Not saved\" stays until that record is written: a later write of another record does not\nclear it. A click, a tap or Enter on the status line opens it in full: the reason, and the\nserver's own words when it sent some and the reason does not already say them. The text of\nthe request itself (a status code, a JSON body) is never shown; it is in the browser's\nnetwork log and the server's log.\n\nA new record the database refused takes no edit while it is still listed (while another cell or\nrecord is being edited, or a draft on a table read a part at a time whose refusal no retry can\nchange, such as an id column too narrow): a click, a key or a paste on\nit shows its notice again instead of an editor. An editor open on it when the refusal comes closes\nwith what it holds, and the notice names it. A draft refused for a reason a retry may get past keeps\ntaking edits, and its next edit sends it again.\n\n**Try again** reads the record first, as an undo does. A value that changed since the\nwrite failed, whether a teammate wrote it or you typed it again, keeps that value and the\npage says so. A record deleted since is reported with what you entered. If the record\ncannot be read, nothing is written and the notice offers Try again once more.\n\nA change of many records at once (a paste, a clear or an Undo of 20 or more) that fails\nis one notice with the number of records, and the same **Try again**: it reads them all\nfirst, sends what is still as it was in blocks, and says how many cells changed since and\nhow many records were deleted since. Part of a block may have landed; the page reads the\ntable again to show which. An Undo of some of those cells takes them out of what Try\nagain would send. A refusal of your permission offers no Try again and leaves no step to\nundo, and so does a refusal of the values, an answer of `400`, `409` or `422`: the same\nvalues would be refused again.\n\nA write that gets no answer is not given up on: it may still land, or be refused. After\n`writeTimeout` (60 seconds by default, on `<SvBase>`) writes to other records go on, and\nlater writes to the same record wait behind it, so none can overtake it or be overwritten\nby it landing late. The status says \"Still saving\" for as long as it has no answer, and\nstarts warning at a sixth of `writeTimeout`. The page keeps what was entered, and goes back\nonly if the write is refused. A delete with no answer keeps its copy in the trash until the\noutcome is known, and leaving the page asks first.\n\nWhile someone is typing in a cell or in a field of a record, changes from others wait\nuntil the editor closes, so no row moves under it and no text changes under the cursor.\nThat holds for a live feed and for a read of the table, on any table. If the record was\ndeleted meanwhile, saving it says so and shows the text.\n\n## Options\n\n`baseSource(dataSource, options)`:\n\n| Option | Default | What it does |\n|---|---|---|\n| `links` | none | How link fields are stored: `{ column }` or `{ through, from, to }` |\n| `columns` | none | Column names that differ from field names: `{ dueDate: 'due_date' }` |\n| `idField` | `'id'` | The key column |\n| `serverIds` | `false` | The database makes the key of a new record |\n| `realtime` | none | Hear of changes made elsewhere: `(apply) => stop`; `apply(changes)` updates those records in place |\n| `skip` | none | Fields kept in the page only |\n| `holdInPage` | `10000` | How many records a table may hold in the page. It is where a table changes how it is read, not a cap: a bigger one is read from the database a part at a time, and no record is left out. (`limit` is the old name.) |\n| `convertField` | none | A field of a big table changed type: rewrite its values in the database and resolve with `true`. Without it the base rewrites them a block at a time. |\n| `duplicate` | none | Copy a big table in the database and resolve with the new table's source. |\n| `serverRows` | automatic | `true` always reads from the database, and the first screen comes sooner on a table you know is big; `{ blockSize }` sets the rows per request (200). `false` always holds every record in the page, however many. Left out, the base decides by `holdInPage`. |\n\n## Build a base from your database\n\n`baseTablesFromSchemas` makes the tables from your database's own\ndescription of them: a number column becomes a number field, an enum a\nsingle select with its values, a foreign key a link with a field in the\nother table that links back. Read the descriptions with\n`introspectSupabaseTable`, `introspectDatabase` or `introspectOpenApi`, or\nwrite them out:\n\n```ts\nimport { baseTablesFromSchemas } from '@svgrid/enterprise/base'\nimport { createRestDataSource, type EntitySchema } from '@svgrid/enterprise'\n\nconst schemas: EntitySchema[] = [\n {\n name: 'deals',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'title', type: 'text' },\n { field: 'stage', type: 'enum', options: [{ value: 'Open', label: 'Open' }, { value: 'Won', label: 'Won' }] },\n { field: 'company_id', type: 'relation', relation: { entity: 'companies', labelField: 'name' } },\n ],\n },\n { name: 'companies', fields: [{ field: 'id', type: 'text', primaryKey: true }, { field: 'name', type: 'text' }] },\n]\n\nconst tables = baseTablesFromSchemas(schemas, (schema) => createRestDataSource({ url: `/api/${schema.name}`, schema }))\n```\n\nThe result is ordinary `BaseTable` objects: change a field's type, add views,\nrename a table. [Build a base on your API](./rest-api.md) does this end to end.\n\nThe other way round, `baseToSql(tables)` writes a base as Postgres SQL:\ntables, foreign keys, the tables behind links to many, and the records, with\n`svgrid:` comments for the field settings, views and automations that SQL\nhas no type for. The tables it makes have text keys with a\n`gen_random_uuid()` default, so a record added later gets its key from the\ndatabase. See [Take a base to a database](./quick-start.md#take-a-base-to-a-database).\n\n## A table of millions\n\nA table has no size limit, and nothing here is a setting you have to get right.\nA table of the thousands of records a team keeps in a tracker, a CRM or an\ninventory is held in the page. One that grows past `holdInPage` is read from the\ndatabase a part at a time, the next time it is read, and looks and works the\nsame: every view, link, lookup, rollup, automation and search reads all of it.\nThe page then holds none of its records, only what is on screen.\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\ndeclare const orders: ServerDataSource<Record<string, unknown>>\n\n// Nothing to set: it reads from the database once the table outgrows the page.\nconst source = baseSource(orders)\n\n// A table you know is big: skip the first look, and size the requests.\nconst big = baseSource(orders, { serverRows: { blockSize: 200 } })\n```\n\n<div data-docs-demo=\"723-base-million-orders\" data-height=\"620\"></div>\n\nHow each part of a base reads such a table:\n\n| | Read a part at a time |\n|---|---|\n| Grid views | Read through the server row model. Each request carries the view's filter (`filterModel.expression`), its sort, its groups (one row per key with its count, the records under an opened key) and the search. The count in the view bar is the server's. A grouped view shows select groups in option order and each group as the field draws it, with the records it holds at every level, and the totals of the fields with a sum, average, lowest or highest picked in the footer. Whenever the view is read again (your delete, Restore, Undo or Redo, a new record, an edit once you leave the record, an option renamed, a field converted, a teammate's change), the group rows and the loaded records of every open group are read, with or without a feed: a deleted record leaves its group, a restored or new one shows in its group, and the counts follow. A group closed at the time reads again when it is opened. A teammate's change that a feed sends with its row patches that row where it is; when it changes a field the view groups or sorts by (any field, when the view groups or sorts by a formula or lookup), the view is read again at once, so the record takes its place in the order and in its group. A filtered view reads again within a second after any change, so a record that left the filter goes. |\n| Kanban | Each lane shows its true size, from one grouped request, and reads its cards as they scroll into sight. A card moved to another lane is written by id and sits at the top of that lane until the lane is read again. Sorted by a number field, dropping a card elsewhere in its lane writes that number, so the order is the table's. |\n| Calendar | Reads the dates on screen and no others. A range of up to 400 records is read whole. A busier one is read a day at a time: each day's first records and its size, from one grouped request where the backend groups and the view has no end date, so an empty day costs nothing and a write reads only the days whose size moved. \"+N more\" lists every record of that day. The days are the viewer's: on a column of moments (Postgres `timestamptz`, SQL Server `datetimeoffset`) the sizes, each day's records and that list follow the page's zone, also across a change of the clocks. A date and a wall clock (`timestamp`, `datetime`, a MySQL `TIMESTAMP`, which reads as the server's clock) show the same everywhere, and their days follow what the cell shows. |\n| Gantt | Rows by start date, read as they scroll into sight. The axis runs from the table's first start to its last end. Dependency arrows and rescheduling reach the rows read so far. |\n| Gallery, list, inbox | Only the records in sight are drawn and read. A grouped list shows each group's size and reads its records when opened. |\n| Chart, dashboard | The server groups and adds up, over every record. A date axis is read a month at a time, in the viewer's months on a column of moments: one grouped request for each part of the records' span with one UTC offset, two a year in a zone with summer time. The records behind a tile show the first 200 and how many there are. |\n| Form | Stores its record through the source, and reads nothing. |\n| Links | A link cell reads the records it names by id, for the cells on screen, in one request. The picker searches the whole table, and a name pasted into the cell is found there. A link edits from either side: on the side that holds no list (a customer's orders), each tick changes that order. |\n| Lookups, rollups and counts | Read the linked records by id. Over a link stored on the big table (a customer's orders), the server counts and adds up: one grouped request a screen, whatever the size. |\n| Search across tables | Each big table searches on the server, and says how many match. |\n| Find in a grid | The search box filters on the server: a find bar could only mark the rows loaded. |\n| Automations | Run on any record, read by id. A scheduled one runs on every matching record, block by block. |\n| Share links | Show the whole table, without the fields the share leaves out. |\n| Autonumber | The next number is the table's largest plus one. Two people can reach it together, so each record is checked once stored: of any two holding a number the later one takes the next, and a column with a UNIQUE constraint refuses the second and the write tries again. Numbers can skip. A number a person deleted in this page is not given out again while it stays open, so an undo finds its number free. After a reload, or on a teammate's page, the number of a deleted record can be given out again, since the next one follows the largest left. A restored record whose number was given out meanwhile takes the next one. |\n| Changing a field's type | Asks first, with the number of records. Then `convertField` does it in one statement (`createSqlDataSource` with `schemaChanges: true` has one on Postgres), or the base reads a block at a time and writes the records whose value changes, sixteen at a time. The other choice changes the field only. |\n| Download as SQL | Writes every record, a block at a time, so the file can be larger than the page could hold. |\n| Duplicate table | Copies in the database with the `duplicate` option (`schemaChanges: true` gives a Postgres source one). Without it the records are read into the page a block at a time, with the count in the tab bar, and the copy lives in the page, so a very large table needs the option. |\n| Edits | Written by id: a change to the 900,000th record is one `update`. |\n| Edit fields | On a selection, in a dialog with progress and Stop. The selection is read first, and only records whose value changes are written, a block of 1,000 at a time. Past 10,000 records it asks first, with the exact number, because Undo cannot take that many back. Stop ends it after the block under way. A block that fails ends it too: the page reads that block back, says how many records changed, and Undo takes those back. Records that landed past 10,000 stay changed. |\n| A range of cells | Paste, one value pasted over a range, Delete, the fill handle and Ctrl+Enter reach every record the selection covers, loaded or not. Up to 200 cells of rows the grid holds are written at once, cell by cell. Anything larger, or reaching rows not loaded, runs in the Edit fields dialog: the records are read in view order, then written a block of 1,000 at a time (200 on a source that writes a request a record, such as Supabase, so the count moves and Stop answers within a block), with the same progress, Stop, count at the end, question past 10,000 and one Undo step. A block the database refuses part way ends the job: the count says how many records changed, and Undo takes those back. If records moved while the range was read (a teammate's edit changed the order or the set of a sorted view), nothing is written or copied: the page says, for a paste, \"Records moved while this was read. Nothing was changed. Try again pastes from \"Acme\" down over the rows as they are now.\", naming the first record selected. Try again finds that record by its id where the list has it at the click, goes from it over as many rows below it as before, and selects those rows first, so the screen shows what it writes; its dialog lies over them, so it names them too (\"From \"Acme\" down over 2,500 rows, selected in the view.\"). If the record is gone or no longer among the rows shown, it writes nothing and says so, and so it does when fewer rows stand below the record now than the first try covered (the record fell to the end of a sorted view): it never turns lines into new records the first try wrote over records that were there. To tell that records moved, the whole id sequence is checked, in requests that ask for ids alone: a range longer than a block reads its ids first and each block must bring the same ids in the same places, each block also reads the last record of the one before again, a record read twice counts as moved, and once the last block is in, the ids of the whole range are read again and must be the very ids read, in the same order. Each of those reads asks for the whole range at once (up to 20,000 ids); a server that caps an answer (PostgREST's `db-max-rows`, 1,000 on Supabase) is read on from where its answer ended, a page of its own size at a time, and only a different id sequence, or a list that ends before the range does, counts as moved. On Supabase and PostgREST these reads select the key alone. Any difference counts, a move inside the part already read too. Try again acts only in the view the cells were chosen in, as it was then: after a switch to another view, or a change of its sort, filter, groups, open groups or shown fields, it writes nothing and says \"That view is no longer open, so nothing was changed.\" or \"The view has changed since, so nothing was changed.\" An answer to a question the job asked (past 10,000 records, new records past the last row, a delete) does the same. A new record that is not stored yet sits on top of the list and in no block of the table: a range over it leaves it out and says how many it left, a paste keeps its line for it, and a copy has its line. A drag of a range over rows not loaded is refused, with the number. A paste while the view is still loading is refused too, and never makes a record. |\n| Copy | Rows not loaded are read first, in a dialog with progress and Cancel, each line a real record with its worked out fields. A copy holds up to 2,000,000 cells: that many, 20 MB of text, took 4.6 s with a longest frame of 450 ms in Chrome on a production build, reading from the page. Past that nothing is copied, the page says how many cells were asked for, and Download gets all of it. If a browser will not take the text so long after the key press, the dialog asks for one more click. |\n| A paste past the last row | A line where no value fits its field makes no record. Up to 10 new records are added at once; past 10 the page asks first, with the number. They go in blocks of 1,000 (`createRows` makes a block one statement), and one Undo takes them out the same way, with the cells the paste wrote. A record someone has worked on since stays, and the page says so. |\n| \"+\" | In every view of records. It opens a new record, filled in from the view's filter (Region is EU in a view of EU orders). Nothing is stored until it holds a value, and one closed empty is gone. If the database refuses it, it stays in the grid with its values and the next edit tries again. What the database fills in, such as an order number, comes back into the record. Ctrl+Z takes a stored record out again. |\n| Insert record, Duplicate | Insert opens a draft, as \"+\" does. Duplicate stores the copy and shows it at the top of the grid. |\n| A new field | The \"+\" at the right of the header row, for whoever may change the schema (`columnAdder={false}` hides it). `createSqlDataSource` with `schemaChanges: true` adds the column on Postgres, MySQL and SQLite. A new field starts empty: when a column by that name is already in the table it takes the next free name, and says so. A column that cannot be added takes the field back. A source that cannot add one, such as Supabase, shows the `ALTER TABLE` to run, and `addField` on `baseSource` is your own way to make it. There, Duplicate field copies nothing: it shows the statement for the copy's column, to run before duplicating. An Autonumber or Created time field stays blank on the records already there. |\n| Delete | By id, to the trash, as the database holds the record at that moment; Ctrl+Z puts it back whole, columns the base shows no field for included, under the key it had, on a table the page holds and on a big one alike. A column off the source's schema never reaches the page, so it takes its default, unless the source reads whole records (`wholeRecords` on `createSqlDataSource`). The record stays in the trash until the database has it. What only the database may write stays the database's: a generated column works itself out again, and a `GENERATED ALWAYS` key gets a new value. Time columns go back as the database wrote them, past the millisecond and at a local time the clocks skipped, on Postgres and MySQL with any driver. A record the database refuses to delete stays in the table and out of the trash, and so does one a row-level policy skipped without an error: after a delete the base looks. |\n| Soft delete | `softDelete: 'deleted_at'` marks a record instead of removing it, and a restore clears the mark, so nothing is rewritten. See [Undo, trash and import](./undo-trash-import.md#soft-delete). |\n| Select all | Selects every record of the view, read or not, and the count says so; a group's tick selects all of the group. A new filter clears the selection. With `selectionBar={{ actions: ['deleteRows'] }}` (and `enableSelectionBar()`), Delete first reads what the selection covers, then asks with the exact number. The records go a block at a time, with a Stop button: what went before you stopped stays gone and stays restorable. `deleteRows` and `createRows` on your data source make a block one statement. Up to 10,000 go to the trash and can be undone; above that the question says they cannot be restored. A group that reads back a different size from its group row stops the job with nothing deleted, since what was left out of the selection could not be told apart. A record that leaves the view after you confirm is still deleted, since you confirmed that set. |\n| Changes made elsewhere | `apply(changes)` updates those rows in the grid, highlighted and credited, whether the page holds them or not. |\n| Formulas | Worked out in the page for the rows on screen. |\n\nAll of this is `getRows` with what a grid view already sends: a range, the\nview's filter, a sort, `groupBy` and `groupKeys`, an `in` list on the key\n(`filterModel.columns.id.selectedValues`), and for a chart or a total\n`aggregations` and `needsGrandTotal`. Grouping a link for a count from its other\nside sets `groupRawKeys`: group by the linked id, which a foreign key does. A calendar's\n`groupDays` and a chart's `groupMonths` ask for a date level by day (`2026-03-14`) or month\n(`2026-03`), on a column of moments in the zone `dayOffset` minutes ahead of UTC. A source that passes over them answers by value and the page adds the groups\nup, which on a time field is a group a record. The data source applies the view's filter\nand acknowledges it with `appliedExpression: true`. The\nSupabase, REST and SQL sources already answer all of these, and\n`createSqlDataSource` also runs a view's filter, sort, groups and totals on a\nformula, lookup or rollup in the database\n([computed fields in SQL](./server-compute.md#computed-fields-in-sql)). On your own\nsource, index the fields views group and place records by: a busy calendar\nmonth is a request per day.\n\n### Index what views sort on\n\nA sort on a column with no index sorts the table again for every block a person\nscrolls to, and that is what limits how many people a big table serves. Give each\nfield a view sorts on an index with the table's key after it:\n\n```sql\nCREATE INDEX orders_amount ON orders (amount, id);\n```\n\nThe key is there because a read breaks ties on it, in the sort's direction\n(`ORDER BY amount DESC, id DESC`). Leave both columns ascending, as above: one index\nthen serves a sort either way. `(amount DESC, id)` matches neither direction, and on\nMySQL it goes unused.\n\nThrough `createBaseEndpoint` on a table of 1,000,000 records, sorted on a numeric\ncolumn, blocks of 100, default database settings, on a shared development machine:\n\n| Median time for a block | No index | With the index |\n|---|---|---|\n| Postgres, one person | 2,263 ms | 567 ms |\n| MySQL, one person | 2,476 ms | 42 ms |\n| Postgres, 30 people at once | 23,576 ms | 2,118 ms |\n| MySQL, 30 people at once | 22,968 ms | 713 ms |\n\nA formula or a lookup has no column to index: a sort on one costs a sort of the\ntable for every block, so a view with many people on it is better sorted on a stored\nfield. A filter narrows what is sorted, and an index that starts with the filtered\nfield and ends with the sorted one serves both.\n\n### What the database cannot run\n\nA view never goes unanswered. When a filter, sort, group or total needs a field\nthe data source cannot compute, or the source does not acknowledge a filter, or\nit fails on a computed field, the page reads the table a block at a time, works\nthe field out with the same code the cells use, and keeps the ids and the values\nthe request needs. The view then reads its records by id. The tab bar shows how\nfar it has got.\n\nIt gives what the cells say, on any backend, and it is slower than the database:\nabout a minute for a lookup over the 1,000,000 records of the demo on a dev\nserver. It is read once. Scrolling, sorting again and the lanes of a board cost\nnothing more, a record you or someone else changes is updated where it stands,\nand changing a field reads again. Taking the sort or filter away stops the read.\nRecords changing while it reads are read again once, and if the count still moves\nthe base says so.\n\nTell the base what your source can work out with `computes`, and that field stays\nin the database. Without it, only `createSqlDataSource` is asked: a `queryRecords`\nbackend needs `computes: () => true` or it is right but slow.\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\ndeclare const orders: ServerDataSource<Record<string, unknown>>\n\nconst source = baseSource(orders, { computes: (def) => def.field === 'tax' })\n```\n\n`@svgrid/enterprise/base/compute` has both halves:\n[`queryRecords`](./server-compute.md#answer-a-paged-table) for records a\nserver holds, and [`fieldFilterToSql`](./server-compute.md#the-views-filter-in-sql)\nfor a database.\n"
5202
+ "markdown": "# Keep a base in a database\n\nA base can keep its records in your database instead of the page. Give a\ntable a `source` and `<SvBase>` loads the records from it when it opens, then\nwrites every change back: a cell edit, a pasted range, a new record, a\ndeleted one, a link made from either side. Postgres, MySQL, SQLite, Supabase\nand any REST API work the same way, because each is reached through the\ndata source contract the grid already uses.\n\n<div data-docs-demo=\"516-base-postgres\" data-height=\"760\"></div>\n\nThe demo above is SvGrid Base on a real Postgres database running in the\npage (PGlite). Change a status and the log shows the `UPDATE` it ran.\n\n## How it fits together\n\n![SvGrid Base keeps every record in the page. The writer compares the tables with what the database holds and sends inserts, updates and deletes through baseSource to a data source, which talks to Postgres, Supabase or your API.](/docs-media/base-data-flow.svg)\n\n- **The page holds every record of a table.** Views, filters, groups,\n summaries, colors and automations all work on those records, so they stay\n instant. A table with more records than the page should hold (10,000 by\n default) is read from the database a part at a time instead, by itself: see\n [A table of millions](#a-table-of-millions).\n- **The writer sends what changed.** After each change it compares the\n tables with what the database holds and queues an `INSERT` for a new\n record, an `UPDATE` with only the fields that changed, or a `DELETE`. The\n writes go one at a time, in order, so an update never overtakes the insert\n of its own record.\n- **A refused write goes back.** When the database says no (a constraint, a\n row level security policy, a network error), the cell returns to what the\n database holds, the end of the tab bar says why in plain words, and a notice\n names the record and the field. What the database said is in the tooltip, or\n through an endpoint in the server log, because it names tables and values:\n [what a person reads](./postgres.md#3-one-endpoint-per-table).\n- **Changes made elsewhere come in.** With `realtime`, the base reads a table\n again when someone else changed it and takes what moved, without writing\n anything back.\n\n## Give a table a source\n\n`baseSource` wraps any data source:\n\n```ts\nimport { baseSource, type BaseTable } from '@svgrid/enterprise/base'\nimport { createRestDataSource } from '@svgrid/enterprise'\n\nconst tasks: BaseTable = {\n id: 'tasks',\n name: 'Tasks',\n primaryField: 'name',\n data: [],\n columns: [\n { field: 'name', header: 'Task', fieldType: 'text' },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: [{ value: 'Todo' }, { value: 'Done' }] } },\n ],\n source: baseSource(createRestDataSource({ url: '/api/tasks' })),\n}\n```\n\n```svelte\n<script lang=\"ts\">\n import { SvToaster } from '@svgrid/grid'\n import { SvBase, enableBase, type BaseTable } from '@svgrid/enterprise/base'\n\n enableBase()\n let { tables }: { tables: BaseTable[] } = $props()\n</script>\n\n<SvBase bind:tables editable />\n<SvToaster />\n```\n\n`data` can start empty: the base fills it. A write that is refused shows a notice\nand the tab bar says so; see [Notices](./quick-start.md#notices).\n\nThe data sources that ship with `@svgrid/enterprise`:\n\n| Source | Talks to | Tutorial |\n|---|---|---|\n| `createSupabaseDataSource` | Supabase (PostgREST), from the browser | [Build a base on Supabase](./supabase.md) |\n| `createSqlDataSource` | Any SQL database, through an `execute(sql, params)` you write. It reads and writes the columns on its schema and no others; `wholeRecords: true` reads and writes every column, for a source in the same process as the page, and `createKitHandlers` refuses one | [Build a base on Postgres](./postgres.md) |\n| `createKitDataSource` | Your SvelteKit endpoint, which runs `createSqlDataSource` on the server | [Build a base on Postgres](./postgres.md) |\n| `createRestDataSource` | A JSON API: `GET`, `POST`, `PATCH`, `DELETE` | [Build a base on your API](./rest-api.md) |\n| `createInMemoryDataSource` | An array, for tests and prototypes | |\n\nYour own source works too: an object with `getRows`, `createRow`,\n`updateRow` and `deleteRow` (the grid's `ServerDataSource`).\n\n## Tables your server makes, copies and deletes\n\nA table with a source lives in your database, so a new one should too. Give\n`<SvBase>` the four hooks and the tab bar's Add table, Duplicate table and\nDelete table, and the trash's Restore for a table, go through your server:\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, baseSource, type BaseTable } from '@svgrid/enterprise/base'\n import { createRestDataSource } from '@svgrid/enterprise'\n\n let { tables } = $props()\n\n // What your API answers for a table, as a BaseTable reading its records from it.\n const asTable = (t: any): BaseTable => ({ ...t, data: [], source: baseSource(createRestDataSource({ url: `/api/tables/${t.id}/rows` })) })\n const post = async (url: string, body?: unknown) => {\n const res = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body ?? {}) })\n if (!res.ok) throw new Error((await res.json()).error ?? 'The table was not saved.')\n return res.json()\n }\n</script>\n\n<SvBase\n bind:tables\n editable\n onAddTable={async (name) => asTable(await post('/api/tables', { name }))}\n onDuplicateTable={async (table, name) => asTable(await post(`/api/tables/${table.id}/copy`, { name }))}\n onDeleteTable={async (table) => (await post(`/api/tables/${table.id}/trash`)).item}\n onRestoreTable={async (item) => asTable(await post(`/api/tables/${item.table.id}/restore`))}\n/>\n```\n\n- **Add table** calls `onAddTable` with the name the base would give the\n table (\"Table\", \"Table 2\"...). The table it answers is added and opened,\n and its `source` is read at once, as the first tables' were. Nothing\n answered adds nothing. A rejection's message is shown.\n- **Import a file as a table** calls `onImportTable` with the table the\n import built: its fields (with the types it found) and its records in\n `data`. Keep it, and answer the table to add, with its `source`; it opens and\n is read from there. Nothing answered adds nothing; a rejection's message is\n shown. Without the hook the table is made in the page.\n- **Duplicate table** calls `onDuplicateTable` with the table and\n \"Name copy\". The copy it answers is added and opened.\n- **Delete table** asks the person first, as always, then calls\n `onDeleteTable`. `false`, or a rejection, keeps the table. A trash item it\n answers is what the trash shows for the table, and your `trashStore` is not\n handed it again. Otherwise the base keeps its own item.\n- **Restore** of a table in the trash calls `onRestoreTable` with the item.\n The table it answers goes back where it was, read from its `source`, and\n opens. Nothing answered leaves the item in the trash.\n\nA table made, copied or brought back this way is yours, not a step of the\npage's history: Ctrl+Z does not take it away. Without a hook, the base makes,\ncopies, deletes and restores tables in the page, as before.\n\nAny table you put in `tables` after the base opened, hooks or not, is read\nfrom its `source` and kept in sync like the first ones.\n\n## Link fields\n\n![How link fields are stored. A link to one record is a foreign key column. A link to many records is a junction table with one row per pair. The field that links back is not stored.](/docs-media/base-links.svg)\n\nIn the page a link field holds record ids. `links` says how each one is kept:\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport { createRestDataSource } from '@svgrid/enterprise'\n\nconst taskTags = createRestDataSource({ url: '/api/task_tags' })\n\nconst source = baseSource(createRestDataSource({ url: '/api/tasks' }), {\n links: {\n // A link to one record: the column with the linked record's id.\n project: { column: 'project_id' },\n // A link to many records: a junction table, one row per pair.\n tags: { through: taskTags, from: 'task_id', to: 'tag_id' },\n },\n})\n```\n\nThe field that links back (a project's Tasks, when tasks have a Project\nfield) is worked out in the page from the other side and never stored. Link\na task from the project's side and the base writes that task's\n`project_id`. A link field that is neither in `links` nor the other side of\none is written as it is, a list of ids, which suits a Postgres `text[]` or a\n`jsonb` column.\n\nA list (a multiple select, a vote, a sparkline) goes to its column as that column takes\nit: an array to `text[]`, JSON to `json` and `jsonb`, and JSON text to a text column, on\nMySQL, SQL Server and SQLite too. It reads back as the list it was.\n\n## Keys the base can use\n\nA record needs one column that names it. When a base reads a database:\n\n- A table with a primary key of one column is a table.\n- A table keyed by both ends, `order_tags (order_id, tag_id, primary key (order_id, tag_id))`,\n with both columns foreign keys, is a link to many, like a junction with its own `id`. A\n link goes by the whole key, so removing a tag deletes that one pair. A tenant column in\n the key, named in `tenantColumn`, is part of the key and no end of the link. Other columns\n on such a table are not read and not written: a new link gives them their defaults, one\n that is `NOT NULL` with no default refuses the link, and the server log names them. A\n pair whose two ends the base does not hold, by their keys, is left out.\n- Any other table with a composite key, or with no primary key, is left out of the base, a\n view included. The rest of the base opens, and the log names the table and says why.\n Nothing runs on part of a key, because a delete by one column of two reaches every row\n that shares it.\n\n`keys` brings such a table in, when one of its columns is unique:\n\n```ts\nexport const { GET, POST } = createBaseEndpoint({ execute, allTables: true, public: true, keys: { v_orders: 'id' } })\n```\n\nThat is your word for it: nothing checks, and a delete reaches every row that holds the\nvalue. `baseFromDatabase` and `baseFromSupabase` take it too. On Supabase the key comes\nfrom the API description; a project that does not show that to the key in use has only a\ncolumn named `id` to go by.\n\n### Foreign keys of more than one column\n\nA foreign key of more than one column, as a database keeps tenants apart with,\n`foreign key (tenant, customer_id) references customers (tenant, id)`, is a link through\n`customer_id` to that tenant's customer, when `tenantColumn` names `tenant` on both tables.\nThe tenant column stays the read-only tenant, not a link. It works the same in a pair\ntable, `(tenant, order_id) -> orders (tenant, id)`. Any other key of more than one column,\nthree columns or two without the tenant, links nothing: its columns are plain values and\nthe log names the key. A key links only to a table its bare name reaches: on Postgres a\ntable of any schema on the search path, unless a table of that name in an earlier schema\nhides it (a key to a hidden table stays a plain value); on SQL Server the user's default\nschema; on MySQL the connected database. The other table still has to be one the base\nserves. Supabase does not describe a key of more than one column, so there\nneither column is a link.\n\n## Record ids\n\nA new record gets an id in the page at once, so it can be edited and linked\nbefore the database answers. By default that id is its key in the database\ntoo: give the key column a text type.\n\nWhen the database makes the key (a `serial` column, a `uuid` with a default),\nset `serverIds: true`. The record is inserted without the page's id, and the\nwriter keeps the page id for the grid and translates to the database id for\nevery later write and every link that points at the record.\n\n## What a write answers\n\nThe row a server answers is the truth. After a write the cell, the record and the views\nshow what was stored: a value a `before*` hook or a trigger changed, a tenant the scope\nstamped, a default on a new record. A number the column rounded shows rounded. Undo goes\nback from what was stored. A block of Edit fields or of a range on a big table answers with\nwhat hooks changed, and a trigger's work on such a block shows when the view reads the rows\nagain. On a table the page holds, a paste, a clear or an Undo of 20 records or more is\nwritten in blocks, and each block's records are read back once it lands, so a trigger's\nwork shows at once there too.\n\nThe answer is the row the write left, not a teammate's write a moment later. Postgres and\nSQLite say it in the write itself (`RETURNING`). SQL Server writes and reads it back in one\ntransaction of one batch. MySQL has no way to do either in one statement: give\n`createSqlDataSource` (or `baseFromDatabase`, `createBaseEndpoint`) its `transaction` and the\nwrite and its read go in one. Without it a teammate's write to the same cell in the moment\nbetween the two is taken for yours, and an Undo of yours can then write over theirs.\n\n## What is not written\n\nFields the page works out are never sent: formula, lookup, rollup, count and\nbutton fields, and the field that links back. Add any other field to `skip`\nto keep it in the page only.\n\n## What a cell holds\n\nA base reads dates, times, bigints and decimals as the database writes them, as\ntext. A SQL source asks for a text copy of each such column\n(`to_json(col) #>> '{}'` on Postgres, `CAST(col AS CHAR)` on MySQL) beside the\ncolumn itself, so sorting and filtering still use the real column.\n\n| Column | What the page holds | What people see |\n|---|---|---|\n| `date` | `2026-03-08` | That day, in any zone |\n| `timestamp`, `datetime` | `2026-03-08T02:30:00.123456` | That wall clock, in any zone |\n| MySQL `timestamp` | The wall clock of the connection's `time_zone` | That wall clock, in any zone |\n| `timestamptz` | `2026-03-14T22:00:00.654321+00:00` | That moment, in the viewer's zone |\n| `bigint`, `numeric`, `decimal` | Text past what a JS number holds | Every digit |\n| `json`, `jsonb` | The text the database writes | Every digit: a driver's `JSON.parse` would round a number past 2^53 |\n\nA time someone types keeps its wall clock on a column without a zone, and is that\nmoment on a `timestamptz`. An undo or a restore writes back the text it read, so\nnothing moves by a zone or loses digits past the millisecond.\n\nThe days of a filter and the months of a chart are the viewer's. On a column of moments\n(Postgres `timestamptz`, SQL Server `datetimeoffset`, SQLite text that ends in a zone)\n\"is 8 March\", \"today\" and \"within the past week\" keep the records whose moment falls on\nthose days where the person is, and a chart counts each record in the month it reads as\nthere, across a change of the clocks too. The page sends each date condition with the\nmoments its days start and end (`moments` on the condition), since a server has no zone\nof the viewer's, and `createSqlDataSource` compares them on such a column. A date and a\nwall clock, a MySQL `TIMESTAMP` among them, compare their days and read the same everywhere.\nOn Supabase, say which columns hold moments: `supabaseFieldFilter(columns, { moments: (def) => def.field === 'starts_at' })`.\nWithout that, a condition there compares the database's days.\n\nOver PostgREST (Supabase) a date already arrives as text. A JSON number cannot\ncarry more than about 15 digits, so the first read that shows a longer one reads\nthat column again with `col::text`, and later reads bring the copy along. A change\nthat arrives through Realtime is plain JSON: such a number in it is rounded until\nthe next read.\n\nJSON in a `text` or `longText` field shows as JSON text. A change goes back as\nJSON; text that is not valid JSON is refused with a message and the cell goes back. A\n`jsonb` column writes its own spaces and key order, and that is no change: nobody is told\nof one. Over PostgREST a JSON column arrives as JSON, so a number past 2^53 in it is rounded.\n\nOpening a cell and leaving it writes nothing, whatever the field shows.\n\n## Changes made elsewhere\n\n![An edit, step by step: Ana's base sends the field that changed, the database tells every subscriber, and Ben's base reads the table again and takes what moved.](/docs-media/base-realtime.svg)\n\n`realtime` takes a function that calls `apply` with what changed and returns a\nfunction that stops listening. With Supabase, hand it Realtime's events as\nthey come:\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport {\n createSupabaseDataSource,\n createSupabaseRealtime,\n type EntitySchema,\n type SupabaseClientLike,\n type SupabaseRealtimeClientLike,\n} from '@svgrid/enterprise'\n\n// Your supabase-js client: createClient(url, anonKey).\ndeclare const client: SupabaseClientLike & SupabaseRealtimeClientLike\ndeclare const schema: EntitySchema\n\nconst source = baseSource(createSupabaseDataSource({ client, table: 'tasks', schema }), {\n realtime: (apply) => createSupabaseRealtime({ client, table: 'tasks', onChange: apply }),\n})\n```\n\nThe base updates just the records a change names: the other records keep\ntheir objects, so the grid redraws one row, not 50,000, and the table is not\nread again. A burst of changes (an agent updating 200 records) goes into the\npage as one update. A change to a record this page wrote in the last few\nseconds may be its own write coming back late, or someone else's edit after\nit: that record alone is read again, by id, to know which.\n\nAny other feed works the same way: a WebSocket message, a server-sent event,\na poll. Call `apply` with the changes, as the database has the records\n(its column names, its ids):\n\n```ts\nimport { baseSource, type BaseChangeInput } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\ndeclare const tasksSource: ServerDataSource<Record<string, unknown>>\n\nconst source = baseSource(tasksSource, {\n realtime: (apply: (changes?: BaseChangeInput) => void) => {\n const socket = new WebSocket('wss://example.com/tasks')\n socket.onmessage = (m) => {\n const { type, id, row, changed } = JSON.parse(m.data)\n if (type === 'update' && changed) apply([{ type: 'update', id, fields: changed }])\n else if (type === 'delete') apply([{ type: 'delete', id }])\n else apply([{ type, record: row }])\n }\n return () => socket.close()\n },\n})\n```\n\n| A change | Carries |\n|---|---|\n| `{ type: 'insert', record }` | The new record, with its key column. |\n| `{ type: 'update', id, record }` | The whole record as it is now. |\n| `{ type: 'update', id, fields }` | Just the columns that changed. |\n| `{ type: 'delete', id }` | The key of the record that went. |\n\nA change that comes back from the page's own write (the database tells every\nlistener, the page that wrote it included) moves nothing and is not reported.\nAn update with `fields` for a record the page does not have, and `apply()`\nwith nothing, read the whole table again. An update with `id` alone reads that one record.\n\n### A feed on an endpoint\n\n`baseFromEndpoint` takes one `feed` for the whole base. It opens when the first table\nlistens and closes with the last. Each message names its table, a junction table\nincluded, and a change in a junction reaches the record it starts from:\n\n```ts\nimport { baseFromEndpoint } from '@svgrid/enterprise/base'\n\nconst tables = await baseFromEndpoint('/api/base', {\n feed: (apply) => {\n const events = new EventSource('/api/base/feed')\n events.onmessage = (e) => {\n // { \"table\": \"orders\", \"changes\": [{ \"type\": \"update\", \"id\": \"o1\", \"fields\": { \"status\": \"Paid\" } }] }\n const { table, changes } = JSON.parse(e.data)\n apply(table, changes)\n }\n // After a reconnect, changes may have been missed: every table reads again.\n let opened = false\n events.onopen = () => {\n if (opened) apply()\n opened = true\n }\n return () => events.close()\n },\n})\n```\n\n`apply(table)` with no changes reads that table again, and `apply()` reads every table again.\n\nKeep it to one connection. A browser opens at most six connections to one host over\nHTTP/1.1, which is what a Vite or Node dev server speaks, and a connection held open by a\nfeed is one of them. With a feed per table on a base of six tables and junctions, no write\nreaches the server. `realtime: (table, apply) => stop`, called per table, is still taken\nfor a feed that shares one connection itself, such as channels on one socket.\n\nThe feed is yours to write and yours to scope: with a tenant `scope`, send each person their\ntenant's rows only.\n\n### What a feed has to cover\n\nA feed is per table, and some of what a person changes is not in that table:\n\n- **A link to many lives in its junction table.** Adding a tag writes a row to `order_tags`\n and nothing to `orders`, so a feed of `orders` alone never tells teammates. Listen to the\n junction too, on the table that stores the link, and name the record it starts from:\n\n ```ts\n import { baseSource } from '@svgrid/enterprise/base'\n import type { ServerDataSource } from '@svgrid/grid'\n\n declare const ordersSource: ServerDataSource<Record<string, unknown>>\n declare const orderTags: ServerDataSource<Record<string, unknown>>\n // Your feed: calls back with what changed in that table, and returns how to stop.\n declare function listen(table: string, on: (change: any) => void): () => void\n\n const source = baseSource(ordersSource, {\n links: { tags: { through: orderTags, from: 'order_id', to: 'tag_id' } },\n realtime: (apply) => {\n const orders = listen('orders', (change) => apply(change))\n const pairs = listen('order_tags', (row) => apply(row?.order_id == null ? undefined : { type: 'update', id: row.order_id }))\n return () => { orders(); pairs() }\n },\n })\n ```\n\n A feed that only says \"something changed\" calls `apply()` for both. `baseFromSupabase`\n and `baseFromEndpoint` listen to the junction tables by themselves, and needs them in the `supabase_realtime`\n publication. A delete's event there has only the key unless the junction table has\n `REPLICA IDENTITY FULL`, so a removed link reads the table again.\n- **A soft delete reaches a feed as an update.** The base reads an update that sets the mark\n as a delete, so send the column. Through `createKitDataSource` the page learns the column\n from the server's first answer. A restore reads as an update of a record the page does not\n have. A page-held table takes it in, and reads the table if it has links through a junction.\n A table read a part at a time reads the rows on screen, at most once a second, because a\n feed cannot tell a restore from an edit of a record scrolled out of view.\n- **A feed that goes down says nothing.** Nothing here can tell silence from no changes.\n\n### What people see\n\nA change made elsewhere does not just appear. Until someone opens the record:\n\n- in a grid view, the cells that changed are tinted, and a record added\n elsewhere is tinted across the row (Kanban and gallery cards are not);\n- the row number has a dot; hover it for \"Ana Ruiz changed this record 2\n minutes ago\";\n- the view bar counts them, \"3 changed by Ana Ruiz\", and a click on the count\n marks them all seen.\n\nOpening the record clears its marks. Its activity lists each change as\n\"Ana Ruiz changed Priority\", with the value before crossed out and the value\nnow: Low → Urgent.\n\nThe name comes from the record itself: its `lastModifiedBy` field (for a\nrecord added elsewhere, `createdBy` first). Whoever writes to the database\nwrites their user id to that column, and the base looks it up in\n`setFieldUsers`. Without such a field the change is credited to \"Someone\nelse\". Your own writes are never reported back to you: the base compares what\nit reads with what it last wrote.\n\n### An AI agent writing to the base\n\nThe same path serves an agent: a script, a worker calling a model, or Claude\nCode with your database's MCP server. Give the agent a user id, add it to\n`setFieldUsers` with a name and an avatar, and have it set `modified_by` (or\nwhichever column your `lastModifiedBy` field reads) on every row it writes.\nPeople then see exactly what it changed, review it in a view filtered on a\n\"Needs review\" field, correct what it got wrong, and approve the rest with a\nbutton field and an automation.\n\n[Let an AI agent work in your base](./ai-agents.md) walks through it with\nClaude Code and Supabase, and [Review what an agent changed](./review-queue.md)\ncovers the review side on any database. Here the agent is a stand-in made of\nkeyword rules, so the demo runs without a model or a key. It writes to the database with SQL; press \"Run the triage\nagent\", then open a ticket.\n\n<div data-docs-demo=\"700-base-ai-triage\" data-height=\"900\"></div>\n\nTo act on changes made elsewhere in code (a notice, a log, a count of your\nown), pass `onRemoteChange` to `<SvBase>`. It gets each change once it is in\nthe page:\n\n```ts\nimport type { BaseRemoteChange } from '@svgrid/enterprise/base'\n\nfunction onRemoteChange(changes: BaseRemoteChange[]) {\n for (const c of changes) {\n // c.type: 'insert' | 'update' | 'delete'; c.table, c.id, c.record\n // c.fields (updates): [{ field: 'priority', from: 'Low', to: 'Urgent' }]\n if (c.type === 'update') console.log(c.id, c.fields)\n }\n}\n```\n\n## Status and errors\n\nThe end of the tab bar says what the base is doing:\n\n| It reads | When |\n|---|---|\n| Loading records... | The tables are loading |\n| Saving... | Writes are on their way |\n| Still saving: the server has not answered yet | A write has been waiting a while |\n| All changes saved | Every write went through |\n| Not saved: *reason* | A write was refused; the cell went back |\n\n![A refused write: the database rejects a status, the cell goes back, and the tab bar says the database does not accept this value.](/docs-media/base-refused-write.png)\n\nA table that cannot be read says so where its records would be, for as long as it lasts,\nwith why and a **Try again**. No empty table is shown for it, and nothing can be added to\nit. The other tables of the base open as usual.\n\nA table read a part at a time (`serverRows`) whose next part cannot be read says so in the\ntab bar, \"Could not load *table*: *reason*\", with **Try again**, for as long as a part of the\nview is unread, wherever it is scrolled to. The rows that did not come are a tinted band with\n\"Could not load these rows.\" and **Retry** on its first row on screen. A read again of rows\nalready on screen, after a teammate's change, that fails leaves those rows as they were: the\ntab bar says so with **Try again**, which reads them again.\n\nWhen the server sent a reason with its error (`{ \"error\": \"...\" }` and no `code`), that reason\nis what the notice says. `createRestDataSource` passes on an API's `{ \"error\" }` or\n`{ \"message\" }` the same way.\n\nA failed write is told in a notice that names the record and the field, says why in\nplain words and shows what was entered, with **Try again** where that can work. The record\nis named as it is stored, never by the value that was refused. A foreign key of more than one\nfield that refuses a write names all of its fields. The notice stays until it is dismissed,\nand \"Not saved\" stays until that record is written: a later write of another record does not\nclear it. A click, a tap or Enter on the status line opens it in full: the reason, and the\nserver's own words when it sent some and the reason does not already say them. The text of\nthe request itself (a status code, a JSON body) is never shown; it is in the browser's\nnetwork log and the server's log.\n\nA new record the database refused takes no edit while it is still listed (while another cell or\nrecord is being edited, or a draft on a table read a part at a time whose refusal no retry can\nchange, such as an id column too narrow): a click, a key or a paste on\nit shows its notice again instead of an editor. An editor open on it when the refusal comes closes\nwith what it holds, and the notice names it. A draft refused for a reason a retry may get past keeps\ntaking edits, and its next edit sends it again.\n\n**Try again** reads the record first, as an undo does. A value that changed since the\nwrite failed, whether a teammate wrote it or you typed it again, keeps that value and the\npage says so. A record deleted since is reported with what you entered. If the record\ncannot be read, nothing is written and the notice offers Try again once more.\n\nA change of many records at once (a paste, a clear or an Undo of 20 or more) that fails\nis one notice with the number of records, and the same **Try again**: it reads them all\nfirst, sends what is still as it was in blocks, and says how many cells changed since and\nhow many records were deleted since. Part of a block may have landed; the page reads the\ntable again to show which. An Undo of some of those cells takes them out of what Try\nagain would send. A refusal of your permission offers no Try again and leaves no step to\nundo, and so does a refusal of the values, an answer of `400`, `409` or `422`: the same\nvalues would be refused again.\n\nA write that gets no answer is not given up on: it may still land, or be refused. After\n`writeTimeout` (60 seconds by default, on `<SvBase>`) writes to other records go on, and\nlater writes to the same record wait behind it, so none can overtake it or be overwritten\nby it landing late. The status says \"Still saving\" for as long as it has no answer, and\nstarts warning at a sixth of `writeTimeout`. The page keeps what was entered, and goes back\nonly if the write is refused. A delete with no answer keeps its copy in the trash until the\noutcome is known, and leaving the page asks first.\n\nWhile someone is typing in a cell or in a field of a record, changes from others wait\nuntil the editor closes, so no row moves under it and no text changes under the cursor.\nThat holds for a live feed and for a read of the table, on any table. If the record was\ndeleted meanwhile, saving it says so and shows the text.\n\n## Options\n\n`baseSource(dataSource, options)`:\n\n| Option | Default | What it does |\n|---|---|---|\n| `links` | none | How link fields are stored: `{ column }` or `{ through, from, to }` |\n| `columns` | none | Column names that differ from field names: `{ dueDate: 'due_date' }` |\n| `idField` | `'id'` | The key column |\n| `serverIds` | `false` | The database makes the key of a new record |\n| `realtime` | none | Hear of changes made elsewhere: `(apply) => stop`; `apply(changes)` updates those records in place |\n| `skip` | none | Fields kept in the page only |\n| `holdInPage` | `10000` | How many records a table may hold in the page. It is where a table changes how it is read, not a cap: a bigger one is read from the database a part at a time, and no record is left out. (`limit` is the old name.) |\n| `convertField` | none | A field of a big table changed type: rewrite its values in the database and resolve with `true`. Without it the base rewrites them a block at a time. |\n| `duplicate` | none | Copy a big table in the database and resolve with the new table's source. |\n| `serverRows` | automatic | `true` always reads from the database, and the first screen comes sooner on a table you know is big; `{ blockSize }` sets the rows per request (200). `false` always holds every record in the page, however many. Left out, the base decides by `holdInPage`. |\n\n## Build a base from your database\n\n`baseTablesFromSchemas` makes the tables from your database's own\ndescription of them: a number column becomes a number field, an enum a\nsingle select with its values, a foreign key a link with a field in the\nother table that links back. Read the descriptions with\n`introspectSupabaseTable`, `introspectDatabase` or `introspectOpenApi`, or\nwrite them out:\n\n```ts\nimport { baseTablesFromSchemas } from '@svgrid/enterprise/base'\nimport { createRestDataSource, type EntitySchema } from '@svgrid/enterprise'\n\nconst schemas: EntitySchema[] = [\n {\n name: 'deals',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'title', type: 'text' },\n { field: 'stage', type: 'enum', options: [{ value: 'Open', label: 'Open' }, { value: 'Won', label: 'Won' }] },\n { field: 'company_id', type: 'relation', relation: { entity: 'companies', labelField: 'name' } },\n ],\n },\n { name: 'companies', fields: [{ field: 'id', type: 'text', primaryKey: true }, { field: 'name', type: 'text' }] },\n]\n\nconst tables = baseTablesFromSchemas(schemas, (schema) => createRestDataSource({ url: `/api/${schema.name}`, schema }))\n```\n\nThe result is ordinary `BaseTable` objects: change a field's type, add views,\nrename a table. [Build a base on your API](./rest-api.md) does this end to end.\n\nThe other way round, `baseToSql(tables)` writes a base as Postgres SQL:\ntables, foreign keys, the tables behind links to many, and the records, with\n`svgrid:` comments for the field settings, views and automations that SQL\nhas no type for. The tables it makes have text keys with a\n`gen_random_uuid()` default, so a record added later gets its key from the\ndatabase. See [Take a base to a database](./quick-start.md#take-a-base-to-a-database).\n\n## A table of millions\n\nA table has no size limit, and nothing here is a setting you have to get right.\nA table of the thousands of records a team keeps in a tracker, a CRM or an\ninventory is held in the page. One that grows past `holdInPage` is read from the\ndatabase a part at a time, the next time it is read, and looks and works the\nsame: every view, link, lookup, rollup, automation and search reads all of it.\nThe page then holds none of its records, only what is on screen.\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\ndeclare const orders: ServerDataSource<Record<string, unknown>>\n\n// Nothing to set: it reads from the database once the table outgrows the page.\nconst source = baseSource(orders)\n\n// A table you know is big: skip the first look, and size the requests.\nconst big = baseSource(orders, { serverRows: { blockSize: 200 } })\n```\n\n<div data-docs-demo=\"723-base-million-orders\" data-height=\"620\"></div>\n\nHow each part of a base reads such a table:\n\n| | Read a part at a time |\n|---|---|\n| Grid views | Read through the server row model. Each request carries the view's filter (`filterModel.expression`), its sort, its groups (one row per key with its count, the records under an opened key) and the search. The count in the view bar is the server's. A grouped view shows select groups in option order and each group as the field draws it, with the records it holds at every level, and the totals of the fields with a sum, average, lowest or highest picked in the footer. Whenever the view is read again (your delete, Restore, Undo or Redo, a new record, an edit once you leave the record, an option renamed, a field converted, a teammate's change), the group rows and the loaded records of every open group are read, with or without a feed: a deleted record leaves its group, a restored or new one shows in its group, and the counts follow. A group closed at the time reads again when it is opened. A teammate's change that a feed sends with its row patches that row where it is; when it changes a field the view groups or sorts by (any field, when the view groups or sorts by a formula or lookup), the view is read again at once, so the record takes its place in the order and in its group. A filtered view reads again within a second after any change, so a record that left the filter goes. |\n| Kanban | Each lane shows its true size, from one grouped request, and reads its cards as they scroll into sight. A card moved to another lane is written by id and sits at the top of that lane until the lane is read again. Sorted by a number field, dropping a card elsewhere in its lane writes that number, so the order is the table's. |\n| Calendar | Reads the dates on screen and no others. A range of up to 400 records is read whole. A busier one is read a day at a time: each day's first records and its size, from one grouped request where the backend groups and the view has no end date, so an empty day costs nothing and a write reads only the days whose size moved. \"+N more\" lists every record of that day. The days are the viewer's: on a column of moments (Postgres `timestamptz`, SQL Server `datetimeoffset`) the sizes, each day's records and that list follow the page's zone, also across a change of the clocks. A date and a wall clock (`timestamp`, `datetime`, a MySQL `TIMESTAMP`, which reads as the server's clock) show the same everywhere, and their days follow what the cell shows. |\n| Gantt | Rows by start date, read as they scroll into sight. The axis runs from the table's first start to its last end. Dependency arrows and rescheduling reach the rows read so far. |\n| Gallery, list, inbox | Only the records in sight are drawn and read. A grouped list shows each group's size and reads its records when opened. |\n| Chart, dashboard | The server groups and adds up, over every record. A date axis is read a month at a time, in the viewer's months on a column of moments: one grouped request for each part of the records' span with one UTC offset, two a year in a zone with summer time. The records behind a tile show the first 200 and how many there are. |\n| Form | Stores its record through the source, and reads nothing. |\n| Links | A link cell reads the records it names by id, for the cells on screen, in one request. The picker searches the whole table, and a name pasted into the cell is found there. A link edits from either side: on the side that holds no list (a customer's orders), each tick changes that order. |\n| Lookups, rollups and counts | Read the linked records by id. Over a link stored on the big table (a customer's orders), the server counts and adds up: one grouped request a screen, whatever the size. |\n| Search across tables | Each big table searches on the server, and says how many match. |\n| Find in a grid | The search box filters on the server: a find bar could only mark the rows loaded. |\n| Automations | Run on any record, read by id. A scheduled one runs on every matching record, block by block. |\n| Share links | Show the whole table, without the fields the share leaves out. |\n| Autonumber | The next number is the table's largest plus one. Two people can reach it together, so each record is checked once stored: of any two holding a number the later one takes the next, and a column with a UNIQUE constraint refuses the second and the write tries again. Numbers can skip. A number a person deleted in this page is not given out again while it stays open, so an undo finds its number free. After a reload, or on a teammate's page, the number of a deleted record can be given out again, since the next one follows the largest left. A restored record whose number was given out meanwhile takes the next one. |\n| Changing a field's type | Asks first, with the number of records. Then `convertField` does it in one statement (`createSqlDataSource` with `schemaChanges: true` has one on Postgres), or the base reads a block at a time and writes the records whose value changes, sixteen at a time. The other choice changes the field only. |\n| Download as SQL | Writes every record, a block at a time, so the file can be larger than the page could hold. |\n| Duplicate table | Copies in the database with the `duplicate` option (`schemaChanges: true` gives a Postgres source one). Without it the records are read into the page a block at a time, with the count in the tab bar, and the copy lives in the page, so a very large table needs the option. |\n| Edits | Written by id: a change to the 900,000th record is one `update`. |\n| Edit fields | On a selection, in a dialog with progress and Stop. The selection is read first, and only records whose value changes are written, a block of 1,000 at a time. Past 10,000 records it asks first, with the exact number, because Undo cannot take that many back. Stop ends it after the block under way. A block that fails ends it too: the page reads that block back, says how many records changed, and Undo takes those back. Records that landed past 10,000 stay changed. |\n| A range of cells | Paste, one value pasted over a range, Delete, the fill handle and Ctrl+Enter reach every record the selection covers, loaded or not. Up to 200 cells of rows the grid holds are written at once, cell by cell. Anything larger, or reaching rows not loaded, runs in the Edit fields dialog: the records are read in view order, then written a block of 1,000 at a time (200 on a source that writes a request a record, such as Supabase, so the count moves and Stop answers within a block), with the same progress, Stop, count at the end, question past 10,000 and one Undo step. A block the database refuses part way ends the job: the count says how many records changed, and Undo takes those back. If records moved while the range was read (a teammate's edit changed the order or the set of a sorted view), nothing is written or copied: the page says, for a paste, \"Records moved while this was read. Nothing was changed. Try again pastes from \"Acme\" down over the rows as they are now.\", naming the first record selected. Try again finds that record by its id where the list has it at the click, goes from it over as many rows below it as before, and selects those rows first, so the screen shows what it writes; its dialog lies over them, so it names them too (\"From \"Acme\" down over 2,500 rows, selected in the view.\"). If the record is gone or no longer among the rows shown, it writes nothing and says so, and so it does when fewer rows stand below the record now than the first try covered (the record fell to the end of a sorted view): it never turns lines into new records the first try wrote over records that were there. To tell that records moved, the whole id sequence is checked, in requests that ask for ids alone: a range longer than a block reads its ids first and each block must bring the same ids in the same places, each block also reads the last record of the one before again, a record read twice counts as moved, and once the last block is in, the ids of the whole range are read again and must be the very ids read, in the same order. Each of those reads asks for the whole range at once (up to 20,000 ids); a server that caps an answer (PostgREST's `db-max-rows`, 1,000 on Supabase) is read on from where its answer ended, a page of its own size at a time, and only a different id sequence, or a list that ends before the range does, counts as moved. On Supabase and PostgREST these reads select the key alone. Any difference counts, a move inside the part already read too. Try again acts only in the view the cells were chosen in, as it was then: after a switch to another view, or a change of its sort, filter, groups, open groups or shown fields, it writes nothing and says \"That view is no longer open, so nothing was changed.\" or \"The view has changed since, so nothing was changed.\" An answer to a question the job asked (past 10,000 records, new records past the last row, a delete) does the same. A new record that is not stored yet sits on top of the list and in no block of the table: a range over it leaves it out and says how many it left, a paste keeps its line for it, and a copy has its line. A drag of a range over rows not loaded is refused, with the number. A paste while the view is still loading is refused too, and never makes a record. |\n| Copy | Rows not loaded are read first, in a dialog with progress and Cancel, each line a real record with its worked out fields. A copy holds up to 2,000,000 cells: that many, 20 MB of text, took 4.6 s with a longest frame of 450 ms in Chrome on a production build, reading from the page. Past that nothing is copied, the page says how many cells were asked for, and Download gets all of it. If a browser will not take the text so long after the key press, the dialog asks for one more click. |\n| A paste past the last row | A line where no value fits its field makes no record. Up to 10 new records are added at once; past 10 the page asks first, with the number. They go in blocks of 1,000 (`createRows` makes a block one statement), and one Undo takes them out the same way, with the cells the paste wrote. A record someone has worked on since stays, and the page says so. |\n| \"+\" | In every view of records. It opens a new record, filled in from the view's filter (Region is EU in a view of EU orders). Nothing is stored until it holds a value, and one closed empty is gone. If the database refuses it, it stays in the grid with its values and the next edit tries again. What the database fills in, such as an order number, comes back into the record. Ctrl+Z takes a stored record out again. |\n| Insert record, Duplicate | Insert opens a draft, as \"+\" does. Duplicate stores the copy and shows it at the top of the grid. |\n| A new field | The \"+\" at the right of the header row, for whoever may change the schema (`columnAdder={false}` hides it). `createSqlDataSource` with `schemaChanges: true` adds the column on Postgres, MySQL and SQLite. A new field starts empty, or with its default: on a table held in the page the base writes the default to every record; on a table read a part at a time `addField` gets it as `default`, to fill the stored records (the one `createSqlDataSource` makes does not yet). When a column by that name is already in the table it takes the next free name, and says so. A column that cannot be added takes the field back. A source that cannot add one, such as Supabase, shows the `ALTER TABLE` to run, and `addField` on `baseSource` is your own way to make it. There, Duplicate field copies nothing: it shows the statement for the copy's column, to run before duplicating. An Autonumber or Created time field stays blank on the records already there. |\n| Delete | By id, to the trash, as the database holds the record at that moment; Ctrl+Z puts it back whole, columns the base shows no field for included, under the key it had, on a table the page holds and on a big one alike. A column off the source's schema never reaches the page, so it takes its default, unless the source reads whole records (`wholeRecords` on `createSqlDataSource`). The record stays in the trash until the database has it. What only the database may write stays the database's: a generated column works itself out again, and a `GENERATED ALWAYS` key gets a new value. Time columns go back as the database wrote them, past the millisecond and at a local time the clocks skipped, on Postgres and MySQL with any driver. A record the database refuses to delete stays in the table and out of the trash, and so does one a row-level policy skipped without an error: after a delete the base looks. |\n| Soft delete | `softDelete: 'deleted_at'` marks a record instead of removing it, and a restore clears the mark, so nothing is rewritten. See [Undo, trash and import](./undo-trash-import.md#soft-delete). |\n| Select all | Selects every record of the view, read or not, and the count says so; a group's tick selects all of the group. A new filter clears the selection. With `selectionBar={{ actions: ['deleteRows'] }}` (and `enableSelectionBar()`), Delete first reads what the selection covers, then asks with the exact number. The records go a block at a time, with a Stop button: what went before you stopped stays gone and stays restorable. `deleteRows` and `createRows` on your data source make a block one statement. Up to 10,000 go to the trash and can be undone; above that the question says they cannot be restored. A group that reads back a different size from its group row stops the job with nothing deleted, since what was left out of the selection could not be told apart. A record that leaves the view after you confirm is still deleted, since you confirmed that set. |\n| Changes made elsewhere | `apply(changes)` updates those rows in the grid, highlighted and credited, whether the page holds them or not. |\n| Formulas | Worked out in the page for the rows on screen. |\n\nAll of this is `getRows` with what a grid view already sends: a range, the\nview's filter, a sort, `groupBy` and `groupKeys`, an `in` list on the key\n(`filterModel.columns.id.selectedValues`), and for a chart or a total\n`aggregations` and `needsGrandTotal`. Grouping a link for a count from its other\nside sets `groupRawKeys`: group by the linked id, which a foreign key does. A calendar's\n`groupDays` and a chart's `groupMonths` ask for a date level by day (`2026-03-14`) or month\n(`2026-03`), on a column of moments in the zone `dayOffset` minutes ahead of UTC. A source that passes over them answers by value and the page adds the groups\nup, which on a time field is a group a record. The data source applies the view's filter\nand acknowledges it with `appliedExpression: true`. The\nSupabase, REST and SQL sources already answer all of these, and\n`createSqlDataSource` also runs a view's filter, sort, groups and totals on a\nformula, lookup or rollup in the database\n([computed fields in SQL](./server-compute.md#computed-fields-in-sql)). On your own\nsource, index the fields views group and place records by: a busy calendar\nmonth is a request per day.\n\n### Index what views sort on\n\nA sort on a column with no index sorts the table again for every block a person\nscrolls to, and that is what limits how many people a big table serves. Give each\nfield a view sorts on an index with the table's key after it:\n\n```sql\nCREATE INDEX orders_amount ON orders (amount, id);\n```\n\nThe key is there because a read breaks ties on it, in the sort's direction\n(`ORDER BY amount DESC, id DESC`). Leave both columns ascending, as above: one index\nthen serves a sort either way. `(amount DESC, id)` matches neither direction, and on\nMySQL it goes unused.\n\nThrough `createBaseEndpoint` on a table of 1,000,000 records, sorted on a numeric\ncolumn, blocks of 100, default database settings, on a shared development machine:\n\n| Median time for a block | No index | With the index |\n|---|---|---|\n| Postgres, one person | 2,263 ms | 567 ms |\n| MySQL, one person | 2,476 ms | 42 ms |\n| Postgres, 30 people at once | 23,576 ms | 2,118 ms |\n| MySQL, 30 people at once | 22,968 ms | 713 ms |\n\nA formula or a lookup has no column to index: a sort on one costs a sort of the\ntable for every block, so a view with many people on it is better sorted on a stored\nfield. A filter narrows what is sorted, and an index that starts with the filtered\nfield and ends with the sorted one serves both.\n\n### What the database cannot run\n\nA view never goes unanswered. When a filter, sort, group or total needs a field\nthe data source cannot compute, or the source does not acknowledge a filter, or\nit fails on a computed field, the page reads the table a block at a time, works\nthe field out with the same code the cells use, and keeps the ids and the values\nthe request needs. The view then reads its records by id. The tab bar shows how\nfar it has got.\n\nIt gives what the cells say, on any backend, and it is slower than the database:\nabout a minute for a lookup over the 1,000,000 records of the demo on a dev\nserver. It is read once. Scrolling, sorting again and the lanes of a board cost\nnothing more, a record you or someone else changes is updated where it stands,\nand changing a field reads again. Taking the sort or filter away stops the read.\nRecords changing while it reads are read again once, and if the count still moves\nthe base says so.\n\nTell the base what your source can work out with `computes`, and that field stays\nin the database. Without it, only `createSqlDataSource` is asked: a `queryRecords`\nbackend needs `computes: () => true` or it is right but slow.\n\n```ts\nimport { baseSource } from '@svgrid/enterprise/base'\nimport type { ServerDataSource } from '@svgrid/grid'\n\ndeclare const orders: ServerDataSource<Record<string, unknown>>\n\nconst source = baseSource(orders, { computes: (def) => def.field === 'tax' })\n```\n\n`@svgrid/enterprise/base/compute` has both halves:\n[`queryRecords`](./server-compute.md#answer-a-paged-table) for records a\nserver holds, and [`fieldFilterToSql`](./server-compute.md#the-views-filter-in-sql)\nfor a database.\n"
5203
5203
  },
5204
5204
  {
5205
5205
  "slug": "help/base/forms",
@@ -5234,7 +5234,7 @@ export const docs = [
5234
5234
  "path": "docs/help/base/permissions.md",
5235
5235
  "title": "Permissions: what each person may do",
5236
5236
  "section": "SvGrid Base",
5237
- "markdown": "# Permissions: what each person may do\n\nYour app already knows its roles: who is an editor, who only comments, who\nsees the margin column. `permissions` hands that to the base, and the screen\noffers only what the signed-in person may do. A commenter gets no \"+\" row and\nno Delete in the record menu; a sales rep never sees the Cost field, or the\nformula that reads it.\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, setCurrentUser, type BaseTable, type BasePermissions } from '@svgrid/enterprise/base'\n\n enableBase()\n let { data } = $props()\n setCurrentUser(data.user)\n\n let tables = $state<BaseTable[]>(data.tables)\n // From your server: the role of the person signed in.\n const permissions: BasePermissions =\n data.user.role === 'editor'\n ? { canEditSchema: false }\n : { canCreate: false, canDelete: false, canEditSchema: false, canEditViews: false, fields: { 'deals.cost': 'hidden' } }\n</script>\n\n<SvBase bind:tables {permissions} editable fieldMenu columnAdder expandRows />\n```\n\nEverything is allowed by default. Each key turns one thing off:\n\n| Permission | Off means |\n|---|---|\n| `canEdit` | No cell, record view, card drag or date drag changes a value. Adding and deleting records are off too. |\n| `canCreate` | No \"+\" row, no group \"+\", no Insert record above or below, no Duplicate record, no \"+\" on board lanes or calendar days, no form views, no \"Import records from a file\". |\n| `canDelete` | No Delete record in the row and card menus, no Delete in the selection bar, no trash button. |\n| `canEditSchema` | No field editor or \"+\" field column, no Add, Rename, Duplicate or Delete table, no \"Import a file as a table\", no Automations button, no SQL export. The field menu keeps Filter, Group, Hide and Color by. |\n| `canEditViews` | No Create, Rename, Duplicate, Delete, Lock or Unlock on shared views. Filters, sorts and groups the person changes stay in their page; they may still make personal views, which are saved. |\n| `canComment` | Comments are read, not written: no comment box, no Comment in the menus. |\n| `fields` | Per field: `'hidden'` or `'readOnly'`. A key is a column id (in every table) or `tableId.columnId`. |\n| `viewsOnly` | Only these views (a view id, or `tableId.viewId`). Tables with none of them are not shown, the field editor is off, and view changes stay in the page. |\n\n## A table's own permissions\n\n`BaseTable.permissions` wins over the base's, key by key, and its `fields`\nare merged over the base's `fields`:\n\n```ts\nconst tables: BaseTable[] = [\n // Everyone may add deals; only the base's permissions decide the rest.\n { id: 'deals', name: 'Deals', columns, data, permissions: { canCreate: true } },\n // The price list is read-only for the person signed in.\n { id: 'prices', name: 'Prices', columns: priceColumns, data: prices, permissions: { canEdit: false } },\n]\n```\n\n## Hidden fields\n\nA hidden field leaves the grid, the record view, cards, search and lookups\nfrom other tables. So does every field that would show what it holds:\n\n- a formula that reads it (`{Amount} - {Cost}` goes with Cost),\n- a lookup or rollup of it in another table,\n- a link to a table the person cannot see, and the lookups that read that link.\n\nThe records keep the values. When the person edits a field, the stored record\nis the same object with Cost still in it, so the database never sees Cost\ncleared. A field change in the field editor comes back with the hidden fields\nin their places, and the columns your app stores never take the\n`editable: false` the screen uses for read-only fields.\n\nHiding is for display. A page that loads the whole table has the values in\nmemory, and a person with the browser's developer tools can read them. For a\nfield that is secret, leave it out of what your server sends, as\n`sharedTables` does for a [read-only share](./collaboration.md#share-a-base-read-only).\n\n## Views a person may change\n\nWithout `canEditViews` the views menu shows \"Create a personal view\" and\nRename, Duplicate and Delete only on the person's own personal views (those\nneed `setCurrentUser`). A filter or sort they set on a shared view shows in\ntheir page and is not saved; `onTablesChange` hands your app the views as\nstored, with their personal views added.\n\nA locked view keeps its settings for everyone. With `canEditViews`, a person\nmay unlock it; without it, they may not.\n\n## A narrow window: `viewsOnly`\n\nA support agent who needs the \"Open tickets\" view and nothing else:\n\n```svelte\n<SvBase bind:tables permissions={{ viewsOnly: ['tickets.open'], canDelete: false }} editable expandRows />\n```\n\nThey see the Tickets tab with one view, edit records in it, and nothing else\nof the base. Their filter and sort changes stay in their page.\n\n## One table\n\nWith `data` and `columns` instead of `tables`, `permissions` works the same.\n`onColumnAdd`, `onColumnChange` and `onColumnRemove` hand your app the\ncolumns as you declared them, hidden fields included.\n\n## In code\n\n```ts\nimport { permittedRecords, tablePermissions, gridPermissions } from '@svgrid/enterprise/base'\n\n// The tables as one person sees them, the hidden fields' values gone from the\n// records: on your server, to send only those.\nconst shown = permittedRecords(tables, permissions)\n\n// Every permission decided for a table (defaults filled in).\ntablePermissions({ canEdit: false }) // { canEdit: false, canCreate: false, canDelete: false, ... }\n\n// What the person may do in a grid of the base: for your own buttons and cells.\nif (gridPermissions(ctrl).canDelete) showDeleteButton()\n```\n\n`permittedTables` gives the same tables with the records as they were, hidden\nvalues included, for code in the page that writes them back. Do not send its\nresult to anyone.\n\n`<sv-base>` takes the same object as its `permissions` property or as JSON in\nthe `permissions` attribute; see [`<sv-base>`](../web-components/sv-base.md).\n\n## Pitfalls\n\n- **The browser follows these; your server decides.** A base on a database\n still needs the API or row-level security to refuse a delete from a role\n that may not delete. The screen not offering it is not the same as the\n server refusing it.\n- **`canCreate` and `canDelete` need `canEdit`.** A person who may not change\n values cannot add or delete records either.\n- **`readOnly` wins.** A base shown with `readOnly` (a share link) is read-only\n whatever `permissions` says.\n- **`fields` keys are column ids.** A field's header can change; its id\n does not. Use `tableId.columnId` when two tables have a field with the same id.\n\n## Next\n\n- [People, comments and files](./collaboration.md): who is signed in, protected\n fields, a read-only share.\n- [Views](./views.md): personal and locked views.\n- [Formulas on a server](./server-compute.md): the values people see, worked\n out in Node for an API or an AI tool.\n"
5237
+ "markdown": "# Permissions: what each person may do\n\nYour app already knows its roles: who is an editor, who only comments, who\nsees the margin column. `permissions` hands that to the base, and the screen\noffers only what the signed-in person may do. A commenter gets no \"+\" row and\nno Delete in the record menu; a sales rep never sees the Cost field, or the\nformula that reads it.\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, setCurrentUser, type BaseTable, type BasePermissions } from '@svgrid/enterprise/base'\n\n enableBase()\n let { data } = $props()\n setCurrentUser(data.user)\n\n let tables = $state<BaseTable[]>(data.tables)\n // From your server: the role of the person signed in.\n const permissions: BasePermissions =\n data.user.role === 'editor'\n ? { canEditSchema: false }\n : { canCreate: false, canDelete: false, canEditSchema: false, canEditViews: false, fields: { 'deals.cost': 'hidden' } }\n</script>\n\n<SvBase bind:tables {permissions} editable fieldMenu columnAdder expandRows />\n```\n\nEverything is allowed by default. Each key turns one thing off:\n\n| Permission | Off means |\n|---|---|\n| `canEdit` | No cell, record view, card drag or date drag changes a value. Adding and deleting records are off too. |\n| `canCreate` | No \"+\" row, no group \"+\", no Insert record above or below, no Duplicate record, no \"+\" on board lanes or calendar days, no form views, no \"Import records from a file\". |\n| `canDelete` | No Delete record in the row and card menus, no Delete in the selection bar, no trash button. |\n| `canEditSchema` | No field editor or \"+\" field column, no Add, Rename, Duplicate or Delete table, no \"Import a file as a table\", no Automations button, no SQL export. The field menu keeps Filter, Group, Hide and Color by. |\n| `canEditViews` | No Create, Rename, Duplicate, Delete, Lock or Unlock on shared views. Filters, sorts and groups the person changes stay in their page; they may still make personal views, which are saved. |\n| `canComment` | Comments are read, not written: no comment box, no Comment in the menus. |\n| `fields` | Per field: `'hidden'` or `'readOnly'`. A key is a column id (in every table) or `tableId.columnId`. |\n| `viewsOnly` | Only these views (a view id, or `tableId.viewId`). Tables with none of them are not shown, the field editor is off, and view changes stay in the page. |\n\n## A table's own permissions\n\n`BaseTable.permissions` wins over the base's, key by key, and its `fields`\nare merged over the base's `fields`:\n\n```ts\nconst tables: BaseTable[] = [\n // Everyone may add deals; only the base's permissions decide the rest.\n { id: 'deals', name: 'Deals', columns, data, permissions: { canCreate: true } },\n // The price list is read-only for the person signed in.\n { id: 'prices', name: 'Prices', columns: priceColumns, data: prices, permissions: { canEdit: false } },\n]\n```\n\n## Hidden fields\n\nA hidden field leaves the grid, the record view, cards, search and lookups\nfrom other tables. So does every field that would show what it holds:\n\n- a formula that reads it (`{Amount} - {Cost}` goes with Cost),\n- a lookup or rollup of it in another table,\n- a link to a table the person cannot see, and the lookups that read that link.\n\nThe records keep the values. When the person edits a field, the stored record\nis the same object with Cost still in it, so the database never sees Cost\ncleared. A field change in the field editor comes back with the hidden fields\nin their places, and the columns your app stores never take the\n`editable: false` the screen uses for read-only fields.\n\nHiding is for display. A page that loads the whole table has the values in\nmemory, and a person with the browser's developer tools can read them. For a\nfield that is secret, leave it out of what your server sends, as\n`sharedTables` does for a [read-only share](./collaboration.md#share-a-base-read-only).\n\n## Views a person may change\n\nWithout `canEditViews` the views menu shows \"Create a personal view\" and\nRename, Duplicate and Delete only on the person's own personal views (those\nneed `setCurrentUser`). A filter or sort they set on a shared view shows in\ntheir page and is not saved; `onTablesChange` hands your app the views as\nstored, with their personal views added.\n\nA locked view keeps its settings for everyone. With `canEditViews`, a person\nmay unlock it; without it, they may not.\n\n## A narrow window: `viewsOnly`\n\nA support agent who needs the \"Open tickets\" view and nothing else:\n\n```svelte\n<SvBase bind:tables permissions={{ viewsOnly: ['tickets.open'], canDelete: false }} editable expandRows />\n```\n\nThey see the Tickets tab with one view, edit records in it, and nothing else\nof the base. Their filter and sort changes stay in their page.\n\n## A view as a page of an app: `chrome=\"page\"`\n\nFor an app built on the base, where each page is one view (an interface, a\nportal), drop the base's own chrome:\n\n```svelte\n<SvBase bind:tables chrome=\"page\" activeTable=\"tickets\" permissions={{ viewsOnly: ['tickets.open'], canEditSchema: false }} editable />\n```\n\n`chrome=\"page\"` shows the view alone: no table tabs, no views menu. The rest\nof the view bar stays (fields, filter, sort, group, search), so people still\nnarrow what they see; with `canEditViews: false` that stays in their page,\nand a dashboard offers no \"Edit dashboard\". The default, `chrome=\"base\"`, is\nthe base as it always was.\n\n## One table\n\nWith `data` and `columns` instead of `tables`, `permissions` works the same.\n`onColumnAdd`, `onColumnChange` and `onColumnRemove` hand your app the\ncolumns as you declared them, hidden fields included.\n\n## In code\n\n```ts\nimport { permittedRecords, tablePermissions, gridPermissions } from '@svgrid/enterprise/base'\n\n// The tables as one person sees them, the hidden fields' values gone from the\n// records: on your server, to send only those.\nconst shown = permittedRecords(tables, permissions)\n\n// Every permission decided for a table (defaults filled in).\ntablePermissions({ canEdit: false }) // { canEdit: false, canCreate: false, canDelete: false, ... }\n\n// What the person may do in a grid of the base: for your own buttons and cells.\nif (gridPermissions(ctrl).canDelete) showDeleteButton()\n```\n\n`permittedTables` gives the same tables with the records as they were, hidden\nvalues included, for code in the page that writes them back. Do not send its\nresult to anyone.\n\n`<sv-base>` takes the same object as its `permissions` property or as JSON in\nthe `permissions` attribute; see [`<sv-base>`](../web-components/sv-base.md).\n\n## Pitfalls\n\n- **The browser follows these; your server decides.** A base on a database\n still needs the API or row-level security to refuse a delete from a role\n that may not delete. The screen not offering it is not the same as the\n server refusing it.\n- **`canCreate` and `canDelete` need `canEdit`.** A person who may not change\n values cannot add or delete records either.\n- **`readOnly` wins.** A base shown with `readOnly` (a share link) is read-only\n whatever `permissions` says.\n- **`fields` keys are column ids.** A field's header can change; its id\n does not. Use `tableId.columnId` when two tables have a field with the same id.\n\n## Next\n\n- [People, comments and files](./collaboration.md): who is signed in, protected\n fields, a read-only share.\n- [Views](./views.md): personal and locked views.\n- [Formulas on a server](./server-compute.md): the values people see, worked\n out in Node for an API or an AI tool.\n"
5238
5238
  },
5239
5239
  {
5240
5240
  "slug": "help/base/postgres",
@@ -5255,7 +5255,7 @@ export const docs = [
5255
5255
  "path": "docs/help/base/rest-api.md",
5256
5256
  "title": "Build a base on your API",
5257
5257
  "section": "SvGrid Base",
5258
- "markdown": "# Build a base on your API\n\nWhen your data sits behind an API you already have, a base can use it as it\nis: it reads a table with one `GET`, and writes each change with `POST`,\n`PATCH` or `DELETE`. This tutorial builds a small CRM, Deals, Companies and\nContacts, from the API's own description of its tables.\n\n<div data-docs-demo=\"518-base-rest-api\" data-height=\"720\"></div>\n\n![A CRM base over a JSON API. Under the base, the request log: a PATCH of a deal answered with 422 and the reason, and the GET of each table when the base opened.](/docs-media/base-rest-api.png)\n\n## 1. What the API answers\n\nFor each table, four routes. The shapes below are the defaults; the next\nsection shows how to read others.\n\n| Request | Answer |\n|---|---|\n| `GET /api/deals?offset=0&limit=10000` | `200` with `{ \"rows\": [...], \"rowCount\": 5 }`, or a plain array |\n| `POST /api/deals` with the new record | `201` with the record as stored, its `id` included |\n| `PATCH /api/deals/d3` with the changed fields only | `200` with the record as stored |\n| `DELETE /api/deals/d3` | `204` |\n\nA foreign key is a plain field: a deal has `company_id`. To refuse a write,\nanswer with a `4xx` status and `{ \"error\": \"Amount must be 0 or more\" }`\n(or `{ \"message\": ... }`); the base puts the cell back and shows that sentence. A\n`400`, `409` or `422` is a refusal of the values, so it offers no Try again.\n\n## 2. Read another shape\n\n`createRestDataSource` takes `buildQuery` (the query string for a read) and\n`parse` (the rows and count from the answer). For an API that pages with\n`page` and `per_page` and answers `{ \"data\": [...], \"meta\": { \"total\": 5 } }`:\n\n```ts\nimport { createRestDataSource } from '@svgrid/enterprise'\n\nconst deals = createRestDataSource({\n url: 'https://api.example.com/v2/deals',\n headers: () => ({ authorization: `Bearer ${localStorage.getItem('token') ?? ''}` }),\n buildQuery: (request) => ({ page: '1', per_page: String(request.endRow - request.startRow) }),\n parse: (body) => {\n const b = body as { data: Record<string, unknown>[]; meta: { total: number } }\n return { rows: b.data, rowCount: b.meta.total }\n },\n})\n```\n\n`offsetLimitAdapter`, `jsonServerAdapter` and `dummyJsonAdapter` are\nready-made pairs for common shapes.\n\n## 3. Describe the tables\n\n`baseTablesFromSchemas` makes base tables from a description of each table:\nits columns and their types. Write the description out, or read it from an\nOpenAPI document with `introspectOpenApi(spec).entities`:\n\n```ts\n// src/lib/crm.ts\nimport { baseTablesFromSchemas, type BaseTable } from '@svgrid/enterprise/base'\nimport { createRestDataSource, type EntitySchema } from '@svgrid/enterprise'\n\nconst STAGES = ['Qualified', 'Proposal', 'Negotiation', 'Won', 'Lost'].map((value) => ({ value, label: value }))\n\nconst SCHEMAS: EntitySchema[] = [\n {\n name: 'deals',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'title', type: 'text' },\n { field: 'stage', type: 'enum', options: STAGES },\n { field: 'amount', type: 'number' },\n { field: 'close_date', type: 'date', label: 'Close date' },\n { field: 'company_id', type: 'relation', relation: { entity: 'companies', labelField: 'name' } },\n ],\n },\n {\n name: 'companies',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'name', type: 'text' },\n { field: 'website', type: 'text', format: 'url' },\n ],\n },\n {\n name: 'contacts',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'name', type: 'text' },\n { field: 'email', type: 'text', format: 'email' },\n { field: 'company_id', type: 'relation', relation: { entity: 'companies', labelField: 'name' } },\n ],\n },\n]\n\nexport function crmTables(): BaseTable[] {\n return baseTablesFromSchemas(\n SCHEMAS,\n (schema) => createRestDataSource({ url: `/api/${schema.name}`, schema }),\n // The API picks the id of a new record.\n () => ({ serverIds: true }),\n )\n}\n```\n\nWhat comes out:\n\n| In the description | In the base |\n|---|---|\n| `text`, with `format: 'url'` or `'email'` | Text, URL or Email field |\n| `number` | Number field |\n| `date`, `datetime` | Date field, with the time for `datetime` |\n| `enum` with options | Single select with those options |\n| `boolean` | Checkbox |\n| `relation` (`company_id`) | A Company link, stored as `company_id`, and a field in Companies that links back |\n| The primary key | The record's id, not a field |\n\nThe first text field is each table's primary field. Companies gets a Deals\nfield and a Contacts field that link back; they are worked out in the page\nand never sent to the API.\n\n## 4. Adjust the fields\n\nThe tables are plain objects. Show Amount as currency with a total, and give\nDeals a Kanban view by stage:\n\n```ts\nimport type { BaseTable } from '@svgrid/enterprise/base'\nimport { crmTables } from '$lib/crm'\n\nconst tables: BaseTable[] = crmTables().map((t) =>\n t.id !== 'deals'\n ? t\n : {\n ...t,\n columns: t.columns.map((c) =>\n c.field === 'amount' ? { ...c, fieldProps: { format: 'currency', symbol: '$', precision: 0, summary: 'sum' } } : c,\n ),\n views: [\n { id: 'grid', name: 'All deals', type: 'grid', color: { mode: 'field', field: 'stage' } },\n { id: 'pipeline', name: 'Pipeline', type: 'kanban', stackBy: 'stage' },\n ],\n },\n)\n```\n\n## 5. The page\n\n```svelte\n<script lang=\"ts\">\n import { SvToaster } from '@svgrid/grid'\n import { SvBase, enableBase } from '@svgrid/enterprise/base'\n import { crmTables } from '$lib/crm'\n\n enableBase()\n let tables = $state.raw(crmTables())\n</script>\n\n<div style=\"height: 640px\">\n <SvBase bind:tables editable sortable summary containerHeight=\"100%\" />\n</div>\n<SvToaster />\n```\n\nOpen it and the base makes one `GET` per table. Change a stage and it sends\n`PATCH /api/deals/d3` with `{ \"stage\": \"Won\" }`. Link a contact to a company\nfrom the Companies tab and it sends `PATCH /api/contacts/p2` with\n`{ \"company_id\": \"c1\" }`.\n\n## Next\n\n- [Keep a base in a database](./data.md): links, record ids, changes made\n elsewhere and every option.\n- [Build a base on Supabase](./supabase.md) and\n [on Postgres](./postgres.md).\n"
5258
+ "markdown": "# Build a base on your API\n\nWhen your data sits behind an API you already have, a base can use it as it\nis: it reads a table with one `GET`, and writes each change with `POST`,\n`PATCH` or `DELETE`. This tutorial builds a small CRM, Deals, Companies and\nContacts, from the API's own description of its tables.\n\n<div data-docs-demo=\"518-base-rest-api\" data-height=\"720\"></div>\n\n![A CRM base over a JSON API. Under the base, the request log: a PATCH of a deal answered with 422 and the reason, and the GET of each table when the base opened.](/docs-media/base-rest-api.png)\n\n## 1. What the API answers\n\nFor each table, four routes. The shapes below are the defaults; the next\nsection shows how to read others.\n\n| Request | Answer |\n|---|---|\n| `GET /api/deals?offset=0&limit=10000` | `200` with `{ \"rows\": [...], \"rowCount\": 5 }`, or a plain array |\n| `POST /api/deals` with the new record | `201` with the record as stored, its `id` included |\n| `PATCH /api/deals/d3` with the changed fields only | `200` with the record as stored |\n| `DELETE /api/deals/d3` | `204` |\n\nA view with an advanced filter (conditions in and/or groups) adds `filter`,\nthe filter as JSON. Apply it in full and answer `\"appliedExpression\": true`\nwith the rows; otherwise leave that out, and the base knows the filter did\nnot run on the server.\n\nA foreign key is a plain field: a deal has `company_id`. To refuse a write,\nanswer with a `4xx` status and `{ \"error\": \"Amount must be 0 or more\" }`\n(or `{ \"message\": ... }`); the base puts the cell back and shows that sentence. A\n`400`, `409` or `422` is a refusal of the values, so it offers no Try again.\n\n## 2. Read another shape\n\n`createRestDataSource` takes `buildQuery` (the query string for a read) and\n`parse` (the rows and count from the answer). For an API that pages with\n`page` and `per_page` and answers `{ \"data\": [...], \"meta\": { \"total\": 5 } }`:\n\n```ts\nimport { createRestDataSource } from '@svgrid/enterprise'\n\nconst deals = createRestDataSource({\n url: 'https://api.example.com/v2/deals',\n headers: () => ({ authorization: `Bearer ${localStorage.getItem('token') ?? ''}` }),\n buildQuery: (request) => ({ page: '1', per_page: String(request.endRow - request.startRow) }),\n parse: (body) => {\n const b = body as { data: Record<string, unknown>[]; meta: { total: number } }\n return { rows: b.data, rowCount: b.meta.total }\n },\n})\n```\n\n`offsetLimitAdapter`, `jsonServerAdapter` and `dummyJsonAdapter` are\nready-made pairs for common shapes.\n\n## 3. Describe the tables\n\n`baseTablesFromSchemas` makes base tables from a description of each table:\nits columns and their types. Write the description out, or read it from an\nOpenAPI document with `introspectOpenApi(spec).entities`:\n\n```ts\n// src/lib/crm.ts\nimport { baseTablesFromSchemas, type BaseTable } from '@svgrid/enterprise/base'\nimport { createRestDataSource, type EntitySchema } from '@svgrid/enterprise'\n\nconst STAGES = ['Qualified', 'Proposal', 'Negotiation', 'Won', 'Lost'].map((value) => ({ value, label: value }))\n\nconst SCHEMAS: EntitySchema[] = [\n {\n name: 'deals',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'title', type: 'text' },\n { field: 'stage', type: 'enum', options: STAGES },\n { field: 'amount', type: 'number' },\n { field: 'close_date', type: 'date', label: 'Close date' },\n { field: 'company_id', type: 'relation', relation: { entity: 'companies', labelField: 'name' } },\n ],\n },\n {\n name: 'companies',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'name', type: 'text' },\n { field: 'website', type: 'text', format: 'url' },\n ],\n },\n {\n name: 'contacts',\n fields: [\n { field: 'id', type: 'text', primaryKey: true },\n { field: 'name', type: 'text' },\n { field: 'email', type: 'text', format: 'email' },\n { field: 'company_id', type: 'relation', relation: { entity: 'companies', labelField: 'name' } },\n ],\n },\n]\n\nexport function crmTables(): BaseTable[] {\n return baseTablesFromSchemas(\n SCHEMAS,\n (schema) => createRestDataSource({ url: `/api/${schema.name}`, schema }),\n // The API picks the id of a new record.\n () => ({ serverIds: true }),\n )\n}\n```\n\nWhat comes out:\n\n| In the description | In the base |\n|---|---|\n| `text`, with `format: 'url'` or `'email'` | Text, URL or Email field |\n| `number` | Number field |\n| `date`, `datetime` | Date field, with the time for `datetime` |\n| `enum` with options | Single select with those options |\n| `boolean` | Checkbox |\n| `relation` (`company_id`) | A Company link, stored as `company_id`, and a field in Companies that links back |\n| The primary key | The record's id, not a field |\n\nThe first text field is each table's primary field. Companies gets a Deals\nfield and a Contacts field that link back; they are worked out in the page\nand never sent to the API.\n\n## 4. Adjust the fields\n\nThe tables are plain objects. Show Amount as currency with a total, and give\nDeals a Kanban view by stage:\n\n```ts\nimport type { BaseTable } from '@svgrid/enterprise/base'\nimport { crmTables } from '$lib/crm'\n\nconst tables: BaseTable[] = crmTables().map((t) =>\n t.id !== 'deals'\n ? t\n : {\n ...t,\n columns: t.columns.map((c) =>\n c.field === 'amount' ? { ...c, fieldProps: { format: 'currency', symbol: '$', precision: 0, summary: 'sum' } } : c,\n ),\n views: [\n { id: 'grid', name: 'All deals', type: 'grid', color: { mode: 'field', field: 'stage' } },\n { id: 'pipeline', name: 'Pipeline', type: 'kanban', stackBy: 'stage' },\n ],\n },\n)\n```\n\n## 5. The page\n\n```svelte\n<script lang=\"ts\">\n import { SvToaster } from '@svgrid/grid'\n import { SvBase, enableBase } from '@svgrid/enterprise/base'\n import { crmTables } from '$lib/crm'\n\n enableBase()\n let tables = $state.raw(crmTables())\n</script>\n\n<div style=\"height: 640px\">\n <SvBase bind:tables editable sortable summary containerHeight=\"100%\" />\n</div>\n<SvToaster />\n```\n\nOpen it and the base makes one `GET` per table. Change a stage and it sends\n`PATCH /api/deals/d3` with `{ \"stage\": \"Won\" }`. Link a contact to a company\nfrom the Companies tab and it sends `PATCH /api/contacts/p2` with\n`{ \"company_id\": \"c1\" }`.\n\n## Next\n\n- [Keep a base in a database](./data.md): links, record ids, changes made\n elsewhere and every option.\n- [Build a base on Supabase](./supabase.md) and\n [on Postgres](./postgres.md).\n"
5259
5259
  },
5260
5260
  {
5261
5261
  "slug": "help/base/review-queue",
@@ -5297,14 +5297,14 @@ export const docs = [
5297
5297
  "path": "docs/help/base/undo-trash-import.md",
5298
5298
  "title": "Undo, the trash and importing files",
5299
5299
  "section": "SvGrid Base",
5300
- "markdown": "# Undo, the trash and importing files\n\nThree things people reach for in their first week with a base: Ctrl+Z after\na slip, getting back a record someone deleted yesterday, and pulling in the\nspreadsheet they kept until now. All three work on `<SvBase tables>` with no\nsetup; this page says what each one does and how an app keeps it.\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\n## Undo and redo\n\nA step undoes what it did and nothing else: what teammates changed since stays, whether\nthe change came through a live feed or a read of the table. A cell someone changed after\nyou keeps their value, on undo and on redo, cell by cell in a paste, and a record you added\nthat someone has worked on since stays, and the page says so. Delete it if it should go.\nFor a range the page says how many: \"Someone has changed 1 of these records since, so it\nkeeps their value.\" once all its blocks are written, or \"1 of these cells\" for a small range\nundone cell by cell.\nA cell undo on a table in a database reads the record first, with a live feed or without\none, so this holds for a change the page never saw; a date with a time is compared as the\npage last heard of it. When the record cannot be read, or a write of it has not answered\nyet, the undo is refused with a message and the step stays the next one to try. A number\nthe column rounded (1.234 in a column of two decimals) counts as what you typed. Moving a\nrecord by drag is a step too.\n\nOn a table in a database one Undo or Redo runs at a time. While one is still checking or\nwriting, another press changes nothing and says \"Undo is still running.\" (or \"Redo is still\nrunning.\"); the buttons show it busy, and leaving the page asks first. One that writes more\nthan one block (1,000 records, or 1,000 cells of a table the page holds) runs in the dialog a\nbig paste has, with its count and Stop: a range, Edit fields, a delete, the records a paste\nadded, and cells. Stopped, an Undo, or a Redo of cells or of added records, stays the next\nstep, and pressing it again writes only what is left; a Redo of a delete that is stopped\nkeeps the records it deleted, and Undo brings those back. A turn that writes a record the\nview no longer shows is done when that write has answered. What an Undo or Redo did is said\nonce it is done, with the number it changed: cells someone else changed, records a teammate\nrestored first or that were deleted forever, records out of reach and writes the database\nrefused are not counted. A paste of cells the grid holds says its count the same way, once\nthe database has answered.\n\nA record you add to a table read a part at a time has its \"add record\" step from the\nmoment its row is there. What you type into it is part of that step. An Undo before the\ndatabase has stored it waits for the insert, then takes the record out; a new record that\nwas never stored (left empty, or refused) just goes, with no Redo. Its activity starts\nonce it is stored: a refused record has none.\n\nAn undo or a redo puts values back. It runs no automation, and the row returns to its\nplace in the view at once.\n\nAn undo of a delete that fails (the network dropped, the database refused) leaves the\nrecord in the trash and the step in place: press Ctrl+Z again, or restore it from the\ntrash.\n\nCtrl+Z (Cmd+Z on a Mac) undoes what was done to the shown table, in the\norder it was done. Ctrl+Shift+Z or Ctrl+Y redoes it. The keys work anywhere\nin the base, and also with nothing focused on the page (after a dialog\ncloses, or a click beside the base): then the base used last takes them. A\nkey typed in a field of your own page stays yours. One history holds:\n\n- cell edits, pastes, fills and Edit fields on a selection, each one step however many\n cells it wrote (the grid's own history). Edit fields on more than 10,000 records of a\n table read a part at a time has no step: it says so and asks first. If it is stopped or\n fails with 10,000 or fewer changed, those have a step. A paste, Delete or fill over a large\n range goes the same way, and its undo reads and writes in blocks too;\n- records added, deleted or imported from a file;\n- fields added, changed (a new type, new options) or deleted;\n- tables added, renamed, duplicated, deleted or imported from a file.\n\nUndoing a deleted record puts it back at the place it had, and the links the\ndelete cleared come back too: delete a task and its project stops listing\nit; undo, and the project lists it again. The step restores the records of\nevery table the change touched.\n\nUndoing a deleted table brings it back as a tab, with its records and the\nfields of other tables that linked to it, and takes it out of the trash.\nUndoing a table you added takes it away again; the step lives on the new\ntable's history, so there is no redo once it is gone.\n\nThe Undo and Redo buttons at the end of the tab bar say what the next press\ndoes (\"Undo delete 2 records\"). `undoRedo={false}` hides them; the keys still\nwork. Each table keeps its history while another table is shown, so going\nback to a table carries on where you left it. View settings (a filter, a\nsort) are not part of the history: a view keeps them as you leave it.\n\n<div data-docs-demo=\"705-base-undo-redo\" data-height=\"620\"></div>\n\n## Soft delete\n\nUndo of a delete writes the record back. Point `softDelete` at a timestamp column and it\ndoes not have to: a delete sets the column and leaves the row, and a restore clears it.\nNothing about the record is rewritten, so columns off the schema, exact times and big\nnumbers come back as they were, and what a teammate wrote before the delete stays.\n\n```sql\nALTER TABLE orders ADD COLUMN deleted_at timestamptz;\n```\n\n```ts\nconst source = createSqlDataSource({ schema, table: 'orders', softDelete: 'deleted_at', dialect, execute })\n```\n\n`createSupabaseDataSource` takes the same option, and so do `createBaseEndpoint`,\n`baseFromDatabase` and `baseFromSupabase`:\n\n```ts\nconst endpoint = createBaseEndpoint({ execute, tables: ['orders', 'tags'], authorize, softDelete: 'deleted_at' })\n```\n\nPer table it is a function: `softDelete: (table) => (table === 'orders' ? 'removed_at' : null)`.\n\nThe string form skips a table without the column. The function form names a column that\nmust be there. Those three keep the column out of the fields. By hand, leave it off the\nschema: no write sets it either way, so a client cannot create a record already deleted or\nmark one through an update, and `createKitHandlers` answers `422` to an update of it alone.\nReads, counts, groups, totals, lookups and rollups skip marked records, and a write to one\nis told the record is gone.\n\n- The trash of a table with `softDelete` reads the table: every marked row is there, after\n a reload, for whoever may delete, whoever marked it. It lists the latest 1,000 per table\n and says how many there are. No trash store is needed for those records.\n- A record's links through a junction table stay. A delete leaves the junction rows, at\n either end of the link, a marked record shows in no link, and a restore finds them.\n- A foreign key in another table stays too. A delete writes nothing to that table, the\n record shows in no link while it is marked, and a restore finds its links where they were,\n whoever restores it and after any reload. A link a teammate changed in the meantime stays\n as they left it. While the record is marked the link reads as empty everywhere: \"is empty\"\n and \"is not empty\", one Empty group, sort, count and the link picker. The key stays in the\n column, so a query of your own still sees it. A link written to a marked record, from a\n picker opened before the delete, is stored, shows empty, and the person is told why.\n- Delete forever and Empty trash are final. Each asks first, the item stays in the trash\n until the database has confirmed, and if it refuses (another table still needs the record)\n the person is told and the record can still be restored. In one Empty trash the others go.\n Junction rows go with the record, and the foreign keys that point at it are emptied with it,\n in the tables of this base: see [Delete forever is one step](#delete-forever-is-one-step). A\n `NOT NULL` key cannot be emptied, so the record stays and the person is told other records\n depend on it. A row itself marked deleted keeps its key: a foreign key constraint refuses\n the purge until that row has gone. Undo cannot bring a deleted record back, in that window\n or another. An undo to a link whose record was deleted forever says so, and offers no Try again.\n- A trash item reaching `trashDays` is deleted for real only when the page's trash holds\n it, that is, when a trash store or `bind:trash` kept it. A row found marked in the table\n stays until someone deletes it, so opening a page never purges what another tool marked.\n For a limit on those, run it on a schedule:\n `DELETE FROM orders WHERE deleted_at < now() - interval '30 days'`.\n- A delete too big for the trash marks and purges a block of 1,000 at a time. A page closed\n half way leaves at most the block under way marked, and it shows in the trash.\n- A marked row still holds its value in a UNIQUE column, and still counts for a foreign key.\n- On Supabase a delete is an UPDATE to row-level security, so write the policy as one.\n- Autonumber reads the highest number over every row, marked ones too, on every source, so\n a marked record keeps its number and a new record takes the next.\n- A trash store item from before `softDelete` was turned on has no mark to clear: Restore\n says it was deleted forever.\n\n### Delete forever is one step\n\nEmptying the keys that hold a record and deleting it are several writes. Which of them can\nstop half way depends on how the base reaches the database:\n\n| The base is on | Delete forever is |\n|---|---|\n| `createBaseEndpoint` with `transaction` | One request and one transaction: all of it or none of it |\n| `createBaseEndpoint` without | One request: the server runs the steps, and a closed page changes nothing |\n| `createKitHandlers` with `linkedFrom` | The same two, by whether the sources share a `transaction` |\n| `baseFromDatabase` with `transaction` | One transaction, for the tables that share it |\n| `createKitHandlers` without `linkedFrom`, `baseFromDatabase` without `transaction` | Steps the page runs, over several requests |\n| Supabase and PostgREST | Steps the page runs. PostgREST has no transaction across requests |\n\nWhere it is steps, they are safe in this order. First the record's mark changes to\n`1970-01-03`, which is a claim: from then on no Restore or undo reaches it, by any path.\nThen the keys go, each only where it still holds this record, then the record. A failure\nputs the keys back, only where a key is still empty, so a link a teammate made meanwhile\nstays, and gives the claim up, with the mark set to that moment. If that fails too, or the\npage closes, the claim stays: the record stays in the trash marked as not finished, Restore\nsays why it cannot, and Delete forever finishes the job. Its links may be gone by then, so\nit does not come back with fewer than it had. A purge never reports a record it did not delete.\n\nGive the `transaction` next to `execute`, the same function for every table of a database. It\nruns `run` in a transaction, hands it an `execute` on that connection, and resolves to what\n`run` resolved to. A throw must roll back.\n\n```ts\n// node-postgres\ntransaction: async (run) => {\n const client = await pool.connect()\n try {\n await client.query('BEGIN')\n const out = await run((sql, params) => client.query(sql, params).then((r) => r.rows))\n await client.query('COMMIT')\n return out\n } catch (e) {\n await client.query('ROLLBACK').catch(() => {})\n throw e\n } finally {\n client.release()\n }\n}\n\n// postgres.js\ntransaction: (run) => sql.begin((tx) => run((text, params) => tx.unsafe(text, params)))\n\n// mysql2\ntransaction: async (run) => {\n const c = await pool.getConnection()\n try {\n await c.beginTransaction()\n const out = await run((sql, params) => c.query(sql, params).then(([rows]) => rows))\n await c.commit()\n return out\n } catch (e) {\n await c.rollback().catch(() => {})\n throw e\n } finally {\n c.release()\n }\n}\n\n// mssql\ntransaction: async (run) => {\n const tx = new mssql.Transaction(pool)\n await tx.begin()\n try {\n const out = await run(async (text, params) => {\n const request = new mssql.Request(tx)\n params.forEach((value, i) => request.input(`p${i + 1}`, value))\n return (await request.query(text)).recordset ?? []\n })\n await tx.commit()\n return out\n } catch (e) {\n await tx.rollback().catch(() => {})\n throw e\n }\n}\n```\n\nOn SQLite run `BEGIN IMMEDIATE`, `run` and `COMMIT` or `ROLLBACK` on the one connection, and\ntake no other write on it meanwhile. A teammate's write to a row the transaction holds waits\nfor it, then lands. Under a transaction a Restore of the record waits too, and finds it gone.\n\nIn the server's step each table's own `authorize`, `scope`, `validate`, hooks and `audit` apply\nto the keys it empties, as the page's requests met them, with `afterUpdate` and the audit only\nfor what stayed emptied. A `beforeUpdate` hook can refuse. What it changes in the patch is not\nwritten here.\n\nWith routes wired by hand, tell each table who holds its keys, and which of its fields lead to a\ntable that marks. Without `liveLinks` a group on such a field has an Empty group for each\ntrashed key.\n\n```ts\nconst orders = createKitHandlers({\n schema: orderSchema,\n source: createSqlDataSource({ ...orderConfig, transaction, liveLinks: { customer_id: { table: 'customers', key: 'id', softDelete: 'deleted_at' } } }),\n})\nconst customers = createKitHandlers({\n schema: customerSchema,\n source: createSqlDataSource({ ...customerConfig, transaction }),\n linkedFrom: [{ handlers: orders, column: 'customer_id' }],\n})\n```\n\n### Index for soft delete\n\n`deleted_at IS NULL` is in every read, so a count or a group can no longer be answered from\nan index that does not hold the column. Scrolling, sorting and filtering a page barely\nnotice; counts and groups do, and MySQL more than Postgres. Measured on a million orders,\nPostgres 16 and MySQL 8.4 on default memory settings:\n\n| Statement, ms | Postgres, plain to soft | MySQL, plain to soft |\n|---|---|---|\n| Count all | 19 to 32 | 55 to 229 |\n| Group by status | 44 to 73 | 112 to 888 |\n| Count through a lookup filter | 14 to 61 | 33 to 465 |\n\nWith a third of 633,000 rows marked, the lookup count on MySQL took about 0.9 s warm and\n13.3 s cold; an index on `(account, deleted_at)` brought it to 18 ms. So add the mark to the\nindexes your views filter and group on, last:\n\n```sql\nCREATE INDEX orders_account_live ON orders (account, deleted_at);\n```\n\nOn Postgres a partial index does the same for less space:\n`CREATE INDEX orders_account_live ON orders (account) WHERE deleted_at IS NULL`. The trash\nreads the latest marks, so index the column by itself on a table with many of them.\n\n## The trash\n\nA deleted view goes there too, with its filter, sorts and settings, and \"Restore\"\nputs it back at its place in the views menu. Undo does the same.\n\nA deleted record, field or table goes to the trash. The trash button at the\nend of the tab bar shows how many items it holds and opens a list, newest\nfirst, with who deleted each one (`setCurrentUser`) and when. Restore puts an\nitem back:\n\n- a record in its table, at the place it had, with its links;\n- a field with its values (the values stay in the records while the field is\n in the trash);\n- a table as a tab, with the fields of other tables that linked to it made\n again from its side.\n\nThe notice that appears after a delete has a Restore button too. A record\nwhose table is in the trash waits until the table is restored; the dialog\nsays so.\n\nThe trash is plain data. Bind it and store it next to the tables:\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, type BaseTable, type BaseTrashItem } from '@svgrid/enterprise/base'\n\n enableBase()\n let tables = $state.raw<BaseTable[]>(loadTables())\n let trash = $state<BaseTrashItem[]>(loadTrash())\n</script>\n\n<SvBase bind:tables bind:trash trashDays={30} editable onTablesChange={saveTables} onTrashChange={saveTrash} />\n```\n\nWith neither `onTrashChange` nor a store the trash lives in the page: it goes when the\npage is closed or reloaded, and the panel says so in place of a number of days. If the\napp keeps a `bind:trash` some other way, pass `trashKept` to show the days.\n\nTo keep the trash where the records are, so it survives a reload and every\nperson of the base gets the same one, give it a store. `list` is read when the\nbase opens (a promise is fine), so someone else's deletes appear in the panel when\nthe page is next opened; `add` and `remove` hear each item deleted, restored, undone\nor emptied, by id:\n\n```ts\nimport type { BaseTrashItem, BaseTrashStore } from '@svgrid/enterprise/base'\n\nconst trashStore: BaseTrashStore = {\n list: async () => (await (await fetch('/api/trash')).json()) as BaseTrashItem[],\n add: (items) => fetch('/api/trash', { method: 'POST', body: JSON.stringify(items) }),\n remove: (ids) => fetch('/api/trash', { method: 'DELETE', body: JSON.stringify(ids) }),\n}\n```\n\nPass it as `<SvBase {trashStore}>`. A store that fails says so in a notice;\nthe page's trash stands either way.\n\nItems older than `trashDays` (30 by default, 0 for no limit) are dropped when\nthe base opens, the same as Delete forever: on a table with `softDelete` the row goes\nwith them, and one the database refuses stays in the trash. `restoreItems(tables, items)` puts items back in code, for an\nadmin screen that restores from a stored trash.\n\n| `BaseTrashItem.kind` | Also holds |\n|---|---|\n| `'record'` | `table` (id), `row`, `index` |\n| `'field'` | `table` (id), `column`, `index` |\n| `'table'` | `table` (the whole `BaseTable`), `index` |\n\nEvery item has `id`, `deletedAt` (ISO time) and, when someone is signed in,\n`deletedBy` (a user id).\n\n<div data-docs-demo=\"706-base-trash\" data-height=\"620\"></div>\n\n## Import a CSV or Excel file\n\nThe tab bar's menus import a CSV, TSV, Excel (.xlsx) or JSON file. The file\nis read in the page; nothing is uploaded. An Excel cell is read as it shows: a\nnumber in a percent cell as a percent, a number in a date cell as that date.\n\n- **As a new table** (the list of tables, \"Import a file as a table\"): each\n column becomes a field, the first one naming the records. The type comes\n from the column's values and the dialog shows each guess to change before\n the import.\n- **Into the shown table** (the table's menu, \"Import records from a file\"):\n each column goes to the field it names, matched by name or id in any case.\n A column that matches nothing is skipped unless you point it at a field. A\n value a select does not have becomes a new option. A link field reads the\n linked records' names, comma-separated, with a name that holds a comma in\n quotes. A person field reads names or emails.\n\nA CSV is read for what it is. The separator (comma, semicolon, tab, pipe) and\nthe encoding are found from the file, and the dialog shows both to change. A\ndecimal comma stays a decimal: `1,50` is 1.5, and `1,500` alone is one thousand\nfive hundred.\n\nEach value is read the way the field reads a paste. A date keeps the calendar day\nit is written with, in every time zone, in any form a person writes one\n(`October 9, 2026`, `12/02/2026`, `3 December 2026`, `2026-10-09`). `12/02/2026`\nreads by the field's date format, then the viewer's language, unless a number past\n12 in the same column settles it: with `13/02/2026` in the column, all of it is day\nfirst. A percent reads as the grid reads it: `25%` is 25%, and a bare `25` in a\npercent field is 25% too. A person matches by name or email. A name that matches\nnobody is not stored, and neither is a linked record's name that no record has: the\ndialog says how many cells that is before the import, and again after it.\n\nThe dialog says what it found before anything is imported: a file that is not\nUTF-8, a quote that is never closed (the quote stays as text and the rows after\nit are read as usual), rows longer or shorter than the header (extra cells get\ncolumns of their own), values a field type cannot hold, names that match no\nperson or record, and records that repeat a name already in the table. A file\nthat is not text is refused.\n\n## Download a view\n\nThe list of tables has \"Download this view as CSV\" and \"Download this view as\nExcel\". The file holds the view's fields in its order and its records, filtered\nand sorted, each cell as it reads on screen: a formula's result, the names of\nlinked records and people, a checklist's items, attachments' file names. Numbers\nstay numbers, at every digit they hold, whether the page or a database driver gave\nthem. A percent is written `12.5%` and a duration `1:30:15`, so the file imports back to\nthe same values. A person sees only what they may see, in the file too. Text that would\nstart a formula in a spreadsheet is guarded in a CSV.\n\nIn Excel a number, a percent, a date and a time of day are real cells with the field's\nnumber format: they sum and sort, and read as on screen, in the date format and at\nthe places the field shows. That goes for a formula with a result of that kind, a count, a\nrollup, and a lookup with one value. A moment reads at the time its cell shows, in the\nviewer's zone or in GMT for a GMT field. These stay text: a number of more digits than a spreadsheet\nkeeps (16 and up), so every digit stays; a date before March 1900, which Excel has no day for;\na lookup of several values; a duration; and a yes or no field, as the word `true` or `false`\non every driver.\n\n`recordsAsShown(columns, rows)` gives the same values in code. `api.exportCsv`\nwrites what is stored: nothing for a formula, ids for links and people.\n\n| Values in the column | Field type |\n|---|---|\n| `$1,200`, `€80.50` | Number as currency, with the symbol |\n| `25%` | Number as percent (0 to 100) |\n| `yes` / `no`, `true` / `false`, `x` | Checkbox |\n| `42`, `3.75` | Number (integer or decimal) |\n| `ana@example.com` | Email |\n| `https://...` | URL |\n| `2026-11-02`, `02/11/2026` | Date (with the time when there is one) |\n| `+1 415 555 0100` | Phone |\n| A few short values, repeated | Single select, a color per value |\n| `Design, Copy`, items repeated | Multiple select |\n| Long text or line breaks | Long text |\n| Anything else | Single line text |\n\nAn import into a table is one undo step. An app that already has a file (a\ndrop zone of its own, a download) opens the same dialog with it:\n\n```svelte\n<script lang=\"ts\">\n let base = $state<ReturnType<typeof SvBase> | null>(null)\n</script>\n\n<SvBase bind:this={base} bind:tables editable />\n<button onclick={() => base?.openImport('append', file)}>Import</button>\n```\n\n`openImport('new', file)` makes a new table from it. In code, without the\ndialog, `tableFromMatrix(rows, tables, name)` builds a table from a header row\nand rows of text, and `recordsFromMatrix(rows, table, matchColumns(header,\ntable))` turns them into records of an existing table. `fileImport={false}`\nremoves the menu items.\n\n<div data-docs-demo=\"709-base-import-csv-excel\" data-height=\"620\"></div>\n\n## Next\n\n- [Views for every team](./views.md): personal and locked views, and the\n layout on a phone.\n- [Collaboration](./collaboration.md): who is signed in, comments and\n @mentions.\n- [Keep a base in a database](./data.md): a restored or imported record is\n written back like any other change.\n"
5300
+ "markdown": "# Undo, the trash and importing files\n\nThree things people reach for in their first week with a base: Ctrl+Z after\na slip, getting back a record someone deleted yesterday, and pulling in the\nspreadsheet they kept until now. All three work on `<SvBase tables>` with no\nsetup; this page says what each one does and how an app keeps it.\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\n## Undo and redo\n\nA step undoes what it did and nothing else: what teammates changed since stays, whether\nthe change came through a live feed or a read of the table. A cell someone changed after\nyou keeps their value, on undo and on redo, cell by cell in a paste, and a record you added\nthat someone has worked on since stays, and the page says so. Delete it if it should go.\nFor a range the page says how many: \"Someone has changed 1 of these records since, so it\nkeeps their value.\" once all its blocks are written, or \"1 of these cells\" for a small range\nundone cell by cell.\nA cell undo on a table in a database reads the record first, with a live feed or without\none, so this holds for a change the page never saw; a date with a time is compared as the\npage last heard of it. When the record cannot be read, or a write of it has not answered\nyet, the undo is refused with a message and the step stays the next one to try. A number\nthe column rounded (1.234 in a column of two decimals) counts as what you typed. Moving a\nrecord by drag is a step too.\n\nOn a table in a database one Undo or Redo runs at a time. While one is still checking or\nwriting, another press changes nothing and says \"Undo is still running.\" (or \"Redo is still\nrunning.\"); the buttons show it busy, and leaving the page asks first. One that writes more\nthan one block (1,000 records, or 1,000 cells of a table the page holds) runs in the dialog a\nbig paste has, with its count and Stop: a range, Edit fields, a delete, the records a paste\nadded, and cells. Stopped, an Undo, or a Redo of cells or of added records, stays the next\nstep, and pressing it again writes only what is left; a Redo of a delete that is stopped\nkeeps the records it deleted, and Undo brings those back. A turn that writes a record the\nview no longer shows is done when that write has answered. What an Undo or Redo did is said\nonce it is done, with the number it changed: cells someone else changed, records a teammate\nrestored first or that were deleted forever, records out of reach and writes the database\nrefused are not counted. A paste of cells the grid holds says its count the same way, once\nthe database has answered.\n\nA record you add to a table read a part at a time has its \"add record\" step from the\nmoment its row is there. What you type into it is part of that step. An Undo before the\ndatabase has stored it waits for the insert, then takes the record out; a new record that\nwas never stored (left empty, or refused) just goes, with no Redo. Its activity starts\nonce it is stored: a refused record has none.\n\nAn undo or a redo puts values back. It runs no automation, and the row returns to its\nplace in the view at once.\n\nAn undo of a delete that fails (the network dropped, the database refused) leaves the\nrecord in the trash and the step in place: press Ctrl+Z again, or restore it from the\ntrash.\n\nCtrl+Z (Cmd+Z on a Mac) undoes what was done to the shown table, in the\norder it was done. Ctrl+Shift+Z or Ctrl+Y redoes it. The keys work anywhere\nin the base, and also with nothing focused on the page (after a dialog\ncloses, or a click beside the base): then the base used last takes them. A\nkey typed in a field of your own page stays yours. One history holds:\n\n- cell edits, pastes, fills and Edit fields on a selection, each one step however many\n cells it wrote (the grid's own history). Edit fields on more than 10,000 records of a\n table read a part at a time has no step: it says so and asks first. If it is stopped or\n fails with 10,000 or fewer changed, those have a step. A paste, Delete or fill over a large\n range goes the same way, and its undo reads and writes in blocks too;\n- records added, deleted or imported from a file;\n- fields added, changed (a new type, new options) or deleted;\n- tables added, renamed, duplicated, deleted or imported from a file.\n\nUndoing a deleted record puts it back at the place it had, and the links the\ndelete cleared come back too: delete a task and its project stops listing\nit; undo, and the project lists it again. The step restores the records of\nevery table the change touched.\n\nUndoing a deleted table brings it back as a tab, with its records and the\nfields of other tables that linked to it, and takes it out of the trash.\nUndoing a table you added takes it away again; the step lives on the new\ntable's history, so there is no redo once it is gone.\n\nThe Undo and Redo buttons at the end of the tab bar say what the next press\ndoes (\"Undo delete 2 records\"). `undoRedo={false}` hides them; the keys still\nwork. Each table keeps its history while another table is shown, so going\nback to a table carries on where you left it. View settings (a filter, a\nsort) are not part of the history: a view keeps them as you leave it.\n\n<div data-docs-demo=\"705-base-undo-redo\" data-height=\"620\"></div>\n\n## Soft delete\n\nUndo of a delete writes the record back. Point `softDelete` at a timestamp column and it\ndoes not have to: a delete sets the column and leaves the row, and a restore clears it.\nNothing about the record is rewritten, so columns off the schema, exact times and big\nnumbers come back as they were, and what a teammate wrote before the delete stays.\n\n```sql\nALTER TABLE orders ADD COLUMN deleted_at timestamptz;\n```\n\n```ts\nconst source = createSqlDataSource({ schema, table: 'orders', softDelete: 'deleted_at', dialect, execute })\n```\n\n`createSupabaseDataSource` takes the same option, and so do `createBaseEndpoint`,\n`baseFromDatabase` and `baseFromSupabase`:\n\n```ts\nconst endpoint = createBaseEndpoint({ execute, tables: ['orders', 'tags'], authorize, softDelete: 'deleted_at' })\n```\n\nPer table it is a function: `softDelete: (table) => (table === 'orders' ? 'removed_at' : null)`.\n\nThe string form skips a table without the column. The function form names a column that\nmust be there. Those three keep the column out of the fields. By hand, leave it off the\nschema: no write sets it either way, so a client cannot create a record already deleted or\nmark one through an update, and `createKitHandlers` answers `422` to an update of it alone.\nReads, counts, groups, totals, lookups and rollups skip marked records, and a write to one\nis told the record is gone.\n\n- The trash of a table with `softDelete` reads the table: every marked row is there, after\n a reload, for whoever may delete, whoever marked it. It lists the latest 1,000 per table\n and says how many there are. No trash store is needed for those records.\n- A record's links through a junction table stay. A delete leaves the junction rows, at\n either end of the link, a marked record shows in no link, and a restore finds them.\n- A foreign key in another table stays too. A delete writes nothing to that table, the\n record shows in no link while it is marked, and a restore finds its links where they were,\n whoever restores it and after any reload. A link a teammate changed in the meantime stays\n as they left it. While the record is marked the link reads as empty everywhere: \"is empty\"\n and \"is not empty\", one Empty group, sort, count and the link picker. The key stays in the\n column, so a query of your own still sees it. A link written to a marked record, from a\n picker opened before the delete, is stored, shows empty, and the person is told why.\n- Delete forever and Empty trash are final. Each asks first, the item stays in the trash\n until the database has confirmed, and if it refuses (another table still needs the record)\n the person is told and the record can still be restored. In one Empty trash the others go.\n Junction rows go with the record, and the foreign keys that point at it are emptied with it,\n in the tables of this base: see [Delete forever is one step](#delete-forever-is-one-step). A\n `NOT NULL` key cannot be emptied, so the record stays and the person is told other records\n depend on it. A row itself marked deleted keeps its key: a foreign key constraint refuses\n the purge until that row has gone. Undo cannot bring a deleted record back, in that window\n or another. An undo to a link whose record was deleted forever says so, and offers no Try again.\n- A trash item reaching `trashDays` is deleted for real only when the page's trash holds\n it, that is, when a trash store or `bind:trash` kept it. A row found marked in the table\n stays until someone deletes it, so opening a page never purges what another tool marked.\n For a limit on those, run it on a schedule:\n `DELETE FROM orders WHERE deleted_at < now() - interval '30 days'`.\n- A delete too big for the trash marks and purges a block of 1,000 at a time. A page closed\n half way leaves at most the block under way marked, and it shows in the trash.\n- A marked row still holds its value in a UNIQUE column, and still counts for a foreign key.\n- On Supabase a delete is an UPDATE to row-level security, so write the policy as one.\n- Autonumber reads the highest number over every row, marked ones too, on every source, so\n a marked record keeps its number and a new record takes the next.\n- A trash store item from before `softDelete` was turned on has no mark to clear: Restore\n says it was deleted forever.\n\n### Delete forever is one step\n\nEmptying the keys that hold a record and deleting it are several writes. Which of them can\nstop half way depends on how the base reaches the database:\n\n| The base is on | Delete forever is |\n|---|---|\n| `createBaseEndpoint` with `transaction` | One request and one transaction: all of it or none of it |\n| `createBaseEndpoint` without | One request: the server runs the steps, and a closed page changes nothing |\n| `createKitHandlers` with `linkedFrom` | The same two, by whether the sources share a `transaction` |\n| `baseFromDatabase` with `transaction` | One transaction, for the tables that share it |\n| `createKitHandlers` without `linkedFrom`, `baseFromDatabase` without `transaction` | Steps the page runs, over several requests |\n| Supabase and PostgREST | Steps the page runs. PostgREST has no transaction across requests |\n\nWhere it is steps, they are safe in this order. First the record's mark changes to\n`1970-01-03`, which is a claim: from then on no Restore or undo reaches it, by any path.\nThen the keys go, each only where it still holds this record, then the record. A failure\nputs the keys back, only where a key is still empty, so a link a teammate made meanwhile\nstays, and gives the claim up, with the mark set to that moment. If that fails too, or the\npage closes, the claim stays: the record stays in the trash marked as not finished, Restore\nsays why it cannot, and Delete forever finishes the job. Its links may be gone by then, so\nit does not come back with fewer than it had. A purge never reports a record it did not delete.\n\nGive the `transaction` next to `execute`, the same function for every table of a database. It\nruns `run` in a transaction, hands it an `execute` on that connection, and resolves to what\n`run` resolved to. A throw must roll back.\n\n```ts\n// node-postgres\ntransaction: async (run) => {\n const client = await pool.connect()\n try {\n await client.query('BEGIN')\n const out = await run((sql, params) => client.query(sql, params).then((r) => r.rows))\n await client.query('COMMIT')\n return out\n } catch (e) {\n await client.query('ROLLBACK').catch(() => {})\n throw e\n } finally {\n client.release()\n }\n}\n\n// postgres.js\ntransaction: (run) => sql.begin((tx) => run((text, params) => tx.unsafe(text, params)))\n\n// mysql2\ntransaction: async (run) => {\n const c = await pool.getConnection()\n try {\n await c.beginTransaction()\n const out = await run((sql, params) => c.query(sql, params).then(([rows]) => rows))\n await c.commit()\n return out\n } catch (e) {\n await c.rollback().catch(() => {})\n throw e\n } finally {\n c.release()\n }\n}\n\n// mssql\ntransaction: async (run) => {\n const tx = new mssql.Transaction(pool)\n await tx.begin()\n try {\n const out = await run(async (text, params) => {\n const request = new mssql.Request(tx)\n params.forEach((value, i) => request.input(`p${i + 1}`, value))\n return (await request.query(text)).recordset ?? []\n })\n await tx.commit()\n return out\n } catch (e) {\n await tx.rollback().catch(() => {})\n throw e\n }\n}\n```\n\nOn SQLite run `BEGIN IMMEDIATE`, `run` and `COMMIT` or `ROLLBACK` on the one connection, and\ntake no other write on it meanwhile. A teammate's write to a row the transaction holds waits\nfor it, then lands. Under a transaction a Restore of the record waits too, and finds it gone.\n\nIn the server's step each table's own `authorize`, `scope`, `validate`, hooks and `audit` apply\nto the keys it empties, as the page's requests met them, with `afterUpdate` and the audit only\nfor what stayed emptied. A `beforeUpdate` hook can refuse. What it changes in the patch is not\nwritten here.\n\nWith routes wired by hand, tell each table who holds its keys, and which of its fields lead to a\ntable that marks. Without `liveLinks` a group on such a field has an Empty group for each\ntrashed key.\n\n```ts\nconst orders = createKitHandlers({\n schema: orderSchema,\n source: createSqlDataSource({ ...orderConfig, transaction, liveLinks: { customer_id: { table: 'customers', key: 'id', softDelete: 'deleted_at' } } }),\n})\nconst customers = createKitHandlers({\n schema: customerSchema,\n source: createSqlDataSource({ ...customerConfig, transaction }),\n linkedFrom: [{ handlers: orders, column: 'customer_id' }],\n})\n```\n\n### Index for soft delete\n\n`deleted_at IS NULL` is in every read, so a count or a group can no longer be answered from\nan index that does not hold the column. Scrolling, sorting and filtering a page barely\nnotice; counts and groups do, and MySQL more than Postgres. Measured on a million orders,\nPostgres 16 and MySQL 8.4 on default memory settings:\n\n| Statement, ms | Postgres, plain to soft | MySQL, plain to soft |\n|---|---|---|\n| Count all | 19 to 32 | 55 to 229 |\n| Group by status | 44 to 73 | 112 to 888 |\n| Count through a lookup filter | 14 to 61 | 33 to 465 |\n\nWith a third of 633,000 rows marked, the lookup count on MySQL took about 0.9 s warm and\n13.3 s cold; an index on `(account, deleted_at)` brought it to 18 ms. So add the mark to the\nindexes your views filter and group on, last:\n\n```sql\nCREATE INDEX orders_account_live ON orders (account, deleted_at);\n```\n\nOn Postgres a partial index does the same for less space:\n`CREATE INDEX orders_account_live ON orders (account) WHERE deleted_at IS NULL`. The trash\nreads the latest marks, so index the column by itself on a table with many of them.\n\n## The trash\n\nA deleted view goes there too, with its filter, sorts and settings, and \"Restore\"\nputs it back at its place in the views menu. Undo does the same.\n\nA deleted record, field or table goes to the trash. The trash button at the\nend of the tab bar shows how many items it holds and opens a list, newest\nfirst, with who deleted each one (`setCurrentUser`) and when. Restore puts an\nitem back:\n\n- a record in its table, at the place it had, with its links;\n- a field with its values (the values stay in the records while the field is\n in the trash);\n- a table as a tab, with the fields of other tables that linked to it made\n again from its side.\n\nThe notice that appears after a delete has a Restore button too. A record\nwhose table is in the trash waits until the table is restored; the dialog\nsays so.\n\nThe trash is plain data. Bind it and store it next to the tables:\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, type BaseTable, type BaseTrashItem } from '@svgrid/enterprise/base'\n\n enableBase()\n let tables = $state.raw<BaseTable[]>(loadTables())\n let trash = $state<BaseTrashItem[]>(loadTrash())\n</script>\n\n<SvBase bind:tables bind:trash trashDays={30} editable onTablesChange={saveTables} onTrashChange={saveTrash} />\n```\n\nWith neither `onTrashChange` nor a store the trash lives in the page: it goes when the\npage is closed or reloaded, and the panel says so in place of a number of days. If the\napp keeps a `bind:trash` some other way, pass `trashKept` to show the days.\n\nTo keep the trash where the records are, so it survives a reload and every\nperson of the base gets the same one, give it a store. `list` is read when the\nbase opens (a promise is fine), so someone else's deletes appear in the panel when\nthe page is next opened; `add` and `remove` hear each item deleted, restored, undone\nor emptied, by id:\n\n```ts\nimport type { BaseTrashItem, BaseTrashStore } from '@svgrid/enterprise/base'\n\nconst trashStore: BaseTrashStore = {\n list: async () => (await (await fetch('/api/trash')).json()) as BaseTrashItem[],\n add: (items) => fetch('/api/trash', { method: 'POST', body: JSON.stringify(items) }),\n remove: (ids) => fetch('/api/trash', { method: 'DELETE', body: JSON.stringify(ids) }),\n}\n```\n\nPass it as `<SvBase {trashStore}>`. A store that fails says so in a notice;\nthe page's trash stands either way.\n\nItems older than `trashDays` (30 by default, 0 for no limit) are dropped when\nthe base opens, the same as Delete forever: on a table with `softDelete` the row goes\nwith them, and one the database refuses stays in the trash. `restoreItems(tables, items)` puts items back in code, for an\nadmin screen that restores from a stored trash.\n\n| `BaseTrashItem.kind` | Also holds |\n|---|---|\n| `'record'` | `table` (id), `row`, `index` |\n| `'field'` | `table` (id), `column`, `index` |\n| `'table'` | `table` (the whole `BaseTable`), `index` |\n\nEvery item has `id`, `deletedAt` (ISO time) and, when someone is signed in,\n`deletedBy` (a user id).\n\n<div data-docs-demo=\"706-base-trash\" data-height=\"620\"></div>\n\n## Import a CSV or Excel file\n\nThe tab bar's menus import a CSV, TSV, Excel (.xlsx) or JSON file. The file\nis read in the page; nothing is uploaded. An Excel cell is read as it shows: a\nnumber in a percent cell as a percent, a number in a date cell as that date.\n\n- **As a new table** (the list of tables, \"Import a file as a table\"): each\n column becomes a field, the first one naming the records. The type comes\n from the column's values and the dialog shows each guess to change before\n the import.\n- **Into the shown table** (the table's menu, \"Import records from a file\"):\n each column goes to the field it names, matched by name or id in any case.\n A column that matches nothing is skipped unless you point it at a field. A\n value a select does not have becomes a new option. A link field reads the\n linked records' names, comma-separated, with a name that holds a comma in\n quotes. A person field reads names or emails.\n\nA CSV is read for what it is. The separator (comma, semicolon, tab, pipe) and\nthe encoding are found from the file, and the dialog shows both to change. A\ndecimal comma stays a decimal: `1,50` is 1.5, and `1,500` alone is one thousand\nfive hundred.\n\nEach value is read the way the field reads a paste. A date keeps the calendar day\nit is written with, in every time zone, in any form a person writes one\n(`October 9, 2026`, `12/02/2026`, `3 December 2026`, `2026-10-09`). `12/02/2026`\nreads by the field's date format, then the viewer's language, unless a number past\n12 in the same column settles it: with `13/02/2026` in the column, all of it is day\nfirst. A percent reads as the grid reads it: `25%` is 25%, and a bare `25` in a\npercent field is 25% too. A person matches by name or email. A name that matches\nnobody is not stored, and neither is a linked record's name that no record has: the\ndialog says how many cells that is before the import, and again after it.\n\nThe dialog says what it found before anything is imported: a file that is not\nUTF-8, a quote that is never closed (the quote stays as text and the rows after\nit are read as usual), rows longer or shorter than the header (extra cells get\ncolumns of their own), values a field type cannot hold, names that match no\nperson or record, and records that repeat a name already in the table. A file\nthat is not text is refused.\n\n## Download a view\n\nThe list of tables has \"Download this view as CSV\" and \"Download this view as\nExcel\". The file holds the view's fields in its order and its records, filtered\nand sorted, each cell as it reads on screen: a formula's result, the names of\nlinked records and people, a checklist's items, attachments' file names. Numbers\nstay numbers, at every digit they hold, whether the page or a database driver gave\nthem. A percent is written `12.5%` and a duration `1:30:15`, so the file imports back to\nthe same values. A person sees only what they may see, in the file too. Text that would\nstart a formula in a spreadsheet is guarded in a CSV.\n\nIn Excel a number, a percent, a date and a time of day are real cells with the field's\nnumber format: they sum and sort, and read as on screen, in the date format and at\nthe places the field shows. That goes for a formula with a result of that kind, a count, a\nrollup, and a lookup with one value. A moment reads at the time its cell shows, in the\nviewer's zone or in GMT for a GMT field. These stay text: a number of more digits than a spreadsheet\nkeeps (16 and up), so every digit stays; a date before March 1900, which Excel has no day for;\na lookup of several values; a duration; and a yes or no field, as the word `true` or `false`\non every driver.\n\n`recordsAsShown(columns, rows)` gives the same values in code. `api.exportCsv`\nwrites what is stored: nothing for a formula, ids for links and people.\n\n| Values in the column | Field type |\n|---|---|\n| `$1,200`, `€80.50` | Number as currency, with the symbol |\n| `25%` | Number as percent (0 to 100) |\n| `yes` / `no`, `true` / `false`, `x` | Checkbox |\n| `42`, `3.75` | Number (integer or decimal) |\n| `ana@example.com` | Email |\n| `https://...` | URL |\n| `2026-11-02`, `02/11/2026` | Date (with the time when there is one) |\n| `+1 415 555 0100` | Phone |\n| A few short values, repeated | Single select, a color per value |\n| `Design, Copy`, items repeated | Multiple select |\n| Long text or line breaks | Long text |\n| Anything else | Single line text |\n\nAn import into a table is one undo step. An app that already has a file (a\ndrop zone of its own, a download) opens the same dialog with it:\n\n```svelte\n<script lang=\"ts\">\n let base = $state<ReturnType<typeof SvBase> | null>(null)\n</script>\n\n<SvBase bind:this={base} bind:tables editable />\n<button onclick={() => base?.openImport('append', file)}>Import</button>\n```\n\n`openImport('new', file)` makes a new table from it. A base whose tables live on a server keeps it\nwith `onImportTable` (see [Keep a base in a database](./data.md)). In code, without the\ndialog, `tableFromMatrix(rows, tables, name)` builds a table from a header row\nand rows of text, and `recordsFromMatrix(rows, table, matchColumns(header,\ntable))` turns them into records of an existing table. `fileImport={false}`\nremoves the menu items.\n\nThe base reads CSV, TSV, `.xlsx` (its first sheet) and JSON itself. To take\nother formats (an old `.xls`, `.ods`, `.xlsb`), give your own reader:\n`importReader` gets every file first and answers its rows as text, the header\nrow first, or `null` to leave the file to the base. With it, the file picker\noffers those formats too.\n\n```ts\nimport * as XLSX from 'xlsx'\n\nconst importReader = async (file: File) => {\n if (!/\\.(xls|xlsb|ods)$/i.test(file.name)) return null\n const book = XLSX.read(new Uint8Array(await file.arrayBuffer()), { type: 'array' })\n const sheet = book.Sheets[book.SheetNames[0]]\n return XLSX.utils.sheet_to_json(sheet, { header: 1, raw: false, defval: '' })\n}\n// <SvBase {tables} {importReader} />\n```\n\n<div data-docs-demo=\"709-base-import-csv-excel\" data-height=\"620\"></div>\n\n## Next\n\n- [Views for every team](./views.md): personal and locked views, and the\n layout on a phone.\n- [Collaboration](./collaboration.md): who is signed in, comments and\n @mentions.\n- [Keep a base in a database](./data.md): a restored or imported record is\n written back like any other change.\n"
5301
5301
  },
5302
5302
  {
5303
5303
  "slug": "help/base/views",
5304
5304
  "path": "docs/help/base/views.md",
5305
5305
  "title": "Views for every team",
5306
5306
  "section": "SvGrid Base",
5307
- "markdown": "# Views for every team\n\nOne table of records, many ways to look at it. Product reads the roadmap\ngrouped by quarter, engineering works off a status board, the leads check a\ntimeline, and anyone in the company files a request through a form. Each of\nthose is a saved view: a name, a type, and the filter, sorts, groups, hidden\nfields, row height and colors it had when someone last left it.\n\n![The Features table feeds six saved views: Roadmap by quarter (a grid grouped by Quarter, sorted by Impact, Lead hidden, row height 56, colored by Status), Now (a grid filtered to active work), Status board (a Kanban stacked by Status), Timeline (bars from Start to Target), Effort by team (a bar chart) and Request a feature (a form). onViewsChange hands the whole list to the app, which stores it and loads it back into bind:views.](/docs-media/base-views.svg)\n\n<div data-docs-demo=\"513-base-product-roadmap\" data-height=\"680\"></div>\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\nThis page builds the Features table of that roadmap one view at a time. Each\nstep adds to the `views` list from the step before and works on its own.\n\n## 1. The table\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, setFieldUsers, type FieldView } from '@svgrid/enterprise/base'\n\n enableBase()\n setFieldUsers([\n { id: 'u1', name: 'Ana Ruiz' },\n { id: 'u2', name: 'Ben Okafor' },\n { id: 'u3', name: 'Cleo Park' },\n ])\n\n type Feature = {\n id: number; feature: string; quarter: string; status: string; teams: string[]\n lead: string; impact: number; effort: number; start: string; target: string; votes: number\n }\n\n const QUARTERS = [\n { value: 'Q4 2026', color: '#2d7ff9' },\n { value: 'Q1 2027', color: '#18bfff' },\n { value: 'Later', color: '#94a3b8' },\n ]\n const STATUS = [\n { value: 'Planned', color: '#94a3b8' },\n { value: 'In progress', color: '#2d7ff9' },\n { value: 'In beta', color: '#8b46ff' },\n { value: 'Shipped', color: '#20c933' },\n { value: 'Blocked', color: '#f82b60' },\n ]\n const TEAMS = [\n { value: 'Web', color: '#2d7ff9' },\n { value: 'Mobile', color: '#ff6f2c' },\n { value: 'Platform', color: '#8b46ff' },\n ]\n\n let rows = $state.raw<Feature[]>([\n { id: 1, feature: 'Single sign-on with SAML', quarter: 'Q4 2026', status: 'In progress', teams: ['Platform'], lead: 'u2', impact: 5, effort: 12, start: '2026-10-05', target: '2026-11-13', votes: 182 },\n { id: 2, feature: 'Offline mode for the mobile app', quarter: 'Q4 2026', status: 'Blocked', teams: ['Mobile'], lead: 'u3', impact: 4, effort: 13, start: '2026-10-12', target: '2026-12-04', votes: 96 },\n { id: 3, feature: 'Dark mode', quarter: 'Q4 2026', status: 'Shipped', teams: ['Web'], lead: 'u1', impact: 2, effort: 4, start: '2026-10-01', target: '2026-10-16', votes: 154 },\n { id: 4, feature: 'Audit log export', quarter: 'Q1 2027', status: 'Planned', teams: ['Platform', 'Web'], lead: 'u1', impact: 3, effort: 5, start: '2027-01-11', target: '2027-01-29', votes: 41 },\n ])\n\n const columns = [\n { field: 'feature', header: 'Feature', width: 260, fieldType: 'text' },\n { field: 'quarter', header: 'Quarter', fieldType: 'singleSelect', fieldProps: { options: QUARTERS } },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: STATUS } },\n { field: 'teams', header: 'Teams', fieldType: 'multiSelect', fieldProps: { options: TEAMS } },\n { field: 'lead', header: 'Lead', fieldType: 'user' },\n { field: 'impact', header: 'Impact', fieldType: 'rating', fieldProps: { max: 5 } },\n { field: 'effort', header: 'Effort (days)', fieldType: 'number', fieldProps: { format: 'integer', summary: 'sum' } },\n { field: 'start', header: 'Start', fieldType: 'date', fieldProps: { dateFormat: 'friendly' } },\n { field: 'target', header: 'Target', fieldType: 'date', fieldProps: { dateFormat: 'friendly' } },\n { field: 'votes', header: 'Votes', fieldType: 'number', fieldProps: { format: 'integer', summary: 'sum' } },\n ]\n\n let views = $state<FieldView[]>([{ id: 'all', name: 'All features', type: 'grid' }])\n</script>\n\n<SvBase data={rows} {columns} bind:views primaryField=\"feature\"\n editable sortable showRowNumbers expandRows summary containerHeight={640}\n rowAdder={{ label: 'Add feature', defaults: () => ({ id: Date.now(), status: 'Planned', quarter: 'Later', teams: [] }) }} />\n```\n\nThe view bar over the grid has \"All features\" on the left, then Hide\nfields, Filter, Group, Sort, Color and a row height button, and \"4 records\"\nwith a search button on the right. The footer row shows \"Sum 34\" under Effort\nand \"Sum 473\" under Votes, because those fields set `fieldProps.summary`.\n\nEvery view key that names a field (`stackBy`, `dateField`, a filter\ncondition's `column`, a chart's `x`) takes the column id. A column without an\n`id` uses its `field`, so in this table the two are the same.\n\n## 2. A roadmap grouped by quarter\n\nA view can start with settings. `state` is the grid's own state, the same\nobject `api.getState()` returns; `color` says how rows are colored.\n\n```ts\nconst roadmap: FieldView = {\n id: 'roadmap',\n name: 'Roadmap by quarter',\n type: 'grid',\n color: { mode: 'field', field: 'status' },\n rowHeight: 56,\n state: {\n grouping: ['quarter'],\n sorting: [{ id: 'quarter', desc: false }, { id: 'impact', desc: true }],\n hiddenColumns: ['lead'],\n },\n}\n```\n\nGroups and sorts share the grid's `sorting` list: a grouped field's\ndirection is an entry ahead of the sorts. The view bar writes them that way,\nso write them that way too. Here the bar reads \"1 hidden field\", \"Grouped by\n1 field\" and \"Sorted by 1 field\": the `quarter` entry belongs to the group,\nnot to Sort.\n\nEach group header shows \"Quarter\" over the option's pill, the number of\nrecords, the summaries the fields picked for that group (\"Effort (days) 29\",\n\"Votes 432\"), and \"+\" to add a feature that already has that quarter. Groups\ncome in the select's option order, not alphabetically. Group rows are at\nleast 52px tall so the field's name fits over the value; with\n`rowHeight: 56` they match the records. Each row has a status color stripe\non its row header. 56 is the row height menu's \"Medium\": from 48px, text and\nselect pills wrap.\n\n## 3. A view that starts filtered\n\nThe filter is the grid's advanced filter with its own kind, `fieldFilter`.\nPut it in `state.advancedFilter`:\n\n```ts\nimport { describeFieldFilter, type FieldFilter } from '@svgrid/enterprise/base'\n\nconst activeWork: FieldFilter = {\n kind: 'fieldFilter',\n conjunction: 'and',\n conditions: [\n { column: 'status', kind: 'select', op: 'isAnyOf', value: ['In progress', 'In beta', 'Blocked'] },\n {\n conjunction: 'or',\n conditions: [\n { column: 'target', kind: 'date', op: 'isWithin', value: { span: 'nextDays', days: 30 } },\n { column: 'impact', kind: 'number', op: 'gte', value: 4 },\n ],\n },\n ],\n}\n\nconst now: FieldView = {\n id: 'now',\n name: 'Now',\n type: 'grid',\n state: { sorting: [{ id: 'target', desc: false }], advancedFilter: activeWork },\n}\n\nconst header = (id: string) => columns.find((c) => c.field === id)?.header ?? id\ndescribeFieldFilter(activeWork, header)\n// \"Status is any of In progress, In beta, Blocked and (Target is within the next 30 days or Impact ≥ 4)\"\n```\n\nThe Filter button reads \"Filtered by 3 fields\" (one field reads \"Filtered by\nStatus\") and the record count drops to what the filter keeps.\n`describeFieldFilter` writes a filter in the words the panel uses, for a page\nsubtitle or an audit line. It returns `\"every record\"` for a filter with no\ncomplete conditions.\n\nA condition is a field, an operator and a value; a group is one level deep.\n[Filters in code](#filters-in-code) below lists the operators per kind.\n\nOne view can serve every lead. `ME` (the string `'@me'`) in a person\ncondition stands for whoever `setCurrentUser` names when the filter runs; the\nFilter panel lists it as \"Me\", first among the people.\n\n```ts\nimport { ME, setCurrentUser } from '@svgrid/enterprise/base'\n\nsetCurrentUser({ id: 'u2', name: 'Ben Okafor' })\n\nconst mine: FieldView = {\n id: 'mine',\n name: 'My features',\n type: 'grid',\n state: {\n advancedFilter: {\n kind: 'fieldFilter',\n conjunction: 'and',\n conditions: [{ column: 'lead', kind: 'select', op: 'is', value: ME }],\n },\n },\n}\n```\n\nBen sees \"Single sign-on with SAML\"; Ana, signed in, sees her two. With\nnobody signed in the condition matches no one. `describeFieldFilter` writes\nit as \"Lead is me\".\n\n## 4. A status board\n\n```ts\nconst board: FieldView = { id: 'board', name: 'Status board', type: 'kanban', stackBy: 'status' }\n```\n\n![The roadmap's Status board: Planned, In progress, In beta and Shipped lanes of feature cards showing Quarter, Teams and Lead, with the right-click menu open on \"Single sign-on with SAML\": Expand record, Comment, Move to, Duplicate record, Delete record.](/docs-media/base-views.png)\n\n`stackBy` takes a single select or a user field that holds one person. You\nget one lane per option, in option order and color, plus \"Uncategorized\",\nwhich shows only while a record has no status. Stack by `lead` instead and\nthe lanes are the people from `setFieldUsers`.\n\nSort the view by a number field and a card dropped elsewhere in its lane takes\na number between its neighbours', so the order is the table's and lasts.\n\nDrop a card in another lane and the status changes through the grid's edit\npath, so undo, validation and `onCellValueChange` all see it. \"+ Add a card\"\nadds a record already in that lane, named by the primary field.\n\nA card shows the record's name, then the next three fields the view shows,\nin column order (the stacked field left out), each drawn as its cell draws\nit. Hide a field in Hide fields and it leaves the cards; drag it up there to\nput it on them. Cards are read, not edited: a rating shows its stars\nbut does not take a click. Double-click a card or press F2 to open the\nrecord. Right-click it for its menu: Expand record, Comment, and, when the\nbase is `editable`, Move to (a submenu of the lanes), Duplicate record and\nDelete record, which asks \"Delete record?\" first. A card with comments shows\ntheir count; click it to open the record at its comment box.\n\n## 5. A timeline\n\n```ts\nconst timeline: FieldView = {\n id: 'timeline',\n name: 'Timeline',\n type: 'gantt',\n dateField: 'start',\n endField: 'target',\n color: { mode: 'field', field: 'status' },\n}\n```\n\nEach feature is a bar from its start to its target date, beside a table of\nnames and dates. Drag a bar to move both dates; drag its edge to change the\ntarget. One drag is one Ctrl+Z. `type: 'calendar'` with the same fields shows\nthe features on a month instead: a date field without a time shows as all-day\nevents. The end of a bar or an event is exclusive, so the record keeps the last\nday: a feature dragged to cover the 19th to the 21st gets\n`target: '2026-10-21'`.\n\nWith only `dateField`, events move but cannot be resized. Pick a day (or a\nrange) on the calendar and a new record lands on it, opened with its name\nready to type. Colored by a single select, the events take the option colors\nand the options appear above the calendar as a legend that hides and shows\nthem.\n\nMoving and resizing need `editable` on the base. Without it the calendar is\nread-only.\n\n## 6. Effort by team\n\n```ts\nconst effort: FieldView = { id: 'effort', name: 'Effort by team', type: 'chart', chart: { kind: 'barH', x: 'teams', y: 'effort' } }\nconst mix: FieldView = { id: 'mix', name: 'Features per quarter', type: 'chart', chart: { kind: 'donut', x: 'quarter' } }\n```\n\nA chart groups the records the view shows by `x` and adds up `y` (or counts\nrecords when there is no `y`). `aggregation: 'avg'` averages instead of\nsumming. Kinds are `'bar'`, `'barH'`, `'line'`, `'pie'` and `'donut'`.\n\nHow `x` groups:\n\n- A single or multiple select keeps its options' order and colors. A\n multiple select counts a record in each of its options, so \"Audit log\n export\" adds 5 days to both Platform and Web.\n- A person or a linked record shows by name.\n- A date groups by month (\"Oct 2026\").\n- Records with no value go in an \"Empty\" bar, last.\n\nValues read as the summed field writes them, and a count as a whole number.\nThe series is labeled \"Sum of Effort (days)\", \"Average of ...\" or \"Records\".\nThe bar shows Filter, which narrows what is charted, and \"Customize chart\",\nwhose Type, Group by, Value and Combine (sum or average) are kept in `chart`.\nA chart view declared without `chart` draws \"Choose a field to chart in\nCustomize chart.\" until a field is picked there.\n\n## 7. A gallery of mockups\n\nAdd an attachment field, then a gallery view with it as the cover:\n\n```ts\nconst mockupField = { field: 'mockups', header: 'Mockups', fieldType: 'attachment' }\nconst gallery: FieldView = { id: 'mockups', name: 'Mockups', type: 'gallery', coverField: 'mockups' }\n```\n\nEach card shows the first image of `mockups`, the primary field as its title,\nthen the fields the grid shows, each drawn as its cell draws it. Hide a field\nin this view and it leaves the cards; drag fields in Hide fields to reorder\nthem. A click on a card opens the record. Without `coverField` the cards have\nno cover.\n\n## 8. A request form\n\n```ts\nconst request: FieldView = {\n id: 'request',\n name: 'Request a feature',\n type: 'form',\n formFields: ['feature', 'teams', 'impact'],\n formRequired: ['feature'],\n formTitle: 'Request a feature',\n formDescription: 'What should we build, and who is it for? Product reviews requests every Friday.',\n formSubmitLabel: 'Send request',\n}\n```\n\nThe form asks for the fields in `formFields` (column ids, in order), each with\nthe editor its cell uses. Without it, the form asks for every field a person\ncan fill in, the primary field first; computed fields are left out. A field\nin `formRequired` must be filled before the form sends. `formTitle` defaults\nto the view's name, `formSubmitLabel` to \"Submit\". A sent form adds a record\nthe way \"+ Add row\" does: `rowAdder.defaults` first, so a request starts as\nPlanned in Later, then what was typed, then `onRowAdd`. The bar shows only\nthe view switcher on a form.\n\nAll the views so far, in one list:\n\n```ts\nlet views = $state<FieldView[]>([roadmap, board, timeline, effort, now, mine, gallery, request])\n```\n\n## 9. A dashboard\n\n```ts\nconst OPEN: FieldFilter = { kind: 'fieldFilter', conjunction: 'and', conditions: [{ column: 'status', kind: 'select', op: 'isNot', value: 'Shipped' }] }\nconst SHIPPED: FieldFilter = { kind: 'fieldFilter', conjunction: 'and', conditions: [{ column: 'status', kind: 'select', op: 'is', value: 'Shipped' }] }\n\nconst overview: FieldView = {\n id: 'overview',\n name: 'Overview',\n type: 'dashboard',\n dashboard: [\n { id: 'open', kind: 'number', title: 'Open features', filter: OPEN },\n { id: 'days', kind: 'number', title: 'Days of work left', aggregation: 'sum', field: 'effort', filter: OPEN, caption: 'Team capacity 40 days' },\n { id: 'shipped', kind: 'progress', title: 'Shipped', filter: SHIPPED },\n { id: 'status', kind: 'chart', chart: { kind: 'bar', x: 'status' } },\n { id: 'wanted', kind: 'list', title: 'Most wanted', sortBy: 'votes', sortDesc: true, limit: 3 },\n ],\n}\n```\n\nA dashboard is a grid of tiles. Each tile reads the records of one table,\nkeeps the ones its `filter` matches (the same `FieldFilter` as a view's\nfilter), and shows one of four things:\n\n- **`'number'`** counts the records, or with `aggregation: 'sum' | 'avg' |\n 'min' | 'max'` and a number `field`, adds them up. The number is written the\n way the field writes it, so a currency field shows \"$42,000\". Here \"Open\n features\" reads 3 and \"Days of work left\" reads 30. `caption` is a line\n under the number.\n- **`'chart'`** takes a chart view's `chart` setting (`kind`, `x`, `y`,\n `aggregation`) and groups the tile's records the same way.\n- **`'list'`** shows the first `limit` records (5 by default) sorted by\n `sortBy`, with that field's value beside each name (\"Single sign-on with\n SAML 182\"); `detail` shows another field instead. A click opens the record.\n- **`'progress'`** shows how many of all the table's records match the filter:\n \"25%, 1 of 4 records\" for Shipped.\n\n`size` is `'1x1'`, `'2x1'` or `'2x2'` (columns by rows). A number or progress\ntile is `'1x1'` by default, a chart or list `'2x2'`. Below about 450px the\ntiles stack in one column. A tile without `title` is named after what it\nshows (\"Total Effort (days)\", \"Status is Shipped\").\n\nWith several tables (`<SvBase bind:tables>`), a tile's `table` names any\ntable of the base, so a dashboard on Deals can count Accounts and list the\nActivities due this week. A tile without `table` reads the table the view is\non. Its filter and fields are that table's.\n\nA number or progress tile is a button: a click, or Enter, lists the records\nit counts (\"Open the 3 records\") in a dialog, each with its name and a few\nof its fields. On a chart, a click on a bar or a slice lists the records in\nit: the records the tile's filter keeps that fall in that bucket. A click on a record in the dialog opens it, in its\nown table's tab when the tile reads another table. While the dashboard is\nbeing edited, the tiles open nothing.\n\n\"Edit dashboard\" at the top of the view adds a tile, and on each tile sets its\nsize, moves it (drag it, or the arrows), edits it in a dialog (kind, table,\nvalue, filter, title, size) or removes it. Every change is saved in the view's\n`dashboard` at once and reaches `onViewsChange` and `onTablesChange`. A locked\nview has no \"Edit dashboard\". The view bar shows only the view switcher on a\ndashboard.\n\n<div data-docs-demo=\"721-base-dashboard\" data-height=\"680\"></div>\n\n## 10. A list for the phone\n\n```ts\nconst list: FieldView = {\n id: 'list',\n name: 'Feature list',\n type: 'list',\n listFields: ['status', 'teams', 'votes'],\n state: { sorting: [{ id: 'quarter', desc: false }, { id: 'votes', desc: true }], grouping: ['quarter'], hiddenColumns: [], advancedFilter: null },\n}\n```\n\nA list shows one record per entry: the primary field in bold, and under it\nthe fields in `listFields` (column ids, in order), each drawn as its cell\ndraws it, so Status is a colored pill and Teams are tags. An empty value is\nleft out. Without `listFields` the list shows the next three fields the grid\nshows. Long names stay readable at phone width, where a grid would cut them.\n\nThe list keeps the view's filter, sorts and groups. Here it is grouped by\nQuarter: a header per quarter with the field's name, its value and the\nnumber of records, \"Quarter Q4 2026 3\", and a click on the header folds the\ngroup. Within each quarter the most voted feature comes first. Grouped by\nmore fields (`grouping: ['quarter', 'status']`), each quarter holds a header\nper status, indented under it, with its own count and its own fold.\n\nA click on a record, or Enter, opens it. The list is one tab stop: Up and\nDown move between records and group headers at every level, Home and End\njump, Left and Right fold and unfold a group, and Left on a record or a\nfolded group moves to the group it is in. A record someone else changed and nobody here\nopened yet has a dot before its name.\n\nThe view bar has Hide fields, Filter, Group, Sort and \"Customize list\", which\nturns the fields under the name on and off and saves them in `listFields`.\n\n<div data-docs-demo=\"719-base-list-view\" data-height=\"620\"></div>\n\n## 11. An inbox of changes\n\n```ts\nconst inbox: FieldView = {\n id: 'inbox',\n name: 'Inbox',\n type: 'inbox',\n inboxDateField: 'start',\n listFields: ['status', 'lead'],\n}\n```\n\nAn inbox shows the records on the left and the picked one on the right: its\nfields, each one editable in place with the editor its cell uses, and its\nlatest changes, \"Cleo Park changed Status: Planned → In progress\". \"Expand\"\nopens the full record with its comments.\n\nThe list is newest first by `inboxDateField` (a date field's column id), so\n\"Audit log export\", which starts on January 11, is on top.\nRecords without a date go last. Without `inboxDateField` the inbox keeps the\nview's sort. The view's filter applies either way.\n\nA record someone else changed and nobody here has opened is unread: its name\nis bold and it has a dot. The changes come from a table with a `source` that\nhears of writes made elsewhere ([Changes made\nelsewhere](./data.md#changes-made-elsewhere)). Picking a record marks it read,\nas opening it in any view does, and \"Mark all read\" marks the rest. The count\nat the top says \"2 unread\" or \"All read\".\n\nDown or j picks the next record and Up or k the previous one; Enter opens the\nfull record. Narrower than 640px the inbox shows the list, and a picked record\nfills it with a Back button (Escape goes back too).\n\nThe view bar has Hide fields, Filter, Sort and \"Customize inbox\": the date\nfield it lists by and the fields under each name. A field hidden in the view\nleaves the record on the right too.\n\n<div data-docs-demo=\"720-base-inbox-view\" data-height=\"620\"></div>\n\n## 12. Keep the views\n\n`onViewsChange` fires with the whole list when a view is created, renamed,\nduplicated or deleted, and about 400ms after the shown view's settings stop\nchanging. Switching views stores the one being left first. Store the list\nwherever the app stores things.\n\nIn the browser:\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, type FieldView } from '@svgrid/enterprise/base'\n\n enableBase()\n const KEY = 'roadmap:views'\n const DEFAULT_VIEWS: FieldView[] = [{ id: 'all', name: 'All features', type: 'grid' }]\n\n function read<T>(key: string, fallback: T): T {\n try {\n const raw = localStorage.getItem(key)\n return raw ? (JSON.parse(raw) as T) : fallback\n } catch {\n return fallback\n }\n }\n function write(key: string, value: unknown) {\n try {\n localStorage.setItem(key, JSON.stringify(value))\n } catch {\n // Private mode or a full quota: the views still work, unsaved.\n }\n }\n\n let views = $state<FieldView[]>(read(KEY, DEFAULT_VIEWS))\n let activeView = $state<string>(read(`${KEY}:active`, ''))\n\n $effect(() => write(`${KEY}:active`, activeView))\n</script>\n\n<SvBase data={rows} {columns} primaryField=\"feature\" editable\n bind:views bind:activeView onViewsChange={(v: FieldView[]) => write(KEY, v)} />\n```\n\nOn a server, decide who owns a list.\n\n- **Per user.** Each person keeps their own list, so one lead's filter does\n not change another's. Seed it from the team's defaults the first time.\n- **Shared.** One list per table that everyone reads. Write it only for the\n people you allow; for everyone else, keep their changes in memory or in\n their own list. A shared \"My features\" view built on `ME` still shows each\n person their own records.\n\n```ts\ntype Scope = 'me' | 'team'\n\nasync function loadViews(scope: Scope): Promise<FieldView[]> {\n const res = await fetch(`/api/tables/features/views?scope=${scope}`)\n return res.ok ? ((await res.json()) as FieldView[]) : DEFAULT_VIEWS\n}\n\nfunction saveViews(scope: Scope, next: FieldView[]) {\n void fetch(`/api/tables/features/views?scope=${scope}`, {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(next),\n })\n}\n```\n\n```svelte\n{#await loadViews('me') then loaded}\n <SvBase data={rows} {columns} primaryField=\"feature\" editable\n views={loaded} onViewsChange={(v: FieldView[]) => saveViews('me', v)} />\n{/await}\n```\n\nOr mount at once and swap the list in when it arrives. When `views` or\n`activeView` changes from outside and the shown view is not the one the grid\nhas, the bar applies it. It never stores the grid's settings into a view it\nhas not applied yet.\n\n```svelte\n<script lang=\"ts\">\n let views = $state<FieldView[]>(DEFAULT_VIEWS)\n let loaded = false\n loadViews('me').then((v) => {\n views = v\n loaded = true\n })\n</script>\n\n<SvBase data={rows} {columns} primaryField=\"feature\" editable\n bind:views onViewsChange={(v: FieldView[]) => loaded && saveViews('me', v)} />\n```\n\nThe `loaded` check matters: about 400ms after mount the bar stores the\ndefault view's settings, and that save must not replace the list on the\nserver before the real one is in.\n\nWith several tables (`<SvBase bind:tables>`), each table keeps its own\n`views`, and `onTablesChange` hands back the whole list of tables, views\nincluded.\n\n## Personal and locked views\n\nOnce several people share a table, two more keys on a view matter:\n\n```ts\nconst views: FieldView[] = [\n // Only Ana sees it, under \"My views\" in the views menu.\n { id: 'ana-open', name: 'My open tasks', type: 'grid', personal: 'u1', state: { /* ... */ } },\n // Everyone sees it; nobody changes its settings until someone unlocks it.\n { id: 'report', name: 'Leadership report', type: 'grid', locked: true, lockedBy: 'u2', state: { /* ... */ } },\n]\n```\n\n- **`personal: userId`** lists the view only for that person, read from\n `setCurrentUser`. With nobody signed in every view is listed. \"Create\" in\n the views menu has a \"Personal view: only I see it\" box once someone is\n signed in.\n- **`locked: true`** keeps the view's filter, sorts, groups, hidden fields,\n colors and row height as saved. Its settings buttons are off, nothing is\n saved into it, and the bar shows \"Locked\" with who locked it. A sort from a\n column header still works for the moment; the bar then says \"Locked, not\n saved\" with a Reset. Records stay editable. A locked view cannot be\n deleted, and a copy of it starts unlocked.\n\nThe lock button in the views menu locks the view as the grid shows it now,\nor unlocks it. `lockViews={false}` on `SvBase` removes it for people who may\nnot lock views. Both keys come back through `onViewsChange` and\n`onTablesChange`, so the app stores a personal view with its owner the same\nway as the others.\n\n<div data-docs-demo=\"710-base-personal-locked-views\" data-height=\"620\"></div>\n\n## On a phone\n\nWhen a table is narrower than 600px (its own width, not the window's), a\ngrid view shows each record as a card: the primary field, then the next four\nfields the view shows, in the view's filter and sort. A tap opens the\nrecord, \"+\" adds one, and on a phone screen the opened record fills it. The\nview bar keeps its icons and the tab bar its tabs.\n\nA card keeps what a row can do. A long press, the button on the card, a\nright-click, the Menu key or Shift+F10 opens the record's menu: expand, comment,\nselect, insert above or below, duplicate and delete. A record selected this way\nshows on its card, as a ring on its list row, and in the selection bar. Copy and\npaste work on a cell, so they stay with the table. A gallery view and a list view\nhave the same menu.\n\nA Kanban lane takes the table's width, the next lane a swipe away and\nsnapped into place. A calendar opens in its agenda, the days listed one under\nanother, since a month of seven columns has no room for a title; Month, Week\nand Day are a tap away. Gallery cards stand one per row, and a form is one\ncolumn at any width.\n\n`phoneLayout` on `SvBase` moves the breakpoint (`phoneLayout={480}`), turns\nthe cards on at every width (`true`) or keeps the grid (`false`).\n\n<div data-docs-demo=\"713-base-phone-layout\" data-height=\"720\"></div>\n\n## Search across tables\n\nThe view bar's search finds records in the view on screen. The box at the\nend of the tab bar searches every table of the base. With the focus in the\nbase, Ctrl+K puts the cursor in it, and so does \"/\" outside the grid and any\ntext box. Neither is taken from the rest of the page.\n\nIt reads a field the way its cell shows it: a single select by its option's\nlabel, a person by name, a date as the field writes it, a link by the names\nof the records it links to, a formula or lookup by its result. Numbers,\ncurrency, percents, durations, ratings, checkboxes, buttons, rollups and\ncounts are not searched. Case and accents do not count: \"tomas\" finds\n\"Tomás\".\n\nEvery word of the query has to be in the record, in one field or another.\nThe results are grouped by table, five records each with \"N more in Deals\"\nunder them, each with its name, the field the words were found in and the\nwords marked. Records rank by:\n\n1. the whole query in one field, before words spread over several;\n2. the primary field, before the others;\n3. a field that is the query, then one that starts with it, then one with a\n word that starts with it, then one that holds it anywhere.\n\nTables are listed by their best record. Up and Down move through the list,\nEnter or a click shows the record's table and opens the record, and Escape\ncloses the list, then clears the box. `search={false}` on `SvBase` leaves the\nbox out. A shared base (`readOnly`) keeps it, over the tables and fields the\nshare shows.\n\nThe same search runs without the box, for a command palette of your own or\non a server:\n\n```ts\nimport { searchBase } from '@svgrid/enterprise/base'\n\nconst groups = searchBase(tables, 'northwind proposal', { limit: 10 })\nfor (const g of groups) {\n console.log(g.name, g.total)\n for (const hit of g.hits) console.log(hit.rowId, hit.title, `${hit.fieldName}: ${hit.text}`, hit.marks)\n}\n```\n\nEach hit has the table and record ids, the record's name (`title`), the\nfield that matched (`field`, `fieldName`, `primary`), its text cut around\nthe match when it is long, and `marks`, the `[start, end)` spans of the\nwords in that text. `field: (table, column) => boolean` in the options picks\nthe fields to search. To open a hit in `SvBase`, show its table\n(`bind:activeTable`) and call `openRecord({ api, rowId })` once that table's\ngrid has called `onApiReady`; the box does this for you.\n\n<div data-docs-demo=\"718-base-search-all-tables\" data-height=\"620\"></div>\n\n## View types and the keys they read\n\n| Type | Keys | View bar buttons |\n|---|---|---|\n| `'grid'` | `state`, `rowHeight`, `color` | Hide fields, Filter, Group, Sort, Color, Row height |\n| `'kanban'` | `stackBy`: a single select, or a user field with one person | Hide fields, Filter, Sort |\n| `'calendar'` | `dateField`, `endField` (optional), `color` | Hide fields, Filter, Sort, Color |\n| `'gantt'` | `dateField`, `endField`, `progressField`, `dependencyField`, `zoom`, `color` | Hide fields, Filter, Sort, Color, Customize timeline |\n| `'gallery'` | `coverField`: an attachment field | Hide fields, Filter, Sort |\n| `'chart'` | `chart`: `kind`, `x`, `y`, `aggregation` | Filter, Customize chart |\n| `'list'` | `listFields`: the fields under each name | Hide fields, Filter, Group, Sort, Customize list |\n| `'inbox'` | `inboxDateField`: a date field, newest first; `listFields` | Hide fields, Filter, Sort, Customize inbox |\n| `'form'` | `formFields`, `formRequired`, `formTitle`, `formDescription`, `formSubmitLabel`, `formConditions`, `formPrefill` | none |\n| `'dashboard'` | `dashboard`: the tiles, in order | none |\n| any type | `personal`, `locked`, `lockedBy` | off while `locked` |\n\nEvery type also keeps `state` (filter, sorts, groups, hidden fields, column\norder, widths, pinning) and switches with the grid's own state, so a filter\nset on the board is still there when you come back to it. The search text is\nnot part of it. The views menu's \"Create\" offers each type `SvBase` can show\nand greys out one the table cannot: a Kanban needs a single select, a\ncalendar a date field, a chart a field to group by. A new view starts with no\nfilter, sorts or groups and every field shown.\n`viewTypes={['grid', 'kanban', 'calendar']}` on `SvBase` limits what\n\"Create\" offers.\n\nA timeline (`type: 'gantt'`) is a calendar with a task table beside the bars.\n\"Create\" offers it as Timeline in every base, and its renderer loads the first\ntime one is shown. Its bars take the view's colors, `progressField` is a percent field drawn as each\nbar's fill, and `dependencyField` is a link field to the same table naming\nwhat each record waits for, drawn as arrows.\n\nA record's dates are its own: a drop on a Sunday stays on the Sunday. By keyboard a\nbar works as a calendar event does: Space picks it up, Left and Right carry it a day\n(Shift, a week), Space puts it down and Escape puts it back. Enter opens the record,\nShift+F10 opens its menu, and Delete asks first, as a row's menu does.\n\n## When an edit changes where a record belongs\n\nA view's filter, sort and groups apply again after an edit, with one pause. In a\ngrid the row you are working in stays where it is while it is the active row, so\nit does not leap away under the cursor; it takes its place when you move to\nanother row, click outside the grid, or close its record. The record count follows\nat the same moment. An undo, a paste and a fill apply at once. A board, a calendar,\na timeline, a gallery and a list show the change as soon as it is made, or when a\nrecord dialog closes. On a table read a page at a time the database is asked again\nat that moment, once it has the edit.\n\n## The view bar, panel by panel\n\n- **Views menu** (the view's name): switch, rename, duplicate (\"Roadmap by\n quarter copy\") and delete. Delete asks in the view's own row, and nothing moves\n until the answer. A deleted view goes to the trash and is one step of undo. The\n last view cannot be deleted.\n- **Hide fields**: a switch per field, a search, hide all and show all, and\n drag to reorder. The list keeps its order while you switch fields, and hidden\n fields sit where they are in the table. The primary field is always shown.\n- **Filter**: \"Where [field] [operator] [value]\" rows joined by \"and\" or\n \"or\", and condition groups. Each change filters at once. A condition still\n missing its value filters nothing.\n- **Group**: up to three fields, each with a direction.\n- **Sort**: fields in order, each with a direction labeled for its type (\"1\n → 9\", \"A → Z\", \"first → last\" for a single select). Attachment and button\n fields are not offered.\n- **Color**: None, Select field (a single select's option colors) or\n Conditions in order.\n- **Row height**: Short 34, Medium 56, Tall 88, Extra tall 128.\n `rowHeights` on `SvBase` or `SvBaseViewBar` sets the list.\n- **Search**: in a grid view, the grid's find bar (Ctrl+F) that marks every\n match. In a board, calendar, gallery, list or inbox, a \"Find a record\" box\n that narrows the records. Switching views clears it.\n- **Search all tables**: the box in the tab bar (below).\n\nA button with something set says so and is tinted. With `fieldMenu` on, each\ncolumn's menu adds \"Filter by this field\" and \"Group by this field\", which\nopen the bar's panel with the new condition or group in it.\n\n## Filters in code\n\n`filterKindOf(columnDef)` gives the kind a field filters as, and\n`operatorsFor(kind)` the operators the panel offers for it, in menu order.\n[Filter conditions](../fields.md#filter-conditions) maps each field type to\nits kind.\n\n| `kind` | `op` values | `value` |\n|---|---|---|\n| `'text'`, `'link'` | `contains`, `notContains`, `is`, `isNot` | a string; a link compares the linked records' names |\n| `'number'` | `eq`, `neq`, `lt`, `gt`, `lte`, `gte` | a number |\n| `'select'` | `is`, `isNot` | one option value, or a person's id (or `ME`) for a user field |\n| `'select'` | `isAnyOf`, `isNoneOf` | an array of them |\n| `'multi'` | `hasAnyOf`, `hasAllOf`, `isExactly`, `hasNoneOf` | an array of option values or ids |\n| `'checkbox'` | `is` | `true` or `false` |\n| `'date'` | `is`, `isBefore`, `isAfter`, `isOnOrBefore`, `isOnOrAfter` | `{ mode: 'today' }`, with `mode` also `'tomorrow'`, `'yesterday'`, `'oneWeekAgo'`, `'oneWeekFromNow'`, `'oneMonthAgo'`, `'oneMonthFromNow'`; or `{ mode: 'exactDate', date: '2026-11-01' }` |\n| `'date'` | `isWithin` | `{ span: 'pastWeek' }`, with `span` also `'pastMonth'`, `'pastYear'`, `'nextWeek'`, `'nextMonth'`, `'nextYear'`; or `{ span: 'pastDays', days: 14 }`, `{ span: 'nextDays', days: 14 }` |\n| `'files'` | `contains` (file name contains) | a string |\n\nEvery kind except checkbox also takes `isEmpty` and `isNotEmpty`, with no\nvalue. A few rules from the code:\n\n- An empty number cell is no number: it matches only `neq`.\n- Dates compare whole days. A bare `'2026-11-01'` is that day where the user\n is, and \"within the past week\" runs from 7 days ago to today.\n- A user condition holds the person's id (`'u2'`), not the name, or `ME`\n for whoever is signed in.\n- A link condition sets `table` to the linked table's id, so it can match\n records by name.\n\nSet a filter on the shown view with `api.setAdvancedFilter(filter)`; the\nview keeps it like one set in the panel.\n\n## Row colors: by field or by conditions\n\n```ts\nimport type { ColorSetting } from '@svgrid/enterprise/base'\n\nconst byStatus: ColorSetting = { mode: 'field', field: 'status' }\nconst byRisk: ColorSetting = {\n mode: 'conditions',\n rules: [\n { color: '#f82b60', condition: { column: 'status', kind: 'select', op: 'is', value: 'Blocked' } },\n { color: '#fcb400', condition: { column: 'target', kind: 'date', op: 'isBefore', value: { mode: 'today' } } },\n ],\n}\n```\n\nBy field, each row takes its option's color, and the row header's title says\nthe option, so the color is never the only signal. A multiple select colors\nby its first value. By conditions, the first rule that matches wins: a\nblocked feature is red even when it is also late. A condition is tested as\nthe filter tests it: on the value the cell shows, so a formula, lookup,\nrollup or count field works, and a condition still missing its value colors\nnothing. A calendar colors its events by a single select only; a Gantt's bars\ntake either kind.\n\nThe color is a 3px stripe on the row header, unless the `rowColor` prop on\n`SvBase` sets a `target` (`'bar'` or `'row'`): a view's colors use it too. A\nview without `color` shows the `rowColor` prop's colors until someone picks\ncolors for it in Color. `{ mode: 'none' }` turns the colors off in that view.\n\n## Summaries in the footer and in group headers\n\nWith `summary` on, a click on a field's footer cell picks its summary: sum,\naverage, median, min, max or range for numbers; checked, unchecked or percent\nchecked for a checkbox; earliest, latest or the date range in days for dates;\nempty, filled, unique, percent empty or percent filled for any field. The\nresult is written as the field writes values. The choice is stored in the\nfield's `fieldProps.summary` and reported through `onColumnChange`; see\n[Summaries at the bottom](../fields.md#summaries-at-the-bottom).\n\nGroup headers show the same summaries over that group's records. Both leave\nout records the filter hides, even in a collapsed group.\n\n## The view bar over your own grid\n\n`SvBaseViewBar` is the bar alone, for a page that lays out its own\n`<SvGrid>`:\n\n```svelte\n<script lang=\"ts\">\n import { SvGrid } from '@svgrid/grid'\n import { SvBaseViewBar, enableBase, type FieldView } from '@svgrid/enterprise/base'\n\n enableBase()\n // Raw: the bar finds its grid by the api object itself, and a proxy is another object.\n let api = $state.raw<any>(null)\n let views = $state<FieldView[]>([\n { id: 'all', name: 'All features', type: 'grid' },\n { id: 'board', name: 'Status board', type: 'kanban', stackBy: 'status' },\n ])\n let activeView = $state('all')\n</script>\n\n{#if api}\n <SvBaseViewBar {api} bind:views bind:activeView\n rowHeights={[{ label: 'Compact', height: 32 }, { label: 'Roomy', height: 64 }]} />\n{/if}\n<SvGrid data={rows} {columns} primaryField=\"feature\" editable containerHeight={600}\n onApiReady={(a) => (api = a)} />\n```\n\nIts \"Create\" offers grid, Kanban and calendar (and Gantt once enabled). It\nloads the board, calendar and gallery renderers the first time a view of\nthat type is shown, and opens the record and the \"Delete record?\" question\nfor a card's menu. Chart and form views are drawn by `SvBase`, not by the\nbar, so leave them out of `viewTypes` here, or draw `SvBaseForm` yourself\nwhen a form view is active.\n\n## Pitfalls\n\n- **A new view from \"Create\" starts with `color: { mode: 'none' }`**, so it\n hides the `rowColor` prop's colors. A new calendar or Gantt is the\n exception: it starts colored by the first single select. Pick colors in\n Color, or declare the view in code without `color`.\n- **`color.field` is the data field; the other keys are column ids.** They\n differ only when a column sets an `id`.\n- **Summaries belong to the field, not the view.** Picking \"Average\" in one\n view changes every view's footer and group headers.\n- **Save views only after they load.** See the `loaded` check in step 12.\n\n## Next\n\n- [Linked records](./linked-records.md): link Features to Feedback and chart\n or filter by the linked names.\n- [Formulas](./formulas.md): computed fields a view can sort, group and chart\n by.\n- [Forms](./forms.md): required fields, the thank-you screen and forms\n outside the base.\n- [Collaboration](./collaboration.md): comments, people and who changed what.\n- [Automations](./automations.md): conditions written with this same filter.\n- [Keep a base in a database](./data.md): load the tables from Postgres,\n Supabase or your API and write every change back.\n"
5307
+ "markdown": "# Views for every team\n\nOne table of records, many ways to look at it. Product reads the roadmap\ngrouped by quarter, engineering works off a status board, the leads check a\ntimeline, and anyone in the company files a request through a form. Each of\nthose is a saved view: a name, a type, and the filter, sorts, groups, hidden\nfields, row height and colors it had when someone last left it.\n\n![The Features table feeds six saved views: Roadmap by quarter (a grid grouped by Quarter, sorted by Impact, Lead hidden, row height 56, colored by Status), Now (a grid filtered to active work), Status board (a Kanban stacked by Status), Timeline (bars from Start to Target), Effort by team (a bar chart) and Request a feature (a form). onViewsChange hands the whole list to the app, which stores it and loads it back into bind:views.](/docs-media/base-views.svg)\n\n<div data-docs-demo=\"513-base-product-roadmap\" data-height=\"680\"></div>\n\n> SvGrid Base is part of the **Suite edition** of `@svgrid/enterprise`. Without a key it runs with a watermark.\n\nThis page builds the Features table of that roadmap one view at a time. Each\nstep adds to the `views` list from the step before and works on its own.\n\n## 1. The table\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, setFieldUsers, type FieldView } from '@svgrid/enterprise/base'\n\n enableBase()\n setFieldUsers([\n { id: 'u1', name: 'Ana Ruiz' },\n { id: 'u2', name: 'Ben Okafor' },\n { id: 'u3', name: 'Cleo Park' },\n ])\n\n type Feature = {\n id: number; feature: string; quarter: string; status: string; teams: string[]\n lead: string; impact: number; effort: number; start: string; target: string; votes: number\n }\n\n const QUARTERS = [\n { value: 'Q4 2026', color: '#2d7ff9' },\n { value: 'Q1 2027', color: '#18bfff' },\n { value: 'Later', color: '#94a3b8' },\n ]\n const STATUS = [\n { value: 'Planned', color: '#94a3b8' },\n { value: 'In progress', color: '#2d7ff9' },\n { value: 'In beta', color: '#8b46ff' },\n { value: 'Shipped', color: '#20c933' },\n { value: 'Blocked', color: '#f82b60' },\n ]\n const TEAMS = [\n { value: 'Web', color: '#2d7ff9' },\n { value: 'Mobile', color: '#ff6f2c' },\n { value: 'Platform', color: '#8b46ff' },\n ]\n\n let rows = $state.raw<Feature[]>([\n { id: 1, feature: 'Single sign-on with SAML', quarter: 'Q4 2026', status: 'In progress', teams: ['Platform'], lead: 'u2', impact: 5, effort: 12, start: '2026-10-05', target: '2026-11-13', votes: 182 },\n { id: 2, feature: 'Offline mode for the mobile app', quarter: 'Q4 2026', status: 'Blocked', teams: ['Mobile'], lead: 'u3', impact: 4, effort: 13, start: '2026-10-12', target: '2026-12-04', votes: 96 },\n { id: 3, feature: 'Dark mode', quarter: 'Q4 2026', status: 'Shipped', teams: ['Web'], lead: 'u1', impact: 2, effort: 4, start: '2026-10-01', target: '2026-10-16', votes: 154 },\n { id: 4, feature: 'Audit log export', quarter: 'Q1 2027', status: 'Planned', teams: ['Platform', 'Web'], lead: 'u1', impact: 3, effort: 5, start: '2027-01-11', target: '2027-01-29', votes: 41 },\n ])\n\n const columns = [\n { field: 'feature', header: 'Feature', width: 260, fieldType: 'text' },\n { field: 'quarter', header: 'Quarter', fieldType: 'singleSelect', fieldProps: { options: QUARTERS } },\n { field: 'status', header: 'Status', fieldType: 'singleSelect', fieldProps: { options: STATUS } },\n { field: 'teams', header: 'Teams', fieldType: 'multiSelect', fieldProps: { options: TEAMS } },\n { field: 'lead', header: 'Lead', fieldType: 'user' },\n { field: 'impact', header: 'Impact', fieldType: 'rating', fieldProps: { max: 5 } },\n { field: 'effort', header: 'Effort (days)', fieldType: 'number', fieldProps: { format: 'integer', summary: 'sum' } },\n { field: 'start', header: 'Start', fieldType: 'date', fieldProps: { dateFormat: 'friendly' } },\n { field: 'target', header: 'Target', fieldType: 'date', fieldProps: { dateFormat: 'friendly' } },\n { field: 'votes', header: 'Votes', fieldType: 'number', fieldProps: { format: 'integer', summary: 'sum' } },\n ]\n\n let views = $state<FieldView[]>([{ id: 'all', name: 'All features', type: 'grid' }])\n</script>\n\n<SvBase data={rows} {columns} bind:views primaryField=\"feature\"\n editable sortable showRowNumbers expandRows summary containerHeight={640}\n rowAdder={{ label: 'Add feature', defaults: () => ({ id: Date.now(), status: 'Planned', quarter: 'Later', teams: [] }) }} />\n```\n\nThe view bar over the grid has \"All features\" on the left, then Hide\nfields, Filter, Group, Sort, Color and a row height button, and \"4 records\"\nwith a search button on the right. The footer row shows \"Sum 34\" under Effort\nand \"Sum 473\" under Votes, because those fields set `fieldProps.summary`.\n\nEvery view key that names a field (`stackBy`, `dateField`, a filter\ncondition's `column`, a chart's `x`) takes the column id. A column without an\n`id` uses its `field`, so in this table the two are the same.\n\n## 2. A roadmap grouped by quarter\n\nA view can start with settings. `state` is the grid's own state, the same\nobject `api.getState()` returns; `color` says how rows are colored.\n\n```ts\nconst roadmap: FieldView = {\n id: 'roadmap',\n name: 'Roadmap by quarter',\n type: 'grid',\n color: { mode: 'field', field: 'status' },\n rowHeight: 56,\n state: {\n grouping: ['quarter'],\n sorting: [{ id: 'quarter', desc: false }, { id: 'impact', desc: true }],\n hiddenColumns: ['lead'],\n },\n}\n```\n\nGroups and sorts share the grid's `sorting` list: a grouped field's\ndirection is an entry ahead of the sorts. The view bar writes them that way,\nso write them that way too. Here the bar reads \"1 hidden field\", \"Grouped by\n1 field\" and \"Sorted by 1 field\": the `quarter` entry belongs to the group,\nnot to Sort.\n\nEach group header shows \"Quarter\" over the option's pill, the number of\nrecords, the summaries the fields picked for that group (\"Effort (days) 29\",\n\"Votes 432\"), and \"+\" to add a feature that already has that quarter. Groups\ncome in the select's option order, not alphabetically. Group rows are at\nleast 52px tall so the field's name fits over the value; with\n`rowHeight: 56` they match the records. Each row has a status color stripe\non its row header. 56 is the row height menu's \"Medium\": from 48px, text and\nselect pills wrap.\n\n## 3. A view that starts filtered\n\nThe filter is the grid's advanced filter with its own kind, `fieldFilter`.\nPut it in `state.advancedFilter`:\n\n```ts\nimport { describeFieldFilter, type FieldFilter } from '@svgrid/enterprise/base'\n\nconst activeWork: FieldFilter = {\n kind: 'fieldFilter',\n conjunction: 'and',\n conditions: [\n { column: 'status', kind: 'select', op: 'isAnyOf', value: ['In progress', 'In beta', 'Blocked'] },\n {\n conjunction: 'or',\n conditions: [\n { column: 'target', kind: 'date', op: 'isWithin', value: { span: 'nextDays', days: 30 } },\n { column: 'impact', kind: 'number', op: 'gte', value: 4 },\n ],\n },\n ],\n}\n\nconst now: FieldView = {\n id: 'now',\n name: 'Now',\n type: 'grid',\n state: { sorting: [{ id: 'target', desc: false }], advancedFilter: activeWork },\n}\n\nconst header = (id: string) => columns.find((c) => c.field === id)?.header ?? id\ndescribeFieldFilter(activeWork, header)\n// \"Status is any of In progress, In beta, Blocked and (Target is within the next 30 days or Impact ≥ 4)\"\n```\n\nThe Filter button reads \"Filtered by 3 fields\" (one field reads \"Filtered by\nStatus\") and the record count drops to what the filter keeps.\n`describeFieldFilter` writes a filter in the words the panel uses, for a page\nsubtitle or an audit line. It returns `\"every record\"` for a filter with no\ncomplete conditions.\n\nA condition is a field, an operator and a value; a group is one level deep.\n[Filters in code](#filters-in-code) below lists the operators per kind.\n\nOne view can serve every lead. `ME` (the string `'@me'`) in a person\ncondition stands for whoever `setCurrentUser` names when the filter runs; the\nFilter panel lists it as \"Me\", first among the people.\n\n```ts\nimport { ME, setCurrentUser } from '@svgrid/enterprise/base'\n\nsetCurrentUser({ id: 'u2', name: 'Ben Okafor' })\n\nconst mine: FieldView = {\n id: 'mine',\n name: 'My features',\n type: 'grid',\n state: {\n advancedFilter: {\n kind: 'fieldFilter',\n conjunction: 'and',\n conditions: [{ column: 'lead', kind: 'select', op: 'is', value: ME }],\n },\n },\n}\n```\n\nBen sees \"Single sign-on with SAML\"; Ana, signed in, sees her two. With\nnobody signed in the condition matches no one. `describeFieldFilter` writes\nit as \"Lead is me\".\n\n## 4. A status board\n\n```ts\nconst board: FieldView = { id: 'board', name: 'Status board', type: 'kanban', stackBy: 'status' }\n```\n\n![The roadmap's Status board: Planned, In progress, In beta and Shipped lanes of feature cards showing Quarter, Teams and Lead, with the right-click menu open on \"Single sign-on with SAML\": Expand record, Comment, Move to, Duplicate record, Delete record.](/docs-media/base-views.png)\n\n`stackBy` takes a single select or a user field that holds one person. You\nget one lane per option, in option order and color, plus \"Uncategorized\",\nwhich shows only while a record has no status. Stack by `lead` instead and\nthe lanes are the people from `setFieldUsers`.\n\nSort the view by a number field and a card dropped elsewhere in its lane takes\na number between its neighbours', so the order is the table's and lasts.\n\nDrop a card in another lane and the status changes through the grid's edit\npath, so undo, validation and `onCellValueChange` all see it. \"+ Add a card\"\nadds a record already in that lane, named by the primary field.\n\nA card shows the record's name, then the next three fields the view shows,\nin column order (the stacked field left out), each drawn as its cell draws\nit. Hide a field in Hide fields and it leaves the cards; drag it up there to\nput it on them. Cards are read, not edited: a rating shows its stars\nbut does not take a click. Double-click a card or press F2 to open the\nrecord. Right-click it for its menu: Expand record, Comment, and, when the\nbase is `editable`, Move to (a submenu of the lanes), Duplicate record and\nDelete record, which asks \"Delete record?\" first. A card with comments shows\ntheir count; click it to open the record at its comment box.\n\n## 5. A timeline\n\n```ts\nconst timeline: FieldView = {\n id: 'timeline',\n name: 'Timeline',\n type: 'gantt',\n dateField: 'start',\n endField: 'target',\n color: { mode: 'field', field: 'status' },\n}\n```\n\nEach feature is a bar from its start to its target date, beside a table of\nnames and dates. Drag a bar to move both dates; drag its edge to change the\ntarget. One drag is one Ctrl+Z. `type: 'calendar'` with the same fields shows\nthe features on a month instead: a date field without a time shows as all-day\nevents. The end of a bar or an event is exclusive, so the record keeps the last\nday: a feature dragged to cover the 19th to the 21st gets\n`target: '2026-10-21'`.\n\nWith only `dateField`, events move but cannot be resized. Pick a day (or a\nrange) on the calendar and a new record lands on it, opened with its name\nready to type. Colored by a single select, the events take the option colors\nand the options appear above the calendar as a legend that hides and shows\nthem.\n\nMoving and resizing need `editable` on the base. Without it the calendar is\nread-only.\n\n## 6. Effort by team\n\n```ts\nconst effort: FieldView = { id: 'effort', name: 'Effort by team', type: 'chart', chart: { kind: 'barH', x: 'teams', y: 'effort' } }\nconst mix: FieldView = { id: 'mix', name: 'Features per quarter', type: 'chart', chart: { kind: 'donut', x: 'quarter' } }\n```\n\nA chart groups the records the view shows by `x` and adds up `y` (or counts\nrecords when there is no `y`). `aggregation: 'avg'` averages instead of\nsumming. Kinds are `'bar'`, `'barH'`, `'line'`, `'pie'` and `'donut'`.\n\nHow `x` groups:\n\n- A single or multiple select keeps its options' order and colors. A\n multiple select counts a record in each of its options, so \"Audit log\n export\" adds 5 days to both Platform and Web.\n- A person or a linked record shows by name.\n- A date groups by month (\"Oct 2026\").\n- Records with no value go in an \"Empty\" bar, last.\n\nValues read as the summed field writes them, and a count as a whole number.\nThe series is labeled \"Sum of Effort (days)\", \"Average of ...\" or \"Records\".\nThe bar shows Filter, which narrows what is charted, and \"Customize chart\",\nwhose Type, Group by, Value and Combine (sum or average) are kept in `chart`.\nA chart view declared without `chart` draws \"Choose a field to chart in\nCustomize chart.\" until a field is picked there.\n\n## 7. A gallery of mockups\n\nAdd an attachment field, then a gallery view with it as the cover:\n\n```ts\nconst mockupField = { field: 'mockups', header: 'Mockups', fieldType: 'attachment' }\nconst gallery: FieldView = { id: 'mockups', name: 'Mockups', type: 'gallery', coverField: 'mockups' }\n```\n\nEach card shows the first image of `mockups`, the primary field as its title,\nthen the fields the grid shows, each drawn as its cell draws it. Hide a field\nin this view and it leaves the cards; drag fields in Hide fields to reorder\nthem. A click on a card opens the record. Without `coverField` the cards have\nno cover.\n\n## 8. A request form\n\n```ts\nconst request: FieldView = {\n id: 'request',\n name: 'Request a feature',\n type: 'form',\n formFields: ['feature', 'teams', 'impact'],\n formRequired: ['feature'],\n formTitle: 'Request a feature',\n formDescription: 'What should we build, and who is it for? Product reviews requests every Friday.',\n formSubmitLabel: 'Send request',\n}\n```\n\nThe form asks for the fields in `formFields` (column ids, in order), each with\nthe editor its cell uses. Without it, the form asks for every field a person\ncan fill in, the primary field first; computed fields are left out. A field\nin `formRequired` must be filled before the form sends. `formTitle` defaults\nto the view's name, `formSubmitLabel` to \"Submit\". A sent form adds a record\nthe way \"+ Add row\" does: `rowAdder.defaults` first, so a request starts as\nPlanned in Later, then what was typed, then `onRowAdd`. The bar shows only\nthe view switcher on a form.\n\nAll the views so far, in one list:\n\n```ts\nlet views = $state<FieldView[]>([roadmap, board, timeline, effort, now, mine, gallery, request])\n```\n\n## 9. A dashboard\n\n```ts\nconst OPEN: FieldFilter = { kind: 'fieldFilter', conjunction: 'and', conditions: [{ column: 'status', kind: 'select', op: 'isNot', value: 'Shipped' }] }\nconst SHIPPED: FieldFilter = { kind: 'fieldFilter', conjunction: 'and', conditions: [{ column: 'status', kind: 'select', op: 'is', value: 'Shipped' }] }\n\nconst overview: FieldView = {\n id: 'overview',\n name: 'Overview',\n type: 'dashboard',\n dashboard: [\n { id: 'open', kind: 'number', title: 'Open features', filter: OPEN },\n { id: 'days', kind: 'number', title: 'Days of work left', aggregation: 'sum', field: 'effort', filter: OPEN, caption: 'Team capacity 40 days' },\n { id: 'shipped', kind: 'progress', title: 'Shipped', filter: SHIPPED },\n { id: 'status', kind: 'chart', chart: { kind: 'bar', x: 'status' } },\n { id: 'wanted', kind: 'list', title: 'Most wanted', sortBy: 'votes', sortDesc: true, limit: 3 },\n ],\n}\n```\n\nA dashboard is a grid of tiles. Each tile reads the records of one table,\nkeeps the ones its `filter` matches (the same `FieldFilter` as a view's\nfilter), and shows one of four things:\n\n- **`'number'`** counts the records, or with `aggregation: 'sum' | 'avg' |\n 'min' | 'max'` and a number `field`, adds them up. The number is written the\n way the field writes it, so a currency field shows \"$42,000\". Here \"Open\n features\" reads 3 and \"Days of work left\" reads 30. `caption` is a line\n under the number.\n- **`'chart'`** takes a chart view's `chart` setting (`kind`, `x`, `y`,\n `aggregation`) and groups the tile's records the same way.\n- **`'list'`** shows the first `limit` records (5 by default) sorted by\n `sortBy`, with that field's value beside each name (\"Single sign-on with\n SAML 182\"); `detail` shows another field instead. A click opens the record.\n- **`'progress'`** shows how many of all the table's records match the filter:\n \"25%, 1 of 4 records\" for Shipped.\n\n`size` is `'1x1'`, `'2x1'` or `'2x2'` (columns by rows). A number or progress\ntile is `'1x1'` by default, a chart or list `'2x2'`. Below about 450px the\ntiles stack in one column. A tile without `title` is named after what it\nshows (\"Total Effort (days)\", \"Status is Shipped\").\n\nWith several tables (`<SvBase bind:tables>`), a tile's `table` names any\ntable of the base, so a dashboard on Deals can count Accounts and list the\nActivities due this week. A tile without `table` reads the table the view is\non. Its filter and fields are that table's.\n\nA number or progress tile is a button: a click, or Enter, lists the records\nit counts (\"Open the 3 records\") in a dialog, each with its name and a few\nof its fields. On a chart, a click on a bar or a slice lists the records in\nit: the records the tile's filter keeps that fall in that bucket. A click on a record in the dialog opens it, in its\nown table's tab when the tile reads another table. While the dashboard is\nbeing edited, the tiles open nothing.\n\n\"Edit dashboard\" at the top of the view adds a tile, and on each tile sets its\nsize, moves it (drag it, or the arrows), edits it in a dialog (kind, table,\nvalue, filter, title, size) or removes it. Every change is saved in the view's\n`dashboard` at once and reaches `onViewsChange` and `onTablesChange`. A locked\nview has no \"Edit dashboard\". The view bar shows only the view switcher on a\ndashboard.\n\n<div data-docs-demo=\"721-base-dashboard\" data-height=\"680\"></div>\n\n### Text, buttons, images, dividers and a record picker\n\nA dashboard can also say, show and link to things, which makes it a page of\nan app rather than only a summary (Airtable's \"blank\" interface layout):\n\n```ts\nconst home: FieldView = {\n id: 'home',\n name: 'Home',\n type: 'dashboard',\n dashboard: [\n { id: 'hello', kind: 'text', text: '# Welcome\\nYour open requests are below. See [the guide](https://example.com/guide).' },\n { id: 'help', kind: 'button', label: 'Ask for help', url: 'https://example.com/help' },\n { id: 'logo', kind: 'image', url: '/img/office.jpg', alt: 'Our office', fit: 'cover' },\n { id: 'sec', kind: 'divider', title: 'By account' },\n { id: 'account', kind: 'picker', table: 'accounts', title: 'Account', fields: ['city', 'owner'] },\n { id: 'deals', kind: 'number', title: 'Deals', pickedBy: { tile: 'account', field: 'account' } },\n ],\n}\n```\n\n- **`'text'`**: `text` in a small part of Markdown: a line starting with `#`\n is a heading, a blank line starts a paragraph, `**bold**` and\n `[words](https://...)` links inside lines. It is drawn as text, never as\n HTML, so what anyone types shows as typed.\n- **`'button'`**: `label` (default \"Open\") and `url`. An address on another\n site opens in a new tab; a path (`/...`) in the same one.\n- **`'image'`**: `url` and `alt` (said to people who cannot see it); `fit` is\n `'contain'` (the whole picture, default) or `'cover'` (the tile filled).\n- **`'divider'`**: a line across the whole dashboard with its `title` over\n it, to start a section.\n- **`'picker'`**: the records of its `table` to choose from by name; the one\n picked shows its `fields` (default: the next four after its name) and an\n \"Open the record\" button.\n\nLinks and pictures go only to `https:`, `http:`, `mailto:` (a link) or a path\non the site: a `javascript:` or `data:` address is shown as words, not\nfollowed.\n\nA number, chart, list or progress tile with `pickedBy: { tile, field }` is\nnarrowed by that picker: once a record is picked, it counts only the records\nwhose link field `field` holds it (\"the deals of the account picked\"), and\n\"Every record\" counts them all again. The pick is the viewer's and is not\nsaved. Under the hood the tile's filter gains a condition of the kind\n`'linked'`:\n\n```ts\nconst narrowing = { column: 'account', kind: 'linked', op: 'hasAnyOf', value: ['a1'] } // the link holds record a1, by id\n```\n\nFor a table the page holds, the page applies it. For a table read from a\nserver (`serverRows`), the server must apply it too: `fieldFilterToSql` and\n`fieldFilterToPostgrest` answer that they cannot (the tile then shows what\nthe server sends), so a server of your own reads `kind: 'linked'` and matches\nthe link's record ids.\n\nIn the tile dialog, \"Shows\" offers these kinds too; a picker's tile picks its\nfields, and the tiles it can narrow offer \"Narrowed by\" with each picker the\ntile's table links to. Dividers take one row across the dashboard; the other\ntiles keep their sizes.\n\n## 10. A list for the phone\n\n```ts\nconst list: FieldView = {\n id: 'list',\n name: 'Feature list',\n type: 'list',\n listFields: ['status', 'teams', 'votes'],\n state: { sorting: [{ id: 'quarter', desc: false }, { id: 'votes', desc: true }], grouping: ['quarter'], hiddenColumns: [], advancedFilter: null },\n}\n```\n\nA list shows one record per entry: the primary field in bold, and under it\nthe fields in `listFields` (column ids, in order), each drawn as its cell\ndraws it, so Status is a colored pill and Teams are tags. An empty value is\nleft out. Without `listFields` the list shows the next three fields the grid\nshows. Long names stay readable at phone width, where a grid would cut them.\n\nThe list keeps the view's filter, sorts and groups. Here it is grouped by\nQuarter: a header per quarter with the field's name, its value and the\nnumber of records, \"Quarter Q4 2026 3\", and a click on the header folds the\ngroup. Within each quarter the most voted feature comes first. Grouped by\nmore fields (`grouping: ['quarter', 'status']`), each quarter holds a header\nper status, indented under it, with its own count and its own fold.\n\nA click on a record, or Enter, opens it. The list is one tab stop: Up and\nDown move between records and group headers at every level, Home and End\njump, Left and Right fold and unfold a group, and Left on a record or a\nfolded group moves to the group it is in. A record someone else changed and nobody here\nopened yet has a dot before its name.\n\nThe view bar has Hide fields, Filter, Group, Sort and \"Customize list\", which\nturns the fields under the name on and off and saves them in `listFields`.\n\n<div data-docs-demo=\"719-base-list-view\" data-height=\"620\"></div>\n\n## 11. An inbox of changes\n\n```ts\nconst inbox: FieldView = {\n id: 'inbox',\n name: 'Inbox',\n type: 'inbox',\n inboxDateField: 'start',\n listFields: ['status', 'lead'],\n}\n```\n\nAn inbox shows the records on the left and the picked one on the right: its\nfields, each one editable in place with the editor its cell uses, and its\nlatest changes, \"Cleo Park changed Status: Planned → In progress\". \"Expand\"\nopens the full record with its comments.\n\nThe list is newest first by `inboxDateField` (a date field's column id), so\n\"Audit log export\", which starts on January 11, is on top.\nRecords without a date go last. Without `inboxDateField` the inbox keeps the\nview's sort. The view's filter applies either way.\n\nA record someone else changed and nobody here has opened is unread: its name\nis bold and it has a dot. The changes come from a table with a `source` that\nhears of writes made elsewhere ([Changes made\nelsewhere](./data.md#changes-made-elsewhere)). Picking a record marks it read,\nas opening it in any view does, and \"Mark all read\" marks the rest. The count\nat the top says \"2 unread\" or \"All read\".\n\nDown or j picks the next record and Up or k the previous one; Enter opens the\nfull record. Narrower than 640px the inbox shows the list, and a picked record\nfills it with a Back button (Escape goes back too).\n\nThe view bar has Hide fields, Filter, Sort and \"Customize inbox\": the date\nfield it lists by and the fields under each name. A field hidden in the view\nleaves the record on the right too.\n\n<div data-docs-demo=\"720-base-inbox-view\" data-height=\"620\"></div>\n\n## 12. Keep the views\n\n`onViewsChange` fires with the whole list when a view is created, renamed,\nduplicated or deleted, and about 400ms after the shown view's settings stop\nchanging. Switching views stores the one being left first. Store the list\nwherever the app stores things.\n\nIn the browser:\n\n```svelte\n<script lang=\"ts\">\n import { SvBase, enableBase, type FieldView } from '@svgrid/enterprise/base'\n\n enableBase()\n const KEY = 'roadmap:views'\n const DEFAULT_VIEWS: FieldView[] = [{ id: 'all', name: 'All features', type: 'grid' }]\n\n function read<T>(key: string, fallback: T): T {\n try {\n const raw = localStorage.getItem(key)\n return raw ? (JSON.parse(raw) as T) : fallback\n } catch {\n return fallback\n }\n }\n function write(key: string, value: unknown) {\n try {\n localStorage.setItem(key, JSON.stringify(value))\n } catch {\n // Private mode or a full quota: the views still work, unsaved.\n }\n }\n\n let views = $state<FieldView[]>(read(KEY, DEFAULT_VIEWS))\n let activeView = $state<string>(read(`${KEY}:active`, ''))\n\n $effect(() => write(`${KEY}:active`, activeView))\n</script>\n\n<SvBase data={rows} {columns} primaryField=\"feature\" editable\n bind:views bind:activeView onViewsChange={(v: FieldView[]) => write(KEY, v)} />\n```\n\nOn a server, decide who owns a list.\n\n- **Per user.** Each person keeps their own list, so one lead's filter does\n not change another's. Seed it from the team's defaults the first time.\n- **Shared.** One list per table that everyone reads. Write it only for the\n people you allow; for everyone else, keep their changes in memory or in\n their own list. A shared \"My features\" view built on `ME` still shows each\n person their own records.\n\n```ts\ntype Scope = 'me' | 'team'\n\nasync function loadViews(scope: Scope): Promise<FieldView[]> {\n const res = await fetch(`/api/tables/features/views?scope=${scope}`)\n return res.ok ? ((await res.json()) as FieldView[]) : DEFAULT_VIEWS\n}\n\nfunction saveViews(scope: Scope, next: FieldView[]) {\n void fetch(`/api/tables/features/views?scope=${scope}`, {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(next),\n })\n}\n```\n\n```svelte\n{#await loadViews('me') then loaded}\n <SvBase data={rows} {columns} primaryField=\"feature\" editable\n views={loaded} onViewsChange={(v: FieldView[]) => saveViews('me', v)} />\n{/await}\n```\n\nOr mount at once and swap the list in when it arrives. When `views` or\n`activeView` changes from outside and the shown view is not the one the grid\nhas, the bar applies it. It never stores the grid's settings into a view it\nhas not applied yet.\n\n```svelte\n<script lang=\"ts\">\n let views = $state<FieldView[]>(DEFAULT_VIEWS)\n let loaded = false\n loadViews('me').then((v) => {\n views = v\n loaded = true\n })\n</script>\n\n<SvBase data={rows} {columns} primaryField=\"feature\" editable\n bind:views onViewsChange={(v: FieldView[]) => loaded && saveViews('me', v)} />\n```\n\nThe `loaded` check matters: about 400ms after mount the bar stores the\ndefault view's settings, and that save must not replace the list on the\nserver before the real one is in.\n\nWith several tables (`<SvBase bind:tables>`), each table keeps its own\n`views`, and `onTablesChange` hands back the whole list of tables, views\nincluded.\n\n## Personal and locked views\n\nOnce several people share a table, two more keys on a view matter:\n\n```ts\nconst views: FieldView[] = [\n // Only Ana sees it, under \"My views\" in the views menu.\n { id: 'ana-open', name: 'My open tasks', type: 'grid', personal: 'u1', state: { /* ... */ } },\n // Everyone sees it; nobody changes its settings until someone unlocks it.\n { id: 'report', name: 'Leadership report', type: 'grid', locked: true, lockedBy: 'u2', state: { /* ... */ } },\n]\n```\n\n- **`personal: userId`** lists the view only for that person, read from\n `setCurrentUser`. With nobody signed in every view is listed. \"Create\" in\n the views menu has a \"Personal view: only I see it\" box once someone is\n signed in.\n- **`locked: true`** keeps the view's filter, sorts, groups, hidden fields,\n colors and row height as saved. Its settings buttons are off, nothing is\n saved into it, and the bar shows \"Locked\" with who locked it. A sort from a\n column header still works for the moment; the bar then says \"Locked, not\n saved\" with a Reset. Records stay editable. A locked view cannot be\n deleted, and a copy of it starts unlocked.\n\nThe lock button in the views menu locks the view as the grid shows it now,\nor unlocks it. `lockViews={false}` on `SvBase` removes it for people who may\nnot lock views. Both keys come back through `onViewsChange` and\n`onTablesChange`, so the app stores a personal view with its owner the same\nway as the others.\n\n<div data-docs-demo=\"710-base-personal-locked-views\" data-height=\"620\"></div>\n\n## On a phone\n\nWhen a table is narrower than 600px (its own width, not the window's), a\ngrid view shows each record as a card: the primary field, then the next four\nfields the view shows, in the view's filter and sort. A tap opens the\nrecord, \"+\" adds one, and on a phone screen the opened record fills it. The\nview bar keeps its icons and the tab bar its tabs.\n\nA card keeps what a row can do. A long press, the button on the card, a\nright-click, the Menu key or Shift+F10 opens the record's menu: expand, comment,\nselect, insert above or below, duplicate and delete. A record selected this way\nshows on its card, as a ring on its list row, and in the selection bar. Copy and\npaste work on a cell, so they stay with the table. A gallery view and a list view\nhave the same menu.\n\nA Kanban lane takes the table's width, the next lane a swipe away and\nsnapped into place. A calendar opens in its agenda, the days listed one under\nanother, since a month of seven columns has no room for a title; Month, Week\nand Day are a tap away. Gallery cards stand one per row, and a form is one\ncolumn at any width.\n\n`phoneLayout` on `SvBase` moves the breakpoint (`phoneLayout={480}`), turns\nthe cards on at every width (`true`) or keeps the grid (`false`).\n\n<div data-docs-demo=\"713-base-phone-layout\" data-height=\"720\"></div>\n\n## Search across tables\n\nThe view bar's search finds records in the view on screen. The box at the\nend of the tab bar searches every table of the base. With the focus in the\nbase, Ctrl+K puts the cursor in it, and so does \"/\" outside the grid and any\ntext box. Neither is taken from the rest of the page.\n\nIt reads a field the way its cell shows it: a single select by its option's\nlabel, a person by name, a date as the field writes it, a link by the names\nof the records it links to, a formula or lookup by its result. Numbers,\ncurrency, percents, durations, ratings, checkboxes, buttons, rollups and\ncounts are not searched. Case and accents do not count: \"tomas\" finds\n\"Tomás\".\n\nEvery word of the query has to be in the record, in one field or another.\nThe results are grouped by table, five records each with \"N more in Deals\"\nunder them, each with its name, the field the words were found in and the\nwords marked. Records rank by:\n\n1. the whole query in one field, before words spread over several;\n2. the primary field, before the others;\n3. a field that is the query, then one that starts with it, then one with a\n word that starts with it, then one that holds it anywhere.\n\nTables are listed by their best record. Up and Down move through the list,\nEnter or a click shows the record's table and opens the record, and Escape\ncloses the list, then clears the box. `search={false}` on `SvBase` leaves the\nbox out. A shared base (`readOnly`) keeps it, over the tables and fields the\nshare shows.\n\nThe same search runs without the box, for a command palette of your own or\non a server:\n\n```ts\nimport { searchBase } from '@svgrid/enterprise/base'\n\nconst groups = searchBase(tables, 'northwind proposal', { limit: 10 })\nfor (const g of groups) {\n console.log(g.name, g.total)\n for (const hit of g.hits) console.log(hit.rowId, hit.title, `${hit.fieldName}: ${hit.text}`, hit.marks)\n}\n```\n\nEach hit has the table and record ids, the record's name (`title`), the\nfield that matched (`field`, `fieldName`, `primary`), its text cut around\nthe match when it is long, and `marks`, the `[start, end)` spans of the\nwords in that text. `field: (table, column) => boolean` in the options picks\nthe fields to search. To open a hit in `SvBase`, show its table\n(`bind:activeTable`) and call `openRecord({ api, rowId })` once that table's\ngrid has called `onApiReady`; the box does this for you.\n\n<div data-docs-demo=\"718-base-search-all-tables\" data-height=\"620\"></div>\n\n## View types and the keys they read\n\n| Type | Keys | View bar buttons |\n|---|---|---|\n| `'grid'` | `state`, `rowHeight`, `color` | Hide fields, Filter, Group, Sort, Color, Row height |\n| `'kanban'` | `stackBy`: a single select, or a user field with one person | Hide fields, Filter, Sort |\n| `'calendar'` | `dateField`, `endField` (optional), `color` | Hide fields, Filter, Sort, Color |\n| `'gantt'` | `dateField`, `endField`, `progressField`, `dependencyField`, `zoom`, `color` | Hide fields, Filter, Sort, Color, Customize timeline |\n| `'gallery'` | `coverField`: an attachment field | Hide fields, Filter, Sort |\n| `'chart'` | `chart`: `kind`, `x`, `y`, `aggregation` | Filter, Customize chart |\n| `'list'` | `listFields`: the fields under each name | Hide fields, Filter, Group, Sort, Customize list |\n| `'inbox'` | `inboxDateField`: a date field, newest first; `listFields` | Hide fields, Filter, Sort, Customize inbox |\n| `'form'` | `formFields`, `formRequired`, `formTitle`, `formDescription`, `formSubmitLabel`, `formConditions`, `formPrefill` | none |\n| `'dashboard'` | `dashboard`: the tiles, in order | none |\n| any type | `personal`, `locked`, `lockedBy` | off while `locked` |\n\nEvery type also keeps `state` (filter, sorts, groups, hidden fields, column\norder, widths, pinning) and switches with the grid's own state, so a filter\nset on the board is still there when you come back to it. The search text is\nnot part of it. The views menu's \"Create\" offers each type `SvBase` can show\nand greys out one the table cannot: a Kanban needs a single select, a\ncalendar a date field, a chart a field to group by. A new view starts with no\nfilter, sorts or groups and every field shown.\n`viewTypes={['grid', 'kanban', 'calendar']}` on `SvBase` limits what\n\"Create\" offers.\n\nA timeline (`type: 'gantt'`) is a calendar with a task table beside the bars.\n\"Create\" offers it as Timeline in every base, and its renderer loads the first\ntime one is shown. Its bars take the view's colors, `progressField` is a percent field drawn as each\nbar's fill, and `dependencyField` is a link field to the same table naming\nwhat each record waits for, drawn as arrows.\n\nA record's dates are its own: a drop on a Sunday stays on the Sunday. By keyboard a\nbar works as a calendar event does: Space picks it up, Left and Right carry it a day\n(Shift, a week), Space puts it down and Escape puts it back. Enter opens the record,\nShift+F10 opens its menu, and Delete asks first, as a row's menu does.\n\n## When an edit changes where a record belongs\n\nA view's filter, sort and groups apply again after an edit, with one pause. In a\ngrid the row you are working in stays where it is while it is the active row, so\nit does not leap away under the cursor; it takes its place when you move to\nanother row, click outside the grid, or close its record. The record count follows\nat the same moment. An undo, a paste and a fill apply at once. A board, a calendar,\na timeline, a gallery and a list show the change as soon as it is made, or when a\nrecord dialog closes. On a table read a page at a time the database is asked again\nat that moment, once it has the edit.\n\n## The view bar, panel by panel\n\n- **Views menu** (the view's name): switch, rename, duplicate (\"Roadmap by\n quarter copy\") and delete. Delete asks in the view's own row, and nothing moves\n until the answer. A deleted view goes to the trash and is one step of undo. The\n last view cannot be deleted.\n- **Hide fields**: a switch per field, a search, hide all and show all, and\n drag to reorder. The list keeps its order while you switch fields, and hidden\n fields sit where they are in the table. The primary field is always shown.\n- **Filter**: \"Where [field] [operator] [value]\" rows joined by \"and\" or\n \"or\", and condition groups. Each change filters at once. A condition still\n missing its value filters nothing.\n- **Group**: up to three fields, each with a direction.\n- **Sort**: fields in order, each with a direction labeled for its type (\"1\n → 9\", \"A → Z\", \"first → last\" for a single select). Attachment and button\n fields are not offered.\n- **Color**: None, Select field (a single select's option colors) or\n Conditions in order.\n- **Row height**: Short 34, Medium 56, Tall 88, Extra tall 128.\n `rowHeights` on `SvBase` or `SvBaseViewBar` sets the list.\n- **Search**: in a grid view, the grid's find bar (Ctrl+F) that marks every\n match. In a board, calendar, gallery, list or inbox, a \"Find a record\" box\n that narrows the records. Switching views clears it.\n- **Search all tables**: the box in the tab bar (below).\n\nA button with something set says so and is tinted. With `fieldMenu` on, each\ncolumn's menu adds \"Filter by this field\" and \"Group by this field\", which\nopen the bar's panel with the new condition or group in it.\n\n## Filters in code\n\n`filterKindOf(columnDef)` gives the kind a field filters as, and\n`operatorsFor(kind)` the operators the panel offers for it, in menu order.\n[Filter conditions](../fields.md#filter-conditions) maps each field type to\nits kind.\n\n| `kind` | `op` values | `value` |\n|---|---|---|\n| `'text'`, `'link'` | `contains`, `notContains`, `is`, `isNot` | a string; a link compares the linked records' names |\n| `'number'` | `eq`, `neq`, `lt`, `gt`, `lte`, `gte` | a number |\n| `'select'` | `is`, `isNot` | one option value, or a person's id (or `ME`) for a user field |\n| `'select'` | `isAnyOf`, `isNoneOf` | an array of them |\n| `'multi'` | `hasAnyOf`, `hasAllOf`, `isExactly`, `hasNoneOf` | an array of option values or ids |\n| `'checkbox'` | `is` | `true` or `false` |\n| `'date'` | `is`, `isBefore`, `isAfter`, `isOnOrBefore`, `isOnOrAfter` | `{ mode: 'today' }`, with `mode` also `'tomorrow'`, `'yesterday'`, `'oneWeekAgo'`, `'oneWeekFromNow'`, `'oneMonthAgo'`, `'oneMonthFromNow'`; or `{ mode: 'exactDate', date: '2026-11-01' }` |\n| `'date'` | `isWithin` | `{ span: 'pastWeek' }`, with `span` also `'pastMonth'`, `'pastYear'`, `'nextWeek'`, `'nextMonth'`, `'nextYear'`; or `{ span: 'pastDays', days: 14 }`, `{ span: 'nextDays', days: 14 }` |\n| `'files'` | `contains` (file name contains) | a string |\n\nEvery kind except checkbox also takes `isEmpty` and `isNotEmpty`, with no\nvalue. A few rules from the code:\n\n- An empty number cell is no number: it matches only `neq`.\n- Dates compare whole days. A bare `'2026-11-01'` is that day where the user\n is, and \"within the past week\" runs from 7 days ago to today.\n- A user condition holds the person's id (`'u2'`), not the name, or `ME`\n for whoever is signed in.\n- A link condition sets `table` to the linked table's id, so it can match\n records by name.\n\nSet a filter on the shown view with `api.setAdvancedFilter(filter)`; the\nview keeps it like one set in the panel.\n\n## Row colors: by field or by conditions\n\n```ts\nimport type { ColorSetting } from '@svgrid/enterprise/base'\n\nconst byStatus: ColorSetting = { mode: 'field', field: 'status' }\nconst byRisk: ColorSetting = {\n mode: 'conditions',\n rules: [\n { color: '#f82b60', condition: { column: 'status', kind: 'select', op: 'is', value: 'Blocked' } },\n { color: '#fcb400', condition: { column: 'target', kind: 'date', op: 'isBefore', value: { mode: 'today' } } },\n ],\n}\n```\n\nBy field, each row takes its option's color, and the row header's title says\nthe option, so the color is never the only signal. A multiple select colors\nby its first value. By conditions, the first rule that matches wins: a\nblocked feature is red even when it is also late. A condition is tested as\nthe filter tests it: on the value the cell shows, so a formula, lookup,\nrollup or count field works, and a condition still missing its value colors\nnothing. A calendar colors its events by a single select only; a Gantt's bars\ntake either kind.\n\nThe color is a 3px stripe on the row header, unless the `rowColor` prop on\n`SvBase` sets a `target` (`'bar'` or `'row'`): a view's colors use it too. A\nview without `color` shows the `rowColor` prop's colors until someone picks\ncolors for it in Color. `{ mode: 'none' }` turns the colors off in that view.\n\n## Summaries in the footer and in group headers\n\nWith `summary` on, a click on a field's footer cell picks its summary: sum,\naverage, median, min, max or range for numbers; checked, unchecked or percent\nchecked for a checkbox; earliest, latest or the date range in days for dates;\nempty, filled, unique, percent empty or percent filled for any field. The\nresult is written as the field writes values. The choice is stored in the\nfield's `fieldProps.summary` and reported through `onColumnChange`; see\n[Summaries at the bottom](../fields.md#summaries-at-the-bottom).\n\nGroup headers show the same summaries over that group's records. Both leave\nout records the filter hides, even in a collapsed group.\n\n## The view bar over your own grid\n\n`SvBaseViewBar` is the bar alone, for a page that lays out its own\n`<SvGrid>`:\n\n```svelte\n<script lang=\"ts\">\n import { SvGrid } from '@svgrid/grid'\n import { SvBaseViewBar, enableBase, type FieldView } from '@svgrid/enterprise/base'\n\n enableBase()\n // Raw: the bar finds its grid by the api object itself, and a proxy is another object.\n let api = $state.raw<any>(null)\n let views = $state<FieldView[]>([\n { id: 'all', name: 'All features', type: 'grid' },\n { id: 'board', name: 'Status board', type: 'kanban', stackBy: 'status' },\n ])\n let activeView = $state('all')\n</script>\n\n{#if api}\n <SvBaseViewBar {api} bind:views bind:activeView\n rowHeights={[{ label: 'Compact', height: 32 }, { label: 'Roomy', height: 64 }]} />\n{/if}\n<SvGrid data={rows} {columns} primaryField=\"feature\" editable containerHeight={600}\n onApiReady={(a) => (api = a)} />\n```\n\nIts \"Create\" offers grid, Kanban and calendar (and Gantt once enabled). It\nloads the board, calendar and gallery renderers the first time a view of\nthat type is shown, and opens the record and the \"Delete record?\" question\nfor a card's menu. Chart and form views are drawn by `SvBase`, not by the\nbar, so leave them out of `viewTypes` here, or draw `SvBaseForm` yourself\nwhen a form view is active.\n\n## Pitfalls\n\n- **A new view from \"Create\" starts with `color: { mode: 'none' }`**, so it\n hides the `rowColor` prop's colors. A new calendar or Gantt is the\n exception: it starts colored by the first single select. Pick colors in\n Color, or declare the view in code without `color`.\n- **`color.field` is the data field; the other keys are column ids.** They\n differ only when a column sets an `id`.\n- **Summaries belong to the field, not the view.** Picking \"Average\" in one\n view changes every view's footer and group headers.\n- **Save views only after they load.** See the `loaded` check in step 12.\n\n## Next\n\n- [Linked records](./linked-records.md): link Features to Feedback and chart\n or filter by the linked names.\n- [Formulas](./formulas.md): computed fields a view can sort, group and chart\n by.\n- [Forms](./forms.md): required fields, the thank-you screen and forms\n outside the base.\n- [Collaboration](./collaboration.md): comments, people and who changed what.\n- [Automations](./automations.md): conditions written with this same filter.\n- [Keep a base in a database](./data.md): load the tables from Postgres,\n Supabase or your API and write every change back.\n"
5308
5308
  },
5309
5309
  {
5310
5310
  "slug": "help/benchmarks",
@@ -6060,7 +6060,7 @@ export const docs = [
6060
6060
  "path": "docs/help/mcp-server.md",
6061
6061
  "title": "MCP server",
6062
6062
  "section": "Help",
6063
- "markdown": "# MCP server\n\nThe SvGrid MCP server does two things for an AI client (Claude Code,\nClaude Desktop, Cursor, Zed, Codex, custom agents): it answers questions\nabout SvGrid from the files this repository ships, and it **checks the\ncode the model writes** against the real exported surface of the version\nyou have installed. No API key either way.\n\n![An AI coding agent calls the @svgrid/mcp server over the Model Context Protocol, which runs grid tools and returns structured JSON results back to the agent.](/docs-media/grid-mcp.svg)\n\n> **What is MCP?** Model Context Protocol is the open standard\n> ([modelcontextprotocol.io](https://modelcontextprotocol.io)) for\n> exposing tools to LLM clients. SvGrid ships an MCP server so the\n> model your team already uses can \"see\" the grid without you having\n> to copy-paste docs into prompts.\n\nIt runs either way you like: as a local process\n([`@svgrid/mcp`](https://www.npmjs.com/package/@svgrid/mcp) on npm), or as\na hosted endpoint at `https://mcp.svgrid.com/mcp` that needs no install at\nall. Both are listed in the official MCP registry as `com.svgrid/svgrid`.\n\n## Two ways to connect\n\n**Hosted (nothing to install).** Point any MCP client at the URL:\n\n```\nhttps://mcp.svgrid.com/mcp\n```\n\n```bash\nclaude mcp add --transport http svgrid https://mcp.svgrid.com/mcp\n```\n\nOne click:\n[Add to Cursor](https://cursor.com/en/install-mcp?name=svgrid&config=eyJ1cmwiOiJodHRwczovL21jcC5zdmdyaWQuY29tL21jcCJ9)\n· [Add to VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=svgrid&config=%7B%22name%22%3A%22svgrid%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmcp.svgrid.com%2Fmcp%22%7D)\n\nIt carries seven tools - `search`, `fetch`, `list_examples`,\n`get_example_source`, `get_api_reference`, `check_svgrid_code` and\n`svgrid_preview` - and needs no Node, no config file, and no key.\n\nIn an AI app builder, add the same URL as a custom MCP server with no\nauthentication: [Bolt.new](./bolt-new.md#3-connect-the-mcp-server) and\n[Lovable](./lovable.md#the-mcp-server-as-a-chat-connector) both take it.\n\n**Local (`npx @svgrid/mcp`).** Everything the hosted server has, plus\nthe Studio tools, the docs and demos as MCP resources, ready-made\nprompts, and a `svgrid_check_code` that additionally *compiles* the file\nwith the Svelte compiler rather than checking it statically. Use it when\nyou want the compile pass, the Studio tools, or no third-party endpoint\nin the loop.\n\n| | Hosted | Local |\n| --- | --- | --- |\n| Setup | a URL | `npx @svgrid/mcp` |\n| Needs Node | no | yes |\n| Code check compiles | no, static checks only | yes |\n| Resources and prompts | yes | yes |\n| Visual preview | yes | yes |\n| `studio_*` tools | no | yes, opt-in |\n| Works offline | no | yes |\n\n## Install\n\nNo install step is required - `npx` fetches it on demand:\n\n```bash\n# One-shot, from any project\nnpx -y @svgrid/mcp\n```\n\nTo pin it as a dev dependency instead:\n\n```bash\npnpm add -D @svgrid/mcp\n```\n\nThe local server is a Node binary (`svgrid-mcp`) that speaks MCP over\nstdio. There is no daemon to maintain. The hosted server needs no install\nstep at all - skip to [Wire it into your AI client](#wire-it-into-your-ai-client)\nand use the URL.\n\n## Wire it into your AI client\n\nEvery snippet below shows the local (stdio) form and the hosted (HTTP)\nform. Pick one - running both connects the same tools twice.\n\n### Claude Code\n\nThe plugin is the shortest path: it installs the\n[Agent Skill](./skill.md) and the hosted server together, so the model\ngets the house style *and* the checker in one step.\n\n```\n/plugin marketplace add sv-grid/sv-grid\n/plugin install svgrid@svgrid\n```\n\nOr add the server on its own:\n\n```bash\n# hosted, nothing to install\nclaude mcp add --transport http svgrid https://mcp.svgrid.com/mcp\n\n# or local\nclaude mcp add svgrid -- npx -y @svgrid/mcp\n```\n\nThen run `/mcp` in a session and you will see `svgrid` listed.\n\nTo share the server with your team, add `--scope project`. That writes\na `.mcp.json` at the repository root which you can commit, so everyone\nwho clones the repo gets the same tooling with no per-machine setup:\n\n```bash\nclaude mcp add svgrid --scope project -- npx -y @svgrid/mcp\n```\n\n### Claude Desktop\n\nEdit `~/Library/Application Support/Claude/claude_desktop_config.json`\n(macOS) or `%APPDATA%\\Claude\\claude_desktop_config.json` (Windows):\n\n```json\n{\n \"mcpServers\": {\n \"svgrid\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"]\n }\n }\n}\n```\n\nOr the hosted server, with nothing to install:\n\n```json\n{\n \"mcpServers\": {\n \"svgrid\": {\n \"type\": \"http\",\n \"url\": \"https://mcp.svgrid.com/mcp\"\n }\n }\n}\n```\n\nRestart Claude Desktop, then ask *\"using svgrid, build me a grid that\ngroups by department\"* to confirm the tools are exposed.\n\n### Cursor\n\nOne click:\n[Add to Cursor](https://cursor.com/en/install-mcp?name=svgrid&config=eyJ1cmwiOiJodHRwczovL21jcC5zdmdyaWQuY29tL21jcCJ9)\n\nOr by hand, in `Settings -> MCP -> Add new MCP server`:\n\n```json\n{ \"url\": \"https://mcp.svgrid.com/mcp\" }\n```\n\n```json\n{ \"command\": \"npx\", \"args\": [\"-y\", \"@svgrid/mcp\"] }\n```\n\n### Zed\n\n`~/.config/zed/settings.json`:\n\n```json\n{\n \"context_servers\": {\n \"svgrid\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"],\n \"env\": {}\n }\n }\n}\n```\n\n### VS Code\n\nOne click:\n[Add to VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=svgrid&config=%7B%22name%22%3A%22svgrid%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmcp.svgrid.com%2Fmcp%22%7D)\n\nOr create `.vscode/mcp.json` in the workspace. Note that VS Code uses\n`servers` rather than the `mcpServers` wrapper:\n\n```json\n{\n \"servers\": {\n \"svgrid\": {\n \"type\": \"http\",\n \"url\": \"https://mcp.svgrid.com/mcp\"\n }\n }\n}\n```\n\n```json\n{\n \"servers\": {\n \"svgrid\": {\n \"type\": \"stdio\",\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"]\n }\n }\n}\n```\n\n### Custom agents (OpenAI Agents SDK, Anthropic SDK, LangChain)\n\nPoint your client's MCP stdio transport at `npx -y @svgrid/mcp`, or its\nstreamable-HTTP transport at `https://mcp.svgrid.com/mcp`. Any client that\nspeaks either transport works.\n\nThe hosted server names its two retrieval tools `search` and `fetch`\nexactly, which is what a connector needs to index it.\n\n## Tools exposed\n\nFive, by default. `tools/list` is sent on **every** request, so the tool\nsurface is pure overhead on every turn - and this server used to spend\n~4,710 tokens of it on 36 tools, 79% of them Studio tools that most\nsessions never call once.\n\n| Tool | What it does |\n| ---- | ------------ |\n| `svgrid_search` | Search the docs, every demo and the API surface **in one call**. No arguments returns an index. |\n| `svgrid_get` | Read one thing in full: a doc slug, a demo id, or `api`. |\n| `svgrid_check_code` | Verify code against the real exported surface before the user sees it. |\n| `svgrid_preview` | Render a **live, interactive grid** in the conversation from columns + rows. |\n| `svgrid_scaffold` | Turn a Drizzle schema, sample rows or an EntitySchema into runnable SvelteKit files. |\n\nStudio adds four more, and only when you ask for them - set\n`SVGRID_MCP_STUDIO=1` or a licence key in the server's env. They need a\nlicence to be useful, so they are not charged to everyone else's context\nwindow.\n\n`svgrid_scaffold` and the Studio tools run on `@svgrid/enterprise`, which the\nserver loads only when it is installed beside it. `npx -y @svgrid/mcp` leaves\nit out so the server starts fast. To scaffold, install both in the project and\nrun the local server:\n\n```bash\nnpm i -D @svgrid/mcp @svgrid/enterprise\nclaude mcp add svgrid -- npx svgrid-mcp\n```\n\nWithout `-y`, `npx` runs the installed copy instead of downloading one, so\nthere is no install on the first connect.\n\nThe **hosted** server carries `search`, `fetch`, `list_examples`,\n`get_example_source`, `get_api_reference`, `check_svgrid_code` and\n`svgrid_preview`, plus the same resources and prompts. The first two are named\nthat way deliberately: those exact names are what a one-click connector needs to\nindex a remote server. It also answers to `svgrid_search`, `svgrid_get` and\n`svgrid_check_code`, so a model that learned the npm package's names is never\ntold \"unknown tool\".\n\nWhat it does **not** have is the compile pass (the Svelte compiler cannot run in\na Worker), the Studio tools (they need a filesystem), and the offline guarantee\n- it is a remote server, so by definition your query reaches it. Use the local\none when any of those matter.\n\n### Verification\n\n#### `svgrid_check_code`\n\nChecks a file **against the version you have installed** and returns\nline-numbered diagnostics with the exact replacement for each: unknown\n`<SvGrid>` props, wrong `ColumnDef` keys, api methods that do not\nexist, imports that will not resolve, and Svelte 5 runes mistakes. It\nalso compiles the component, so a syntax error surfaces here rather\nthan in the user's terminal.\n\nThis is the tool that makes the rest worth having. Retrieval alone\nstill lets a model write a confident, wrong grid; nothing else in the\nserver stops it. Run it on every file you write, fix what it reports,\nand run it again.\n\n### Finding and reading\n\n#### `svgrid_search`\n\nOne call across all three corpora, because \"how do I pin a column\" does\nnot announce whether it is answered by a doc page, a demo, or an API\nname:\n\n```json\n{ \"query\": \"pin a column\" }\n```\n\nReturns ranked doc hits with excerpts, matching demos, and matching API\nnames - each with the reference you pass to `svgrid_get`. Narrow with\n`kind` (`docs` | `examples` | `api`), trade tokens for completeness\nwith `detail` (`concise` | `full`), and cap with `limit` (max 50).\n\nCall it with **no arguments** for an index of doc sections, demo\ncategories and API groups - the cheapest way to orient before searching.\n\n#### `svgrid_get`\n\n```json\n{ \"ref\": \"help/columns/column-definitions\" }\n{ \"ref\": \"11-stock-market\" }\n{ \"ref\": \"api\" }\n```\n\nThe kind is inferred from the reference; pass `kind` to force it. A\nreference that does not resolve comes back with near matches rather\nthan a bare \"not found\".\n\n### It fixes what it finds\n\n`svgrid_check_code` does not stop at telling you what is wrong. Where the\ncorrection is exact it returns the corrected file too:\n\n```json\n{\n \"diagnostics\": [ ... ],\n \"applied\": [\"rowData -> data (line 7)\", \"accessorKey -> field (line 3)\"],\n \"fixed\": \"<the corrected source>\"\n}\n```\n\nBoth fields are omitted when there is nothing mechanically fixable, so a clean\ncheck stays small.\n\nThe rules are deliberately narrow, because this tool's whole worth is that it\nnever cries wolf - and rewriting raises the stakes from wasting a turn to\ncorrupting working code. Only exact renames are applied (a known rename, or a\nclose-enough spelling), only on word boundaries, and only on the line the\ndiagnostic reported. Advice that is ambiguous - \"this has no equivalent, remove\nit\" - stays advice. A test asserts that running auto-fix across every demo\nin this repository changes nothing at all.\n\n### It knows which version you have\n\nThe result carries the version it checked against:\n\n```json\n{ \"version\": { \"corpus\": \"3.0.0\", \"installed\": \"2.6.8\", \"warning\": \"...\" } }\n```\n\nThe server reads the `@svgrid/grid` in your project and says plainly when it\ndisagrees with the corpus it ships, so a model is told to hedge instead of\nconfidently citing an API you do not have. A server that answers from a remote\nbackend cannot do this - it has no idea what is in your `node_modules`.\n\n### Nothing leaves your machine\n\nThis server makes **no network calls**. Not for docs, not for the API surface,\nnot for verification - the whole corpus (every demo, every doc page, the full\nexported API) ships inside the package, which is why it is megabytes rather\nthan kilobytes. There is no API key, no licence check on the wire, and no telemetry.\n\nIt works on a plane, behind a corporate proxy, and inside an air-gapped\nnetwork. `tools/mcp-offline.test.ts` enforces it: the server is driven through\na full session with every network primitive booby-trapped, and the test fails if\nanything is even attempted.\n\nThe one honest exception: the **preview** loads the grid from a CDN to draw it.\nThat happens in your client's sandboxed iframe, never in this server, and only\nwhen you actually render a preview.\n\n### Seeing the grid, not just reading about it\n\n`svgrid_preview` renders a **real, interactive SvGrid inside the\nconversation** - sortable, filterable, scrollable. Not a screenshot and not a\nmock table: the same `<sv-grid>` custom element a page would use, loaded from\nthe CDN, with the columns and rows you passed.\n\n```json\n{\n \"title\": \"Team roster\",\n \"columns\": [{ \"field\": \"name\", \"header\": \"Name\" }, { \"field\": \"amount\", \"header\": \"Amount\" }],\n \"data\": [{ \"name\": \"Ada\", \"amount\": 20000 }],\n \"sortable\": true\n}\n```\n\nIt uses [MCP Apps](https://blog.modelcontextprotocol.io/posts/2026-01-26-mcp-apps/),\nthe official UI extension: the tool points at a `ui://` resource through\n`_meta`, the client loads that HTML in a sandboxed iframe, and the tool's\n`structuredContent` arrives over a postMessage bridge. Supported in Claude\n(web and desktop), VS Code and ChatGPT.\n\nClients without UI support are not left out - they ignore the `_meta` and get\na text summary of the same grid, so it is always safe to call. That is the\nextension's own rule, and it is why the text half describes the grid rather\nthan pointing at a picture the reader cannot see.\n\nPass `demo` instead of `columns` / `data` and you get the demo's source: a\ndemo is a Svelte component, not data, so there is nothing to hand the element\nand rendering an empty grid would just look broken.\n\n### Resources and prompts\n\nThe docs and demos are also exposed as **MCP resources**, so a user can\nattach a page or a demo directly instead of hoping the model thinks to\nsearch for it:\n\n```\nsvgrid://doc/help/columns/column-definitions\nsvgrid://example/11-stock-market\n```\n\nAnd three **prompts** ship ready to run: `build_grid`, `explain_api`\nand `review_grid_code`. Each is written to make the model use this\nserver rather than recall SvGrid from training data, and each ends at\n`svgrid_check_code`.\n\n### SvGrid Studio (commercial)\n\nOff unless enabled. Set `SVGRID_MCP_STUDIO=1`, or a valid\n`SVGRID_LICENSE_KEY`, in the server's env, and run the server from a project\nthat has `@svgrid/enterprise` installed beside it\n(`npm i -D @svgrid/mcp @svgrid/enterprise`, then `npx svgrid-mcp`). Without it\nthese tools answer with those steps instead of running.\n\n#### `svgrid_scaffold`\n\nPoint it at a Drizzle schema, sample JSON rows, or an `EntitySchema`\nyou already have, and it infers the schema and generates the `$lib`\nschema module, a `+server.ts` API route and a `+page.svelte` with\n`SvGrid` + `SvGridEditPanel` - in one call. Pass `schemaOnly: true` to\nstop after inference. Generated bodies carry `svgrid:managed` markers,\nso regenerating preserves your edits outside them.\n\n#### The `studio_*` tools\n\nFour tools drive the same validated project model the visual designer\nuses:\n\n| Tool | What it does |\n| ---- | ------------ |\n| `studio_project` | `new`, `load`, `describe`, `config`, `capabilities` |\n| `studio_apply` | A **batch** of model changes - entities, screens, blocks, components - applied in order |\n| `studio_configure` | Theme, auth, access, tenancy, data layer, jobs, deploy target, layouts, in one call |\n| `studio_build` | `validate`, then `generate` the full runnable SvelteKit app |\n\nCall `studio_project` with `action: \"capabilities\"` first: it reports\nexactly what the installed version supports, so the agent does not have\nto guess block kinds or component keys.\n\n`studio_apply` takes a batch on purpose. Building a five-screen app was\ntwenty-odd round trips when every block was its own tool; now a whole\nscreen is one call, and a failure reports which op failed and what\nalready applied.\n\n### The pre-3.0 names\n\nEvery tool name from before 3.0 still answers - `search_docs`,\n`get_doc`, `list_examples`, `get_example_source`, `list_docs`,\n`get_api_reference`, `check_svgrid_code`, `introspect_source`,\n`scaffold_entity` and all 27 individual `studio_*` tools. They are not\n**listed**, because listing is what costs context and answering a name\nyou did not advertise costs nothing. Saved prompts and scripts keep\nworking; nobody pays for the compatibility.\n\nTheir JSON response shape follows 3.0, not 2.x. A model reads either\nwithout trouble; a script that parsed the old shape by hand needs a look.\n\n## Licensing\n\nThe documentation and example tools are free. The Studio code\ngenerators are part of the commercial offering. You can evaluate them\nwithout a key: they run, but prepend a notice comment\nto generated files. To license them, set\nthe key in your MCP client's server config:\n\n```json\n{\n \"mcpServers\": {\n \"svgrid\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"],\n \"env\": { \"SVGRID_LICENSE_KEY\": \"YOUR-LICENSE-KEY\" }\n }\n }\n}\n```\n\n## Enterprise features and the trial\n\nMost of SvGrid is the MIT `@svgrid/grid` package. Export to Excel and PDF,\npivot tables, the Kanban board, the scheduler, the spreadsheet and the\nserver-side row model are in `@svgrid/enterprise`, which is commercial.\n\nThe server tells your assistant which is which. In `svgrid_search` results a\npaid doc or demo carries `\"enterprise\": true`, and when a question is about a\npaid feature the answer says so once, with the trial link.\n`svgrid_get` puts the same line at the top of a paid doc or demo, and\n`svgrid_check_code` adds it when the fix is to install the package. Nothing\nis sent anywhere to do this; it is part of the answer text.\n\n`@svgrid/enterprise` runs without a license key and shows a watermark until\none is set, so you can try a feature before deciding. The\n[30-day trial](https://svgrid.com/pricing/?trial=mcp-docs) adds a download of\nevery demo and 30 days of email support.\n\n## Verifying it works\n\nAsk your model: *\"What MCP tools do you have from svgrid?\"* The local\nserver lists five, including `svgrid_check_code` (four Studio tools more when\nenabled); the hosted server lists seven.\n\nThen give it something to catch:\n\n> Check this with svgrid: `<SvGrid rowData={rows} {columns} />`\n\nIt should come back with `rowData` is not a SvGrid prop, use `data`. If\nit explains the code instead of calling a tool, the server is not\nconnected.\n\nIf nothing is listed at all, check your client's MCP log. For the local\nserver the usual cause is `npx` not being on PATH - use the absolute path\nto the binary. For the hosted one, confirm the endpoint answers:\n\n```bash\ncurl https://mcp.svgrid.com/health\n```\n\n## Security model\n\nThe two ways of running it differ here, so pick deliberately.\n\n**Local (`npx @svgrid/mcp`)**\n\n- Runs on your machine over stdio. No telemetry, no outbound network\n calls, no API key.\n- Serves a documentation and example corpus bundled into the package at\n build time, so answers are pinned to the version you installed.\n- `svgrid_check_code` reads the source you pass it in-process and never\n sends it anywhere.\n\n**Hosted (`https://mcp.svgrid.com/mcp`)**\n\n- Your client sends tool arguments to a Cloudflare Worker we operate.\n Anything you pass to a tool leaves your machine, and for\n `check_svgrid_code` that means **the source you ask it to check**.\n- Each call is recorded: tool name, duration, whether it succeeded, the\n query or id it was given, how many pages matched, and whether the answer\n mentioned the Enterprise trial. For `check_svgrid_code` only the **byte\n length** of the submitted source and the names of the rules that fired\n are recorded, never the source itself. The records stay in Cloudflare\n (Workers logs, and an Analytics Engine dataset kept three months) and are\n read in aggregate to see what people ask for.\n- No account, no key, no cookies. Requests are not tied to a user.\n- If your code cannot leave the building, use the local server. That is\n what it is for.\n\n**Both**\n\n- The Studio tools return generated files as data. Writing them to disk\n is your client's decision, not the server's.\n- See [security](./security.md) for the general supply-chain posture.\n\n## Building your own MCP integrations\n\nThe same docs manifest, JSON Schemas (column definitions, the grid's\noptions, export options, and the chart spec at `schemas/chart-spec.json`,\nwhich `svgrid_get` also serves for \"chart spec schema\"), and `llms.txt`\nfiles are also served directly from the docs site:\n\n```ts\nconst docs = await fetch('https://svgrid.com/docs.json').then((r) => r.json())\nconst schemas = await fetch('https://svgrid.com/schemas/index.json').then((r) => r.json())\nconst llms = await fetch('https://svgrid.com/llms-full.txt').then((r) => r.text())\n```\n\nIf you do not want to run the MCP server, building these into your\nagent's system prompt gives most of the same grounding.\n\n## Without the MCP server\n\nAn agent that can only fetch pages gets the same material over plain HTTP,\nin pieces small enough for one fetch (fetch tools cut a response near\n100 KB):\n\n| URL | What it holds |\n|---|---|\n| `/llms.txt` | The docs index, with links to everything below. `/llms/<product>.txt` (grid, ui, enterprise, sheet, base, studio, compare) is one product's part of it |\n| `/docs/<slug>.md` | One docs page as markdown |\n| `/demos.md`, `/demos/<id>.md` | Every live demo, and one demo with what it shows and its full source |\n| `/api.json` | Every export of `@svgrid/grid` and `@svgrid/enterprise` by module, with the member names of each type |\n| `/api/<name>.json` | One symbol's doc comment and signature, by its lowercased name: `/api/svgridapi.json`, `/api/createreview.json` |\n| `/.well-known/mcp.json` | Where this server is: the remote endpoint, the npm package, the setup commands |\n\n```ts\nconst index = await fetch('https://svgrid.com/api.json').then((r) => r.json())\nconst api = await fetch('https://svgrid.com/api/svgridapi.json').then((r) => r.json())\nconst demo = await fetch('https://svgrid.com/demos/702-change-review.md').then((r) => r.text())\n```\n\nIn a browser with WebMCP (`document.modelContext`), svgrid.com registers\nfour tools for an agent driving the page: `svgrid_search`, `svgrid_get_doc`,\n`svgrid_get_demo` and `svgrid_lookup_api`. They answer from the files\nabove.\n\n## Frequently asked questions\n\n### What is the SvGrid MCP server?\n\nA Model Context Protocol server that lets AI clients (Claude Code, Claude\nDesktop, Cursor, Zed, custom agents) query SvGrid's documentation, read real\ndemo source, scaffold SvelteKit CRUD apps, and check the code they write\nagainst the real API - grounded in the files the package ships, so the model\nanswers from current facts instead of guessing.\n\n### Do I need an API key to run it?\n\nNo, on either transport. A `SVGRID_LICENSE_KEY` is optional and only affects\nthe commercial Studio code generators.\n\n### Local or hosted - which should I use?\n\nHosted (`https://mcp.svgrid.com/mcp`) if you want it working in one paste,\nwith no Node and no config file. Local (`npx @svgrid/mcp`) if you want the\nSvelte compiler pass in `svgrid_check_code`, the Studio tools, offline\nuse, or your source never leaving the machine. See\n[Security model](#security-model) for what each one sends.\n\n### How does it help AI assistants write better SvGrid code?\n\nTwo ways. It exposes the docs, example sources, and API reference as tools,\nso the assistant retrieves version-pinned answers instead of hallucinating an\nAPI from training data. And `svgrid_check_code` closes the loop: the model\nruns what it wrote past the real exported surface and gets told exactly what\nis wrong before you see it. That matters most for Svelte 5, where models\nroutinely mix in outdated Svelte 4 syntax.\n\n### Does it work with a version of SvGrid I have not upgraded to?\n\nThe local server answers for the version bundled in the `@svgrid/mcp` release\nyou install, so pin it alongside `@svgrid/grid` if you are behind. The hosted\nserver always tracks the current release. Either way, every\n`svgrid_check_code` result names the version it checked against in its\n`checkedAgainst` field.\n\n## See also\n\n- [Agent Skill](./skill.md) - the always-on house-style layer; the Claude Code plugin installs it together with this server\n- [LLM grounding](./llm-grounding.md) - the same files used by the MCP server, but documented for direct LLM consumption\n- [Agents](./agents.md) - how to build an AI agent that drives the live grid\n- [AI assistant](./ai.md) - the in-grid AI features (filter / smart-fill / classify / summarise), free in @svgrid/grid\n"
6063
+ "markdown": "# MCP server\n\nThe SvGrid MCP server does two things for an AI client (Claude Code,\nClaude Desktop, Cursor, Zed, Codex, custom agents): it answers questions\nabout SvGrid from the files this repository ships, and it **checks the\ncode the model writes** against the real exported surface of the version\nyou have installed. No API key either way.\n\n![An AI coding agent calls the @svgrid/mcp server over the Model Context Protocol, which runs grid tools and returns structured JSON results back to the agent.](/docs-media/grid-mcp.svg)\n\n> **What is MCP?** Model Context Protocol is the open standard\n> ([modelcontextprotocol.io](https://modelcontextprotocol.io)) for\n> exposing tools to LLM clients. SvGrid ships an MCP server so the\n> model your team already uses can \"see\" the grid without you having\n> to copy-paste docs into prompts.\n\nIt runs either way you like: as a local process\n([`@svgrid/mcp`](https://www.npmjs.com/package/@svgrid/mcp) on npm), or as\na hosted endpoint at `https://mcp.svgrid.com/mcp` that needs no install at\nall. Both are listed in the official MCP registry as `com.svgrid/svgrid`.\n\n## Two ways to connect\n\n**Hosted (nothing to install).** Point any MCP client at the URL:\n\n```\nhttps://mcp.svgrid.com/mcp\n```\n\n```bash\nclaude mcp add --transport http svgrid https://mcp.svgrid.com/mcp\n```\n\nOne click:\n[Add to Cursor](https://cursor.com/en/install-mcp?name=svgrid&config=eyJ1cmwiOiJodHRwczovL21jcC5zdmdyaWQuY29tL21jcCJ9)\n· [Add to VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=svgrid&config=%7B%22name%22%3A%22svgrid%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmcp.svgrid.com%2Fmcp%22%7D)\n\nIt carries seven tools - `search`, `fetch`, `list_examples`,\n`get_example_source`, `get_api_reference`, `check_svgrid_code` and\n`svgrid_preview` - and needs no Node, no config file, and no key.\n\nIn an AI app builder, add the same URL as a custom MCP server with no\nauthentication: [Bolt.new](./bolt-new.md#3-connect-the-mcp-server) and\n[Lovable](./lovable.md#the-mcp-server-as-a-chat-connector) both take it.\n\n**Local (`npx @svgrid/mcp`).** Everything the hosted server has, plus\nthe Studio tools, the docs and demos as MCP resources, ready-made\nprompts, and a `svgrid_check_code` that additionally *compiles* the file\nwith the Svelte compiler rather than checking it statically. Use it when\nyou want the compile pass, the Studio tools, or no third-party endpoint\nin the loop.\n\n| | Hosted | Local |\n| --- | --- | --- |\n| Setup | a URL | `npx @svgrid/mcp` |\n| Needs Node | no | yes |\n| Code check compiles | no, static checks only | yes, with your project's Svelte |\n| Resources and prompts | yes | yes |\n| Visual preview | yes | yes |\n| `studio_*` tools | no | yes, opt-in |\n| Works offline | no | yes |\n\n## Install\n\nNo install step is required - `npx` fetches it on demand:\n\n```bash\n# One-shot, from any project\nnpx -y @svgrid/mcp\n```\n\nTo pin it as a dev dependency instead:\n\n```bash\npnpm add -D @svgrid/mcp\n```\n\nThe local server is a Node binary (`svgrid-mcp`) that speaks MCP over\nstdio. There is no daemon to maintain. The hosted server needs no install\nstep at all - skip to [Wire it into your AI client](#wire-it-into-your-ai-client)\nand use the URL.\n\n## Wire it into your AI client\n\nEvery snippet below shows the local (stdio) form and the hosted (HTTP)\nform. Pick one - running both connects the same tools twice.\n\n### Claude Code\n\nThe plugin is the shortest path: it installs the\n[Agent Skill](./skill.md) and the hosted server together, so the model\ngets the house style *and* the checker in one step.\n\n```\n/plugin marketplace add sv-grid/sv-grid\n/plugin install svgrid@svgrid\n```\n\nOr add the server on its own:\n\n```bash\n# hosted, nothing to install\nclaude mcp add --transport http svgrid https://mcp.svgrid.com/mcp\n\n# or local\nclaude mcp add svgrid -- npx -y @svgrid/mcp\n```\n\nThen run `/mcp` in a session and you will see `svgrid` listed.\n\nTo share the server with your team, add `--scope project`. That writes\na `.mcp.json` at the repository root which you can commit, so everyone\nwho clones the repo gets the same tooling with no per-machine setup:\n\n```bash\nclaude mcp add svgrid --scope project -- npx -y @svgrid/mcp\n```\n\n### Claude Desktop\n\nEdit `~/Library/Application Support/Claude/claude_desktop_config.json`\n(macOS) or `%APPDATA%\\Claude\\claude_desktop_config.json` (Windows):\n\n```json\n{\n \"mcpServers\": {\n \"svgrid\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"]\n }\n }\n}\n```\n\nOr the hosted server, with nothing to install:\n\n```json\n{\n \"mcpServers\": {\n \"svgrid\": {\n \"type\": \"http\",\n \"url\": \"https://mcp.svgrid.com/mcp\"\n }\n }\n}\n```\n\nRestart Claude Desktop, then ask *\"using svgrid, build me a grid that\ngroups by department\"* to confirm the tools are exposed.\n\n### Cursor\n\nOne click:\n[Add to Cursor](https://cursor.com/en/install-mcp?name=svgrid&config=eyJ1cmwiOiJodHRwczovL21jcC5zdmdyaWQuY29tL21jcCJ9)\n\nOr by hand, in `Settings -> MCP -> Add new MCP server`:\n\n```json\n{ \"url\": \"https://mcp.svgrid.com/mcp\" }\n```\n\n```json\n{ \"command\": \"npx\", \"args\": [\"-y\", \"@svgrid/mcp\"] }\n```\n\n### Zed\n\n`~/.config/zed/settings.json`:\n\n```json\n{\n \"context_servers\": {\n \"svgrid\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"],\n \"env\": {}\n }\n }\n}\n```\n\n### VS Code\n\nOne click:\n[Add to VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=svgrid&config=%7B%22name%22%3A%22svgrid%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmcp.svgrid.com%2Fmcp%22%7D)\n\nOr create `.vscode/mcp.json` in the workspace. Note that VS Code uses\n`servers` rather than the `mcpServers` wrapper:\n\n```json\n{\n \"servers\": {\n \"svgrid\": {\n \"type\": \"http\",\n \"url\": \"https://mcp.svgrid.com/mcp\"\n }\n }\n}\n```\n\n```json\n{\n \"servers\": {\n \"svgrid\": {\n \"type\": \"stdio\",\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"]\n }\n }\n}\n```\n\n### Custom agents (OpenAI Agents SDK, Anthropic SDK, LangChain)\n\nPoint your client's MCP stdio transport at `npx -y @svgrid/mcp`, or its\nstreamable-HTTP transport at `https://mcp.svgrid.com/mcp`. Any client that\nspeaks either transport works.\n\nThe hosted server names its two retrieval tools `search` and `fetch`\nexactly, which is what a connector needs to index it.\n\n## Tools exposed\n\nFive, by default. `tools/list` is sent on **every** request, so the tool\nsurface is pure overhead on every turn - and this server used to spend\n~4,710 tokens of it on 36 tools, 79% of them Studio tools that most\nsessions never call once.\n\n| Tool | What it does |\n| ---- | ------------ |\n| `svgrid_search` | Search the docs, every demo and the API surface **in one call**. No arguments returns an index. |\n| `svgrid_get` | Read one thing in full: a doc slug, a demo id, or `api`. |\n| `svgrid_check_code` | Verify code against the real exported surface before the user sees it. |\n| `svgrid_preview` | Render a **live, interactive grid** in the conversation from columns + rows. |\n| `svgrid_scaffold` | Turn a Drizzle schema, sample rows or an EntitySchema into runnable SvelteKit files. |\n\nStudio adds four more, and only when you ask for them - set\n`SVGRID_MCP_STUDIO=1` or a licence key in the server's env. They need a\nlicence to be useful, so they are not charged to everyone else's context\nwindow.\n\n`svgrid_scaffold` and the Studio tools run on `@svgrid/enterprise`, which the\nserver loads only when it is installed beside it. `npx -y @svgrid/mcp` leaves\nit out so the server starts fast. To scaffold, install both in the project and\nrun the local server:\n\n```bash\nnpm i -D @svgrid/mcp @svgrid/enterprise\nclaude mcp add svgrid -- npx svgrid-mcp\n```\n\nWithout `-y`, `npx` runs the installed copy instead of downloading one, so\nthere is no install on the first connect.\n\nThe **hosted** server carries `search`, `fetch`, `list_examples`,\n`get_example_source`, `get_api_reference`, `check_svgrid_code` and\n`svgrid_preview`, plus the same resources and prompts. The first two are named\nthat way deliberately: those exact names are what a one-click connector needs to\nindex a remote server. It also answers to `svgrid_search`, `svgrid_get` and\n`svgrid_check_code`, so a model that learned the npm package's names is never\ntold \"unknown tool\".\n\nWhat it does **not** have is the compile pass (the Svelte compiler cannot run in\na Worker), the Studio tools (they need a filesystem), and the offline guarantee\n- it is a remote server, so by definition your query reaches it. Use the local\none when any of those matter.\n\n### Verification\n\n#### `svgrid_check_code`\n\nChecks a file **against the version you have installed** and returns\nline-numbered diagnostics with the exact replacement for each: unknown\n`<SvGrid>` props, wrong `ColumnDef` keys, api methods that do not\nexist, imports that will not resolve, and Svelte 5 runes mistakes. It\nalso compiles the component, so a syntax error surfaces here rather\nthan in the user's terminal.\n\nThis is the tool that makes the rest worth having. Retrieval alone\nstill lets a model write a confident, wrong grid; nothing else in the\nserver stops it. Run it on every file you write, fix what it reports,\nand run it again.\n\n### Finding and reading\n\n#### `svgrid_search`\n\nOne call across all three corpora, because \"how do I pin a column\" does\nnot announce whether it is answered by a doc page, a demo, or an API\nname:\n\n```json\n{ \"query\": \"pin a column\" }\n```\n\nReturns ranked doc hits with excerpts, matching demos, and matching API\nnames - each with the reference you pass to `svgrid_get`. Narrow with\n`kind` (`docs` | `examples` | `api`), trade tokens for completeness\nwith `detail` (`concise` | `full`), and cap with `limit` (max 50).\n\nCall it with **no arguments** for an index of doc sections, demo\ncategories and API groups - the cheapest way to orient before searching.\n\n#### `svgrid_get`\n\n```json\n{ \"ref\": \"help/columns/column-definitions\" }\n{ \"ref\": \"11-stock-market\" }\n{ \"ref\": \"api\" }\n```\n\nThe kind is inferred from the reference; pass `kind` to force it. A\nreference that does not resolve comes back with near matches rather\nthan a bare \"not found\".\n\n### It fixes what it finds\n\n`svgrid_check_code` does not stop at telling you what is wrong. Where the\ncorrection is exact it returns the corrected file too:\n\n```json\n{\n \"diagnostics\": [ ... ],\n \"applied\": [\"rowData -> data (line 7)\", \"accessorKey -> field (line 3)\"],\n \"fixed\": \"<the corrected source>\"\n}\n```\n\nBoth fields are omitted when there is nothing mechanically fixable, so a clean\ncheck stays small.\n\nThe rules are deliberately narrow, because this tool's whole worth is that it\nnever cries wolf - and rewriting raises the stakes from wasting a turn to\ncorrupting working code. Only exact renames are applied (a known rename, or a\nclose-enough spelling), only on word boundaries, and only on the line the\ndiagnostic reported. Advice that is ambiguous - \"this has no equivalent, remove\nit\" - stays advice. A test asserts that running auto-fix across every demo\nin this repository changes nothing at all.\n\n### It knows which version you have\n\nThe result carries the version it checked against:\n\n```json\n{ \"version\": { \"corpus\": \"3.0.0\", \"installed\": \"2.6.8\", \"warning\": \"...\" } }\n```\n\nThe server reads the `@svgrid/grid` in your project and says plainly when it\ndisagrees with the corpus it ships, so a model is told to hedge instead of\nconfidently citing an API you do not have. A server that answers from a remote\nbackend cannot do this - it has no idea what is in your `node_modules`.\n\n### Nothing leaves your machine\n\nThis server makes **no network calls**. Not for docs, not for the API surface,\nnot for verification - the whole corpus (every demo, every doc page, the full\nexported API) ships inside the package, which is why it is megabytes rather\nthan kilobytes. There is no API key, no licence check on the wire, and no telemetry.\n\nIt works on a plane, behind a corporate proxy, and inside an air-gapped\nnetwork. `tools/mcp-offline.test.ts` enforces it: the server is driven through\na full session with every network primitive booby-trapped, and the test fails if\nanything is even attempted.\n\nThe one honest exception: the **preview** loads the grid from a CDN to draw it.\nThat happens in your client's sandboxed iframe, never in this server, and only\nwhen you actually render a preview.\n\n### Seeing the grid, not just reading about it\n\n`svgrid_preview` renders a **real, interactive SvGrid inside the\nconversation** - sortable, filterable, scrollable. Not a screenshot and not a\nmock table: the same `<sv-grid>` custom element a page would use, loaded from\nthe CDN, with the columns and rows you passed.\n\n```json\n{\n \"title\": \"Team roster\",\n \"columns\": [{ \"field\": \"name\", \"header\": \"Name\" }, { \"field\": \"amount\", \"header\": \"Amount\" }],\n \"data\": [{ \"name\": \"Ada\", \"amount\": 20000 }],\n \"sortable\": true\n}\n```\n\nIt uses [MCP Apps](https://blog.modelcontextprotocol.io/posts/2026-01-26-mcp-apps/),\nthe official UI extension: the tool points at a `ui://` resource through\n`_meta`, the client loads that HTML in a sandboxed iframe, and the tool's\n`structuredContent` arrives over a postMessage bridge. Supported in Claude\n(web and desktop), VS Code and ChatGPT.\n\nClients without UI support are not left out - they ignore the `_meta` and get\na text summary of the same grid, so it is always safe to call. That is the\nextension's own rule, and it is why the text half describes the grid rather\nthan pointing at a picture the reader cannot see.\n\nPass `demo` instead of `columns` / `data` and you get the demo's source: a\ndemo is a Svelte component, not data, so there is nothing to hand the element\nand rendering an empty grid would just look broken.\n\n### Resources and prompts\n\nThe docs and demos are also exposed as **MCP resources**, so a user can\nattach a page or a demo directly instead of hoping the model thinks to\nsearch for it:\n\n```\nsvgrid://doc/help/columns/column-definitions\nsvgrid://example/11-stock-market\n```\n\nAnd three **prompts** ship ready to run: `build_grid`, `explain_api`\nand `review_grid_code`. Each is written to make the model use this\nserver rather than recall SvGrid from training data, and each ends at\n`svgrid_check_code`.\n\n### SvGrid Studio (commercial)\n\nOff unless enabled. Set `SVGRID_MCP_STUDIO=1`, or a valid\n`SVGRID_LICENSE_KEY`, in the server's env, and run the server from a project\nthat has `@svgrid/enterprise` installed beside it\n(`npm i -D @svgrid/mcp @svgrid/enterprise`, then `npx svgrid-mcp`). Without it\nthese tools answer with those steps instead of running.\n\n#### `svgrid_scaffold`\n\nPoint it at a Drizzle schema, sample JSON rows, or an `EntitySchema`\nyou already have, and it infers the schema and generates the `$lib`\nschema module, a `+server.ts` API route and a `+page.svelte` with\n`SvGrid` + `SvGridEditPanel` - in one call. Pass `schemaOnly: true` to\nstop after inference. Generated bodies carry `svgrid:managed` markers,\nso regenerating preserves your edits outside them.\n\n#### The `studio_*` tools\n\nFour tools drive the same validated project model the visual designer\nuses:\n\n| Tool | What it does |\n| ---- | ------------ |\n| `studio_project` | `new`, `load`, `describe`, `config`, `capabilities` |\n| `studio_apply` | A **batch** of model changes - entities, screens, blocks, components - applied in order |\n| `studio_configure` | Theme, auth, access, tenancy, data layer, jobs, deploy target, layouts, in one call |\n| `studio_build` | `validate`, then `generate` the full runnable SvelteKit app |\n\nCall `studio_project` with `action: \"capabilities\"` first: it reports\nexactly what the installed version supports, so the agent does not have\nto guess block kinds or component keys.\n\n`studio_apply` takes a batch on purpose. Building a five-screen app was\ntwenty-odd round trips when every block was its own tool; now a whole\nscreen is one call, and a failure reports which op failed and what\nalready applied.\n\n### The pre-3.0 names\n\nEvery tool name from before 3.0 still answers - `search_docs`,\n`get_doc`, `list_examples`, `get_example_source`, `list_docs`,\n`get_api_reference`, `check_svgrid_code`, `introspect_source`,\n`scaffold_entity` and all 27 individual `studio_*` tools. They are not\n**listed**, because listing is what costs context and answering a name\nyou did not advertise costs nothing. Saved prompts and scripts keep\nworking; nobody pays for the compatibility.\n\nTheir JSON response shape follows 3.0, not 2.x. A model reads either\nwithout trouble; a script that parsed the old shape by hand needs a look.\n\n## Licensing\n\nThe documentation and example tools are free. The Studio code\ngenerators are part of the commercial offering. You can evaluate them\nwithout a key: they run, but prepend a notice comment\nto generated files. To license them, set\nthe key in your MCP client's server config:\n\n```json\n{\n \"mcpServers\": {\n \"svgrid\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@svgrid/mcp\"],\n \"env\": { \"SVGRID_LICENSE_KEY\": \"YOUR-LICENSE-KEY\" }\n }\n }\n}\n```\n\n## Enterprise features and the trial\n\nMost of SvGrid is the MIT `@svgrid/grid` package. Export to Excel and PDF,\npivot tables, the Kanban board, the scheduler, the spreadsheet and the\nserver-side row model are in `@svgrid/enterprise`, which is commercial.\n\nThe server tells your assistant which is which. In `svgrid_search` results a\npaid doc or demo carries `\"enterprise\": true`, and when a question is about a\npaid feature the answer says so once, with the trial link.\n`svgrid_get` puts the same line at the top of a paid doc or demo, and\n`svgrid_check_code` adds it when the fix is to install the package. Nothing\nis sent anywhere to do this; it is part of the answer text.\n\n`@svgrid/enterprise` runs without a license key and shows a watermark until\none is set, so you can try a feature before deciding. The\n[30-day trial](https://svgrid.com/pricing/?trial=mcp-docs) adds a download of\nevery demo and 30 days of email support.\n\n## Verifying it works\n\nAsk your model: *\"What MCP tools do you have from svgrid?\"* The local\nserver lists five, including `svgrid_check_code` (four Studio tools more when\nenabled); the hosted server lists seven.\n\nThen give it something to catch:\n\n> Check this with svgrid: `<SvGrid rowData={rows} {columns} />`\n\nIt should come back with `rowData` is not a SvGrid prop, use `data`. If\nit explains the code instead of calling a tool, the server is not\nconnected.\n\nIf nothing is listed at all, check your client's MCP log. For the local\nserver the usual cause is `npx` not being on PATH - use the absolute path\nto the binary. For the hosted one, confirm the endpoint answers:\n\n```bash\ncurl https://mcp.svgrid.com/health\n```\n\n**\"The svgrid MCP server timed out\" or \"connection timed out after\n30000ms\".** The server starts in well under a second; the wait is `npx`\ndownloading it. That happens on the first start and again after each new\n`@svgrid/mcp` release, and a slow network or a virus scanner can push it\npast the 30 seconds a client waits. Any of these fixes it:\n\n- use the hosted server, which has nothing to download:\n `claude mcp add --transport http svgrid https://mcp.svgrid.com/mcp`\n- install it once, so later starts skip the download:\n `pnpm add -D @svgrid/mcp`, then `claude mcp add svgrid -- npx svgrid-mcp`\n- give the client longer: in Claude Code, start it with `MCP_TIMEOUT=60000`\n\nThe compile pass of `svgrid_check_code` uses the Svelte in the project the\nserver starts in. Started outside a Svelte project, the check still runs\nits API rules and its `compiler` field reads `unavailable`.\n\n## Security model\n\nThe two ways of running it differ here, so pick deliberately.\n\n**Local (`npx @svgrid/mcp`)**\n\n- Runs on your machine over stdio. No telemetry, no outbound network\n calls, no API key.\n- Serves a documentation and example corpus bundled into the package at\n build time, so answers are pinned to the version you installed.\n- `svgrid_check_code` reads the source you pass it in-process and never\n sends it anywhere.\n\n**Hosted (`https://mcp.svgrid.com/mcp`)**\n\n- Your client sends tool arguments to a Cloudflare Worker we operate.\n Anything you pass to a tool leaves your machine, and for\n `check_svgrid_code` that means **the source you ask it to check**.\n- Each call is recorded: tool name, duration, whether it succeeded, the\n query or id it was given, how many pages matched, and whether the answer\n mentioned the Enterprise trial. For `check_svgrid_code` only the **byte\n length** of the submitted source and the names of the rules that fired\n are recorded, never the source itself. The records stay in Cloudflare\n (Workers logs, and an Analytics Engine dataset kept three months) and are\n read in aggregate to see what people ask for.\n- No account, no key, no cookies. Requests are not tied to a user.\n- If your code cannot leave the building, use the local server. That is\n what it is for.\n\n**Both**\n\n- The Studio tools return generated files as data. Writing them to disk\n is your client's decision, not the server's.\n- See [security](./security.md) for the general supply-chain posture.\n\n## Building your own MCP integrations\n\nThe same docs manifest, JSON Schemas (column definitions, the grid's\noptions, export options, and the chart spec at `schemas/chart-spec.json`,\nwhich `svgrid_get` also serves for \"chart spec schema\"), and `llms.txt`\nfiles are also served directly from the docs site:\n\n```ts\nconst docs = await fetch('https://svgrid.com/docs.json').then((r) => r.json())\nconst schemas = await fetch('https://svgrid.com/schemas/index.json').then((r) => r.json())\nconst llms = await fetch('https://svgrid.com/llms-full.txt').then((r) => r.text())\n```\n\nIf you do not want to run the MCP server, building these into your\nagent's system prompt gives most of the same grounding.\n\n## Without the MCP server\n\nAn agent that can only fetch pages gets the same material over plain HTTP,\nin pieces small enough for one fetch (fetch tools cut a response near\n100 KB):\n\n| URL | What it holds |\n|---|---|\n| `/llms.txt` | The docs index, with links to everything below. `/llms/<product>.txt` (grid, ui, enterprise, sheet, base, studio, compare) is one product's part of it |\n| `/docs/<slug>.md` | One docs page as markdown |\n| `/demos.md`, `/demos/<id>.md` | Every live demo, and one demo with what it shows and its full source |\n| `/api.json` | Every export of `@svgrid/grid` and `@svgrid/enterprise` by module, with the member names of each type |\n| `/api/<name>.json` | One symbol's doc comment and signature, by its lowercased name: `/api/svgridapi.json`, `/api/createreview.json` |\n| `/.well-known/mcp.json` | Where this server is: the remote endpoint, the npm package, the setup commands |\n\n```ts\nconst index = await fetch('https://svgrid.com/api.json').then((r) => r.json())\nconst api = await fetch('https://svgrid.com/api/svgridapi.json').then((r) => r.json())\nconst demo = await fetch('https://svgrid.com/demos/702-change-review.md').then((r) => r.text())\n```\n\nIn a browser with WebMCP (`document.modelContext`), svgrid.com registers\nfour tools for an agent driving the page: `svgrid_search`, `svgrid_get_doc`,\n`svgrid_get_demo` and `svgrid_lookup_api`. They answer from the files\nabove.\n\n## Frequently asked questions\n\n### What is the SvGrid MCP server?\n\nA Model Context Protocol server that lets AI clients (Claude Code, Claude\nDesktop, Cursor, Zed, custom agents) query SvGrid's documentation, read real\ndemo source, scaffold SvelteKit CRUD apps, and check the code they write\nagainst the real API - grounded in the files the package ships, so the model\nanswers from current facts instead of guessing.\n\n### Do I need an API key to run it?\n\nNo, on either transport. A `SVGRID_LICENSE_KEY` is optional and only affects\nthe commercial Studio code generators.\n\n### Local or hosted - which should I use?\n\nHosted (`https://mcp.svgrid.com/mcp`) if you want it working in one paste,\nwith no Node and no config file. Local (`npx @svgrid/mcp`) if you want the\nSvelte compiler pass in `svgrid_check_code`, the Studio tools, offline\nuse, or your source never leaving the machine. See\n[Security model](#security-model) for what each one sends.\n\n### How does it help AI assistants write better SvGrid code?\n\nTwo ways. It exposes the docs, example sources, and API reference as tools,\nso the assistant retrieves version-pinned answers instead of hallucinating an\nAPI from training data. And `svgrid_check_code` closes the loop: the model\nruns what it wrote past the real exported surface and gets told exactly what\nis wrong before you see it. That matters most for Svelte 5, where models\nroutinely mix in outdated Svelte 4 syntax.\n\n### Does it work with a version of SvGrid I have not upgraded to?\n\nThe local server answers for the version bundled in the `@svgrid/mcp` release\nyou install, so pin it alongside `@svgrid/grid` if you are behind. The hosted\nserver always tracks the current release. Either way, every\n`svgrid_check_code` result names the version it checked against in its\n`checkedAgainst` field.\n\n## See also\n\n- [Agent Skill](./skill.md) - the always-on house-style layer; the Claude Code plugin installs it together with this server\n- [LLM grounding](./llm-grounding.md) - the same files used by the MCP server, but documented for direct LLM consumption\n- [Agents](./agents.md) - how to build an AI agent that drives the live grid\n- [AI assistant](./ai.md) - the in-grid AI features (filter / smart-fill / classify / summarise), free in @svgrid/grid\n"
6064
6064
  },
6065
6065
  {
6066
6066
  "slug": "help/migrating-from-ag-grid",
@@ -7439,7 +7439,7 @@ export const docs = [
7439
7439
  "path": "docs/help/ui-components/sv-rich-text.md",
7440
7440
  "title": "SvRichText",
7441
7441
  "section": "UI components",
7442
- "markdown": "# SvRichText\n\nA lightweight WYSIWYG editor: a formatting toolbar over a `contentEditable`\nregion that emits HTML through a bindable `value`.\n\n`SvRichText` covers the common editing commands - bold, italic, underline,\nstrikethrough, headings, lists, quote, code block, alignment, links, and\nundo/redo - in a compact toolbar you can reorder or trim. It emits an HTML string\nvia `bind:value` and reflects the active formatting state (bold/italic and list\nbuttons light up with the caret). It uses `document.execCommand`, the pragmatic\napproach for a component-kit editor. All color comes from the `--sg-*` tokens.\n\n`value` goes through `sanitizeHtml` on its way in and out, so a stored string\ncannot run a script: event attributes, `javascript:` links and any style but a\ntext alignment are removed.\n\nRelated: [Inputs overview](inputs.md) · [SvForm](sv-form.md) · [Navigation & rich overview](navigation.md)\n\n## Installation\n\nAdd it with the CLI - this drops a ready-to-edit `SvRichText` starter into your app:\n\n<div data-docs-add=\"add rich-text\"></div>\n\nPrefer to see it first? `npx @svgrid/ui try rich-text` opens it in a throwaway sandbox - no project needed.\n\nOr install the package and import it directly. `SvRichText` ships free in\n`@svgrid/grid` (dependency-free):\n\n<div data-docs-install=\"@svgrid/grid\"></div>\n\nThe examples on this page import from `@svgrid/grid`:\n\n```svelte {preamble}\n<script lang=\"ts\">\n import { SvButton, SvRichText } from '@svgrid/grid'\n</script>\n```\n\n```ts\nimport { SvRichText } from '@svgrid/grid'\n```\n\n## Example\n\n<div data-docs-demo=\"341-rich-text-editor\" data-height=\"440\" data-code></div>\n\n```svelte {runnable}\n<script lang=\"ts\">\n import { SvRichText } from '@svgrid/grid'\n let html = $state('<p>Hello</p>')\n</script>\n\n<SvRichText bind:value={html} placeholder=\"Write something…\" />\n```\n\n## Props\n\n| Prop | Type | Default | Description |\n| ------------- | --------------------------- | --------------------- | -------------------------------------------------------------- |\n| `value` | `string` | `''` | HTML string (bindable). |\n| `onChange` | `(html: string) => void` | - | Fires with the HTML on every edit. |\n| `placeholder` | `string` | `''` | Shown when the editor is empty. |\n| `disabled` | `boolean` | `false` | Dims the editor and blocks all input. |\n| `readonly` | `boolean` | `false` | Hides the toolbar and makes the body non-editable. |\n| `minHeight` | `string` | `160px` | Minimum height of the editable body (any CSS length). |\n| `tools` | `RichTextTool[]` | full default set | Toolbar tools and their order; use `'\\|'` for a separator. |\n| `ariaLabel` | `string` | `Rich text editor` | Accessible name for the editable region. |\n\n`RichTextTool` (exported) is one of:\n`'bold' | 'italic' | 'underline' | 'strike' | 'h1' | 'h2' | 'h3' | 'p' | 'ul' | 'ol' | 'quote' | 'code' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'link' | 'clear' | 'undo' | 'redo' | '|'`.\nThe `'|'` entry draws a visual separator between tool groups.\n\n## Examples\n\n### A trimmed toolbar\n\nPass just the tools you need; group them with `'|'` separators:\n\n```svelte\n<SvRichText\n bind:value={note}\n tools={['bold', 'italic', '|', 'ul', 'ol', '|', 'link']}\n/>\n```\n\n### Read-only rendering\n\nSet `readonly` to show formatted content without a toolbar - useful for previews\nof the same HTML the editor produced:\n\n```svelte\n<SvRichText value={savedHtml} readonly />\n```\n\n### Reacting to edits\n\nPersist on change instead of only on blur:\n\n```svelte\n<SvRichText bind:value={html} onChange={(h) => queueSave(h)} />\n```\n\n### A field bound to a record, with preview\n\nBind `value` straight to a field on your state object so edits flow back into the\nmodel. Track a `dirty` flag from `onChange` to gate the Save button, then flip to\n`readonly` to preview the exact HTML the editor produced:\n\n```svelte {runnable}\n<script lang=\"ts\">\n import { SvRichText, SvButton } from '@svgrid/grid'\n\n let ticket = $state({ id: 42, notes: '<p>Initial triage notes.</p>' })\n let editing = $state(true)\n let dirty = $state(false)\n\n function save() {\n fetch(`/api/tickets/${ticket.id}`, {\n method: 'PATCH',\n body: JSON.stringify({ notes: ticket.notes }),\n })\n dirty = false\n editing = false\n }\n</script>\n\n{#if editing}\n <SvRichText\n bind:value={ticket.notes}\n tools={['bold', 'italic', '|', 'ul', 'ol', '|', 'link', 'clear']}\n minHeight=\"200px\"\n placeholder=\"Add triage notes...\"\n onChange={() => (dirty = true)}\n />\n <SvButton variant=\"primary\" disabled={!dirty} onclick={save}>Save</SvButton>\n{:else}\n <SvRichText value={ticket.notes} readonly />\n <SvButton onclick={() => (editing = true)}>Edit</SvButton>\n{/if}\n```\n\nTip: an external change to `value` is written into the editor only while it is\nnot focused - writing `innerHTML` mid-caret would collapse the selection - so a\nvalue set from elsewhere applies once the field blurs. `readonly` mode drops the\ntoolbar and renders the same HTML, making it a zero-cost preview of what you saved.\n\n## Accessibility\n\n- The editable region is a `role=\"textbox\"` with `aria-multiline` and an\n `aria-label`.\n- The toolbar is a `role=\"toolbar\"` wired to the body via `aria-controls`.\n- Toggle tools (bold, italic, lists) expose `aria-pressed` reflecting the current\n caret state; every button has a descriptive label.\n\n## Disabled and read-only\n\nDisabled takes the control out of the tab order; read-only keeps it focusable and copyable. Reach for read-only when the value still matters to the reader.\n\n```svelte {runnable}\n<script lang=\"ts\">\n import { SvRichText } from '@svgrid/grid'\n\n let html = $state('')\n</script>\n\n<SvRichText bind:value={html} disabled />\n\n<SvRichText bind:value={html} readonly />\n```\n\n## See also\n\n- [Navigation overview](navigation.md) - the wayfinding family at a glance.\n- [Inputs overview](inputs.md) - the text and value editors.\n- [SvForm](sv-form.md) - collect rich text alongside other fields.\n"
7442
+ "markdown": "# SvRichText\n\nA lightweight WYSIWYG editor: a formatting toolbar over a `contentEditable`\nregion that emits HTML through a bindable `value`.\n\n`SvRichText` covers the common editing commands - bold, italic, underline,\nstrikethrough, headings, lists, quote, code block, alignment, links, and\nundo/redo - in a compact toolbar you can reorder or trim. It emits an HTML string\nvia `bind:value` and reflects the active formatting state (bold/italic and list\nbuttons light up with the caret). It uses `document.execCommand`, the pragmatic\napproach for a component-kit editor. All color comes from the `--sg-*` tokens.\n\n`value` goes through `sanitizeHtml` on its way in and out, so a stored string\ncannot run a script: event attributes, `javascript:` links and any style but a\ntext alignment are removed.\n\nFour more tools can be listed in `tools` for page and article editing: `image`\n(uploaded through `onImageUpload`), `table`, `hr` and `source` (the HTML itself).\nWith `name`, the editor posts its value with a plain form.\n\nRelated: [Inputs overview](inputs.md) · [SvForm](sv-form.md) · [Navigation & rich overview](navigation.md)\n\n## Installation\n\nAdd it with the CLI - this drops a ready-to-edit `SvRichText` starter into your app:\n\n<div data-docs-add=\"add rich-text\"></div>\n\nPrefer to see it first? `npx @svgrid/ui try rich-text` opens it in a throwaway sandbox - no project needed.\n\nOr install the package and import it directly. `SvRichText` ships free in\n`@svgrid/grid` (dependency-free):\n\n<div data-docs-install=\"@svgrid/grid\"></div>\n\nThe examples on this page import from `@svgrid/grid`:\n\n```svelte {preamble}\n<script lang=\"ts\">\n import { SvButton, SvRichText } from '@svgrid/grid'\n</script>\n```\n\n```ts\nimport { SvRichText } from '@svgrid/grid'\n```\n\n## Example\n\n<div data-docs-demo=\"341-rich-text-editor\" data-height=\"440\" data-code></div>\n\n```svelte {runnable}\n<script lang=\"ts\">\n import { SvRichText } from '@svgrid/grid'\n let html = $state('<p>Hello</p>')\n</script>\n\n<SvRichText bind:value={html} placeholder=\"Write something…\" />\n```\n\n## Props\n\n| Prop | Type | Default | Description |\n| ------------- | --------------------------- | --------------------- | -------------------------------------------------------------- |\n| `value` | `string` | `''` | HTML string (bindable). |\n| `onChange` | `(html: string) => void` | - | Fires with the HTML on every edit. |\n| `placeholder` | `string` | `''` | Shown when the editor is empty. |\n| `disabled` | `boolean` | `false` | Dims the editor and blocks all input. |\n| `readonly` | `boolean` | `false` | Hides the toolbar and makes the body non-editable. |\n| `minHeight` | `string` | `160px` | Minimum height of the editable body (any CSS length). |\n| `tools` | `RichTextTool[]` | full default set | Toolbar tools and their order; use `'\\|'` for a separator. |\n| `ariaLabel` | `string` | `Rich text editor` | Accessible name for the editable region. |\n| `messages` | `Partial<RichTextMessages>` | - | Any toolbar label or prompt, for localization. |\n| `onImageUpload` | `(file: File) => Promise<string \\| null>` | - | The `image` tool's upload: resolve to the URL to insert. Without it, the tool asks for a URL. |\n| `sanitize` | `(html: string) => string` | `sanitizeHtml` | Replaces the sanitizer both ways, for content the app trusts. |\n| `name` | `string` | - | Posts the value with a native form, as a hidden input. |\n\n`RichTextTool` (exported) is one of:\n`'bold' | 'italic' | 'underline' | 'strike' | 'h1' | 'h2' | 'h3' | 'p' | 'ul' | 'ol' | 'quote' | 'code' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'link' | 'clear' | 'undo' | 'redo' | 'image' | 'table' | 'hr' | 'source' | '|'`.\nThe `'|'` entry draws a visual separator between tool groups. The default\ntoolbar is every tool up to `redo`; `image`, `table`, `hr` and `source` appear\nonly when listed.\n\n## Examples\n\n### A trimmed toolbar\n\nPass just the tools you need; group them with `'|'` separators:\n\n```svelte\n<SvRichText\n bind:value={note}\n tools={['bold', 'italic', '|', 'ul', 'ol', '|', 'link']}\n/>\n```\n\n### Pages and articles: images, tables, the HTML\n\nFor a CMS page or a blog post, list the extra tools, upload images to your\nserver and post the editor with the rest of the form. `sanitize` is replaced\nonly because the administrators who write these pages are trusted to use\ninline styles; keep the default for anything a visitor can write.\n\n```svelte\n<script lang=\"ts\">\n import { SvRichText } from '@svgrid/grid'\n\n async function upload(file: File) {\n const body = new FormData()\n body.append('image', file)\n const answer = await (await fetch('/api/upload', { method: 'POST', body })).json()\n return answer.url ?? null\n }\n</script>\n\n<form method=\"post\">\n <SvRichText\n name=\"content\"\n value={page.content}\n tools={['bold', 'italic', 'h2', 'h3', '|', 'ul', 'ol', '|', 'link', 'image', 'table', 'hr', '|', 'source', 'undo', 'redo']}\n onImageUpload={upload}\n sanitize={(html) => html.replace(/<script[\\s\\S]*?<\\/script>/gi, '')}\n />\n <button>Save</button>\n</form>\n```\n\n`source` swaps the body for a text area with the HTML; the other tools wait\nuntil it is switched off, and what was typed there goes through `sanitize`.\n\n### Read-only rendering\n\nSet `readonly` to show formatted content without a toolbar - useful for previews\nof the same HTML the editor produced:\n\n```svelte\n<SvRichText value={savedHtml} readonly />\n```\n\n### Reacting to edits\n\nPersist on change instead of only on blur:\n\n```svelte\n<SvRichText bind:value={html} onChange={(h) => queueSave(h)} />\n```\n\n### A field bound to a record, with preview\n\nBind `value` straight to a field on your state object so edits flow back into the\nmodel. Track a `dirty` flag from `onChange` to gate the Save button, then flip to\n`readonly` to preview the exact HTML the editor produced:\n\n```svelte {runnable}\n<script lang=\"ts\">\n import { SvRichText, SvButton } from '@svgrid/grid'\n\n let ticket = $state({ id: 42, notes: '<p>Initial triage notes.</p>' })\n let editing = $state(true)\n let dirty = $state(false)\n\n function save() {\n fetch(`/api/tickets/${ticket.id}`, {\n method: 'PATCH',\n body: JSON.stringify({ notes: ticket.notes }),\n })\n dirty = false\n editing = false\n }\n</script>\n\n{#if editing}\n <SvRichText\n bind:value={ticket.notes}\n tools={['bold', 'italic', '|', 'ul', 'ol', '|', 'link', 'clear']}\n minHeight=\"200px\"\n placeholder=\"Add triage notes...\"\n onChange={() => (dirty = true)}\n />\n <SvButton variant=\"primary\" disabled={!dirty} onclick={save}>Save</SvButton>\n{:else}\n <SvRichText value={ticket.notes} readonly />\n <SvButton onclick={() => (editing = true)}>Edit</SvButton>\n{/if}\n```\n\nTip: an external change to `value` is written into the editor only while it is\nnot focused - writing `innerHTML` mid-caret would collapse the selection - so a\nvalue set from elsewhere applies once the field blurs. `readonly` mode drops the\ntoolbar and renders the same HTML, making it a zero-cost preview of what you saved.\n\n## Accessibility\n\n- The editable region is a `role=\"textbox\"` with `aria-multiline` and an\n `aria-label`.\n- The toolbar is a `role=\"toolbar\"` wired to the body via `aria-controls`.\n- Toggle tools (bold, italic, lists) expose `aria-pressed` reflecting the current\n caret state; every button has a descriptive label.\n\n## Disabled and read-only\n\nDisabled takes the control out of the tab order; read-only keeps it focusable and copyable. Reach for read-only when the value still matters to the reader.\n\n```svelte {runnable}\n<script lang=\"ts\">\n import { SvRichText } from '@svgrid/grid'\n\n let html = $state('')\n</script>\n\n<SvRichText bind:value={html} disabled />\n\n<SvRichText bind:value={html} readonly />\n```\n\n## See also\n\n- [Navigation overview](navigation.md) - the wayfinding family at a glance.\n- [Inputs overview](inputs.md) - the text and value editors.\n- [SvForm](sv-form.md) - collect rich text alongside other fields.\n"
7443
7443
  },
7444
7444
  {
7445
7445
  "slug": "help/ui-components/sv-scroll-area",
@@ -8825,8 +8825,8 @@ export const apiReference = {
8825
8825
  ]
8826
8826
  };
8827
8827
  export const apiSurface = {
8828
- "gridVersion": "3.0.34",
8829
- "enterpriseVersion": "3.1.39",
8828
+ "gridVersion": "3.0.35",
8829
+ "enterpriseVersion": "3.1.40",
8830
8830
  "grid": {
8831
8831
  "values": [
8832
8832
  "ALL_FILTER_OPERATORS",