@altertable/data-app 0.67.0 → 0.69.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 (183) hide show
  1. package/AGENTS.md +6 -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-ktmvs916.js → index-2sbp9h2b.js} +37 -21
  8. package/dist/chunks/index-2sbp9h2b.js.map +13 -0
  9. package/dist/chunks/{index-23dktynd.js → index-ap60vggk.js} +4 -4
  10. package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
  11. package/dist/chunks/index-cv36cyna.js.map +10 -0
  12. package/dist/chunks/{index-ag0cgnvq.js → index-k766wwwr.js} +13 -9
  13. package/dist/chunks/index-k766wwwr.js.map +13 -0
  14. package/dist/chunks/{index-mt93ff2b.js → index-kwnqycjt.js} +2 -2
  15. package/dist/chunks/index-kwnqycjt.js.map +10 -0
  16. package/dist/chunks/index-m0gbxtgp.js +355 -0
  17. package/dist/chunks/index-m0gbxtgp.js.map +13 -0
  18. package/dist/chunks/{index-8qfxv0h5.js → index-qhzdzca2.js} +3951 -2242
  19. package/dist/chunks/index-qhzdzca2.js.map +118 -0
  20. package/dist/chunks/{index-x69p7cv7.js → index-r7b1ftwy.js} +3 -3
  21. package/dist/chunks/index-r7b1ftwy.js.map +10 -0
  22. package/dist/chunks/{index-ev2b5aaf.js → index-sx488hvs.js} +4 -4
  23. package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
  24. package/dist/chunks/index-wss3gd3h.js.map +13 -0
  25. package/dist/chunks/{index-qd5xgx6y.js → index-zcqxfwdq.js} +5 -12
  26. package/dist/chunks/index-zcqxfwdq.js.map +13 -0
  27. package/dist/client/index.js +6 -6
  28. package/dist/core/appearance.js +1 -1
  29. package/dist/core/config.js +3 -3
  30. package/dist/core/contract.js +3 -3
  31. package/dist/core/format.js +10 -2
  32. package/dist/core/format.js.map +1 -1
  33. package/dist/embed/index.js +26 -25
  34. package/dist/embed/index.js.map +4 -4
  35. package/dist/index.js +3 -3
  36. package/dist/local.js +166 -144
  37. package/dist/local.js.map +8 -7
  38. package/dist/preview.js +1456 -0
  39. package/dist/preview.js.map +17 -0
  40. package/dist/react/embed/index.js +1 -1
  41. package/dist/react/index.js +272 -103
  42. package/dist/react/index.js.map +10 -11
  43. package/dist/react/ui/index.js +2124 -1254
  44. package/dist/react/ui/index.js.map +20 -13
  45. package/dist/server.js +68 -57
  46. package/dist/server.js.map +7 -6
  47. package/dist/types/client/download.d.ts +5 -0
  48. package/dist/types/client/iframe.d.ts +4 -2
  49. package/dist/types/client/logger.d.ts +10 -2
  50. package/dist/types/core/annotations.d.ts +5 -0
  51. package/dist/types/core/appearance.d.ts +2 -0
  52. package/dist/types/core/bridge-endpoint.d.ts +2 -2
  53. package/dist/types/core/bridge.d.ts +22 -0
  54. package/dist/types/core/config.d.ts +5 -0
  55. package/dist/types/core/contract.d.ts +3 -1
  56. package/dist/types/core/date-format.d.ts +24 -0
  57. package/dist/types/core/dimension.d.ts +2 -1
  58. package/dist/types/core/filters.d.ts +4 -3
  59. package/dist/types/core/format.d.ts +5 -3
  60. package/dist/types/core/messages.d.ts +3 -1
  61. package/dist/types/core/operation-types.d.ts +7 -7
  62. package/dist/types/core/time-interval.d.ts +96 -0
  63. package/dist/types/core/variables.d.ts +13 -4
  64. package/dist/types/embed/host.d.ts +4 -4
  65. package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
  66. package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
  67. package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
  68. package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
  69. package/dist/types/react/bindings.d.ts +26 -3
  70. package/dist/types/react/date-formatting.d.ts +12 -0
  71. package/dist/types/react/hooks.d.ts +10 -9
  72. package/dist/types/react/index.d.ts +7 -2
  73. package/dist/types/react/search-suggestions.d.ts +8 -0
  74. package/dist/types/react/style-contract.d.ts +13 -5
  75. package/dist/types/react/ui/ChartLegend.d.ts +4 -3
  76. package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
  77. package/dist/types/react/ui/ComposedChart.d.ts +1 -1
  78. package/dist/types/react/ui/DataApp.d.ts +5 -4
  79. package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
  80. package/dist/types/react/ui/DataTable.d.ts +6 -4
  81. package/dist/types/react/ui/DataWidget.d.ts +4 -0
  82. package/dist/types/react/ui/DateDisplay.d.ts +9 -0
  83. package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
  84. package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
  85. package/dist/types/react/ui/DimensionPicker.d.ts +3 -1
  86. package/dist/types/react/ui/EmptyState.d.ts +1 -1
  87. package/dist/types/react/ui/FunnelChart.d.ts +20 -0
  88. package/dist/types/react/ui/GradientScroll.d.ts +8 -0
  89. package/dist/types/react/ui/Grid.d.ts +1 -1
  90. package/dist/types/react/ui/JourneyChart.d.ts +10 -0
  91. package/dist/types/react/ui/MetricWidget.d.ts +2 -0
  92. package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
  93. package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
  94. package/dist/types/react/ui/PickerField.d.ts +15 -0
  95. package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
  96. package/dist/types/react/ui/RequestHint.d.ts +2 -2
  97. package/dist/types/react/ui/RetentionChart.d.ts +27 -0
  98. package/dist/types/react/ui/SearchField.d.ts +3 -1
  99. package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
  100. package/dist/types/react/ui/SectionHeading.d.ts +8 -0
  101. package/dist/types/react/ui/Select.d.ts +5 -1
  102. package/dist/types/react/ui/Sheet.d.ts +3 -1
  103. package/dist/types/react/ui/TableWidget.d.ts +8 -0
  104. package/dist/types/react/ui/Tabs.d.ts +4 -3
  105. package/dist/types/react/ui/VariableBar.d.ts +1 -1
  106. package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
  107. package/dist/types/react/ui/chart-data.d.ts +9 -0
  108. package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
  109. package/dist/types/react/ui/chart-interaction.d.ts +21 -0
  110. package/dist/types/react/ui/chart-primitives.d.ts +7 -5
  111. package/dist/types/react/ui/chart-time.d.ts +16 -0
  112. package/dist/types/react/ui/chartColor.d.ts +1 -0
  113. package/dist/types/react/ui/icons.d.ts +3 -1
  114. package/dist/types/react/ui/index.d.ts +15 -4
  115. package/dist/types/react/ui/journey-flow.d.ts +49 -0
  116. package/dist/types/react/ui/metric-comparison.d.ts +2 -2
  117. package/dist/types/react/ui/metric.d.ts +2 -2
  118. package/dist/types/react/ui/presentation.d.ts +2 -0
  119. package/dist/types/react/ui/searchItems.d.ts +2 -0
  120. package/dist/types/react/ui/useSvgId.d.ts +2 -0
  121. package/dist/types/react/ui/variables.d.ts +1 -1
  122. package/dist/types/react/view-control-bar.d.ts +16 -0
  123. package/dist/types/react/view-controls.d.ts +3 -2
  124. package/dist/types/react/view-runtime.d.ts +3 -1
  125. package/dist/types/react/view.d.ts +14 -2
  126. package/dist/types/server/local.d.ts +3 -1
  127. package/dist/types/server/preview/host.d.ts +1 -0
  128. package/dist/types/server/preview/index.d.ts +16 -0
  129. package/dist/types/server/reload-channel.d.ts +6 -0
  130. package/dist/types/server/request-body.d.ts +4 -0
  131. package/dist/worker.js +2 -2
  132. package/docs/app-authoring.md +17 -9
  133. package/docs/client.md +1 -1
  134. package/docs/contract.md +10 -10
  135. package/docs/embed.md +11 -3
  136. package/docs/formatting-and-appearance.md +36 -5
  137. package/docs/layout.md +31 -8
  138. package/docs/react-embed.md +4 -4
  139. package/docs/react.md +1 -1
  140. package/docs/server-bun.md +25 -0
  141. package/docs/server.md +1 -1
  142. package/docs/styling.md +7 -28
  143. package/docs/ui.md +33 -12
  144. package/docs/variables.md +92 -15
  145. package/docs/views.md +13 -36
  146. package/docs/widgets.md +38 -23
  147. package/docs/worker.md +2 -1
  148. package/examples/starter-data-app/index.tsx +0 -1
  149. package/examples/starter-local-data-app/.bun-version +1 -0
  150. package/examples/starter-local-data-app/.node-version +1 -0
  151. package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
  152. package/examples/starter-local-data-app/.oxlintrc.json +33 -0
  153. package/examples/starter-local-data-app/AGENTS.md +22 -0
  154. package/examples/starter-local-data-app/README.md +54 -0
  155. package/examples/starter-local-data-app/app.ts +22 -0
  156. package/examples/starter-local-data-app/bunfig.toml +2 -0
  157. package/examples/starter-local-data-app/package.json +33 -0
  158. package/examples/starter-local-data-app/src/App.tsx +8 -0
  159. package/examples/starter-local-data-app/src/assets.d.ts +1 -0
  160. package/examples/starter-local-data-app/src/data-context.ts +21 -0
  161. package/examples/starter-local-data-app/src/favicon.svg +13 -0
  162. package/examples/starter-local-data-app/src/index.html +14 -0
  163. package/examples/starter-local-data-app/src/main.tsx +7 -0
  164. package/examples/starter-local-data-app/src/operations.ts +6 -0
  165. package/examples/starter-local-data-app/src/server.ts +6 -0
  166. package/examples/starter-local-data-app/tsconfig.json +15 -0
  167. package/package.json +13 -3
  168. package/dist/chunks/index-8qfxv0h5.js.map +0 -108
  169. package/dist/chunks/index-ag0cgnvq.js.map +0 -13
  170. package/dist/chunks/index-dq7b35fn.js +0 -307
  171. package/dist/chunks/index-dq7b35fn.js.map +0 -13
  172. package/dist/chunks/index-f5cnbrjz.js.map +0 -13
  173. package/dist/chunks/index-ktmvs916.js.map +0 -13
  174. package/dist/chunks/index-m6n8ctfc.js.map +0 -10
  175. package/dist/chunks/index-mev09s5v.js +0 -77
  176. package/dist/chunks/index-mev09s5v.js.map +0 -10
  177. package/dist/chunks/index-mt93ff2b.js.map +0 -10
  178. package/dist/chunks/index-qd5xgx6y.js.map +0 -13
  179. package/dist/chunks/index-x69p7cv7.js.map +0 -10
  180. package/dist/types/react/shellStyles.d.ts +0 -3
  181. package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
  182. /package/dist/chunks/{index-23dktynd.js.map → index-ap60vggk.js.map} +0 -0
  183. /package/dist/chunks/{index-ev2b5aaf.js.map → index-sx488hvs.js.map} +0 -0
