@altertable/data-app-react 0.76.0 → 0.78.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.
@@ -1,9 +1,9 @@
1
- import { $ as mountDataApp, $t as StoryFinding, A as DataAppControlProps, B as DateTimeRangePreset, E as MetricWidgetProps$1, Et as SearchSuggestion, F as ChoiceVariable, G as VariablePresentation, H as DateTimeRangeVariableOptions, I as DateTimeRangeComparisonRequest, J as dateTimeRangeVariable, Jt as DataContext, K as choiceVariable, L as DateTimeRangeComparisonSelection, Lt as ItemActions, M as AppVariable, N as AppVariableValues, Nt as CsvTable, O as DataValueProps$1, P as ChoiceOption, R as DateTimeRangeComparisonVariable, Rt as EmptyContent, S as TextWidgetProps$1, U as MultiChoiceVariable, V as DateTimeRangeVariable, W as SearchVariable, X as searchVariable, Xt as GlossaryEntry, Y as multiChoiceVariable, Yt as EvidenceDeclaration, Zt as createDataContext, _ as HelpPopoverProps, a as DateDisplay, an as DataIdentifierDefinition, at as TableDisplayMode, b as VisualizationWidgetView$1, c as SectionHeadingProps, cn as Button, ct as TableWidgetProps$1, d as TooltipProvider, et as DataAppStyle, f as TooltipProviderProps, i as useDateFormatting, in as ColumnIdentifier, it as injectDataAppStyles, jt as CsvCell, k as DataAppBaseProps, l as Tooltip, ln as ButtonProps, lt as TableWidgetSearch, m as AppIconName, n as DateTimeRangePickerProps, nn as MetricDefinition, nt as DataAppStyleToken, o as DateDisplayProps, on as TableIdentifier, q as dateTimeRangePresets, qt as AuthoringDataContext, rn as MetricComparison, rt as DataAppStylesOptions, s as SectionHeading, sn as defineDataIdentifiers, st as TableWidgetColumn, t as DateTimeRangePicker, tt as DataAppStyleHooks, u as TooltipProps, y as VisualizationWidgetProps$1, z as DateTimeRangeComparisonVariableOptions, zt as WidgetEvidence } from "./chunks/DateTimeRangePicker.js";
1
+ import { $ as TableWidgetSearch, $t as TableIdentifier, A as NoticeProps, At as DataContext, Ct as CsvTable, Dt as ItemActions, E as MetricWidgetProps$1, F as DateTimeRangeFilter, Ft as StoryFinding, G as DataAppStyleHooks, J as injectDataAppStyles, Jt as ButtonProps, K as DataAppStyleToken, M as DataAppControlProps, Mt as GlossaryEntry, Nt as createDataContext, O as DataValueProps$1, Ot as EmptyContent, Q as TableWidgetProps$1, Qt as DataIdentifierDefinition, Rt as MetricDefinition, S as TextWidgetProps$1, U as mountDataApp, W as DataAppStyle, Xt as MetricComparison, Y as TableDisplayMode, Z as TableWidgetColumn, Zt as ColumnIdentifier, _ as HelpPopoverProps, a as DateDisplay, b as VisualizationWidgetView$1, c as SectionHeadingProps, d as TooltipProvider, en as defineDataIdentifiers, f as TooltipProviderProps, gt as SearchSuggestion, i as useDateFormatting, j as DataAppBaseProps, jt as EvidenceDeclaration, k as Notice, kt as AuthoringDataContext, l as Tooltip, m as AppIconName, n as DateTimeRangePickerProps, o as DateDisplayProps, q as DataAppStylesOptions, qt as Button, s as SectionHeading, t as DateTimeRangePicker, u as TooltipProps, xt as CsvCell, y as VisualizationWidgetProps$1, zt as WidgetEvidence } from "./chunks/DateTimeRangePicker.js";
2
2
  import { DataClient, InputOf, OutputOf } from "@altertable/data-app/client";
3
- import { AppVariableValues as AppVariableValues$1, CheckedFacetContexts, CheckedVariableDeclarations, ChoiceVariable as ChoiceVariable$1, DataReading, DataView, DimensionFilterSettings, DimensionValue, DisplayedSnapshot, FacetVariable, IsUnion, MetricReading, MetricValues, MetricValues as MetricValues$1, VariableCollection } from "@altertable/data-app/internal";
3
+ import { ChoiceFilter, DataReading, DataView, DisplayedSnapshot, FilterCollection, FilterInput, FilterValues, IsUnion, MetricReading, MetricValues, MetricValues as MetricValues$1 } from "@altertable/data-app/internal";
4
4
  import { ComponentPropsWithRef, ReactNode, Ref, RefObject } from "react";
5
- import { DataAppAnnotationDraft, DataOperations, DateTimeRangeComparisonRequest as DateTimeRangeComparisonRequest$1, DateTimeRangeComparisonVariable as DateTimeRangeComparisonVariable$1, DimensionOption, DisclosedQuery, ReportingPeriod, ReportingPeriod as ReportingPeriod$1 } from "@altertable/data-app/contract";
6
5
  import { DateFormat, MetricFormat } from "@altertable/data-app/format";
6
+ import { DataAppAnnotationDraft, DataOperations, DateTimeRangeInput, DisclosedQuery, ReportingPeriod, ReportingPeriod as ReportingPeriod$1 } from "@altertable/data-app/contract";
7
7
  import { Theme } from "@altertable/data-app/appearance";
8
8
  //#region src/view-runtime.d.ts
