@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/contract.md CHANGED
@@ -8,17 +8,12 @@ import operation types using `import type`.
8
8
 
9
9
  ## Execute named queries
10
10
 
11
- Declare SQL once with `defineDataApp()` to preserve exact query and parameter
12
- names. Use stable `lowerCamelCase` IDs describing the result, such as `products`,
13
- `productsByCategory`, or `dailyRevenue`. Use plural names for row lists; keep parameter
14
- values in `params`. Every query must include `params`; use `{}` when it declares no
15
- parameters.
16
- The app owns an immutable registry snapshot. Define operations with
17
- `dataApp.defineOperation()`.
11
+ Declare queries with `defineDataApp()` and operations with `dataApp.defineOperation()`.
12
+ Use descriptive `lowerCamelCase` query names. Declare parameter types in `params`
13
+ (use `{}` for none) and returned aliases in `projections`.
18
14
 
19
15
  ```ts
20
16
  import { defineDataApp } from '@altertable/data-app';
21
- import { rowsAsRecords } from '@altertable/data-app/contract';
22
17
 
23
18
  const dataApp = defineDataApp({
24
19
  title: 'Products',
@@ -27,34 +22,58 @@ const dataApp = defineDataApp({
27
22
  appearance: { theme: 'system' },
28
23
  queries: {
29
24
  products: {
30
- statement: 'SELECT * FROM products WHERE org_id = $orgId LIMIT $limit',
31
- params: { orgId: {}, limit: { defaultValue: 10 } },
25
+ statement:
26
+ 'SELECT name, unit_price AS "unitPrice" FROM products WHERE org_id = $orgId LIMIT $limit',
27
+ params: {
28
+ orgId: { type: 'string' },
29
+ limit: { type: 'number', defaultValue: 10 },
30
+ },
31
+ projections: {
32
+ name: { type: 'string' },
33
+ unitPrice: { type: 'number', nullable: true },
34
+ },
32
35
  },
33
36
  },
34
37
  });
35
38
 
36
39
  const products = dataApp.defineOperation({
37
40
  input: parseProductInput,
38
- output: parseProducts,
39
41
  checks: [{}],
40
42
  policy: { maxQueryRows: 100, maxDurationMs: 15000 },
41
43
  async run({ query }, input) {
42
44
  const result = await query('products', input);
43
- return rowsAsRecords(result, ['org_id']);
45
+ return result.rows;
44
46
  },
45
47
  });
46
48
  ```
47
49
 
48
- `parseProductInput()` and `parseProducts()` are app-owned example functions, not
49
- package exports. Validate
50
- filter values in the input parser. `{}` declares a required parameter; `{ defaultValue }` supplies
51
- a fallback. `query(name, params, { limit })` executes only registered queries and
52
- inherits the operation's row limit and cancellation signal.
50
+ `parseProductInput()` is app-owned. Validate inputs there and business rules in
51
+ `run()`. Derive operation data from `query()` rows; clients and views infer the
52
+ returned type. Handle empty results. HTTP results must be JSON-serializable.
53
+ Include representative valid inputs in `checks`.
53
54
 
54
- SQL and resolved parameter values pass unchanged to the backend. Results include
55
- query evidence; use `products.queryNames` with `createDataContext()` to bind it.
56
- For HTTP apps, authorization can supply protected `queryParams`, such as `orgId`.
57
- The host/backend enforces data access and limits.
55
+ Host `queryParams` supplies protected parameters; callers cannot override them.
56
+ Other values come from `query()` arguments or `defaultValue`. Missing values are
57
+ checked before execution. `query(name, params, { limit })` inherits the operation's
58
+ row limit and cancellation signal.
59
+
60
+ ### Declare query projections
61
+
62
+ Inspect each query and declare every returned alias with `{ type, nullable? }`.
63
+ Result keys keep the exact SQL names; alias columns in SQL to change casing, as
64
+ with `"unitPrice"` above.
65
+ Determine nullability from the schema and SQL, even when sampled rows contain no
66
+ nulls. Update projections when changing SQL.
67
+
68
+ `query()` converts result cells to the declared types before `run()` uses them.
69
+ Numbers that cannot be converted become `"##ERROR##"`; booleans use JavaScript
70
+ truthiness. Nulls pass through unless `nullable: false`. Parameters are validated
71
+ without conversion. For exact numeric precision, return SQL text
72
+ and declare `string`.
73
+
74
+ Results include query evidence; use `products.queryNames` with `createDataContext()`
75
+ to bind it. The host/backend enforces data access and limits; see
76
+ [server authorization](server.md).
58
77
 
