@maif/react-forms 1.0.60 → 1.1.2
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 +21 -0
- package/lib/esm/index.js +1290 -2772
- package/lib/index.d.ts +364 -0
- package/lib/index.js +1304 -2786
- package/package.json +23 -15
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as yup_lib_types from 'yup/lib/types';
|
|
3
|
+
import * as yup from 'yup';
|
|
4
|
+
import { AnySchema, StringSchema, NumberSchema, ArraySchema, TestFunction } from 'yup';
|
|
5
|
+
import Reference from 'yup/lib/Reference';
|
|
6
|
+
import * as yup_lib_object from 'yup/lib/object';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
declare const type: {
|
|
10
|
+
readonly string: "string";
|
|
11
|
+
readonly number: "number";
|
|
12
|
+
readonly bool: "bool";
|
|
13
|
+
readonly date: "date";
|
|
14
|
+
readonly object: "object";
|
|
15
|
+
readonly file: "file";
|
|
16
|
+
readonly json: "json";
|
|
17
|
+
};
|
|
18
|
+
declare let typeValues: ("string" | "number" | "object" | "json" | "bool" | "date" | "file")[];
|
|
19
|
+
declare type Type = typeof typeValues[number];
|
|
20
|
+
|
|
21
|
+
declare const format: {
|
|
22
|
+
readonly array: "array";
|
|
23
|
+
readonly select: "select";
|
|
24
|
+
readonly code: "code";
|
|
25
|
+
readonly markdown: "markdown";
|
|
26
|
+
readonly text: "textarea";
|
|
27
|
+
readonly textarea: "textarea";
|
|
28
|
+
readonly email: "email";
|
|
29
|
+
readonly password: "password";
|
|
30
|
+
readonly hidden: "hidden";
|
|
31
|
+
readonly form: "form";
|
|
32
|
+
readonly buttonsSelect: "buttons";
|
|
33
|
+
readonly singleLineCode: "singleLineCode";
|
|
34
|
+
};
|
|
35
|
+
declare let formatValues: ("markdown" | "email" | "array" | "select" | "code" | "textarea" | "password" | "hidden" | "form" | "buttons" | "singleLineCode")[];
|
|
36
|
+
declare type Format = typeof formatValues[number];
|
|
37
|
+
|
|
38
|
+
declare type Constraint = (resolver: any, key: string, dependencies: any[]) => AnySchema;
|
|
39
|
+
declare type NumberRef = Reference<number> | number;
|
|
40
|
+
declare const required: (message?: string) => (r: AnySchema) => any;
|
|
41
|
+
declare const url: (message?: string) => (r: StringSchema) => yup.StringSchema<string | undefined, yup_lib_types.AnyObject, string | undefined>;
|
|
42
|
+
declare const email: (message?: string) => (r: StringSchema) => yup.StringSchema<string | undefined, yup_lib_types.AnyObject, string | undefined>;
|
|
43
|
+
declare const uuid: (message?: string) => (r: StringSchema) => yup.StringSchema<string | undefined, yup_lib_types.AnyObject, string | undefined>;
|
|
44
|
+
declare const matches: (regexp?: RegExp, message?: string) => (r: StringSchema) => yup.StringSchema<string | undefined, yup_lib_types.AnyObject, string | undefined>;
|
|
45
|
+
declare const min: (ref: NumberRef, message?: string) => (r: StringSchema | NumberSchema) => yup.StringSchema<string | undefined, yup_lib_types.AnyObject, string | undefined> | yup.NumberSchema<number | undefined, yup_lib_types.AnyObject, number | undefined>;
|
|
46
|
+
declare const max: (ref: NumberRef, message?: string) => (r: StringSchema | NumberSchema) => yup.StringSchema<string | undefined, yup_lib_types.AnyObject, string | undefined> | yup.NumberSchema<number | undefined, yup_lib_types.AnyObject, number | undefined>;
|
|
47
|
+
declare const positive: (message?: string) => (r: NumberSchema) => yup.NumberSchema<number | undefined, yup_lib_types.AnyObject, number | undefined>;
|
|
48
|
+
declare const negative: (message?: string) => (r: NumberSchema) => yup.NumberSchema<number | undefined, yup_lib_types.AnyObject, number | undefined>;
|
|
49
|
+
declare const integer: (message?: string) => (r: NumberSchema) => yup.NumberSchema<number | undefined, yup_lib_types.AnyObject, number | undefined>;
|
|
50
|
+
declare const lessThan: (ref: NumberRef, message?: string) => (r: NumberSchema, key: any, dependencies: Array<[any, Reference]>) => yup.NumberSchema<number | undefined, yup_lib_types.AnyObject, number | undefined>;
|
|
51
|
+
declare const moreThan: (ref: NumberRef, message?: string) => (r: NumberSchema, key: any, dependencies: Array<[any, Reference]>) => yup.NumberSchema<number | undefined, yup_lib_types.AnyObject, number | undefined>;
|
|
52
|
+
declare const length: (ref: NumberRef, message?: string) => (r: ArraySchema<any>) => yup.ArraySchema<any, yup_lib_types.AnyObject, any[] | undefined, any[] | undefined>;
|
|
53
|
+
declare const supportedFormat: (arrayOfValues: string[], message?: string) => (r: AnySchema) => yup.AnySchema<any, any, any>;
|
|
54
|
+
declare const unsupportedFormat: (arrayOfValues: string[], message?: string) => (r: AnySchema) => yup.AnySchema<any, any, any>;
|
|
55
|
+
declare const maxSize: (ref: Reference, message?: string) => (r: AnySchema) => yup.AnySchema<any, any, any>;
|
|
56
|
+
declare const test: (name: string, message: string | undefined, test: TestFunction<any, object>) => (r: AnySchema) => yup.AnySchema<any, any, any>;
|
|
57
|
+
declare const when: (ref: string, test: TestFunction<any, object>, then?: Constraint[], otherwise?: Constraint[]) => (r: AnySchema, key: string, dependencies: any[]) => yup.AnySchema<any, any, any>;
|
|
58
|
+
declare const oneOf: (arrayOfValues: any[], message?: string) => (r: AnySchema) => yup.AnySchema<any, any, any>;
|
|
59
|
+
declare const blacklist: (arrayOfValues: any[], message?: string) => (r: AnySchema) => yup.AnySchema<any, any, any>;
|
|
60
|
+
declare const ref: (ref: string) => Reference<unknown>;
|
|
61
|
+
declare const jsonConstraints: Record<string, any>;
|
|
62
|
+
declare type TConstraintType = keyof typeof jsonConstraints;
|
|
63
|
+
|
|
64
|
+
type constraints_d_Constraint = Constraint;
|
|
65
|
+
declare const constraints_d_required: typeof required;
|
|
66
|
+
declare const constraints_d_url: typeof url;
|
|
67
|
+
declare const constraints_d_email: typeof email;
|
|
68
|
+
declare const constraints_d_uuid: typeof uuid;
|
|
69
|
+
declare const constraints_d_matches: typeof matches;
|
|
70
|
+
declare const constraints_d_min: typeof min;
|
|
71
|
+
declare const constraints_d_max: typeof max;
|
|
72
|
+
declare const constraints_d_positive: typeof positive;
|
|
73
|
+
declare const constraints_d_negative: typeof negative;
|
|
74
|
+
declare const constraints_d_integer: typeof integer;
|
|
75
|
+
declare const constraints_d_lessThan: typeof lessThan;
|
|
76
|
+
declare const constraints_d_moreThan: typeof moreThan;
|
|
77
|
+
declare const constraints_d_length: typeof length;
|
|
78
|
+
declare const constraints_d_supportedFormat: typeof supportedFormat;
|
|
79
|
+
declare const constraints_d_unsupportedFormat: typeof unsupportedFormat;
|
|
80
|
+
declare const constraints_d_maxSize: typeof maxSize;
|
|
81
|
+
declare const constraints_d_test: typeof test;
|
|
82
|
+
declare const constraints_d_when: typeof when;
|
|
83
|
+
declare const constraints_d_oneOf: typeof oneOf;
|
|
84
|
+
declare const constraints_d_blacklist: typeof blacklist;
|
|
85
|
+
declare const constraints_d_ref: typeof ref;
|
|
86
|
+
declare const constraints_d_jsonConstraints: typeof jsonConstraints;
|
|
87
|
+
type constraints_d_TConstraintType = TConstraintType;
|
|
88
|
+
declare namespace constraints_d {
|
|
89
|
+
export {
|
|
90
|
+
constraints_d_Constraint as Constraint,
|
|
91
|
+
constraints_d_required as required,
|
|
92
|
+
constraints_d_url as url,
|
|
93
|
+
constraints_d_email as email,
|
|
94
|
+
constraints_d_uuid as uuid,
|
|
95
|
+
constraints_d_matches as matches,
|
|
96
|
+
constraints_d_min as min,
|
|
97
|
+
constraints_d_max as max,
|
|
98
|
+
constraints_d_positive as positive,
|
|
99
|
+
constraints_d_negative as negative,
|
|
100
|
+
constraints_d_integer as integer,
|
|
101
|
+
constraints_d_lessThan as lessThan,
|
|
102
|
+
constraints_d_moreThan as moreThan,
|
|
103
|
+
constraints_d_length as length,
|
|
104
|
+
constraints_d_supportedFormat as supportedFormat,
|
|
105
|
+
constraints_d_unsupportedFormat as unsupportedFormat,
|
|
106
|
+
constraints_d_maxSize as maxSize,
|
|
107
|
+
constraints_d_test as test,
|
|
108
|
+
constraints_d_when as when,
|
|
109
|
+
constraints_d_oneOf as oneOf,
|
|
110
|
+
constraints_d_blacklist as blacklist,
|
|
111
|
+
constraints_d_ref as ref,
|
|
112
|
+
constraints_d_jsonConstraints as jsonConstraints,
|
|
113
|
+
constraints_d_TConstraintType as TConstraintType,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface PropType {
|
|
118
|
+
onChange?: (v: boolean) => void;
|
|
119
|
+
value?: boolean;
|
|
120
|
+
readOnly?: boolean;
|
|
121
|
+
}
|
|
122
|
+
declare const BooleanInput: React.ForwardRefExoticComponent<PropType & React.RefAttributes<HTMLInputElement>>;
|
|
123
|
+
|
|
124
|
+
declare const Collapse: (props: {
|
|
125
|
+
initCollapsed?: boolean;
|
|
126
|
+
collapsed?: boolean;
|
|
127
|
+
errored: boolean;
|
|
128
|
+
label?: React.ReactNode;
|
|
129
|
+
inline?: any;
|
|
130
|
+
children: React.ReactNode;
|
|
131
|
+
lineEnd?: boolean;
|
|
132
|
+
}) => JSX.Element;
|
|
133
|
+
|
|
134
|
+
declare type SelectOption = {
|
|
135
|
+
label: string;
|
|
136
|
+
value: any;
|
|
137
|
+
};
|
|
138
|
+
declare const SelectInput: <T extends {
|
|
139
|
+
[x: string]: any;
|
|
140
|
+
}>(props: {
|
|
141
|
+
possibleValues: T[];
|
|
142
|
+
transformer?: {
|
|
143
|
+
label: string;
|
|
144
|
+
value: string;
|
|
145
|
+
} | ((v: T) => SelectOption) | undefined;
|
|
146
|
+
value?: any;
|
|
147
|
+
defaultValue?: any;
|
|
148
|
+
isMulti?: boolean | undefined;
|
|
149
|
+
optionsFrom: string | Promise<T[]> | ((param: {
|
|
150
|
+
rawValues: object;
|
|
151
|
+
value: any;
|
|
152
|
+
}) => string | Promise<T[]>);
|
|
153
|
+
fetchCondition?: (() => boolean) | undefined;
|
|
154
|
+
id?: string | undefined;
|
|
155
|
+
httpClient?: ((url: string, method: string) => Promise<Response>) | undefined;
|
|
156
|
+
onChange?: ((options: any[] | any) => void) | undefined;
|
|
157
|
+
onCreateOption?: ((option: string) => T) | undefined;
|
|
158
|
+
buttons: boolean;
|
|
159
|
+
disabled?: boolean | undefined;
|
|
160
|
+
createOption?: boolean | undefined;
|
|
161
|
+
label?: string | undefined;
|
|
162
|
+
placeholder?: React.ReactNode;
|
|
163
|
+
className: string;
|
|
164
|
+
}) => JSX.Element;
|
|
165
|
+
|
|
166
|
+
declare type InternalState = {
|
|
167
|
+
[x: string]: {
|
|
168
|
+
key: string;
|
|
169
|
+
value: any;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
declare const ObjectInput: (props: {
|
|
173
|
+
value?: object | undefined;
|
|
174
|
+
onChange?: ((value: InternalState) => void) | undefined;
|
|
175
|
+
defaultKeyValue?: {
|
|
176
|
+
key: string;
|
|
177
|
+
value: string;
|
|
178
|
+
} | undefined;
|
|
179
|
+
className: string;
|
|
180
|
+
disabled?: boolean | undefined;
|
|
181
|
+
placeholderKey?: string | undefined;
|
|
182
|
+
placeholderValue?: string | undefined;
|
|
183
|
+
}) => JSX.Element;
|
|
184
|
+
|
|
185
|
+
declare type LanguageMode = "javascript" | "css" | "json" | "html" | "markdown";
|
|
186
|
+
|
|
187
|
+
declare function CodeInput({ onChange, value, mode, tabSize, readOnly, showLinesNumber, highlightLine, themeStyle, setRef }: {
|
|
188
|
+
onChange?: (v: string) => void;
|
|
189
|
+
value?: string;
|
|
190
|
+
mode?: LanguageMode;
|
|
191
|
+
tabSize?: number;
|
|
192
|
+
readOnly?: boolean;
|
|
193
|
+
showLinesNumber?: boolean;
|
|
194
|
+
highlightLine?: boolean;
|
|
195
|
+
themeStyle?: {
|
|
196
|
+
height: string;
|
|
197
|
+
minHeight: string;
|
|
198
|
+
maxHeight: string;
|
|
199
|
+
width: string;
|
|
200
|
+
minWidth: string;
|
|
201
|
+
maxWidth: string;
|
|
202
|
+
};
|
|
203
|
+
setRef?: (editor: any) => void;
|
|
204
|
+
}): JSX.Element;
|
|
205
|
+
|
|
206
|
+
declare const MarkdownInput: (props: {
|
|
207
|
+
value?: string | undefined;
|
|
208
|
+
preview?: boolean | undefined;
|
|
209
|
+
className: string;
|
|
210
|
+
readOnly?: boolean | undefined;
|
|
211
|
+
onChange?: ((value: string) => void) | undefined;
|
|
212
|
+
}) => JSX.Element;
|
|
213
|
+
|
|
214
|
+
declare function SingleLineCode({ onChange, value, mode, tabSize, readOnly, showLinesNumber, highlightLine, themeStyle }: {
|
|
215
|
+
onChange?: (newValue: string) => void;
|
|
216
|
+
value?: string;
|
|
217
|
+
mode?: LanguageMode;
|
|
218
|
+
tabSize?: number;
|
|
219
|
+
readOnly?: boolean;
|
|
220
|
+
showLinesNumber?: boolean;
|
|
221
|
+
highlightLine?: boolean;
|
|
222
|
+
themeStyle?: {
|
|
223
|
+
height: string;
|
|
224
|
+
minHeight: string;
|
|
225
|
+
maxHeight: string;
|
|
226
|
+
width: string;
|
|
227
|
+
minWidth: string;
|
|
228
|
+
maxWidth: string;
|
|
229
|
+
};
|
|
230
|
+
}): JSX.Element;
|
|
231
|
+
|
|
232
|
+
interface OptionActionItem {
|
|
233
|
+
display?: boolean;
|
|
234
|
+
label?: string;
|
|
235
|
+
}
|
|
236
|
+
interface OptionActions {
|
|
237
|
+
reset?: OptionActionItem;
|
|
238
|
+
submit?: OptionActionItem;
|
|
239
|
+
}
|
|
240
|
+
declare type HttpClient = (url: string, method: string) => Promise<Response>;
|
|
241
|
+
interface Option {
|
|
242
|
+
httpClient?: HttpClient;
|
|
243
|
+
watch?: boolean | ((param: any) => void);
|
|
244
|
+
autosubmit?: boolean;
|
|
245
|
+
actions?: OptionActions;
|
|
246
|
+
showErrorsOnStart?: boolean;
|
|
247
|
+
}
|
|
248
|
+
interface Schema {
|
|
249
|
+
[key: string]: SchemaEntry;
|
|
250
|
+
}
|
|
251
|
+
declare type SchemaRenderType = ({ rawValues, value, onChange, error, setValue, parent }: {
|
|
252
|
+
rawValues?: any;
|
|
253
|
+
value?: any;
|
|
254
|
+
onChange?: (param: object) => void;
|
|
255
|
+
error?: boolean;
|
|
256
|
+
parent?: string;
|
|
257
|
+
setValue?: (data: any) => void;
|
|
258
|
+
}) => JSX.Element;
|
|
259
|
+
interface ConditionnalSchemaElement {
|
|
260
|
+
default?: boolean;
|
|
261
|
+
condition?: ({ rawValues, ref }: {
|
|
262
|
+
rawValues: {
|
|
263
|
+
[x: string]: any;
|
|
264
|
+
};
|
|
265
|
+
ref: any;
|
|
266
|
+
}) => boolean | any;
|
|
267
|
+
schema: Schema;
|
|
268
|
+
flow: Array<FlowObject | string>;
|
|
269
|
+
}
|
|
270
|
+
interface ConditionnalSchema {
|
|
271
|
+
ref: string;
|
|
272
|
+
switch: ConditionnalSchemaElement[];
|
|
273
|
+
}
|
|
274
|
+
interface SchemaEntry {
|
|
275
|
+
schema?: Schema;
|
|
276
|
+
type: Type;
|
|
277
|
+
format?: Format;
|
|
278
|
+
array?: boolean;
|
|
279
|
+
createOption?: boolean;
|
|
280
|
+
onCreateOption?: (option: string) => any;
|
|
281
|
+
isMulti?: boolean;
|
|
282
|
+
defaultKeyValue?: object;
|
|
283
|
+
visible?: boolean | {
|
|
284
|
+
ref: string;
|
|
285
|
+
test: (b: any, idx?: number) => boolean;
|
|
286
|
+
};
|
|
287
|
+
disabled?: boolean | ((prop: {
|
|
288
|
+
rawValues: {
|
|
289
|
+
[x: string]: any;
|
|
290
|
+
};
|
|
291
|
+
value: any;
|
|
292
|
+
}) => boolean);
|
|
293
|
+
label?: React.ReactNode | ((prop: {
|
|
294
|
+
rawValues: {
|
|
295
|
+
[x: string]: any;
|
|
296
|
+
};
|
|
297
|
+
value: any;
|
|
298
|
+
}) => React.ReactNode);
|
|
299
|
+
placeholder?: string;
|
|
300
|
+
defaultValue?: any;
|
|
301
|
+
help?: string;
|
|
302
|
+
className?: string;
|
|
303
|
+
style?: object;
|
|
304
|
+
onChange?: (param: object) => void;
|
|
305
|
+
render: SchemaRenderType;
|
|
306
|
+
itemRender?: SchemaRenderType;
|
|
307
|
+
props: object;
|
|
308
|
+
options: Array<any | {
|
|
309
|
+
label: string;
|
|
310
|
+
value: any;
|
|
311
|
+
}>;
|
|
312
|
+
optionsFrom: string;
|
|
313
|
+
transformer: ((v: any) => SelectOption) | {
|
|
314
|
+
label: string;
|
|
315
|
+
value: string;
|
|
316
|
+
};
|
|
317
|
+
conditionalSchema: ConditionnalSchema;
|
|
318
|
+
constraints: Array<Constraint | {
|
|
319
|
+
type: TConstraintType;
|
|
320
|
+
message?: string;
|
|
321
|
+
}>;
|
|
322
|
+
flow: Array<string | FlowObject>;
|
|
323
|
+
onAfterChange?: (obj: {
|
|
324
|
+
entry: string;
|
|
325
|
+
value: object;
|
|
326
|
+
rawValues: object;
|
|
327
|
+
previousValue?: object;
|
|
328
|
+
getValue: (entry: string) => any;
|
|
329
|
+
setValue: (entry: string, value: any) => void;
|
|
330
|
+
onChange: (v: any) => void;
|
|
331
|
+
informations?: Informations;
|
|
332
|
+
}) => void;
|
|
333
|
+
visibleOnCollapse?: boolean;
|
|
334
|
+
addableDefaultValue: any;
|
|
335
|
+
collapsed?: boolean;
|
|
336
|
+
collapsable?: boolean;
|
|
337
|
+
}
|
|
338
|
+
interface FlowObject {
|
|
339
|
+
label: string;
|
|
340
|
+
flow: Flow;
|
|
341
|
+
collapse: boolean;
|
|
342
|
+
}
|
|
343
|
+
declare type Flow = Array<string | FlowObject>;
|
|
344
|
+
interface Informations {
|
|
345
|
+
path: string;
|
|
346
|
+
parent?: Informations;
|
|
347
|
+
index?: number;
|
|
348
|
+
}
|
|
349
|
+
declare const validate: (flow: string[], schema: Schema, value: object) => Promise<yup_lib_object.AssertsShape<yup_lib_object.Assign<yup_lib_object.ObjectShape, yup_lib_object.ObjectShape>>>;
|
|
350
|
+
declare const Form: React.ForwardRefExoticComponent<{
|
|
351
|
+
schema: Schema;
|
|
352
|
+
flow: Array<string | FlowObject>;
|
|
353
|
+
value?: object | undefined;
|
|
354
|
+
inputWrapper?: ((props: object) => JSX.Element) | undefined;
|
|
355
|
+
onSubmit: (obj: object) => void;
|
|
356
|
+
onError?: (() => void) | undefined;
|
|
357
|
+
footer?: ((props: object) => JSX.Element) | undefined;
|
|
358
|
+
style?: object | undefined;
|
|
359
|
+
className?: string | undefined;
|
|
360
|
+
options?: Option | undefined;
|
|
361
|
+
nostyle: boolean;
|
|
362
|
+
} & React.RefAttributes<unknown>>;
|
|
363
|
+
|
|
364
|
+
export { BooleanInput, CodeInput, Collapse, ConditionnalSchema, Flow, Form, Format, MarkdownInput, ObjectInput, Schema, SchemaEntry, SelectInput, SelectOption, SingleLineCode, Type, constraints_d as constraints, format, type, validate };
|