@altertable/data-app-react 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.
- package/dist/chunks/{SectionHeading-CLvnHe1C.js → SectionHeading-Bz5RIXit.js} +767 -1152
- package/dist/chunks/SectionHeading-Bz5RIXit.js.map +1 -0
- package/dist/index.js +174 -37
- package/dist/index.js.map +1 -1
- package/dist/types/chunks/DateTimeRangePicker.d.ts +127 -122
- package/dist/types/index.d.ts +179 -217
- package/dist/types/ui/index.d.ts +70 -54
- package/dist/ui/index.js +921 -187
- package/dist/ui/index.js.map +1 -1
- package/package.json +13 -5
- package/dist/chunks/SectionHeading-CLvnHe1C.js.map +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as DataAppControlProps, At as GlossaryEntry, Dt as AuthoringDataContext, E as MetricWidgetProps$1, Et as EmptyContent, G as DataAppStylesOptions, Gt as Button, H as DataAppStyle, It as MetricDefinition, Jt as MetricComparison, K as injectDataAppStyles, Kt as ButtonProps, Lt as WidgetEvidence, N as DateTimeRangeFilter, Nt as StoryFinding, O as DataValueProps$1, Ot as DataContext, Qt as defineDataIdentifiers, S as TextWidgetProps$1, Tt as ItemActions, U as DataAppStyleHooks, V as mountDataApp, W as DataAppStyleToken, X as TableWidgetProps$1, Xt as DataIdentifierDefinition, Y as TableWidgetColumn, Yt as ColumnIdentifier, Z as TableWidgetSearch, Zt as TableIdentifier, _ as HelpPopoverProps, a as DateDisplay, b as VisualizationWidgetView$1, c as SectionHeadingProps, d as TooltipProvider, f as TooltipProviderProps, i as useDateFormatting, jt as createDataContext, k as DataAppBaseProps, kt as EvidenceDeclaration, l as Tooltip, m as AppIconName, mt as SearchSuggestion, n as DateTimeRangePickerProps, o as DateDisplayProps, q as TableDisplayMode, s as SectionHeading, t as DateTimeRangePicker, u as TooltipProps, xt as CsvTable, y as VisualizationWidgetProps$1, yt as CsvCell } from "./chunks/DateTimeRangePicker.js";
|
|
2
2
|
import { DataClient, InputOf, OutputOf } from "@altertable/data-app/client";
|
|
3
|
-
import {
|
|
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, DateRangeRequest, 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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
/** A typed, query-backed destination.
|
|
43
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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: (
|
|
55
|
-
constructor(target: DetailView<Data, Input>, render: (
|
|
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 : Variable extends DateRangeVariable$1 ? DateRangeRequest : 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 DateRangeVariable$1 | 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) => DateRangeRequest | 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 'dateRange' | '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<
|
|
142
|
+
type FilterPatch<Collection extends FilterCollection> = Partial<{ [Key in keyof Collection]: Extract<Collection[Key]['presentation'], {
|
|
124
143
|
group: 'display';
|
|
125
|
-
}> extends 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
|
-
|
|
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
|
-
|
|
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) =>
|
|
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,
|
|
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) =>
|
|
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?:
|
|
294
|
+
period?: DateTimeRangeInput;
|
|
272
295
|
}>;
|
|
273
|
-
records
|
|
274
|
-
|
|
275
|
-
|
|
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,99 +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 CalendarTimeViewDefinition<Operations extends DataOperations, Name extends keyof Operations & string, Additional extends VariableCollection, Context extends AuthoringDataContext> = {
|
|
328
|
-
operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
|
|
329
|
-
dataContext: Context;
|
|
330
|
-
time: Omit<DateRangeVariableOptions, 'key'>;
|
|
331
|
-
variables?: Additional & CheckedVariableDeclarations<NoInfer<Additional>> & {
|
|
332
|
-
period?: never;
|
|
333
|
-
} & Omit<CheckedFacetContexts<TimeVariables<NoInfer<Additional>>>, 'period'> & Omit<CheckedFacetSources<Operations, TimeVariables<NoInfer<Additional>>>, 'period'>;
|
|
334
|
-
isEmpty: (data: OutputOf<Operations[Name]>) => boolean;
|
|
335
|
-
emptyFallback: EmptyContent;
|
|
336
|
-
} & TimeInputMapping<NoInfer<Additional>, InputOf<Operations[Name]>> & ViewBindingOptions<TimeVariables<NoInfer<Additional>>, InputOf<Operations[Name]>, RequiredPeriodBinding<InputOf<Operations[Name]>>>;
|
|
337
|
-
type DateTimeViewDefinition<Operations extends DataOperations, Name extends keyof Operations & string, Additional extends VariableCollection, Context extends AuthoringDataContext, Period extends DateTimeRangeVariable | DateTimeRangeComparisonVariable = DateTimeRangeVariable> = Omit<DataViewDefinition<Name, {
|
|
338
|
-
period: Period;
|
|
339
|
-
} & NoInfer<Additional>, InputOf<Operations[Name]>, OutputOf<Operations[Name]>>, 'variables' | 'describeInput' | 'date'> & {
|
|
340
|
-
operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
|
|
341
|
-
dataContext: Context;
|
|
342
|
-
time: Period;
|
|
343
|
-
variables?: Additional & CheckedVariableDeclarations<NoInfer<Additional>> & {
|
|
344
|
-
period?: never;
|
|
345
|
-
} & Omit<CheckedFacetContexts<{
|
|
346
|
-
period: Period;
|
|
347
|
-
} & NoInfer<Additional>>, 'period'> & Omit<CheckedFacetSources<Operations, {
|
|
348
|
-
period: Period;
|
|
349
|
-
} & NoInfer<Additional>>, 'period'>;
|
|
350
|
-
} & ViewBindingOptions<{
|
|
351
|
-
period: Period;
|
|
352
|
-
} & NoInfer<Additional>, InputOf<Operations[Name]>, Period extends DateTimeRangeComparisonVariable ? InputOf<Operations[Name]> extends {
|
|
353
|
-
period: DateTimeRangeComparisonRequest;
|
|
354
|
-
} ? never : 'period' : never>;
|
|
355
|
-
type TimeVariables<Additional extends VariableCollection> = {
|
|
356
|
-
period: ReturnType<typeof dateRangeVariable>;
|
|
357
|
-
} & Additional;
|
|
358
|
-
type TimeInput<Additional extends VariableCollection> = keyof Additional extends never ? DateRangeRequest : ResolvedVariables<TimeVariables<Additional>>;
|
|
359
|
-
type TimeInputMapping<Additional extends VariableCollection, Input> = TimeInput<Additional> extends Input ? {
|
|
360
|
-
input?: (values: ResolvedVariables<TimeVariables<Additional>>) => Input;
|
|
361
|
-
} : {
|
|
362
|
-
input: (values: ResolvedVariables<TimeVariables<Additional>>) => Input;
|
|
363
|
-
};
|
|
364
|
-
/** Match the period reader's precedence for each possible operation input. */
|
|
365
|
-
type RequiredPeriodBinding<Input> = Input extends unknown ? 'period' extends keyof Input ? Input extends {
|
|
366
|
-
period: DateRangeRequest;
|
|
367
|
-
} ? never : 'period' : Input extends DateRangeRequest ? never : 'period' : never;
|
|
368
329
|
type NonEmptyColumns<Columns extends object> = keyof Columns extends never ? never : Columns;
|
|
369
|
-
|
|
370
|
-
|
|
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;
|
|
371
348
|
}> & {
|
|
372
|
-
filter(): FilterTarget<FilterPatch<
|
|
373
|
-
breakdown<Key extends
|
|
374
|
-
|
|
375
|
-
}> extends never ? never : unknown : never)): Variables[Key] extends ChoiceVariable$1<infer Value> ? BreakdownTarget<Value> : never;
|
|
376
|
-
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]> & {
|
|
377
352
|
columns: Columns & NonEmptyColumns<Columns>;
|
|
378
|
-
}): Dataset<Data,
|
|
379
|
-
metric(definition: Parameters<Context['metric']>[0], select: (data: Data, input:
|
|
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 : {
|
|
380
355
|
current: number;
|
|
381
356
|
previous?: never;
|
|
382
|
-
}): Metric<Data,
|
|
383
|
-
scope(snapshot: DisplayedSnapshot<Data,
|
|
384
|
-
content(render: (state: DataContentState<Data,
|
|
385
|
-
};
|
|
386
|
-
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];
|
|
387
|
-
type FacetConfig<Operations extends DataOperations, Value extends DimensionValue, Context extends VariableCollection, Name extends keyof Operations & string> = DimensionFilterSettings<Value> & {
|
|
388
|
-
facet: {
|
|
389
|
-
context: Context & CheckedVariableDeclarations<NoInfer<Context>> & (string extends keyof Context ? never : unknown);
|
|
390
|
-
operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
|
|
391
|
-
input: (values: ResolvedVariables<NoInfer<Context>>) => InputOf<Operations[NoInfer<Name>]>;
|
|
392
|
-
};
|
|
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>>;
|
|
393
360
|
};
|
|
394
|
-
type
|
|
395
|
-
type BoundDetailView<Data, Input, Context extends AuthoringDataContext> = DetailView<Data, Input> & {
|
|
361
|
+
type BoundDetailView<Data, Input, Context extends AuthoringDataContext, Own = Input> = DetailView<Data, Input, Own> & {
|
|
396
362
|
dataset<Row, const Columns extends Record<string, object> = Record<string, object>>(definition: DatasetDefinition<Data, Input, Row, Parameters<Context['evidence']>[0]> & {
|
|
397
363
|
columns: Columns & NonEmptyColumns<Columns>;
|
|
398
364
|
}): Dataset<Data, Input, Row>;
|
|
@@ -401,60 +367,54 @@ type BoundDetailView<Data, Input, Context extends AuthoringDataContext> = Detail
|
|
|
401
367
|
previous?: never;
|
|
402
368
|
}): Metric<Data, Input>;
|
|
403
369
|
};
|
|
404
|
-
/** Bind declared operations to URL
|
|
370
|
+
/** Bind declared operations to URL filters, displayed readings, and request feedback.
|
|
371
|
+
* The client's operations declare their filters; `<DataApp>` renders their controls. */
|
|
405
372
|
export declare function createDataHooks<Operations extends DataOperations>(client: DataClient<Operations>): {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
} & {
|
|
411
|
-
dataContext: Context;
|
|
412
|
-
date: ViewDate<Variables, InputOf<Operations[Name]>>;
|
|
413
|
-
}): BoundDataView<Name, Variables, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, true>;
|
|
414
|
-
<Name extends keyof Operations & string, const Variables extends VariableCollection = {}, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: DataViewDefinition<Name, Variables, InputOf<Operations[Name]>, OutputOf<Operations[Name]>> & {
|
|
415
|
-
operation: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown);
|
|
416
|
-
variables?: Variables & CheckedFacetSources<Operations, NoInfer<Variables>>;
|
|
417
|
-
} & {
|
|
418
|
-
dataContext: Context;
|
|
419
|
-
}): BoundDataView<Name, Variables, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, false>;
|
|
420
|
-
};
|
|
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>;
|
|
421
377
|
defineDetailView: <Name extends keyof Operations & string, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: DetailViewDefinition<OutputOf<Operations[Name]>, InputOf<Operations[Name]>> & {
|
|
422
378
|
operation: Name;
|
|
423
379
|
dataContext: Context;
|
|
424
|
-
}) => BoundDetailView<OutputOf<Operations[Name]>, InputOf<Operations[Name]>, Context
|
|
425
|
-
defineTimeView: {
|
|
426
|
-
<Name extends keyof Operations & string, const Additional extends VariableCollection = {}, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: DateTimeViewDefinition<Operations, Name, Additional, Context, DateTimeRangeComparisonVariable>): BoundDataView<Name, {
|
|
427
|
-
period: DateTimeRangeComparisonVariable;
|
|
428
|
-
} & Additional, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, true>;
|
|
429
|
-
<Name extends keyof Operations & string, const Additional extends VariableCollection = {}, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: DateTimeViewDefinition<Operations, Name, Additional, Context>): BoundDataView<Name, {
|
|
430
|
-
period: DateTimeRangeVariable;
|
|
431
|
-
} & Additional, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, false>;
|
|
432
|
-
<Name extends keyof Operations & string, const Additional extends VariableCollection = {}, const Context extends AuthoringDataContext = AuthoringDataContext>(definition: CalendarTimeViewDefinition<Operations, Name, Additional, Context>): BoundDataView<Name, TimeVariables<Additional>, InputOf<Operations[Name]>, OutputOf<Operations[Name]>, Context, true>;
|
|
433
|
-
};
|
|
434
|
-
defineFacetFilter: {
|
|
435
|
-
<const Context extends VariableCollection, const Name extends FacetOperationName<Operations, string>>(config: FacetConfig<Operations, string, Context, Name>): FacetVariable<string, Readonly<Context>, Name, InputOf<Operations[Name]>>;
|
|
436
|
-
<const Context extends VariableCollection, const Name extends FacetOperationName<Operations, number>>(config: FacetConfig<Operations, number, Context, Name>): FacetVariable<number, Readonly<Context>, Name, InputOf<Operations[Name]>>;
|
|
437
|
-
};
|
|
380
|
+
}) => BoundDetailView<OutputOf<Operations[Name]>, InputOf<Operations[Name]>, Context, DetailOwnInput<Operations[Name]>>;
|
|
438
381
|
};
|
|
439
382
|
//#endregion
|
|
440
383
|
//#region src/ui/DataApp.d.ts
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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;
|
|
445
406
|
/** Show supplied datasets’ record suggestions on the first declared search. Defaults to true. */
|
|
446
407
|
showSearchSuggestions?: boolean;
|
|
447
|
-
/** Omit to leave presentation out of the toolbar.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
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]>)[]];
|
|
453
413
|
/** Detail destinations available to dataset actions and metric record inspection. */
|
|
454
414
|
details?: readonly DetailContent<any, any>[];
|
|
455
415
|
};
|
|
456
|
-
/** Executes the primary view and owns
|
|
457
|
-
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;
|
|
458
418
|
//#endregion
|
|
459
419
|
//#region src/ui/Stack.d.ts
|
|
460
420
|
type StackProps = {
|
|
@@ -641,6 +601,8 @@ type DataSectionProps<Data, Input = unknown> = {
|
|
|
641
601
|
};
|
|
642
602
|
label?: string;
|
|
643
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. */
|
|
644
606
|
export declare function DataSection<Data, Input>({ content, ...presentation }: DataSectionProps<Data, Input>): import("react").JSX.Element;
|
|
645
607
|
//#endregion
|
|
646
608
|
//#region src/ui/DateTimeTooltip.d.ts
|
|
@@ -674,7 +636,7 @@ type PeriodSummaryProps = {
|
|
|
674
636
|
comparison?: PeriodComparison;
|
|
675
637
|
className?: string;
|
|
676
638
|
};
|
|
677
|
-
/** Read-only period context for the
|
|
639
|
+
/** Read-only period context for the control bar, including exact bounds for assistive technology. */
|
|
678
640
|
export declare function PeriodSummary({ period, comparison, className }: PeriodSummaryProps): import("react").JSX.Element;
|
|
679
641
|
//#endregion
|
|
680
642
|
//#region src/ui/shortcuts.d.ts
|
|
@@ -782,5 +744,5 @@ export declare function AnnotationBar({ ref, annotations, active, theme, disable
|
|
|
782
744
|
/** Install only the outer-frame annotation controls; leave host page typography and layout intact. */
|
|
783
745
|
export declare function injectDataAppAnnotationStyles(options?: DataAppStylesOptions): HTMLStyleElement;
|
|
784
746
|
//#endregion
|
|
785
|
-
export { type
|
|
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, 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 };
|
|
786
748
|
//# sourceMappingURL=index.d.ts.map
|