package/docs/styling.md CHANGED
@@ -13,15 +13,6 @@ Configure theme, palette, accent, typography, density, radius, and elevation thr
13
13
  Add app-owned classes through `className`. Render package components rather than copying their classes onto markup;
14
14
  private descendants are not customization hooks. Public names and stable roots
15
15
  are listed in the [typed contract](https://github.com/altertable-ai/data-app/blob/main/src/react/style-contract.ts).
16
- CSS comments document [inherited defaults](https://github.com/altertable-ai/data-app/blob/main/src/react/tokens.css),
17
- [interaction overrides](https://github.com/altertable-ai/data-app/blob/main/src/react/interaction.css),
18
- and [focus overrides](https://github.com/altertable-ai/data-app/blob/main/src/react/ui/Focus.css).
19
- Widget-specific overrides live beside their uses in
20
- [metrics](https://github.com/altertable-ai/data-app/blob/main/src/react/ui/MetricWidget.css),
21
- [bar charts](https://github.com/altertable-ai/data-app/blob/main/src/react/ui/BarChart.css),
22
- [code](https://github.com/altertable-ai/data-app/blob/main/src/react/ui/QueryList.css),
23
- and [layout](https://github.com/altertable-ai/data-app/blob/main/src/react/ui/Grid.css).
24
- The `--atbl-` prefix means Altertable.
25
16
 
26
17
  ```css
27
18
  .app-action {
@@ -30,20 +21,10 @@ The `--atbl-` prefix means Altertable.
30
21
  }
31
22
  ```
32
23
 
33
- Set tokens on `:root` for the document or on a component for local overrides.
34
- Inherited tokens are usable in app CSS. Optional overrides fall back where they
35
- are consumed, so local colors, fonts, and spacing compose. Portals inherit from
36
- their actual DOM ancestors. Normal unlayered app CSS overrides package rules.
37
- `DataAppStyle` checks public inline custom-property names.
38
-
39
- `--atbl-control-text-size` controls editable text, including compact search fields,
40
- date segments, and annotation editors. It defaults to the body text size.
41
- Package controls and custom controls with `data-atbl-control="text"` enforce a
42
- 16px minimum on narrow or touch viewports to prevent browser focus zoom. Keep
43
- that minimum when adding app-owned input styles.
44
-
45
- When overriding `--atbl-accent` directly, also choose `--atbl-on-accent` with
46
- sufficient contrast. Prefer appearance configuration for brand and chart colors.
24
+ Type inline token overrides with `DataAppStyle`. Give optional tokens a `var()`
25
+ fallback in app CSS. Use `:root` for shared theme overrides, including menus and overlays.
26
+ Prefer `app.appearance` for brand and chart colors. When overriding accent tokens,
27
+ choose a contrasting foreground too. Keep text inputs at least 16px on mobile.
47
28
 
48
29
  ## Native controls
49
30
 
@@ -55,8 +36,6 @@ Use package controls when possible. For a custom native control:
55
36
  </button>
56
37
  ```
57
38
 
58
- These hooks provide cursor and focus styling; keep native semantics, accessible
59
- names, disabled state, and keyboard behavior. `DataAppStyleHooks` checks hook
60
- values. Use `default` for tooltip targets that only reveal information on hover
61
- or tap, and `action` for controls that perform an action. Use `inset` focus inside
62
- clipped surfaces and `group` when a wrapper owns an input's outline. See [UI quality](ui-quality.md) for rendered verification.
39
+ These hooks provide cursor and focus styling; keep accessible names, disabled
40
+ state, and keyboard behavior. See
41
+ [UI quality](ui-quality.md) for rendered verification.
package/docs/ui.md CHANGED
@@ -10,10 +10,14 @@ 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
+ Widget titles use the available header width and wrap when needed. Supplying
14
+ `status` reserves space for refresh and retry feedback, including while idle.
15
+
13
16
  Direct `<DateRangePicker>`, `<DimensionPicker>`, and `useAppVariables()` support
14
17
  custom control ownership. The caller supplies values and change handlers.
15
18
  Custom tables use `<DataTable>` and its cell helpers; controls and overlays
16
19
  include `<SearchField>`, `<ChoicePicker>`, `<Tabs>`, `<Sheet>`, and `<HelpPopover>`.
20
+ Horizontal `<TabList>` content scrolls with gradient cues at overflowing edges.
17
21
 
18
22
  Standalone `<AboutData>`, glossary components, and `<PresentStory>` support
19
23
  custom inspection and presentation. Supply registered context and evidence, and
@@ -100,6 +104,26 @@ the samples. Pie slices represent mutually exclusive parts of one total; shares
100
104
  use the sum of supplied items, so include Other when showing a subset of the
101
105
  whole. Scatter points represent independent X/Y observations.
102
106
 
107
+ Use `useSvgId()` for stable IDs when composing custom SVG definitions.
108
+
109
+ ### Product analytics charts
110
+
111
+ Use `<FunnelChart>`, `<RetentionChart>`, and `<JourneyChart>` from `/react/ui`
112
+ inside `<VisualizationWidget>`. Derive inputs from the displayed rows; the
113
+ binding owns loading, evidence, CSV, and story content. The query owns counting,
114
+ conversion windows, and cohort definitions; these components visualize results.
115
+
116
+ - `<FunnelChart>`: ordered steps and aligned, nonincreasing counts per population.
117
+ - `<RetentionChart>`: numeric offsets, fractional rates (`0.25`, not `25`), retained
118
+ counts, and cohort size. Distinguish unobserved (`null`), observed zero, and
119
+ observed but still accumulating (`incomplete`) periods.
120
+ - `<JourneyChart>`: full ordered paths with counts and outcomes; preserve repeated
121
+ events and mark cut-off paths as `truncated`.
122
+
123
+ See the [complete component examples](https://github.com/altertable-ai/data-app/blob/main/dev/fixtures/gallery-basics.tsx)
124
+ for input shapes and composition. Read the exported types and JSDoc for exact
125
+ constraints before adapting displayed rows.
126
+
103
127
  ### Composed charts
104
128
 
105
129
  Use `<ComposedChart>` from `/react/ui` for multiple series or mixed marks inside
@@ -134,16 +158,16 @@ its columns aligned with the displayed measures.
134
158
 
135
159
  ### Legends
136
160
 
137
- Include `<ComposedChart.Legend />` to derive labels and markers from the series;
161
+ Include `<ComposedChart.Legend />` to derive labels and colored square markers from the series;
138
162
  omit it when no legend is needed. For any chart, compose `<ChartLegend>` with
139
163
  `<ChartLegend.Item>`, `<ChartLegend.Marker>`, and `<ChartLegend.Label>` using the
140
- same names and colors as the plot.
164
+ same names and colors as the plot. Square markers are
165
+ shared with chart tooltips and funnel summaries. Pass `kind="square"` explicitly
166
+ when composing a marker.
141
167
  `<PieChart>` includes a legend by default; `showLegend={false}` omits it.
142
168
 
143
- Legends align cells in a container-responsive grid, truncate labels, and reserve
144
- an overflow cell for “+X more.” Use `maxVisibleItems` to choose the limit or
145
- `layout="vertical"` for a list. Legends describe series; authored toggles or a
146
- composed legend's `onClick` leave series visibility to the app.
169
+ Legends describe series; authored toggles or a composed legend's `onClick`
170
+ leave series visibility to the app.
147
171
 
148
172
  ## Filter controls
149
173
 
@@ -182,15 +206,12 @@ and emit only valid intervals. Numeric input and compact selects respect the
182
206
  shared mobile text-size minimum.
183
207
 
184
208
  Use `<FilterBar>` to arrange predicates and `<VariableBar>` for mixed app
185
- parameters. Each filter shows its current value; categorical single selection includes All.
186
- `<FilterActions>` provides one Clear icon with a tooltip, plus optional paired
187
- Apply/Cancel actions for app-owned drafts. The caller owns those actions; the
188
- components do not infer query state.
209
+ parameters. Use `<FilterActions>` for Clear or paired Apply/Cancel actions on
210
+ app-owned drafts; provide the handlers for your applied state.
189
211
 
190
212
  `<NumberFilterPicker>` composes numeric fields inside a dedicated popover. Edits
191
213
  remain local until Apply; Cancel and dismissal discard them. Use `<NumberField>`
192
214
  and `<NumberRangeField>` as inline input primitives when composing forms.
193
215
 
194
216
  Use `<Button variant="primary">` for the main committing action, such as Apply.
195
- Primary buttons use the theme foreground as their fill and the theme background
196
- for contrasting text. Use outline and ghost buttons for secondary actions.
217
+ Use outline and ghost buttons for secondary actions.
package/docs/variables.md CHANGED
@@ -9,6 +9,9 @@ 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
16
  `dimensionFilter()` from `/contract` requires exactly one option source: fixed `options` or a `facet`.
14
17
  Use `defineFacetFilter()` to bind a facet operation and its typed input. `<DimensionPicker>` offers missing values separately and keeps selected values
@@ -17,9 +20,89 @@ available when they have zero matches.
17
20
  ## Declare controls once
18
21
 
19
22
  Use `searchVariable()`, `choiceVariable()`, and `dateRangeVariable()` in a view's
20
- `variables`. `<DataApp view={view}>` generates their controls and keeps values in the URL.
23
+ `variables`. `<DataApp view={view}>` generates search, filters, and display options
24
+ and keeps their values in the URL.
25
+ Set `showSearch={false}` or `showFilters={false}` on `<DataApp>` to hide the
26
+ corresponding region while preserving its values; `showFilters` includes display options.
27
+
21
28
  Keep local search out of the operation input when it only filters loaded rows.
22
29
 
30
+ ### Search suggestions
31
+
32
+ Declaring dataset `suggestions` enables autocomplete automatically. Use it when
33
+ record titles are useful query completions; omit it for aggregate datasets or when
34
+ completion would not help. No additional enabling prop is needed.
35
+
36
+ The app-owned `customers` operation accepts `{ q: string }` and returns `{ rows }`.
37
+ With your typed `client` and registered `dataContext`, connect the query to its
38
+ records and widgets:
39
+
40
+ ```tsx
41
+ const view = createDataHooks(client).defineDataView({
42
+ dataContext,
43
+ operation: 'customers',
44
+ variables: {
45
+ search: searchVariable({ key: 'q', label: 'Search customers' }),
46
+ },
47
+ input: ({ search }) => ({ q: search }),
48
+ describeInput: ({ q }) => (q ? `Customers matching ${q}` : 'All customers'),
49
+ isEmpty: () => false,
50
+ emptyFallback: { title: 'No customers' },
51
+ });
52
+ const customers = view.dataset({
53
+ name: 'Customers',
54
+ select: data => data.rows,
55
+ rowKey: row => row.id,
56
+ columns: { name: { value: row => row.name } },
57
+ evidence: { id: 'customers', queryNames: ['customers'] },
58
+ suggestions: {
59
+ title: row => row.name,
60
+ description: row => row.country,
61
+ },
62
+ });
63
+ const content = view.content(source => (
64
+ <TableWidget dataset={customers} source={source} />
65
+ ));
66
+
67
+ <DataApp view={view} datasets={[customers]} story={story}>
68
+ <DataSection content={content} />
69
+ </DataApp>;
70
+ ```
71
+
72
+ The first `searchVariable()` in declaration order is the primary search: it owns
73
+ autocomplete and combines supplied datasets that declare suggestions. Typing
74
+ updates the page and suggestions from the same displayed result. Capped or
75
+ paginated sources offer suggestions only for supplied rows. Title matches rank
76
+ ahead of description matches; the five suggestion slots are shared across datasets. Selection completes the query with
77
+ the title; `suggestions.onSelect: row => openCustomer(row.id)` overrides completion
78
+ with an app action. `showSearchSuggestions` defaults to true; set it to false to
79
+ suppress autocomplete for a particular app.
80
+
81
+ ### Organize controls by intent
82
+
83
+ Declare controls in priority order for the user's task. Keep useful scope filters
84
+ visible and set `presentation.prominence: 'secondary'` for less frequent ones in
85
+ the Filters sheet. Active secondary filters remain available for direct editing.
86
+ Choose useful defaults rather than exposing every field; declare each label once.
87
+
88
+ Set `presentation.group: 'display'` for ordering or presentation choices. These
89
+ appear separately from scope filters. Search remains separate from both.
90
+
91
+ ```ts
92
+ const active = booleanFilter({
93
+ key: 'active',
94
+ label: 'Active account',
95
+ presentation: { prominence: 'secondary' },
96
+ });
97
+ const sort = choiceVariable({
98
+ key: 'sort',
99
+ label: 'Sort by',
100
+ options: [{ id: 'name', label: 'Customer name' }],
101
+ defaultValue: 'name',
102
+ presentation: { group: 'display' },
103
+ });
104
+ ```
105
+
23
106
  The [date range contract](contract.md#shared-date-ranges) owns source coverage,
24
107
  maximum range, time zone, and comparison rules. `defineTimeView()` is the compact
25
108
  path for a view whose primary input is a period. Use `defineDataView()` for fixed
@@ -73,7 +156,7 @@ const region = dimensionFilter({
73
156
  ```
74
157
 
75
158
  For query-backed choices use the hooks factory's `defineFacetFilter()`. The
76
- facet operation returns parsed dimension options. Its input mapper reads current
159
+ facet operation returns parsed dimension options. Its input mapper uses current
77
160
  resolved variables, including other filters:
78
161
 
79
162
  ```ts
@@ -98,10 +181,8 @@ A dimension without an explicit selection represents all members.
98
181
  Map parsed selections to the query's declared parameters; do not construct SQL
99
182
  from filter values. Choose selection modes supported by the registered query.
100
183
 
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
184
+ Choose `selectionMode: 'single'` when one value replaces another and
185
+ `selectionMode: 'multiple'` for independent values. `All` is an explicit choice for a single-value
105
186
  filter and the meaning of an empty selection for a multiple-value filter.
106
187
 
107
188
  ## Fixed choices
@@ -126,11 +207,6 @@ const variables = {
126
207
  };
127
208
  ```
128
209
 
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
210
  ## Numeric and boolean predicates
135
211
 
136
212
  Import `numberFilter()` and `booleanFilter()` from `/contract` and put their
@@ -159,13 +235,14 @@ Set `allowExclusion: true` on `dimensionFilter()` to support
159
235
  alongside selected members. Enable exclusion only when the registered query supports
160
236
  it, including the intended behavior for missing values.
161
237
 
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.
238
+ Clear removes predicate filters while preserving search and display settings.
239
+ Clear search separately in its field.
164
240
  `resetAll()` restores all
165
241
  configured variable defaults, including fixed choices and periods. Nonempty
166
242
  default filters can therefore be active immediately after Reset.
167
243
 
168
- Direct `useAppVariables()` callers can use `clearAll()` and `resetAll()` for one
169
- atomic history update. `<FilterActions>` also supports app-owned draft state
244
+ Direct `useAppVariables()` callers can use `clearAll()` and `resetAll()`. `<FilterActions>` also supports app-owned draft state
170
245
  with paired Apply/Cancel handlers; derive queries and visible controls from applied
171
246
  values while a draft is being edited.
247
+
248
+ Filters apply immediately; use app-owned drafts only when the task needs Apply/Cancel.
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 dimension, numeric, and boolean selections in required operation input fields
39
+ with the same names 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,11 @@ 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.
94
-
95
- ## Request ownership
96
-
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.
101
-
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.
107
-
108
- Keep related datasets in one view so export and story share a coherent snapshot.
109
-
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 |
118
-
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.
121
-
122
- `<DataApp>` owns request execution, refresh, and cancellation. Keep raw request
123
- state out of app code.
99
+ A measured zero is valid data. Define `isEmpty` for the analysis and provide
100
+ useful `emptyFallback` copy.
package/docs/widgets.md CHANGED
@@ -18,33 +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
- | How did one metric change between periods? | `<Comparison>` | Use the metric reading and its displayed comparison period. |
42
- | What are the exact values or row details? | `<TableWidget>` | Use a bound table for lookup, search, and precise comparisons. |
43
-
44
- 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;
45
47
  use a pie for a simple composition question. Prefer a line when the trend is
46
48
  enough; use area when the fill adds meaning. Keep exact values available in a
47
- 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,
48
50
  use the [composed chart primitives](ui.md#composed-charts) within the same bound
49
51
  visualization workflow.
50
52
 
@@ -96,13 +98,27 @@ row-key callbacks explicitly; row keys must be stable and unique.
96
98
  Metric comparisons require a
97
99
  view date binding. `read()` returns a loading-aware value for custom prose.
98
100
  Pass the binding and `source={snapshot}` to reuse a widget in a story. Use the
99
- source supplied by that binding's own view; reconstructed or foreign sources
100
- are rejected before selection.
101
- Selectors do not run during loading. Table search, pagination, descriptions, and
101
+ source supplied by that binding's own view. Table search, pagination, descriptions, and
102
102
  actions remain local choices. For custom cells, use `format: row => ...`; CSV
103
103
  still uses the raw `value` accessor. Datasets default to “No results”; supply
104
104
  `emptyFallback` for specific copy. See [export](stories-and-export.md).
105
105
 
106
+ `<TableWidget>` automatically shows the count of matching supplied rows. Use
107
+ `count` for a server total; other widgets can receive a count from the displayed result.
108
+
109
+ Provide useful `emptyFallback` and `noMatchesFallback` copy. Local search offers
110
+ Clear search automatically. For server-filtered tables, supply `onClearFilters`
111
+ only while filters affecting that dataset are active, preserving unrelated filters,
112
+ search, and display settings.
113
+
114
+ ```tsx
115
+ <TableWidget
116
+ dataset={customers}
117
+ source={source}
118
+ onClearFilters={hasActiveCustomerFilters ? clearCustomerFilters : undefined}
119
+ />
120
+ ```
121
+
106
122
  ## Narrative text
107
123
 
108
124
  Use `<TextContent>` for prose within a page or custom layout, and `<TextWidget>`
@@ -110,7 +126,7 @@ when the explanation belongs in a titled panel alongside other widgets.
110
126
 
111
127
  Give text a purpose: frame the question, explain how to interpret a comparison,
112
128
  qualify a finding, or suggest what to explore next. Choose the content for the
113
- reader's question.
129
+ user's question.
114
130
 
115
131
  For data-dependent text, pass `metric` or `dataset` and `source` to `<TextWidget>`.
116
132
  It derives its title and evidence. A metric formats its current value by default;
@@ -120,7 +136,6 @@ including an empty selection, so they can explain zero activity.
120
136
  Use `<DataValue metric={total} source={result} />` for a formatted value inside
121
137
  static prose, or pass a dataset and row renderer. Its default loading fallback is
122
138
  an inline skeleton. Use `<DataValue scope={result.scope} />` for a scope label.
123
- All selectors use the displayed source; loading selectors do not run.
124
139
  Use `<TextContent>` for static instructions; local filters should feed the same
125
140
  filtered data to the text and its related visualization.
126
141
 
package/docs/worker.md CHANGED
@@ -28,7 +28,8 @@ and these string bindings:
28
28
  | `PARENT_ORIGINS` | Space-separated trusted HTTP(S) origins; first exact origin is the default | `https://app.example.com https://*.preview.example.com` |
29
29
 
30
30
  The Worker serves only `/` on a single preview label under `DOMAIN_NAME` matching
31
- `/^(?=.{1,63}$)[a-z0-9]+(?:-[a-z0-9]+)+-app-[1-9][0-9]*$/`. Other hosts and paths
31
+ `/^(?=.{1,63}$)[a-z0-9]+(?:-+[a-z0-9]+)+$/`
32
+ (any hyphenated lowercase DNS label; the host keeps each app's label unique). Other hosts and paths
32
33
  return 404. GET returns HTML; HEAD returns the same headers with no body. Other
33
34
  methods return 405 with `Allow: GET, HEAD`.
34
35
 
@@ -65,7 +65,6 @@ function parseSampleCounts(
65
65
  const operations = {
66
66
  sampleCountsByGroup: dataApp.defineOperation({
67
67
  input: parseSampleCountFilter,
68
- output: parseSampleCounts,
69
68
  checks: [
70
69
  { groupName: '' },
71
70
  { groupName: 'Alpha' },
@@ -0,0 +1 @@
1
+ 24.18.0
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "ignorePatterns": ["dist/**", "bun.lock"]
4
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": ["eslint", "typescript", "unicorn", "oxc", "react", "jsx-a11y"],
4
+ "categories": {
5
+ "correctness": "error"
6
+ },
7
+ "options": {
8
+ "typeAware": true
9
+ },
10
+ "rules": {
11
+ "react/unsupported-syntax": "error",
12
+ "eslint/no-restricted-imports": [
13
+ "error",
14
+ {
15
+ "patterns": [
16
+ {
17
+ "regex": "^\\.\\.?/",
18
+ "message": "Use #app/* or #config for app-owned files."
19
+ }
20
+ ]
21
+ }
22
+ ],
23
+ "func-style": [
24
+ "error",
25
+ "declaration",
26
+ {
27
+ "overrides": {
28
+ "namedExports": "declaration"
29
+ }
30
+ }
31
+ ]
32
+ }
33
+ }
@@ -0,0 +1,22 @@
1
+ # Build this local data app
2
+
3
+ Read [AGENTS.md](https://github.com/altertable-ai/data-app/blob/main/AGENTS.md) first, then use the app files below.
4
+
5
+ | Task | App-owned files |
6
+ | ---------------------------------------- | -------------------------------------------------------- |
7
+ | Define queries and inputs | `app.ts`, `src/operations.ts`, optional shared contracts |
8
+ | Build the exploration, export, and story | `src/App.tsx` |
9
+ | Bind definitions and source evidence | `src/data-context.ts` |
10
+ | Change identity and appearance | `app.ts` |
11
+ | Inject styles and mount React | `src/main.tsx` |
12
+ | Configure local serving | `src/server.ts` |
13
+
14
+ See [README.md](README.md) for setup and checks.
15
+
16
+ ## Focused guidance
17
+
18
+ Read the installed package's `AGENTS.md` and `docs/app-authoring.md` before
19
+ changing the app. Follow their task routes for views, variables, widgets, evidence,
20
+ and stories/export. Prefer generated controls and bound readings; keep static
21
+ context visible during requests. Update this app's instructions when a reusable
22
+ app-specific convention changes. Package internals remain dependencies.
@@ -0,0 +1,54 @@
1
+ # Local data app starter
2
+
3
+ Use this starter with the [local authoring guide](https://github.com/altertable-ai/data-app/blob/main/docs/local-data-apps.md).
4
+ See [AGENTS.md](AGENTS.md) for app-owned files.
5
+
6
+ A Bun and React app that imports the public `@altertable/data-app` package.
7
+ It starts with a lakehouse connectivity check. Replace that check with bounded
8
+ operations and views built from inspected data before sharing an analysis.
9
+
10
+ ## Run from this repository
11
+
12
+ Use the Bun and Node versions in `.bun-version` and `.node-version`.
13
+ From the repository root:
14
+
15
+ ```fish
16
+ bun install --frozen-lockfile
17
+ bun run build
18
+ bun install --frozen-lockfile
19
+ cd examples/starter-local-data-app
20
+ bun run dev
21
+ ```
22
+
23
+ The second install refreshes the local file dependency with the built exports.
24
+
25
+ Open <http://127.0.0.1:25837>. Missing credentials show the connection error state;
26
+ the page still runs. Set server-only credentials before starting the server:
27
+
28
+ ```fish
29
+ set -gx ALTERTABLE_LAKEHOUSE_USERNAME your-username
30
+ read --silent --prompt-str 'Lakehouse password: ' ALTERTABLE_LAKEHOUSE_PASSWORD
31
+ set -gx ALTERTABLE_LAKEHOUSE_PASSWORD $ALTERTABLE_LAKEHOUSE_PASSWORD
32
+ bun run dev
33
+ ```
34
+
35
+ Alternatively, supply `ALTERTABLE_DATA_PROXY_URL` and
36
+ `ALTERTABLE_DATA_PROXY_TOKEN` for an existing CLI proxy. These values must stay
37
+ on the server. This local adapter does not authorize hosted viewers.
38
+
39
+ ## Make it your app
40
+
41
+ This checkout uses `file:../..` to exercise the built package before publication.
42
+ When copying the starter elsewhere, replace that dependency with the published
43
+ package using `bun add @altertable/data-app`, `npm install @altertable/data-app`,
44
+ or `pnpm add @altertable/data-app`, then regenerate your lockfile.
45
+
46
+ ```fish
47
+ bun run check
48
+ ```
49
+
50
+ Edit the `defineDataApp()` declaration in `app.ts` for identity, appearance,
51
+ and queries.
52
+
53
+ `bun run build` typechecks the app, then bundles the browser page into `dist/`. That browser artifact
54
+ still needs an authorized `/api/data` backend when hosted.
@@ -0,0 +1,22 @@
1
+ import { defineDataApp } from "@altertable/data-app";
2
+
3
+ export const dataApp = defineDataApp({
4
+ title: "Getting started",
5
+ description: "Check your lakehouse connection, then build an exploration.",
6
+ scope: {
7
+ organization: "Your organization",
8
+ environment: "your environment",
9
+ },
10
+ appearance: {
11
+ theme: "light",
12
+ baseColor: "neutral",
13
+ density: "comfortable",
14
+ cornerRadius: "medium",
15
+ elevation: "subtle",
16
+ typography: {
17
+ body: "system",
18
+ heading: "system",
19
+ },
20
+ },
21
+ queries: { connection: { statement: "SELECT 1 AS connection_check", params: {} } },
22
+ });