@altertable/data-app 0.68.0 → 0.70.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 (203) hide show
  1. package/AGENTS.md +10 -0
  2. package/CONTRIBUTING.md +27 -1
  3. package/README.md +18 -21
  4. package/THIRD_PARTY_NOTICES +18 -0
  5. package/dist/chunks/index-22d576sn.js +153 -0
  6. package/dist/chunks/index-22d576sn.js.map +11 -0
  7. package/dist/chunks/index-2ajhmsc4.js +355 -0
  8. package/dist/chunks/index-2ajhmsc4.js.map +13 -0
  9. package/dist/chunks/{index-ktmvs916.js → index-58kks6a8.js} +37 -21
  10. package/dist/chunks/index-58kks6a8.js.map +13 -0
  11. package/dist/chunks/{index-23dktynd.js → index-7q99hf1z.js} +19 -12
  12. package/dist/chunks/index-7q99hf1z.js.map +10 -0
  13. package/dist/chunks/{index-mt93ff2b.js → index-9zqbrv2z.js} +7 -3
  14. package/dist/chunks/index-9zqbrv2z.js.map +10 -0
  15. package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
  16. package/dist/chunks/index-cv36cyna.js.map +10 -0
  17. package/dist/chunks/{index-ag0cgnvq.js → index-q1w84fv9.js} +178 -31
  18. package/dist/chunks/index-q1w84fv9.js.map +15 -0
  19. package/dist/chunks/{index-qd5xgx6y.js → index-rew95tbg.js} +89 -21
  20. package/dist/chunks/index-rew95tbg.js.map +13 -0
  21. package/dist/chunks/{index-gvers8jw.js → index-vtpygsbq.js} +5651 -2711
  22. package/dist/chunks/index-vtpygsbq.js.map +126 -0
  23. package/dist/chunks/{index-x69p7cv7.js → index-wjt6cavj.js} +6 -4
  24. package/dist/chunks/index-wjt6cavj.js.map +10 -0
  25. package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
  26. package/dist/chunks/index-wss3gd3h.js.map +13 -0
  27. package/dist/chunks/{index-ev2b5aaf.js → index-xzb7sx6g.js} +4 -4
  28. package/dist/client/index.js +6 -6
  29. package/dist/core/appearance.js +1 -1
  30. package/dist/core/config.js +3 -3
  31. package/dist/core/contract.js +7 -7
  32. package/dist/core/contract.js.map +1 -1
  33. package/dist/core/format.js +10 -2
  34. package/dist/core/format.js.map +1 -1
  35. package/dist/embed/index.js +26 -25
  36. package/dist/embed/index.js.map +4 -4
  37. package/dist/index.js +3 -3
  38. package/dist/local.js +200 -145
  39. package/dist/local.js.map +10 -7
  40. package/dist/preview.js +1456 -0
  41. package/dist/preview.js.map +17 -0
  42. package/dist/react/embed/index.js +1 -1
  43. package/dist/react/index.js +500 -401
  44. package/dist/react/index.js.map +10 -13
  45. package/dist/react/ui/index.js +1851 -1476
  46. package/dist/react/ui/index.js.map +24 -21
  47. package/dist/server.js +102 -58
  48. package/dist/server.js.map +9 -6
  49. package/dist/types/client/data-client.d.ts +21 -10
  50. package/dist/types/client/download.d.ts +5 -0
  51. package/dist/types/client/iframe.d.ts +4 -2
  52. package/dist/types/client/logger.d.ts +10 -2
  53. package/dist/types/core/annotations.d.ts +5 -0
  54. package/dist/types/core/appearance.d.ts +2 -0
  55. package/dist/types/core/bridge-endpoint.d.ts +2 -2
  56. package/dist/types/core/bridge.d.ts +22 -0
  57. package/dist/types/core/config.d.ts +25 -17
  58. package/dist/types/core/contract.d.ts +26 -14
  59. package/dist/types/core/date-format.d.ts +24 -0
  60. package/dist/types/core/dimension-source.d.ts +64 -0
  61. package/dist/types/core/dimension.d.ts +33 -24
  62. package/dist/types/core/facets.d.ts +13 -0
  63. package/dist/types/core/filters.d.ts +4 -3
  64. package/dist/types/core/format.d.ts +5 -3
  65. package/dist/types/core/keys.d.ts +2 -0
  66. package/dist/types/core/messages.d.ts +3 -1
  67. package/dist/types/core/operation-types.d.ts +12 -11
  68. package/dist/types/core/queries.d.ts +75 -7
  69. package/dist/types/core/time-interval.d.ts +96 -0
  70. package/dist/types/core/variables.d.ts +49 -14
  71. package/dist/types/embed/host.d.ts +4 -4
  72. package/dist/types/embed/sql.d.ts +1 -1
  73. package/dist/types/index.d.ts +1 -1
  74. package/dist/types/react/actions.d.ts +53 -0
  75. package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
  76. package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
  77. package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
  78. package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
  79. package/dist/types/react/bindings.d.ts +62 -3
  80. package/dist/types/react/date-formatting.d.ts +12 -0
  81. package/dist/types/react/details.d.ts +46 -0
  82. package/dist/types/react/exploration.d.ts +44 -0
  83. package/dist/types/react/hooks.d.ts +82 -43
  84. package/dist/types/react/index.d.ts +10 -2
  85. package/dist/types/react/search-suggestions.d.ts +8 -0
  86. package/dist/types/react/style-contract.d.ts +1 -5
  87. package/dist/types/react/ui/AboutData.d.ts +9 -4
  88. package/dist/types/react/ui/AreaChart.d.ts +2 -2
  89. package/dist/types/react/ui/BarChart.d.ts +2 -2
  90. package/dist/types/react/ui/Button.d.ts +2 -1
  91. package/dist/types/react/ui/ChartLegend.d.ts +3 -2
  92. package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
  93. package/dist/types/react/ui/ComposedChartLegend.d.ts +2 -1
  94. package/dist/types/react/ui/DataApp.d.ts +8 -4
  95. package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
  96. package/dist/types/react/ui/DataTable.d.ts +6 -4
  97. package/dist/types/react/ui/DataWidget.d.ts +7 -0
  98. package/dist/types/react/ui/DateDisplay.d.ts +9 -0
  99. package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
  100. package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
  101. package/dist/types/react/ui/DimensionPicker.d.ts +5 -3
  102. package/dist/types/react/ui/EmptyState.d.ts +1 -1
  103. package/dist/types/react/ui/ExplorationActionControl.d.ts +60 -0
  104. package/dist/types/react/ui/GradientScroll.d.ts +8 -0
  105. package/dist/types/react/ui/Grid.d.ts +1 -1
  106. package/dist/types/react/ui/InspectionProvider.d.ts +2 -2
  107. package/dist/types/react/ui/LineChart.d.ts +2 -2
  108. package/dist/types/react/ui/Menu.d.ts +3 -2
  109. package/dist/types/react/ui/MetricWidget.d.ts +4 -0
  110. package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
  111. package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
  112. package/dist/types/react/ui/PickerField.d.ts +23 -0
  113. package/dist/types/react/ui/PieChart.d.ts +2 -2
  114. package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
  115. package/dist/types/react/ui/RequestHint.d.ts +2 -2
  116. package/dist/types/react/ui/SearchField.d.ts +3 -1
  117. package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
  118. package/dist/types/react/ui/SectionHeading.d.ts +8 -0
  119. package/dist/types/react/ui/Select.d.ts +9 -1
  120. package/dist/types/react/ui/Sheet.d.ts +4 -2
  121. package/dist/types/react/ui/TableWidget.d.ts +8 -0
  122. package/dist/types/react/ui/Tabs.d.ts +4 -3
  123. package/dist/types/react/ui/TrendChart.d.ts +3 -3
  124. package/dist/types/react/ui/VariableBar.d.ts +1 -1
  125. package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
  126. package/dist/types/react/ui/chart-data.d.ts +8 -6
  127. package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
  128. package/dist/types/react/ui/chart-interaction.d.ts +27 -0
  129. package/dist/types/react/ui/chart-primitives.d.ts +4 -4
  130. package/dist/types/react/ui/chart-time.d.ts +19 -0
  131. package/dist/types/react/ui/chartColor.d.ts +1 -1
  132. package/dist/types/react/ui/icons.d.ts +5 -1
  133. package/dist/types/react/ui/index.d.ts +10 -4
  134. package/dist/types/react/ui/metric-comparison.d.ts +2 -2
  135. package/dist/types/react/ui/metric.d.ts +2 -2
  136. package/dist/types/react/ui/presentation.d.ts +2 -0
  137. package/dist/types/react/ui/searchItems.d.ts +2 -0
  138. package/dist/types/react/ui/use-chart-scroll-to-end.d.ts +2 -0
  139. package/dist/types/react/ui/variables.d.ts +1 -1
  140. package/dist/types/react/view-control-bar.d.ts +18 -0
  141. package/dist/types/react/view-controls.d.ts +3 -2
  142. package/dist/types/react/view-runtime.d.ts +8 -3
  143. package/dist/types/react/view.d.ts +28 -7
  144. package/dist/types/react/widgets.d.ts +22 -11
  145. package/dist/types/server/local.d.ts +3 -1
  146. package/dist/types/server/preview/host.d.ts +1 -0
  147. package/dist/types/server/preview/index.d.ts +16 -0
  148. package/dist/types/server/reload-channel.d.ts +6 -0
  149. package/dist/types/server/request-body.d.ts +4 -0
  150. package/dist/worker.js +1 -1
  151. package/docs/app-authoring.md +27 -12
  152. package/docs/client.md +6 -7
  153. package/docs/composition.md +84 -0
  154. package/docs/contract.md +45 -26
  155. package/docs/data-context.md +2 -0
  156. package/docs/embed.md +11 -3
  157. package/docs/formatting-and-appearance.md +36 -5
  158. package/docs/layout.md +31 -8
  159. package/docs/react-embed.md +4 -4
  160. package/docs/react.md +1 -1
  161. package/docs/server-bun.md +25 -0
  162. package/docs/server.md +2 -2
  163. package/docs/styling.md +10 -27
  164. package/docs/ui.md +32 -18
  165. package/docs/variables.md +174 -25
  166. package/docs/views.md +60 -29
  167. package/docs/widgets.md +131 -26
  168. package/examples/starter-data-app/index.tsx +10 -23
  169. package/examples/starter-local-data-app/.bun-version +1 -0
  170. package/examples/starter-local-data-app/.node-version +1 -0
  171. package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
  172. package/examples/starter-local-data-app/.oxlintrc.json +33 -0
  173. package/examples/starter-local-data-app/AGENTS.md +22 -0
  174. package/examples/starter-local-data-app/README.md +54 -0
  175. package/examples/starter-local-data-app/app.ts +28 -0
  176. package/examples/starter-local-data-app/bunfig.toml +2 -0
  177. package/examples/starter-local-data-app/package.json +33 -0
  178. package/examples/starter-local-data-app/src/App.tsx +8 -0
  179. package/examples/starter-local-data-app/src/assets.d.ts +1 -0
  180. package/examples/starter-local-data-app/src/data-context.ts +21 -0
  181. package/examples/starter-local-data-app/src/favicon.svg +13 -0
  182. package/examples/starter-local-data-app/src/index.html +14 -0
  183. package/examples/starter-local-data-app/src/main.tsx +7 -0
  184. package/examples/starter-local-data-app/src/operations.ts +6 -0
  185. package/examples/starter-local-data-app/src/server.ts +6 -0
  186. package/examples/starter-local-data-app/tsconfig.json +21 -0
  187. package/package.json +13 -3
  188. package/dist/chunks/index-23dktynd.js.map +0 -10
  189. package/dist/chunks/index-ag0cgnvq.js.map +0 -13
  190. package/dist/chunks/index-dq7b35fn.js +0 -307
  191. package/dist/chunks/index-dq7b35fn.js.map +0 -13
  192. package/dist/chunks/index-f5cnbrjz.js.map +0 -13
  193. package/dist/chunks/index-gvers8jw.js.map +0 -109
  194. package/dist/chunks/index-ktmvs916.js.map +0 -13
  195. package/dist/chunks/index-m6n8ctfc.js.map +0 -10
  196. package/dist/chunks/index-mev09s5v.js +0 -77
  197. package/dist/chunks/index-mev09s5v.js.map +0 -10
  198. package/dist/chunks/index-mt93ff2b.js.map +0 -10
  199. package/dist/chunks/index-qd5xgx6y.js.map +0 -13
  200. package/dist/chunks/index-x69p7cv7.js.map +0 -10
  201. package/dist/types/react/shellStyles.d.ts +0 -3
  202. package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
  203. /package/dist/chunks/{index-ev2b5aaf.js.map → index-xzb7sx6g.js.map} +0 -0
