@altertable/data-app 0.68.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.
- package/AGENTS.md +6 -0
- package/CONTRIBUTING.md +27 -1
- package/README.md +18 -21
- package/THIRD_PARTY_NOTICES +18 -0
- package/dist/chunks/index-22d576sn.js +153 -0
- package/dist/chunks/index-22d576sn.js.map +11 -0
- package/dist/chunks/{index-ktmvs916.js → index-2sbp9h2b.js} +37 -21
- package/dist/chunks/index-2sbp9h2b.js.map +13 -0
- package/dist/chunks/{index-23dktynd.js → index-ap60vggk.js} +4 -4
- package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
- package/dist/chunks/index-cv36cyna.js.map +10 -0
- package/dist/chunks/{index-ag0cgnvq.js → index-k766wwwr.js} +13 -9
- package/dist/chunks/index-k766wwwr.js.map +13 -0
- package/dist/chunks/{index-mt93ff2b.js → index-kwnqycjt.js} +2 -2
- package/dist/chunks/index-kwnqycjt.js.map +10 -0
- package/dist/chunks/index-m0gbxtgp.js +355 -0
- package/dist/chunks/index-m0gbxtgp.js.map +13 -0
- package/dist/chunks/{index-gvers8jw.js → index-qhzdzca2.js} +3709 -2170
- package/dist/chunks/index-qhzdzca2.js.map +118 -0
- package/dist/chunks/{index-x69p7cv7.js → index-r7b1ftwy.js} +3 -3
- package/dist/chunks/index-r7b1ftwy.js.map +10 -0
- package/dist/chunks/{index-ev2b5aaf.js → index-sx488hvs.js} +4 -4
- package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
- package/dist/chunks/index-wss3gd3h.js.map +13 -0
- package/dist/chunks/{index-qd5xgx6y.js → index-zcqxfwdq.js} +5 -12
- package/dist/chunks/index-zcqxfwdq.js.map +13 -0
- package/dist/client/index.js +6 -6
- package/dist/core/appearance.js +1 -1
- package/dist/core/config.js +3 -3
- package/dist/core/contract.js +3 -3
- package/dist/core/format.js +10 -2
- package/dist/core/format.js.map +1 -1
- package/dist/embed/index.js +26 -25
- package/dist/embed/index.js.map +4 -4
- package/dist/index.js +3 -3
- package/dist/local.js +166 -144
- package/dist/local.js.map +8 -7
- package/dist/preview.js +1456 -0
- package/dist/preview.js.map +17 -0
- package/dist/react/embed/index.js +1 -1
- package/dist/react/index.js +250 -93
- package/dist/react/index.js.map +10 -10
- package/dist/react/ui/index.js +1168 -1165
- package/dist/react/ui/index.js.map +13 -11
- package/dist/server.js +68 -57
- package/dist/server.js.map +7 -6
- package/dist/types/client/download.d.ts +5 -0
- package/dist/types/client/iframe.d.ts +4 -2
- package/dist/types/client/logger.d.ts +10 -2
- package/dist/types/core/annotations.d.ts +5 -0
- package/dist/types/core/appearance.d.ts +2 -0
- package/dist/types/core/bridge-endpoint.d.ts +2 -2
- package/dist/types/core/bridge.d.ts +22 -0
- package/dist/types/core/config.d.ts +5 -0
- package/dist/types/core/contract.d.ts +3 -1
- package/dist/types/core/date-format.d.ts +24 -0
- package/dist/types/core/dimension.d.ts +2 -1
- package/dist/types/core/filters.d.ts +4 -3
- package/dist/types/core/format.d.ts +5 -3
- package/dist/types/core/messages.d.ts +3 -1
- package/dist/types/core/operation-types.d.ts +7 -7
- package/dist/types/core/time-interval.d.ts +96 -0
- package/dist/types/core/variables.d.ts +13 -4
- package/dist/types/embed/host.d.ts +4 -4
- package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
- package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
- package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
- package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
- package/dist/types/react/bindings.d.ts +26 -3
- package/dist/types/react/date-formatting.d.ts +12 -0
- package/dist/types/react/hooks.d.ts +10 -9
- package/dist/types/react/index.d.ts +7 -2
- package/dist/types/react/search-suggestions.d.ts +8 -0
- package/dist/types/react/style-contract.d.ts +1 -5
- package/dist/types/react/ui/ChartLegend.d.ts +3 -2
- package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
- package/dist/types/react/ui/DataApp.d.ts +5 -4
- package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
- package/dist/types/react/ui/DataTable.d.ts +6 -4
- package/dist/types/react/ui/DataWidget.d.ts +4 -0
- package/dist/types/react/ui/DateDisplay.d.ts +9 -0
- package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
- package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
- package/dist/types/react/ui/DimensionPicker.d.ts +3 -1
- package/dist/types/react/ui/EmptyState.d.ts +1 -1
- package/dist/types/react/ui/GradientScroll.d.ts +8 -0
- package/dist/types/react/ui/Grid.d.ts +1 -1
- package/dist/types/react/ui/MetricWidget.d.ts +2 -0
- package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
- package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
- package/dist/types/react/ui/PickerField.d.ts +15 -0
- package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
- package/dist/types/react/ui/RequestHint.d.ts +2 -2
- package/dist/types/react/ui/SearchField.d.ts +3 -1
- package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
- package/dist/types/react/ui/SectionHeading.d.ts +8 -0
- package/dist/types/react/ui/Select.d.ts +5 -1
- package/dist/types/react/ui/Sheet.d.ts +3 -1
- package/dist/types/react/ui/TableWidget.d.ts +8 -0
- package/dist/types/react/ui/Tabs.d.ts +4 -3
- package/dist/types/react/ui/VariableBar.d.ts +1 -1
- package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
- package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
- package/dist/types/react/ui/chart-interaction.d.ts +21 -0
- package/dist/types/react/ui/chart-primitives.d.ts +4 -4
- package/dist/types/react/ui/chart-time.d.ts +16 -0
- package/dist/types/react/ui/chartColor.d.ts +1 -1
- package/dist/types/react/ui/icons.d.ts +3 -1
- package/dist/types/react/ui/index.d.ts +8 -4
- package/dist/types/react/ui/metric-comparison.d.ts +2 -2
- package/dist/types/react/ui/metric.d.ts +2 -2
- package/dist/types/react/ui/presentation.d.ts +2 -0
- package/dist/types/react/ui/searchItems.d.ts +2 -0
- package/dist/types/react/ui/variables.d.ts +1 -1
- package/dist/types/react/view-control-bar.d.ts +16 -0
- package/dist/types/react/view-controls.d.ts +3 -2
- package/dist/types/react/view-runtime.d.ts +3 -1
- package/dist/types/react/view.d.ts +14 -2
- package/dist/types/server/local.d.ts +3 -1
- package/dist/types/server/preview/host.d.ts +1 -0
- package/dist/types/server/preview/index.d.ts +16 -0
- package/dist/types/server/reload-channel.d.ts +6 -0
- package/dist/types/server/request-body.d.ts +4 -0
- package/dist/worker.js +1 -1
- package/docs/app-authoring.md +17 -9
- package/docs/client.md +1 -1
- package/docs/contract.md +8 -9
- package/docs/embed.md +11 -3
- package/docs/formatting-and-appearance.md +36 -5
- package/docs/layout.md +31 -8
- package/docs/react-embed.md +4 -4
- package/docs/react.md +1 -1
- package/docs/server-bun.md +25 -0
- package/docs/server.md +1 -1
- package/docs/styling.md +7 -28
- package/docs/ui.md +21 -18
- package/docs/variables.md +92 -15
- package/docs/views.md +13 -36
- package/docs/widgets.md +38 -26
- package/examples/starter-data-app/index.tsx +0 -1
- package/examples/starter-local-data-app/.bun-version +1 -0
- package/examples/starter-local-data-app/.node-version +1 -0
- package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
- package/examples/starter-local-data-app/.oxlintrc.json +33 -0
- package/examples/starter-local-data-app/AGENTS.md +22 -0
- package/examples/starter-local-data-app/README.md +54 -0
- package/examples/starter-local-data-app/app.ts +22 -0
- package/examples/starter-local-data-app/bunfig.toml +2 -0
- package/examples/starter-local-data-app/package.json +33 -0
- package/examples/starter-local-data-app/src/App.tsx +8 -0
- package/examples/starter-local-data-app/src/assets.d.ts +1 -0
- package/examples/starter-local-data-app/src/data-context.ts +21 -0
- package/examples/starter-local-data-app/src/favicon.svg +13 -0
- package/examples/starter-local-data-app/src/index.html +14 -0
- package/examples/starter-local-data-app/src/main.tsx +7 -0
- package/examples/starter-local-data-app/src/operations.ts +6 -0
- package/examples/starter-local-data-app/src/server.ts +6 -0
- package/examples/starter-local-data-app/tsconfig.json +15 -0
- package/package.json +13 -3
- package/dist/chunks/index-ag0cgnvq.js.map +0 -13
- package/dist/chunks/index-dq7b35fn.js +0 -307
- package/dist/chunks/index-dq7b35fn.js.map +0 -13
- package/dist/chunks/index-f5cnbrjz.js.map +0 -13
- package/dist/chunks/index-gvers8jw.js.map +0 -109
- package/dist/chunks/index-ktmvs916.js.map +0 -13
- package/dist/chunks/index-m6n8ctfc.js.map +0 -10
- package/dist/chunks/index-mev09s5v.js +0 -77
- package/dist/chunks/index-mev09s5v.js.map +0 -10
- package/dist/chunks/index-mt93ff2b.js.map +0 -10
- package/dist/chunks/index-qd5xgx6y.js.map +0 -13
- package/dist/chunks/index-x69p7cv7.js.map +0 -10
- package/dist/types/react/shellStyles.d.ts +0 -3
- package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
- /package/dist/chunks/{index-23dktynd.js.map → index-ap60vggk.js.map} +0 -0
- /package/dist/chunks/{index-ev2b5aaf.js.map → index-sx488hvs.js.map} +0 -0
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
|
|
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
|
|
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
|
|
102
|
-
|
|
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
|
-
|
|
163
|
-
Clear
|
|
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()
|
|
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()`
|
|
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
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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,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
|
|
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
|
|
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
|
|
32
|
-
|
|
|
33
|
-
| How do categories compare?
|
|
34
|
-
| Which items lead?
|
|
35
|
-
| How does a measure change over time?
|
|
36
|
-
| How large is the measure over time?
|
|
37
|
-
| What makes up the whole?
|
|
38
|
-
| What share of an observed total does each part represent?
|
|
39
|
-
| How do several measures relate on one plot?
|
|
40
|
-
| How are two numeric measures related?
|
|
41
|
-
| Where
|
|
42
|
-
| Do cohorts return
|
|
43
|
-
| Which paths do
|
|
44
|
-
| How did one metric change between periods?
|
|
45
|
-
| What are the exact values or row details?
|
|
46
|
-
|
|
47
|
-
Prefer bars or a ranking when
|
|
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
|
|
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
|
|
|
@@ -99,13 +98,27 @@ row-key callbacks explicitly; row keys must be stable and unique.
|
|
|
99
98
|
Metric comparisons require a
|
|
100
99
|
view date binding. `read()` returns a loading-aware value for custom prose.
|
|
101
100
|
Pass the binding and `source={snapshot}` to reuse a widget in a story. Use the
|
|
102
|
-
source supplied by that binding's own view
|
|
103
|
-
are rejected before selection.
|
|
104
|
-
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
|
|
105
102
|
actions remain local choices. For custom cells, use `format: row => ...`; CSV
|
|
106
103
|
still uses the raw `value` accessor. Datasets default to “No results”; supply
|
|
107
104
|
`emptyFallback` for specific copy. See [export](stories-and-export.md).
|
|
108
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
|
+
|
|
109
122
|
## Narrative text
|
|
110
123
|
|
|
111
124
|
Use `<TextContent>` for prose within a page or custom layout, and `<TextWidget>`
|
|
@@ -113,7 +126,7 @@ when the explanation belongs in a titled panel alongside other widgets.
|
|
|
113
126
|
|
|
114
127
|
Give text a purpose: frame the question, explain how to interpret a comparison,
|
|
115
128
|
qualify a finding, or suggest what to explore next. Choose the content for the
|
|
116
|
-
|
|
129
|
+
user's question.
|
|
117
130
|
|
|
118
131
|
For data-dependent text, pass `metric` or `dataset` and `source` to `<TextWidget>`.
|
|
119
132
|
It derives its title and evidence. A metric formats its current value by default;
|
|
@@ -123,7 +136,6 @@ including an empty selection, so they can explain zero activity.
|
|
|
123
136
|
Use `<DataValue metric={total} source={result} />` for a formatted value inside
|
|
124
137
|
static prose, or pass a dataset and row renderer. Its default loading fallback is
|
|
125
138
|
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
139
|
Use `<TextContent>` for static instructions; local filters should feed the same
|
|
128
140
|
filtered data to the text and its related visualization.
|
|
129
141
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.4.2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24.18.0
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "data-app-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"imports": {
|
|
6
|
+
"#app/*": "./src/*",
|
|
7
|
+
"#config": "./app.ts"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"typecheck": "tsc --noEmit",
|
|
11
|
+
"lint": "oxlint --type-aware src",
|
|
12
|
+
"format": "oxfmt src app.ts",
|
|
13
|
+
"format:check": "oxfmt --check src app.ts",
|
|
14
|
+
"dev": "bun --hot src/server.ts",
|
|
15
|
+
"build": "bun run typecheck && bun build src/index.html --outdir=dist --production",
|
|
16
|
+
"check": "bun run lint && bun run format:check && bun run build"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@altertable/data-app": "file:../..",
|
|
20
|
+
"react": "19.3.0",
|
|
21
|
+
"react-dom": "19.3.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/bun": "1.4.2",
|
|
25
|
+
"@types/react": "19.3.0",
|
|
26
|
+
"@types/react-dom": "19.3.0",
|
|
27
|
+
"oxfmt": "0.70.0",
|
|
28
|
+
"oxlint": "1.85.0",
|
|
29
|
+
"oxlint-tsgolint": "7.0.2003",
|
|
30
|
+
"typescript": "7.0.2"
|
|
31
|
+
},
|
|
32
|
+
"packageManager": "bun@1.4.2"
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GettingStarted } from "@altertable/data-app/react/ui";
|
|
2
|
+
import { dataContext } from "#app/data-context.ts";
|
|
3
|
+
|
|
4
|
+
/** Connectivity-only screen. Investigate the requested question, then replace this with a view
|
|
5
|
+
* that leads with a supported finding and explores the useful angles behind it. */
|
|
6
|
+
export function App() {
|
|
7
|
+
return <GettingStarted dataContext={dataContext} />;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.css";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createDataContext } from "@altertable/data-app/react";
|
|
2
|
+
import { dataApp } from "#config";
|
|
3
|
+
|
|
4
|
+
const connectionQueryNames = { connection: "connection" } satisfies Record<
|
|
5
|
+
string,
|
|
6
|
+
keyof typeof dataApp.queries
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
/** Setup context only. Replace it with the exploration's scope, exact definitions, limitations,
|
|
10
|
+
* and query evidence after inspecting the source data. */
|
|
11
|
+
export const dataContext = createDataContext(connectionQueryNames)({
|
|
12
|
+
description:
|
|
13
|
+
"This starter runs a lightweight query to verify that the selected lakehouse profile can execute SQL. It does not check access to individual datasets. Replace the check with a query that answers a real question before sharing the app.",
|
|
14
|
+
glossary: {
|
|
15
|
+
connectionVerified: {
|
|
16
|
+
term: "Connected",
|
|
17
|
+
definition: "The latest connection-check query completed successfully.",
|
|
18
|
+
queryNames: [connectionQueryNames.connection],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 51 44">
|
|
2
|
+
<style>
|
|
3
|
+
path { fill: #01050b; }
|
|
4
|
+
@media (prefers-color-scheme: dark) {
|
|
5
|
+
path { fill: #fff; }
|
|
6
|
+
}
|
|
7
|
+
</style>
|
|
8
|
+
<path
|
|
9
|
+
fill-rule="evenodd"
|
|
10
|
+
clip-rule="evenodd"
|
|
11
|
+
d="M40.3274 28.9788L35.9663 28.8378L34.9541 28.6881L18.1066 10.301L24.1073 0L26.8738 0.545413L41.5212 25.6848L40.3274 28.9788ZM20.5319 20.1112L18.1894 15.6731L14.6154 16.2904L0 41.378L0.894584 44H12.9453L20.5769 20.4134L20.5319 20.1112ZM44.9804 31.6253L20.3808 36.9197L17.5838 41.2974L19.9001 44H49.2036L51 41.9551L44.9804 31.6253Z"
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="theme-color" content="#ffffff" />
|
|
7
|
+
<title>Altertable app</title>
|
|
8
|
+
<link rel="icon" href="./favicon.svg" type="image/svg+xml" />
|
|
9
|
+
<script type="module" src="./main.tsx"></script>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { dataApp } from "#config";
|
|
2
|
+
import { connectionCheck } from "@altertable/data-app/contract";
|
|
3
|
+
|
|
4
|
+
/** Connectivity probe only: its successful query supplies no analytical result. Replace it with
|
|
5
|
+
* bounded, validated operations that cover the questions the finished app will answer. */
|
|
6
|
+
export const operations = { connection: connectionCheck(dataApp.queries) };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "Preserve",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"types": ["bun"]
|
|
13
|
+
},
|
|
14
|
+
"include": ["src", "app.ts"]
|
|
15
|
+
}
|