@altertable/data-app 0.75.0 → 0.77.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 (50) hide show
  1. package/README.md +56 -9
  2. package/REFERENCE.md +387 -333
  3. package/dist/chunks/{contract-B3s0ybE2.js → contract-BQsFReRp.js} +314 -237
  4. package/dist/chunks/contract-BQsFReRp.js.map +1 -0
  5. package/dist/chunks/{contract-DcPjfm0R.js → contract-VhY9V9wd.js} +184 -91
  6. package/dist/chunks/contract-VhY9V9wd.js.map +1 -0
  7. package/dist/chunks/{format-5hMYUWk3.js → date-time-range-value-CnlTr1U1.js} +8 -153
  8. package/dist/chunks/date-time-range-value-CnlTr1U1.js.map +1 -0
  9. package/dist/chunks/{diagnostics-DVwQ5PDK.js → diagnostics-Dyj-rUsY.js} +2 -2
  10. package/dist/chunks/{diagnostics-DVwQ5PDK.js.map → diagnostics-Dyj-rUsY.js.map} +1 -1
  11. package/dist/chunks/{operation-CGuN7Zcb.js → operation-BVRM-A5Y.js} +3 -3
  12. package/dist/chunks/{operation-CGuN7Zcb.js.map → operation-BVRM-A5Y.js.map} +1 -1
  13. package/dist/client/index.js +65 -50
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/core/config.js +1 -1
  16. package/dist/core/config.js.map +1 -1
  17. package/dist/core/contract.js +4 -4
  18. package/dist/core/format.js +149 -1
  19. package/dist/core/format.js.map +1 -0
  20. package/dist/internal.js +6 -308
  21. package/dist/internal.js.map +1 -1
  22. package/dist/server/index.js +3 -3
  23. package/dist/types/chunks/contract.d.ts +359 -599
  24. package/dist/types/chunks/contract2.d.ts +221 -0
  25. package/dist/types/chunks/date-time-range-value.d.ts +2 -28
  26. package/dist/types/chunks/date-time-range.d.ts +29 -0
  27. package/dist/types/chunks/index.d.ts +33 -5
  28. package/dist/types/client/index.d.ts +3 -3
  29. package/dist/types/core/config.d.ts +8 -4
  30. package/dist/types/core/contract.d.ts +5 -3
  31. package/dist/types/core/format.d.ts +2 -1
  32. package/dist/types/index.d.ts +2 -2
  33. package/dist/types/internal.d.ts +7 -5
  34. package/dist/types/server/index.d.ts +1 -1
  35. package/docs/app-authoring.md +15 -10
  36. package/docs/client.md +12 -7
  37. package/docs/contract.md +33 -50
  38. package/docs/data-context.md +9 -5
  39. package/docs/filters.md +295 -0
  40. package/docs/hosted-apps.md +4 -3
  41. package/docs/layout.md +24 -18
  42. package/docs/stories-and-export.md +19 -10
  43. package/docs/ui.md +7 -6
  44. package/docs/views.md +62 -26
  45. package/docs/widgets.md +38 -14
  46. package/package.json +16 -5
  47. package/dist/chunks/contract-B3s0ybE2.js.map +0 -1
  48. package/dist/chunks/contract-DcPjfm0R.js.map +0 -1
  49. package/dist/chunks/format-5hMYUWk3.js.map +0 -1
  50. package/docs/variables.md +0 -269
package/docs/contract.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  Keep the starter's `defineDataApp()` declaration and operation registry. Declare
4
4
  named SQL queries with typed `params` and `projections`; execute them through
5
- `dataApp.defineOperation()`. Use descriptive `lowerCamelCase` query names.
5
+ `dataApp.defineOperation()`. Write one query and operation per widget result,
6
+ and use descriptive `lowerCamelCase` query names.
6
7
 
7
8
  ## Execute named queries
8
9
 