package/docs/variables.md CHANGED
@@ -9,17 +9,101 @@ description for an empty result). With no additional variables, its default
9
9
  input is the calendar request. With additional variables, it is `{ period, ...variables }`.
10
10
  Supply an `input` mapper for a different operation shape and `bindings` to extract
11
11
  nested period or field-filter inputs. Mappings must preserve the selected values.
12
+ Bindings are required when the operation input cannot supply a compatible
13
+ top-level filter field or the calendar request. Keep parsed selections in the
14
+ operation input and derive SQL parameters inside the operation.
12
15
 
13
- `dimensionFilter()` from `/contract` requires exactly one option source: fixed `options` or a `facet`.
14
- Use `defineFacetFilter()` to bind a facet operation and its typed input. `<DimensionPicker>` offers missing values separately and keeps selected values
15
- available when they have zero matches.
16
+ `dimensionFilter()` from `/contract` uses fixed `options`. Use `defineFacetFilter()`
17
+ for options derived from declared variable context, or `app.defineDimension()`
18
+ for independent source options and exact member lookup. `<DimensionPicker>` offers missing values separately and keeps selected values
19
+ available when options refresh or fail; unknown counts remain undisclosed.
16
20
 
17
21
  ## Declare controls once
18
22
 
19
23
  Use `searchVariable()`, `choiceVariable()`, and `dateRangeVariable()` in a view's