59
78
  ## Shared date ranges
60
79
 
@@ -73,8 +92,8 @@ export const calendar = defineDateRangeContract({
73
92
  });
74
93
  ```
75
94
 
76
- `parseEmptyInput()`, `parseTrue()`, `parseCount()`, and `parseDateRangeInput()` validate
77
- common inputs and results. `connectionCheck(dataApp.queries)` runs the registered `connection` query. A successful connectivity check confirms access; it is not an
95
+ `parseEmptyInput()`, `parseCount()`, and `parseDateRangeInput()` validate common inputs
96
+ and query values. `connectionCheck(dataApp.queries)` runs the registered `connection` query. A successful connectivity check confirms access; it is not an
78
97
  analysis result.
79
98
 
80
99
  See [server authorization](server.md) and [React views](react.md) for the two
@@ -112,9 +131,9 @@ an intentional public code, message, and optional request ID; other handler
112
131
  errors are replaced with a generic failure.
113
132
 
114
133
  `defineDataQueryRoute(operationContracts)` validates the selected operation's
115
- input and output and preserves its response evidence. It infers the result type
116
- from the selected operation when used with `createMessageClient()`. Share input and
117
- output parsers, not operation implementations containing SQL or credentials.
134
+ input and preserves its response evidence. It infers the result type from the
135
+ selected operation's `run` when used with `createMessageClient()`. Share input
136
+ parsers and operation types, not operation implementations containing SQL or credentials.
118
137
  `dataAppRoutes` supplies generic `data:query` and `navigation:update` contracts;
119
138
  generic hosts must delegate operation validation and authorization to their
120
139
  server. Request handlers receive `{ signal }` for cancellation.
@@ -2,6 +2,8 @@
2
2
 
3
3
  Set `dataContext: context` in each view for source descriptions, glossary, and
4
4
  permitted query evidence. App inspection and the view's sections use that context.
5
+ Keep glossary query references scoped to that view's executed queries. Detail
6
+ views declare their own context when their queries differ.
5
7
  Render registered identifiers where `<DataIdentifier>` is used.
6
8
 
7
9
  Physical source identifiers name inspected tables and columns. Glossary entries
package/docs/embed.md CHANGED
@@ -100,9 +100,17 @@ client acknowledged initialization or a bundle script finished evaluation. It
100
100
  does not mean asynchronous data queries finished. Script errors report `failed`.
101
101
  The source bridge's `startupTimeoutMs` defaults to 30 seconds.
102
102
 
103
- `onDiagnostic` receives only message `direction` and `type`, never tokens or
104
- payloads. Routed handlers must authorize every data request. Message validation
105
- and iframe isolation do not grant access to data or execute SQL.
103
+ `onDiagnostic` receives delivery metadata, never tokens or payloads: `direction`
104
+ (`send`, `receive`, or `drop`), message `type`, and, when present, the request
105
+ `id`, `route`, query `operation`, and error `code`, `message`, and `requestId`.
106
+ Results and errors include `durationMs`, the host handling time. `drop` events
107
+ report why a message from the connected iframe was ignored, such as a stale
108
+ session or token; messages from other windows are not reported.
109
+
110
+ When a `logger` is set, the iframe also forwards its view of the bridge: messages
111
+ it sends, receives, and ignores, local timeouts, reconnect resets, and the cause
112
+ of a `failed` status. Routed handlers must authorize every data request. Message
113
+ validation and iframe isolation do not grant access to data or execute SQL.
106
114
 
107
115
  ## SQL query route
108
116
 
@@ -13,6 +13,9 @@ Import formatting helpers from `@altertable/data-app/format`.
13
13
  | `formatCount()` | Nonnegative integer counts, optionally compact |
14
14
  | `formatPercent()` | Ratios represented as a fraction, such as 0.12 for 12% |
15
15
  | `formatMetric()` | A metric definition's count, ratio, or currency format |
16
+ | `formatDate()` | Calendar dates without time-zone shifts |
17
+ | `formatDateTime()` | Event timestamps in the reporting time zone |
18
+ | `formatTime()` | Intraday chart labels |
16
19
  | `formatDateRange()` | Inclusive calendar ranges |
17
20
  | `pluralize()` | Count-dependent labels |
18
21
 
@@ -37,6 +40,32 @@ Import `chartColor()` from `/react` to select colors from the configured palette
37
40
  `<DateTimeTooltip>` expose readable timestamps with exact-date details.
38
41
  `<DataTableTimestamp>` and `<DataTableShare>` format custom table cells.
39
42
 
43
+ ## Display dates consistently
44
+
45
+ Declare date meaning on dataset columns so tables use readable values and CSV
46
+ keeps the originals:
47
+
48
+ ```ts
49
+ columns: {
50
+ day: { value: row => row.day, format: { kind: 'date' } },
51
+ observed: {
52
+ value: row => row.observed,
53
+ format: { kind: 'dateTime', precision: 'second' },
54
+ },
55
+ }
56
+ ```
57
+
58
+ Calendar dates use `YYYY-MM-DD`. Instants accept epoch milliseconds or timestamp
59
+ strings; `<DateDisplay>` also accepts `Date`. Timestamp strings require `Z` or an explicit
60
+ offset; convert database-local timestamps in the operation using their known
61
+ source zone. Ambiguous or invalid values display as missing.
62
+
63
+ Use `<DateDisplay>` for prose and `useDateFormatting()` with format helpers for
64
+ custom chart labels. Defaults are `en-US` and UTC; configure app-wide
65
+ `dateFormatting: { locale, timeZone }` when appropriate. A time view supplies its
66
+ reporting zone, and an explicit field zone overrides it. Keep seconds when event
67
+ ordering matters; exact-time details remain available on timestamps.
68
+
40
69
  ## Configure identity and appearance
41
70
 
42
71
  ```ts
