@altertable/data-app 0.76.0 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CONTRIBUTING.md +3 -0
  2. package/REFERENCE.md +392 -276
  3. package/dist/chunks/contract-gu1rDsV0.js +1588 -0
  4. package/dist/chunks/contract-gu1rDsV0.js.map +1 -0
  5. package/dist/chunks/data-client-BMdL73Ab.js +122 -0
  6. package/dist/chunks/data-client-BMdL73Ab.js.map +1 -0
  7. package/dist/chunks/{date-time-range-value-TE8KCsfV.js → date-time-range-value-D-XfqVTT.js} +28 -31
  8. package/dist/chunks/date-time-range-value-D-XfqVTT.js.map +1 -0
  9. package/dist/chunks/{diagnostics-DhCqGklq.js → diagnostics-CX9SsU79.js} +240 -63
  10. package/dist/chunks/diagnostics-CX9SsU79.js.map +1 -0
  11. package/dist/chunks/record-Cr4Uk1K3.js +9 -0
  12. package/dist/chunks/record-Cr4Uk1K3.js.map +1 -0
  13. package/dist/client/index.js +4 -86
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/core/appearance.js +3 -5
  16. package/dist/core/appearance.js.map +1 -1
  17. package/dist/core/config.js +11 -3
  18. package/dist/core/config.js.map +1 -1
  19. package/dist/core/contract.js +3 -4
  20. package/dist/core/format.js +1 -1
  21. package/dist/internal.js +58 -124
  22. package/dist/internal.js.map +1 -1
  23. package/dist/types/chunks/contract.d.ts +592 -308
  24. package/dist/types/chunks/data-client.d.ts +46 -0
  25. package/dist/types/chunks/date-time-range-value.d.ts +28 -2
  26. package/dist/types/chunks/index.d.ts +65 -53
  27. package/dist/types/client/index.d.ts +4 -3
  28. package/dist/types/core/config.d.ts +16 -6
  29. package/dist/types/core/contract.d.ts +3 -5
  30. package/dist/types/core/format.d.ts +1 -2
  31. package/dist/types/index.d.ts +4 -4
  32. package/dist/types/internal.d.ts +26 -7
  33. package/docs/app-authoring.md +23 -14
  34. package/docs/client.md +14 -48
  35. package/docs/contract.md +58 -56
  36. package/docs/data-context.md +13 -6
  37. package/docs/diagnostics.md +16 -23
  38. package/docs/embed.md +60 -25
  39. package/docs/filters.md +271 -0
  40. package/docs/hosted-apps.md +11 -10
  41. package/docs/layout.md +45 -18
  42. package/docs/local-data-apps.md +5 -6
  43. package/docs/react-embed.md +44 -2
  44. package/docs/react.md +1 -2
  45. package/docs/server-bun.md +8 -5
  46. package/docs/stories-and-export.md +23 -14
  47. package/docs/styling.md +2 -1
  48. package/docs/ui.md +18 -8
  49. package/docs/views.md +63 -26
  50. package/docs/widgets.md +40 -16
  51. package/docs/worker.md +1 -1
  52. package/package.json +1 -5
  53. package/dist/chunks/contract-DsyRYgN_.js +0 -626
  54. package/dist/chunks/contract-DsyRYgN_.js.map +0 -1
  55. package/dist/chunks/contract-kNFYPHRK.js +0 -713
  56. package/dist/chunks/contract-kNFYPHRK.js.map +0 -1
  57. package/dist/chunks/date-time-range-value-TE8KCsfV.js.map +0 -1
  58. package/dist/chunks/diagnostics-DhCqGklq.js.map +0 -1
  59. package/dist/chunks/operation-7tiT4cpJ.js +0 -134
  60. package/dist/chunks/operation-7tiT4cpJ.js.map +0 -1
  61. package/dist/chunks/request-body-H1qPmmTN.js +0 -50
  62. package/dist/chunks/request-body-H1qPmmTN.js.map +0 -1
  63. package/dist/server/index.js +0 -90
  64. package/dist/server/index.js.map +0 -1
  65. package/dist/types/chunks/contract2.d.ts +0 -207
  66. package/dist/types/chunks/date-time-range.d.ts +0 -29
  67. package/dist/types/server/index.d.ts +0 -17
  68. package/docs/server.md +0 -41
  69. package/docs/variables.md +0 -280
