@sectile/vue 0.11.1 → 0.12.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/chart.d.ts +542 -0
- package/dist/chart.js +2 -0
- package/dist/chart.js.map +1 -0
- package/dist/form.d.ts +45 -23
- package/dist/form.js +1 -1
- package/dist/form.js.map +1 -1
- package/dist/internal/virtual-core.d.ts +4 -9
- package/dist/internal/virtual-core.js.map +1 -1
- package/dist/internal/virtual-list.js +1 -1
- package/dist/internal/virtual-list.js.map +1 -1
- package/dist/tabs.js +1 -1
- package/dist/tabs.js.map +1 -1
- package/dist/text.js +1 -1
- package/dist/text.js.map +1 -1
- package/package.json +22 -11
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
import type { StableID } from '@sectile/core';
|
|
2
|
+
import type { RevisionSnapshot } from '@sectile/core/revision';
|
|
3
|
+
import type { UnitID } from '@sectile/core/units';
|
|
4
|
+
import { type ChartController } from '@sectile/chart/controller';
|
|
5
|
+
import type { ChartAccessor, ChartAxisDomainInput, ChartAxisInputValue, ChartAxisViewUpdateMode, ChartAxisViewWindow, ChartHeatmapReduction, ChartViewState } from '@sectile/chart/contract';
|
|
6
|
+
import type { ChartDefinition, ChartDefinitionState, ResolvedChartLayer } from '@sectile/chart/definition';
|
|
7
|
+
import type { ChartCommand, ChartEvent, ChartSelection, ChartState } from '@sectile/chart/interaction';
|
|
8
|
+
import type { ChartLimits, ChartModel, ChartPatch } from '@sectile/chart/model';
|
|
9
|
+
import type { ChartProjection } from '@sectile/chart/projection';
|
|
10
|
+
import type { ChartResult } from '@sectile/chart/result';
|
|
11
|
+
import type { ChartScaleKind } from '@sectile/chart/scale';
|
|
12
|
+
import type { ChartAxisViewCapability } from '@sectile/chart/view';
|
|
13
|
+
import type { ResolvedChartAxis } from '@sectile/chart/layout';
|
|
14
|
+
import { type DOMChartConnection, type DOMChartDragMode, type DOMChartOptions, type DOMChartWheelMode, type DOMChartWheelModifier } from '@sectile/dom/chart';
|
|
15
|
+
import { type AllowedComponentProps, type ComponentCustomProps, type MaybeRefOrGetter, type PropType, type ShallowRef, type VNodeChild, type VNodeProps } from 'vue';
|
|
16
|
+
export interface ChartWritableRef<T> {
|
|
17
|
+
value: T;
|
|
18
|
+
}
|
|
19
|
+
export type ChartReactiveModel<ID extends StableID = StableID> = MaybeRefOrGetter<ChartModel<ID>>;
|
|
20
|
+
export type ChartReactiveDefinition<ID extends StableID = StableID> = MaybeRefOrGetter<ChartDefinition<any, ID>>;
|
|
21
|
+
interface UseChartStateOptions<ID extends StableID> {
|
|
22
|
+
readonly limits?: ChartLimits;
|
|
23
|
+
readonly activeDatum?: ChartWritableRef<ID | null>;
|
|
24
|
+
readonly defaultActiveDatum?: ID | null;
|
|
25
|
+
readonly cursor?: ChartWritableRef<ID | null>;
|
|
26
|
+
readonly defaultCursor?: ID | null;
|
|
27
|
+
readonly selection?: ChartWritableRef<ChartSelection<ID>>;
|
|
28
|
+
readonly defaultSelection?: ChartSelection<ID>;
|
|
29
|
+
readonly view?: ChartWritableRef<ChartViewState<ID> | null>;
|
|
30
|
+
readonly defaultView?: ChartViewState<ID> | null;
|
|
31
|
+
readonly onActiveDatumChange?: (value: ID | null) => void;
|
|
32
|
+
readonly onCursorChange?: (value: ID | null) => void;
|
|
33
|
+
readonly onSelectionChange?: (value: ChartSelection<ID>) => void;
|
|
34
|
+
readonly onViewChange?: (value: ChartViewState<ID> | null) => void;
|
|
35
|
+
readonly onCommand?: (command: ChartCommand<ID>) => void;
|
|
36
|
+
}
|
|
37
|
+
export type UseChartOptions<ID extends StableID = StableID> = UseChartStateOptions<ID> & ({
|
|
38
|
+
readonly model: ChartReactiveModel<ID>;
|
|
39
|
+
readonly definition?: never;
|
|
40
|
+
readonly viewCapabilities?: never;
|
|
41
|
+
} | {
|
|
42
|
+
readonly model?: never;
|
|
43
|
+
readonly definition: ChartReactiveDefinition<ID>;
|
|
44
|
+
readonly viewCapabilities?: MaybeRefOrGetter<readonly ChartAxisViewCapability<ID>[]>;
|
|
45
|
+
});
|
|
46
|
+
export interface UseChartResult<ID extends StableID = StableID> {
|
|
47
|
+
readonly controller: ChartController<ID>;
|
|
48
|
+
readonly snapshot: ShallowRef<RevisionSnapshot<ChartState<ID>>>;
|
|
49
|
+
readonly projection: ShallowRef<ChartProjection<ID> | null>;
|
|
50
|
+
readonly connection: ShallowRef<DOMChartConnection<ID> | null>;
|
|
51
|
+
replaceModel(model: ChartModel<ID>, expectedRevision?: number): ChartResult<RevisionSnapshot<ChartState<ID>>>;
|
|
52
|
+
replaceDefinition<Datum>(definition: ChartDefinition<Datum, ID>, viewCapabilities?: readonly ChartAxisViewCapability<ID>[], expectedRevision?: number): ChartResult<RevisionSnapshot<ChartState<ID>>>;
|
|
53
|
+
applyPatch(patch: ChartPatch<ID>, expectedRevision?: number): ChartResult<RevisionSnapshot<ChartState<ID>>>;
|
|
54
|
+
dispatch(event: ChartEvent<ID>, expectedRevision?: number): ChartResult<{
|
|
55
|
+
readonly snapshot: RevisionSnapshot<ChartState<ID>>;
|
|
56
|
+
readonly commands: readonly ChartCommand<ID>[];
|
|
57
|
+
}>;
|
|
58
|
+
syncControlledValues(): ChartResult<RevisionSnapshot<ChartState<ID>>>;
|
|
59
|
+
dispose(): void;
|
|
60
|
+
}
|
|
61
|
+
export interface ChartContext<ID extends StableID = StableID> {
|
|
62
|
+
readonly controller: Readonly<ShallowRef<ChartController<ID> | null>>;
|
|
63
|
+
readonly snapshot: Readonly<ShallowRef<RevisionSnapshot<ChartState<ID>> | null>>;
|
|
64
|
+
dispatch(event: ChartEvent<ID>): ChartResult<RevisionSnapshot<ChartState<ID>> | null>;
|
|
65
|
+
applyPatch(patch: ChartPatch<ID>): ChartResult<RevisionSnapshot<ChartState<ID>> | null>;
|
|
66
|
+
}
|
|
67
|
+
export declare function useChart<ID extends StableID>(options: UseChartOptions<ID>): UseChartResult<ID>;
|
|
68
|
+
export interface ChartRootProps<ID extends StableID = StableID> {
|
|
69
|
+
readonly limits?: ChartLimits;
|
|
70
|
+
readonly modelValue?: ChartSelection<ID>;
|
|
71
|
+
readonly defaultModelValue?: ChartSelection<ID>;
|
|
72
|
+
readonly activeDatum?: ID | null;
|
|
73
|
+
readonly defaultActiveDatum?: ID | null;
|
|
74
|
+
readonly cursor?: ID | null;
|
|
75
|
+
readonly defaultCursor?: ID | null;
|
|
76
|
+
readonly view?: ChartViewState<ID> | null;
|
|
77
|
+
readonly defaultView?: ChartViewState<ID> | null;
|
|
78
|
+
readonly patch?: ChartPatch<ID> | null;
|
|
79
|
+
readonly dom?: Omit<DOMChartOptions<ID>, 'root' | 'canvas' | 'controller' | 'navigation'>;
|
|
80
|
+
readonly onError?: (error: unknown) => void;
|
|
81
|
+
}
|
|
82
|
+
export interface ChartRootSlotProps<ID extends StableID = StableID> {
|
|
83
|
+
readonly controller: ChartController<ID> | null;
|
|
84
|
+
readonly snapshot: RevisionSnapshot<ChartState<ID>> | null;
|
|
85
|
+
readonly state: ChartState<ID> | null;
|
|
86
|
+
readonly projection: ChartProjection<ID> | null;
|
|
87
|
+
readonly definition: ChartDefinitionState<ID> | null;
|
|
88
|
+
}
|
|
89
|
+
export interface ChartDeclarationDiagnostics {
|
|
90
|
+
readonly registeredRecords: number;
|
|
91
|
+
readonly publications: number;
|
|
92
|
+
readonly readRecords: number;
|
|
93
|
+
}
|
|
94
|
+
export type ChartRootPublicProps<ID extends StableID = StableID> = ChartRootProps<ID> & VNodeProps & AllowedComponentProps & ComponentCustomProps & {
|
|
95
|
+
readonly 'onUpdate:modelValue'?: (value: ChartSelection<ID>) => unknown;
|
|
96
|
+
readonly 'onUpdate:activeDatum'?: (value: ID | null) => unknown;
|
|
97
|
+
readonly 'onUpdate:cursor'?: (value: ID | null) => unknown;
|
|
98
|
+
readonly 'onUpdate:view'?: (value: ChartViewState<ID> | null) => unknown;
|
|
99
|
+
readonly onCommand?: (command: ChartCommand<ID>) => unknown;
|
|
100
|
+
};
|
|
101
|
+
export interface ChartRootComponent {
|
|
102
|
+
new <ID extends StableID = StableID>(props: ChartRootPublicProps<ID>): {
|
|
103
|
+
$props: ChartRootPublicProps<ID>;
|
|
104
|
+
$slots: {
|
|
105
|
+
default?: (props: ChartRootSlotProps<ID>) => VNodeChild;
|
|
106
|
+
};
|
|
107
|
+
readonly controller: ShallowRef<ChartController<ID> | null>;
|
|
108
|
+
getDeclarationDiagnostics(): ChartDeclarationDiagnostics;
|
|
109
|
+
refresh(): void;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export declare function useChartContext<ID extends StableID = StableID>(): ChartContext<ID>;
|
|
113
|
+
export interface ChartProviderProps<ID extends StableID = StableID> {
|
|
114
|
+
readonly controller: ChartController<ID>;
|
|
115
|
+
}
|
|
116
|
+
export interface ChartProviderSlotProps<ID extends StableID = StableID> {
|
|
117
|
+
readonly controller: ChartController<ID>;
|
|
118
|
+
readonly snapshot: RevisionSnapshot<ChartState<ID>>;
|
|
119
|
+
readonly state: ChartState<ID>;
|
|
120
|
+
readonly definition: ChartDefinitionState<ID> | null;
|
|
121
|
+
}
|
|
122
|
+
export interface ChartProviderComponent {
|
|
123
|
+
new <ID extends StableID = StableID>(props: ChartProviderProps<ID>): {
|
|
124
|
+
$props: ChartProviderProps<ID>;
|
|
125
|
+
$slots: {
|
|
126
|
+
default?: (props: ChartProviderSlotProps<ID>) => VNodeChild;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export declare const ChartProvider: ChartProviderComponent;
|
|
131
|
+
export type ChartSelectorFunction<ID extends StableID, Selected> = (state: ChartState<ID> | null) => Selected;
|
|
132
|
+
export type ChartLayerSelectorFunction<ID extends StableID, Selected> = (layer: ResolvedChartLayer<ID> | null) => Selected;
|
|
133
|
+
export type ChartAxisSelectorFunction<ID extends StableID, Selected> = (axis: ResolvedChartAxis<ID> | null) => Selected;
|
|
134
|
+
export interface ChartSelectorOptions<Selected> {
|
|
135
|
+
readonly equals?: (previous: Selected, next: Selected) => boolean;
|
|
136
|
+
}
|
|
137
|
+
export declare function useChartSelector<ID extends StableID, Selected>(selector: ChartSelectorFunction<ID, Selected>, options?: ChartSelectorOptions<Selected>): Readonly<ShallowRef<Selected>>;
|
|
138
|
+
export declare function useChartLayerSelector<ID extends StableID, Selected>(id: ID, selector: ChartLayerSelectorFunction<ID, Selected>, options?: ChartSelectorOptions<Selected>): Readonly<ShallowRef<Selected>>;
|
|
139
|
+
export declare function useChartAxisSelector<ID extends StableID, Selected>(id: ID, selector: ChartAxisSelectorFunction<ID, Selected>, options?: ChartSelectorOptions<Selected>): Readonly<ShallowRef<Selected>>;
|
|
140
|
+
export declare const ChartRoot: ChartRootComponent;
|
|
141
|
+
export declare const ChartCartesian: import("vue").DefineComponent<{}, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
142
|
+
export declare const ChartRadial: import("vue").DefineComponent<{}, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
143
|
+
export interface ChartAxisProps<ID extends StableID = StableID> {
|
|
144
|
+
readonly id: ID;
|
|
145
|
+
readonly scale?: ChartScaleKind;
|
|
146
|
+
readonly domain?: ChartAxisDomainInput;
|
|
147
|
+
readonly field?: string;
|
|
148
|
+
readonly getValue?: ChartAccessor<any, ChartAxisInputValue>;
|
|
149
|
+
readonly ticks?: number;
|
|
150
|
+
readonly label?: string;
|
|
151
|
+
readonly unit?: UnitID;
|
|
152
|
+
}
|
|
153
|
+
export declare const ChartXAxis: GenericSemanticComponent<ChartAxisProps>;
|
|
154
|
+
export declare const ChartYAxis: GenericSemanticComponent<ChartAxisProps>;
|
|
155
|
+
interface GenericSemanticComponent<Props> {
|
|
156
|
+
new <ID extends StableID = StableID>(props: Props & {
|
|
157
|
+
readonly id: ID;
|
|
158
|
+
} & VNodeProps & AllowedComponentProps & ComponentCustomProps): {
|
|
159
|
+
$props: Props & {
|
|
160
|
+
readonly id: ID;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
interface ChartLayerBaseProps<Datum, ID extends StableID> {
|
|
165
|
+
readonly id: ID;
|
|
166
|
+
readonly data: readonly Datum[];
|
|
167
|
+
readonly getId?: ChartAccessor<Datum, ID>;
|
|
168
|
+
readonly label?: string;
|
|
169
|
+
}
|
|
170
|
+
export interface ChartCartesianLayerProps<Datum = unknown, ID extends StableID = StableID> extends ChartLayerBaseProps<Datum, ID> {
|
|
171
|
+
readonly xAxis: ID;
|
|
172
|
+
readonly yAxis: ID;
|
|
173
|
+
readonly getX?: ChartAccessor<Datum, ChartAxisInputValue>;
|
|
174
|
+
readonly getY?: ChartAccessor<Datum, ChartAxisInputValue>;
|
|
175
|
+
}
|
|
176
|
+
export interface ChartScatterProps<Datum = unknown, ID extends StableID = StableID> extends ChartCartesianLayerProps<Datum, ID> {
|
|
177
|
+
readonly projection?: 'raw' | 'density';
|
|
178
|
+
}
|
|
179
|
+
export interface ChartBarProps<Datum = unknown, ID extends StableID = StableID> extends ChartCartesianLayerProps<Datum, ID> {
|
|
180
|
+
readonly orientation?: 'vertical' | 'horizontal';
|
|
181
|
+
}
|
|
182
|
+
export interface ChartHeatmapProps<Datum = unknown, ID extends StableID = StableID> extends ChartCartesianLayerProps<Datum, ID> {
|
|
183
|
+
readonly getValue?: ChartAccessor<Datum, number>;
|
|
184
|
+
readonly valueField?: string;
|
|
185
|
+
readonly projection?: 'raw' | {
|
|
186
|
+
readonly kind: 'aggregate';
|
|
187
|
+
readonly reduction: ChartHeatmapReduction;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export interface ChartRadialLayerProps<Datum = unknown, ID extends StableID = StableID> extends ChartLayerBaseProps<Datum, ID> {
|
|
191
|
+
readonly getValue?: ChartAccessor<Datum, number>;
|
|
192
|
+
readonly valueField?: string;
|
|
193
|
+
readonly getLabel?: ChartAccessor<Datum, string>;
|
|
194
|
+
readonly labelField?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface ChartDonutProps<Datum = unknown, ID extends StableID = StableID> extends ChartRadialLayerProps<Datum, ID> {
|
|
197
|
+
readonly innerRadius?: number;
|
|
198
|
+
readonly outerRadius?: number;
|
|
199
|
+
}
|
|
200
|
+
type ChartSemanticPublicProps<Props> = Props & VNodeProps & AllowedComponentProps & ComponentCustomProps;
|
|
201
|
+
export interface ChartLineComponent {
|
|
202
|
+
new <Datum = unknown, ID extends StableID = StableID>(props: ChartSemanticPublicProps<ChartCartesianLayerProps<Datum, ID>>): {
|
|
203
|
+
$props: ChartCartesianLayerProps<Datum, ID>;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export interface ChartScatterComponent {
|
|
207
|
+
new <Datum = unknown, ID extends StableID = StableID>(props: ChartSemanticPublicProps<ChartScatterProps<Datum, ID>>): {
|
|
208
|
+
$props: ChartScatterProps<Datum, ID>;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export interface ChartBarComponent {
|
|
212
|
+
new <Datum = unknown, ID extends StableID = StableID>(props: ChartSemanticPublicProps<ChartBarProps<Datum, ID>>): {
|
|
213
|
+
$props: ChartBarProps<Datum, ID>;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export interface ChartHeatmapComponent {
|
|
217
|
+
new <Datum = unknown, ID extends StableID = StableID>(props: ChartSemanticPublicProps<ChartHeatmapProps<Datum, ID>>): {
|
|
218
|
+
$props: ChartHeatmapProps<Datum, ID>;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
export interface ChartPieComponent {
|
|
222
|
+
new <Datum = unknown, ID extends StableID = StableID>(props: ChartSemanticPublicProps<ChartRadialLayerProps<Datum, ID>>): {
|
|
223
|
+
$props: ChartRadialLayerProps<Datum, ID>;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
export interface ChartDonutComponent {
|
|
227
|
+
new <Datum = unknown, ID extends StableID = StableID>(props: ChartSemanticPublicProps<ChartDonutProps<Datum, ID>>): {
|
|
228
|
+
$props: ChartDonutProps<Datum, ID>;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export declare const ChartLine: ChartLineComponent;
|
|
232
|
+
export declare const ChartScatter: ChartScatterComponent;
|
|
233
|
+
export declare const ChartBar: ChartBarComponent;
|
|
234
|
+
export declare const ChartBars: ChartBarComponent;
|
|
235
|
+
export declare const ChartHeatmap: ChartHeatmapComponent;
|
|
236
|
+
export declare const ChartPie: ChartPieComponent;
|
|
237
|
+
export declare const ChartDonut: ChartDonutComponent;
|
|
238
|
+
export interface ChartAxisViewProps<ID extends StableID = StableID> {
|
|
239
|
+
readonly axis?: ID;
|
|
240
|
+
readonly initial?: ChartAxisViewWindow;
|
|
241
|
+
readonly minimumSpan?: number;
|
|
242
|
+
readonly maximumSpan?: number;
|
|
243
|
+
readonly update?: ChartAxisViewUpdateMode;
|
|
244
|
+
}
|
|
245
|
+
export declare const ChartAxisView: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
246
|
+
axis: {
|
|
247
|
+
type: PropType<StableID>;
|
|
248
|
+
default: undefined;
|
|
249
|
+
};
|
|
250
|
+
initial: {
|
|
251
|
+
type: PropType<ChartAxisViewWindow>;
|
|
252
|
+
default: undefined;
|
|
253
|
+
};
|
|
254
|
+
minimumSpan: {
|
|
255
|
+
type: NumberConstructor;
|
|
256
|
+
default: undefined;
|
|
257
|
+
};
|
|
258
|
+
maximumSpan: {
|
|
259
|
+
type: NumberConstructor;
|
|
260
|
+
default: undefined;
|
|
261
|
+
};
|
|
262
|
+
update: {
|
|
263
|
+
type: PropType<ChartAxisViewUpdateMode>;
|
|
264
|
+
default: string;
|
|
265
|
+
};
|
|
266
|
+
}>, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
267
|
+
axis: {
|
|
268
|
+
type: PropType<StableID>;
|
|
269
|
+
default: undefined;
|
|
270
|
+
};
|
|
271
|
+
initial: {
|
|
272
|
+
type: PropType<ChartAxisViewWindow>;
|
|
273
|
+
default: undefined;
|
|
274
|
+
};
|
|
275
|
+
minimumSpan: {
|
|
276
|
+
type: NumberConstructor;
|
|
277
|
+
default: undefined;
|
|
278
|
+
};
|
|
279
|
+
maximumSpan: {
|
|
280
|
+
type: NumberConstructor;
|
|
281
|
+
default: undefined;
|
|
282
|
+
};
|
|
283
|
+
update: {
|
|
284
|
+
type: PropType<ChartAxisViewUpdateMode>;
|
|
285
|
+
default: string;
|
|
286
|
+
};
|
|
287
|
+
}>> & Readonly<{}>, {
|
|
288
|
+
axis: StableID;
|
|
289
|
+
initial: ChartAxisViewWindow;
|
|
290
|
+
minimumSpan: number;
|
|
291
|
+
maximumSpan: number;
|
|
292
|
+
update: ChartAxisViewUpdateMode;
|
|
293
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
294
|
+
export interface ChartNavigationProps<ID extends StableID = StableID> {
|
|
295
|
+
readonly axes?: readonly ID[];
|
|
296
|
+
readonly drag?: DOMChartDragMode;
|
|
297
|
+
readonly wheel?: DOMChartWheelMode;
|
|
298
|
+
readonly wheelModifier?: DOMChartWheelModifier;
|
|
299
|
+
readonly pinch?: boolean;
|
|
300
|
+
readonly keyboard?: boolean;
|
|
301
|
+
}
|
|
302
|
+
export declare const ChartNavigation: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
303
|
+
axes: {
|
|
304
|
+
type: PropType<readonly StableID[]>;
|
|
305
|
+
default: undefined;
|
|
306
|
+
};
|
|
307
|
+
drag: {
|
|
308
|
+
type: PropType<DOMChartDragMode>;
|
|
309
|
+
default: string;
|
|
310
|
+
};
|
|
311
|
+
wheel: {
|
|
312
|
+
type: PropType<DOMChartWheelMode>;
|
|
313
|
+
default: string;
|
|
314
|
+
};
|
|
315
|
+
wheelModifier: {
|
|
316
|
+
type: PropType<DOMChartWheelModifier>;
|
|
317
|
+
default: string;
|
|
318
|
+
};
|
|
319
|
+
pinch: {
|
|
320
|
+
type: BooleanConstructor;
|
|
321
|
+
default: boolean;
|
|
322
|
+
};
|
|
323
|
+
keyboard: {
|
|
324
|
+
type: BooleanConstructor;
|
|
325
|
+
default: boolean;
|
|
326
|
+
};
|
|
327
|
+
}>, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
328
|
+
axes: {
|
|
329
|
+
type: PropType<readonly StableID[]>;
|
|
330
|
+
default: undefined;
|
|
331
|
+
};
|
|
332
|
+
drag: {
|
|
333
|
+
type: PropType<DOMChartDragMode>;
|
|
334
|
+
default: string;
|
|
335
|
+
};
|
|
336
|
+
wheel: {
|
|
337
|
+
type: PropType<DOMChartWheelMode>;
|
|
338
|
+
default: string;
|
|
339
|
+
};
|
|
340
|
+
wheelModifier: {
|
|
341
|
+
type: PropType<DOMChartWheelModifier>;
|
|
342
|
+
default: string;
|
|
343
|
+
};
|
|
344
|
+
pinch: {
|
|
345
|
+
type: BooleanConstructor;
|
|
346
|
+
default: boolean;
|
|
347
|
+
};
|
|
348
|
+
keyboard: {
|
|
349
|
+
type: BooleanConstructor;
|
|
350
|
+
default: boolean;
|
|
351
|
+
};
|
|
352
|
+
}>> & Readonly<{}>, {
|
|
353
|
+
axes: readonly StableID[];
|
|
354
|
+
drag: DOMChartDragMode;
|
|
355
|
+
wheel: DOMChartWheelMode;
|
|
356
|
+
wheelModifier: DOMChartWheelModifier;
|
|
357
|
+
pinch: boolean;
|
|
358
|
+
keyboard: boolean;
|
|
359
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
360
|
+
export declare const ChartViewControls: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
361
|
+
axis: {
|
|
362
|
+
type: PropType<StableID>;
|
|
363
|
+
default: undefined;
|
|
364
|
+
};
|
|
365
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
366
|
+
axis: {
|
|
367
|
+
type: PropType<StableID>;
|
|
368
|
+
default: undefined;
|
|
369
|
+
};
|
|
370
|
+
}>> & Readonly<{}>, {
|
|
371
|
+
axis: StableID;
|
|
372
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
373
|
+
export declare const ChartExternalViewControls: import("vue").DefineComponent<{}, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
374
|
+
export declare const ChartPanControl: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
375
|
+
axis: {
|
|
376
|
+
type: PropType<StableID>;
|
|
377
|
+
default: undefined;
|
|
378
|
+
};
|
|
379
|
+
label: {
|
|
380
|
+
type: StringConstructor;
|
|
381
|
+
default: undefined;
|
|
382
|
+
};
|
|
383
|
+
direction: {
|
|
384
|
+
type: PropType<'backward' | 'forward'>;
|
|
385
|
+
required: true;
|
|
386
|
+
};
|
|
387
|
+
step: {
|
|
388
|
+
type: NumberConstructor;
|
|
389
|
+
default: number;
|
|
390
|
+
};
|
|
391
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
392
|
+
axis: {
|
|
393
|
+
type: PropType<StableID>;
|
|
394
|
+
default: undefined;
|
|
395
|
+
};
|
|
396
|
+
label: {
|
|
397
|
+
type: StringConstructor;
|
|
398
|
+
default: undefined;
|
|
399
|
+
};
|
|
400
|
+
direction: {
|
|
401
|
+
type: PropType<'backward' | 'forward'>;
|
|
402
|
+
required: true;
|
|
403
|
+
};
|
|
404
|
+
step: {
|
|
405
|
+
type: NumberConstructor;
|
|
406
|
+
default: number;
|
|
407
|
+
};
|
|
408
|
+
}>> & Readonly<{}>, {
|
|
409
|
+
axis: StableID;
|
|
410
|
+
label: string;
|
|
411
|
+
step: number;
|
|
412
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
413
|
+
export declare const ChartZoomControl: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
414
|
+
axis: {
|
|
415
|
+
type: PropType<StableID>;
|
|
416
|
+
default: undefined;
|
|
417
|
+
};
|
|
418
|
+
label: {
|
|
419
|
+
type: StringConstructor;
|
|
420
|
+
default: undefined;
|
|
421
|
+
};
|
|
422
|
+
direction: {
|
|
423
|
+
type: PropType<'in' | 'out'>;
|
|
424
|
+
required: true;
|
|
425
|
+
};
|
|
426
|
+
factor: {
|
|
427
|
+
type: NumberConstructor;
|
|
428
|
+
default: number;
|
|
429
|
+
};
|
|
430
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
431
|
+
axis: {
|
|
432
|
+
type: PropType<StableID>;
|
|
433
|
+
default: undefined;
|
|
434
|
+
};
|
|
435
|
+
label: {
|
|
436
|
+
type: StringConstructor;
|
|
437
|
+
default: undefined;
|
|
438
|
+
};
|
|
439
|
+
direction: {
|
|
440
|
+
type: PropType<'in' | 'out'>;
|
|
441
|
+
required: true;
|
|
442
|
+
};
|
|
443
|
+
factor: {
|
|
444
|
+
type: NumberConstructor;
|
|
445
|
+
default: number;
|
|
446
|
+
};
|
|
447
|
+
}>> & Readonly<{}>, {
|
|
448
|
+
axis: StableID;
|
|
449
|
+
label: string;
|
|
450
|
+
factor: number;
|
|
451
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
452
|
+
export declare const ChartResetView: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
453
|
+
axis: {
|
|
454
|
+
type: PropType<StableID>;
|
|
455
|
+
default: undefined;
|
|
456
|
+
};
|
|
457
|
+
label: {
|
|
458
|
+
type: StringConstructor;
|
|
459
|
+
default: undefined;
|
|
460
|
+
};
|
|
461
|
+
to: {
|
|
462
|
+
type: PropType<'initial' | 'latest'>;
|
|
463
|
+
default: string;
|
|
464
|
+
};
|
|
465
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
466
|
+
axis: {
|
|
467
|
+
type: PropType<StableID>;
|
|
468
|
+
default: undefined;
|
|
469
|
+
};
|
|
470
|
+
label: {
|
|
471
|
+
type: StringConstructor;
|
|
472
|
+
default: undefined;
|
|
473
|
+
};
|
|
474
|
+
to: {
|
|
475
|
+
type: PropType<'initial' | 'latest'>;
|
|
476
|
+
default: string;
|
|
477
|
+
};
|
|
478
|
+
}>> & Readonly<{}>, {
|
|
479
|
+
axis: StableID;
|
|
480
|
+
label: string;
|
|
481
|
+
to: "initial" | "latest";
|
|
482
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
483
|
+
export declare const ChartPlot: import("vue").DefineComponent<{}, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
484
|
+
export declare const ChartRenderer: import("vue").DefineComponent<{}, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
485
|
+
export declare const ChartCanvas: import("vue").DefineComponent<{}, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
486
|
+
export declare const ChartGrid: import("vue").DefineComponent<{}, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
487
|
+
export declare const ChartGridLines: import("vue").DefineComponent<{}, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
488
|
+
export declare const ChartLegend: import("vue").DefineComponent<{}, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
489
|
+
export declare const ChartAxisTicks: import("vue").DefineComponent<{}, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
490
|
+
export declare const ChartTicks: import("vue").DefineComponent<{}, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
491
|
+
export type ChartBoundProviderPublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps;
|
|
492
|
+
export interface ChartBoundProviderComponent<ID extends StableID = StableID> {
|
|
493
|
+
new (props: ChartBoundProviderPublicProps): {
|
|
494
|
+
$props: ChartBoundProviderPublicProps;
|
|
495
|
+
$slots: {
|
|
496
|
+
default?: (props: ChartProviderSlotProps<ID>) => VNodeChild;
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
export interface ChartBoundRootComponent<ID extends StableID = StableID> {
|
|
501
|
+
new (props: ChartRootPublicProps<ID>): {
|
|
502
|
+
$props: ChartRootPublicProps<ID>;
|
|
503
|
+
$slots: {
|
|
504
|
+
default?: (props: ChartRootSlotProps<ID>) => VNodeChild;
|
|
505
|
+
};
|
|
506
|
+
readonly controller: ShallowRef<ChartController<ID> | null>;
|
|
507
|
+
getDeclarationDiagnostics(): ChartDeclarationDiagnostics;
|
|
508
|
+
refresh(): void;
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
export interface ChartComponents<ID extends StableID = StableID> {
|
|
512
|
+
readonly Provider: ChartBoundProviderComponent<ID>;
|
|
513
|
+
readonly Root: ChartBoundRootComponent<ID>;
|
|
514
|
+
readonly Cartesian: typeof ChartCartesian;
|
|
515
|
+
readonly Radial: typeof ChartRadial;
|
|
516
|
+
readonly XAxis: typeof ChartXAxis;
|
|
517
|
+
readonly YAxis: typeof ChartYAxis;
|
|
518
|
+
readonly AxisView: typeof ChartAxisView;
|
|
519
|
+
readonly Line: typeof ChartLine;
|
|
520
|
+
readonly Scatter: typeof ChartScatter;
|
|
521
|
+
readonly Bar: typeof ChartBar;
|
|
522
|
+
readonly Bars: typeof ChartBars;
|
|
523
|
+
readonly Heatmap: typeof ChartHeatmap;
|
|
524
|
+
readonly Pie: typeof ChartPie;
|
|
525
|
+
readonly Donut: typeof ChartDonut;
|
|
526
|
+
readonly Navigation: typeof ChartNavigation;
|
|
527
|
+
readonly ViewControls: typeof ChartViewControls;
|
|
528
|
+
readonly ExternalViewControls: typeof ChartExternalViewControls;
|
|
529
|
+
readonly PanControl: typeof ChartPanControl;
|
|
530
|
+
readonly ZoomControl: typeof ChartZoomControl;
|
|
531
|
+
readonly ResetView: typeof ChartResetView;
|
|
532
|
+
readonly Plot: typeof ChartPlot;
|
|
533
|
+
readonly Renderer: typeof ChartRenderer;
|
|
534
|
+
readonly Canvas: typeof ChartCanvas;
|
|
535
|
+
readonly Grid: typeof ChartGrid;
|
|
536
|
+
readonly GridLines: typeof ChartGridLines;
|
|
537
|
+
readonly Legend: typeof ChartLegend;
|
|
538
|
+
readonly AxisTicks: typeof ChartAxisTicks;
|
|
539
|
+
readonly Ticks: typeof ChartTicks;
|
|
540
|
+
}
|
|
541
|
+
export declare function createChartComponents<ID extends StableID>(controller: ChartController<ID>): ChartComponents<ID>;
|
|
542
|
+
export {};
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createChartController}from"@sectile/chart/controller";import{createDOMChart}from"@sectile/dom/chart";import{defineComponent,getCurrentScope,h,inject,nextTick,onBeforeUnmount,onMounted,onScopeDispose,provide,shallowRef,toValue,watch}from"vue";function useChart(options){if(options===null||typeof options!=="object")throw new TypeError("useChart options must be an object.");if(options.model===void 0===(options.definition===void 0)){throw new TypeError("useChart requires exactly one model or declarative definition.")}assertControlledDefaults(options);const controlled=controlledValues(options);const source=options.definition===void 0?{model:toValue(options.model)}:{definition:toValue(options.definition),viewCapabilities:toValue(options.viewCapabilities??(()=>Object.freeze([])))};const controller=createChartController({...source,...options.limits===void 0?{}:{limits:options.limits},...defaultValues(options),...Object.keys(controlled).length===0?{}:{controlled}});const binding=bindController(controller,options,true);const stops=[];if(options.model!==void 0){stops.push(watch(()=>toValue(options.model),model=>{binding.replaceModel(model)},{deep:false}))}else{stops.push(watch(()=>[toValue(options.definition),toValue(options.viewCapabilities??(()=>Object.freeze([])))],([definition,capabilities])=>{binding.replaceDefinition(definition,capabilities)},{deep:false}))}for(const sourceRef of[options.activeDatum,options.cursor,options.selection,options.view]){if(sourceRef!==void 0)stops.push(watch(()=>sourceRef.value,()=>{binding.syncControlledValues()},{deep:false}))}const disposeBinding=binding.dispose;const result=Object.freeze({...binding,dispose(){for(const stop of stops.splice(0))stop();disposeBinding()}});if(getCurrentScope()!==void 0)onScopeDispose(result.dispose);return result}class ChartDeclarations{#records=new Map;#publish;#token=0;#scheduled=false;#active=true;#publications=0;#readRecords=0;constructor(publish){this.#publish=publish}register(kind,read){const token=++this.#token;this.#records.set(token,{token,kind,read});this.schedule();let active=true;return Object.freeze({touch:()=>{if(active)this.schedule()},dispose:()=>{if(!active)return;active=false;this.#records.delete(token);this.schedule()}})}publishNow(){if(!this.#active)return;this.#scheduled=false;this.#publish(this.assemble());this.#publications+=1}getDiagnostics(){return Object.freeze({registeredRecords:this.#records.size,publications:this.#publications,readRecords:this.#readRecords})}schedule(){if(!this.#active||this.#scheduled)return;this.#scheduled=true;void nextTick(()=>{if(this.#scheduled)this.publishNow()})}assemble(){const records=[...this.#records.values()].sort((left,right)=>left.token-right.token);this.#readRecords=records.length;const coordinates=records.filter(record=>record.kind==="coordinate");if(coordinates.length!==1)throw new TypeError("ChartRoot requires exactly one ChartCartesian or ChartRadial coordinate.");const coordinate=coordinates[0]?.read();const axes=records.filter(record=>record.kind==="axis").map(record=>record.read());const layers=records.filter(record=>record.kind==="layer").map(record=>record.read());const capabilities=records.filter(record=>record.kind==="view").map(record=>record.read());const navigationRecords=records.filter(record=>record.kind==="navigation");if(navigationRecords.length>1)throw new TypeError("ChartRoot accepts at most one ChartNavigation declaration.");const controls=records.filter(record=>record.kind==="controls").map(record=>record.read());const navigation=navigationRecords[0]?.read();const alternative=controls.includes("built-in")?"built-in":controls.includes("external")?"external":void 0;if(navigation!==void 0&&((navigation.drag??"none")!=="none"||navigation.pinch===true)&&alternative===void 0){throw new TypeError("Chart direct gestures require ChartViewControls or ChartExternalViewControls.")}return Object.freeze({definition:Object.freeze({coordinate:coordinate.kind==="cartesian"?Object.freeze({kind:"cartesian",axes:Object.freeze(axes)}):Object.freeze({kind:"radial"}),layers:Object.freeze(layers)}),viewCapabilities:Object.freeze(capabilities),navigation:Object.freeze({...navigation??{},...alternative===void 0?{}:{controlAlternative:alternative}})})}dispose(){if(!this.#active)return;this.#active=false;this.#scheduled=false;this.#records.clear()}}const chartKey=Symbol("SectileChart");const chartPublicKey=Symbol("SectileChartPublic");const chartOwnerKey=Symbol("SectileChartOwner");const chartAxisKey=Symbol("SectileChartAxis");const chartControlAxisKey=Symbol("SectileChartControlAxis");function useInternalChart(){const context=inject(chartKey);if(context===void 0)throw new TypeError("Chart component must be used inside ChartRoot.");return context}function useChartContext(){const context=inject(chartPublicKey);if(context===void 0)throw new TypeError("useChartContext must be used inside ChartRoot or ChartProvider.");return context}const ChartProviderRuntime=defineComponent({name:"SectileChartProvider",props:{controller:{type:Object,required:true}},setup(props,{slots}){const controller=shallowRef(props.controller);const snapshot=shallowRef(controller.value.getSnapshot());const unsubscribe=controller.value.subscribeSnapshots(next=>{snapshot.value=next});const owner=Object.freeze({controller});const context=Object.freeze({controller,snapshot,dispatch(event){const result=controller.value.dispatch(event);return result.ok?Object.freeze({ok:true,value:result.value.snapshot}):result},applyPatch(patch){return controller.value.applyPatch(patch)}});provide(chartOwnerKey,owner);provide(chartPublicKey,context);onScopeDispose(unsubscribe);return()=>slots["default"]?.({controller:controller.value,snapshot:snapshot.value,state:snapshot.value.state,definition:controller.value.getDefinition()})??null}});const ChartProvider=ChartProviderRuntime;function useChartSelector(selector,options={}){const context=useChartContext();return useChartContextSelector(context,()=>selector(context.snapshot.value?.state??null),options.equals)}function useChartLayerSelector(id,selector,options={}){const context=useChartContext();return useChartContextSelector(context,()=>{const layers=context.controller.value?.getDefinition()?.layers;return selector(layers?.find(layer=>layer.id===id)??null)},options.equals)}function useChartAxisSelector(id,selector,options={}){const context=useChartContext();return useChartContextSelector(context,()=>{const axes=context.controller.value?.getDefinition()?.axes;return selector(axes?.find(axis=>axis.id===id)??null)},options.equals)}function useChartContextSelector(context,read,equals=Object.is){const selected=shallowRef(read());const stop=watch([context.controller,context.snapshot],()=>{const next=read();if(!equals(selected.value,next))selected.value=next},{deep:false,flush:"sync"});onScopeDispose(stop);return selected}const ChartRootRuntime=defineComponent({name:"SectileChartRoot",inheritAttrs:false,props:{limits:{type:Object,default:void 0},modelValue:{type:Object,default:void 0},defaultModelValue:{type:Object,default:void 0},activeDatum:{type:[String,Number],default:void 0},defaultActiveDatum:{type:[String,Number],default:void 0},cursor:{type:[String,Number],default:void 0},defaultCursor:{type:[String,Number],default:void 0},view:{type:Object,default:void 0},defaultView:{type:Object,default:void 0},patch:{type:Object,default:void 0},dom:{type:Object,default:void 0},onError:{type:Function,default:void 0}},emits:{"update:modelValue":_value=>true,"update:activeDatum":_value=>true,"update:cursor":_value=>true,"update:view":_value=>true,command:_command=>true},setup(props,{attrs,emit,expose,slots}){assertRootControlledDefaults(props);const ownerContext=inject(chartOwnerKey,void 0);const ownsController=ownerContext===void 0;const root=shallowRef(null);const canvas=shallowRef(null);const controller=shallowRef(ownerContext?.controller.value??null);const snapshot=shallowRef(controller.value?.getSnapshot()??null);const projection=shallowRef(null);const connection=shallowRef(null);let assembled=null;let unsubscribeCommands=null;let unsubscribeSnapshots=null;let previousState=snapshot.value?.state??null;let mounted=false;let definitionAccepted=false;const controlled=Object.freeze({activeDatum:props.activeDatum!==void 0,cursor:props.cursor!==void 0,selection:props.modelValue!==void 0,view:props.view!==void 0});const report=error=>{if(props.onError!==void 0)props.onError(error);else throw error};const publishSnapshot=()=>{const owner=controller.value;if(owner===null)return;const current=owner.getSnapshot();if(snapshot.value===current)return;const prior=previousState;snapshot.value=current;previousState=current.state;if(prior!==null){if(!controlled.activeDatum&&prior.activeDatum!==current.state.activeDatum)emit("update:activeDatum",current.state.activeDatum);if(!controlled.cursor&&prior.cursor!==current.state.cursor)emit("update:cursor",current.state.cursor);if(!controlled.selection&&prior.selection!==current.state.selection)emit("update:modelValue",current.state.selection);if(!controlled.view&&prior.view!==current.state.view)emit("update:view",current.state.view)}};const onCommand=command=>{emit("command",command);if(command.type==="active-change-requested")emit("update:activeDatum",command.id);else if(command.type==="cursor-change-requested")emit("update:cursor",command.id);else if(command.type==="selection-change-requested")emit("update:modelValue",command.selection);else if(command.type==="view-change-requested")emit("update:view",command.view);publishSnapshot()};const connect=()=>{const owner=controller.value;if(!mounted||owner===null||root.value===null||canvas.value===null||connection.value!==null)return;const dom=props.dom??{};try{connection.value=createDOMChart({...dom,root:root.value,canvas:canvas.value,controller:owner,...assembled===null?{}:{navigation:assembled.navigation},onCommand:command=>{dom.onCommand?.(command)},onProjectionChange:next=>{projection.value=next;dom.onProjectionChange?.(next)}});projection.value=connection.value.getProjection()}catch(error){report(error)}};const publishDefinition=next=>{assembled=next;definitionAccepted=false;const owner=controller.value;if(!mounted||owner===null)return;const replaced=owner.replaceDefinition(next.definition,next.viewCapabilities);if(!replaced.ok){report(new TypeError(`${replaced.error.code}: ${replaced.error.message}`));return}definitionAccepted=true;publishSnapshot();const navigation=connection.value?.setNavigation(next.navigation);if(navigation!==void 0&&!navigation.ok)report(new TypeError(`${navigation.error.code}: ${navigation.error.message}`));connection.value?.refresh()};const declarations=new ChartDeclarations(next=>{try{publishDefinition(next)}catch(error){report(error)}});const context=Object.freeze({declarations,controller,canvas,dispatch(event){const result=controller.value?.dispatch(event);if(result!==void 0&&!result.ok)report(new TypeError(`${result.error.code}: ${result.error.message}`));publishSnapshot()}});provide(chartKey,context);const publicContext=Object.freeze({controller,snapshot,dispatch(event){const result=controller.value?.dispatch(event);if(result===void 0)return Object.freeze({ok:true,value:null});publishSnapshot();return result.ok?Object.freeze({ok:true,value:result.value.snapshot}):result},applyPatch(patch){const result=controller.value?.applyPatch(patch);if(result===void 0)return Object.freeze({ok:true,value:null});publishSnapshot();return result}});provide(chartPublicKey,publicContext);const syncControlled=()=>{const owner=controller.value;if(owner===null)return;const result=owner.syncControlledValues(Object.freeze({...controlled.activeDatum?{activeDatum:props.activeDatum??null}:{},...controlled.cursor?{cursor:props.cursor??null}:{},...controlled.selection?{selection:props.modelValue}:{},...controlled.view?{view:props.view??null}:{}}));if(!result.ok)report(new TypeError(`${result.error.code}: ${result.error.message}`));publishSnapshot()};watch(()=>[props.activeDatum,props.cursor,props.modelValue,props.view],syncControlled,{deep:false});watch(()=>props.patch,patch=>{if(patch===null||patch===void 0||controller.value===null)return;const result=controller.value.applyPatch(patch);if(!result.ok)report(new TypeError(`${result.error.code}: ${result.error.message}`));publishSnapshot()},{deep:false});watch(()=>props.dom?.accessibilityLabel,label=>{connection.value?.setAccessibilityLabel(label)},{flush:"post"});onMounted(()=>{mounted=true;try{declarations.publishNow();const next=assembled;const controlledValues2=Object.freeze({...controlled.activeDatum?{activeDatum:props.activeDatum??null}:{},...controlled.cursor?{cursor:props.cursor??null}:{},...controlled.selection?{selection:props.modelValue}:{},...controlled.view?{view:props.view??null}:{}});const initialValues=Object.freeze({...!controlled.activeDatum&&props.defaultActiveDatum!==void 0?{activeDatum:props.defaultActiveDatum}:{},...!controlled.cursor&&props.defaultCursor!==void 0?{cursor:props.defaultCursor}:{},...!controlled.selection&&props.defaultModelValue!==void 0?{selection:props.defaultModelValue}:{},...!controlled.view&&props.defaultView!==void 0?{view:props.defaultView}:{}});if(ownerContext===void 0){controller.value=createChartController({definition:next.definition,viewCapabilities:next.viewCapabilities,...props.limits===void 0?{}:{limits:props.limits},...Object.keys(controlledValues2).length===0?{}:{controlled:controlledValues2},...Object.keys(initialValues).length===0?{}:{initialValues}})}else{const borrowed=ownerContext.controller.value;if(!definitionAccepted)return;controller.value=borrowed;if(Object.keys(controlledValues2).length!==0){const synced=borrowed.syncControlledValues(controlledValues2);if(!synced.ok)throw new TypeError(`${synced.error.code}: ${synced.error.message}`)}}snapshot.value=controller.value.getSnapshot();previousState=snapshot.value.state;unsubscribeCommands=controller.value.subscribeCommands(onCommand);unsubscribeSnapshots=controller.value.subscribeSnapshots(()=>{publishSnapshot()});void nextTick(connect)}catch(error){report(error)}});onBeforeUnmount(()=>{mounted=false;declarations.dispose();connection.value?.disconnect();connection.value=null;unsubscribeCommands?.();unsubscribeCommands=null;unsubscribeSnapshots?.();unsubscribeSnapshots=null;if(ownsController)controller.value?.dispose();controller.value=null});expose({controller,getDeclarationDiagnostics:()=>declarations.getDiagnostics(),refresh:()=>connection.value?.refresh()});return()=>h("div",{...attrs,ref:element=>{root.value=element},"data-scope":"chart","data-part":"root"},slots["default"]?.({controller:controller.value,snapshot:snapshot.value,state:snapshot.value?.state??null,projection:projection.value,definition:controller.value?.getDefinition()??null}))}});const ChartRoot=ChartRootRuntime;const coordinateProps={};const ChartCartesian=defineComponent({name:"SectileChartCartesian",props:coordinateProps,setup(_props,{slots}){const context=useInternalChart();const record=context.declarations.register("coordinate",()=>Object.freeze({kind:"cartesian"}));onBeforeUnmount(record.dispose);return()=>slots["default"]?.()??null}});const ChartRadial=defineComponent({name:"SectileChartRadial",props:coordinateProps,setup(_props,{slots}){const context=useInternalChart();const record=context.declarations.register("coordinate",()=>Object.freeze({kind:"radial"}));onBeforeUnmount(record.dispose);return()=>slots["default"]?.()??null}});const axisProps={id:{type:[String,Number],required:true},scale:{type:String,default:"linear"},domain:{type:[String,Object],default:"auto"},field:{type:String,default:void 0},getValue:{type:Function,default:void 0},ticks:{type:Number,default:void 0},label:{type:String,default:void 0},unit:{type:String,default:void 0}};function axisComponent(orientation){return defineComponent({name:orientation==="x"?"SectileChartXAxis":"SectileChartYAxis",props:axisProps,setup(props,{slots}){const context=useInternalChart();const axis=shallowRef(props.id);provide(chartAxisKey,axis);const value=shallowRef(axisDefinition(props,orientation));const record=context.declarations.register("axis",()=>value.value);watch(()=>[props.id,props.scale,props.domain,props.field,props.getValue,props.ticks,props.label,props.unit],()=>{axis.value=props.id;value.value=axisDefinition(props,orientation);record.touch()},{deep:false,flush:"post"});onBeforeUnmount(record.dispose);return()=>slots["default"]?.()??null}})}const ChartXAxis=axisComponent("x");const ChartYAxis=axisComponent("y");function axisDefinition(props,orientation){return defined({id:props["id"],orientation,scale:props["scale"],domain:props["domain"],field:props["field"],getValue:props["getValue"],ticks:props["ticks"],label:props["label"],unit:props["unit"]})}const layerBaseProps={id:{type:[String,Number],required:true},data:{type:Array,required:true},getId:{type:Function,default:void 0},label:{type:String,default:void 0}};const cartesianLayerProps={...layerBaseProps,xAxis:{type:[String,Number],required:true},yAxis:{type:[String,Number],required:true},getX:{type:Function,default:void 0},getY:{type:Function,default:void 0}};function layerComponent(kind,extraProps={}){return defineComponent({name:`SectileChart${kind[0]?.toUpperCase()}${kind.slice(1)}`,props:{...kind==="pie"||kind==="donut"?layerBaseProps:cartesianLayerProps,...extraProps},setup(props){const context=useInternalChart();const value=shallowRef(layerDefinition(props,kind));const record=context.declarations.register("layer",()=>value.value);watch(()=>Object.values(props),()=>{value.value=layerDefinition(props,kind);record.touch()},{deep:false,flush:"post"});onBeforeUnmount(record.dispose);return()=>null}})}const ChartLine=layerComponent("line");const ChartScatter=layerComponent("scatter",{projection:{type:String,default:"raw"}});const ChartBar=layerComponent("bar",{orientation:{type:String,default:"vertical"}});const ChartBars=ChartBar;const ChartHeatmap=layerComponent("heatmap",{getValue:{type:Function,default:void 0},valueField:{type:String,default:void 0},projection:{type:[String,Object],default:"raw"}});const ChartPie=layerComponent("pie",{getValue:{type:Function,default:void 0},valueField:{type:String,default:void 0},getLabel:{type:Function,default:void 0},labelField:{type:String,default:void 0}});const ChartDonut=layerComponent("donut",{getValue:{type:Function,default:void 0},valueField:{type:String,default:void 0},getLabel:{type:Function,default:void 0},labelField:{type:String,default:void 0},innerRadius:{type:Number,default:.5},outerRadius:{type:Number,default:1}});function layerDefinition(props,kind){return defined({kind,id:props["id"],data:props["data"],getId:props["getId"],label:props["label"],xAxis:props["xAxis"],yAxis:props["yAxis"],getX:props["getX"],getY:props["getY"],projection:props["projection"],orientation:props["orientation"],getValue:props["getValue"],valueField:props["valueField"],getLabel:props["getLabel"],labelField:props["labelField"],innerRadius:props["innerRadius"],outerRadius:props["outerRadius"]})}const ChartAxisView=defineComponent({name:"SectileChartAxisView",props:{axis:{type:[String,Number],default:void 0},initial:{type:Object,default:void 0},minimumSpan:{type:Number,default:void 0},maximumSpan:{type:Number,default:void 0},update:{type:String,default:"preserve"}},setup(props){const context=useInternalChart();const inheritedAxis=inject(chartAxisKey,void 0);const read=()=>viewCapability(props,inheritedAxis?.value);const value=shallowRef(read());const record=context.declarations.register("view",()=>value.value);watch(()=>[props.axis,inheritedAxis?.value,props.initial,props.minimumSpan,props.maximumSpan,props.update],()=>{value.value=read();record.touch()},{deep:false,flush:"post"});onBeforeUnmount(record.dispose);return()=>null}});function viewCapability(props,inheritedAxis){const axisID=props["axis"]??inheritedAxis;if(axisID===void 0)throw new TypeError("ChartAxisView requires an axis prop or an enclosing ChartXAxis or ChartYAxis.");return Object.freeze(defined({axisID,initial:props["initial"],minimumSpan:props["minimumSpan"],maximumSpan:props["maximumSpan"],update:props["update"]}))}const ChartNavigation=defineComponent({name:"SectileChartNavigation",props:{axes:{type:Array,default:void 0},drag:{type:String,default:"none"},wheel:{type:String,default:"native"},wheelModifier:{type:String,default:"none"},pinch:{type:Boolean,default:false},keyboard:{type:Boolean,default:false}},setup(props){const context=useInternalChart();const value=shallowRef(navigationDefinition(props));const record=context.declarations.register("navigation",()=>value.value);watch(()=>[props.axes,props.drag,props.wheel,props.wheelModifier,props.pinch,props.keyboard],()=>{const next=navigationDefinition(props);if(sameNavigation(value.value,next))return;value.value=next;record.touch()},{deep:false,flush:"post"});onBeforeUnmount(record.dispose);return()=>null}});function navigationDefinition(props){return Object.freeze(defined({axes:props["axes"],drag:props["drag"],wheel:props["wheel"],wheelModifier:props["wheelModifier"],pinch:props["pinch"],keyboard:props["keyboard"]}))}function sameNavigation(left,right){return sameStableIDs(left.axes,right.axes)&&left.drag===right.drag&&left.wheel===right.wheel&&left.wheelModifier===right.wheelModifier&&left.pinch===right.pinch&&left.keyboard===right.keyboard}function sameStableIDs(left,right){if(left===right)return true;if(left===void 0||right===void 0||left.length!==right.length)return false;for(let index=0;index<left.length;index+=1)if(left[index]!==right[index])return false;return true}const ChartViewControls=defineComponent({name:"SectileChartViewControls",inheritAttrs:false,props:{axis:{type:[String,Number],default:void 0}},setup(props,{attrs,slots}){const context=useInternalChart();const inheritedAxis=inject(chartAxisKey,void 0);const initialAxis=props.axis??inheritedAxis?.value;if(initialAxis===void 0)throw new TypeError("ChartViewControls requires an axis prop or an enclosing ChartXAxis or ChartYAxis.");const axis=shallowRef(initialAxis);provide(chartControlAxisKey,axis);watch(()=>[props.axis,inheritedAxis?.value],()=>{axis.value=props.axis??inheritedAxis?.value},{deep:false,flush:"sync"});const record=context.declarations.register("controls",()=>"built-in");onBeforeUnmount(record.dispose);return()=>h("div",{...attrs,"data-scope":"chart","data-part":"view-controls"},slots["default"]?.())}});const ChartExternalViewControls=defineComponent({name:"SectileChartExternalViewControls",setup(){const context=useInternalChart();const record=context.declarations.register("controls",()=>"external");onBeforeUnmount(record.dispose);return()=>null}});const axisControlProps={axis:{type:[String,Number],default:void 0},label:{type:String,default:void 0}};const ChartPanControl=defineComponent({name:"SectileChartPanControl",inheritAttrs:false,props:{...axisControlProps,direction:{type:String,required:true},step:{type:Number,default:.1}},setup(props,{attrs,slots}){const context=useInternalChart();const inheritedAxis=inject(chartControlAxisKey,inject(chartAxisKey,void 0));const axis=()=>requiredControlAxis(props.axis,inheritedAxis?.value);return()=>h("button",{...attrs,type:"button",disabled:context.controller.value===null,"aria-label":props.label??`Pan ${String(axis())} ${props.direction}`,"data-scope":"chart","data-part":"pan-control",onClick:()=>context.dispatch({type:"pan-axis-view",axisID:axis(),fraction:props.direction==="backward"?-props.step:props.step,phase:"settled"})},slots["default"]?.()??props.direction)}});const ChartZoomControl=defineComponent({name:"SectileChartZoomControl",inheritAttrs:false,props:{...axisControlProps,direction:{type:String,required:true},factor:{type:Number,default:1.25}},setup(props,{attrs,slots}){const context=useInternalChart();const inheritedAxis=inject(chartControlAxisKey,inject(chartAxisKey,void 0));const axis=()=>requiredControlAxis(props.axis,inheritedAxis?.value);return()=>h("button",{...attrs,type:"button",disabled:context.controller.value===null,"aria-label":props.label??`Zoom ${String(axis())} ${props.direction}`,"data-scope":"chart","data-part":"zoom-control",onClick:()=>context.dispatch({type:"zoom-axis-view",axisID:axis(),factor:props.direction==="in"?props.factor:1/props.factor,anchor:.5,phase:"settled"})},slots["default"]?.()??props.direction)}});const ChartResetView=defineComponent({name:"SectileChartResetView",inheritAttrs:false,props:{...axisControlProps,to:{type:String,default:"initial"}},setup(props,{attrs,slots}){const context=useInternalChart();const inheritedAxis=inject(chartControlAxisKey,inject(chartAxisKey,void 0));const axis=()=>requiredControlAxis(props.axis,inheritedAxis?.value);return()=>h("button",{...attrs,type:"button",disabled:context.controller.value===null,"aria-label":props.label??`Reset ${String(axis())} view`,"data-scope":"chart","data-part":"reset-view",onClick:()=>context.dispatch({type:"reset-axis-view",axisID:axis(),to:props.to,phase:"settled"})},slots["default"]?.()??"Reset")}});const ChartPlot=defineComponent({name:"SectileChartPlot",inheritAttrs:false,setup(_props,{attrs,slots}){return()=>h("div",{...attrs,"data-scope":"chart","data-part":"plot"},slots["default"]?.())}});const ChartRenderer=defineComponent({name:"SectileChartRenderer",inheritAttrs:false,setup(_props,{attrs}){const context=useInternalChart();return()=>h("canvas",{...attrs,ref:element=>{context.canvas.value=element},"aria-hidden":"true","data-scope":"chart","data-part":"renderer"})}});const ChartCanvas=ChartRenderer;function semanticMarker(name,part){return defineComponent({name,setup(){useInternalChart();return()=>null}})}const ChartGrid=semanticMarker("SectileChartGrid","grid");const ChartGridLines=ChartGrid;const ChartLegend=semanticMarker("SectileChartLegend","legend");const ChartAxisTicks=semanticMarker("SectileChartAxisTicks","axis-ticks");const ChartTicks=ChartAxisTicks;const chartSuiteKey=Symbol("SectileChartSuite");const chartComponentSuites=new WeakMap;function createChartComponents(controller){if(controller===null||typeof controller!=="object")throw new TypeError("createChartComponents requires a Chart controller.");const cached=chartComponentSuites.get(controller);if(cached!==void 0)return cached;const token=Object.freeze({controller});const suite=Object.freeze({Provider:boundChartProvider(controller,token),Root:boundChartRoot(token),Cartesian:ChartCartesian,Radial:ChartRadial,XAxis:ChartXAxis,YAxis:ChartYAxis,AxisView:ChartAxisView,Line:ChartLine,Scatter:ChartScatter,Bar:ChartBar,Bars:ChartBars,Heatmap:ChartHeatmap,Pie:ChartPie,Donut:ChartDonut,Navigation:ChartNavigation,ViewControls:ChartViewControls,ExternalViewControls:ChartExternalViewControls,PanControl:ChartPanControl,ZoomControl:ChartZoomControl,ResetView:ChartResetView,Plot:ChartPlot,Renderer:ChartRenderer,Canvas:ChartCanvas,Grid:ChartGrid,GridLines:ChartGridLines,Legend:ChartLegend,AxisTicks:ChartAxisTicks,Ticks:ChartTicks});chartComponentSuites.set(controller,suite);return suite}function boundChartProvider(controller,token){return defineComponent({name:"SectileBoundChartProvider",inheritAttrs:false,setup(_props,{attrs,slots}){provide(chartSuiteKey,token);return()=>h(ChartProviderRuntime,{...attrs,controller},slots)}})}function boundChartRoot(token){return defineComponent({name:"SectileBoundChartRoot",inheritAttrs:false,setup(_props,{attrs,slots}){if(inject(chartSuiteKey,void 0)!==token){throw new TypeError("Controller-bound Chart.Root requires its matching Chart.Provider.")}return()=>h(ChartRootRuntime,attrs,slots)}})}function requiredControlAxis(axis,inheritedAxis){const resolved=axis??inheritedAxis;if(resolved===void 0)throw new TypeError("Chart view control requires an axis prop or an enclosing axis control scope.");return resolved}function bindController(controller,options,owned){const snapshot=shallowRef(controller.getSnapshot());const projection=shallowRef(null);const connection=shallowRef(null);let active=true;const controlledFlags={activeDatum:options.activeDatum!==void 0,cursor:options.cursor!==void 0,selection:options.selection!==void 0,view:options.view!==void 0};const publish=()=>{if(!active)return;const previous=snapshot.value;const current=controller.getSnapshot();if(current===previous)return;snapshot.value=current;if(!controlledFlags.activeDatum&¤t.state.activeDatum!==previous.state.activeDatum)options.onActiveDatumChange?.(current.state.activeDatum);if(!controlledFlags.cursor&¤t.state.cursor!==previous.state.cursor)options.onCursorChange?.(current.state.cursor);if(!controlledFlags.selection&¤t.state.selection!==previous.state.selection)options.onSelectionChange?.(current.state.selection);if(!controlledFlags.view&¤t.state.view!==previous.state.view)options.onViewChange?.(current.state.view)};const unsubscribeCommands=controller.subscribeCommands(command=>{options.onCommand?.(command);if(command.type==="active-change-requested"){if(options.activeDatum!==void 0)options.activeDatum.value=command.id;options.onActiveDatumChange?.(command.id)}else if(command.type==="cursor-change-requested"){if(options.cursor!==void 0)options.cursor.value=command.id;options.onCursorChange?.(command.id)}else if(command.type==="selection-change-requested"){if(options.selection!==void 0)options.selection.value=command.selection;options.onSelectionChange?.(command.selection)}else if(command.type==="view-change-requested"){if(options.view!==void 0)options.view.value=command.view;options.onViewChange?.(command.view)}publish()});const unsubscribeSnapshots=controller.subscribeSnapshots(()=>{publish()});const result={controller,snapshot,projection,connection,replaceModel(model,expectedRevision){const value=controller.replaceModel(model,expectedRevision);publish();return value},replaceDefinition(definition,viewCapabilities,expectedRevision){const value=controller.replaceDefinition(definition,viewCapabilities,expectedRevision);publish();return value},applyPatch(patch,expectedRevision){const value=controller.applyPatch(patch,expectedRevision);publish();return value},dispatch(event,expectedRevision){const value=controller.dispatch(event,expectedRevision);publish();return value},syncControlledValues(){const value=controller.syncControlledValues(controlledValues(options));publish();return value},dispose(){if(!active)return;active=false;connection.value?.disconnect();connection.value=null;unsubscribeCommands();unsubscribeSnapshots();if(owned)controller.dispose()}};return Object.freeze(result)}function controlledValues(options){return Object.freeze({...options.activeDatum===void 0?{}:{activeDatum:options.activeDatum.value},...options.cursor===void 0?{}:{cursor:options.cursor.value},...options.selection===void 0?{}:{selection:options.selection.value},...options.view===void 0?{}:{view:options.view.value}})}function defaultValues(options){const values=Object.freeze({...options.activeDatum!==void 0||options.defaultActiveDatum===void 0?{}:{activeDatum:options.defaultActiveDatum},...options.cursor!==void 0||options.defaultCursor===void 0?{}:{cursor:options.defaultCursor},...options.selection!==void 0||options.defaultSelection===void 0?{}:{selection:options.defaultSelection},...options.view!==void 0||options.defaultView===void 0?{}:{view:options.defaultView}});return Object.keys(values).length===0?{}:{initialValues:values}}function assertControlledDefaults(options){if(options.activeDatum!==void 0&&options.defaultActiveDatum!==void 0||options.cursor!==void 0&&options.defaultCursor!==void 0||options.selection!==void 0&&options.defaultSelection!==void 0||options.view!==void 0&&options.defaultView!==void 0){throw new TypeError("Chart controlled values and their default counterparts are mutually exclusive.")}}function assertRootControlledDefaults(props){if(props["modelValue"]!==void 0&&props["defaultModelValue"]!==void 0||props["activeDatum"]!==void 0&&props["defaultActiveDatum"]!==void 0||props["cursor"]!==void 0&&props["defaultCursor"]!==void 0||props["view"]!==void 0&&props["defaultView"]!==void 0){throw new TypeError("ChartRoot controlled props and their default counterparts are mutually exclusive.")}}function defined(value){return Object.fromEntries(Object.entries(value).filter(([,entry])=>entry!==void 0))}export{ChartAxisTicks,ChartAxisView,ChartBar,ChartBars,ChartCanvas,ChartCartesian,ChartDonut,ChartExternalViewControls,ChartGrid,ChartGridLines,ChartHeatmap,ChartLegend,ChartLine,ChartNavigation,ChartPanControl,ChartPie,ChartPlot,ChartProvider,ChartRadial,ChartRenderer,ChartResetView,ChartRoot,ChartScatter,ChartTicks,ChartViewControls,ChartXAxis,ChartYAxis,ChartZoomControl,createChartComponents,useChart,useChartAxisSelector,useChartContext,useChartLayerSelector,useChartSelector};
|
|
2
|
+
//# sourceMappingURL=chart.js.map
|