9
9
  type ViewResult<Data, Input> = {
@@ -15,19 +15,78 @@ type ViewResult<Data, Input> = {
15
15
  cancel: () => unknown;
16
16
  refreshing: boolean;
17
17
  queries?: DisclosedQuery[];
18
- searchControls?: ReactNode;
19
- filterControls?: ReactNode;
20
18
  emptyFallback: EmptyContent;
21
19
  };
20
+ /** Whether the view may send its request now. A disabled view stays loading until enabled. */
21
+ type ViewRequest = {
22
+ enabled: boolean;
23
+ };
22
24
  /** The executor is private; declarations expose data composition, not subscription hooks. */
23
25
  declare class DeclaredView<Data, Input, Definition = unknown> {
24
26
  #private;
25
- constructor(useResult: () => ViewResult<Data, Input>, definition?: Definition);
27
+ constructor(useResult: (request: ViewRequest) => ViewResult<Data, Input>, definition?: Definition);
26
28
  static definition<Data, Input, Definition>(view: DeclaredView<Data, Input, Definition>): Definition;
27
- static useResult<View extends DeclaredView<unknown, unknown>>(view: View): DeclaredViewResult<View>;
29
+ static useResult<View extends DeclaredView<unknown, unknown>>(view: View, request: ViewRequest): DeclaredViewResult<View>;
28
30
  }
29
31
  /** Distribute across declarations so each result keeps its own data and input together. */
30
32
  type DeclaredViewResult<View> = View extends DeclaredView<infer Data, infer Input> ? ViewResult<Data, Input> : never;
33
+ type FilterControls = {
34
+ searchControls: ReactNode;
35
+ filterControls: ReactNode;
36
+ };
37
+ /** Every filter one client's operations read, and the hook rendering their controls. */
38
+ type ClientFilters = {
39
+ filters: FilterCollection;
40
+ useControls: () => FilterControls;
41
+ };
42
+ //#endregion
43
+ //#region src/content.d.ts
44
+ type DataContentState<Data, Input> = {
45
+ scope: DataReading<string>;
46
+ } & ({
47
+ loading: true;
48
+ data?: never;
49
+ input?: never;
50
+ } | {
51
+ loading: false;
52
+ data: Data;
53
+ input: Input;
54
+ });
55
+ /** A section's request owner and render layout are declared together. */
56
+ declare class ViewContent<Data, Input> {
57
+ #private;
58
+ constructor(view: DeclaredView<Data, Input>, render: (source: DataContentState<Data, Input>) => ReactNode, describeInput: (input: Input) => string);
59
+ static section<Data, Input>(content: ViewContent<Data, Input>): {
60
+ loadingFallback: ReactNode;
61
+ children(this: void, data: Data, input: Input): ReactNode;
62
+ view: DeclaredView<Data, Input, unknown>;
63
+ };
64
+ }
65
+ //#endregion
66
+ //#region src/view.d.ts
67
+ type ViewDefinition<Name extends string, Input, Data> = {
68
+ operation: Name;
69
+ dataContext: DataContext;
70
+ /** Describe the displayed scope in prose. Defaults to the reporting period and each
71
+ * narrowed filter, such as `Mar 1–7, 2026 UTC · group Alpha`, or `all data`. */
72
+ describeInput?: (input: Input) => string;
73
+ } & ViewEmptiness<Data>;
74
+ /** A view with everything derived from its operation's filters. */
75
+ type ResolvedViewDefinition<Name extends string, Filters extends FilterCollection, Data> = Required<ViewEmptiness<Data>> & {
76
+ operation: Name;
77
+ dataContext: DataContext;
78
+ filters: Filters;
79
+ describeInput: (input: FilterInput<Filters>) => string;
80
+ /** The operation's date filter, which sets the reporting period. */
81
+ dateFilter?: keyof Filters & string;
82
+ };
83
+ /** Omit both for a result that is never empty, such as a total. */
84
+ type ViewEmptiness<Data> = {
85
+ /** App-owned semantics: measured zero need not mean an empty result. Defaults to never empty. */
86
+ isEmpty?: (data: Data) => boolean;
87
+ /** Inherited by DataSection unless it supplies its own copy. */
88
+ emptyFallback?: EmptyContent;
89
+ };
31
90
  //#endregion
32
91
  //#region src/details.d.ts
33
92
  type DetailViewDefinition<Data, Input> = {
@@ -35,82 +94,42 @@ type DetailViewDefinition<Data, Input> = {
35
94
  title: ReactNode;
36
95
  /** Validates untrusted navigation input before a detail operation can run. */
37
96
  parseInput: (input: unknown) => Input;
38
- describeInput: (input: Input) => string;
39
- isEmpty: (data: Data) => boolean;
40
- emptyFallback: EmptyContent;
41
- };
42
- /** A typed, query-backed destination. */
43
- export declare class DetailView<Data, Input> {
97
+ /** Describe the destination's scope. Defaults to the filters its operation reads;
98
+ * supply it to name the record, such as `orders for Customer 042`. */
99
+ describeInput?: (input: Input) => string;
100
+ } & ViewEmptiness<Data>;
101
+ /** A typed, query-backed destination. Interactions supply its own fields (`Own`);
102
+ * the filters its operation reads carry over from the displayed scope. */
103
+ export declare class DetailView<Data, Input, Own = Input> {
44
104
  #private;
45
- readonly definition: DetailViewDefinition<Data, Input>;
105
+ readonly definition: DetailViewDefinition<Data, Input> & Required<ViewEmptiness<Data>> & {
106
+ describeInput: (input: Input) => string;
107
+ };
46
108
  readonly useResult: (input: Input) => ViewResult<Data, Input>;
47
- constructor(definition: DetailViewDefinition<Data, Input>, useResult: (input: Input) => ViewResult<Data, Input>);
48
- content(render: (source: ViewSource<Data, Input>) => ReactNode): DetailContent<Data, Input>;
49
- static content<Data, Input>(target: DetailView<Data, Input>): DetailContent<Data, Input>;
109
+ readonly ownInput?: Own;
110
+ constructor(definition: DetailViewDefinition<Data, Input> & Required<ViewEmptiness<Data>> & {
111
+ describeInput: (input: Input) => string;
112
+ }, useResult: (input: Input) => ViewResult<Data, Input>, filters?: FilterCollection);
113
+ /** The destination input: each filter it reads as displayed (or as currently
114
+ * selected when the source does not read it), then the interaction's own fields
115
+ * and narrowed filters. */
116
+ static inputFrom(target: DetailView<any, any, any>, own: object, displayedInput: unknown): unknown;
117
+ /** Render like view content: displayed data, its input, and the derived scope. */
118
+ content(render: (state: DataContentState<Data, Input>) => ReactNode): DetailContent<Data, Input>;
119
+ static content<Data, Input>(target: DetailView<Data, Input, any>): DetailContent<Data, Input>;
50
120
  }
51
121
  /** A destination’s rendered body. Pass these to DataApp.details. */
52
122
  export declare class DetailContent<Data, Input> {
53
- readonly target: DetailView<Data, Input>;
54
- readonly render: (source: ViewSource<Data, Input>) => ReactNode;
55
- constructor(target: DetailView<Data, Input>, render: (source: ViewSource<Data, Input>) => ReactNode);
123
+ readonly target: DetailView<Data, Input, any>;
124
+ readonly render: (state: DataContentState<Data, Input>) => ReactNode;
125
+ constructor(target: DetailView<Data, Input, any>, render: (state: DataContentState<Data, Input>) => ReactNode);
56
126
  }
57
127
  type DetailNavigation = {
58
- open<Data, Input>(target: DetailView<Data, Input>, input: Input, trigger?: HTMLElement | SVGElement | null): void;
128
+ open<Data, Input>(target: DetailView<Data, Input, any>, input: Input, trigger?: HTMLElement | SVGElement | null): void;
59
129
  };
60
130
  /** Resolve a detail target from an interaction. The destination validates input before fetching. */
61
131
  export declare function useDetailNavigation(): DetailNavigation;
62
132
  //#endregion
63
- //#region src/view.d.ts
64
- type ResolvedVariable<Variable> = Variable extends DateTimeRangeComparisonVariable$1 ? DateTimeRangeComparisonRequest$1 : AppVariableValues$1<{
65
- value: Variable;
66
- }>['value'];
67
- type ResolvedVariables<Variables extends VariableCollection> = { [Key in keyof Variables]: ResolvedVariable<Variables[Key]> | (string extends keyof Variables ? undefined : never); };
68
- type DateVariableKey<Variables extends VariableCollection> = { [Key in keyof Variables]: Variables[Key] extends DateTimeRangeComparisonVariable$1 ? Key : never; }[keyof Variables] & string;
69
- /** Extract the selected range and comparison unchanged, including from nested inputs. */
70
- type ViewDate<Variables extends VariableCollection, Input> = {
71
- variable: DateVariableKey<Variables>;
72
- input: (input: Input) => DateTimeRangeComparisonRequest$1;
73
- };
74
- /** Read variable values from a custom operation input; omitted keys use top-level fields. */
75
- type ViewBindings<Variables extends VariableCollection, Input> = Partial<{ [Key in keyof Variables]: (input: Input) => ResolvedVariables<Variables>[Key]; }>;
76
- type RequiredFilterBindingKeys<Variables extends VariableCollection, Input> = { [Key in keyof Variables]: Variables[Key]['kind'] extends 'dateTimeRangeComparison' ? never : Variables[Key]['kind'] extends 'choice' ? [Input] extends [Record<Key, unknown>] ? ResolvedVariables<Variables>[Key] extends Input[Key] ? never : Key : Key : Extract<Variables[Key]['presentation'], {
77
- group: 'display';
78
- }> extends never ? [Input] extends [Record<Key, ResolvedVariables<Variables>[Key]>] ? [ResolvedVariables<Variables>[Key]] extends [Input[Key]] ? never : Key : Key : never; }[keyof Variables];
79
- /** Derive compatible top-level filter bindings; require readers for other input shapes. */
80
- type ViewBindingOptions<Variables extends VariableCollection, Input, AdditionalRequired extends keyof Variables = never> = [RequiredFilterBindingKeys<Variables, Input> | AdditionalRequired] extends [never] ? {
81
- bindings?: ViewBindings<Variables, Input>;
82
- } : {
83
- bindings: ViewBindings<Variables, Input> & { [Key in RequiredFilterBindingKeys<Variables, Input> | AdditionalRequired]-?: (input: Input) => ResolvedVariables<Variables>[Key]; };
84
- };
85
- type SameViewInput<Variables extends VariableCollection, Input> = [ResolvedVariables<Variables>] extends [Input] ? [Input] extends [{ [Key in keyof Variables]: Variables[Key]['kind'] extends 'choice' ? string : ResolvedVariables<Variables>[Key]; }] ? [Input] extends [Record<string, never>] ? true : [keyof Input] extends [keyof Variables] ? true : false : false : false;
86
- type ViewInputMapping<Variables extends VariableCollection, Input> = SameViewInput<Variables, Input> extends true ? {
87
- input?: (values: ResolvedVariables<Variables>) => Input;
88
- } : {
89
- input: (values: ResolvedVariables<Variables>) => Input;
90
- };
91
- type DataViewDefinition<Name extends string, Variables extends VariableCollection, Input, Data> = {
92
- operation: Name;
93
- dataContext: DataContext;
94
- /** App-owned semantics: measured zero need not mean an empty result. */
95
- isEmpty: (data: Data) => boolean;
96
- /** Inherited by DataSection unless it supplies its own copy. */
97
- emptyFallback: EmptyContent;
98
- } & (keyof Variables extends never ? {
99
- variables?: Variables & CheckedFacetContexts<NoInfer<Variables>>;
100
- } : {
101
- variables: Variables & CheckedFacetContexts<NoInfer<Variables>>;
102
- }) & ViewInputMapping<NoInfer<Variables>, Input> & ViewBindingOptions<NoInfer<Variables>, Input> & ({
103
- date: ViewDate<Variables, Input>;
104
- describeInput?: (input: Input) => string;
105
- } | {
106
- date?: never;
107
- describeInput: (input: Input) => string;
108
- });
109
- type ResolvedDataViewDefinition<Name extends string, Variables extends VariableCollection, Input, Data> = Omit<DataViewDefinition<Name, Variables, Input, Data>, 'variables' | 'input'> & {
110
- variables: Variables;
111
- input: (values: ResolvedVariables<Variables>) => Input;
112
- };
113
- //#endregion
114
133
  //#region src/exploration.d.ts
115
134
  declare const filterPatch: unique symbol;
116
135
  declare const breakdownValue: unique symbol;
@@ -120,24 +139,27 @@ declare class FilterTarget<Patch> {
120
139
  declare class BreakdownTarget<Value extends string> {
121
140
  readonly [breakdownValue]: Value;
122
141
  }
123
- type FilterPatch<Variables extends VariableCollection> = Partial<{ [Key in keyof Variables]: Extract<Variables[Key]['presentation'], {
142
+ type FilterPatch<Collection extends FilterCollection> = Partial<{ [Key in keyof Collection]: Extract<Collection[Key]['presentation'], {
124
143
  group: 'display';
125
- }> extends never ? AppVariableValues$1<Variables>[Key] : never; }>;
144
+ }> extends never ? FilterValues<Collection>[Key] : never; }>;
126
145
  //#endregion
127
146
  //#region src/actions.d.ts
128
147
  type ActionCondition<Row> = {
129
148
  label: string;
130
149
  when?: (row: Row) => boolean;
131
150
  };
132
- type DetailAction<Row, Input, DestinationInput> = ActionCondition<Row> & {
151
+ /** A detail interaction: the destination and the fields a row supplies. */
152
+ type DetailAction<Row, Input, DestinationInput, Own> = ActionCondition<Row> & {
133
153
  label: string;
134
- target: DetailView<any, DestinationInput>;
135
- input: (row: Row, displayedInput: Input) => DestinationInput;
154
+ target: DetailView<any, DestinationInput, Own>;
155
+ /** The destination's own fields, such as the clicked record, and any filter it
156
+ * narrows; its other filters carry over from the displayed scope. */
157
+ input: (row: Row, displayedInput: Input) => Own & Partial<DestinationInput>;
136
158
  };
137
159
  type ActionDeclaration<Row, Input> = ActionCondition<Row> & ({
138
160
  kind: 'detail';
139
- target: DetailView<any, any>;
140
- input: (row: Row, input: Input) => unknown;
161
+ target: DetailView<any, any, any>;
162
+ input: (row: Row, input: Input) => object;
141
163
  } | {
142
164
  kind: 'filter';
143
165
  target: object;
@@ -148,7 +170,7 @@ type ActionDeclaration<Row, Input> = ActionCondition<Row> & ({
148
170
  };
149
171
  });
150
172
  declare class ActionBuilder<Row, Input> {
151
- detail<DestinationInput>(config: DetailAction<Row, Input, DestinationInput>): ActionDeclaration<Row, Input>;
173
+ detail<DestinationInput, Own>(config: DetailAction<Row, Input, DestinationInput, Own>): ActionDeclaration<Row, Input>;
152
174
  filter<Patch extends object, const Values extends NoInfer<Patch>, Value extends string = never>(config: ActionCondition<Row> & {
153
175
  label: string;
154
176
  target: FilterTarget<Patch>;
@@ -170,6 +192,7 @@ declare class ExplorationActions<Row, Input> {
170
192
  //#endregion
171
193
  //#region src/bindings.d.ts
172
194
  /** Displayed data, or an initial loading reading. Pending filter values are never a source. */
195
+ /** A view's displayed data and input, or its loading state; widgets and bindings read it. */
173
196
  type ViewSource<Data, Input> = {
174
197
  loading: true;
175
198
  } | {
@@ -230,7 +253,7 @@ declare class RegisteredBinding {
230
253
  /** @internal */
231
254
  static owner(binding: RegisteredBinding): object | undefined;
232
255
  protected assertSource(source: object): void;
233
- static evidence(binding: RegisteredBinding, owner: object): WidgetEvidence;
256
+ static evidence(binding: RegisteredBinding, owners: readonly object[]): WidgetEvidence;
234
257
  }
235
258
  declare class ExportDataset<Data, Input> extends RegisteredBinding {
236
259
  #private;
@@ -266,13 +289,15 @@ declare class Dataset<Data, Input, Row> extends ExportDataset<Data, Input> {
266
289
  declare class Metric<Data, Input> extends RegisteredBinding {
267
290
  #private;
268
291
  readonly definition: MetricDefinition;
269
- constructor(definition: MetricDefinition, select: (data: Data, input: Input) => MetricValues$1, date?: (input: Input) => DateTimeRangeComparisonRequest$1, owner?: object);
292
+ constructor(definition: MetricDefinition, select: (data: Data, input: Input) => MetricValues$1, date?: (input: Input) => DateTimeRangeInput, owner?: object);
270
293
  read: <Source extends ViewSource<Data, Input>>(source: Source) => SourceReading<Source, MetricValues$1 & {
271
- period?: DateTimeRangeComparisonRequest$1;
294
+ period?: DateTimeRangeInput;
272
295
  }>;
273
- records<DetailData, DetailInput>(options: {
274
- target: DetailView<DetailData, DetailInput>;
275
- input: (displayedInput: Input) => DetailInput;
296
+ /** Show the records behind this metric. `input` returns the destination's own
297
+ * fields and any filter it narrows; its other filters carry over from the displayed scope. */
298
+ records<DetailData, DetailInput, Own>(options: {
299
+ target: DetailView<DetailData, DetailInput, Own>;
300
+ input: (displayedInput: Input) => Own & Partial<DetailInput>;
276
301
  }): MetricRecords<Data, Input, DetailData, DetailInput>;
277
302
  actions<const Actions extends Record<string, ActionDeclaration<void, Input>>>(build: (action: ActionBuilder<void, Input>) => Actions, options?: {
278
303
  primary?: keyof Actions & string;
@@ -281,7 +306,7 @@ declare class Metric<Data, Input> extends RegisteredBinding {
281
306
  /** A metric-owned record destination. It can only render from that metric's displayed source. */
282
307
  declare class MetricRecords<Data, Input, DetailData, DetailInput> {
283
308
  #private;
284
- constructor(metric: Metric<Data, Input>, target: DetailView<DetailData, DetailInput>, input: (displayedInput: Input) => DetailInput);
309
+ constructor(metric: Metric<Data, Input>, target: DetailView<DetailData, DetailInput, any>, input: (displayedInput: Input) => DetailInput);
285
310
  render(source: ViewSource<Data, Input>, navigation?: DetailNavigation): {
286
311
  scope: string;
287
312
  content: import("react").FunctionComponentElement<{
@@ -300,76 +325,40 @@ declare class MetricRecords<Data, Input, DetailData, DetailInput> {
300
325
  } | undefined;
301
326
  }
302
327
  //#endregion
303
- //#region src/content.d.ts
304
- type DataContentState<Data, Input> = {
305
- scope: DataReading<string>;
306
- } & ({
307
- loading: true;
308
- data?: never;
309
- input?: never;
310
- } | {
311
- loading: false;
312
- data: Data;
313
- input: Input;
314
- });
315
- /** A section's request owner and render layout are declared together. */
316
- declare class ViewContent<Data, Input> {
317
- #private;
318
- constructor(view: DeclaredView<Data, Input>, render: (source: DataContentState<Data, Input>) => ReactNode, describeInput: (input: Input) => string);
319
- static section<Data, Input>(content: ViewContent<Data, Input>): {
320
- loadingFallback: ReactNode;
321
- children(this: void, data: Data, input: Input): ReactNode;
322
- view: DeclaredView<Data, Input, unknown>;
323
- };
324
- }
325
- //#endregion
326
328
  //#region src/hooks.d.ts
327
- type DateTimeViewDefinition<Operations extends DataOperations, Name extends keyof Operations & string, Additional extends VariableCollection, Context extends AuthoringDataContext, Period extends DateTimeRangeVariable | DateTimeRangeComparisonVariable = DateTimeRangeVariable> = Omit<DataViewDefinition<Name, {
328
- period: Period;
329
- } & NoInfer<Additional>, InputOf<Operations[Name]>, OutputOf<Operations[Name]>>, 'variables' | 'describeInput' | 'date'> & {
330
- operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
331
- dataContext: Context;
332
- time: Period;
333
- variables?: Additional & CheckedVariableDeclarations<NoInfer<Additional>> & {
334
- period?: never;
335
- } & Omit<CheckedFacetContexts<{
336
- period: Period;
337
- } & NoInfer<Additional>>, 'period'> & Omit<CheckedFacetSources<Operations, {
338
- period: Period;
339
- } & NoInfer<Additional>>, 'period'>;
340
- } & ViewBindingOptions<{
341
- period: Period;
342
- } & NoInfer<Additional>, InputOf<Operations[Name]>, Period extends DateTimeRangeComparisonVariable ? InputOf<Operations[Name]> extends {
343
- period: DateTimeRangeComparisonRequest;
344
- } ? never : 'period' : never>;
345
329
  type NonEmptyColumns<Columns extends object> = keyof Columns extends never ? never : Columns;
346
- type BoundDataView<Name extends string, Variables extends VariableCollection, Input, Data, Context extends AuthoringDataContext, HasDate extends boolean> = DeclaredView<Data, Input, ResolvedDataViewDefinition<Name, Variables, Input, Data> & {
347
- describeInput: (input: Input) => string;
330
+ /** The filters an operation declares; `{}` when it reads none. */
331
+ type FiltersOf<Operation> = Operation extends {
332
+ filters: infer Filters extends FilterCollection;
333
+ } ? Filters : {};
334
+ /** The fields a destination's interactions supply; its filters carry over. */
335
+ type DetailOwnInput<Operation> = Omit<InputOf<Operation>, keyof FiltersOf<Operation>>;
336
+ /** Operations a view can run: those whose input is their declared filters, or empty.
337
+ * Operations that parse their own input are destinations for `defineDetailView`. */
338
+ type ViewOperationName<Operations extends DataOperations> = { [Name in keyof Operations & string]: Operations[Name] extends {
339
+ filters: infer Filters extends FilterCollection;
340
+ } ? [FilterInput<Filters>] extends [InputOf<Operations[Name]>] ? Name : never : [InputOf<Operations[Name]>] extends [Record<string, never>] ? Name : never; }[keyof Operations & string];
341
+ /** Metric comparisons need a reporting period with a comparison. */
342
+ type HasPeriod<Filters extends FilterCollection> = { [Name in keyof Filters]: Filters[Name] extends DateTimeRangeFilter<true> ? true : never; }[keyof Filters] extends never ? false : true;
343
+ type DisplayChoiceName<Filters extends FilterCollection> = { [Name in keyof Filters]: Filters[Name] extends ChoiceFilter<any> ? Extract<Filters[Name]['presentation'], {
344
+ group: 'display';
345
+ }> extends never ? never : Name : never; }[keyof Filters] & string;
346
+ type BoundView<Name extends string, Filters extends FilterCollection, Data, Context extends AuthoringDataContext> = DeclaredView<Data, FilterInput<Filters>, ResolvedViewDefinition<Name, Filters, Data> & {
347
+ clientFilters: ClientFilters;
348
348
  }> & {
349
- filter(): FilterTarget<FilterPatch<Variables>>;
350
- breakdown<Key extends keyof Variables & string>(key: Key & (Variables[Key] extends ChoiceVariable$1<any> ? Extract<Variables[Key]['presentation'], {
351
- group: 'display';
352
- }> extends never ? never : unknown : never)): Variables[Key] extends ChoiceVariable$1<infer Value> ? BreakdownTarget<Value> : never;
353
- dataset<Row, const Columns extends Record<string, object> = Record<string, object>>(definition: DatasetDefinition<Data, Input, Row, Parameters<Context['evidence']>[0]> & {
349
+ filter(): FilterTarget<FilterPatch<Filters>>;
350
+ breakdown<Key extends DisplayChoiceName<Filters>>(key: Key): Filters[Key] extends ChoiceFilter<infer Value> ? BreakdownTarget<Value> : never;
351
+ dataset<Row, const Columns extends Record<string, object> = Record<string, object>>(definition: DatasetDefinition<Data, FilterInput<Filters>, Row, Parameters<Context['evidence']>[0]> & {
354
352
  columns: Columns & NonEmptyColumns<Columns>;
355
- }): Dataset<Data, Input, Row>;
356
- metric(definition: Parameters<Context['metric']>[0], select: (data: Data, input: Input) => HasDate extends true ? MetricValues$1 : {
353
+ }): Dataset<Data, FilterInput<Filters>, Row>;
354
+ metric(definition: Parameters<Context['metric']>[0], select: (data: Data, input: FilterInput<Filters>) => HasPeriod<Filters> extends true ? MetricValues$1 : {
357
355
  current: number;
358
356
  previous?: never;
359
- }): Metric<Data, Input>;
360
- scope(snapshot: DisplayedSnapshot<Data, Input>): string;
361
- content(render: (state: DataContentState<Data, Input>) => ReactNode): ViewContent<Data, Input>;
362
- };
363
- type FacetOperationName<Operations extends DataOperations, Value extends DimensionValue> = { [Name in keyof Operations & string]: OutputOf<Operations[Name]> extends readonly DimensionOption<Value>[] ? Name : never; }[keyof Operations & string];
364
- type FacetConfig<Operations extends DataOperations, Value extends DimensionValue, Context extends VariableCollection, Name extends keyof Operations & string> = DimensionFilterSettings<Value> & {
365
- facet: {
366
- context: Context & CheckedVariableDeclarations<NoInfer<Context>> & (string extends keyof Context ? never : unknown);
367
- operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
368
- input: (values: ResolvedVariables<NoInfer<Context>>) => InputOf<Operations[NoInfer<Name>]>;
369
- };
357
+ }): Metric<Data, FilterInput<Filters>>;
358
+ scope(snapshot: DisplayedSnapshot<Data, FilterInput<Filters>>): string;
359
+ content(render: (state: DataContentState<Data, FilterInput<Filters>>) => ReactNode): ViewContent<Data, FilterInput<Filters>>;
370
360
  };
371
- type CheckedFacetSources<Operations extends DataOperations, Variables extends VariableCollection> = CheckedVariableDeclarations<Variables> & { [Key in keyof Variables]: Variables[Key] extends FacetVariable<infer Value, infer _Context, infer Name, infer Input> ? Name extends keyof Operations ? Input extends InputOf<Operations[Name]> ? OutputOf<Operations[Name]> extends readonly DimensionOption<Value>[] ? Variables[Key] : never : never : never : Variables[Key]; };
372
- type BoundDetailView<Data, Input, Context extends AuthoringDataContext> = DetailView<Data, Input> & {
361
+ type BoundDetailView<Data, Input, Context extends AuthoringDataContext, Own = Input> = DetailView<Data, Input, Own> & {
373
362
  dataset<Row, const Columns extends Record<string, object> = Record<string, object>>(definition: DatasetDefinition<Data, Input, Row, Parameters<Context['evidence']>[0]> & {
374
363
  columns: Columns & NonEmptyColumns<Columns>;
375
364
  }): Dataset<Data, Input, Row>;
@@ -378,54 +367,54 @@ type BoundDetailView<Data, Input, Context extends AuthoringDataContext> = Detail
378
367
  previous?: never;
379
368
  }): Metric<Data, Input>;
380
369
  };
381
- /** Bind declared operations to URL variables, displayed readings, and request feedback. */
370
+ /** Bind declared operations to URL filters, displayed readings, and request feedback.
371
+ * The client's operations declare their filters; `<DataApp>` renders their controls. */
382
372
  export declare function createDataHooks<Operations extends DataOperations>(client: DataClient<Operations>): {
383
- defineDataView: {
384
- <Name extends keyof Operations & string, const Variables extends VariableCollection = {}, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: DataViewDefinition<Name, Variables, InputOf<Operations[Name]>, OutputOf<Operations[Name]>> & {
385
- operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
386
- variables?: Variables & CheckedFacetSources<Operations, NoInfer<Variables>>;
387
- } & {
388
- dataContext: Context;
389
- date: ViewDate<Variables, InputOf<Operations[Name]>>;
390
- }): BoundDataView<Name, Variables, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, true>;
391
- <Name extends keyof Operations & string, const Variables extends VariableCollection = {}, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: DataViewDefinition<Name, Variables, InputOf<Operations[Name]>, OutputOf<Operations[Name]>> & {
392
- operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
393
- variables?: Variables & CheckedFacetSources<Operations, NoInfer<Variables>>;
394
- } & {
395
- dataContext: Context;
396
- }): BoundDataView<Name, Variables, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, false>;
397
- };
373
+ defineView: <Name extends ViewOperationName<Operations>, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: ViewDefinition<Name, FilterInput<FiltersOf<Operations[Name]>>, OutputOf<Operations[Name]>> & {
374
+ operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
375
+ dataContext: Context;
376
+ }) => BoundView<Name, FiltersOf<Operations[Name]>, OutputOf<Operations[Name]>, Context>;
398
377
  defineDetailView: <Name extends keyof Operations & string, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: DetailViewDefinition<OutputOf<Operations[Name]>, InputOf<Operations[Name]>> & {
399
378
  operation: Name;
400
379
  dataContext: Context;
401
- }) => BoundDetailView<OutputOf<Operations[Name]>, InputOf<Operations[Name]>, Context>;
402
- defineTimeView: <Name extends keyof Operations & string, const Additional extends VariableCollection = {}, const Context extends AuthoringDataContext = AuthoringDataContext, Period extends DateTimeRangeVariable | DateTimeRangeComparisonVariable = DateTimeRangeVariable>(definition: DateTimeViewDefinition<Operations, Name, Additional, Context, Period>) => BoundDataView<Name, {
403
- period: Period;
404
- } & Additional, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, Period extends DateTimeRangeComparisonVariable ? true : false>;
405
- defineFacetFilter: {
406
- <const Context extends VariableCollection, const Name extends FacetOperationName<Operations, string>>(config: FacetConfig<Operations, string, Context, Name>): FacetVariable<string, Readonly<Context>, Name, InputOf<Operations[Name]>>;
407
- <const Context extends VariableCollection, const Name extends FacetOperationName<Operations, number>>(config: FacetConfig<Operations, number, Context, Name>): FacetVariable<number, Readonly<Context>, Name, InputOf<Operations[Name]>>;
408
- };
380
+ }) => BoundDetailView<OutputOf<Operations[Name]>, InputOf<Operations[Name]>, Context, DetailOwnInput<Operations[Name]>>;
409
381
  };
410
382
  //#endregion
411
383
  //#region src/ui/DataApp.d.ts
412
- type DataAppProps<Data, Input = unknown> = Omit<DataAppBaseProps, 'dataContext'> & DataAppControlProps & {
413
- view: DeclaredView<Data, Input> & {
414
- scope(snapshot: DisplayedSnapshot<Data, Input>): string;
415
- };
384
+ /** A declared data or time view that `<DataApp>` can run and describe. */
385
+ type DataAppView<Data, Input> = DeclaredView<Data, Input> & {
386
+ scope(snapshot: DisplayedSnapshot<Data, Input>): string;
387
+ };
388
+ type AnyView = DataAppView<any, any>;
389
+ /** Read a view's data and input through its `scope()` signature. */
390
+ type SnapshotOf<View> = View extends {
391
+ scope(snapshot: infer Snapshot): string;
392
+ } ? Snapshot : never;
393
+ type ExportOf<View> = View extends {
394
+ scope(snapshot: DisplayedSnapshot<infer Data, infer Input>): string;
395
+ } ? ExportDataset<Data, Input> : never;
396
+ type StoryFindings = readonly (Omit<StoryFinding, 'evidence'> & {
397
+ evidence: RegisteredBinding;
398
+ })[];
399
+ type DataAppProps<Data, Input = unknown, SummaryViews extends readonly AnyView[] = []> = Omit<DataAppBaseProps, 'dataContext'> & DataAppControlProps & {
400
+ /** The headline view. `<DataApp>` renders the controls for every filter its
401
+ * client's operations read and owns their URL state. */
402
+ view: DataAppView<Data, Input>;
403
+ /** Other views that the story and CSV export read, sharing `view`’s data context.
404
+ * They load with `view` instead of waiting for their sections to near the viewport. */
405
+ summaryViews?: SummaryViews;
416
406
  /** Show supplied datasets’ record suggestions on the first declared search. Defaults to true. */
417
407
  showSearchSuggestions?: boolean;
418
- /** Omit to leave presentation out of the toolbar. */
419
- story?: (snapshot: DisplayedSnapshot<Data, Input>) => readonly (Omit<StoryFinding, 'evidence'> & {
420
- evidence: RegisteredBinding;
421
- })[];
422
- /** Omit to leave CSV export out of the toolbar. */
423
- datasets?: readonly [ExportDataset<Data, Input>, ...ExportDataset<Data, Input>[]];
408
+ /** Omit to leave presentation out of the toolbar. Receives `view`’s displayed
409
+ * snapshot, then one per summary view in `summaryViews` order. */
410
+ story?: (snapshot: DisplayedSnapshot<Data, Input>, ...summaries: { [Index in keyof SummaryViews]: SnapshotOf<SummaryViews[Index]>; }) => StoryFindings;
411
+ /** Omit to leave CSV export out of the toolbar. Datasets may belong to `view` or a summary view. */
412
+ datasets?: readonly [ExportDataset<Data, Input> | ExportOf<SummaryViews[number]>, ...(ExportDataset<Data, Input> | ExportOf<SummaryViews[number]>)[]];
424
413
  /** Detail destinations available to dataset actions and metric record inspection. */
425
414
  details?: readonly DetailContent<any, any>[];
426
415
  };
427
- /** Executes the primary view and owns its controls, inspection, exports, and stories. */
428
- export declare function DataApp<Data, Input>(props: DataAppProps<Data, Input>): import("react").JSX.Element;
416
+ /** Executes the primary view and its summary views, and owns controls, inspection, exports, and stories. */
417
+ export declare function DataApp<Data, Input, const SummaryViews extends readonly AnyView[] = []>(props: DataAppProps<Data, Input, SummaryViews>): import("react").JSX.Element;
429
418
  //#endregion
430
419
  //#region src/ui/Stack.d.ts
431
420
  type StackProps = {
@@ -612,6 +601,8 @@ type DataSectionProps<Data, Input = unknown> = {
612
601
  };
613
602
  label?: string;
614
603
  } & Omit<ComponentPropsWithRef<'div'>, 'children' | 'content'>;
604
+ /** Sections of views that `<DataApp>` runs share its results; every other section
605
+ * requests its own view once it nears the viewport. */
615
606
  export declare function DataSection<Data, Input>({ content, ...presentation }: DataSectionProps<Data, Input>): import("react").JSX.Element;
616
607
  //#endregion
617
608
  //#region src/ui/DateTimeTooltip.d.ts
@@ -645,7 +636,7 @@ type PeriodSummaryProps = {
645
636
  comparison?: PeriodComparison;
646
637
  className?: string;
647
638
  };
648
- /** Read-only period context for the variable bar, including exact bounds for assistive technology. */
639
+ /** Read-only period context for the control bar, including exact bounds for assistive technology. */
649
640
  export declare function PeriodSummary({ period, comparison, className }: PeriodSummaryProps): import("react").JSX.Element;
650
641
  //#endregion
651
642
  //#region src/ui/shortcuts.d.ts
@@ -753,5 +744,5 @@ export declare function AnnotationBar({ ref, annotations, active, theme, disable
753
744
  /** Install only the outer-frame annotation controls; leave host page typography and layout intact. */
754
745
  export declare function injectDataAppAnnotationStyles(options?: DataAppStylesOptions): HTMLStyleElement;
755
746
  //#endregion
756
- export { type AnnotationBarHandle, type AnnotationBarProps, type AnnotationTargetProps, type AppVariable, type AppVariableValues, type BreakdownItem, type BreakdownProps, Button, type ButtonProps, type ChoiceOption, type ChoiceVariable, type ColumnIdentifier, type ComparisonProps, type CsvCell, type DataAppProps, type DataAppStyle, type DataAppStyleHooks, type DataAppStyleToken, type DataAppStylesOptions, type DataContext, type DataIdentifierDefinition, type DataSectionProps, type DataValueProps, type DatasetColumn, type DatasetDeclaration as DatasetDefinition, type DatasetSuggestionOptions, DateDisplay, type DateDisplayProps, type DateTimeRangeComparisonRequest, type DateTimeRangeComparisonSelection, type DateTimeRangeComparisonVariable, type DateTimeRangeComparisonVariableOptions, DateTimeRangePicker, type DateTimeRangePickerProps, type DateTimeRangePreset, type DateTimeRangeVariable, type DateTimeRangeVariableOptions, type DateTimeTooltipProps, type DetailViewDefinition, type EmptyStateProps, type ExternalLinkProps, type GlossaryEntry, type GridItemProps, type GridProps, type IconButtonProps, type MetricDefinition, type MetricRecords, type MetricValues, type MetricWidgetProps, type MultiChoiceVariable, type PeriodComparison, type PeriodSummaryProps, type RankingItem, type RankingProps, type ReportingPeriod, type SearchVariable, SectionHeading, type SectionHeadingProps, type SkeletonProps, type StackProps, type TableIdentifier, type TableWidgetProps, type TableWidgetSearch, type TextContentProps, type TextWidgetProps, Tooltip, type TooltipProps, TooltipProvider, type TooltipProviderProps, type UpdatedAtProps, type VariablePresentation, type VisualizationWidgetProps, type VisualizationWidgetView, type WidgetEvidence, choiceVariable, createDataContext, dateTimeRangePresets, dateTimeRangeVariable, defineDataIdentifiers, injectDataAppStyles, mountDataApp, multiChoiceVariable, searchVariable, useDateFormatting };
747
+ export { type ActionBuilder, type AnnotationBarHandle, type AnnotationBarProps, type AnnotationTargetProps, type BreakdownItem, type BreakdownProps, Button, type ButtonProps, type ColumnIdentifier, type ComparisonProps, type CsvCell, type DataAppProps, type DataAppStyle, type DataAppStyleHooks, type DataAppStyleToken, type DataAppStylesOptions, type DataAppView, type DataContext, type DataIdentifierDefinition, type DataSectionProps, type DataValueProps, type Dataset, type DatasetColumn, type DatasetDeclaration as DatasetDefinition, type DatasetSuggestionOptions, DateDisplay, type DateDisplayProps, DateTimeRangePicker, type DateTimeRangePickerProps, type DateTimeTooltipProps, type DetailAction, type DetailViewDefinition, type EmptyStateProps, type ExternalLinkProps, type GlossaryEntry, type GridItemProps, type GridProps, type IconButtonProps, type MetricDefinition, type MetricRecords, type MetricValues, type MetricWidgetProps, Notice, type NoticeProps, type PeriodComparison, type PeriodSummaryProps, type RankingItem, type RankingProps, type ReportingPeriod, SectionHeading, type SectionHeadingProps, type SkeletonProps, type StackProps, type TableIdentifier, type TableWidgetProps, type TableWidgetSearch, type TextContentProps, type TextWidgetProps, Tooltip, type TooltipProps, TooltipProvider, type TooltipProviderProps, type UpdatedAtProps, type ViewSource, type VisualizationWidgetProps, type VisualizationWidgetView, type WidgetEvidence, createDataContext, defineDataIdentifiers, injectDataAppStyles, mountDataApp, useDateFormatting };
757
748
  //# sourceMappingURL=index.d.ts.map