20
- `variables`. `<DataApp view={view}>` generates their controls and keeps values in the URL.
24
+ `variables`. `<DataApp view={view}>` generates search, filters, and display options
25
+ and keeps their values in the URL.
26
+ Set `showSearch={false}` or `showFilters={false}` on `<DataApp>` to hide the
27
+ corresponding region while preserving its values; `showFilters` includes display options.
28
+
21
29
  Keep local search out of the operation input when it only filters loaded rows.
22
30
 
31
+ ### Search suggestions
32
+
33
+ Declaring dataset `suggestions` enables autocomplete automatically. Use it when
34
+ record titles are useful query completions; omit it for aggregate datasets or when
35
+ completion would not help. No additional enabling prop is needed.
36
+
37
+ The app-owned `customers` operation accepts `{ q: string }` and returns `{ rows }`.
38
+ With your typed `client` and registered `dataContext`, connect the query to its
39
+ records and widgets:
40
+
41
+ ```tsx
42
+ const view = createDataHooks(client).defineDataView({
43
+ dataContext,
44
+ operation: 'customers',
45
+ variables: {
46
+ search: searchVariable({ key: 'q', label: 'Search customers' }),
47
+ },
48
+ input: ({ search }) => ({ q: search }),
49
+ describeInput: ({ q }) => (q ? `Customers matching ${q}` : 'All customers'),
50
+ isEmpty: () => false,
51
+ emptyFallback: { title: 'No customers' },
52
+ });
53
+ const customers = view.dataset({
54
+ name: 'Customers',
55
+ select: data => data.rows,
56
+ rowKey: row => row.id,
57
+ columns: { name: { value: row => row.name } },
58
+ evidence: { id: 'customers', queryNames: ['customers'] },
59
+ suggestions: {
60
+ title: row => row.name,
61
+ description: row => row.country,
62
+ },
63
+ });
64
+ const content = view.content(source => (
65
+ <TableWidget dataset={customers} source={source} />
66
+ ));
67
+
68
+ <DataApp view={view} datasets={[customers]} story={story}>
69
+ <DataSection content={content} />
70
+ </DataApp>;
71
+ ```
72
+
73
+ The first `searchVariable()` in declaration order is the primary search: it owns
74
+ autocomplete and combines supplied datasets that declare suggestions. Typing
75
+ updates the page and suggestions from the same displayed result. Capped or
76
+ paginated sources offer suggestions only for supplied rows. Title matches rank
77
+ ahead of description matches; the five suggestion slots are shared across datasets. Selection completes the query with
78
+ the title; `suggestions.onSelect: row => openCustomer(row.id)` overrides completion
79
+ with an app action. `showSearchSuggestions` defaults to true; set it to false to
80
+ suppress autocomplete for a particular app.
81
+
82
+ ### Organize controls by intent
83
+
84
+ Declare controls in priority order for the user's task. Keep useful scope filters
85
+ visible and set `presentation.prominence: 'secondary'` for less frequent ones in
86
+ the Filters sheet. Active filter summaries reopen the same Filters sheet.
87
+ Choose useful defaults rather than exposing every field; declare each label once.
88
+
89
+ Set `presentation.group: 'display'` for ordering or presentation choices. These
90
+ appear separately from scope filters. Search remains separate from both.
91
+
92
+ ```ts
93
+ const active = booleanFilter({
94
+ key: 'active',
95
+ label: 'Active account',
96
+ presentation: { prominence: 'secondary' },
97
+ });
98
+ const sort = choiceVariable({
99
+ key: 'sort',
100
+ label: 'Sort by',
101
+ options: [{ id: 'name', label: 'Customer name' }],
102
+ defaultValue: 'name',
103
+ presentation: { group: 'display' },
104
+ });
105
+ ```
106
+
23
107
  The [date range contract](contract.md#shared-date-ranges) owns source coverage,
24
108
  maximum range, time zone, and comparison rules. `defineTimeView()` is the compact
25
109
  path for a view whose primary input is a period. Use `defineDataView()` for fixed
@@ -73,43 +157,50 @@ const region = dimensionFilter({
73
157
  ```
74
158
 
75
159
  For query-backed choices use the hooks factory's `defineFacetFilter()`. The
76
- facet operation returns parsed dimension options. Its input mapper reads current
160
+ facet operation returns parsed dimension options. Its input mapper uses current
77
161
  resolved variables, including other filters:
78
162
 
79
163
  ```ts
80
- const { defineFacetFilter, defineTimeView } = createDataHooks(client);
164
+ const { defineFacetFilter } = createDataHooks(client);
165
+ const period = dateRangeVariable({
166
+ key: 'period',
167
+ contract: calendar,
168
+ defaultValue: { kind: 'preset', id: 'last-7' },
169
+ });
81
170
  const region = defineFacetFilter({
82
171
  key: 'region',
83
172
  label: 'Region',
84
173
  valueType: 'string',
85
174
  selectionMode: 'multiple',
86
175
  facet: {
176
+ context: { period },
87
177
  operation: 'regions',
88
- input: values => ({ period: values.period as DateRangeRequest }),
178
+ input: values => ({ period: values.period }),
89
179
  },
90
180
  });
91
181
  ```
92
182
 
93
- The client's operation map defines `regions` and its typed period input;
94
- import `DateRangeRequest` from `/contract`. Put `region` in the view's `variables`
95
- alongside its period. Use `parseFacetOptions()` to validate facet results.
183
+ Declare mapper dependencies in `facet.context` (`{}` for none), and include them
184
+ alongside the facet in the view's `variables`. Mapper inputs and option values are
185
+ inferred from the variables and operation; options must match `valueType`.
96
186
  For the operation's input parser, use `parseDimensionSelection(value, region)` from `/contract`.
97
187
  A dimension without an explicit selection represents all members.
98
188
  Map parsed selections to the query's declared parameters; do not construct SQL
99
189
  from filter values. Choose selection modes supported by the registered query.
100
190
 
101
- Choose `selectionMode: 'single'` when one value replaces another. Its picker closes
102
- after choosing a value and shows a checkmark for the current choice. Use
103
- `selectionMode: 'multiple'` for independent values; checkbox indicators and an open
104
- popup allow repeated selections. `All` is an explicit choice for a single-value
191
+ Choose `selectionMode: 'single'` when one value replaces another and
192
+ `selectionMode: 'multiple'` for independent values. `All` is an explicit choice for a single-value
105
193
  filter and the meaning of an empty selection for a multiple-value filter.
194
+ Single-value filters always have a selection limit of one.
106
195
 
107
196
  ## Fixed choices
108
197
 
109
198
  `choiceVariable()` requires labeled `options` and a valid `defaultValue`.
110
199
  `multiChoiceVariable()` stores unique option IDs with an optional selection limit.
111
- An empty fixed-choice collection means no choices; categorical filters use
112
- `dimensionFilter()` when an empty selection should mean all records.
200
+ Fixed-choice declarations need at least one option. Inline options or `as const`
201
+ preserve their IDs so TypeScript checks defaults against them. An empty selected
202
+ collection means no choices; categorical filters use `dimensionFilter()` when
203
+ an empty selection should mean all records.
113
204
 
114
205
  ```ts
115
206
  const variables = {
@@ -126,11 +217,6 @@ const variables = {
126
217
  };
127
218
  ```
128
219
 
129
- Fixed single choices generate `<Select>`; multiple choices generate
130
- `<ChoicePicker selectionMode="multiple">`. Direct controls can present the same
131
- values as radio groups, checkbox groups, or segmented choices without changing
132
- URL state.
133
-
134
220
  ## Numeric and boolean predicates
135
221
 
136
222
  Import `numberFilter()` and `booleanFilter()` from `/contract` and put their
@@ -159,13 +245,76 @@ Set `allowExclusion: true` on `dimensionFilter()` to support
159
245
  alongside selected members. Enable exclusion only when the registered query supports
160
246
  it, including the intended behavior for missing values.
161
247
 
162
- Generated controls show active values within each filter and one collective
163
- Clear icon with a tooltip. Clear removes restrictions from search and predicate filters.
248
+ Clear removes predicate filters while preserving search and display settings.
249
+ Clear search separately in its field.
164
250
  `resetAll()` restores all
165
251
  configured variable defaults, including fixed choices and periods. Nonempty
166
252
  default filters can therefore be active immediately after Reset.
167
253
 
168
- Direct `useAppVariables()` callers can use `clearAll()` and `resetAll()` for one
169
- atomic history update. `<FilterActions>` also supports app-owned draft state
254
+ Direct `useAppVariables()` callers can use `clearAll()` and `resetAll()`. `<FilterActions>` also supports app-owned draft state
170
255
  with paired Apply/Cancel handlers; derive queries and visible controls from applied
171
256
  values while a draft is being edited.
257
+
258
+ Filters apply immediately; use app-owned drafts only when the task needs Apply/Cancel.
259
+
260
+ ## Independent filters and chart breakdowns
261
+
262
+ Each dimension owns its selection. Readers can select Germany without selecting
263
+ a region; changing or clearing Region preserves Country and Customer. Filters
264
+ combine in the operation's query. Incompatible selections can return an empty
265
+ result; keep the selections visible so readers can correct them.
266
+
267
+ Use `dimensionFilter()` for static options or `app.defineDimension()` for query-backed
268
+ options. `variableInput()` from `/contract` validates named variables alongside an
269
+ app-owned base parser. Use it on every operation consuming these filters, including
270
+ details. Declare the same variables on the view and preserve them in operation input.
271
+
272
+ ```ts
273
+ const country = app.defineDimension({
274
+ key: 'country',
275
+ label: 'Country',
276
+ valueType: 'string',
277
+ selectionMode: 'single',
278
+ presentation: { prominence: 'secondary' },
279
+ source: { query: 'countries' },
280
+ });
281
+ const revenueBy = choiceVariable({
282
+ key: 'revenue-by',
283
+ label: 'Revenue breakdown',
284
+ defaultValue: 'region',
285
+ options: [
286
+ { id: 'region', label: 'Region' },
287
+ { id: 'country', label: 'Country' },
288
+ ],
289
+ presentation: { group: 'display', control: 'widget' },
290
+ });
291
+ const parseInput = variableInput(parsePeriodInput, { country, revenueBy });
292
+ ```
293
+
294
+ A breakdown is an ordinary display choice, independent of population filters.
295
+ `<VisualizationWidget breakdown={view.breakdown('revenueBy')}>` renders that
296
+ choice in its header. `presentation.control: 'widget'` omits it from the toolbar.
297
+ Scope filters still appear in the Filters sheet, active summaries, and Clear filters.
298
+ Primary controls stay in the toolbar. Active non-primary filters appear beside them
299
+ as editable controls. Once the toolbar scrolls above the viewport,
300
+ a floating summary shows every active filter and opens the Filters sheet.
301
+ Declare each chart's choice separately when readers should control them independently.
302
+
303
+ Each source query declares a nullable `member` parameter matching `valueType` and
304
+ nonnullable projections for `value` (the same type), `label` (string), and optional
305
+ `count` (number). `member = null` requests at most 200 options; a selected value requests
306
+ an exact lookup. Other query parameters need defaults or trusted server values.
307
+ Keep SQL and parameter declarations literal in `defineDataApp()`.
308
+
309
+ ```sql
310
+ SELECT code AS value, name AS label
311
+ FROM countries
312
+ WHERE ($member IS NULL OR code = $member)
313
+ ORDER BY name
314
+ ```
315
+
316
+ Exact selected-member lookups run before business queries, sharing authorization,
317
+ cancellation, execution limits, and query evidence. Labels resolve separately from
318
+ the options page, including when it fails. Picker search searches supplied options;
319
+ it does not fetch additional members. Clear filters preserves search and display
320
+ choices and returns dates to their configured defaults.
package/docs/views.md CHANGED
@@ -35,6 +35,10 @@ function App() {
35
35
 
36
36
  Omit `variables` when there are no controls. Omit `input` when the resolved
37
37
  variables match the operation input; nested or different inputs need a mapper.
38
+ Keep scope variable values in required operation input fields with the same names
39
+ to derive their bindings. Other input shapes require typed
40
+ `bindings` that read each selection back unchanged. Derive scalar SQL parameters
41
+ inside the operation rather than replacing the selections in the view input.
38
42
  The operation and `ActivityWidgets` are app-owned. The bound widgets derive
39
43
  loading content from their source; see [widgets](widgets.md) and the
40
44
  [complete starter](../examples/starter-data-app/index.tsx). Define
@@ -64,7 +68,7 @@ operation and its view. For nested inputs in `defineTimeView()`, use
64
68
  `bindings.period` to extract the selected period; see the
65
69
  [time-view example](variables.md#declare-controls-once).
66
70
 
67
- Use `result.scope` inside `view.content()` as a reading for scope text. In stories and exports,
71
+ Use `result.scope` inside `view.content()` to show scope text. In stories and exports,
68
72
  `view.scope(snapshot)` returns the same label from the displayed input, using
69
73
  `describeInput` or the view's date label.
70
74
 
@@ -78,7 +82,7 @@ Declare evidence references on `view.dataset()` for charts and tables. `<MetricW
78
82
  its metric definition for the label, format, and evidence; keep view-specific
79
83
  descriptions on the widget.
80
84
 
81
- `<MetricWidget>` and `<Comparison>` share a metric reading. Comparisons
85
+ `<MetricWidget>` and `<Comparison>` share a metric result. Comparisons
82
86
  follow the displayed result's range.
83
87
 
84
88
  Use the [format helpers](formatting-and-appearance.md) for metric formats and values in tables,
@@ -86,38 +90,65 @@ charts, and custom views.
86
90
 
87
91
  ## Preserve displayed results
88
92
 
89
- The callback in `view.content()` receives a displayed source with `loading`,
90
- `data`, `input`, and `scope`. Bind widgets to that source. Its input remains the
91
- one that produced the visible data during refreshes and failures.
93
+ Bind widgets to the source supplied by `view.content()`. Derive scope labels,
94
+ stories, and exports from its displayed input, including during refreshes.
95
+ Keep related datasets in one view so their results stay consistent; use
96
+ `<DataSection>` for independently queried content. Let the view handle loading,
97
+ errors, and refreshes instead of duplicating request state in app code.
92
98
 
93
- Keep the client stable across renders; create it outside the component.
99
+ A measured zero is valid data. Define `isEmpty` for the analysis and provide
100
+ useful `emptyFallback` copy.
94
101
 
95
- ## Request ownership
102
+ ## Detail destinations
96
103
 
97
- `<DataApp>` owns the toolbar, controls, inspection, and page feedback for its
98
- primary `view`. It always renders children, so introductions and static
99
- context remain visible while a section loads. It requires both
100
- [story and CSV export](stories-and-export.md) for a data request.
104
+ Use `createDataHooks(client).defineDetailView()` for a scoped population or entity.
105
+ The destination owns its input parser, operation, datasets, evidence, and content.
106
+ Pass its content to `<DataApp details={[ordersDetail]}>`:
101
107
 
102
- Place `<DataSection content={content}>` around each independently fetched subtree.
103
- Declare its shared loading and ready layout with `view.content()`. The section
104
- inherits empty copy from its view, with an optional local override, and handles
105
- initial errors and retries. Primary content shares the app's displayed result;
106
- independent content uses its own context and executed queries.
108
+ ```tsx
109
+ const ordersView = defineDetailView({
110
+ id: 'orders',
111
+ title: 'Contributing orders',
112
+ operation: 'orders',
113
+ dataContext,
114
+ parseInput: operations.orders.input,
115
+ describeInput: describeOrderScope,
116
+ isEmpty: data => data.rows.length === 0,
117
+ emptyFallback: { title: 'No contributing orders' },
118
+ });
119
+ const ordersDetail = ordersView.content(source => (
120
+ <TableWidget dataset={orders} source={source} />
121
+ ));
122
+ ```
107
123
 
108
- Keep related datasets in one view so export and story share a coherent snapshot.
124
+ Declare `orders` with `ordersView.dataset()`. Detail inputs contain serializable
125
+ scope and IDs; exclude entire records, credentials, and protected server values.
126
+ Validate selected members through the same `variableInput()` parser used by the dashboard.
127
+ Shared links validate before execution. Nested destinations replace the single
128
+ detail sheet; the main app retains ownership of exports and stories.
129
+ The complete route supports up to 20 destinations and 16,384 serialized characters;
130
+ navigation rejects overflow before changing history.
109
131
 
110
- | State | Display |
111
- | --------------- | --------------------------------------------------------- |
112
- | Initial loading | The authored loading fallback; selectors do not run |
113
- | Initial error | A source-aware error with retry when recovery is possible |
114
- | Empty result | The authored empty fallback |
115
- | Ready | Data and the input that produced it |
116
- | Updating | The prior result and its original input, fully readable |
117
- | Failed refresh | The prior result and its evidence, with recovery feedback |
132
+ ### Contributing metric records
118
133
 
119
- `isEmpty` is app-owned. A measured zero is valid data unless the analysis explicitly
120
- says otherwise. Use the displayed input in content, export, and story callbacks for scope labels.
134
+ Attach a destination to a metric and supply it to the existing inspection trigger:
135
+
136
+ ```tsx
137
+ const contributingOrders = orderCount.records({
138
+ target: ordersView,
139
+ input: displayedInput => displayedInput,
140
+ });
141
+
142
+ <MetricWidget
143
+ metric={orderCount}
144
+ source={source}
145
+ records={contributingOrders}
146
+ />;
147
+ ```
121
148
 
122
- `<DataApp>` owns request execution, refresh, and cancellation. Keep raw request
123
- state out of app code.
149
+ Inspection tabs become Records, Glossary, Queries. Records load when their tab
150
+ is shown; the destination's `describeInput()` supplies their scope. Source context
151
+ belongs in Glossary. Match record inclusion to the metric and explain non-additive
152
+ metrics. State completeness limits visibly in destination content. Local pagination
153
+ covers only supplied rows; larger populations need explicit server paging or a
154
+ visible limit.
package/docs/widgets.md CHANGED
@@ -18,36 +18,35 @@ readings without inventing values. Use `isEmpty` for the predicate and
18
18
  | One data-dependent phrase within static prose | `<DataValue>` |
19
19
 
20
20
  Use [layout](layout.md) for `<Stack>`, `<Grid>`, and responsive `<GridItem>` spans.
21
- `<Skeleton>` supports custom fallback content; `/react/ui` supplies
22
- `<DataAppSkeleton>` for iframe startup.
21
+ `<Skeleton>` supports custom fallback content.
23
22
 
24
23
  ## Choose a visualization
25
24
 
26
- Choose the component by the reader's question. Compose dataset visuals inside
25
+ Choose the component by the user's question. Compose dataset visuals inside
27
26
  `<VisualizationWidget>`; use `<MetricWidget>` for a headline value. Built-in
28
27
  charts come from `/react/ui`; `<Ranking>`, `<Breakdown>`, and `<Comparison>`
29
28
  are also available from `/react`.
30
29
 
31
- | Question or need | Component | Guidance |
32
- | --------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------ |
33
- | How do categories compare? | `<BarChart>` | Compare nonnegative category values; order by value for rank or by a meaningful category order. |
34
- | Which items lead? | `<Ranking>` | Use a compact ordered list with values and optional detail. Tracks scale to the largest visible item, not a total. |
35
- | How does a measure change over time? | `<LineChart>` | Use ordered, equally spaced samples to emphasize the trend. |
36
- | How large is the measure over time? | `<AreaChart>` | Use the same samples as a line chart when filled magnitude relative to zero helps answer the question. |
37
- | What makes up the whole? | `<PieChart>` | Use a few mutually exclusive parts of one total; include the remainder as Other. |
38
- | What share of an observed total does each part represent? | `<Breakdown>` | Use a compact display of values and shares with an explicit total, including when only some parts are shown. |
39
- | How do several measures relate on one plot? | `<ComposedChart>` | Compose bars, lines, areas, or scatter series; label units clearly and use separate axes for different units. |
40
- | How are two numeric measures related? | `<ScatterChart>` | Use independent X/Y observations to explore relationships, clusters, and outliers. |
41
- | Where do users drop out of a sequence? | `<FunnelChart>` | Use ordered counts from the same population reaching each successive step. |
42
- | Do cohorts return over time? | `<RetentionChart>` | Use query-defined rates and retained counts by numeric offset; mark incomplete periods. |
43
- | Which paths do users take? | `<JourneyChart>` | Use full paths with population counts and outcomes; explore branches step by step. |
44
- | How did one metric change between periods? | `<Comparison>` | Use the metric reading and its displayed comparison period. |
45
- | What are the exact values or row details? | `<TableWidget>` | Use a bound table for lookup, search, and precise comparisons. |
46
-
47
- Prefer bars or a ranking when readers need to compare similarly sized categories;
30
+ | Question or need | Component | Guidance |
31
+ | ------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
32
+ | How do categories compare? | `<BarChart>` | Compare nonnegative category values; order by value for rank or by a meaningful category order. |
33
+ | Which items lead? | `<Ranking>` | Use a compact ordered list with values and optional detail. Tracks scale to the largest visible item, not a total. |
34
+ | How does a measure, including conversion rate, change over calendar time? | `<LineChart>` | Use ordered, equally spaced samples to emphasize the trend. |
35
+ | How large is the measure over time? | `<AreaChart>` | Use the same samples as a line chart when filled magnitude relative to zero helps answer the question. |
36
+ | What makes up the whole? | `<PieChart>` | Use a few mutually exclusive parts of one total; include the remainder as Other. |
37
+ | What share of an observed total does each part represent? | `<Breakdown>` | Use a compact display of values and shares with an explicit total, including when only some parts are shown. |
38
+ | How do several measures relate on one plot? | `<ComposedChart>` | Compose bars, lines, areas, or scatter series; label units clearly and use separate axes for different units. |
39
+ | How are two numeric measures related? | `<ScatterChart>` | Use independent X/Y observations to explore relationships, clusters, and outliers. |
40
+ | Where does a population drop off across ordered steps? | `<FunnelChart>` | Show counts and drop-off across ordered steps within a population; optionally compare populations. See [inputs and examples](ui.md#product-analytics-charts). |
41
+ | Do cohorts return at elapsed intervals after a starting event? | `<RetentionChart>` | Show return rates over elapsed intervals after a starting event; optionally compare cohorts or segments. See [inputs and examples](ui.md#product-analytics-charts). |
42
+ | Which event paths do populations follow, and where do they branch? | `<JourneyChart>` | Explore full paths with population counts and outcomes. See [inputs and examples](ui.md#product-analytics-charts). |
43
+ | How did one metric change between periods? | `<Comparison>` | Use the metric result and its displayed comparison period. |
44
+ | What are the exact values or row details? | `<TableWidget>` | Use a bound table for lookup, search, and precise comparisons. |
45
+
46
+ Prefer bars or a ranking when users need to compare similarly sized categories;
48
47
  use a pie for a simple composition question. Prefer a line when the trend is
49
48
  enough; use area when the fill adds meaning. Keep exact values available in a
50
- table when they matter. Follow the [chart input constraints](ui.md#charts). For multiple or mixed series,
49
+ table when they matter. Follow the [chart input constraints](ui.md#charts). For custom combinations of series,
51
50
  use the [composed chart primitives](ui.md#composed-charts) within the same bound
52
51
  visualization workflow.
53
52
 
@@ -59,6 +58,8 @@ question from the same dataset.
59
58
  Bind reusable selections to the view. Declare evidence references directly;
60
59
  the view validates them against its own context. A dataset's columns supply both formatted
61
60
  table cells and raw CSV values. Widgets derive their readings, evidence, and empty fallback from the binding.
61
+ Declare at least one dataset column. Metric selectors may return `previous`
62
+ only for views with a date binding, including `defineTimeView()`.
62
63
 
63
64
  ```tsx
64
65
  const countries = activityView.dataset({
@@ -99,13 +100,27 @@ row-key callbacks explicitly; row keys must be stable and unique.
99
100
  Metric comparisons require a
100
101
  view date binding. `read()` returns a loading-aware value for custom prose.
101
102
  Pass the binding and `source={snapshot}` to reuse a widget in a story. Use the
102
- source supplied by that binding's own view; reconstructed or foreign sources
103
- are rejected before selection.
104
- Selectors do not run during loading. Table search, pagination, descriptions, and
103
+ source supplied by that binding's own view. Table search, pagination, descriptions, and
105
104
  actions remain local choices. For custom cells, use `format: row => ...`; CSV
106
105
  still uses the raw `value` accessor. Datasets default to “No results”; supply
107
106
  `emptyFallback` for specific copy. See [export](stories-and-export.md).
108
107
 
108
+ `<TableWidget>` automatically shows the count of matching supplied rows. Use
109
+ `count` for a server total; other widgets can receive a count from the displayed result.
110
+
111
+ Provide useful `emptyFallback` and `noMatchesFallback` copy. Local search offers
112
+ Clear search automatically. For server-filtered tables, supply `onClearFilters`
113
+ only while filters affecting that dataset are active, preserving unrelated filters,
114
+ search, and display settings.
115
+
116
+ ```tsx
117
+ <TableWidget
118
+ dataset={customers}
119
+ source={source}
120
+ onClearFilters={hasActiveCustomerFilters ? clearCustomerFilters : undefined}
121
+ />
122
+ ```
123
+
109
124
  ## Narrative text
110
125
 
111
126
  Use `<TextContent>` for prose within a page or custom layout, and `<TextWidget>`
@@ -113,7 +128,7 @@ when the explanation belongs in a titled panel alongside other widgets.
113
128
 
114
129
  Give text a purpose: frame the question, explain how to interpret a comparison,
115
130
  qualify a finding, or suggest what to explore next. Choose the content for the
116
- reader's question.
131
+ user's question.
117
132
 
118
133
  For data-dependent text, pass `metric` or `dataset` and `source` to `<TextWidget>`.
119
134
  It derives its title and evidence. A metric formats its current value by default;
@@ -123,7 +138,6 @@ including an empty selection, so they can explain zero activity.
123
138
  Use `<DataValue metric={total} source={result} />` for a formatted value inside
124
139
  static prose, or pass a dataset and row renderer. Its default loading fallback is
125
140
  an inline skeleton. Use `<DataValue scope={result.scope} />` for a scope label.
126
- All selectors use the displayed source; loading selectors do not run.
127
141
  Use `<TextContent>` for static instructions; local filters should feed the same
128
142
  filtered data to the text and its related visualization.
129
143
 
@@ -146,3 +160,94 @@ For embedded theme and chrome, see [parent presentation](embed.md#parent-present
146
160
 
147
161
  `<TooltipProvider>` shares hover timing outside `<DataApp>`; the app already
148
162
  provides it.
163
+
164
+ ## Exploration actions
165
+
166
+ Declare actions on their dataset or metric and pass them to its widget. Detail
167
+ mappings receive the displayed operation input, including during refreshes.
168
+ Both `children` and alternate-view `render` callbacks receive the displayed rows
169
+ and the same action resolver.
170
+
171
+ ```tsx
172
+ const placeActions = places.actions(
173
+ action => ({
174
+ orders: action.detail({
175
+ label: 'View orders',
176
+ target: ordersView,
177
+ input: (row, displayedInput) => ({ ...displayedInput, placeId: row.id }),
178
+ }),
179
+ filter: action.filter({
180
+ label: 'Filter to this region',
181
+ when: row => row.dimension === 'region',
182
+ target: salesView.filter(),
183
+ values: row => ({
184
+ region: {
185
+ kind: 'include',
186
+ members: [{ kind: 'value', value: row.id }],
187
+ },
188
+ }),
189
+ }),
190
+ drill: action.filter({
191
+ label: 'Drill down',
192
+ when: row => row.dimension === 'region',
193
+ target: salesView.filter(),
194
+ values: row => ({
195
+ region: {
196
+ kind: 'include',
197
+ members: [{ kind: 'value', value: row.id }],
198
+ },
199
+ }),
200
+ breakdown: {
201
+ target: salesView.breakdown('revenueBy'),
202
+ value: () => 'country',
203
+ },
204
+ }),
205
+ }),
206
+ { primary: 'orders' }
207
+ );
208
+
209
+ <VisualizationWidget
210
+ dataset={places}
211
+ source={source}
212
+ actions={placeActions}
213
+ breakdown={salesView.breakdown('revenueBy')}
214
+ >
215
+ {(rows, actions) => (
216
+ <BarChart
217
+ ariaLabel="Revenue by place"
218
+ unit="USD"
219
+ items={rows.map(row => ({ ...row, value: row.revenue }))}
220
+ itemActions={actions}
221
+ />
222
+ )}
223
+ </VisualizationWidget>;
224
+ ```
225
+
226
+ Keep domain fields when adapting chart items. Bar, line, area, pie slices, and
227
+ pie legend items share the same action contract. Chart marks keep a sole or
228
+ declared `primary` action direct. The full pie legend row and bar label open the
229
+ menu; bar labels use a small inline disclosure chevron.
230
+
231
+ Menus retain every available action and group copying after exploration actions.
232
+ The first copy action names the text it copies. Copy summary includes the displayed
233
+ label, formatted value, unit, and pie share. Successful copies are silent; failures
234
+ are announced and shown on the chart.
235
+ Right-click opens the menu at the pointer; Shift+F10 anchors it to the control.
236
+ Breakdown controls keep their selected choice visible and their accessible names.
237
+ Custom controls can compose `<ExplorationActionControl>` from `/react/ui`.
238
+
239
+ `<TableWidget actions={placeActions}>` adds row actions without changing the
240
+ dataset or its CSV export. `<MetricWidget>` accepts actions declared with
241
+ `metric.actions()`; metric action mappings receive `undefined` for the row and
242
+ the displayed operation input as their second argument. Actions must belong to
243
+ the metric or dataset rendered by the widget.
244
+
245
+ `view.filter()` targets scope variables. An optional `breakdown` explicitly updates
246
+ one chart's display choice in the same history entry. Filters preserve unrelated
247
+ selections. Filter actions wait for displayed and applied scope to agree; actions
248
+ that also change a breakdown check that chart's displayed choice. No filter change
249
+ implicitly changes another filter or chart.
250
+
251
+ A day drill passes its day. A value-band drill passes a stable band ID; validate
252
+ it in the destination operation and derive bounds there. Query matching records
253
+ rather than filtering a capped dashboard preview. See [detail destinations](views.md#detail-destinations).