@@ -0,0 +1,271 @@
1
+ # Filters and display options
2
+
3
+ Declare each filter once as a constant and list it in `filters` on every
4
+ operation that reads it. Everything else derives from that list: input
5
+ validation, checks, the view's period and scope, and the controls `<DataApp>`
6
+ renders. Import filters from `@altertable/data-app/contract`.
7
+
8
+ ## Declare filters on operations
9
+
10
+ This sample-count example shares one fixed group choice across operations:
11
+
12
+ ```tsx
13
+ import { choiceFilter, parseCount } from '@altertable/data-app/contract';
14
+
15
+ // ... dataApp, sampleDataContext, and section contents
16
+ const groupName = choiceFilter({
17
+ key: 'group',
18
+ label: 'Group',
19
+ defaultValue: 'all',
20
+ options: [
21
+ { id: 'all', label: 'All groups' },
22
+ { id: 'Alpha', label: 'Alpha' },
23
+ { id: 'Beta', label: 'Beta' },
24
+ ],
25
+ });
26
+
27
+ const operations = dataApp.defineOperations({
28
+ sampleCountsByGroup: dataApp.defineOperation({
29
+ filters: { groupName },
30
+ policy: { maxQueryRows: 10, maxDurationMs: 15000 },
31
+ async run({ query }, { groupName }) {
32
+ const result = await query('sampleCountsByGroup', {
33
+ groupName: groupName === 'all' ? '' : groupName,
34
+ });
35
+ return result.rows.map(row => ({
36
+ groupName: row.group_name,
37
+ sampleCount: parseCount(row.sample_count),
38
+ }));
39
+ },
40
+ }),
41
+ // ... sampleTotal reads the same { groupName }
42
+ });
43
+ const { defineView } = createDataHooks(operations.createDataClient());
44
+ const sampleCountsView = defineView({
45
+ dataContext: sampleDataContext,
46
+ operation: 'sampleCountsByGroup',
47
+ isEmpty: rows => rows.length === 0,
48
+ emptyFallback: { title: 'No matching groups' },
49
+ });
50
+
51
+ function App() {
52
+ return (
53
+ <DataApp view={sampleCountsView}>
54
+ <DataSection content={countsContent} />
55
+ </DataApp>
56
+ );
57
+ }
58
+ ```
59
+
60
+ - Reuse the same constant on every operation that reads it; two filters with one
61
+ name, or one URL key, fail.
62
+ - Omit `filters` for an operation without inputs.
63
+ - A detail operation that also needs its own fields, such as a record ID, keeps
64
+ `filters` for the scope and adds `input` and `checks` for those fields only.
65
+ - The view's scope reads like “Mar 1–7, 2026 UTC · group Alpha” or “all data”.
66
+ Pass `describeInput` only for different copy.
67
+ - Use `searchFilter()` to query the server; use a table's `search` prop to filter
68
+ rows already loaded.
69
+
70
+ ## Read filter values
71
+
72
+ `run(context, input)` receives one field per declared filter:
73
+
74
+ | Filter | Input value |
75
+ | ------------------------------------------------------ | ---------------------------------------------- |
76
+ | `searchFilter()` | `string`, at most `maxLength` (200 by default) |
77
+ | `choiceFilter()`, `displayChoice()` | Selected option ID |
78
+ | `multiChoiceFilter()` | Selected option IDs |
79
+ | `dimensionFilter()`, `facetFilter()`, source dimension | `DimensionSelection` |
80
+ | `numberFilter()`, `booleanFilter()` | `NumberSelection`, `BooleanSelection` |
81
+ | `dateTimeRangeFilter()` | `{ range, comparison }` of resolved dates |
82
+
83
+ Pass values to declared query parameters; never interpolate them into SQL. Bind
84
+ date filter bounds as [separate parameters](contract.md#bind-date-ranges).
85
+ For a single-value choice, bind its selected ID as a string:
86
+
87
+ ```ts
88
+ // ... in defineDataApp({ queries })
89
+ revenueByCampaign: {
90
+ statement: `SELECT o.campaign, sum(o.amount) AS revenue
91
+ FROM demo.orders o JOIN demo.customers c ON c.id = o.customer_id
92
+ WHERE c.country = $country
93
+ GROUP BY o.campaign`,
94
+ params: { country: { type: 'string' } },
95
+ projections: { campaign: { type: 'string' }, revenue: { type: 'number' } },
96
+ },
97
+ // ... in the operation: query('revenueByCampaign', { country: input.country })
98
+ ```
99
+
100
+ Dimension selections bind as JSON. Express multiple values, missing values, and
101
+ exclusion in DuckDB SQL. Dimension, number, and boolean selections support
102
+ `{ kind: 'all' }`. Offer only predicates the registered query supports.
103
+
104
+ ## Categorical dimensions
105
+
106
+ For source-backed members, use `dataApp.defineDimension()`:
107
+
108
+ ```ts
109
+ // ... dataApp with its registered groups query
110
+ const group = dataApp.defineDimension({
111
+ key: 'group',
112
+ label: 'Group',
113
+ valueType: 'string',
114
+ selectionMode: 'multiple',
115
+ source: { query: 'groups' },
116
+ });
117
+ ```
118
+
119
+ Declare the source query in `defineDataApp()` with a nullable `member` parameter
120
+ matching `valueType`. Its nonnullable projections are `value` (same type),
121
+ `label` (string), and optional `count` (number). Null requests options; a selected
122
+ member requests exact lookup. Other parameters need defaults or trusted values:
123
+
124
+ ```sql
125
+ SELECT DISTINCT group_name AS value, group_name AS label
126
+ FROM sample_counts
127
+ WHERE ($member IS NULL OR group_name = $member)
128
+ ORDER BY label
129
+ ```
130
+
131
+ Operations reading `group` check selected members against this query before
132
+ `run()`. Use `dimensionFilter()` when options are known constants:
133
+
134
+ ```ts
135
+ const group = dimensionFilter({
136
+ key: 'group',
137
+ label: 'Group',
138
+ valueType: 'string',
139
+ selectionMode: 'multiple',
140
+ options: [
141
+ { value: 'Alpha', label: 'Alpha' },
142
+ { value: 'Beta', label: 'Beta' },
143
+ ],
144
+ });
145
+ ```
146
+
147
+ Set `defaultValue` to start from a narrower selection, such as
148
+ `{ kind: 'include', members: [{ kind: 'value', value: 'paid' }] }`; clearing
149
+ filters still returns to every member.
150
+
151
+ No selection means every member. Enable `allowExclusion` and `allowMissing` only
152
+ when the query handles them. Use `multiChoiceFilter()` for fixed multiselect
153
+ choices; empty means no choices, unlike an unrestricted dimension.
154
+
155
+ ## Facet filters
156
+
157
+ Use `facetFilter()` only when options must follow other selections:
158
+
159
+ ```ts
160
+ // ... period filter
161
+ const group = facetFilter({
162
+ key: 'group',
163
+ label: 'Group',
164
+ valueType: 'string',
165
+ selectionMode: 'multiple',
166
+ options: 'groupOptions',
167
+ });
168
+ const operations = {
169
+ groupOptions: dataApp.defineOperation({
170
+ filters: { period },
171
+ // ... policy, and run() returning DimensionOption[] for the period
172
+ }),
173
+ groupCounts: dataApp.defineOperation({
174
+ filters: { period, group },
175
+ // ... policy and run()
176
+ }),
177
+ };
178
+ ```
179
+
180
+ - `options` names a registered operation. Its filters decide what narrows the
181
+ options: here, changing `period` reloads them.
182
+ - Return `{ value, label, count? }[]` from `run()`, at most 200 values. The picker
183
+ shows `count` beside each option.
184
+ - The server checks a facet selection's shape, not its members; use a source
185
+ dimension when unknown members must be rejected.
186
+
187
+ ## Display choices and breakdowns
188
+
189
+ Use `displayChoice()` for a choice that changes how results are shown rather
190
+ than which data is included. List it on the operation, which receives the
191
+ selected ID and groups its results accordingly:
192
+
193
+ ```ts
194
+ const countsBy = displayChoice({
195
+ key: 'counts-by',
196
+ label: 'Counts breakdown',
197
+ defaultValue: 'group',
198
+ options: [
199
+ { id: 'group', label: 'Group' },
200
+ { id: 'country', label: 'Country' },
201
+ ],
202
+ presentation: { control: 'widget' },
203
+ });
204
+ // ... sampleCountsByGroup declares filters: { groupName, countsBy }
205
+ ```
206
+
207
+ Pass `view.breakdown('countsBy')` to `<VisualizationWidget breakdown>`. Without
208
+ `control: 'widget'`, the choice renders in the toolbar's display options. Use one
209
+ choice per independently controlled chart. Use
210
+ `presentation.prominence: 'secondary'` for less frequent filters.
211
+
212
+ ## Date ranges
213
+
214
+ Use one `dateTimeRangeFilter()` per operation. It sets the view's reporting
215
+ period, time zone, and metric comparisons:
216
+
217
+ ```ts
218
+ import {
219
+ dateTimeRangeFilter,
220
+ dateTimeRangePresets,
221
+ queryDateTimeRangeParams,
222
+ } from '@altertable/data-app/contract';
223
+
224
+ const periodFilter = dateTimeRangeFilter({
225
+ key: 'period',
226
+ defaultValue: '30d',
227
+ maxRangeDays: 90,
228
+ comparison: 'off',
229
+ presets: dateTimeRangePresets.analytics,
230
+ });
231
+ const dailyCounts = dataApp.defineOperation({
232
+ filters: { period: periodFilter, groupName },
233
+ policy: { maxQueryRows: 100, maxDurationMs: 15000 },
234
+ async run({ query }, { period, groupName }) {
235
+ const current = await query('dailyCounts', {
236
+ ...queryDateTimeRangeParams(periodFilter, period, 'period').current,
237
+ groupName,
238
+ });
239
+ // ... use .comparison for the previous period when selected
240
+ return current.rows;
241
+ },
242
+ });
243
+ ```
244
+
245
+ - `run()` receives `{ range, comparison }` with resolved dates. Ranges include
246
+ `from` and exclude `to`: September 24–30 queries `2026-09-24T00:00:00Z`
247
+ through `2026-10-01T00:00:00Z`. Bind them as
248
+ [separate parameters](contract.md#bind-date-ranges).
249
+ - A range that runs past now ends at now: today picked in the calendar queries
250
+ midnight through the current time.
251
+ - `comparison: 'off'` or `'on'` offers the previous-period toggle, starting in
252
+ that state. `period.comparison` is the same window one selected length
253
+ earlier, such as yesterday through the same time, while the toggle is on, and
254
+ `null` otherwise. Omit `comparison` for no toggle.
255
+ - `defaultValue` and preset `range` take range text such as `'24h'`, `'7d'`, or
256
+ `'6mo'`, or `{ from, to }`. `dateTimeRangePresets.analytics` covers days to a
257
+ year; `dateTimeRangePresets.monitoring` covers minutes to 24 hours.
258
+ - Relative ranges such as `'7d'` resolve in `timeZone`, UTC by default.
259
+ - `minDate`, `maxDate`, and `maxRangeDays` limit what readers can pick.
260
+ Coverage runs through now; set `completeDays: true` to end it yesterday when
261
+ the source loads whole days.
262
+
263
+ ## Exclusion, clear, and reset
264
+
265
+ Clear removes filter predicates and returns dates to defaults, preserving search
266
+ and display choices. `resetAll()` restores all defaults. Filters apply immediately;
267
+ use app-owned drafts only when the task needs Apply/Cancel.
268
+
269
+ Custom control ownership is needed only when generated controls cannot express
270
+ the requirement; use `/ui` for that case. Do not reuse reserved inspection,
271
+ presentation, or navigation URL keys.
@@ -14,24 +14,25 @@ interpolation), finite signed numbers, booleans, and null. Parentheses, `as`, an
14
14
  `satisfies` are allowed. Keep executable composition outside the call; omit spreads,
15
15
  computed keys, references, and callbacks. Static apps use `queries: {}`.
16
16
 
17
- Replace sample queries and bindings with inspected source data. Supply `scope`
17
+ Replace sample queries, operations, and datasets with inspected source data. Supply `scope`
18
18
  in `defineDataApp()`. When using bound `<DataApp>`, follow its current
19
19
  [story and dataset requirements](stories-and-export.md).
20
20
 
21
- Keep the starter's client, style injection, and mounting code. The host supplies
22
- the transport; no bootstrap or message routes are needed in app code.
21
+ Keep the starter's client, style injection, and mounting code. The current
22
+ single-file starter collects the operations with `dataApp.defineOperations()`
23
+ and uses `operations.createDataClient()`. The operation's `run()` executes in
24
+ the iframe and sends its registered query IDs and parameter values through
25
+ `data:query`; no bootstrap or message routes are needed in app code.
23
26
 
24
27
  ## Convert a local data app
25
28
 
26
- 1. Combine the app's operations and parsers, data context, views, any presentation
29
+ 1. Combine the app's filters, operations, data context, views, any presentation
27
30
  and export features, app declaration, and browser entry into one `index.tsx`, following the
28
31
  [single-file starter](app-authoring.md#use-release-matched-starters).
29
- 2. Replace the HTTP client with `createDataClient({ operations })`, using the
30
- operation registry as a value. See [browser-owned operations](client.md#browser-owned-operations-for-bundle-apps)
31
- for execution through the host.
32
- 3. Remove the Bun server, HTML, server adapters, credentials, and relative or
33
- app-alias imports. Rewrite any operation that depends on server-only code
34
- to use the operation's `query()` helper.
32
+ 2. Keep `operations.createDataClient()`; the hosted bootstrap supplies its
33
+ query bridge. See [registered operations](client.md#registered-operations).
34
+ 3. Remove the Bun server, HTML, local query adapter installation, credentials,
35
+ and relative or app-alias imports.
35
36
  4. Confirm the host can query the same catalogs, tables, and fields.
36
37
  [Verify the app](app-authoring.md#verify-the-app) in the hosted runtime against
37
38
  the local version's filters and findings.
package/docs/layout.md CHANGED
@@ -2,26 +2,32 @@
2
2
 
3
3
  Use `<Stack>` for reading order, `<Grid>` for peer widgets, and `<GridItem>` for
4
4
  spans. The shell owns page width and gutters; parents own spacing and widgets
5
- own internal padding. Keep default density unless customization is requested.
5
+ own internal padding. Lay out sections the same way as widgets; static headings
6
+ and prose stay outside their loading boundaries. Keep default density unless
7
+ customization is requested.
6
8
 
7
9
  ```tsx
8
- // ... sampleCountsView, sampleCounts, and totalSamples
9
- const sampleContent = sampleCountsView.content(result => (
10
- <Stack>
11
- <SectionHeading>Sample counts</SectionHeading>
12
- <TextContent>
13
- <p>Explore the sources behind this finding.</p>
14
- </TextContent>
15
- <Grid columns={3}>
16
- <GridItem span={2}>
17
- <TableWidget dataset={sampleCounts} source={result} />
18
- </GridItem>
19
- <GridItem>
20
- <MetricWidget metric={totalSamples} source={result} />
21
- </GridItem>
22
- </Grid>
23
- </Stack>
24
- ));
10
+ // ... sampleCountsView, countsContent, and totalContent
11
+ function App() {
12
+ return (
13
+ <DataApp view={sampleCountsView}>
14
+ <Stack>
15
+ <SectionHeading>Sample counts</SectionHeading>
16
+ <TextContent>
17
+ <p>Explore the sources behind this finding.</p>
18
+ </TextContent>
19
+ <Grid columns={3}>
20
+ <GridItem span={2}>
21
+ <DataSection content={countsContent} />
22
+ </GridItem>
23
+ <GridItem>
24
+ <DataSection content={totalContent} />
25
+ </GridItem>
26
+ </Grid>
27
+ </Stack>
28
+ </DataApp>
29
+ );
30
+ }
25
31
  ```
26
32
 
27
33
  Grids wrap to fit their container and spans collapse when needed. Set widget
@@ -32,6 +38,27 @@ Compose paragraphs, links, and inline components directly; no `<TextContent>`
32
38
  wrapper is needed. Keep headings and widgets in the body and controls in
33
39
  `footerActions`.
34
40
 
41
+ Embedded hosts supply the page chrome, so `<DataApp>` omits its header, footer,
42
+ `toolbarActions`, and `footerActions` there; the host runs refresh, export,
43
+ story, and inspection. Keep controls readers need in the body.
44
+
45
+ ## Adapt to the available container
46
+
47
+ Base layout decisions on the app's available width. An embedded panel can be
48
+ narrow inside a wide browser window. Use `<Grid>` and `<GridItem>` first: their
49
+ tracks and spans respond to the containing grid rather than a viewport breakpoint.
50
+ Choose the column count and reading order for the evidence in the app brief.
51
+
52
+ For custom layout that these primitives cannot express, give an app-owned wrapper
53
+ `container-type: inline-size` and, when needed, a `container-name`. Use CSS
54
+ `@container` queries to adapt its descendants to that wrapper's width. The
55
+ container must be an ancestor of the elements whose layout changes. Keep theme
56
+ and user-preference media queries separate from these width decisions.
57
+
58
+ Apply the same composition and container rules to hosted and local apps. Verify
59
+ both a narrow browser and a narrow embed inside a wide browser; neither should
60
+ clip controls or require horizontal page scrolling.
61
+
35
62
  ## Verify rendered layouts
36
63
 
37
64
  Review authored composition with realistic labels and values. For custom layout
@@ -2,15 +2,14 @@
2
2
 
3
3
  Use the local scaffold supplied by your authoring workflow. Its README covers
4
4
  setup and its AGENTS.md identifies app-owned files.
5
- Replace the connectivity screen or fixture examples with the content specified by
5
+ Replace the sample queries and views with the content specified by
6
6
  the app brief, using the [shared SDK patterns](app-authoring.md). Local execution
7
7
  does not require a particular content structure or presentation story.
8
8
 
9
- | Task | Documentation |
10
- | ---------------------------- | ---------------------------------------- |
11
- | Customize local serving | [Bun server](server-bun.md) |
12
- | Authorize hosted viewers | [Server](server.md) |
13
- | Customize the browser client | [HTTP client](client.md#http-operations) |
9
+ | Task | Documentation |
10
+ | ---------------------------- | ----------------------------------------- |
11
+ | Customize local serving | [Bun server](server-bun.md) |
12
+ | Customize the browser client | [Client](client.md#registered-operations) |
14
13
 
15
14
  You can also [convert the local app to a hosted data app](hosted-apps.md#convert-a-local-data-app).
16
15
 
@@ -100,5 +100,47 @@ Pass `presentation={{ surface: 'embedded', theme: resolvedTheme }}`
100
100
  to `<DataAppBridge>` in either source or connection mode. Use `'standalone'` when the app should render its own page chrome.
101
101
  Prop updates publish trusted state without reloading the iframe or reconnecting
102
102
  the session. Resolve system preference in the parent to `'light'` or `'dark'`.
103
- Inside an embedded surface, `<DataApp>` retains toolbar actions and hides its header
104
- and footer. See [parent presentation](embed.md#parent-presentation).
103
+ Inside an embedded surface, `<DataApp>` hides its header, footer, and page
104
+ toolbar. See [parent presentation](embed.md#parent-presentation).
105
+
106
+ ## Page actions
107
+
108
+ Render the app's page actions in the parent with `onActionsChange`, and run them
109
+ through the bridge's `ref`:
110
+
111
+ ```tsx
112
+ import { useRef, useState } from 'react';
113
+ import {
114
+ DataAppBridge,
115
+ type DataAppBridgeHandle,
116
+ } from '@altertable/data-app-embed/react';
117
+ import type { DataAppActions } from '@altertable/data-app-embed';
118
+
119
+ // ... javascript bundle and router
120
+ function Shell() {
121
+ const bridge = useRef<DataAppBridgeHandle>(null);
122
+ const [actions, setActions] = useState<DataAppActions>({});
123
+ return (
124
+ <>
125
+ {actions.refresh && (
126
+ <button
127
+ disabled={actions.refresh.refreshing}
128
+ onClick={() => bridge.current?.runAction({ type: 'refresh' })}
129
+ >
130
+ Refresh
131
+ </button>
132
+ )}
133
+ <DataAppBridge
134
+ ref={bridge}
135
+ title="Activity report"
136
+ source={{ type: 'bundle', javascript }}
137
+ presentation={{ surface: 'embedded', theme: 'light' }}
138
+ onActionsChange={setActions}
139
+ onMessage={router.dispatch}
140
+ />
141
+ </>
142
+ );
143
+ }
144
+ ```
145
+
146
+ See [page actions](embed.md#page-actions) for every action and its state.
package/docs/react.md CHANGED
@@ -7,9 +7,8 @@ React and React DOM 19.2 or newer are required. Start with
7
7
  ## Mount the app
8
8
 
9
9
  ```tsx
10
- import { injectDataAppStyles, mountDataApp } from '@altertable/data-app-react';
10
+ import { mountDataApp } from '@altertable/data-app-react';
11
11
 
12
- injectDataAppStyles();
13
12
  mountDataApp({ app: dataApp, component: App });
14
13
  ```
15
14
 
@@ -10,13 +10,17 @@ when typechecking a Bun app.
10
10
  ```ts
11
11
  import { serveLocalApp } from '@altertable/data-app-bun';
12
12
  import page from './index.html';
13
- import { operations } from './operations.ts';
13
+ import { dataApp } from './app.ts';
14
14
 
15
- serveLocalApp({ page, operations, title: 'Activity' });
15
+ serveLocalApp({
16
+ page,
17
+ app: dataApp,
18
+ });
16
19
  ```
17
20
 
18
21
  The server binds to `127.0.0.1`. Its default port is `25837`, overridable through
19
- `PORT` or the `port` option. It serves the Bun HTML bundle and operation requests.
22
+ `PORT` or the `port` option. It serves the Bun HTML bundle and registered queries
23
+ by ID.
20
24
 
21
25
  `localLakehouse()` reads the CLI proxy URL and token from
22
26
  `ALTERTABLE_DATA_PROXY_URL` and `ALTERTABLE_DATA_PROXY_TOKEN`. It also supports
@@ -25,5 +29,4 @@ server-only `ALTERTABLE_LAKEHOUSE_USERNAME` and
25
29
  Missing credentials fail at startup. Keep these variables out of browser code.
26
30
 
27
31
  Local serving does not authenticate hosted viewers.
28
- Use [the portable server handler](server.md) with per-request authorization when
29
- hosting an app for other people.
32
+ Hosted apps authorize viewers in the host before executing registered queries.
@@ -2,7 +2,7 @@
2
2
 
3
3
  The bound `<DataApp>` from `@altertable/data-app-react` accepts an optional `story`
4
4
  callback and optional nonempty `datasets` list. Omit either prop to omit its toolbar
5
- control. Supplied features use the displayed snapshot, including during refresh or
5
+ control, or the matching [page action](embed.md#page-actions) when embedded. Supplied features use the displayed snapshot, including during refresh or
6
6
  failure. A story callback returning `[]` leaves a disabled presentation action.
7
7
  Set `showToolbar={false}` to omit page actions together; data loading, error states,
8
8
  and declared filters remain available. Setup and static screens can use `<DataApp>`
@@ -14,44 +14,53 @@ explanatory prose in the app body.
14
14
 
15
15
  ## Present data with stories
16
16
 
17
- Continue the starter's `totalSamples` binding. Return one to four findings with a
18
- headline, visual, and registered dataset or
19
- metric as `evidence`. Reuse bindings and derive scope from the snapshot:
17
+ This example adds a story to the sample-count bindings in [widgets](widgets.md).
18
+ Return one to four findings with a headline, visual, and registered dataset or
19
+ metric as `evidence`. The story receives `view`'s displayed snapshot, then one
20
+ snapshot per entry in `summaryViews`. Reuse each binding with its own view's
21
+ snapshot and derive scope from it:
20
22
 
21
23
  ```tsx
22
- // ... sampleCountsView, sampleCounts, totalSamples, and sampleContent
24
+ // ... sampleCountsView, sampleTotalView, sampleCounts, totalSamples, and contents
23
25
  function App() {
24
26
  return (
25
27
  <DataApp
26
28
  view={sampleCountsView}
29
+ summaryViews={[sampleTotalView]}
27
30
  datasets={[sampleCounts]}
28
- story={snapshot => {
29
- const total = totalSamples.read(snapshot);
31
+ story={(countsSnapshot, totalSnapshot) => {
32
+ const total = totalSamples.read(totalSnapshot);
30
33
  return [
31
34
  {
32
35
  id: 'total-samples',
33
36
  headline: `Total samples: ${formatMetric(total.value.current, totalSamples.definition.format)}`,
34
- context: sampleCountsView.scope(snapshot),
35
- visual: <MetricWidget metric={totalSamples} source={snapshot} />,
37
+ context: sampleCountsView.scope(countsSnapshot),
38
+ visual: (
39
+ <MetricWidget metric={totalSamples} source={totalSnapshot} />
40
+ ),
36
41
  evidence: totalSamples,
37
42
  },
38
43
  ];
39
44
  }}
40
45
  >
41
- <DataSection content={sampleContent} />
46
+ <DataSection content={totalContent} />
47
+ <DataSection content={countsContent} />
42
48
  </DataApp>
43
49
  );
44
50
  }
45
51
  ```
46
52
 
47
- Keep the starter's `formatMetric()` import for formatted headlines.
53
+ List a view in `summaryViews` only when the story or export reads it: summary
54
+ views load with the page instead of when their sections near the viewport.
55
+
56
+ Import `formatMetric()` from `@altertable/data-app/format` for formatted headlines.
48
57
 
49
58
  ## Export displayed data as CSV
50
59
 
51
60
  Declare [datasets](widgets.md#declare-datasets-and-metrics) once and pass
52
- `datasets={[sampleCounts]}`. This list determines which datasets are available
53
- for export, using their bound rows and columns. Preserve the displayed grain;
54
- reuse a dataset for visuals sharing the same rows.
61
+ `datasets={[sampleCounts]}`. List datasets from `view` or a summary view; each
62
+ exports its bound rows and columns. Preserve the displayed grain; reuse a dataset
63
+ for visuals sharing the same rows.
55
64
 
56
65
  One dataset downloads as CSV; multiple datasets offer individual downloads and
57
66
  **Export all** as ZIP. Filenames use the displayed scope. Accessors must return
package/docs/styling.md CHANGED
@@ -3,7 +3,8 @@
3
3
  Keep default appearance unless customization is requested. Use components and
4
4
  typed props first. Configure appearance once through
5
5
  `dataApp.appearance`; see [formatting and appearance](formatting-and-appearance.md).
6
- Call `injectDataAppStyles()` before mounting and use one `<DataApp>` per document.
6
+ `mountDataApp()` installs styles. When mounting `DataAppProvider` yourself, call
7
+ `injectDataAppStyles()` first. Use one `<DataApp>` per document.
7
8
 
8
9
  ## Customize
9
10
 
package/docs/ui.md CHANGED
@@ -10,7 +10,7 @@ frame for deliberately custom content. Use `<GettingStarted>` for
10
10
  connection setup. Fetched data belongs to a declared view; avoid inventing
11
11
  request states to populate a shell.
12
12
 
13
- Custom controls own values and change handlers; use `useAppVariables()` for
13
+ Custom controls own values and change handlers; use `useAppFilters()` for
14
14
  custom URL state. Use `<DataTable>` for custom tables and `<Tabs>`, `<Sheet>`,
15
15
  and `<HelpPopover>` for navigation and overlays.
16
16
 
@@ -20,8 +20,8 @@ derive findings from the displayed data. Standard widgets and `<DataApp>`
20
20
  already own these experiences.
21
21
 
22
22
  For framework mounting, `<DataAppProvider app={dataApp}>` supplies app identity, shared requests and one inspection sheet. Wrap custom shells in it; app components inherit identity and appearance.
23
- Call `injectDataAppStyles()` before mounting either entry; imports do not install
24
- styles.
23
+ `mountDataApp()` installs styles. For a custom root using `DataAppProvider`, call
24
+ `injectDataAppStyles()` before mounting; imports do not install styles.
25
25
 
26
26
  ## Tooltips and explanations
27
27
 
@@ -53,7 +53,7 @@ function ExportActions({ exportRows }: { exportRows: () => void }) {
53
53
  }
54
54
  ```
55
55
 
56
- `<AppLayout>` already provides shared timing. A standalone `<Tooltip>` works
56
+ A standalone `<Tooltip>` works
57
57
  without a provider; wrap adjacent custom controls in `<TooltipProvider>` to share
58
58
  the first-hover delay and open subsequent hints immediately. Keyboard focus opens
59
59
  hints immediately. The pointer can move onto the hint to keep it visible; Escape
@@ -153,6 +153,15 @@ so rows, loading state, evidence, and inspection come from that dataset.
153
153
  Pass ordered items with unique, nonblank IDs and finite numbers. Bar and pie
154
154
  values must be nonnegative. Use `formatValue` for domain formatting.
155
155
 
156
+ Use `showYAxis` on interactive bar charts when readers need a numeric scale,
157
+ including counts, ratios, and monetary amounts. Keep category names in the labels.
158
+ Match `valueFormat` to the measure: `{ kind: 'count' }`, `{ kind: 'ratio' }`
159
+ (fractions displayed as percentages), or `{ kind: 'currency', currency: 'USD' }`.
160
+ The format applies consistently to the axis and tooltips. For other units, use
161
+ the default number scale and name the unit in the chart title; `formatValue`
162
+ customizes inspected values. For ranked categories, use `scrollToEnd={false}`
163
+ to begin with the leading item; the default keeps the latest samples in view.
164
+
156
165
  Line and area charts space samples equally; include missing periods and use
157
166
  composed charts for irregular intervals. Distinguish missing observations from zero.
158
167
  Pie slices represent mutually exclusive parts of one total; shares
@@ -283,8 +292,8 @@ function FilterChoices() {
283
292
 
284
293
  A standalone `<Checkbox>` uses `checked` and `onChange`; group items use `value`.
285
294
 
286
- Use `<FilterBar>` to arrange predicates and `<VariableBar>` for mixed app
287
- parameters. Use `<FilterActions>` for Clear or paired Apply/Cancel actions on
295
+ Use `<FilterBar>` to arrange predicates and `<ControlBar>` for a row of mixed
296
+ search, filter, and display controls. Use `<FilterActions>` for Clear or paired Apply/Cancel actions on
288
297
  app-owned drafts; provide the handlers for your applied state.
289
298
 
290
299
  Use `<NumberFilterPicker>` for a numeric predicate popover or numeric fields
@@ -296,7 +305,8 @@ Use `<Button variant="inline">` for actions within text or table cells. Use butt
296
305
 
297
306
  ## Datetime selection
298
307
 
299
- Prefer a [datetime variable](variables.md#absolute-and-relative-datetime-ranges)
308
+ Prefer a [datetime filter](filters.md#date-ranges)
300
309
  for generated controls and URL state. For custom screens, `<DateTimeRangePicker>`
301
310
  accepts the same `DateTimeRange` and preset sets, with calendar and natural-language
302
- entry. See its props in [REFERENCE.md](../REFERENCE.md).
311
+ entry. Pass `policy={period.policy}` to apply a date filter's coverage and time
312
+ zone. See its props in [REFERENCE.md](../REFERENCE.md).