@altertable/data-app 0.72.0 → 0.74.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 +5 -61
- package/CONTRIBUTING.md +130 -181
- package/README.md +3 -4
- package/REFERENCE.md +35 -345
- package/dist/chunks/contract-BeLPJwlO.js +558 -0
- package/dist/chunks/contract-BeLPJwlO.js.map +1 -0
- package/dist/chunks/contract-Di8SP74I.js +462 -0
- package/dist/chunks/contract-Di8SP74I.js.map +1 -0
- package/dist/chunks/diagnostics-BTZSlNtW.js +967 -0
- package/dist/chunks/diagnostics-BTZSlNtW.js.map +1 -0
- package/dist/chunks/format-BdFlv_xa.js +148 -0
- package/dist/chunks/format-BdFlv_xa.js.map +1 -0
- package/dist/chunks/operation-CSM9UmO3.js +134 -0
- package/dist/chunks/operation-CSM9UmO3.js.map +1 -0
- package/dist/chunks/request-body-H1qPmmTN.js +50 -0
- package/dist/chunks/request-body-H1qPmmTN.js.map +1 -0
- package/dist/client/index.js +273 -285
- package/dist/client/index.js.map +1 -13
- package/dist/core/appearance.js +171 -162
- package/dist/core/appearance.js.map +1 -10
- package/dist/core/config.js +49 -11
- package/dist/core/config.js.map +1 -9
- package/dist/core/contract.js +3 -73
- package/dist/core/format.js +1 -26
- package/dist/index.js +1 -12
- package/dist/internal.js +352 -397
- package/dist/internal.js.map +1 -15
- package/dist/server/index.js +85 -97
- package/dist/server/index.js.map +1 -10
- package/dist/types/chunks/appearance.d.ts +45 -0
- package/dist/types/chunks/contract.d.ts +720 -0
- package/dist/types/chunks/index.d.ts +240 -0
- package/dist/types/client/index.d.ts +3 -13
- package/dist/types/core/appearance.d.ts +2 -42
- package/dist/types/core/config.d.ts +36 -39
- package/dist/types/core/contract.d.ts +2 -114
- package/dist/types/core/format.d.ts +44 -17
- package/dist/types/index.d.ts +3 -3
- package/dist/types/internal.d.ts +312 -22
- package/dist/types/server/index.d.ts +15 -4
- package/docs/app-authoring.md +77 -128
- package/docs/client.md +29 -63
- package/docs/composition.md +44 -75
- package/docs/contract.md +60 -100
- package/docs/data-context.md +35 -61
- package/docs/diagnostics.md +45 -0
- package/docs/embed.md +86 -55
- package/docs/formatting-and-appearance.md +17 -38
- package/docs/hosted-apps.md +7 -14
- package/docs/layout.md +30 -47
- package/docs/local-data-apps.md +7 -7
- package/docs/react-embed.md +20 -26
- package/docs/react.md +10 -27
- package/docs/server-bun.md +2 -27
- package/docs/server.md +6 -12
- package/docs/stories-and-export.md +38 -40
- package/docs/styling.md +14 -22
- package/docs/ui-quality.md +5 -5
- package/docs/ui.md +93 -70
- package/docs/variables.md +142 -254
- package/docs/views.md +85 -116
- package/docs/widgets.md +100 -153
- package/docs/worker.md +15 -27
- package/package.json +3 -2
- package/dist/chunks/index-5a27erdg.js +0 -54
- package/dist/chunks/index-5a27erdg.js.map +0 -10
- package/dist/chunks/index-9yxr7nmm.js +0 -742
- package/dist/chunks/index-9yxr7nmm.js.map +0 -17
- package/dist/chunks/index-j5q5n3ra.js +0 -151
- package/dist/chunks/index-j5q5n3ra.js.map +0 -10
- package/dist/chunks/index-q75zm3a7.js +0 -153
- package/dist/chunks/index-q75zm3a7.js.map +0 -11
- package/dist/chunks/index-vhaec7m5.js +0 -30
- package/dist/chunks/index-vhaec7m5.js.map +0 -10
- package/dist/chunks/index-zp78caex.js +0 -1047
- package/dist/chunks/index-zp78caex.js.map +0 -19
- package/dist/core/contract.js.map +0 -9
- package/dist/core/format.js.map +0 -9
- package/dist/index.js.map +0 -9
- package/dist/types/client/annotations.d.ts +0 -27
- package/dist/types/client/data-client.d.ts +0 -43
- package/dist/types/client/download.d.ts +0 -5
- package/dist/types/client/iframe.d.ts +0 -59
- package/dist/types/client/location.d.ts +0 -13
- package/dist/types/client/logger.d.ts +0 -14
- package/dist/types/client/messages.d.ts +0 -7
- package/dist/types/client/navigation.d.ts +0 -15
- package/dist/types/client/transport.d.ts +0 -15
- package/dist/types/core/annotations.d.ts +0 -99
- package/dist/types/core/bridge-endpoint.d.ts +0 -21
- package/dist/types/core/bridge.d.ts +0 -172
- package/dist/types/core/data-view.d.ts +0 -46
- package/dist/types/core/date-format.d.ts +0 -24
- package/dist/types/core/date-range.d.ts +0 -20
- package/dist/types/core/dimension-source.d.ts +0 -64
- package/dist/types/core/dimension.d.ts +0 -71
- package/dist/types/core/facets.d.ts +0 -13
- package/dist/types/core/filters.d.ts +0 -45
- package/dist/types/core/invariant.d.ts +0 -2
- package/dist/types/core/keys.d.ts +0 -2
- package/dist/types/core/logger.d.ts +0 -12
- package/dist/types/core/messages.d.ts +0 -62
- package/dist/types/core/navigation.d.ts +0 -11
- package/dist/types/core/operation-types.d.ts +0 -80
- package/dist/types/core/operation.d.ts +0 -20
- package/dist/types/core/presentation.d.ts +0 -9
- package/dist/types/core/queries.d.ts +0 -84
- package/dist/types/core/reading.d.ts +0 -17
- package/dist/types/core/uuid.d.ts +0 -2
- package/dist/types/core/variables.d.ts +0 -133
- package/dist/types/server/handler.d.ts +0 -13
- package/dist/types/server/request-body.d.ts +0 -4
package/docs/views.md
CHANGED
|
@@ -1,154 +1,123 @@
|
|
|
1
1
|
# Views and displayed results
|
|
2
2
|
|
|
3
|
+
Keep the starter's client and hooks. Use one view for related results; split only
|
|
4
|
+
when sections need independent requests. The examples continue the hosted
|
|
5
|
+
starter's `sampleCountsByGroup` operation and `sampleDataContext`.
|
|
6
|
+
|
|
3
7
|
## Bind a view
|
|
4
8
|
|
|
5
9
|
```tsx
|
|
6
|
-
import { createDataClient } from '@altertable/data-app/client';
|
|
7
10
|
import {
|
|
8
11
|
createDataHooks,
|
|
9
12
|
DataApp,
|
|
10
13
|
DataSection,
|
|
14
|
+
searchVariable,
|
|
15
|
+
TableWidget,
|
|
11
16
|
} from '@altertable/data-app-react';
|
|
12
|
-
import type { operations } from '#app/operations.ts';
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
// ... client, operations, and sampleDataContext
|
|
15
19
|
const { defineDataView } = createDataHooks(client);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
const sampleCountsView = defineDataView({
|
|
22
|
+
dataContext: sampleDataContext,
|
|
23
|
+
operation: 'sampleCountsByGroup',
|
|
24
|
+
variables: {
|
|
25
|
+
groupName: searchVariable({
|
|
26
|
+
key: 'group',
|
|
27
|
+
label: 'Group',
|
|
28
|
+
defaultValue: '',
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
describeInput: ({ groupName }) =>
|
|
32
|
+
groupName ? `group ${groupName}` : 'all groups',
|
|
33
|
+
isEmpty: rows => rows.length === 0,
|
|
34
|
+
emptyFallback: { title: 'No matching groups' },
|
|
22
35
|
});
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
// ... sampleCounts dataset and story callback
|
|
37
|
+
const sampleContent = sampleCountsView.content(result => (
|
|
38
|
+
<TableWidget dataset={sampleCounts} source={result} />
|
|
25
39
|
));
|
|
26
40
|
|
|
27
41
|
function App() {
|
|
28
42
|
return (
|
|
29
|
-
<DataApp view={
|
|
30
|
-
<DataSection content={
|
|
43
|
+
<DataApp view={sampleCountsView} story={story} datasets={[sampleCounts]}>
|
|
44
|
+
<DataSection content={sampleContent} />
|
|
31
45
|
</DataApp>
|
|
32
46
|
);
|
|
33
47
|
}
|
|
34
48
|
```
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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.
|
|
42
|
-
The operation and `ActivityWidgets` are app-owned. The bound widgets derive
|
|
43
|
-
loading content from their source; see [widgets](widgets.md) and the
|
|
44
|
-
[complete starter](app-authoring.md#use-release-matched-starters). Define
|
|
45
|
-
[filters](variables.md), [context and evidence](data-context.md), and
|
|
46
|
-
[story and datasets](stories-and-export.md) for the app's question.
|
|
47
|
-
|
|
48
|
-
Render static text immediately; skeletonize only dynamic content. Keep section
|
|
49
|
-
introductions outside request boundaries so they remain visible on empty and
|
|
50
|
-
error states.
|
|
51
|
-
|
|
52
|
-
Use `<DataSection>` for each independently fetched subtree and `view.content()`
|
|
53
|
-
to share its loading and ready layout. Refreshes retain displayed content.
|
|
54
|
-
|
|
55
|
-
Use `<DataValue>` for a dynamic value within static prose:
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
<p>
|
|
59
|
-
Orders in the last 7 days: <DataValue metric={weeklyOrders} source={result} />
|
|
60
|
-
</p>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Bind the whole sentence with `<TextWidget>` when its wording depends on the result.
|
|
64
|
-
Use `<DataValue scope={result.scope} />` for the displayed scope label.
|
|
65
|
-
|
|
66
|
-
Use the same [date range contract](contract.md#shared-date-ranges) for the
|
|
67
|
-
operation and its view. For nested inputs in `defineTimeView()`, use
|
|
68
|
-
`bindings.period` to extract the selected period; see the
|
|
69
|
-
[time-view example](variables.md#declare-controls-once).
|
|
70
|
-
|
|
71
|
-
Use `result.scope` inside `view.content()` to show scope text. In stories and exports,
|
|
72
|
-
`view.scope(snapshot)` returns the same label from the displayed input, using
|
|
73
|
-
`describeInput` or the view's date label.
|
|
74
|
-
|
|
75
|
-
Declare standard controls in the view's [variables](variables.md). Keep
|
|
76
|
-
local-only filters out of the operation's `input`.
|
|
77
|
-
|
|
78
|
-
For large tables, use query-backed pagination with a stable sort and total
|
|
79
|
-
count. Client pagination and search cover only the rows already returned.
|
|
80
|
-
|
|
81
|
-
Declare evidence references on `view.dataset()` for charts and tables. `<MetricWidget>` uses
|
|
82
|
-
its metric definition for the label, format, and evidence; keep view-specific
|
|
83
|
-
descriptions on the widget.
|
|
84
|
-
|
|
85
|
-
`<MetricWidget>` and `<Comparison>` share a metric result. Comparisons
|
|
86
|
-
follow the displayed result's range.
|
|
87
|
-
|
|
88
|
-
Use the [format helpers](formatting-and-appearance.md) for metric formats and values in tables,
|
|
89
|
-
charts, and custom views.
|
|
50
|
+
Keep operation input flat and named like the variables. Omit `input` and
|
|
51
|
+
`bindings` when those shapes match. Use `defineTimeView()` for period-driven
|
|
52
|
+
analysis and `defineDataView()` otherwise. Adapt an existing nested input only
|
|
53
|
+
when required; see [input mapping](variables.md#adapt-existing-input-shapes).
|
|
90
54
|
|
|
91
55
|
## Preserve displayed results
|
|
92
56
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
57
|
+
Use the source from `view.content()` for every widget. Derive narrative, story,
|
|
58
|
+
export, and scope from that source and its displayed input, including during
|
|
59
|
+
refresh or failure. Use `result.scope` in content and `view.scope(snapshot)` in
|
|
60
|
+
stories. Let views and bound widgets own request state and loading feedback.
|
|
61
|
+
Keep static introductions outside loading boundaries.
|
|
98
62
|
|
|
99
|
-
A measured zero is valid data.
|
|
100
|
-
|
|
63
|
+
A measured zero is valid data. Set `isEmpty` for the analysis and provide useful
|
|
64
|
+
`emptyFallback` copy.
|
|
101
65
|
|
|
102
66
|
## Detail destinations
|
|
103
67
|
|
|
104
|
-
|
|
105
|
-
The destination owns its input parser, operation, datasets,
|
|
106
|
-
Pass its content to `<DataApp details={[
|
|
68
|
+
Add `defineDetailView()` only when readers need a scoped population or entity.
|
|
69
|
+
The destination owns its input parser, operation, datasets, context, and content.
|
|
70
|
+
Pass its content to `<DataApp details={[groupDetail]}>`:
|
|
107
71
|
|
|
108
72
|
```tsx
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
73
|
+
// ... client, operations, sampleDataContext, main view, datasets, and story
|
|
74
|
+
const { defineDetailView } = createDataHooks(client);
|
|
75
|
+
|
|
76
|
+
const groupView = defineDetailView({
|
|
77
|
+
id: 'group',
|
|
78
|
+
title: 'Group counts',
|
|
79
|
+
operation: 'sampleCountsByGroup',
|
|
80
|
+
dataContext: sampleDataContext,
|
|
81
|
+
parseInput: operations.sampleCountsByGroup.input,
|
|
82
|
+
describeInput: ({ groupName }) => `group ${groupName}`,
|
|
83
|
+
isEmpty: rows => rows.length === 0,
|
|
84
|
+
emptyFallback: { title: 'No matching group' },
|
|
85
|
+
});
|
|
86
|
+
const groupCounts = groupView.dataset({
|
|
87
|
+
name: 'Group counts',
|
|
88
|
+
select: rows => rows,
|
|
89
|
+
rowKey: row => row.groupName,
|
|
90
|
+
columns: {
|
|
91
|
+
groupName: { value: row => row.groupName },
|
|
92
|
+
sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
|
|
93
|
+
},
|
|
94
|
+
evidence: { id: 'group-counts', glossaryIds: ['sampleCount'] },
|
|
118
95
|
});
|
|
119
|
-
const
|
|
120
|
-
<TableWidget dataset={
|
|
96
|
+
const groupDetail = groupView.content(result => (
|
|
97
|
+
<TableWidget dataset={groupCounts} source={result} />
|
|
121
98
|
));
|
|
99
|
+
|
|
100
|
+
function App() {
|
|
101
|
+
return (
|
|
102
|
+
<DataApp
|
|
103
|
+
view={sampleCountsView}
|
|
104
|
+
datasets={[sampleCounts]}
|
|
105
|
+
story={story}
|
|
106
|
+
details={[groupDetail]}
|
|
107
|
+
>
|
|
108
|
+
<DataSection content={sampleContent} />
|
|
109
|
+
</DataApp>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
122
112
|
```
|
|
123
113
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Validate selected members through the same `variableInput()` parser used by the dashboard.
|
|
127
|
-
Shared links validate before execution. Nested destinations replace the single
|
|
128
|
-
detail sheet; the main app retains ownership of exports and stories.
|
|
129
|
-
The complete route supports up to 20 destinations and 16,384 serialized characters;
|
|
130
|
-
navigation rejects overflow before changing history.
|
|
114
|
+
Pass serializable scope and IDs, not records or credentials. Validate dimension selections with
|
|
115
|
+
the dashboard's `variableInput()` parser. The main app owns stories and exports.
|
|
131
116
|
|
|
132
117
|
### Contributing metric records
|
|
133
118
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
input: displayedInput => displayedInput,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
<MetricWidget
|
|
143
|
-
metric={orderCount}
|
|
144
|
-
source={source}
|
|
145
|
-
records={contributingOrders}
|
|
146
|
-
/>;
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Inspection tabs become Records, Glossary, Queries. Records load when their tab
|
|
150
|
-
is shown; the destination's `describeInput()` supplies their scope. Source context
|
|
151
|
-
belongs in Glossary. Match record inclusion to the metric and explain non-additive
|
|
152
|
-
metrics. State completeness limits visibly in destination content. Local pagination
|
|
153
|
-
covers only supplied rows; larger populations need explicit server paging or a
|
|
154
|
-
visible limit.
|
|
119
|
+
Use `metric.records()` when a detail shows the records behind that metric, then
|
|
120
|
+
pass it to `<MetricWidget records={...}>`. Match record inclusion to the metric
|
|
121
|
+
and explain non-additive measures or completeness limits. Query matching records
|
|
122
|
+
rather than filtering a capped dashboard preview; use server pagination for
|
|
123
|
+
larger populations.
|
package/docs/widgets.md
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Metrics, tables, and visualizations from `@altertable/data-app-react` consume view bindings and a source. For static displays, use
|
|
6
6
|
[direct UI composition](ui.md).
|
|
7
|
-
Manage requests in
|
|
8
|
-
readings without inventing values. Use `isEmpty` for the predicate and
|
|
9
|
-
`emptyFallback` for empty-result copy.
|
|
7
|
+
Manage requests in [views](views.md).
|
|
10
8
|
|
|
11
9
|
| Need | Component |
|
|
12
10
|
| ------------------------------------------------ | ----------------------- |
|
|
@@ -17,7 +15,8 @@ readings without inventing values. Use `isEmpty` for the predicate and
|
|
|
17
15
|
| Borderless explanatory prose | `<TextContent>` |
|
|
18
16
|
| One data-dependent phrase within static prose | `<DataValue>` |
|
|
19
17
|
|
|
20
|
-
Use
|
|
18
|
+
Use `<Stack>` for reading order and `<Grid>` for peers. Read [layout](layout.md)
|
|
19
|
+
only when changing spans or shell composition.
|
|
21
20
|
`<Skeleton>` supports custom fallback content.
|
|
22
21
|
|
|
23
22
|
## Choose a visualization
|
|
@@ -27,34 +26,30 @@ Choose the component by the user's question. Compose dataset visuals inside
|
|
|
27
26
|
charts come from `@altertable/data-app-react/ui`; `<Ranking>`, `<Breakdown>`, and `<Comparison>`
|
|
28
27
|
are also available from `@altertable/data-app-react`.
|
|
29
28
|
|
|
30
|
-
| Question
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
table when they matter. Follow the [chart input constraints](ui.md#charts). For custom combinations of series,
|
|
50
|
-
use the [composed chart primitives](ui.md#composed-charts) within the same bound
|
|
51
|
-
visualization workflow.
|
|
52
|
-
|
|
53
|
-
Use widget `views` when a chart and another representation answer the same
|
|
54
|
-
question from the same dataset.
|
|
29
|
+
| Question | Component and constraint |
|
|
30
|
+
| -------------------------------- | ------------------------------------------------------------------------------- |
|
|
31
|
+
| Compare categories | `<BarChart>` for nonnegative values; order by rank or meaningful category order |
|
|
32
|
+
| Show leaders | `<Ranking>`; tracks scale to the largest visible item |
|
|
33
|
+
| Show a time trend | `<LineChart>` for equally spaced samples |
|
|
34
|
+
| Show magnitude over time | `<AreaChart>` when fill relative to zero adds meaning |
|
|
35
|
+
| Show parts of a whole | `<PieChart>` for a few exclusive parts; include Other |
|
|
36
|
+
| Show shares of an observed total | `<Breakdown>` with an explicit total |
|
|
37
|
+
| Combine measures or marks | `<ComposedChart>`; label units and use separate axes when needed |
|
|
38
|
+
| Relate two numeric measures | `<ScatterChart>` with independent X/Y observations |
|
|
39
|
+
| Show ordered step drop-off | `<FunnelChart>` with counts from one population |
|
|
40
|
+
| Show return by elapsed interval | `<RetentionChart>` with cohort counts and rates |
|
|
41
|
+
| Explore event paths | `<JourneyChart>` with full paths, counts, and outcomes |
|
|
42
|
+
| Compare periods | `<Comparison>` with a bound metric |
|
|
43
|
+
| Inspect exact values | `<TableWidget>` with a dataset binding |
|
|
44
|
+
|
|
45
|
+
Use widget `views` for alternate representations of one dataset. Check
|
|
46
|
+
[chart input constraints](ui.md#charts) before adapting rows, and keep exact
|
|
47
|
+
values available in a table when they matter.
|
|
55
48
|
|
|
56
49
|
## Declare datasets and metrics
|
|
57
50
|
|
|
51
|
+
Continue the starter's `sampleCountsView`. Use `<BarChart>` from
|
|
52
|
+
`@altertable/data-app-react/ui`.
|
|
58
53
|
Bind reusable selections to the view. Declare evidence references directly;
|
|
59
54
|
the view validates them against its own context. A dataset's columns supply both formatted
|
|
60
55
|
table cells and raw CSV values. Widgets derive their readings, evidence, and empty fallback from the binding.
|
|
@@ -62,64 +57,57 @@ Declare at least one dataset column. Metric selectors may return `previous`
|
|
|
62
57
|
only for views with a date binding, including `defineTimeView()`.
|
|
63
58
|
|
|
64
59
|
```tsx
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
// ... sampleCountsView and imports
|
|
61
|
+
const sampleCounts = sampleCountsView.dataset({
|
|
62
|
+
name: 'Sample counts',
|
|
63
|
+
select: rows => rows,
|
|
64
|
+
rowKey: row => row.groupName,
|
|
65
|
+
evidence: { id: 'counts-by-group', glossaryIds: ['sampleCount'] },
|
|
70
66
|
columns: {
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
groupName: { label: 'Group', value: row => row.groupName },
|
|
68
|
+
sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
|
|
73
69
|
},
|
|
74
70
|
});
|
|
75
|
-
const
|
|
71
|
+
const totalSamples = sampleCountsView.metric(
|
|
76
72
|
{
|
|
77
|
-
id: '
|
|
78
|
-
glossaryId: '
|
|
73
|
+
id: 'total-samples',
|
|
74
|
+
glossaryId: 'sampleCount',
|
|
75
|
+
label: 'Total samples',
|
|
79
76
|
format: { kind: 'count', compact: true },
|
|
80
77
|
},
|
|
81
|
-
|
|
82
|
-
current: data.count,
|
|
83
|
-
previous: data.previousCount,
|
|
84
|
-
})
|
|
78
|
+
rows => ({ current: rows.reduce((sum, row) => sum + row.sampleCount, 0) })
|
|
85
79
|
);
|
|
86
|
-
const
|
|
80
|
+
const sampleContent = sampleCountsView.content(result => (
|
|
87
81
|
<Grid columns={2}>
|
|
88
|
-
<MetricWidget metric={
|
|
89
|
-
<TableWidget dataset={
|
|
90
|
-
<VisualizationWidget dataset={
|
|
91
|
-
{rows =>
|
|
82
|
+
<MetricWidget metric={totalSamples} source={result} />
|
|
83
|
+
<TableWidget dataset={sampleCounts} source={result} />
|
|
84
|
+
<VisualizationWidget dataset={sampleCounts} source={result}>
|
|
85
|
+
{rows => (
|
|
86
|
+
<BarChart
|
|
87
|
+
ariaLabel="Sample counts by group"
|
|
88
|
+
unit="samples"
|
|
89
|
+
items={rows.map(row => ({
|
|
90
|
+
...row,
|
|
91
|
+
id: row.groupName,
|
|
92
|
+
label: row.groupName,
|
|
93
|
+
value: row.sampleCount,
|
|
94
|
+
}))}
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
92
97
|
</VisualizationWidget>
|
|
93
98
|
</Grid>
|
|
94
99
|
));
|
|
95
100
|
```
|
|
96
101
|
|
|
97
|
-
Column keys supply
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
view date binding. `read()` returns a loading-aware value for custom prose.
|
|
102
|
-
Pass the binding and `source={snapshot}` to reuse a widget in a story. Use the
|
|
103
|
-
source supplied by that binding's own view. Table search, pagination, descriptions, and
|
|
104
|
-
actions remain local choices. For custom cells, use `format: row => ...`; CSV
|
|
105
|
-
still uses the raw `value` accessor. Datasets default to “No results”; supply
|
|
106
|
-
`emptyFallback` for specific copy. See [export](stories-and-export.md).
|
|
107
|
-
|
|
108
|
-
`<TableWidget>` automatically shows the count of matching supplied rows. Use
|
|
109
|
-
`count` for a server total; other widgets can receive a count from the displayed result.
|
|
110
|
-
|
|
111
|
-
Provide useful `emptyFallback` and `noMatchesFallback` copy. Local search offers
|
|
112
|
-
Clear search automatically. For server-filtered tables, supply `onClearFilters`
|
|
113
|
-
only while filters affecting that dataset are active, preserving unrelated filters,
|
|
114
|
-
search, and display settings.
|
|
102
|
+
Column keys supply IDs and default labels; set `label` for a different header.
|
|
103
|
+
Keep row keys stable and unique. Custom cells use `format: row => ...`; CSV uses
|
|
104
|
+
the raw `value` accessor. Metric comparisons require a view date binding.
|
|
105
|
+
Reuse bindings in stories with `source={snapshot}` from the same view.
|
|
115
106
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
onClearFilters={hasActiveCustomerFilters ? clearCustomerFilters : undefined}
|
|
121
|
-
/>
|
|
122
|
-
```
|
|
107
|
+
Tables search and paginate only supplied rows. Use query-backed pagination with a
|
|
108
|
+
stable sort and total `count` for larger datasets. Provide useful `emptyFallback`
|
|
109
|
+
and `noMatchesFallback` copy. Supply `onClearFilters` only while relevant server
|
|
110
|
+
filters are active, preserving unrelated selections.
|
|
123
111
|
|
|
124
112
|
## Narrative text
|
|
125
113
|
|
|
@@ -135,7 +123,7 @@ It derives its title and evidence. A metric formats its current value by default
|
|
|
135
123
|
use a child renderer for authored prose. Dataset renderers receive displayed rows,
|
|
136
124
|
including an empty selection, so they can explain zero activity.
|
|
137
125
|
|
|
138
|
-
Use `<DataValue metric={
|
|
126
|
+
Use `<DataValue metric={totalSamples} source={result} />` for a formatted value inside
|
|
139
127
|
static prose, or pass a dataset and row renderer. Its default loading fallback is
|
|
140
128
|
an inline skeleton. Use `<DataValue scope={result.scope} />` for a scope label.
|
|
141
129
|
Use `<TextContent>` for static instructions; local filters should feed the same
|
|
@@ -150,16 +138,8 @@ The dataset owns evidence and empty copy; an empty row selection shows that fall
|
|
|
150
138
|
alternate-view selection shared with its inspection sheet. Give views stable IDs
|
|
151
139
|
and keep interactive state above the widget, since inspection may render it again.
|
|
152
140
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
mode shows a bounded preview without local pagination. Custom tables can use
|
|
156
|
-
`<DataTable>`, `<DataTableEmptyRow>`, `<DataTableTimestamp>`, and `<DataTableShare>`.
|
|
157
|
-
|
|
158
|
-
For custom controls, tables, and overlays, see [direct UI composition](ui.md).
|
|
159
|
-
For embedded theme and chrome, see [parent presentation](embed.md#parent-presentation).
|
|
160
|
-
|
|
161
|
-
`<TooltipProvider>` shares hover timing outside `<DataApp>`; the app already
|
|
162
|
-
provides it.
|
|
141
|
+
Use custom controls, tables, or overlays only when bound components cannot
|
|
142
|
+
express the requirement; see [direct UI composition](ui.md).
|
|
163
143
|
|
|
164
144
|
## Exploration actions
|
|
165
145
|
|
|
@@ -169,84 +149,51 @@ Both `children` and alternate-view `render` callbacks receive the displayed rows
|
|
|
169
149
|
and the same action resolver.
|
|
170
150
|
|
|
171
151
|
```tsx
|
|
172
|
-
|
|
152
|
+
// ... sampleCountsView, sampleCounts, and groupView
|
|
153
|
+
const groupActions = sampleCounts.actions(
|
|
173
154
|
action => ({
|
|
174
|
-
|
|
175
|
-
label: 'View
|
|
176
|
-
target:
|
|
177
|
-
input:
|
|
178
|
-
}),
|
|
179
|
-
filter: action.filter({
|
|
180
|
-
label: 'Filter to this region',
|
|
181
|
-
when: row => row.dimension === 'region',
|
|
182
|
-
target: salesView.filter(),
|
|
183
|
-
values: row => ({
|
|
184
|
-
region: {
|
|
185
|
-
kind: 'include',
|
|
186
|
-
members: [{ kind: 'value', value: row.id }],
|
|
187
|
-
},
|
|
188
|
-
}),
|
|
189
|
-
}),
|
|
190
|
-
drill: action.filter({
|
|
191
|
-
label: 'Drill down',
|
|
192
|
-
when: row => row.dimension === 'region',
|
|
193
|
-
target: salesView.filter(),
|
|
194
|
-
values: row => ({
|
|
195
|
-
region: {
|
|
196
|
-
kind: 'include',
|
|
197
|
-
members: [{ kind: 'value', value: row.id }],
|
|
198
|
-
},
|
|
199
|
-
}),
|
|
200
|
-
breakdown: {
|
|
201
|
-
target: salesView.breakdown('revenueBy'),
|
|
202
|
-
value: () => 'country',
|
|
203
|
-
},
|
|
155
|
+
group: action.detail({
|
|
156
|
+
label: 'View group',
|
|
157
|
+
target: groupView,
|
|
158
|
+
input: row => ({ groupName: row.groupName }),
|
|
204
159
|
}),
|
|
205
160
|
}),
|
|
206
|
-
{ primary: '
|
|
161
|
+
{ primary: 'group' }
|
|
207
162
|
);
|
|
208
163
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
164
|
+
const sampleContent = sampleCountsView.content(result => (
|
|
165
|
+
<VisualizationWidget
|
|
166
|
+
dataset={sampleCounts}
|
|
167
|
+
source={result}
|
|
168
|
+
actions={groupActions}
|
|
169
|
+
>
|
|
170
|
+
{(rows, actions) => (
|
|
171
|
+
<BarChart
|
|
172
|
+
ariaLabel="Sample counts by group"
|
|
173
|
+
unit="samples"
|
|
174
|
+
items={rows.map(row => ({
|
|
175
|
+
...row,
|
|
176
|
+
id: row.groupName,
|
|
177
|
+
label: row.groupName,
|
|
178
|
+
value: row.sampleCount,
|
|
179
|
+
}))}
|
|
180
|
+
itemActions={actions}
|
|
181
|
+
/>
|
|
182
|
+
)}
|
|
183
|
+
</VisualizationWidget>
|
|
184
|
+
));
|
|
224
185
|
```
|
|
225
186
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
The first copy action names the text it copies. Copy summary includes the displayed
|
|
233
|
-
label, formatted value, unit, and pie share. Successful copies are silent; failures
|
|
234
|
-
are announced and shown on the chart.
|
|
235
|
-
Right-click opens the menu at the pointer; Shift+F10 anchors it to the control.
|
|
236
|
-
Breakdown controls keep their selected choice visible and their accessible names.
|
|
237
|
-
Custom controls can compose `<ExplorationActionControl>` from `/react/ui`.
|
|
238
|
-
|
|
239
|
-
`<TableWidget actions={placeActions}>` adds row actions without changing the
|
|
240
|
-
dataset or its CSV export. `<MetricWidget>` accepts actions declared with
|
|
241
|
-
`metric.actions()`; metric action mappings receive `undefined` for the row and
|
|
242
|
-
the displayed operation input as their second argument. Actions must belong to
|
|
243
|
-
the metric or dataset rendered by the widget.
|
|
187
|
+
`groupView` is the destination from the detail-view example.
|
|
188
|
+
Keep domain fields when adapting chart items so action mappings retain IDs and
|
|
189
|
+
scope. Pass dataset actions to `<TableWidget>` or `<VisualizationWidget>`;
|
|
190
|
+
metric actions use `metric.actions()` and `<MetricWidget>`. Actions must belong
|
|
191
|
+
to the binding rendered by the widget. Metric mappings receive `undefined` for
|
|
192
|
+
the row and displayed input as their second argument.
|
|
244
193
|
|
|
245
194
|
`view.filter()` targets scope variables. An optional `breakdown` explicitly updates
|
|
246
|
-
one chart's display choice in the same history entry. Filters preserve unrelated
|
|
247
|
-
|
|
248
|
-
that also change a breakdown check that chart's displayed choice. No filter change
|
|
249
|
-
implicitly changes another filter or chart.
|
|
195
|
+
one chart's display choice in the same history entry. Filters preserve unrelated selections. Declare chart breakdown choices
|
|
196
|
+
independently of scope filters.
|
|
250
197
|
|
|
251
198
|
A day drill passes its day. A value-band drill passes a stable band ID; validate
|
|
252
199
|
it in the destination operation and derive bounds there. Query matching records
|
package/docs/worker.md
CHANGED
|
@@ -27,30 +27,18 @@ and these string bindings:
|
|
|
27
27
|
| `DOMAIN_NAME` | Runtime domain without scheme, port, or trailing dot | `apps.example.net` |
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
The Worker enforces a restrictive CSP with configured `frame-ancestors`,
|
|
46
|
-
`no-referrer`, and `nosniff`. App scripts load through the authenticated bridge. Apps own styling and
|
|
47
|
-
navigation. Bundle apps execute their operation registry in the browser and send
|
|
48
|
-
SQL through the [host query route](embed.md#sql-query-route); the Worker does not
|
|
49
|
-
resolve operation names or execute queries. Data requests require backend authorization.
|
|
50
|
-
|
|
51
|
-
If Terraform reads a file, copy the resolved `@altertable/data-app-worker` asset unchanged to that
|
|
52
|
-
file during deployment preparation. Configure `DOMAIN_NAME`, `PARENT_ORIGINS`,
|
|
53
|
-
domains, routes, and deployment settings in Terraform. Upgrade the host package
|
|
54
|
-
and Worker together for protocol changes.
|
|
55
|
-
Custom hosts that bundle their own bootstrap can use `startDataAppBootstrap()` from
|
|
56
|
-
[the embed package](embed.md#trusted-bootstrap).
|
|
30
|
+
Serve `/` on unique hyphenated lowercase preview labels under `DOMAIN_NAME`,
|
|
31
|
+
such as `report-123.apps.example.net`. Other hosts and paths return 404.
|
|
32
|
+
|
|
33
|
+
`__altertable_parent` selects an exact trusted origin from `PARENT_ORIGINS`; it
|
|
34
|
+
cannot add trust. Wildcards allow one HTTPS subdomain label without a port.
|
|
35
|
+
Exact entries must be bare HTTP(S) origins. Keep an exact origin first for the
|
|
36
|
+
default parent.
|
|
37
|
+
|
|
38
|
+
The Worker sets CSP and trusted frame ancestors. Data queries use the
|
|
39
|
+
[host's authorized SQL route](embed.md#sql-query-route); the Worker does not
|
|
40
|
+
execute queries.
|
|
41
|
+
|
|
42
|
+
For file-based deployment tools such as Terraform, copy the resolved asset
|
|
43
|
+
unchanged. Upgrade the host package and Worker together for protocol changes.
|
|
44
|
+
Custom bootstrap hosts use [startDataAppBootstrap()](embed.md#trusted-bootstrap).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altertable/data-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"description": "Portable definitions, contracts, formatting, browser clients, and request handlers for Altertable data apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"altertable",
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
"registry": "https://registry.npmjs.org"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
|
-
"build": "bun ../../scripts/build.ts data-app"
|
|
76
|
+
"build": "bun ../../scripts/build.ts data-app",
|
|
77
|
+
"typecheck": "bun ../../node_modules/typescript/bin/tsc --noEmit -p tsconfig.build.json"
|
|
77
78
|
},
|
|
78
79
|
"dependencies": {
|
|
79
80
|
"@internationalized/date": "3.12.4"
|