@altertable/data-app 0.72.0 → 0.73.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 +93 -180
- package/README.md +3 -4
- package/REFERENCE.md +30 -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/format-BdFlv_xa.js +148 -0
- package/dist/chunks/format-BdFlv_xa.js.map +1 -0
- package/dist/chunks/iframe-C3uCZEXh.js +809 -0
- package/dist/chunks/iframe-C3uCZEXh.js.map +1 -0
- package/dist/chunks/operation-CBxhjNhK.js +131 -0
- package/dist/chunks/operation-CBxhjNhK.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 +253 -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 +189 -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 +72 -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/embed.md +83 -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 +68 -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/variables.md
CHANGED
|
@@ -1,320 +1,208 @@
|
|
|
1
1
|
# Variables and filters
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
controls, and displayed-period label. Declare `time: { contract, defaultValue }`,
|
|
7
|
-
an operation, `isEmpty` (a predicate), and `emptyFallback` (a title and optional
|
|
8
|
-
description for an empty result). With no additional variables, its default
|
|
9
|
-
input is the calendar request. With additional variables, it is `{ period, ...variables }`.
|
|
10
|
-
Supply an `input` mapper for a different operation shape and `bindings` to extract
|
|
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.
|
|
15
|
-
|
|
16
|
-
`dimensionFilter()` from `/contract` uses fixed `options`. Use `defineFacetFilter()`
|
|
17
|
-
for options derived from declared variable context, or `app.defineDimension()`
|
|
18
|
-
for independent source options and exact member lookup. `<DimensionPicker>` offers missing values separately and keeps selected values
|
|
19
|
-
available when options refresh or fail; unknown counts remain undisclosed.
|
|
3
|
+
Declare controls once in the view's `variables`; `<DataApp view={view}>` renders
|
|
4
|
+
them and owns URL state. Use flat operation inputs matching variable names and
|
|
5
|
+
resolved types. Derive SQL parameters inside the operation.
|
|
20
6
|
|
|
21
7
|
## Declare controls once
|
|
22
8
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
and keeps their values in the URL.
|
|
26
|
-
Set `showSearch={false}` or `showFilters={false}` on `<DataApp>` to hide the
|
|
27
|
-
corresponding region while preserving its values; `showFilters` includes display options.
|
|
9
|
+
The starter's operation accepts `{ groupName: string }`, so it needs no `input`
|
|
10
|
+
mapper or explicit `bindings`:
|
|
28
11
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Declaring dataset `suggestions` enables autocomplete automatically. Use it when
|
|
34
|
-
record titles are useful query completions; omit it for aggregate datasets or when
|
|
35
|
-
completion would not help. No additional enabling prop is needed.
|
|
36
|
-
|
|
37
|
-
The app-owned `customers` operation accepts `{ q: string }` and returns `{ rows }`.
|
|
38
|
-
With your typed `client` and registered `dataContext`, connect the query to its
|
|
39
|
-
records and widgets:
|
|
12
|
+
```ts
|
|
13
|
+
// ... client and sampleDataContext
|
|
14
|
+
const { defineDataView } = createDataHooks(client);
|
|
40
15
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
operation: 'customers',
|
|
16
|
+
const sampleCountsView = defineDataView({
|
|
17
|
+
dataContext: sampleDataContext,
|
|
18
|
+
operation: 'sampleCountsByGroup',
|
|
45
19
|
variables: {
|
|
46
|
-
|
|
20
|
+
groupName: searchVariable({
|
|
21
|
+
key: 'group',
|
|
22
|
+
label: 'Group',
|
|
23
|
+
defaultValue: '',
|
|
24
|
+
}),
|
|
47
25
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
isEmpty:
|
|
51
|
-
emptyFallback: { title: 'No
|
|
26
|
+
describeInput: ({ groupName }) =>
|
|
27
|
+
groupName ? `group ${groupName}` : 'all groups',
|
|
28
|
+
isEmpty: rows => rows.length === 0,
|
|
29
|
+
emptyFallback: { title: 'No matching groups' },
|
|
52
30
|
});
|
|
53
|
-
const customers = view.dataset({
|
|
54
|
-
name: 'Customers',
|
|
55
|
-
select: data => data.rows,
|
|
56
|
-
rowKey: row => row.id,
|
|
57
|
-
columns: { name: { value: row => row.name } },
|
|
58
|
-
evidence: { id: 'customers', queryNames: ['customers'] },
|
|
59
|
-
suggestions: {
|
|
60
|
-
title: row => row.name,
|
|
61
|
-
description: row => row.country,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
const content = view.content(source => (
|
|
65
|
-
<TableWidget dataset={customers} source={source} />
|
|
66
|
-
));
|
|
67
|
-
|
|
68
|
-
<DataApp view={view} datasets={[customers]} story={story}>
|
|
69
|
-
<DataSection content={content} />
|
|
70
|
-
</DataApp>;
|
|
71
31
|
```
|
|
72
32
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
paginated sources offer suggestions only for supplied rows. Title matches rank
|
|
77
|
-
ahead of description matches; the five suggestion slots are shared across datasets. Selection completes the query with
|
|
78
|
-
the title; `suggestions.onSelect: row => openCustomer(row.id)` overrides completion
|
|
79
|
-
with an app action. `showSearchSuggestions` defaults to true; set it to false to
|
|
80
|
-
suppress autocomplete for a particular app.
|
|
33
|
+
Keep search local only when it filters already loaded rows. Add dataset
|
|
34
|
+
`suggestions` when record names make useful query completions; suggestions cover
|
|
35
|
+
supplied rows only.
|
|
81
36
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Declare controls in priority order for the user's task. Keep useful scope filters
|
|
85
|
-
visible and set `presentation.prominence: 'secondary'` for less frequent ones in
|
|
86
|
-
the Filters sheet. Active filter summaries reopen the same Filters sheet.
|
|
87
|
-
Choose useful defaults rather than exposing every field; declare each label once.
|
|
37
|
+
## Independent filters and chart breakdowns
|
|
88
38
|
|
|
89
|
-
|
|
90
|
-
appear separately from scope filters. Search remains separate from both.
|
|
39
|
+
For source-backed categorical members, use `dataApp.defineDimension()`:
|
|
91
40
|
|
|
92
41
|
```ts
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
label: 'Sort by',
|
|
101
|
-
options: [{ id: 'name', label: 'Customer name' }],
|
|
102
|
-
defaultValue: 'name',
|
|
103
|
-
presentation: { group: 'display' },
|
|
42
|
+
// ... dataApp with its registered groups query
|
|
43
|
+
const group = dataApp.defineDimension({
|
|
44
|
+
key: 'group',
|
|
45
|
+
label: 'Group',
|
|
46
|
+
valueType: 'string',
|
|
47
|
+
selectionMode: 'multiple',
|
|
48
|
+
source: { query: 'groups' },
|
|
104
49
|
});
|
|
50
|
+
const parseInput = variableInput(parseEmptyInput, { group });
|
|
105
51
|
```
|
|
106
52
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
snapshots or other input shapes.
|
|
53
|
+
Import `variableInput()` and `parseEmptyInput()` from `/contract`. Use `parseInput`
|
|
54
|
+
on the operation and declare the same `group` in the view's `variables`. Use an
|
|
55
|
+
app-owned base parser instead of `parseEmptyInput()` for other input fields.
|
|
111
56
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
period: input => input.filters.period,
|
|
123
|
-
region: input => input.filters.region,
|
|
124
|
-
},
|
|
125
|
-
isEmpty: data => data.rows.length === 0,
|
|
126
|
-
emptyFallback: { title: 'No activity' },
|
|
127
|
-
});
|
|
57
|
+
Declare the source query in `defineDataApp()` with a nullable `member` parameter
|
|
58
|
+
matching `valueType`. Its nonnullable projections are `value` (same type),
|
|
59
|
+
`label` (string), and optional `count` (number). Null requests options; a selected
|
|
60
|
+
member requests exact lookup. Other parameters need defaults or trusted values:
|
|
61
|
+
|
|
62
|
+
```sql
|
|
63
|
+
SELECT DISTINCT group_name AS value, group_name AS label
|
|
64
|
+
FROM sample_counts
|
|
65
|
+
WHERE ($member IS NULL OR group_name = $member)
|
|
66
|
+
ORDER BY label
|
|
128
67
|
```
|
|
129
68
|
|
|
130
|
-
|
|
131
|
-
|
|
69
|
+
Here `sample_counts` is the inspected table replacing the starter's fixture.
|
|
70
|
+
Validate these variables in every consuming operation, including details. Map
|
|
71
|
+
parsed predicates to declared query parameters; never interpolate filter values
|
|
72
|
+
into SQL. Each dimension is independent: changing one preserves other selections,
|
|
73
|
+
even when their combination returns no rows. No selection means all members.
|
|
74
|
+
|
|
75
|
+
### Chart breakdowns
|
|
132
76
|
|
|
133
|
-
|
|
77
|
+
Use `choiceVariable()` for a display choice, separately from population filters:
|
|
134
78
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
79
|
+
```ts
|
|
80
|
+
const countsBy = choiceVariable({
|
|
81
|
+
key: 'counts-by',
|
|
82
|
+
label: 'Counts breakdown',
|
|
83
|
+
defaultValue: 'group',
|
|
84
|
+
options: [
|
|
85
|
+
{ id: 'group', label: 'Group' },
|
|
86
|
+
{ id: 'country', label: 'Country' },
|
|
87
|
+
],
|
|
88
|
+
presentation: { group: 'display', control: 'widget' },
|
|
89
|
+
});
|
|
90
|
+
```
|
|
139
91
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
[direct UI composition](ui.md).
|
|
92
|
+
Pass `view.breakdown('countsBy')` to `<VisualizationWidget breakdown={...}>`.
|
|
93
|
+
Declare a separate choice for each independently controlled chart.
|
|
94
|
+
Use `presentation.prominence: 'secondary'` for less frequent scope filters.
|
|
144
95
|
|
|
145
96
|
## Fixed options and query-backed facets
|
|
146
97
|
|
|
147
|
-
|
|
98
|
+
Use `dimensionFilter()` from `/contract` when options are known constants:
|
|
148
99
|
|
|
149
100
|
```ts
|
|
150
|
-
const
|
|
151
|
-
key: '
|
|
152
|
-
label: '
|
|
101
|
+
const group = dimensionFilter({
|
|
102
|
+
key: 'group',
|
|
103
|
+
label: 'Group',
|
|
153
104
|
valueType: 'string',
|
|
154
105
|
selectionMode: 'multiple',
|
|
155
|
-
options: [
|
|
106
|
+
options: [
|
|
107
|
+
{ value: 'Alpha', label: 'Alpha' },
|
|
108
|
+
{ value: 'Beta', label: 'Beta' },
|
|
109
|
+
],
|
|
156
110
|
});
|
|
157
111
|
```
|
|
158
112
|
|
|
159
|
-
|
|
160
|
-
facet operation returns parsed dimension options. Its input mapper uses current
|
|
161
|
-
resolved variables, including other filters:
|
|
113
|
+
Use `defineFacetFilter()` only when options must depend on other selections:
|
|
162
114
|
|
|
163
115
|
```ts
|
|
116
|
+
// ... client and period variable
|
|
164
117
|
const { defineFacetFilter } = createDataHooks(client);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
const region = defineFacetFilter({
|
|
171
|
-
key: 'region',
|
|
172
|
-
label: 'Region',
|
|
118
|
+
|
|
119
|
+
const group = defineFacetFilter({
|
|
120
|
+
key: 'group',
|
|
121
|
+
label: 'Group',
|
|
173
122
|
valueType: 'string',
|
|
174
123
|
selectionMode: 'multiple',
|
|
175
124
|
facet: {
|
|
176
125
|
context: { period },
|
|
177
|
-
operation: '
|
|
126
|
+
operation: 'groups',
|
|
178
127
|
input: values => ({ period: values.period }),
|
|
179
128
|
},
|
|
180
129
|
});
|
|
181
130
|
```
|
|
182
131
|
|
|
183
|
-
Declare
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
For the operation's input parser, use `parseDimensionSelection(value, region)` from `/contract`.
|
|
187
|
-
A dimension without an explicit selection represents all members.
|
|
188
|
-
Map parsed selections to the query's declared parameters; do not construct SQL
|
|
189
|
-
from filter values. Choose selection modes supported by the registered query.
|
|
132
|
+
Declare `period` with `dateRangeVariable()`, include it alongside `group` in the view's variables,
|
|
133
|
+
and return parsed dimension options from the `groups` operation. Validate facet
|
|
134
|
+
selections with `parseDimensionSelection(value, group)` from `/contract`.
|
|
190
135
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
136
|
+
Use `single` for a replacement choice and `multiple` for independent members.
|
|
137
|
+
Enable `allowExclusion` only when the query supports exclusion and its intended
|
|
138
|
+
missing-value behavior. Use `multiChoiceVariable()` for fixed multiselect
|
|
139
|
+
choices; empty means no choices, unlike an unrestricted dimension.
|
|
195
140
|
|
|
196
|
-
##
|
|
141
|
+
## Reporting periods
|
|
197
142
|
|
|
198
|
-
`
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
collection means no choices; categorical filters use `dimensionFilter()` when
|
|
203
|
-
an empty selection should mean all records.
|
|
143
|
+
Use `defineTimeView()` when the analysis is period-driven. Obtain it from the
|
|
144
|
+
existing hooks factory and share a `defineDateRangeContract()` with the parser.
|
|
145
|
+
After adapting the operation to accept `{ period, groupName }`, the view can stay
|
|
146
|
+
flat:
|
|
204
147
|
|
|
205
148
|
```ts
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
metric: choiceVariable({
|
|
209
|
-
key: 'metric',
|
|
210
|
-
label: 'Metric',
|
|
211
|
-
defaultValue: 'orders',
|
|
212
|
-
options: [
|
|
213
|
-
{ id: 'orders', label: 'Orders' },
|
|
214
|
-
{ id: 'revenue', label: 'Revenue' },
|
|
215
|
-
],
|
|
216
|
-
}),
|
|
217
|
-
};
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
## Numeric and boolean predicates
|
|
149
|
+
// ... client, dailyCountsContext, and calendar contract
|
|
150
|
+
const { defineTimeView } = createDataHooks(client);
|
|
221
151
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
152
|
+
const dailyCountsView = defineTimeView({
|
|
153
|
+
dataContext: dailyCountsContext,
|
|
154
|
+
operation: 'dailyCountsByGroup',
|
|
155
|
+
time: { contract: calendar, defaultValue: { kind: 'preset', id: 'last-7' } },
|
|
156
|
+
variables: {
|
|
157
|
+
groupName: searchVariable({
|
|
158
|
+
key: 'group',
|
|
159
|
+
label: 'Group',
|
|
160
|
+
defaultValue: '',
|
|
161
|
+
}),
|
|
162
|
+
},
|
|
163
|
+
isEmpty: rows => rows.length === 0,
|
|
164
|
+
emptyFallback: { title: 'No matching groups' },
|
|
165
|
+
});
|
|
231
166
|
```
|
|
232
167
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
value. Invalid ranges disable Apply.
|
|
237
|
-
Input mappings and bindings must preserve these predicates unchanged, as with
|
|
238
|
-
categorical filters. Map parsed operators and values to declared query parameters;
|
|
239
|
-
offer only operators supported by the registered query.
|
|
240
|
-
|
|
241
|
-
## Exclusion, clear, and reset
|
|
242
|
-
|
|
243
|
-
Set `allowExclusion: true` on `dimensionFilter()` to support
|
|
244
|
-
`{ kind: 'exclude', members }`. `<DimensionPicker>` then exposes Include/Exclude
|
|
245
|
-
alongside selected members. Enable exclusion only when the registered query supports
|
|
246
|
-
it, including the intended behavior for missing values.
|
|
168
|
+
The operation's parser validates `period` with `calendar.parseRequest()`.
|
|
169
|
+
Without additional variables, the default input is the calendar request itself.
|
|
170
|
+
Use `defineDataView()` for fixed snapshots or analysis without a reporting period.
|
|
247
171
|
|
|
248
|
-
|
|
249
|
-
Clear search separately in its field.
|
|
250
|
-
`resetAll()` restores all
|
|
251
|
-
configured variable defaults, including fixed choices and periods. Nonempty
|
|
252
|
-
default filters can therefore be active immediately after Reset.
|
|
172
|
+
## Numeric and boolean predicates
|
|
253
173
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
174
|
+
Use `numberFilter()` or `booleanFilter()` from `/contract` for field predicates.
|
|
175
|
+
Declare them in `variables` and validate input with `parseNumberSelection()` or
|
|
176
|
+
`parseBooleanSelection()` using the same declarations. Both support
|
|
177
|
+
`{ kind: 'all' }`. Offer only predicates the registered query supports.
|
|
257
178
|
|
|
258
|
-
|
|
179
|
+
## Exclusion, clear, and reset
|
|
259
180
|
|
|
260
|
-
|
|
181
|
+
Clear removes scope predicates and returns dates to defaults, preserving search
|
|
182
|
+
and display choices. `resetAll()` restores all defaults. Filters apply immediately;
|
|
183
|
+
use app-owned drafts only when the task needs Apply/Cancel.
|
|
261
184
|
|
|
262
|
-
|
|
263
|
-
a region; changing or clearing Region preserves Country and Customer. Filters
|
|
264
|
-
combine in the operation's query. Incompatible selections can return an empty
|
|
265
|
-
result; keep the selections visible so readers can correct them.
|
|
185
|
+
## Adapt existing input shapes
|
|
266
186
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
app-owned base parser. Use it on every operation consuming these filters, including
|
|
270
|
-
details. Declare the same variables on the view and preserve them in operation input.
|
|
187
|
+
Add a mapper and bindings only when an existing operation requires nested or
|
|
188
|
+
differently named inputs. Preserve selected values unchanged in both directions:
|
|
271
189
|
|
|
272
190
|
```ts
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
label: 'Country',
|
|
276
|
-
valueType: 'string',
|
|
277
|
-
selectionMode: 'single',
|
|
278
|
-
presentation: { prominence: 'secondary' },
|
|
279
|
-
source: { query: 'countries' },
|
|
280
|
-
});
|
|
281
|
-
const revenueBy = choiceVariable({
|
|
282
|
-
key: 'revenue-by',
|
|
283
|
-
label: 'Revenue breakdown',
|
|
284
|
-
defaultValue: 'region',
|
|
285
|
-
options: [
|
|
286
|
-
{ id: 'region', label: 'Region' },
|
|
287
|
-
{ id: 'country', label: 'Country' },
|
|
288
|
-
],
|
|
289
|
-
presentation: { group: 'display', control: 'widget' },
|
|
290
|
-
});
|
|
291
|
-
const parseInput = variableInput(parsePeriodInput, { country, revenueBy });
|
|
292
|
-
```
|
|
191
|
+
// ... client; operation input is { filters: { period, groupName } }
|
|
192
|
+
const { defineTimeView } = createDataHooks(client);
|
|
293
193
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
nonnullable projections for `value` (the same type), `label` (string), and optional
|
|
305
|
-
`count` (number). `member = null` requests at most 200 options; a selected value requests
|
|
306
|
-
an exact lookup. Other query parameters need defaults or trusted server values.
|
|
307
|
-
Keep SQL and parameter declarations literal in `defineDataApp()`.
|
|
308
|
-
|
|
309
|
-
```sql
|
|
310
|
-
SELECT code AS value, name AS label
|
|
311
|
-
FROM countries
|
|
312
|
-
WHERE ($member IS NULL OR code = $member)
|
|
313
|
-
ORDER BY name
|
|
194
|
+
const dailyCountsView = defineTimeView({
|
|
195
|
+
// ... operation, dataContext, time, variables, isEmpty, and emptyFallback
|
|
196
|
+
input: values => ({
|
|
197
|
+
filters: { period: values.period, groupName: values.groupName },
|
|
198
|
+
}),
|
|
199
|
+
bindings: {
|
|
200
|
+
period: input => input.filters.period,
|
|
201
|
+
groupName: input => input.filters.groupName,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
314
204
|
```
|
|
315
205
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
it does not fetch additional members. Clear filters preserves search and display
|
|
320
|
-
choices and returns dates to their configured defaults.
|
|
206
|
+
Custom control ownership is needed only when generated controls cannot express
|
|
207
|
+
the requirement; use `/ui` for that case. Do not reuse reserved inspection,
|
|
208
|
+
presentation, or navigation URL keys.
|