@altertable/data-app-examples 0.75.0 → 0.77.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.
@@ -2,121 +2,149 @@ import {
2
2
  createDataHooks,
3
3
  DataApp,
4
4
  DataSection,
5
- VisualizationWidget,
6
- DataValue,
7
- TableWidget,
8
- Ranking,
5
+ MetricWidget,
9
6
  Stack,
10
- TextContent,
7
+ TableWidget,
8
+ VisualizationWidget,
11
9
  } from '@altertable/data-app-react';
10
+ import { BarChart, ComposedChart } from '@altertable/data-app-react/ui';
12
11
  import { createDataClient } from '@altertable/data-app/client';
13
12
 
14
13
  import { sampleDataContext } from '#app/data-context.ts';
14
+ import { operationFilters } from '#app/filters.ts';
15
15
  import type { operations } from '#app/operations.ts';
16
- const { defineDataView } =
17
- createDataHooks(createDataClient<typeof operations>());
18
- const sampleCountsView = defineDataView({
16
+ const { defineView } = createDataHooks(
17
+ createDataClient<typeof operations>({ filters: operationFilters })
18
+ );
19
+ const count = { kind: 'count' } as const;
20
+ const emptyFallback = {
21
+ title: 'No samples in this period',
22
+ description: 'No observations are available for this period.',
23
+ };
24
+ const totalView = defineView({
19
25
  dataContext: sampleDataContext,
20
- operation: 'sampleCountsByGroup',
21
- describeInput: () => 'fixture groups',
22
- isEmpty: sampleCounts => sampleCounts.length === 0,
23
- emptyFallback: {
24
- title: 'No matching groups',
25
- description: 'No observations are available for this query.',
26
+ operation: 'sampleTotal',
27
+ });
28
+ const totalSamples = totalView.metric(
29
+ {
30
+ id: 'total-samples',
31
+ label: 'Samples',
32
+ glossaryId: 'sampleCount',
33
+ format: count,
26
34
  },
35
+ total => ({
36
+ current: total.current,
37
+ ...(total.previous !== null && { previous: total.previous }),
38
+ })
39
+ );
40
+ const trendView = defineView({
41
+ dataContext: sampleDataContext,
42
+ operation: 'samplesOverTime',
43
+ isEmpty: rows => rows.length === 0,
44
+ emptyFallback,
27
45
  });
28
- const sampleCounts = sampleCountsView.dataset({
29
- name: 'Sample counts',
46
+ const trend = trendView.dataset({
47
+ name: 'Samples over time',
30
48
  select: rows => rows,
31
- rowKey: row => row.groupName,
49
+ rowKey: row => row.periodStart,
32
50
  columns: {
33
- groupName: { label: 'Group', value: row => row.groupName },
34
- sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
35
- },
36
- evidence: {
37
- id: 'counts-by-group',
38
- glossaryIds: ['sampleCount'],
51
+ periodStart: { label: 'Period start', value: row => row.periodStart },
52
+ sampleCount: { value: row => row.sampleCount, format: count },
39
53
  },
54
+ evidence: { id: 'samples-over-time', glossaryIds: ['sampleCount'] },
40
55
  });
41
- const totalSamples = sampleCountsView.metric(
42
- {
43
- id: 'total-samples',
44
- label: 'Total samples',
45
- glossaryId: 'sampleCount',
46
- format: { kind: 'count' },
56
+ const memberView = defineView({
57
+ dataContext: sampleDataContext,
58
+ operation: 'samplesByMember',
59
+ isEmpty: rows => rows.length === 0,
60
+ emptyFallback,
61
+ });
62
+ const byMember = memberView.dataset({
63
+ name: 'Samples by member',
64
+ select: rows => rows,
65
+ rowKey: row => row.member,
66
+ columns: {
67
+ member: { label: 'Member', value: row => row.member },
68
+ sampleCount: { value: row => row.sampleCount, format: count },
47
69
  },
48
- rows => ({ current: rows.reduce((sum, row) => sum + row.sampleCount, 0) })
49
- );
50
- const alphaSamples = sampleCountsView.metric(
51
- {
52
- id: 'alpha-samples',
53
- label: 'Alpha samples',
54
- glossaryId: 'sampleCount',
55
- format: { kind: 'count' },
70
+ evidence: { id: 'samples-by-member', glossaryIds: ['sampleCount'] },
71
+ });
72
+ const rowsView = defineView({
73
+ dataContext: sampleDataContext,
74
+ operation: 'sampleRows',
75
+ isEmpty: rows => rows.length === 0,
76
+ emptyFallback,
77
+ });
78
+ const sampleRows = rowsView.dataset({
79
+ name: 'Samples',
80
+ select: rows => rows,
81
+ rowKey: row => `${row.periodStart}:${row.member}`,
82
+ columns: {
83
+ periodStart: { label: 'Period start', value: row => row.periodStart },
84
+ member: { label: 'Member', value: row => row.member },
85
+ sampleCount: { value: row => row.sampleCount, format: count },
56
86
  },
57
- rows => {
58
- const alpha = rows.find(row => row.groupName === 'Alpha');
59
- if (!alpha)
60
- throw new Error('The sample Finding requires evidence for Alpha.');
61
- return { current: alpha.sampleCount };
62
- }
63
- );
64
- // This fictional Finding demonstrates prose, inline evidence, and a Markdown-table equivalent.
65
- // Preserve each real Finding's own headings and argument instead of reusing these sections.
66
- const sampleContent = sampleCountsView.content(result => (
67
- <Stack>
68
- <TextContent>
69
- <h2>Contribution by group</h2>
70
- <p>
71
- <strong>Alpha</strong> contributed{' '}
72
- <DataValue metric={alphaSamples} source={result} /> of the{' '}
73
- <DataValue metric={totalSamples} source={result} /> recorded samples.
74
- The group comparison below supports that concentration; it does not
75
- explain its cause.
76
- </p>
77
- </TextContent>
78
- <VisualizationWidget
79
- dataset={sampleCounts}
80
- source={result}
81
- title="Sample count"
82
- >
83
- {rows => (
84
- <Ranking
85
- aria-label="Samples by group"
86
- items={rows.map(row => ({
87
- id: row.groupName,
88
- label: row.groupName,
89
- value: row.sampleCount,
90
- }))}
91
- />
92
- )}
93
- </VisualizationWidget>
94
- <TextContent>
95
- <h2>Supporting evidence</h2>
96
- <p>
97
- The source rows are grouped by <code>group_name</code> and summed using{' '}
98
- <code>sample_count</code>. The table retains the exact values behind the
99
- comparison.
100
- </p>
101
- <ul>
102
- <li>Compare the groups within the same sample population.</li>
103
- <li>
104
- <em>Volume alone does not establish performance or causality.</em>
105
- </li>
106
- </ul>
107
- </TextContent>
108
- <TableWidget
109
- dataset={sampleCounts}
110
- source={result}
111
- title="Counts by group"
112
- pagination={false}
113
- />
114
- </Stack>
87
+ evidence: { id: 'samples', glossaryIds: ['sampleCount'] },
88
+ });
89
+ // The Finding's text is shown above the app; keep content to charts and captions.
90
+ const totalContent = totalView.content(result => (
91
+ <MetricWidget metric={totalSamples} source={result} />
92
+ ));
93
+ const trendContent = trendView.content(result => (
94
+ <VisualizationWidget
95
+ dataset={trend}
96
+ source={result}
97
+ title="Samples over time"
98
+ description="Includes the previous period when comparison is on."
99
+ breakdown={trendView.breakdown('grain')}
100
+ >
101
+ {rows => (
102
+ <ComposedChart
103
+ ariaLabel="Samples over time"
104
+ data={rows}
105
+ valueFormat={count}
106
+ >
107
+ <ComposedChart.XAxis dataKey="periodStart" />
108
+ <ComposedChart.YAxis />
109
+ <ComposedChart.Line dataKey="sampleCount" name="Samples" />
110
+ <ComposedChart.Tooltip />
111
+ </ComposedChart>
112
+ )}
113
+ </VisualizationWidget>
114
+ ));
115
+ const memberContent = memberView.content(result => (
116
+ <VisualizationWidget
117
+ dataset={byMember}
118
+ source={result}
119
+ title="Samples by member"
120
+ breakdown={memberView.breakdown('breakdown')}
121
+ >
122
+ {rows => (
123
+ <BarChart
124
+ ariaLabel="Samples by member"
125
+ unit="samples"
126
+ items={rows.map(row => ({
127
+ ...row,
128
+ id: row.member,
129
+ label: row.member,
130
+ value: row.sampleCount,
131
+ }))}
132
+ />
133
+ )}
134
+ </VisualizationWidget>
135
+ ));
136
+ const rowsContent = rowsView.content(result => (
137
+ <TableWidget dataset={sampleRows} source={result} title="Samples" />
115
138
  ));
116
139
  export function App() {
117
140
  return (
118
- <DataApp view={sampleCountsView} showToolbar={false}>
119
- <DataSection content={sampleContent} />
141
+ <DataApp view={totalView} showToolbar={false}>
142
+ <Stack>
143
+ <DataSection content={totalContent} />
144
+ <DataSection content={trendContent} />
145
+ <DataSection content={memberContent} />
146
+ <DataSection content={rowsContent} />
147
+ </Stack>
120
148
  </DataApp>
121
149
  );
122
150
  }
@@ -1,13 +1,19 @@
1
1
  import { createDataContext } from '@altertable/data-app-react';
2
- const queryNames = { sampleCountsByGroup: 'sampleCountsByGroup' } as const;
2
+ // The browser imports operations by type only, so name their queries here.
3
+ const queryNames = {
4
+ sampleTotal: 'sampleTotal',
5
+ samplesOverTime: 'samplesOverTime',
6
+ samplesByMember: 'samplesByMember',
7
+ sampleRows: 'sampleRows',
8
+ } as const;
3
9
  export const sampleDataContext = createDataContext(queryNames)({
4
10
  description:
5
- 'Fictional sample volumes grouped from starter_demo.sample_counts. Replace this evidence with the actual Finding queries.',
11
+ 'Fictional daily samples from starter_demo.daily_samples. Replace this evidence with the actual Finding queries.',
6
12
  glossary: {
7
13
  sampleCount: {
8
14
  term: 'Sample count',
9
- definition: 'A fixture value: Alpha is 2,200,000 and Beta is 600,000.',
10
- queryNames: [queryNames.sampleCountsByGroup],
15
+ definition: 'Fixture samples recorded per day, group, and segment.',
16
+ queryNames: Object.values(queryNames),
11
17
  },
12
18
  },
13
19
  });
@@ -0,0 +1,48 @@
1
+ import {
2
+ dateTimeRangeFilter,
3
+ displayChoice,
4
+ } from '@altertable/data-app/contract';
5
+
6
+ // Declare each filter once in this browser-safe module: operations read them on
7
+ // the server, and the browser client renders their controls.
8
+ const findingPeriod = {
9
+ from: new Date('2026-03-09T00:00:00Z'),
10
+ to: new Date('2026-03-16T00:00:00Z'),
11
+ };
12
+ const period = dateTimeRangeFilter({
13
+ key: 'period',
14
+ defaultValue: findingPeriod,
15
+ minDate: '2026-01-05',
16
+ maxDate: '2026-03-29',
17
+ maxRangeDays: 28,
18
+ comparison: 'off',
19
+ presets: [{ label: 'Finding period', range: findingPeriod }],
20
+ });
21
+ const grain = displayChoice({
22
+ key: 'grain',
23
+ label: 'Grain',
24
+ defaultValue: 'day',
25
+ options: [
26
+ { id: 'day', label: 'Day' },
27
+ { id: 'week', label: 'Week' },
28
+ ],
29
+ presentation: { control: 'widget' },
30
+ });
31
+ const breakdown = displayChoice({
32
+ key: 'breakdown',
33
+ label: 'Breakdown',
34
+ defaultValue: 'segment',
35
+ options: [
36
+ { id: 'segment', label: 'Segment' },
37
+ { id: 'group', label: 'Group' },
38
+ ],
39
+ presentation: { control: 'widget' },
40
+ });
41
+
42
+ /** The filters each operation reads. */
43
+ export const operationFilters = {
44
+ sampleTotal: { period },
45
+ samplesOverTime: { period, grain },
46
+ samplesByMember: { period, breakdown },
47
+ sampleRows: { period, grain, breakdown },
48
+ };
@@ -1,15 +1,66 @@
1
1
  import { parseCount } from '@altertable/data-app/contract';
2
2
 
3
+ import { operationFilters } from '#app/filters.ts';
3
4
  import { dataApp } from '#config';
5
+ // One query per widget: each section loads its own result when it nears the viewport.
6
+ const policy = { maxQueryRows: 500, maxDurationMs: 15000 };
4
7
  export const operations = {
5
- sampleCountsByGroup: dataApp.defineOperation({
6
- input: () => ({}),
7
- checks: [{}],
8
- policy: { maxQueryRows: 10, maxDurationMs: 15000 },
9
- async run({ query }) {
10
- const result = await query('sampleCountsByGroup', {});
8
+ sampleTotal: dataApp.defineOperation({
9
+ filters: operationFilters.sampleTotal,
10
+ policy,
11
+ async run({ query }, { period }) {
12
+ const current = await query('sampleTotal', { period: period.range });
13
+ const previous = period.comparison
14
+ ? await query('sampleTotal', { period: period.comparison })
15
+ : null;
16
+ return {
17
+ current: parseCount(current.rows[0]!.sample_count),
18
+ previous: previous && parseCount(previous.rows[0]!.sample_count),
19
+ };
20
+ },
21
+ }),
22
+ samplesOverTime: dataApp.defineOperation({
23
+ filters: operationFilters.samplesOverTime,
24
+ policy,
25
+ async run({ query }, { period, grain }) {
26
+ // With the comparison on, the trend starts at the previous period.
27
+ const range = {
28
+ from: period.comparison?.from ?? period.range.from,
29
+ to: period.range.to,
30
+ };
31
+ const result = await query('samplesOverTime', { period: range, grain });
32
+ return result.rows.map(row => ({
33
+ periodStart: row.period_start,
34
+ sampleCount: parseCount(row.sample_count),
35
+ }));
36
+ },
37
+ }),
38
+ samplesByMember: dataApp.defineOperation({
39
+ filters: operationFilters.samplesByMember,
40
+ policy,
41
+ async run({ query }, { period, breakdown }) {
42
+ const result = await query('samplesByMember', {
43
+ period: period.range,
44
+ breakdown,
45
+ });
46
+ return result.rows.map(row => ({
47
+ member: row.member,
48
+ sampleCount: parseCount(row.sample_count),
49
+ }));
50
+ },
51
+ }),
52
+ sampleRows: dataApp.defineOperation({
53
+ filters: operationFilters.sampleRows,
54
+ policy,
55
+ async run({ query }, { period, grain, breakdown }) {
56
+ const result = await query('sampleRows', {
57
+ period: period.range,
58
+ grain,
59
+ breakdown,
60
+ });
11
61
  return result.rows.map(row => ({
12
- groupName: row.group_name,
62
+ periodStart: row.period_start,
63
+ member: row.member,
13
64
  sampleCount: parseCount(row.sample_count),
14
65
  }));
15
66
  },
@@ -2,16 +2,16 @@
2
2
 
3
3
  Read `node_modules/@altertable/data-app/docs/app-authoring.md` and use this project
4
4
  as the selected scaffold. If dependencies are unavailable, read the
5
- [version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.75.0/docs/app-authoring.md). <!-- x-release-please-version -->
5
+ [version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.77.0/docs/app-authoring.md). <!-- x-release-please-version -->
6
6
 
7
- | Task | App-owned files |
8
- | ------------------------------------------ | -------------------------------------------------------- |
9
- | Define queries and inputs | `app.ts`, `src/operations.ts`, optional shared contracts |
10
- | Compose app content and supported features | `src/App.tsx` |
11
- | Bind definitions and source evidence | `src/data-context.ts` |
12
- | Change identity and appearance | `app.ts` |
13
- | Inject styles and mount React | `src/main.tsx` |
14
- | Configure local serving | `src/server.ts` |
7
+ | Task | App-owned files |
8
+ | ------------------------------------------ | ----------------------------------------------- |
9
+ | Define queries, filters, and operations | `app.ts`, `src/filters.ts`, `src/operations.ts` |
10
+ | Compose app content and supported features | `src/App.tsx` |
11
+ | Bind definitions and source evidence | `src/data-context.ts` |
12
+ | Change identity and appearance | `app.ts` |
13
+ | Inject styles and mount React | `src/main.tsx` |
14
+ | Configure local serving | `src/server.ts` |
15
15
 
16
16
  See [README.md](README.md) for setup and checks.
17
17
 
@@ -1,11 +1,11 @@
1
1
  # Local metric data app starter
2
2
 
3
3
  Use `node_modules/@altertable/data-app/docs/app-authoring.md` for this SDK version.
4
- Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.75.0/docs/app-authoring.md). <!-- x-release-please-version -->
4
+ Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.77.0/docs/app-authoring.md). <!-- x-release-please-version -->
5
5
  See [AGENTS.md](AGENTS.md) for app-owned files.
6
6
 
7
7
  The example queries require the seeded sample data described in the
8
- [local preview guide](https://github.com/altertable-ai/data-app/blob/v0.75.0/docs/local-data-apps.md#preview-the-use-case-starters). <!-- x-release-please-version -->
8
+ [local preview guide](https://github.com/altertable-ai/data-app/blob/v0.77.0/docs/local-data-apps.md#preview-the-use-case-starters). <!-- x-release-please-version -->
9
9
  Use that mock for development, or replace the example queries with verified data
10
10
  in your lakehouse. The starter does not install a mock or create demo tables.
11
11
 
@@ -17,9 +17,9 @@
17
17
  "lint:fix": "oxlint --type-aware --fix src"
18
18
  },
19
19
  "dependencies": {
20
- "@altertable/data-app": "0.75.0",
21
- "@altertable/data-app-bun": "0.75.0",
22
- "@altertable/data-app-react": "0.75.0",
20
+ "@altertable/data-app": "0.77.0",
21
+ "@altertable/data-app-bun": "0.77.0",
22
+ "@altertable/data-app-react": "0.77.0",
23
23
  "react": "19.3.1",
24
24
  "react-dom": "19.3.1"
25
25
  },
@@ -4,33 +4,20 @@ import {
4
4
  DataSection,
5
5
  VisualizationWidget,
6
6
  Stack,
7
- choiceVariable,
8
7
  } from '@altertable/data-app-react';
9
8
  import { BarChart } from '@altertable/data-app-react/ui';
10
9
  import { createDataClient } from '@altertable/data-app/client';
11
10
 
12
11
  import { sampleDataContext } from '#app/data-context.ts';
12
+ import { operationFilters } from '#app/filters.ts';
13
13
  import type { operations } from '#app/operations.ts';
14
- const { defineDataView } =
15
- createDataHooks(createDataClient<typeof operations>());
16
- const sampleCountsView = defineDataView({
14
+ const { defineView } = createDataHooks(
15
+ createDataClient<typeof operations>({ filters: operationFilters })
16
+ );
17
+ const sampleCountsView = defineView({
17
18
  dataContext: sampleDataContext,
18
19
  operation: 'sampleCountsByGroup',
19
- variables: {
20
- groupName: choiceVariable({
21
- key: 'group',
22
- label: 'Group',
23
- defaultValue: 'all',
24
- options: [
25
- { id: 'all', label: 'All groups' },
26
- { id: 'Alpha', label: 'Alpha' },
27
- { id: 'Beta', label: 'Beta' },
28
- ],
29
- }),
30
- },
31
- describeInput: ({ groupName }) =>
32
- groupName === 'all' ? 'all groups' : groupName,
33
- isEmpty: result => result.groups.length === 0,
20
+ isEmpty: rows => rows.length === 0,
34
21
  emptyFallback: {
35
22
  title: 'No matching groups',
36
23
  description: 'No observations are available for this query.',
@@ -38,7 +25,7 @@ const sampleCountsView = defineDataView({
38
25
  });
39
26
  const sampleCounts = sampleCountsView.dataset({
40
27
  name: 'Sample counts',
41
- select: result => result.groups,
28
+ select: rows => rows,
42
29
  rowKey: row => row.groupName,
43
30
  columns: {
44
31
  groupName: { label: 'Group', value: row => row.groupName },
@@ -49,9 +36,18 @@ const sampleCounts = sampleCountsView.dataset({
49
36
  glossaryIds: ['sampleCount'],
50
37
  },
51
38
  });
52
- const segments = sampleCountsView.dataset({
39
+ const segmentCountsView = defineView({
40
+ dataContext: sampleDataContext,
41
+ operation: 'sampleCountsBySegment',
42
+ isEmpty: rows => rows.length === 0,
43
+ emptyFallback: {
44
+ title: 'No matching segments',
45
+ description: 'No observations are available for this query.',
46
+ },
47
+ });
48
+ const segmentCounts = segmentCountsView.dataset({
53
49
  name: 'Counts by segment',
54
- select: result => result.segments,
50
+ select: rows => rows,
55
51
  rowKey: row => row.segmentName,
56
52
  columns: {
57
53
  segmentName: { label: 'Segment', value: row => row.segmentName },
@@ -70,55 +66,58 @@ const groupActions = sampleCounts.actions(
70
66
  { primary: 'drill' }
71
67
  );
72
68
  // Keep only the breakdowns and interactions relevant to the requested metric.
73
- const sampleContent = sampleCountsView.content(result => (
74
- <Stack>
75
- <VisualizationWidget
76
- dataset={sampleCounts}
77
- source={result}
78
- title="Sample count"
79
- description="Select a group to filter both charts; choose All groups to reset."
80
- actions={groupActions}
81
- >
82
- {(rows, actions) => (
83
- <BarChart
84
- ariaLabel="Sample counts by group"
85
- unit="samples"
86
- items={rows.map(row => ({
87
- ...row,
88
- id: row.groupName,
89
- label: row.groupName,
90
- value: row.sampleCount,
91
- }))}
92
- itemActions={actions}
93
- />
94
- )}
95
- </VisualizationWidget>
96
- <VisualizationWidget
97
- dataset={segments}
98
- source={result}
99
- title="Samples by segment"
100
- description="Segment breakdown for the selected group scope."
101
- >
102
- {(rows, actions) => (
103
- <BarChart
104
- ariaLabel="Sample counts by segment"
105
- unit="samples"
106
- items={rows.map(row => ({
107
- ...row,
108
- id: row.segmentName,
109
- label: row.segmentName,
110
- value: row.sampleCount,
111
- }))}
112
- itemActions={actions}
113
- />
114
- )}
115
- </VisualizationWidget>
116
- </Stack>
69
+ const groupContent = sampleCountsView.content(result => (
70
+ <VisualizationWidget
71
+ dataset={sampleCounts}
72
+ source={result}
73
+ title="Sample count"
74
+ description="Select a group to filter both charts; choose All groups to reset."
75
+ actions={groupActions}
76
+ >
77
+ {(rows, actions) => (
78
+ <BarChart
79
+ ariaLabel="Sample counts by group"
80
+ unit="samples"
81
+ items={rows.map(row => ({
82
+ ...row,
83
+ id: row.groupName,
84
+ label: row.groupName,
85
+ value: row.sampleCount,
86
+ }))}
87
+ itemActions={actions}
88
+ />
89
+ )}
90
+ </VisualizationWidget>
91
+ ));
92
+ const segmentContent = segmentCountsView.content(result => (
93
+ <VisualizationWidget
94
+ dataset={segmentCounts}
95
+ source={result}
96
+ title="Samples by segment"
97
+ description="Segment breakdown for the selected group scope."
98
+ >
99
+ {(rows, actions) => (
100
+ <BarChart
101
+ ariaLabel="Sample counts by segment"
102
+ unit="samples"
103
+ items={rows.map(row => ({
104
+ ...row,
105
+ id: row.segmentName,
106
+ label: row.segmentName,
107
+ value: row.sampleCount,
108
+ }))}
109
+ itemActions={actions}
110
+ />
111
+ )}
112
+ </VisualizationWidget>
117
113
  ));
118
114
  export function App() {
119
115
  return (
120
116
  <DataApp view={sampleCountsView} showToolbar={false}>
121
- <DataSection content={sampleContent} />
117
+ <Stack>
118
+ <DataSection content={groupContent} label="Sample count" />
119
+ <DataSection content={segmentContent} label="Samples by segment" />
120
+ </Stack>
122
121
  </DataApp>
123
122
  );
124
123
  }
@@ -0,0 +1,20 @@
1
+ import { choiceFilter } from '@altertable/data-app/contract';
2
+
3
+ // Declare each filter once in this browser-safe module: operations read them on
4
+ // the server, and the browser client renders their controls.
5
+ const groupName = choiceFilter({
6
+ key: 'group',
7
+ label: 'Group',
8
+ defaultValue: 'all',
9
+ options: [
10
+ { id: 'all', label: 'All groups' },
11
+ { id: 'Alpha', label: 'Alpha' },
12
+ { id: 'Beta', label: 'Beta' },
13
+ ],
14
+ });
15
+
16
+ /** The filters each operation reads. */
17
+ export const operationFilters = {
18
+ sampleCountsByGroup: { groupName },
19
+ sampleCountsBySegment: { groupName },
20
+ };