@cfinnestad/react-form-builder 1.0.14 → 1.0.16
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/cjs/index.js +10 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Errors/Errors.d.ts +1 -2
- package/dist/cjs/types/components/Items/GetValue.d.ts +1 -1
- package/dist/cjs/types/components/Items/Items.d.ts +23 -4
- package/dist/cjs/types/components/Items/Subtypes/Text/index.d.ts +1 -1
- package/dist/cjs/types/shared/themes/TestTheme.d.ts +13 -0
- package/dist/esm/index.js +12 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/Errors/Errors.d.ts +1 -2
- package/dist/esm/types/components/Items/GetValue.d.ts +1 -1
- package/dist/esm/types/components/Items/Items.d.ts +23 -4
- package/dist/esm/types/components/Items/Subtypes/Text/index.d.ts +1 -1
- package/dist/esm/types/shared/themes/TestTheme.d.ts +13 -0
- package/dist/index.d.ts +24 -5
- package/package.json +2 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AnyItem } from "../Items";
|
|
2
1
|
export type ErrorType = {
|
|
3
2
|
[key: string]: string;
|
|
4
3
|
};
|
|
5
4
|
declare const Errors: () => ErrorType;
|
|
6
|
-
export declare const GetError: (error: string, item:
|
|
5
|
+
export declare const GetError: (error: string, item: object, errors: ErrorType) => string | undefined;
|
|
7
6
|
export default Errors;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FieldItem, HiddenItem } from "./Items";
|
|
2
|
-
declare const GetValue: (item: FieldItem | HiddenItem) => string | number | boolean | string[] | undefined;
|
|
2
|
+
declare const GetValue: (item: FieldItem | HiddenItem) => string | number | boolean | string[] | File[] | undefined;
|
|
3
3
|
export default GetValue;
|
|
@@ -21,7 +21,7 @@ export type Options = {
|
|
|
21
21
|
setItems: Dispatch<SetStateAction<AnyItem[]>>;
|
|
22
22
|
setModal?: Dispatch<SetStateAction<boolean>>;
|
|
23
23
|
Mode?: string;
|
|
24
|
-
getError: (error: string, item:
|
|
24
|
+
getError: (error: string, item: any) => string | undefined;
|
|
25
25
|
searchableOptions?: {
|
|
26
26
|
[key: string]: (input?: string) => Promise<Option[]> | Option[];
|
|
27
27
|
};
|
|
@@ -142,7 +142,7 @@ export type FieldItem = NamedItem & {
|
|
|
142
142
|
custom?: {
|
|
143
143
|
[key: string]: any;
|
|
144
144
|
};
|
|
145
|
-
value?: string | number | string[] | boolean;
|
|
145
|
+
value?: string | number | string[] | boolean | File[];
|
|
146
146
|
errorText?: string;
|
|
147
147
|
};
|
|
148
148
|
export type OptionSubtype = FieldItem & {
|
|
@@ -184,6 +184,15 @@ export type TextSubtype = FieldItem & {
|
|
|
184
184
|
minLength?: number;
|
|
185
185
|
maxLength?: number;
|
|
186
186
|
};
|
|
187
|
+
export type FileSubtype = FieldItem & {
|
|
188
|
+
label?: string;
|
|
189
|
+
subtype: 'File';
|
|
190
|
+
value?: File[];
|
|
191
|
+
maxFiles: number;
|
|
192
|
+
maxSizeBytes: number;
|
|
193
|
+
fileTypes?: string[];
|
|
194
|
+
content: string;
|
|
195
|
+
};
|
|
187
196
|
export type EmailSubtype = FieldItem & {
|
|
188
197
|
label?: string;
|
|
189
198
|
subtype: 'Email';
|
|
@@ -225,7 +234,7 @@ export type BooleanSubtype = FieldItem & {
|
|
|
225
234
|
description: string;
|
|
226
235
|
value?: boolean;
|
|
227
236
|
};
|
|
228
|
-
export type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
237
|
+
export type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | FileSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
229
238
|
export type ItemType = {
|
|
230
239
|
Item: AnyItem;
|
|
231
240
|
ItemFC: (props: ItemProps | HiddenProps | FieldProps | SubmitProps | HTMLProps | GroupProps) => JSX.Element;
|
|
@@ -282,6 +291,12 @@ export type TextType = FieldType & {
|
|
|
282
291
|
EditFC: (props: TextProps) => JSX.Element;
|
|
283
292
|
ValidateFC?: (item: TextSubtype, options: Options) => boolean;
|
|
284
293
|
};
|
|
294
|
+
export type FileType = FieldType & {
|
|
295
|
+
Subtype: FileSubtype;
|
|
296
|
+
SubtypeFC: (props: FileProps) => JSX.Element;
|
|
297
|
+
EditFC: (props: FileProps) => JSX.Element;
|
|
298
|
+
ValidateFC?: (item: FileSubtype, options: Options) => boolean;
|
|
299
|
+
};
|
|
285
300
|
export type EmailType = FieldType & {
|
|
286
301
|
Subtype: EmailSubtype;
|
|
287
302
|
SubtypeFC: (props: EmailProps) => JSX.Element;
|
|
@@ -318,7 +333,7 @@ export type PhoneType = FieldType & {
|
|
|
318
333
|
EditFC: (props: PhoneProps) => JSX.Element;
|
|
319
334
|
ValidateFC?: (item: PhoneSubtype, options: Options) => boolean;
|
|
320
335
|
};
|
|
321
|
-
export type AnyFieldType = SelectType | RadioType | CheckboxType | TextType | EmailType | NumberType | DateType | BooleanType | AutocompleteType | PhoneType;
|
|
336
|
+
export type AnyFieldType = SelectType | RadioType | CheckboxType | TextType | FileType | EmailType | NumberType | DateType | BooleanType | AutocompleteType | PhoneType;
|
|
322
337
|
export type BaseItemProps = {
|
|
323
338
|
item: AnyItem;
|
|
324
339
|
items: AnyItem[];
|
|
@@ -355,6 +370,9 @@ export type CheckboxProps = FieldProps & {
|
|
|
355
370
|
export type TextProps = FieldProps & {
|
|
356
371
|
item: TextSubtype;
|
|
357
372
|
};
|
|
373
|
+
export type FileProps = FieldProps & {
|
|
374
|
+
item: FileSubtype;
|
|
375
|
+
};
|
|
358
376
|
export type EmailProps = FieldProps & {
|
|
359
377
|
item: EmailSubtype;
|
|
360
378
|
};
|
|
@@ -383,6 +401,7 @@ export declare function isSelect(item: AnyItem): item is SelectSubtype;
|
|
|
383
401
|
export declare function isRadio(item: AnyItem): item is RadioSubtype;
|
|
384
402
|
export declare function isCheckbox(item: AnyItem): item is CheckboxSubtype;
|
|
385
403
|
export declare function isText(item: AnyItem): item is TextSubtype;
|
|
404
|
+
export declare function isFile(item: AnyItem): item is FileSubtype;
|
|
386
405
|
export declare function isEmail(item: AnyItem): item is EmailSubtype;
|
|
387
406
|
export declare function isNumber(item: AnyItem): item is NumberSubtype;
|
|
388
407
|
export declare function isDate(item: AnyItem): item is DateSubtype;
|
|
@@ -1 +1,14 @@
|
|
|
1
1
|
export declare const TestTheme: import("@mui/material").Theme;
|
|
2
|
+
declare module '@mui/material/styles' {
|
|
3
|
+
interface Palette {
|
|
4
|
+
custom: Palette['primary'];
|
|
5
|
+
}
|
|
6
|
+
interface PaletteOptions {
|
|
7
|
+
custom: PaletteOptions['primary'];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare module '@mui/material/Button' {
|
|
11
|
+
interface ButtonPropsColorOverrides {
|
|
12
|
+
custom: true;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ type Options = {
|
|
|
35
35
|
setItems: Dispatch<SetStateAction<AnyItem[]>>;
|
|
36
36
|
setModal?: Dispatch<SetStateAction<boolean>>;
|
|
37
37
|
Mode?: string;
|
|
38
|
-
getError: (error: string, item:
|
|
38
|
+
getError: (error: string, item: any) => string | undefined;
|
|
39
39
|
searchableOptions?: {
|
|
40
40
|
[key: string]: (input?: string) => Promise<Option[]> | Option[];
|
|
41
41
|
};
|
|
@@ -156,7 +156,7 @@ type FieldItem = NamedItem & {
|
|
|
156
156
|
custom?: {
|
|
157
157
|
[key: string]: any;
|
|
158
158
|
};
|
|
159
|
-
value?: string | number | string[] | boolean;
|
|
159
|
+
value?: string | number | string[] | boolean | File[];
|
|
160
160
|
errorText?: string;
|
|
161
161
|
};
|
|
162
162
|
type OptionSubtype = FieldItem & {
|
|
@@ -198,6 +198,15 @@ type TextSubtype = FieldItem & {
|
|
|
198
198
|
minLength?: number;
|
|
199
199
|
maxLength?: number;
|
|
200
200
|
};
|
|
201
|
+
type FileSubtype = FieldItem & {
|
|
202
|
+
label?: string;
|
|
203
|
+
subtype: 'File';
|
|
204
|
+
value?: File[];
|
|
205
|
+
maxFiles: number;
|
|
206
|
+
maxSizeBytes: number;
|
|
207
|
+
fileTypes?: string[];
|
|
208
|
+
content: string;
|
|
209
|
+
};
|
|
201
210
|
type EmailSubtype = FieldItem & {
|
|
202
211
|
label?: string;
|
|
203
212
|
subtype: 'Email';
|
|
@@ -239,7 +248,7 @@ type BooleanSubtype = FieldItem & {
|
|
|
239
248
|
description: string;
|
|
240
249
|
value?: boolean;
|
|
241
250
|
};
|
|
242
|
-
type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
251
|
+
type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | FileSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
243
252
|
type ItemType = {
|
|
244
253
|
Item: AnyItem;
|
|
245
254
|
ItemFC: (props: ItemProps | HiddenProps | FieldProps | SubmitProps | HTMLProps | GroupProps) => JSX.Element;
|
|
@@ -296,6 +305,12 @@ type TextType = FieldType & {
|
|
|
296
305
|
EditFC: (props: TextProps) => JSX.Element;
|
|
297
306
|
ValidateFC?: (item: TextSubtype, options: Options) => boolean;
|
|
298
307
|
};
|
|
308
|
+
type FileType = FieldType & {
|
|
309
|
+
Subtype: FileSubtype;
|
|
310
|
+
SubtypeFC: (props: FileProps) => JSX.Element;
|
|
311
|
+
EditFC: (props: FileProps) => JSX.Element;
|
|
312
|
+
ValidateFC?: (item: FileSubtype, options: Options) => boolean;
|
|
313
|
+
};
|
|
299
314
|
type EmailType = FieldType & {
|
|
300
315
|
Subtype: EmailSubtype;
|
|
301
316
|
SubtypeFC: (props: EmailProps) => JSX.Element;
|
|
@@ -332,7 +347,7 @@ type PhoneType = FieldType & {
|
|
|
332
347
|
EditFC: (props: PhoneProps) => JSX.Element;
|
|
333
348
|
ValidateFC?: (item: PhoneSubtype, options: Options) => boolean;
|
|
334
349
|
};
|
|
335
|
-
type AnyFieldType = SelectType | RadioType | CheckboxType | TextType | EmailType | NumberType | DateType | BooleanType | AutocompleteType | PhoneType;
|
|
350
|
+
type AnyFieldType = SelectType | RadioType | CheckboxType | TextType | FileType | EmailType | NumberType | DateType | BooleanType | AutocompleteType | PhoneType;
|
|
336
351
|
type BaseItemProps = {
|
|
337
352
|
item: AnyItem;
|
|
338
353
|
items: AnyItem[];
|
|
@@ -369,6 +384,9 @@ type CheckboxProps = FieldProps & {
|
|
|
369
384
|
type TextProps = FieldProps & {
|
|
370
385
|
item: TextSubtype;
|
|
371
386
|
};
|
|
387
|
+
type FileProps = FieldProps & {
|
|
388
|
+
item: FileSubtype;
|
|
389
|
+
};
|
|
372
390
|
type EmailProps = FieldProps & {
|
|
373
391
|
item: EmailSubtype;
|
|
374
392
|
};
|
|
@@ -397,6 +415,7 @@ declare function isSelect(item: AnyItem): item is SelectSubtype;
|
|
|
397
415
|
declare function isRadio(item: AnyItem): item is RadioSubtype;
|
|
398
416
|
declare function isCheckbox(item: AnyItem): item is CheckboxSubtype;
|
|
399
417
|
declare function isText(item: AnyItem): item is TextSubtype;
|
|
418
|
+
declare function isFile(item: AnyItem): item is FileSubtype;
|
|
400
419
|
declare function isEmail(item: AnyItem): item is EmailSubtype;
|
|
401
420
|
declare function isNumber(item: AnyItem): item is NumberSubtype;
|
|
402
421
|
declare function isDate(item: AnyItem): item is DateSubtype;
|
|
@@ -503,4 +522,4 @@ declare const RenderedFlatObject: (items: AnyItem[]) => {};
|
|
|
503
522
|
declare const RenderedArray: (items: AnyItem[]) => {} | [];
|
|
504
523
|
declare const RenderedFlatArray: (items: AnyItem[]) => object[];
|
|
505
524
|
|
|
506
|
-
export { AllowedItems, AllowedSubtypes, AndFilter, AnyFieldType, AnyItem, AutocompleteProps, AutocompleteSubtype, AutocompleteType, BaseItem, BaseItemProps, BooleanProps, BooleanSubtype, BooleanType, BuildErrors, Builder, BuilderProps, BuilderUseOptions, CheckboxProps, CheckboxSubtype, CheckboxType, Clear, ComparisonFilter, DateProps, DateSubtype, DateType, EmailProps, EmailSubtype, EmailType, EqFilter, ErrorType, Errors, FieldFilter, FieldItem, FieldProps, FieldType, FilterType, GetNamedItem as GetItem, GroupItem, GroupProps, GroupType, GtFilter, GteFilter, HTMLItem, HTMLProps, HTMLType, HiddenItem, HiddenProps, HiddenType, InFilter, ItemProps, ItemType, LtFilter, LteFilter, MultiplesSubtype, NamedItem, NotFilter, NumberProps, NumberSubtype, NumberType, Option, OptionSubtype, Options, OrFilter, PhoneProps, PhoneSubtype, PhoneType, Preview, RadioProps, RadioSubtype, RadioType, Render, RenderOptions, RenderProps, RenderedArray, RenderedFlatArray, RenderedFlatObject, RenderedObject, Save, SelectProps, SelectSubtype, SelectType, UpdateItemInItems as SetItem, SubmitButtonElement, SubmitButtonProps, SubmitItem, SubmitProps, SubmitType, TextProps, TextSubtype, TextType, Transfer, ValidateFields, getSiblingItems, isAndFilter, isAutocomplete, isBoolean, isCheckbox, isComparisonFilter, isDate, isEmail, isEqFilter, isField, isFieldFilter, isGroup, isGtFilter, isGteFilter, isHidden, isHtml, isInFilter, isLtFilter, isLteFilter, isNamed, isNotFilter, isNumber, isOption, isOrFilter, isPhone, isRadio, isSelect, isSubmit, isText, validateNameChange };
|
|
525
|
+
export { AllowedItems, AllowedSubtypes, AndFilter, AnyFieldType, AnyItem, AutocompleteProps, AutocompleteSubtype, AutocompleteType, BaseItem, BaseItemProps, BooleanProps, BooleanSubtype, BooleanType, BuildErrors, Builder, BuilderProps, BuilderUseOptions, CheckboxProps, CheckboxSubtype, CheckboxType, Clear, ComparisonFilter, DateProps, DateSubtype, DateType, EmailProps, EmailSubtype, EmailType, EqFilter, ErrorType, Errors, FieldFilter, FieldItem, FieldProps, FieldType, FileProps, FileSubtype, FileType, FilterType, GetNamedItem as GetItem, GroupItem, GroupProps, GroupType, GtFilter, GteFilter, HTMLItem, HTMLProps, HTMLType, HiddenItem, HiddenProps, HiddenType, InFilter, ItemProps, ItemType, LtFilter, LteFilter, MultiplesSubtype, NamedItem, NotFilter, NumberProps, NumberSubtype, NumberType, Option, OptionSubtype, Options, OrFilter, PhoneProps, PhoneSubtype, PhoneType, Preview, RadioProps, RadioSubtype, RadioType, Render, RenderOptions, RenderProps, RenderedArray, RenderedFlatArray, RenderedFlatObject, RenderedObject, Save, SelectProps, SelectSubtype, SelectType, UpdateItemInItems as SetItem, SubmitButtonElement, SubmitButtonProps, SubmitItem, SubmitProps, SubmitType, TextProps, TextSubtype, TextType, Transfer, ValidateFields, getSiblingItems, isAndFilter, isAutocomplete, isBoolean, isCheckbox, isComparisonFilter, isDate, isEmail, isEqFilter, isField, isFieldFilter, isFile, isGroup, isGtFilter, isGteFilter, isHidden, isHtml, isInFilter, isLtFilter, isLteFilter, isNamed, isNotFilter, isNumber, isOption, isOrFilter, isPhone, isRadio, isSelect, isSubmit, isText, validateNameChange };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfinnestad/react-form-builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "FormBuilder and FormRender Component library for building and gathering custom form data",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"rollup": "rollup -c",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"mini-css-extract-plugin": "^2.7.6",
|
|
93
93
|
"mui-phone-number": "^3.0.3",
|
|
94
94
|
"react-copy-to-clipboard": "^5.1.0",
|
|
95
|
+
"react-dropzone": "^14.2.3",
|
|
95
96
|
"styled-components": "^5.3.10",
|
|
96
97
|
"tinymce": "^6.6.0",
|
|
97
98
|
"uuidv4": "^6.2.13"
|