panelui-native 0.44.0 → 0.49.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/README.md +6 -1
- package/lib/module/components/accordion/index.js +32 -4
- package/lib/module/components/accordion/index.js.map +1 -1
- package/lib/module/components/button/index.js +83 -15
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/button-group/index.js +186 -0
- package/lib/module/components/button-group/index.js.map +1 -0
- package/lib/module/components/color-picker/index.js +110 -1
- package/lib/module/components/color-picker/index.js.map +1 -1
- package/lib/module/components/combobox/index.js +7 -1
- package/lib/module/components/combobox/index.js.map +1 -1
- package/lib/module/components/date-time-picker/index.js +272 -0
- package/lib/module/components/date-time-picker/index.js.map +1 -0
- package/lib/module/components/fab/index.js +514 -0
- package/lib/module/components/fab/index.js.map +1 -0
- package/lib/module/components/grid-item/index.js +486 -0
- package/lib/module/components/grid-item/index.js.map +1 -0
- package/lib/module/components/{kpi-chart → kpi}/index.js +62 -62
- package/lib/module/components/kpi/index.js.map +1 -0
- package/lib/module/components/line-chart/index.js +92 -10
- package/lib/module/components/line-chart/index.js.map +1 -1
- package/lib/module/components/markdown-editor/index.js +406 -0
- package/lib/module/components/markdown-editor/index.js.map +1 -0
- package/lib/module/components/markdown-editor/markdown-transforms.js +243 -0
- package/lib/module/components/markdown-editor/markdown-transforms.js.map +1 -0
- package/lib/module/components/pie-chart/index.js +625 -0
- package/lib/module/components/pie-chart/index.js.map +1 -0
- package/lib/module/components/questionnaire/index.js +1312 -0
- package/lib/module/components/questionnaire/index.js.map +1 -0
- package/lib/module/components/scatter-chart/index.js +1173 -0
- package/lib/module/components/scatter-chart/index.js.map +1 -0
- package/lib/module/components/tabs/index.js +359 -41
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/components/time-picker/index.js +34 -6
- package/lib/module/components/time-picker/index.js.map +1 -1
- package/lib/module/components/tree/index.js +500 -0
- package/lib/module/components/tree/index.js.map +1 -0
- package/lib/module/icons/index.js +217 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/chart.js +81 -0
- package/lib/module/utils/chart.js.map +1 -1
- package/lib/typescript/src/components/accordion/index.d.ts +21 -0
- package/lib/typescript/src/components/accordion/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +21 -0
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button-group/index.d.ts +212 -0
- package/lib/typescript/src/components/button-group/index.d.ts.map +1 -0
- package/lib/typescript/src/components/color-picker/index.d.ts +82 -1
- package/lib/typescript/src/components/color-picker/index.d.ts.map +1 -1
- package/lib/typescript/src/components/combobox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/date-time-picker/index.d.ts +127 -0
- package/lib/typescript/src/components/date-time-picker/index.d.ts.map +1 -0
- package/lib/typescript/src/components/fab/index.d.ts +285 -0
- package/lib/typescript/src/components/fab/index.d.ts.map +1 -0
- package/lib/typescript/src/components/grid-item/index.d.ts +292 -0
- package/lib/typescript/src/components/grid-item/index.d.ts.map +1 -0
- package/lib/typescript/src/components/{kpi-chart → kpi}/index.d.ts +65 -65
- package/lib/typescript/src/components/kpi/index.d.ts.map +1 -0
- package/lib/typescript/src/components/line-chart/index.d.ts +25 -1
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/markdown-editor/index.d.ts +102 -0
- package/lib/typescript/src/components/markdown-editor/index.d.ts.map +1 -0
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts +76 -0
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts.map +1 -0
- package/lib/typescript/src/components/pie-chart/index.d.ts +245 -0
- package/lib/typescript/src/components/pie-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/questionnaire/index.d.ts +336 -0
- package/lib/typescript/src/components/questionnaire/index.d.ts.map +1 -0
- package/lib/typescript/src/components/scatter-chart/index.d.ts +309 -0
- package/lib/typescript/src/components/scatter-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/tabs/index.d.ts +29 -2
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/components/time-picker/index.d.ts +19 -1
- package/lib/typescript/src/components/time-picker/index.d.ts.map +1 -1
- package/lib/typescript/src/components/tree/index.d.ts +125 -0
- package/lib/typescript/src/components/tree/index.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +22 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +14 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/chart.d.ts +34 -0
- package/lib/typescript/src/utils/chart.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/index.tsx +48 -6
- package/src/components/button/index.tsx +97 -15
- package/src/components/button-group/index.tsx +199 -0
- package/src/components/color-picker/index.tsx +140 -3
- package/src/components/combobox/index.tsx +7 -1
- package/src/components/date-time-picker/index.tsx +411 -0
- package/src/components/fab/index.tsx +583 -0
- package/src/components/grid-item/index.tsx +515 -0
- package/src/components/{kpi-chart → kpi}/index.tsx +85 -85
- package/src/components/line-chart/index.tsx +98 -8
- package/src/components/markdown-editor/index.tsx +526 -0
- package/src/components/markdown-editor/markdown-transforms.ts +228 -0
- package/src/components/pie-chart/index.tsx +863 -0
- package/src/components/questionnaire/index.tsx +1615 -0
- package/src/components/scatter-chart/index.tsx +1401 -0
- package/src/components/tabs/index.tsx +392 -50
- package/src/components/time-picker/index.tsx +42 -6
- package/src/components/tree/index.tsx +564 -0
- package/src/icons/index.tsx +154 -0
- package/src/index.ts +142 -18
- package/src/utils/chart.ts +110 -0
- package/lib/module/components/kpi-chart/index.js.map +0 -1
- package/lib/typescript/src/components/kpi-chart/index.d.ts.map +0 -1
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Questionnaire — one question at a time, with progress, validation and a way
|
|
3
|
+
* back.
|
|
4
|
+
*
|
|
5
|
+
* Unlike `Steps`, which reflects a flow the app owns, Questionnaire *owns* the
|
|
6
|
+
* flow: it holds the answers, decides which question is current, gates the way
|
|
7
|
+
* forward on the current one being answered, and reports the whole set back
|
|
8
|
+
* when it is done. The caller supplies the questions and does something with
|
|
9
|
+
* the answers; everything between those two points belongs here.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Questionnaire items={items} onSubmit={(answers) => save(answers)}>
|
|
13
|
+
* <Questionnaire.Title>Project setup</Questionnaire.Title>
|
|
14
|
+
* <Questionnaire.Progress />
|
|
15
|
+
* <Questionnaire.Item name="direction" required>
|
|
16
|
+
* <Questionnaire.Question>What should we build next?</Questionnaire.Question>
|
|
17
|
+
* <Questionnaire.Description>Choose one, or write your own.</Questionnaire.Description>
|
|
18
|
+
* <Questionnaire.Choices>
|
|
19
|
+
* <Questionnaire.Choice value="delegation" label="Delegation" />
|
|
20
|
+
* <Questionnaire.Choice value="prompts" label="Question prompts" />
|
|
21
|
+
* <Questionnaire.Input placeholder="Type another answer…" />
|
|
22
|
+
* </Questionnaire.Choices>
|
|
23
|
+
* <Questionnaire.Error />
|
|
24
|
+
* </Questionnaire.Item>
|
|
25
|
+
* <Questionnaire.Footer>
|
|
26
|
+
* <Questionnaire.Back />
|
|
27
|
+
* <Questionnaire.Next />
|
|
28
|
+
* <Questionnaire.Submit />
|
|
29
|
+
* </Questionnaire.Footer>
|
|
30
|
+
* </Questionnaire>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ## Why it draws its own Frame
|
|
34
|
+
*
|
|
35
|
+
* A survey is a widget, not a paragraph: it wants a boundary, a title strip and
|
|
36
|
+
* a footer that stays put while the middle changes. That is exactly `Frame`, so
|
|
37
|
+
* the root renders one rather than leaving every caller to assemble the same
|
|
38
|
+
* shell. `Frame.Panel`'s `overflow-hidden` also does the clipping the sliding
|
|
39
|
+
* question needs, for free. Pass `frame={false}` to drop it — for a
|
|
40
|
+
* questionnaire inside a `BottomSheet` or a card that already draws a border.
|
|
41
|
+
*
|
|
42
|
+
* ## Why the root reads its children instead of collecting registrations
|
|
43
|
+
*
|
|
44
|
+
* Only the active question is mounted, so an unmounted one cannot report that
|
|
45
|
+
* it exists — and without knowing the full set there is no total to count
|
|
46
|
+
* against, no "is this the last one", and no way to disable a question the
|
|
47
|
+
* user has not reached. So the root inspects its children once per render and
|
|
48
|
+
* reads `name`, `required`, `multiple` and `disabled` straight off the
|
|
49
|
+
* elements. React elements carry their props before anything renders them,
|
|
50
|
+
* which makes the whole set knowable without mounting any of it.
|
|
51
|
+
*
|
|
52
|
+
* That same pass sorts the parts into the shell: the title and progress go to
|
|
53
|
+
* the header strip, the footer to a section at the bottom of the panel, and
|
|
54
|
+
* everything else is a question.
|
|
55
|
+
*
|
|
56
|
+
* ## Answers are one record, the way a form would submit them
|
|
57
|
+
*
|
|
58
|
+
* `answers[name]` is a string for a single-answer question and an array for a
|
|
59
|
+
* `multiple` one. A freeform answer lands under the same name — it is another
|
|
60
|
+
* answer to the same question, not a separate field — which is why the text
|
|
61
|
+
* input shows whatever value does not match one of the question's own choices.
|
|
62
|
+
* Picking a choice and typing therefore replace each other, without either one
|
|
63
|
+
* having to know the other exists.
|
|
64
|
+
*
|
|
65
|
+
* ## What blocks the way forward
|
|
66
|
+
*
|
|
67
|
+
* A required question blocks until it has an answer. An optional one never
|
|
68
|
+
* blocks. `Questionnaire.Skip` does not unblock anything, then — it *records*
|
|
69
|
+
* that the question was deliberately left out, moving its status from
|
|
70
|
+
* `unanswered` to `skipped` so the app can tell the two apart. Making an
|
|
71
|
+
* optional question demand an explicit skip would trap anyone who did not
|
|
72
|
+
* render the Skip button, and a question that cannot be ignored is not
|
|
73
|
+
* optional.
|
|
74
|
+
*/
|
|
75
|
+
import { type ReactNode } from 'react';
|
|
76
|
+
import { View, type TextInput, type ViewProps } from 'react-native';
|
|
77
|
+
import { type ButtonProps } from '../button/index.js';
|
|
78
|
+
import { type InputProps } from '../input/index.js';
|
|
79
|
+
/** Where a question stands: never touched, answered, or deliberately left out. */
|
|
80
|
+
export type QuestionnaireItemStatus = 'unanswered' | 'answered' | 'skipped';
|
|
81
|
+
/** Which key each answer is badged with. */
|
|
82
|
+
export type QuestionnaireShortcutMode = 'letters' | 'numbers';
|
|
83
|
+
/** Every answer given so far, keyed by question name. */
|
|
84
|
+
export type QuestionnaireAnswers = Record<string, string | string[]>;
|
|
85
|
+
/**
|
|
86
|
+
* A question, described rather than rendered. Pass these as `items` so the
|
|
87
|
+
* questionnaire knows its full set before any of it mounts — which is what
|
|
88
|
+
* makes a conditional question countable and a total meaningful.
|
|
89
|
+
*/
|
|
90
|
+
export interface QuestionnaireItemDefinition {
|
|
91
|
+
/** Unique name — the key this question's answer is stored under. */
|
|
92
|
+
name: string;
|
|
93
|
+
/** Blocks the way forward until it has an answer. */
|
|
94
|
+
required?: boolean;
|
|
95
|
+
/** Accepts more than one answer, so its answer is an array. */
|
|
96
|
+
multiple?: boolean;
|
|
97
|
+
/** Left out of the count and never navigated to. */
|
|
98
|
+
disabled?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface QuestionnaireProps extends Omit<ViewProps, 'children'> {
|
|
101
|
+
className?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The full set of questions, in order. Optional: without it the order and
|
|
104
|
+
* the totals come from the `Questionnaire.Item` children instead. Pass it
|
|
105
|
+
* when a question is conditional, since a question the user has not reached
|
|
106
|
+
* still has to be counted — or not counted, if it no longer applies.
|
|
107
|
+
*/
|
|
108
|
+
items?: readonly QuestionnaireItemDefinition[];
|
|
109
|
+
/** Controlled active question, by name. */
|
|
110
|
+
item?: string;
|
|
111
|
+
/** Which question to open on. Defaults to the first enabled one. */
|
|
112
|
+
defaultItem?: string;
|
|
113
|
+
/** Called with the name of the question being moved to. */
|
|
114
|
+
onItemChange?: (name: string) => void;
|
|
115
|
+
/** Controlled answers. */
|
|
116
|
+
answers?: QuestionnaireAnswers;
|
|
117
|
+
/** Answers to start with — for resuming a part-finished questionnaire. */
|
|
118
|
+
defaultAnswers?: QuestionnaireAnswers;
|
|
119
|
+
/** Called with the whole set every time any answer changes. */
|
|
120
|
+
onAnswersChange?: (answers: QuestionnaireAnswers) => void;
|
|
121
|
+
/** Called with every answer once the last question validates. */
|
|
122
|
+
onSubmit?: (answers: QuestionnaireAnswers) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Badge every answer with a letter (`A`, `B`, `C`) or a number (`1`, `2`,
|
|
125
|
+
* `3`). Disabled answers are skipped rather than taking a badge with them.
|
|
126
|
+
*
|
|
127
|
+
* The badge is an affordance, not a binding: React Native surfaces hardware
|
|
128
|
+
* key events only to a focused text field, so nothing here can listen for
|
|
129
|
+
* the key itself.
|
|
130
|
+
*/
|
|
131
|
+
shortcuts?: QuestionnaireShortcutMode;
|
|
132
|
+
/**
|
|
133
|
+
* Let a horizontal drag move between questions. Going forward is gated on
|
|
134
|
+
* the same answer the button is, so a swipe off an unanswered required
|
|
135
|
+
* question springs back and shows its error.
|
|
136
|
+
*/
|
|
137
|
+
swipeable?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Draw the surrounding `Frame`. Turn it off to place the questionnaire in a
|
|
140
|
+
* sheet, a dialog or a card that already draws its own boundary.
|
|
141
|
+
*/
|
|
142
|
+
frame?: boolean;
|
|
143
|
+
children?: ReactNode;
|
|
144
|
+
}
|
|
145
|
+
declare function QuestionnaireRoot({ className, items, item: itemProp, defaultItem, onItemChange, answers: answersProp, defaultAnswers, onAnswersChange, onSubmit, shortcuts, swipeable, frame, children, ...props }: QuestionnaireProps): import("react").JSX.Element;
|
|
146
|
+
declare namespace QuestionnaireRoot {
|
|
147
|
+
var displayName: string;
|
|
148
|
+
}
|
|
149
|
+
export interface QuestionnaireTitleProps extends ViewProps {
|
|
150
|
+
className?: string;
|
|
151
|
+
children?: ReactNode;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Names the questionnaire as a whole, in the frame's header strip. The
|
|
155
|
+
* current question's own prompt is `Questionnaire.Question`.
|
|
156
|
+
*/
|
|
157
|
+
declare function QuestionnaireTitle({ className, children, ...props }: QuestionnaireTitleProps): import("react").JSX.Element;
|
|
158
|
+
declare namespace QuestionnaireTitle {
|
|
159
|
+
var displayName: string;
|
|
160
|
+
}
|
|
161
|
+
/** What a custom progress indicator is told about where the reader is. */
|
|
162
|
+
export interface QuestionnaireProgressState {
|
|
163
|
+
/** One-based position of the active question. */
|
|
164
|
+
current: number;
|
|
165
|
+
/** How many questions are enabled. */
|
|
166
|
+
total: number;
|
|
167
|
+
first: boolean;
|
|
168
|
+
last: boolean;
|
|
169
|
+
}
|
|
170
|
+
/** How the position is drawn. */
|
|
171
|
+
export type QuestionnaireProgressVariant = 'pips' | 'numbers' | 'count';
|
|
172
|
+
export interface QuestionnaireProgressProps {
|
|
173
|
+
className?: string;
|
|
174
|
+
/**
|
|
175
|
+
* `pips` is a bar per question, filled up to the one being asked and widened
|
|
176
|
+
* on it. `numbers` counts them out instead, which is what you want when the
|
|
177
|
+
* reader will be sent back to a particular question. `count` is the plain
|
|
178
|
+
* `Question 2 of 5`.
|
|
179
|
+
*
|
|
180
|
+
* `pips` and `numbers` fall back to `count` past eight questions, where
|
|
181
|
+
* neither is countable at a glance any more.
|
|
182
|
+
*/
|
|
183
|
+
variant?: QuestionnaireProgressVariant;
|
|
184
|
+
/**
|
|
185
|
+
* Replace the indicator entirely. Given a function, it is called with the
|
|
186
|
+
* position — for a bar, a row of dots, or a percentage.
|
|
187
|
+
*/
|
|
188
|
+
children?: ReactNode | ((state: QuestionnaireProgressState) => ReactNode);
|
|
189
|
+
}
|
|
190
|
+
/** Where the reader is in the set, announced as a progress bar. */
|
|
191
|
+
declare function QuestionnaireProgress({ className, variant, children, }: QuestionnaireProgressProps): import("react").JSX.Element;
|
|
192
|
+
declare namespace QuestionnaireProgress {
|
|
193
|
+
var displayName: string;
|
|
194
|
+
}
|
|
195
|
+
export interface QuestionnaireItemProps extends Omit<ViewProps, 'children'> {
|
|
196
|
+
className?: string;
|
|
197
|
+
/** Unique name — the key this question's answer is stored under. */
|
|
198
|
+
name: string;
|
|
199
|
+
/** Blocks the way forward until it has an answer. */
|
|
200
|
+
required?: boolean;
|
|
201
|
+
/** Accepts more than one answer, so its answer is an array. */
|
|
202
|
+
multiple?: boolean;
|
|
203
|
+
/** Left out of the count and never navigated to. */
|
|
204
|
+
disabled?: boolean;
|
|
205
|
+
/** Mark the question at fault from a validator of your own. */
|
|
206
|
+
invalid?: boolean;
|
|
207
|
+
/** Called whenever this question moves between unanswered, answered and skipped. */
|
|
208
|
+
onStatusChange?: (status: QuestionnaireItemStatus) => void;
|
|
209
|
+
children?: ReactNode;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* One question. Only the active one is mounted, so anything it holds is built
|
|
213
|
+
* when it is reached and thrown away when it is left.
|
|
214
|
+
*/
|
|
215
|
+
declare function QuestionnaireItem({ className, name, required, multiple, invalid: invalidProp, children, disabled: _disabled, onStatusChange: _onStatusChange, ...props }: QuestionnaireItemProps): import("react").JSX.Element;
|
|
216
|
+
declare namespace QuestionnaireItem {
|
|
217
|
+
var displayName: string;
|
|
218
|
+
}
|
|
219
|
+
export interface QuestionnaireQuestionProps extends ViewProps {
|
|
220
|
+
className?: string;
|
|
221
|
+
children?: ReactNode;
|
|
222
|
+
}
|
|
223
|
+
/** The question being asked. */
|
|
224
|
+
declare function QuestionnaireQuestion({ className, children, ...props }: QuestionnaireQuestionProps): import("react").JSX.Element;
|
|
225
|
+
declare namespace QuestionnaireQuestion {
|
|
226
|
+
var displayName: string;
|
|
227
|
+
}
|
|
228
|
+
export interface QuestionnaireDescriptionProps extends ViewProps {
|
|
229
|
+
className?: string;
|
|
230
|
+
children?: ReactNode;
|
|
231
|
+
}
|
|
232
|
+
/** A line under the question — what to consider, or that it can be skipped. */
|
|
233
|
+
declare function QuestionnaireDescription({ className, children, ...props }: QuestionnaireDescriptionProps): import("react").JSX.Element;
|
|
234
|
+
declare namespace QuestionnaireDescription {
|
|
235
|
+
var displayName: string;
|
|
236
|
+
}
|
|
237
|
+
export interface QuestionnaireChoicesProps extends Omit<ViewProps, 'children'> {
|
|
238
|
+
className?: string;
|
|
239
|
+
children?: ReactNode;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The answers to a question. It hands each choice its shortcut badge, counting
|
|
243
|
+
* only the ones that can be picked so a disabled answer does not take a letter
|
|
244
|
+
* out of the sequence with it.
|
|
245
|
+
*/
|
|
246
|
+
declare function QuestionnaireChoices({ className, children, ...props }: QuestionnaireChoicesProps): import("react").JSX.Element;
|
|
247
|
+
declare namespace QuestionnaireChoices {
|
|
248
|
+
var displayName: string;
|
|
249
|
+
}
|
|
250
|
+
export interface QuestionnaireChoiceProps {
|
|
251
|
+
className?: string;
|
|
252
|
+
/** The value recorded when this answer is picked. */
|
|
253
|
+
value: string;
|
|
254
|
+
/** The answer itself. */
|
|
255
|
+
label?: string;
|
|
256
|
+
/** A line under the label, for an answer that needs explaining. */
|
|
257
|
+
description?: string;
|
|
258
|
+
disabled?: boolean;
|
|
259
|
+
children?: ReactNode;
|
|
260
|
+
}
|
|
261
|
+
export interface QuestionnaireInputProps extends Omit<InputProps, 'value' | 'onChangeText' | 'errorMessage'> {
|
|
262
|
+
className?: string;
|
|
263
|
+
}
|
|
264
|
+
export interface QuestionnaireErrorProps extends ViewProps {
|
|
265
|
+
className?: string;
|
|
266
|
+
/** Replace the default message. */
|
|
267
|
+
children?: ReactNode;
|
|
268
|
+
}
|
|
269
|
+
/** Why the way forward is closed. Nothing until the question fails to pass. */
|
|
270
|
+
declare function QuestionnaireError({ className, children, ...props }: QuestionnaireErrorProps): import("react").JSX.Element | null;
|
|
271
|
+
declare namespace QuestionnaireError {
|
|
272
|
+
var displayName: string;
|
|
273
|
+
}
|
|
274
|
+
export interface QuestionnaireFooterProps extends ViewProps {
|
|
275
|
+
className?: string;
|
|
276
|
+
children?: ReactNode;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The action row, in its own section at the foot of the panel. It stays put
|
|
280
|
+
* while the question above it changes, which is what keeps the button under
|
|
281
|
+
* the thumb where it was.
|
|
282
|
+
*/
|
|
283
|
+
declare function QuestionnaireFooter({ className, children, ...props }: QuestionnaireFooterProps): import("react").JSX.Element;
|
|
284
|
+
declare namespace QuestionnaireFooter {
|
|
285
|
+
var displayName: string;
|
|
286
|
+
}
|
|
287
|
+
/** What a navigation button is told about the question it is acting on. */
|
|
288
|
+
export interface QuestionnaireActionState {
|
|
289
|
+
/** Whether the action applies to the active question at all. */
|
|
290
|
+
visible: boolean;
|
|
291
|
+
/** Where the active question stands. */
|
|
292
|
+
status: QuestionnaireItemStatus;
|
|
293
|
+
}
|
|
294
|
+
export interface QuestionnaireActionProps extends Omit<ButtonProps, 'children'> {
|
|
295
|
+
/** Replace the label. Given a function, it is called with the question's state. */
|
|
296
|
+
children?: ReactNode | ((state: QuestionnaireActionState) => ReactNode);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* A flexible gap for the footer, so the trailing buttons sit against the
|
|
300
|
+
* trailing edge whether or not `Questionnaire.Back` is showing.
|
|
301
|
+
*/
|
|
302
|
+
declare function QuestionnaireSpacer({ className, ...props }: ViewProps): import("react").JSX.Element;
|
|
303
|
+
declare namespace QuestionnaireSpacer {
|
|
304
|
+
var displayName: string;
|
|
305
|
+
}
|
|
306
|
+
export declare const Questionnaire: typeof QuestionnaireRoot & {
|
|
307
|
+
Title: typeof QuestionnaireTitle;
|
|
308
|
+
Progress: typeof QuestionnaireProgress;
|
|
309
|
+
Item: typeof QuestionnaireItem;
|
|
310
|
+
Question: typeof QuestionnaireQuestion;
|
|
311
|
+
Description: typeof QuestionnaireDescription;
|
|
312
|
+
Choices: typeof QuestionnaireChoices;
|
|
313
|
+
Choice: import("react").ForwardRefExoticComponent<QuestionnaireChoiceProps & import("react").RefAttributes<View>>;
|
|
314
|
+
Input: import("react").ForwardRefExoticComponent<QuestionnaireInputProps & import("react").RefAttributes<TextInput>>;
|
|
315
|
+
Error: typeof QuestionnaireError;
|
|
316
|
+
Footer: typeof QuestionnaireFooter;
|
|
317
|
+
Spacer: typeof QuestionnaireSpacer;
|
|
318
|
+
Back: {
|
|
319
|
+
({ children, variant, className, ...props }: QuestionnaireActionProps): import("react").JSX.Element | null;
|
|
320
|
+
displayName: string;
|
|
321
|
+
};
|
|
322
|
+
Skip: {
|
|
323
|
+
({ children, variant, className, ...props }: QuestionnaireActionProps): import("react").JSX.Element | null;
|
|
324
|
+
displayName: string;
|
|
325
|
+
};
|
|
326
|
+
Next: {
|
|
327
|
+
({ children, variant, className, ...props }: QuestionnaireActionProps): import("react").JSX.Element | null;
|
|
328
|
+
displayName: string;
|
|
329
|
+
};
|
|
330
|
+
Submit: {
|
|
331
|
+
({ children, variant, className, ...props }: QuestionnaireActionProps): import("react").JSX.Element | null;
|
|
332
|
+
displayName: string;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
export {};
|
|
336
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/questionnaire/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,OAAO,EAaL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,IAAI,EAEJ,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAiBtB,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,oBAAW,CAAC;AAErD,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,mBAAU,CAAC;AA0GlD,kFAAkF;AAClF,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5E,4CAA4C;AA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,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,MAAM,EAAE,uBAAuB,CAAC;CACjC;AAED,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;IAC7E,mFAAmF;IACnF,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,wBAAwB,KAAK,SAAS,CAAC,CAAC;CACzE;AA4GD;;;GAGG;AACH,iBAAS,mBAAmB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,+BAE9D;kBAFQ,mBAAmB;;;AAK5B,eAAO,MAAM,aAAa;;;;;;;;;;;;;qDAjFoC,wBAAwB;;;;qDAAxB,wBAAwB;;;;qDAAxB,wBAAwB;;;;qDAAxB,wBAAwB;;;CAiGpF,CAAC"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScatterChart — two quantities against each other, drawn on the UI thread.
|
|
3
|
+
*
|
|
4
|
+
* Every other chart in this library spaces its points evenly along the x-axis,
|
|
5
|
+
* because their x is a position: twelve months are twelve equal steps whatever
|
|
6
|
+
* the gaps between the dates behind them. A scatter plot is the one shape where
|
|
7
|
+
* that is wrong. Both coordinates are *measured*, and the reader is being asked
|
|
8
|
+
* to look for a relationship between them — spread the points evenly and the
|
|
9
|
+
* relationship is the one thing you have thrown away.
|
|
10
|
+
*
|
|
11
|
+
* So this chart carries an x-domain as well as a y-domain, and both are tweened
|
|
12
|
+
* when the data changes.
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <ScatterChart data={sessions} xDataKey="spend">
|
|
16
|
+
* <ScatterChart.Grid />
|
|
17
|
+
* <ScatterChart.Points dataKey="revenue" />
|
|
18
|
+
* <ScatterChart.XAxis />
|
|
19
|
+
* <ScatterChart.YAxis />
|
|
20
|
+
* <ScatterChart.Tooltip />
|
|
21
|
+
* </ScatterChart>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* As elsewhere, there are two layers and the parts sort themselves into the
|
|
25
|
+
* right one: the geometry is SVG, and anything with text or a gesture on it is
|
|
26
|
+
* a React Native view over the top. SVG text ignores the platform's text
|
|
27
|
+
* scaling and the theme's font, and a gesture handler cannot be attached to an
|
|
28
|
+
* SVG node at all.
|
|
29
|
+
*
|
|
30
|
+
* **Finding a point.** A crosshair that snaps to an x index — the way a line
|
|
31
|
+
* chart's does — has nothing to snap to here, because there is no shared x and
|
|
32
|
+
* two points can sit at the same one. Instead the nearest point to the finger
|
|
33
|
+
* is resolved by distance, on the UI thread, and only within a radius: a touch
|
|
34
|
+
* in an empty corner of the plot selects nothing rather than lighting up
|
|
35
|
+
* whichever point happens to be least far away. The radius is generous, because
|
|
36
|
+
* the points are a few pixels across and a fingertip is not.
|
|
37
|
+
*
|
|
38
|
+
* Colours come from the `--color-chart-*` tokens, so a chart follows the active
|
|
39
|
+
* theme. Nothing here hardcodes a hex.
|
|
40
|
+
*/
|
|
41
|
+
import { type ReactNode } from 'react';
|
|
42
|
+
import { type ViewProps } from 'react-native';
|
|
43
|
+
type Layer = 'svg' | 'overlay' | 'header';
|
|
44
|
+
export type ScatterChartStatus = 'loading' | 'ready';
|
|
45
|
+
export type ScatterChartDatum = Record<string, string | number | null | undefined>;
|
|
46
|
+
/** One plotted point, resolved back to the row it came from. */
|
|
47
|
+
export interface ScatterChartPoint {
|
|
48
|
+
/** Index into `data`. */
|
|
49
|
+
index: number;
|
|
50
|
+
/** The series key this point belongs to. */
|
|
51
|
+
dataKey: string;
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
datum: ScatterChartDatum;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The selected point, for something rendered *inside* the chart.
|
|
58
|
+
*
|
|
59
|
+
* A readout usually belongs in the card's header, which is outside this
|
|
60
|
+
* provider — use `onActivePointChange` for that. A hook cannot reach up out of
|
|
61
|
+
* the subtree it is called in.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useScatterChart(): {
|
|
64
|
+
activePoint: ScatterChartPoint | null;
|
|
65
|
+
xDataKey: string;
|
|
66
|
+
};
|
|
67
|
+
export interface ScatterChartProps extends ViewProps {
|
|
68
|
+
className?: string;
|
|
69
|
+
/** The rows. Each one is a point, placed by two of its values. */
|
|
70
|
+
data: ScatterChartDatum[];
|
|
71
|
+
/** Key holding the x value. Unlike the other charts, this must be a number. */
|
|
72
|
+
xDataKey?: string;
|
|
73
|
+
/**
|
|
74
|
+
* `loading` draws a still field of muted dots and settles into the real ones
|
|
75
|
+
* when it turns `ready`. One component throughout, rather than a spinner
|
|
76
|
+
* swapped for a chart — swapping loses the transition.
|
|
77
|
+
*/
|
|
78
|
+
status?: ScatterChartStatus;
|
|
79
|
+
/** Width ÷ height. `1` suits a scatter plot: neither axis is the important one. */
|
|
80
|
+
aspectRatio?: number;
|
|
81
|
+
/** Milliseconds for the reveal on mount. */
|
|
82
|
+
animationDuration?: number;
|
|
83
|
+
/** Milliseconds for the axes to settle after the data changes. */
|
|
84
|
+
domainDuration?: number;
|
|
85
|
+
/** Fix the x-axis instead of deriving it from the data. */
|
|
86
|
+
xDomain?: [number, number];
|
|
87
|
+
/** Fix the y-axis instead of deriving it from the data. */
|
|
88
|
+
yDomain?: [number, number];
|
|
89
|
+
/**
|
|
90
|
+
* The point under the finger, and `null` when it lifts. This is how a readout
|
|
91
|
+
* in the card's header gets its value — that header is outside the chart, so
|
|
92
|
+
* it cannot use `useScatterChart`.
|
|
93
|
+
*
|
|
94
|
+
* Fires when the selection changes, not per frame.
|
|
95
|
+
*/
|
|
96
|
+
onActivePointChange?: (point: ScatterChartPoint | null) => void;
|
|
97
|
+
/** Drop the axis padding so the field reaches the edges, for a thumbnail. */
|
|
98
|
+
compact?: boolean;
|
|
99
|
+
children?: ReactNode;
|
|
100
|
+
}
|
|
101
|
+
/** Imperative handle: re-run the reveal on demand, for a "replay" control. */
|
|
102
|
+
export interface ScatterChartHandle {
|
|
103
|
+
replay: () => void;
|
|
104
|
+
}
|
|
105
|
+
export interface ScatterChartGridProps {
|
|
106
|
+
/** Horizontal rules across the plot. */
|
|
107
|
+
rows?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Vertical rules down it. A scatter plot's x is a quantity, so it earns a
|
|
110
|
+
* grid in both directions — a line chart's does not, because its x is a
|
|
111
|
+
* label and a rule under a label divides nothing.
|
|
112
|
+
*/
|
|
113
|
+
columns?: number;
|
|
114
|
+
color?: string;
|
|
115
|
+
/** Dash pattern, e.g. `"4,6"`. Omit for a solid rule. */
|
|
116
|
+
dashArray?: string;
|
|
117
|
+
opacity?: number;
|
|
118
|
+
}
|
|
119
|
+
/** Reference lines both ways. Drawn under everything, and not part of the reveal. */
|
|
120
|
+
declare function ScatterChartGrid({ rows, columns, color, dashArray, opacity, }: ScatterChartGridProps): import("react").JSX.Element;
|
|
121
|
+
declare namespace ScatterChartGrid {
|
|
122
|
+
var displayName: string;
|
|
123
|
+
var layer: Layer;
|
|
124
|
+
}
|
|
125
|
+
export interface ScatterChartPointsProps {
|
|
126
|
+
/** Key holding this series' y values. */
|
|
127
|
+
dataKey: string;
|
|
128
|
+
/**
|
|
129
|
+
* Fill colour. Defaults to the `--color-chart-*` token at `colorIndex`, so a
|
|
130
|
+
* series follows the theme without the call site naming a colour.
|
|
131
|
+
*/
|
|
132
|
+
color?: string;
|
|
133
|
+
/** Which `--color-chart-*` token to take when `color` is not given. */
|
|
134
|
+
colorIndex?: 1 | 2 | 3 | 4 | 5;
|
|
135
|
+
/** Radius of a point, in points. Ignored when `sizeKey` is given. */
|
|
136
|
+
size?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Key holding a third quantity, mapped to each point's *area* — a bubble
|
|
139
|
+
* chart. Area rather than radius, because doubling a radius quadruples the
|
|
140
|
+
* ink and the reader sees four times the value that is there.
|
|
141
|
+
*/
|
|
142
|
+
sizeKey?: string;
|
|
143
|
+
/** Smallest and largest radius `sizeKey` maps onto. */
|
|
144
|
+
sizeRange?: [number, number];
|
|
145
|
+
/**
|
|
146
|
+
* Fill opacity. Below 1 by default so that overlapping points read as denser
|
|
147
|
+
* rather than hiding each other — in a crowded region that overlap *is* the
|
|
148
|
+
* finding, and opaque dots erase it.
|
|
149
|
+
*/
|
|
150
|
+
opacity?: number;
|
|
151
|
+
}
|
|
152
|
+
/** One series, as a field of dots. */
|
|
153
|
+
declare function ScatterChartPoints({ dataKey, color, colorIndex, size, sizeKey, sizeRange, opacity, }: ScatterChartPointsProps): import("react").JSX.Element | null;
|
|
154
|
+
declare namespace ScatterChartPoints {
|
|
155
|
+
var displayName: string;
|
|
156
|
+
var layer: Layer;
|
|
157
|
+
}
|
|
158
|
+
export interface ScatterChartSkeletonProps {
|
|
159
|
+
/** How many placeholder dots to scatter. */
|
|
160
|
+
count?: number;
|
|
161
|
+
color?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The loading state: a still field of muted dots where the data will be.
|
|
165
|
+
*
|
|
166
|
+
* Deliberately still. A shimmer over a field of dots reads as the points
|
|
167
|
+
* *moving*, which is the one thing a scatter plot must never appear to do —
|
|
168
|
+
* position is the entire message, and a loading state that implies it is
|
|
169
|
+
* changing is a loading state that lies.
|
|
170
|
+
*
|
|
171
|
+
* The layout is deterministic rather than random, so it does not reshuffle on
|
|
172
|
+
* every render of a component that may re-render several times while waiting.
|
|
173
|
+
*
|
|
174
|
+
* Still is not the same as abrupt, though. It dissolves as the real points grow
|
|
175
|
+
* in, and outlives the status change by exactly that long — cut at the frame the
|
|
176
|
+
* data lands, the placeholder disappears before anything has replaced it and the
|
|
177
|
+
* plot is briefly empty.
|
|
178
|
+
*/
|
|
179
|
+
declare function ScatterChartSkeleton({ count, color }: ScatterChartSkeletonProps): import("react").JSX.Element | null;
|
|
180
|
+
declare namespace ScatterChartSkeleton {
|
|
181
|
+
var displayName: string;
|
|
182
|
+
var layer: Layer;
|
|
183
|
+
}
|
|
184
|
+
export interface ScatterChartXAxisProps {
|
|
185
|
+
/** How many intervals to divide the axis into. Yields `ticks + 1` labels. */
|
|
186
|
+
ticks?: number;
|
|
187
|
+
/** Turn a value into its label. Defaults to a compact number. */
|
|
188
|
+
format?: (value: number) => string;
|
|
189
|
+
className?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The x labels, evenly along the axis.
|
|
193
|
+
*
|
|
194
|
+
* Evenly spaced here — unlike a line chart's, where each label sits on the point
|
|
195
|
+
* it names — because this axis is a continuous scale rather than a list of
|
|
196
|
+
* rows. There is no point to sit on.
|
|
197
|
+
*/
|
|
198
|
+
declare function ScatterChartXAxis({ ticks, format, className }: ScatterChartXAxisProps): import("react").JSX.Element;
|
|
199
|
+
declare namespace ScatterChartXAxis {
|
|
200
|
+
var displayName: string;
|
|
201
|
+
var layer: Layer;
|
|
202
|
+
}
|
|
203
|
+
export interface ScatterChartYAxisProps {
|
|
204
|
+
/** How many intervals to divide the axis into. Yields `ticks + 1` labels. */
|
|
205
|
+
ticks?: number;
|
|
206
|
+
/** Turn a value into its label. Defaults to a compact number. */
|
|
207
|
+
format?: (value: number) => string;
|
|
208
|
+
className?: string;
|
|
209
|
+
}
|
|
210
|
+
/** Value labels down the side, one per grid line. */
|
|
211
|
+
declare function ScatterChartYAxis({ ticks, format, className }: ScatterChartYAxisProps): import("react").JSX.Element;
|
|
212
|
+
declare namespace ScatterChartYAxis {
|
|
213
|
+
var displayName: string;
|
|
214
|
+
var layer: Layer;
|
|
215
|
+
var axis: "y";
|
|
216
|
+
}
|
|
217
|
+
export interface ScatterChartTooltipProps {
|
|
218
|
+
/** Float a small readout beside the selected point. On by default. */
|
|
219
|
+
showLabel?: boolean;
|
|
220
|
+
/** Format the x value for the readout. Defaults to a compact number. */
|
|
221
|
+
formatX?: (value: number) => string;
|
|
222
|
+
/** Format the y value for the readout. Defaults to a compact number. */
|
|
223
|
+
formatY?: (value: number, key: string) => string;
|
|
224
|
+
/** A heading for the readout, from the row — a name, a label, a category. */
|
|
225
|
+
formatTitle?: (datum: ScatterChartDatum) => string;
|
|
226
|
+
/** How far from a point a touch still counts as being on it, in points. */
|
|
227
|
+
hitRadius?: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The touch target, the selection it drives, and the readout that follows it.
|
|
231
|
+
*
|
|
232
|
+
* A line chart's crosshair snaps to an x index. That is not available here:
|
|
233
|
+
* there is no shared x, and two points can sit on the same one. So the nearest
|
|
234
|
+
* point is found by distance instead — and only within `hitRadius`, so a touch
|
|
235
|
+
* in an empty corner selects nothing rather than lighting up whichever point is
|
|
236
|
+
* least far away.
|
|
237
|
+
*
|
|
238
|
+
* The search runs on the UI thread over a flat array of already-projected
|
|
239
|
+
* coordinates, and only the *identity* of the winner crosses back into JS, and
|
|
240
|
+
* only when it changes. A drag across the plot therefore costs a handful of
|
|
241
|
+
* re-renders rather than one per frame.
|
|
242
|
+
*
|
|
243
|
+
* Distances are compared squared. The nearest point by distance is the nearest
|
|
244
|
+
* by distance-squared, and a square root per point per frame buys nothing.
|
|
245
|
+
*/
|
|
246
|
+
declare function ScatterChartTooltip({ showLabel, formatX, formatY, formatTitle, hitRadius, }: ScatterChartTooltipProps): import("react").JSX.Element | null;
|
|
247
|
+
declare namespace ScatterChartTooltip {
|
|
248
|
+
var displayName: string;
|
|
249
|
+
var layer: Layer;
|
|
250
|
+
}
|
|
251
|
+
export interface ScatterChartLegendProps extends ViewProps {
|
|
252
|
+
className?: string;
|
|
253
|
+
/** Label per series key. A key with no label falls back to the key itself. */
|
|
254
|
+
labels?: Record<string, string>;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* A swatch and a name per registered series. Sits in the top-left of the plot
|
|
258
|
+
* by default — move it with `className`.
|
|
259
|
+
*/
|
|
260
|
+
declare function ScatterChartLegend({ className, labels, ...props }: ScatterChartLegendProps): import("react").JSX.Element | null;
|
|
261
|
+
declare namespace ScatterChartLegend {
|
|
262
|
+
var displayName: string;
|
|
263
|
+
var layer: Layer;
|
|
264
|
+
}
|
|
265
|
+
export interface ScatterChartHeaderProps extends ViewProps {
|
|
266
|
+
className?: string;
|
|
267
|
+
/** Small line above the value — what the chart is of. */
|
|
268
|
+
title?: string;
|
|
269
|
+
/** The readout. The largest thing on the card, and the first thing read. */
|
|
270
|
+
value?: string;
|
|
271
|
+
/** One muted line under the value — a period, a comparison, a total. */
|
|
272
|
+
caption?: string;
|
|
273
|
+
/** Prettier names for the series keys, as the legend takes. */
|
|
274
|
+
labels?: Record<string, string>;
|
|
275
|
+
/**
|
|
276
|
+
* Draw a swatch and a name per series along the trailing edge. Prefer this to
|
|
277
|
+
* `ScatterChart.Legend` on a chart that has a header: the legend floats over
|
|
278
|
+
* the plot, where it competes with the points for the same corner.
|
|
279
|
+
*/
|
|
280
|
+
legend?: boolean;
|
|
281
|
+
/** Trailing slot — a control, a badge, a range picker. Wins over `legend`. */
|
|
282
|
+
children?: ReactNode;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* The strip above the plot: what the chart is of, what it currently reads, and
|
|
286
|
+
* what the colours mean.
|
|
287
|
+
*
|
|
288
|
+
* The value is not derived here. A readout that follows the finger belongs to
|
|
289
|
+
* whoever owns the data — take it from `onActivePointChange` and pass the
|
|
290
|
+
* formatted string down, so one header can show a summary when nothing is
|
|
291
|
+
* pressed and a point's values when something is.
|
|
292
|
+
*/
|
|
293
|
+
declare function ScatterChartHeader({ className, title, value, caption, labels, legend, children, ...props }: ScatterChartHeaderProps): import("react").JSX.Element;
|
|
294
|
+
declare namespace ScatterChartHeader {
|
|
295
|
+
var displayName: string;
|
|
296
|
+
var layer: Layer;
|
|
297
|
+
}
|
|
298
|
+
export declare const ScatterChart: import("react").ForwardRefExoticComponent<ScatterChartProps & import("react").RefAttributes<ScatterChartHandle>> & {
|
|
299
|
+
Header: typeof ScatterChartHeader;
|
|
300
|
+
Grid: typeof ScatterChartGrid;
|
|
301
|
+
Points: typeof ScatterChartPoints;
|
|
302
|
+
Skeleton: typeof ScatterChartSkeleton;
|
|
303
|
+
XAxis: typeof ScatterChartXAxis;
|
|
304
|
+
YAxis: typeof ScatterChartYAxis;
|
|
305
|
+
Tooltip: typeof ScatterChartTooltip;
|
|
306
|
+
Legend: typeof ScatterChartLegend;
|
|
307
|
+
};
|
|
308
|
+
export {};
|
|
309
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/scatter-chart/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AA8ExF,KAAK,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,CAAC;AACrD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEnF,gEAAgE;AAChE,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,iBAAiB,CAAC;CAC1B;AAoCD;;;;;;GAMG;AACH,wBAAgB,eAAe;;;EAG9B;AAED,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,kB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