@@ -48,7 +77,7 @@ const dataApp = defineDataApp({
48
77
  scope: { organization: 'Acme', environment: 'Production' },
49
78
  appearance: {
50
79
  theme: 'system',
51
- accentColor: '#405d47',
80
+ baseColor: 'neutral',
52
81
  density: 'comfortable',
53
82
  },
54
83
  queries: {},
@@ -56,13 +85,15 @@ const dataApp = defineDataApp({
56
85
  ```
57
86
 
58
87
  Scope labels describe the configured connection; they do not grant access.
59
- `dataAppTitle()` produces the scoped document title used by `mountDataApp()`.
60
88
 
61
89
  Title and description explain the app and can be revised when regenerating it.
62
90
  Omit appearance to use the standard defaults.
63
91
 
64
- Appearance controls the brand palette, typography, density, corner radius, and
65
- elevation. Those settings apply consistently to the app instead of tuning each
66
- widget. Theme preference is reader-owned in standalone apps. A trusted parent's
92
+ The default UI is neutral in light and dark themes. Use `baseColor` for the base
93
+ palette and `accentColor` with optional `darkAccentColor` for brand emphasis.
94
+ Configure chart colors separately with `chartColors`; preserve semantic status
95
+ colors for favorable and unfavorable outcomes.
96
+
97
+ Configure appearance once for the app. Theme preference is user-owned in standalone apps. A trusted parent's
67
98
  resolved theme takes precedence and hides local theme controls; see
68
99
  [parent presentation](embed.md#parent-presentation).
package/docs/layout.md CHANGED
@@ -2,20 +2,17 @@
2
2
 
3
3
  The shell owns page width, outer gutters, and header/body spacing. Use `<Stack>`
4
4
  for sections, `<Grid>` for peer widgets, and `<GridItem>` for spans. Use
5
- `<TextContent>` for prose. Widgets own their internal padding; their parents own
5
+ `<SectionHeading>` to name widget groups and `<TextContent>` for prose. Widgets own their internal padding; their parents own
6
6
  external spacing. Keep widget customization inside the widget so its parent can maintain consistent
7
7
  spacing between sections and cards.
8
8
 
9
- By default, section and widget gaps use `--atbl-layout-gap`, with density configured once
10
- in `app.appearance`. The package owns wrapping and span collapse based
11
- on the available container width and configured gap. Custom length values for
12
- `--atbl-layout-gap`, `--atbl-space-sm`, and `--atbl-space-md` also drive span
13
- collapse; a two-column span activates only when two minimum-width tracks fit.
9
+ Configure density once in `app.appearance`. `<Grid>` wraps to fit its container;
10
+ spans collapse when there is not enough space.
14
11
 
15
12
  ```tsx
16
13
  <Stack>
14
+ <SectionHeading>Activity</SectionHeading>
17
15
  <TextContent>
18
- <h2>Activity</h2>
19
16
  <p>Explore the sources behind this finding.</p>
20
17
  </TextContent>
21
18
  <Grid columns={3}>
@@ -25,9 +22,35 @@ collapse; a two-column span activates only when two minimum-width tracks fit.
25
22
  </Stack>
26
23
  ```
27
24
 
25
+ Set widget `headingLevel={3}` beneath a section heading; visual styling stays
26
+ consistent across widget types.
27
+
28
+ Use `<DataApp footer={...}>` for an optional source, coverage, or methodology
29
+ note below the app content. The footer provides muted body text across the content
30
+ width and top spacing. Compose paragraphs, links, lists, and inline components such
31
+ as `<DataIdentifier>` or `<DateDisplay>` directly; no `<TextContent>` wrapper is
32
+ needed. Keep headings and data widgets in the body, and app controls in
33
+ `footerActions`. Keep static notes outside loading sections.
34
+
35
+ ```tsx
36
+ <DataApp
37
+ {...appProps}
38
+ footer={
39
+ <>
40
+ <p>
41
+ <strong>Coverage.</strong> Records include the last 90 days.
42
+ </p>
43
+ <p>Counts reflect current inventory, not an activity log.</p>
44
+ </>
45
+ }
46
+ >
47
+ <DataSection content={content} />
48
+ </DataApp>
49
+ ```
50
+
28
51
  ## Verify rendered layouts
29
52
 
30
- Check computed section/widget gaps, sibling alignment, outer gutters, and
53
+ Check spacing, alignment, outer gutters, and
31
54
  horizontal overflow at phone and desktop iframe widths. Check loading, empty,
32
55
  error, ready, and stale states. Loading placeholders should use the same grid as
33
56
  the ready content.
@@ -94,10 +94,10 @@ are mutually exclusive.
94
94
 
95
95
  ## Loading an embedded app
96
96
 
97
- Use `<DataAppSkeleton>` from `/react/ui` while the host builds or starts an app.
98
- Call `injectDataAppShellStyles()` from `/react/ui` before rendering the placeholder.
99
- The host owns when to show it and supplies any surrounding header or footer.
100
- `/react/embed` itself remains independent of UI components and styles.
97
+ The host owns loading and generation UI while an app starts. Use a neutral
98
+ status that does not imply a particular app layout. `/react/embed` remains
99
+ independent of UI components and styles. Once the app loads, its query and
100
+ widget loading states describe the content they replace.
101
101
 
102
102
  ## Parent-owned presentation
103
103
 
package/docs/react.md CHANGED
@@ -7,7 +7,7 @@ React 19.2 or newer and React DOM 19.2 or newer are peer dependencies.
7
7
 
8
8
  Use `mountDataApp({ app, component })` to mount into `#root`. When mounting
9
9
  through another framework, wrap the root in `<DataAppProvider app={app}>` from `/react/ui`.
10
- `<DataApp>` inherits identity and appearance from that root. Mounting sets the document title before React renders.
10
+ `<DataApp>` inherits identity and appearance from that root.
11
11
 
12
12
  ```tsx
13
13
  import { injectDataAppStyles, mountDataApp } from '@altertable/data-app/react';
@@ -27,3 +27,28 @@ Missing credentials fail the query. Keep these variables out of browser code.
27
27
  Local serving does not authenticate hosted viewers.
28
28
  Use [the portable server handler](server.md) with per-request authorization when
29
29
  hosting an app for other people.
30
+
31
+ ## Preview a single-file app
32
+
33
+ Import `serveAppFile()` from `@altertable/data-app/server/bun/preview` to preview
34
+ an app in the hosted sandbox. The caller supplies the server-only lakehouse.
35
+ The runtime owns bundling, imported-file watching, reloads, navigation, and exports.
36
+
37
+ ```ts
38
+ import { serveAppFile } from '@altertable/data-app/server/bun/preview';
39
+ import { localLakehouse } from '@altertable/data-app/server/bun';
40
+
41
+ const preview = await serveAppFile({
42
+ file: '/absolute/path/index.tsx',
43
+ lakehouse: localLakehouse(),
44
+ });
45
+ console.log(preview.url);
46
+ // When the launcher stops:
47
+ await preview.stop();
48
+ ```
49
+
50
+ The preview resolves `@altertable/data-app` and React from its own installation.
51
+ It binds to localhost and accepts SQL only from its own origin,
52
+ with a streaming limit of 100,000 UTF-8 bytes per query request. The caller
53
+ owns profile validation, dependency installation, and credentials. This entry requires Bun and adds no Bun installation or dependency
54
+ to browser consumers. Keep it separate from browser imports.
package/docs/server.md CHANGED
@@ -24,10 +24,10 @@ export const handleDataRequest = createDataHandler(
24
24
  The app supplies `authenticate()` and `lakehouseFor()`, then routes `/api/data/*`
25
25
  requests to the handler. Authorize every viewer and operation, and scope the
26
26
  returned lakehouse to the viewer's permitted data. Supply trusted registry
27
- parameters through `queryParams`; query callers cannot override these values. Origin and Fetch Metadata
27
+ parameters through `queryParams`; query callers cannot override them. Origin and Fetch Metadata
28
28
  checks reject cross-site browser requests; they do not authenticate viewers.
29
29
 
30
- The handler validates operation input and output, enforces query row and duration
30
+ The handler validates operation input, enforces query row and duration
31
31
  bounds, propagates cancellation, and returns query evidence and request IDs.
32
32
  Keep credentials and operation implementations on the server.
33
33
 
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,14 @@ 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.
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.
38
28
 
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.
29
+ Menus and selection dropdowns share `--atbl-dropdown-padding`,
30
+ `--atbl-dropdown-item-padding-block`, `--atbl-dropdown-item-padding-inline`, and
31
+ `--atbl-dropdown-item-gap`. Their default padding follows the control density.
47
32
 
48
33
  ## Native controls
49
34
 
@@ -55,8 +40,6 @@ Use package controls when possible. For a custom native control:
55
40
  </button>
56
41
  ```
57
42
 
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.
43
+ These hooks provide cursor and focus styling; keep accessible names, disabled
44
+ state, and keyboard behavior. See
45
+ [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
@@ -106,15 +110,20 @@ Use `useSvgId()` for stable IDs when composing custom SVG definitions.
106
110
 
107
111
  Use `<FunnelChart>`, `<RetentionChart>`, and `<JourneyChart>` from `/react/ui`
108
112
  inside `<VisualizationWidget>`. Derive inputs from the displayed rows; the
109
- binding owns loading, evidence, CSV, and story content. Types and JSDoc describe
110
- input constraints; the gallery includes complete examples.
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. Offset labels come from
120
+ supplied points; numeric spacing preserves elapsed distance.
121
+ - `<JourneyChart>`: full ordered paths with counts and outcomes; preserve repeated
122
+ events and mark cut-off paths as `truncated`.
111
123
 
112
- - `<FunnelChart>` compares ordered step counts across populations. Each series
113
- uses its first step as the baseline; hatching shows previous-step drop-off.
114
- - `<RetentionChart>` plots query-defined rates and retained counts by interval
115
- offset. Use `null` for unobserved periods; `incomplete` produces a dotted tail.
116
- - `<JourneyChart>` derives expandable branches and outcomes from full paths.
117
- Truncated paths stop at the last loaded event.
124
+ See the [complete component examples](https://github.com/altertable-ai/data-app/blob/main/dev/fixtures/gallery-basics.tsx)
125
+ for input shapes and composition. Read the exported types and JSDoc for exact
126
+ constraints before adapting displayed rows.
118
127
 
119
128
  ### Composed charts
120
129
 
@@ -143,6 +152,13 @@ primitives are also available.
143
152
  </VisualizationWidget>
144
153
  ```
145
154
 
155
+ For irregular time intervals, use `<ComposedChart.XAxis>` with ISO dates, zoned
156
+ ISO timestamps, or `Date` values; spacing follows elapsed time. Use `scale="utc"`
157
+ for epoch milliseconds, or `type="category"` to keep date-like labels categorical.
158
+ On UTC axes, supplied `ticks` and `tickFormatter` take precedence over automatic labels.
159
+ Preserve missing measures as `null` and choose `connectNulls` deliberately; do not
160
+ replace missing observations with zero.
161
+
146
162
  Label series and units clearly. See component JSDoc and the
147
163
  [Recharts API](https://recharts.github.io/en-US/api/ComposedChart/) for options.
148
164
  The dataset owns loading, empty results, evidence, CSV, and story content; keep
@@ -158,10 +174,8 @@ shared with chart tooltips and funnel summaries. Pass `kind="square"` explicitly
158
174
  when composing a marker.
159
175
  `<PieChart>` includes a legend by default; `showLegend={false}` omits it.
160
176
 
161
- Legends align cells in a container-responsive grid, truncate labels, and reserve
162
- an overflow cell for “+X more.” Use `maxVisibleItems` to choose the limit or
163
- `layout="vertical"` for a list. Legends describe series; authored toggles or a
164
- composed legend's `onClick` leave series visibility to the app.
177
+ Legends describe series; authored toggles or a composed legend's `onClick`
178
+ leave series visibility to the app.
165
179
 
166
180
  ## Filter controls
167
181
 
@@ -200,15 +214,15 @@ and emit only valid intervals. Numeric input and compact selects respect the
200
214
  shared mobile text-size minimum.
201
215
 
202
216
  Use `<FilterBar>` to arrange predicates and `<VariableBar>` for mixed app
203
- parameters. Each filter shows its current value; categorical single selection includes All.
204
- `<FilterActions>` provides one Clear icon with a tooltip, plus optional paired
205
- Apply/Cancel actions for app-owned drafts. The caller owns those actions; the
206
- components do not infer query state.
217
+ parameters. Use `<FilterActions>` for Clear or paired Apply/Cancel actions on
218
+ app-owned drafts; provide the handlers for your applied state.
207
219
 
208
220
  `<NumberFilterPicker>` composes numeric fields inside a dedicated popover. Edits
209
221
  remain local until Apply; Cancel and dismissal discard them. Use `<NumberField>`
210
222
  and `<NumberRangeField>` as inline input primitives when composing forms.
211
223
 
212
224
  Use `<Button variant="primary">` for the main committing action, such as Apply.
213
- Primary buttons use the theme foreground as their fill and the theme background
214
- for contrasting text. Use outline and ghost buttons for secondary actions.
225
+ Use outline and ghost buttons for secondary actions.
226
+ Use `<Button variant="inline">` for actions within text or table cells. It has no
227
+ control padding or background and underlines on hover. Keep button semantics for
228
+ opening a sheet; use links for navigation to a URL.