@@ -35,20 +36,17 @@ ORDER BY group_name LIMIT $limit`,
35
36
 
36
37
  Replace fixture SQL with inspected data. Keep query declarations and projections
37
38
  in sync when adapting SQL to the app's inputs. Preserve metric definitions.
38
- Keep operation inputs flat; derive SQL parameters inside `run()`:
39
+ List the [filters](filters.md) an operation reads; `run()` receives one flat
40
+ field per filter, and you derive SQL parameters inside it:
39
41
 
40
42
  ```ts
41
- import { parseCount } from '@altertable/data-app/contract';
43
+ import { parseCount, searchFilter } from '@altertable/data-app/contract';
42
44
 
43
- // ... dataApp and parseSampleCountFilter
45
+ // ... dataApp
46
+ const groupName = searchFilter({ key: 'group', label: 'Group' });
44
47
  const operations = {
45
48
  sampleCountsByGroup: dataApp.defineOperation({
46
- input: parseSampleCountFilter,
47
- checks: [
48
- { groupName: '' },
49
- { groupName: 'Alpha' },
50
- { groupName: 'missing' },
51
- ],
49
+ filters: { groupName },
52
50
  policy: { maxQueryRows: 10, maxDurationMs: 15000 },
53
51
  async run({ query }, { groupName }) {
54
52
  const result = await query('sampleCountsByGroup', { groupName });
@@ -61,11 +59,13 @@ const operations = {
61
59
  };
62
60
  ```
63
61
 
64
- The starter supplies `parseSampleCountFilter()` and `parseCount()`. Validate
65
- unknown input in the parser and business rules in `run()`. Include representative
66
- valid inputs in `checks`. Derive results from `query()` rows without duplicate
67
- schemas or type assertions; clients and views infer the returned type.
68
- HTTP results must be JSON-serializable.
62
+ The filters validate input and supply the operation's checks; enforce business
63
+ rules in `run()`. Omit `filters` for an operation without inputs. An operation
64
+ with its own fields, such as a detail record ID, adds an `input` parser and
65
+ representative valid `checks` for those fields; its `filters` still parse the
66
+ scope it reads. Derive results from `query()` rows
67
+ without duplicate schemas or type assertions; clients and views infer the
68
+ returned type. HTTP results must be JSON-serializable.
69
69
 
70
70
  Host `queryParams` supplies protected parameters that callers cannot override.
71
71
  Other values come from `query()` arguments or defaults. The host/backend enforces
@@ -82,50 +82,33 @@ return SQL text and declare `string` when exact numeric precision matters.
82
82
 
83
83
  Use `operations.sampleCountsByGroup.queryNames` for context and evidence.
84
84
 
85
- ### Bind datetime ranges
85
+ ### Bind date ranges
86
86
 
87
- Declare a `dateTimeRange` parameter and pass a `DateTimeRange` to `query()`.
88
- For a [comparison variable](variables.md#absolute-and-relative-datetime-ranges),
89
- pass its `range` or `comparison` bounds. Reference those bounds in SQL:
87
+ Declare `{ type: 'dateTimeRange' }` and pass a date filter's `range` or
88
+ `comparison`. Reference its bounds as `$period.from` (inclusive) and
89
+ `$period.to` (exclusive):
90
90
 
91
91
  ```ts
92
92
  const dataApp = defineDataApp({
93
93
  // ... title, description, and scope
94
94
  queries: {
95
- events: {
96
- statement: `SELECT occurred_at AS "occurredAt" FROM events
97
- WHERE occurred_at >= $period.from AND occurred_at < $period.to`,
95
+ dailyOrders: {
96
+ statement: `SELECT CAST(ordered_at AS DATE) AS day, count(*) AS orders
97
+ FROM orders
98
+ WHERE ordered_at >= $period.from AND ordered_at < $period.to
99
+ GROUP BY day ORDER BY day`,
98
100
  params: { period: { type: 'dateTimeRange' } },
99
- projections: { occurredAt: { type: 'string' } },
101
+ projections: {
102
+ day: { type: 'string' },
103
+ orders: { type: 'number' },
104
+ },
100
105
  },
101
106
  },
102
107
  });
103
108
  ```
104
109
 
105
- The start is inclusive and the end exclusive. Relative values resolve at query
106
- execution. Absolute values encode wall-clock fields in UTC: selecting 4 PM stores
107
- 16:00Z.
108
- SQL bounds are timezone-free timestamps. Configure the backend session to the
109
- reporting timezone and interpret timestamp-with-timezone comparisons in that
110
- same zone.
111
-
112
- ## Share reporting policy
113
-
114
- Pass an optional `defineDateRangeContract()` to `dateTimeRangeVariable()` to
115
- share coverage, duration limits, and reporting timezone between the picker and
116
- server parser. By default, coverage ends yesterday; set `completeDays: false`
117
- to include today. Declare the policy once:
118
-
119
- ```ts
120
- import { defineDateRangeContract } from '@altertable/data-app/contract';
121
-
122
- const calendar = defineDateRangeContract({
123
- minDate: '2026-01-01',
124
- maxRangeDays: 90,
125
- timeZone: 'UTC',
126
- });
127
- ```
128
-
129
- Use the shared contract in the [datetime variable workflow](variables.md#absolute-and-relative-datetime-ranges),
130
- including optional previous-period comparison. Calendar-only views share it with
131
- `calendar.parseRequest()` and `defineTimeView()`.
110
+ Date filters pass resolved bounds in their `timeZone`, encoded as UTC wall-clock
111
+ fields: 4 PM in the reporting zone is 16:00Z. SQL bounds are therefore
112
+ timezone-free timestamps; interpret timestamp-with-timezone columns in that same
113
+ zone. Coverage and duration limits live on the
114
+ [date filter](filters.md#date-ranges).
@@ -1,7 +1,8 @@
1
1
  # Data context and evidence
2
2
 
3
- Continue the starter's operation and context. Use its derived `queryNames` for
4
- business definitions and evidence. Reference only queries the view executes.
3
+ Continue the starter's operations and context. Build one context from every
4
+ operation's `queryNames` and share it across the app's views. Reference only
5
+ queries the app executes.
5
6
 
6
7
  ## Bind evidence
7
8
 
@@ -9,21 +10,24 @@ business definitions and evidence. Reference only queries the view executes.
9
10
  import { createDataContext } from '@altertable/data-app-react';
10
11
 
11
12
  // ... operations
12
- const queryNames = operations.sampleCountsByGroup.queryNames;
13
+ const queryNames = {
14
+ ...operations.sampleCountsByGroup.queryNames,
15
+ ...operations.sampleTotal.queryNames,
16
+ };
13
17
  const sampleDataContext = createDataContext(queryNames)({
14
18
  description: 'Sample counts for the selected groups.',
15
19
  glossary: {
16
20
  sampleCount: {
17
21
  term: 'Sample count',
18
22
  definition: 'The number of samples in each group.',
19
- queryNames: [queryNames.sampleCountsByGroup],
23
+ queryNames: [queryNames.sampleCountsByGroup, queryNames.sampleTotal],
20
24
  },
21
25
  },
22
26
  });
23
27
  ```
24
28
 
25
29
  Import `createDataContext()` from `@altertable/data-app-react`. Supply
26
- `dataContext: sampleDataContext` on `sampleCountsView`, then use its glossary IDs
30
+ `dataContext: sampleDataContext` on each view, then use its glossary IDs
27
31
  in `view.metric()` and `view.dataset()`. Reuse those bindings in widgets and stories.
28
32
  Detail views need their own context when their queries differ.
29
33
 
@@ -0,0 +1,295 @@
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
+ The hosted starter's operations both read one group search:
11
+
12
+ ```tsx
13
+ import { parseCount, searchFilter } from '@altertable/data-app/contract';
14
+
15
+ // ... dataApp, sampleDataContext, and section contents
16
+ const groupName = searchFilter({ key: 'group', label: 'Group' });
17
+
18
+ const operations = {
19
+ sampleCountsByGroup: dataApp.defineOperation({
20
+ filters: { groupName },
21
+ policy: { maxQueryRows: 10, maxDurationMs: 15000 },
22
+ async run({ query }, { groupName }) {
23
+ const result = await query('sampleCountsByGroup', { groupName });
24
+ return result.rows.map(row => ({
25
+ groupName: row.group_name,
26
+ sampleCount: parseCount(row.sample_count),
27
+ }));
28
+ },
29
+ }),
30
+ // ... sampleTotal reads the same { groupName }
31
+ };
32
+ const { defineView } = createDataHooks(createDataClient({ operations }));
33
+ const sampleCountsView = defineView({
34
+ dataContext: sampleDataContext,
35
+ operation: 'sampleCountsByGroup',
36
+ isEmpty: rows => rows.length === 0,
37
+ emptyFallback: { title: 'No matching groups' },
38
+ });
39
+
40
+ function App() {
41
+ return (
42
+ <DataApp view={sampleCountsView}>
43
+ <DataSection content={countsContent} />
44
+ </DataApp>
45
+ );
46
+ }
47
+ ```
48
+
49
+ - Reuse the same constant on every operation that reads it; two filters with one
50
+ name, or one URL key, fail.
51
+ - Omit `filters` for an operation without inputs.
52
+ - A detail operation that also needs its own fields, such as a record ID, keeps
53
+ `filters` for the scope and adds `input` and `checks` for those fields only.
54
+ - The view's scope reads like “Mar 1–7, 2026 UTC · group Alpha” or “all data”.
55
+ Pass `describeInput` only for different copy.
56
+ - Use `searchFilter()` to query the server; use a table's `search` prop to filter
57
+ rows already loaded.
58
+
59
+ ## Read filter values
60
+
61
+ `run(context, input)` receives one field per declared filter:
62
+
63
+ | Filter | Input value |
64
+ | ------------------------------------------------------ | ---------------------------------------------- |
65
+ | `searchFilter()` | `string`, at most `maxLength` (200 by default) |
66
+ | `choiceFilter()`, `displayChoice()` | Selected option ID |
67
+ | `multiChoiceFilter()` | Selected option IDs |
68
+ | `dimensionFilter()`, `facetFilter()`, source dimension | `DimensionSelection` |
69
+ | `numberFilter()`, `booleanFilter()` | `NumberSelection`, `BooleanSelection` |
70
+ | `dateTimeRangeFilter()` | `{ range, comparison }` of resolved dates |
71
+
72
+ Pass values to declared query parameters; never interpolate them into SQL. Date
73
+ ranges bind as [`dateTimeRange` parameters](contract.md#bind-date-ranges). A
74
+ dimension selection binds whole to a `{ type: 'dimension', valueType }`
75
+ parameter; `$country.matches(column)` keeps the selected rows, including
76
+ multiple members, missing values, and exclusion:
77
+
78
+ ```ts
79
+ // ... in defineDataApp({ queries })
80
+ revenueByCampaign: {
81
+ statement: `SELECT o.campaign, sum(o.amount) AS revenue
82
+ FROM demo.orders o JOIN demo.customers c ON c.id = o.customer_id
83
+ WHERE $country.matches(c.country)
84
+ GROUP BY o.campaign`,
85
+ params: { country: { type: 'dimension', valueType: 'string' } },
86
+ projections: { campaign: { type: 'string' }, revenue: { type: 'number' } },
87
+ },
88
+ // ... in the operation: query('revenueByCampaign', { country: input.country })
89
+ ```
90
+
91
+ Dimension, number, and boolean selections support `{ kind: 'all' }`. Offer only
92
+ predicates the registered query supports.
93
+
94
+ ## Categorical dimensions
95
+
96
+ For source-backed members, use `dataApp.defineDimension()`:
97
+
98
+ ```ts
99
+ // ... dataApp with its registered groups query
100
+ const group = dataApp.defineDimension({
101
+ key: 'group',
102
+ label: 'Group',
103
+ valueType: 'string',
104
+ selectionMode: 'multiple',
105
+ source: { query: 'groups' },
106
+ });
107
+ ```
108
+
109
+ Declare the source query in `defineDataApp()` with a nullable `member` parameter
110
+ matching `valueType`. Its nonnullable projections are `value` (same type),
111
+ `label` (string), and optional `count` (number). Null requests options; a selected
112
+ member requests exact lookup. Other parameters need defaults or trusted values:
113
+
114
+ ```sql
115
+ SELECT DISTINCT group_name AS value, group_name AS label
116
+ FROM sample_counts
117
+ WHERE ($member IS NULL OR group_name = $member)
118
+ ORDER BY label
119
+ ```
120
+
121
+ Operations reading `group` check selected members against this query before
122
+ `run()`. Use `dimensionFilter()` when options are known constants:
123
+
124
+ ```ts
125
+ const group = dimensionFilter({
126
+ key: 'group',
127
+ label: 'Group',
128
+ valueType: 'string',
129
+ selectionMode: 'multiple',
130
+ options: [
131
+ { value: 'Alpha', label: 'Alpha' },
132
+ { value: 'Beta', label: 'Beta' },
133
+ ],
134
+ });
135
+ ```
136
+
137
+ Set `defaultValue` to start from a narrower selection, such as
138
+ `{ kind: 'include', members: [{ kind: 'value', value: 'paid' }] }`; clearing
139
+ filters still returns to every member.
140
+
141
+ No selection means every member. Enable `allowExclusion` and `allowMissing` only
142
+ when the query handles them. Use `multiChoiceFilter()` for fixed multiselect
143
+ choices; empty means no choices, unlike an unrestricted dimension.
144
+
145
+ ## Facet filters
146
+
147
+ Use `facetFilter()` only when options must follow other selections:
148
+
149
+ ```ts
150
+ // ... period filter
151
+ const group = facetFilter({
152
+ key: 'group',
153
+ label: 'Group',
154
+ valueType: 'string',
155
+ selectionMode: 'multiple',
156
+ options: 'groupOptions',
157
+ });
158
+ const operations = {
159
+ groupOptions: dataApp.defineOperation({
160
+ filters: { period },
161
+ // ... policy, and run() returning DimensionOption[] for the period
162
+ }),
163
+ groupCounts: dataApp.defineOperation({
164
+ filters: { period, group },
165
+ // ... policy and run()
166
+ }),
167
+ };
168
+ ```
169
+
170
+ - `options` names a registered operation. Its filters decide what narrows the
171
+ options: here, changing `period` reloads them.
172
+ - Return `{ value, label, count? }[]` from `run()`, at most 200 values. The picker
173
+ shows `count` beside each option.
174
+ - The server checks a facet selection's shape, not its members; use a source
175
+ dimension when unknown members must be rejected.
176
+
177
+ ## Display choices and breakdowns
178
+
179
+ Use `displayChoice()` for a choice that changes how results are shown rather
180
+ than which data is included. List it on the operation, which receives the
181
+ selected ID and groups its results accordingly:
182
+
183
+ ```ts
184
+ const countsBy = displayChoice({
185
+ key: 'counts-by',
186
+ label: 'Counts breakdown',
187
+ defaultValue: 'group',
188
+ options: [
189
+ { id: 'group', label: 'Group' },
190
+ { id: 'country', label: 'Country' },
191
+ ],
192
+ presentation: { control: 'widget' },
193
+ });
194
+ // ... sampleCountsByGroup declares filters: { groupName, countsBy }
195
+ ```
196
+
197
+ Pass `view.breakdown('countsBy')` to `<VisualizationWidget breakdown>`. Without
198
+ `control: 'widget'`, the choice renders in the toolbar's display options. Use one
199
+ choice per independently controlled chart. Use
200
+ `presentation.prominence: 'secondary'` for less frequent filters.
201
+
202
+ ## Date ranges
203
+
204
+ Use one `dateTimeRangeFilter()` per operation. It sets the view's reporting
205
+ period, time zone, and metric comparisons:
206
+
207
+ ```ts
208
+ import {
209
+ dateTimeRangeFilter,
210
+ dateTimeRangePresets,
211
+ } from '@altertable/data-app/contract';
212
+
213
+ const period = dateTimeRangeFilter({
214
+ key: 'period',
215
+ defaultValue: '30d',
216
+ maxRangeDays: 90,
217
+ comparison: 'off',
218
+ presets: dateTimeRangePresets.analytics,
219
+ });
220
+ const dailyCounts = dataApp.defineOperation({
221
+ filters: { period, groupName },
222
+ policy: { maxQueryRows: 100, maxDurationMs: 15000 },
223
+ async run({ query }, { period, groupName }) {
224
+ const current = await query('dailyCounts', {
225
+ period: period.range,
226
+ groupName,
227
+ });
228
+ // ... query { period: period.comparison } when it is not null
229
+ return current.rows;
230
+ },
231
+ });
232
+ ```
233
+
234
+ - `run()` receives `{ range, comparison }` with resolved dates. Ranges include
235
+ `from` and exclude `to`: September 24–30 queries `2026-09-24T00:00:00Z`
236
+ through `2026-10-01T00:00:00Z`. Bind them to a
237
+ [`dateTimeRange` parameter](contract.md#bind-date-ranges).
238
+ - A range that runs past now ends at now: today picked in the calendar queries
239
+ midnight through the current time.
240
+ - `comparison: 'off'` or `'on'` offers the previous-period toggle, starting in
241
+ that state. `period.comparison` is the same window one selected length
242
+ earlier, such as yesterday through the same time, while the toggle is on, and
243
+ `null` otherwise. Omit `comparison` for no toggle.
244
+ - `defaultValue` and preset `range` take range text such as `'24h'`, `'7d'`, or
245
+ `'6mo'`, or `{ from, to }`. `dateTimeRangePresets.analytics` covers days to a
246
+ year; `dateTimeRangePresets.monitoring` covers minutes to 24 hours.
247
+ - Relative ranges such as `'7d'` resolve in `timeZone`, UTC by default.
248
+ - `minDate`, `maxDate`, and `maxRangeDays` limit what readers can pick.
249
+ Coverage runs through now; set `completeDays: true` to end it yesterday when
250
+ the source loads whole days.
251
+
252
+ ## Exclusion, clear, and reset
253
+
254
+ Clear removes filter predicates and returns dates to defaults, preserving search
255
+ and display choices. `resetAll()` restores all defaults. Filters apply immediately;
256
+ use app-owned drafts only when the task needs Apply/Cancel.
257
+
258
+ Custom control ownership is needed only when generated controls cannot express
259
+ the requirement; use `/ui` for that case. Do not reuse reserved inspection,
260
+ presentation, or navigation URL keys.
261
+
262
+ ## Share filters with HTTP and local apps
263
+
264
+ HTTP and local apps keep operations on the server, so the browser imports them
265
+ as types only. Declare filters in a browser-safe module that both sides import:
266
+
267
+ ```ts
268
+ // src/filters.ts
269
+ import { choiceFilter } from '@altertable/data-app/contract';
270
+
271
+ const groupName = choiceFilter({
272
+ // ... key, label, defaultValue, and options
273
+ });
274
+
275
+ export const operationFilters = {
276
+ sampleCountsByGroup: { groupName },
277
+ sampleCountsBySegment: { groupName },
278
+ };
279
+ ```
280
+
281
+ Each operation in `src/operations.ts` declares
282
+ `filters: operationFilters.sampleCountsByGroup`, and the browser client receives
283
+ the same map:
284
+
285
+ ```ts
286
+ // src/App.tsx
287
+ import { operationFilters } from '#app/filters.ts';
288
+ import type { operations } from '#app/operations.ts';
289
+
290
+ const { defineView } = createDataHooks(
291
+ createDataClient<typeof operations>({ filters: operationFilters })
292
+ );
293
+ ```
294
+
295
+ The client's types require `filters` whenever an operation declares them.
@@ -14,7 +14,7 @@ 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
 
@@ -23,11 +23,12 @@ the transport; no bootstrap or message routes are needed in app code.
23
23
 
24
24
  ## Convert a local data app
25
25
 
26
- 1. Combine the app's operations and parsers, data context, views, any presentation
26
+ 1. Combine the app's filters, operations, data context, views, any presentation
27
27
  and export features, app declaration, and browser entry into one `index.tsx`, following the
28
28
  [single-file starter](app-authoring.md#use-release-matched-starters).
29
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)
30
+ operation registry as a value; it supplies the operations' filters, so drop
31
+ the `filters` option. See [browser-owned operations](client.md#browser-owned-operations-for-bundle-apps)
31
32
  for execution through the host.
32
33
  3. Remove the Bun server, HTML, server adapters, credentials, and relative or
33
34
  app-alias imports. Rewrite any operation that depends on server-only code
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
@@ -16,42 +16,51 @@ explanatory prose in the app body.
16
16
 
17
17
  Continue the starter's `totalSamples` binding. Return one to four findings with a
18
18
  headline, visual, and registered dataset or
19
- metric as `evidence`. Reuse bindings and derive scope from the snapshot:
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
 
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
+
47
56
  Keep the starter's `formatMetric()` import 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/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
 
@@ -259,7 +259,7 @@ filter declarations own URL state, validation, and operation meaning.
259
259
  | `<SegmentedControl>` | Compact radio choices |
260
260
  | `<NumberField>` | Localized numeric input; empty is `null` |
261
261
  | `<NumberRangeField>` | Exact, inclusive minimum/maximum; omitted bounds are unrestricted |
262
- | `<DateRangePicker>` | Explicit or relative periods |
262
+ | `<DateTimeRangePicker>` | Datetime ranges with an exclusive end |
263
263
  | `<DimensionPicker>` | Typed categorical predicates with fixed or facet options |
264
264
 
265
265
  ```tsx
@@ -283,8 +283,8 @@ function FilterChoices() {
283
283
 
284
284
  A standalone `<Checkbox>` uses `checked` and `onChange`; group items use `value`.
285
285
 
286
- Use `<FilterBar>` to arrange predicates and `<VariableBar>` for mixed app
287
- parameters. Use `<FilterActions>` for Clear or paired Apply/Cancel actions on
286
+ Use `<FilterBar>` to arrange predicates and `<ControlBar>` for a row of mixed
287
+ search, filter, and display controls. Use `<FilterActions>` for Clear or paired Apply/Cancel actions on
288
288
  app-owned drafts; provide the handlers for your applied state.
289
289
 
290
290
  Use `<NumberFilterPicker>` for a numeric predicate popover or numeric fields
@@ -296,7 +296,8 @@ Use `<Button variant="inline">` for actions within text or table cells. Use butt
296
296
 
297
297
  ## Datetime selection
298
298
 
299
- Prefer a [datetime variable](variables.md#absolute-and-relative-datetime-ranges)
299
+ Prefer a [datetime filter](filters.md#date-ranges)
300
300
  for generated controls and URL state. For custom screens, `<DateTimeRangePicker>`
301
301
  accepts the same `DateTimeRange` and preset sets, with calendar and natural-language
302
- entry. See its props in [REFERENCE.md](../REFERENCE.md).
302
+ entry. Pass `policy={period.policy}` to apply a date filter's coverage and time
303
+ zone. See its props in [REFERENCE.md](../REFERENCE.md).