@wise/dynamic-flow-types 2.16.0 → 2.17.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/build/renderers/index.d.ts +364 -0
- package/package.json +3 -2
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import type { Action, Icon as DFIcon, Margin as DFMargin, Size as DFSize, SearchResult as SearchResultSpec, Step } from '../next';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export type Align = 'start' | 'center' | 'end';
|
|
4
|
+
export type Bias = 'none' | 'start' | 'end';
|
|
5
|
+
export type Context = 'positive' | 'negative' | 'warning' | 'neutral';
|
|
6
|
+
export type Margin = DFMargin;
|
|
7
|
+
export type Size = DFSize;
|
|
8
|
+
export type LoadingState = 'idle' | 'submitting' | 'refreshing';
|
|
9
|
+
export type AnalyticsEventDispatcher = (eventName: string, properties?: Record<string, unknown>) => void;
|
|
10
|
+
export type Image = {
|
|
11
|
+
url: string;
|
|
12
|
+
accessibilityDescription?: string;
|
|
13
|
+
};
|
|
14
|
+
export type Icon = DFIcon;
|
|
15
|
+
export type DecisionOption = {
|
|
16
|
+
description?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
icon?: Icon;
|
|
19
|
+
image?: Image;
|
|
20
|
+
title: string;
|
|
21
|
+
onClick: () => void;
|
|
22
|
+
};
|
|
23
|
+
export type InstructionItem = {
|
|
24
|
+
context: Context;
|
|
25
|
+
text: string;
|
|
26
|
+
};
|
|
27
|
+
export type ReviewCallToAction = {
|
|
28
|
+
title: string;
|
|
29
|
+
onClick: () => void;
|
|
30
|
+
};
|
|
31
|
+
export type ReviewField = {
|
|
32
|
+
help?: string;
|
|
33
|
+
label: string;
|
|
34
|
+
value: string;
|
|
35
|
+
};
|
|
36
|
+
export type Renderer<P extends RendererProps> = {
|
|
37
|
+
canRenderType: P['type'];
|
|
38
|
+
canRender?: (props: P) => boolean;
|
|
39
|
+
render: (props: P) => JSX.Element;
|
|
40
|
+
};
|
|
41
|
+
export interface CoreContainerRendererProps {
|
|
42
|
+
type: 'container';
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
export type RendererProps = AlertRendererProps | BooleanInputRendererProps | BoxRendererProps | ButtonRendererProps | ColumnsRendererProps | CoreContainerRendererProps | DateInputRendererProps | DecisionRendererProps | DividerRendererProps | FormRendererProps | FormSectionRendererProps | HeadingRendererProps | HiddenRendererProps | ImageRendererProps | InstructionsRendererProps | IntegerInputRendererProps | LoadingIndicatorRendererProps | MarkdownRendererProps | ModalRendererProps | MultiSelectInputRendererProps | MultiUploadInputRendererProps | NumberInputRendererProps | ParagraphRendererProps | RepeatableRendererProps | ReviewRendererProps | SearchRendererProps | SelectInputRendererProps | StatusListRendererProps | StepRendererProps | TextInputRendererProps | UploadInputRendererProps;
|
|
46
|
+
export type Renderers = readonly (Renderer<StepRendererProps> | Renderer<CoreContainerRendererProps> | Renderer<AlertRendererProps> | Renderer<BoxRendererProps> | Renderer<ColumnsRendererProps> | Renderer<DecisionRendererProps> | Renderer<DividerRendererProps> | Renderer<FormRendererProps> | Renderer<HeadingRendererProps> | Renderer<InstructionsRendererProps> | Renderer<LoadingIndicatorRendererProps> | Renderer<MarkdownRendererProps> | Renderer<ImageRendererProps> | Renderer<ModalRendererProps> | Renderer<ParagraphRendererProps> | Renderer<ReviewRendererProps> | Renderer<SearchRendererProps> | Renderer<StatusListRendererProps> | Renderer<FormSectionRendererProps> | Renderer<BooleanInputRendererProps> | Renderer<ButtonRendererProps> | Renderer<DateInputRendererProps> | Renderer<HiddenRendererProps> | Renderer<IntegerInputRendererProps> | Renderer<NumberInputRendererProps> | Renderer<RepeatableRendererProps> | Renderer<SelectInputRendererProps> | Renderer<MultiSelectInputRendererProps> | Renderer<TextInputRendererProps> | Renderer<UploadInputRendererProps> | Renderer<MultiUploadInputRendererProps>)[];
|
|
47
|
+
export type StepRendererProps = {
|
|
48
|
+
type: 'step';
|
|
49
|
+
control?: string;
|
|
50
|
+
back?: {
|
|
51
|
+
title?: string;
|
|
52
|
+
onClick: () => void;
|
|
53
|
+
};
|
|
54
|
+
description?: string;
|
|
55
|
+
error?: string;
|
|
56
|
+
external?: {
|
|
57
|
+
url: string;
|
|
58
|
+
};
|
|
59
|
+
loadingState: LoadingState;
|
|
60
|
+
title?: string;
|
|
61
|
+
trackEvent: AnalyticsEventDispatcher;
|
|
62
|
+
/** @experimental Please do not use this property. It is only here to support a legacy camera step. */
|
|
63
|
+
step?: Step;
|
|
64
|
+
/** @experimental Please do not use this function. Calling onAction from a step renderer completely bypasses the core logic and may result in unexpected behavior. It is only here to support a legacy camera step. */
|
|
65
|
+
onAction?: (action: Action) => void | Promise<void>;
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
};
|
|
68
|
+
export type AlertRendererProps = {
|
|
69
|
+
type: 'alert';
|
|
70
|
+
control?: string;
|
|
71
|
+
context: Context;
|
|
72
|
+
margin: Margin;
|
|
73
|
+
markdown: string;
|
|
74
|
+
};
|
|
75
|
+
export type BoxRendererProps = {
|
|
76
|
+
type: 'box';
|
|
77
|
+
control?: string;
|
|
78
|
+
border: boolean;
|
|
79
|
+
children: ReactNode;
|
|
80
|
+
margin: Margin;
|
|
81
|
+
width: Size;
|
|
82
|
+
};
|
|
83
|
+
export type ColumnsRendererProps = {
|
|
84
|
+
type: 'columns';
|
|
85
|
+
control?: string;
|
|
86
|
+
bias: Bias;
|
|
87
|
+
margin: Margin;
|
|
88
|
+
startChildren: ReactNode;
|
|
89
|
+
endChildren: ReactNode;
|
|
90
|
+
};
|
|
91
|
+
export type DecisionRendererProps = {
|
|
92
|
+
type: 'decision';
|
|
93
|
+
control?: string;
|
|
94
|
+
options: DecisionOption[];
|
|
95
|
+
margin: Margin;
|
|
96
|
+
title?: string;
|
|
97
|
+
};
|
|
98
|
+
export type DividerRendererProps = {
|
|
99
|
+
type: 'divider';
|
|
100
|
+
control?: string;
|
|
101
|
+
margin: Margin;
|
|
102
|
+
};
|
|
103
|
+
export type FormRendererProps = {
|
|
104
|
+
type: 'form';
|
|
105
|
+
control?: string;
|
|
106
|
+
children: ReactNode;
|
|
107
|
+
margin: Margin;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Known values for "control" are: 'display'.
|
|
111
|
+
*/
|
|
112
|
+
export type HeadingRendererProps = {
|
|
113
|
+
type: 'heading';
|
|
114
|
+
control?: string;
|
|
115
|
+
align: Align;
|
|
116
|
+
margin: Margin;
|
|
117
|
+
size: Size;
|
|
118
|
+
text: string;
|
|
119
|
+
};
|
|
120
|
+
export type InstructionsRendererProps = {
|
|
121
|
+
type: 'instructions';
|
|
122
|
+
control?: string;
|
|
123
|
+
items: InstructionItem[];
|
|
124
|
+
margin: Margin;
|
|
125
|
+
title?: string;
|
|
126
|
+
};
|
|
127
|
+
export type LoadingIndicatorRendererProps = {
|
|
128
|
+
type: 'loading-indicator';
|
|
129
|
+
control?: string;
|
|
130
|
+
margin: Margin;
|
|
131
|
+
size: Size;
|
|
132
|
+
};
|
|
133
|
+
export type MarkdownRendererProps = {
|
|
134
|
+
type: 'markdown';
|
|
135
|
+
control?: string;
|
|
136
|
+
align: Align;
|
|
137
|
+
margin: Margin;
|
|
138
|
+
content: string;
|
|
139
|
+
};
|
|
140
|
+
export type ImageRendererProps = {
|
|
141
|
+
type: 'image';
|
|
142
|
+
control?: string;
|
|
143
|
+
accessibilityDescription?: string;
|
|
144
|
+
size: Size;
|
|
145
|
+
margin: Margin;
|
|
146
|
+
url: string;
|
|
147
|
+
};
|
|
148
|
+
export type ModalRendererProps = {
|
|
149
|
+
type: 'modal';
|
|
150
|
+
control?: string;
|
|
151
|
+
content: {
|
|
152
|
+
components: ReactNode;
|
|
153
|
+
};
|
|
154
|
+
margin: Margin;
|
|
155
|
+
trigger: {
|
|
156
|
+
title: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Known values for "control" are: 'copyable'.
|
|
161
|
+
*/
|
|
162
|
+
export type ParagraphRendererProps = {
|
|
163
|
+
type: 'paragraph';
|
|
164
|
+
control?: string;
|
|
165
|
+
align: Align;
|
|
166
|
+
margin: Margin;
|
|
167
|
+
text: string;
|
|
168
|
+
};
|
|
169
|
+
export type ReviewRendererProps = {
|
|
170
|
+
type: 'review';
|
|
171
|
+
control?: string;
|
|
172
|
+
fields: ReviewField[];
|
|
173
|
+
margin: Margin;
|
|
174
|
+
title?: string;
|
|
175
|
+
callToAction?: ReviewCallToAction;
|
|
176
|
+
};
|
|
177
|
+
export type SearchRendererProps = {
|
|
178
|
+
type: 'search';
|
|
179
|
+
control?: string;
|
|
180
|
+
id: string;
|
|
181
|
+
isLoading: boolean;
|
|
182
|
+
margin: Margin;
|
|
183
|
+
query: string;
|
|
184
|
+
onChange: (query: string) => void;
|
|
185
|
+
state: SearchState;
|
|
186
|
+
title: string;
|
|
187
|
+
};
|
|
188
|
+
export type SearchState = PendingSearchState | NoResultsSearchState | ResultsSearchState | ErrorSearchState;
|
|
189
|
+
export type PendingSearchState = {
|
|
190
|
+
type: 'pending';
|
|
191
|
+
};
|
|
192
|
+
export type NoResultsSearchState = {
|
|
193
|
+
type: 'noResults';
|
|
194
|
+
message: string;
|
|
195
|
+
};
|
|
196
|
+
export type ErrorSearchState = {
|
|
197
|
+
type: 'error';
|
|
198
|
+
onRetry: () => void;
|
|
199
|
+
};
|
|
200
|
+
export type ResultsSearchState = {
|
|
201
|
+
type: 'results';
|
|
202
|
+
results: SearchResult[];
|
|
203
|
+
};
|
|
204
|
+
export type SearchResult = Pick<SearchResultSpec, 'description' | 'icon' | 'image' | 'title' | 'type'> & {
|
|
205
|
+
id?: string;
|
|
206
|
+
onClick: () => void;
|
|
207
|
+
};
|
|
208
|
+
export type StatusListRendererProps = {
|
|
209
|
+
type: 'status-list';
|
|
210
|
+
control?: string;
|
|
211
|
+
items: StatusListItem[];
|
|
212
|
+
margin: Margin;
|
|
213
|
+
title?: string;
|
|
214
|
+
};
|
|
215
|
+
export type StatusListItem = {
|
|
216
|
+
description?: string;
|
|
217
|
+
icon: Icon;
|
|
218
|
+
status?: 'done' | 'not-done' | 'pending';
|
|
219
|
+
title: string;
|
|
220
|
+
};
|
|
221
|
+
export type StatusListItemStatus = 'done' | 'not-done' | 'pending';
|
|
222
|
+
export type FormSectionRendererProps = {
|
|
223
|
+
type: 'form-section';
|
|
224
|
+
control?: string;
|
|
225
|
+
title?: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
help?: string;
|
|
228
|
+
children: ReactNode;
|
|
229
|
+
};
|
|
230
|
+
interface BaseInputRendererProps {
|
|
231
|
+
id: string;
|
|
232
|
+
control?: string;
|
|
233
|
+
autoComplete: string;
|
|
234
|
+
description?: string;
|
|
235
|
+
disabled: boolean;
|
|
236
|
+
error?: string;
|
|
237
|
+
help?: string;
|
|
238
|
+
label?: string;
|
|
239
|
+
placeholder?: string;
|
|
240
|
+
required: boolean;
|
|
241
|
+
onBlur: () => void;
|
|
242
|
+
onFocus: () => void;
|
|
243
|
+
}
|
|
244
|
+
export interface BooleanInputRendererProps extends BaseInputRendererProps {
|
|
245
|
+
type: 'input-boolean';
|
|
246
|
+
value: boolean;
|
|
247
|
+
onChange: (value: boolean) => void;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Known values for "control" are: 'primary' | 'secondary' | 'tertiary'.
|
|
251
|
+
*/
|
|
252
|
+
export type ButtonRendererProps = {
|
|
253
|
+
type: 'button';
|
|
254
|
+
control?: string;
|
|
255
|
+
context: Context;
|
|
256
|
+
disabled: boolean;
|
|
257
|
+
margin: Margin;
|
|
258
|
+
pinOrder?: number;
|
|
259
|
+
size?: Size;
|
|
260
|
+
title: string;
|
|
261
|
+
onClick: () => void;
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Known values for "control" are: 'date-lookup'.
|
|
265
|
+
*/
|
|
266
|
+
export type DateInputRendererProps = BaseInputRendererProps & {
|
|
267
|
+
type: 'input-date';
|
|
268
|
+
minimumDate?: string;
|
|
269
|
+
maximumDate?: string;
|
|
270
|
+
value: string | null;
|
|
271
|
+
onChange: (value: string | null) => void;
|
|
272
|
+
};
|
|
273
|
+
export type HiddenRendererProps = {
|
|
274
|
+
type: 'hidden';
|
|
275
|
+
control?: string;
|
|
276
|
+
};
|
|
277
|
+
export type IntegerInputRendererProps = BaseInputRendererProps & {
|
|
278
|
+
type: 'input-integer';
|
|
279
|
+
value: number | null;
|
|
280
|
+
onChange: (value: number | null) => void;
|
|
281
|
+
};
|
|
282
|
+
export type MultiSelectInputRendererProps = BaseInputRendererProps & {
|
|
283
|
+
type: 'input-multi-select';
|
|
284
|
+
label?: string;
|
|
285
|
+
description?: string;
|
|
286
|
+
selectedIndices: number[];
|
|
287
|
+
options: SelectInputRendererOption[];
|
|
288
|
+
onSelect: (indices: number[]) => void;
|
|
289
|
+
};
|
|
290
|
+
export type NumberInputRendererProps = BaseInputRendererProps & {
|
|
291
|
+
type: 'input-number';
|
|
292
|
+
value: number | null;
|
|
293
|
+
onChange: (value: number | null) => void;
|
|
294
|
+
};
|
|
295
|
+
export type RepeatableRendererProps = {
|
|
296
|
+
type: 'repeatable';
|
|
297
|
+
control?: string;
|
|
298
|
+
addItemTitle: string;
|
|
299
|
+
description?: string;
|
|
300
|
+
children: ReactNode[];
|
|
301
|
+
editableItem: ReactNode;
|
|
302
|
+
editItemTitle: string;
|
|
303
|
+
error?: string;
|
|
304
|
+
items: RepeatableItemRendererProps[];
|
|
305
|
+
title: string;
|
|
306
|
+
onAdd: () => void;
|
|
307
|
+
onEdit: (itemIndex: number) => void;
|
|
308
|
+
onSave: () => boolean;
|
|
309
|
+
onRemove: () => void;
|
|
310
|
+
};
|
|
311
|
+
export type RepeatableItemRendererProps = {
|
|
312
|
+
id: string;
|
|
313
|
+
description?: string;
|
|
314
|
+
icon?: Icon;
|
|
315
|
+
image?: Image;
|
|
316
|
+
title?: string;
|
|
317
|
+
};
|
|
318
|
+
export type SelectInputRendererProps = BaseInputRendererProps & {
|
|
319
|
+
type: 'input-select';
|
|
320
|
+
children: ReactNode;
|
|
321
|
+
options: SelectInputRendererOption[];
|
|
322
|
+
selectedIndex: number | null;
|
|
323
|
+
onSelect: (index: number | null) => void;
|
|
324
|
+
};
|
|
325
|
+
export type SelectInputRendererOption = {
|
|
326
|
+
description?: string;
|
|
327
|
+
disabled: boolean;
|
|
328
|
+
icon?: Icon;
|
|
329
|
+
image?: Image;
|
|
330
|
+
keywords?: string[];
|
|
331
|
+
title: string;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Known values for "control" are: 'password' | 'textarea' | 'email' | 'numeric' | 'phone-number'.
|
|
335
|
+
*/
|
|
336
|
+
export type TextInputRendererProps = BaseInputRendererProps & {
|
|
337
|
+
type: 'input-text';
|
|
338
|
+
displayFormat?: string;
|
|
339
|
+
value: string | null;
|
|
340
|
+
onChange: (value: string | null) => void;
|
|
341
|
+
};
|
|
342
|
+
export type UploadInputRendererProps = BaseInputRendererProps & {
|
|
343
|
+
type: 'input-upload';
|
|
344
|
+
maxSize?: number;
|
|
345
|
+
accepts?: string[];
|
|
346
|
+
value: File | null;
|
|
347
|
+
onUpload: (file: File | null) => Promise<void>;
|
|
348
|
+
};
|
|
349
|
+
export type MultiUploadInputRendererProps = BaseInputRendererProps & {
|
|
350
|
+
type: 'input-upload-multi';
|
|
351
|
+
maxSize?: number;
|
|
352
|
+
minItems?: number;
|
|
353
|
+
maxItems?: number;
|
|
354
|
+
accepts?: string[];
|
|
355
|
+
uploadLabel?: string;
|
|
356
|
+
value: FileWithId[];
|
|
357
|
+
onUpload: (file: File, fileId: string) => Promise<void>;
|
|
358
|
+
onDelete: (fileId: string) => Promise<void>;
|
|
359
|
+
};
|
|
360
|
+
type FileWithId = {
|
|
361
|
+
id: string;
|
|
362
|
+
file: File;
|
|
363
|
+
};
|
|
364
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Dynamic Flow TypeScript Types",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@formatjs/cli": "^6.2.12",
|
|
27
|
+
"@types/react": "18.3.3",
|
|
27
28
|
"esbuild": "0.20.2",
|
|
28
|
-
"npm-run-all2": "
|
|
29
|
+
"npm-run-all2": "6.2.2",
|
|
29
30
|
"ts-to-zod": "3.6.1",
|
|
30
31
|
"typescript": "5.4.5"
|
|
31
32
|
},
|