@cfinnestad/react-form-builder 1.0.30 → 1.0.32
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 +8 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Builder/Builder.d.ts +4 -0
- package/dist/cjs/types/components/Items/EditModal.d.ts +1 -0
- package/dist/cjs/types/components/Items/Items.d.ts +31 -5
- package/dist/cjs/types/components/Items/List/ItemList.d.ts +4 -0
- package/dist/cjs/types/components/Items/List/ItemListEdit.d.ts +4 -0
- package/dist/cjs/types/components/Items/List/List.stories.d.ts +16 -0
- package/dist/cjs/types/components/Items/List/index.d.ts +2 -0
- package/dist/esm/index.js +12 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/Builder/Builder.d.ts +4 -0
- package/dist/esm/types/components/Items/EditModal.d.ts +1 -0
- package/dist/esm/types/components/Items/Items.d.ts +31 -5
- package/dist/esm/types/components/Items/List/ItemList.d.ts +4 -0
- package/dist/esm/types/components/Items/List/ItemListEdit.d.ts +4 -0
- package/dist/esm/types/components/Items/List/List.stories.d.ts +16 -0
- package/dist/esm/types/components/Items/List/index.d.ts +2 -0
- package/dist/index.d.ts +35 -5
- package/package.json +1 -1
|
@@ -41,6 +41,10 @@ export type BuilderUseOptions = {
|
|
|
41
41
|
submitColors?: string[];
|
|
42
42
|
fileTypes?: Accept;
|
|
43
43
|
};
|
|
44
|
+
export type ModalProps = {
|
|
45
|
+
item: AnyItem;
|
|
46
|
+
inList?: boolean;
|
|
47
|
+
};
|
|
44
48
|
export type BuilderOptions = Options & {};
|
|
45
49
|
export type BuilderProps = {
|
|
46
50
|
AllowedItems?: AllowedItems;
|
|
@@ -2,13 +2,13 @@ import { Dispatch, FC, JSX, SetStateAction } from "react";
|
|
|
2
2
|
import { ActionProps } from "../Actions";
|
|
3
3
|
import { SubmitButtonProps } from "./Submit";
|
|
4
4
|
import { Theme } from "@mui/material/styles";
|
|
5
|
-
import { ActiveType } from "../Builder/Builder";
|
|
5
|
+
import { ActiveType, ModalProps } from "../Builder/Builder";
|
|
6
6
|
import { Accept } from "react-dropzone";
|
|
7
7
|
export type AllowedSubtypes = {
|
|
8
8
|
[key: string]: AnyFieldType;
|
|
9
9
|
};
|
|
10
10
|
export type AllowedItems = {
|
|
11
|
-
[key: string]: ItemType | HTMLType | GroupType | FieldType | SubmitType | HiddenType;
|
|
11
|
+
[key: string]: ItemType | HTMLType | GroupType | ListType | FieldType | SubmitType | HiddenType;
|
|
12
12
|
};
|
|
13
13
|
export type BuildErrors = {
|
|
14
14
|
[key: string]: string;
|
|
@@ -20,7 +20,7 @@ export type Options = {
|
|
|
20
20
|
onSave?: (Items: AnyItem[]) => void;
|
|
21
21
|
SetItem: Dispatch<SetStateAction<AnyItem>>;
|
|
22
22
|
setItems: Dispatch<SetStateAction<AnyItem[]>>;
|
|
23
|
-
setModal?: Dispatch<SetStateAction<
|
|
23
|
+
setModal?: Dispatch<SetStateAction<ModalProps | undefined>>;
|
|
24
24
|
Mode?: string;
|
|
25
25
|
getError: (error: string, item: any) => string | undefined;
|
|
26
26
|
searchableOptions?: {
|
|
@@ -126,6 +126,17 @@ export type SubmitItem = BaseItem & {
|
|
|
126
126
|
label?: string;
|
|
127
127
|
color?: string;
|
|
128
128
|
};
|
|
129
|
+
export type ListItem = BaseItem & {
|
|
130
|
+
type: 'List';
|
|
131
|
+
label?: string;
|
|
132
|
+
addButton?: string;
|
|
133
|
+
addColor?: string;
|
|
134
|
+
list?: InListItem[];
|
|
135
|
+
deprecated?: boolean;
|
|
136
|
+
minListSize: number;
|
|
137
|
+
maxListSize: number;
|
|
138
|
+
baseItem: InListItem;
|
|
139
|
+
};
|
|
129
140
|
export type GroupItem = NamedItem & {
|
|
130
141
|
type: 'Group';
|
|
131
142
|
label?: string;
|
|
@@ -239,7 +250,8 @@ export type BooleanSubtype = FieldItem & {
|
|
|
239
250
|
description: string;
|
|
240
251
|
value?: boolean;
|
|
241
252
|
};
|
|
242
|
-
export type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | FileSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
253
|
+
export type AnyItem = BaseItem | FieldItem | GroupItem | ListItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | FileSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
254
|
+
export type InListItem = FieldItem | GroupItem;
|
|
243
255
|
export type ItemType = {
|
|
244
256
|
Item: AnyItem;
|
|
245
257
|
ItemFC: (props: ItemProps | HiddenProps | FieldProps | SubmitProps | HTMLProps | GroupProps) => JSX.Element;
|
|
@@ -255,6 +267,11 @@ export type GroupType = {
|
|
|
255
267
|
ItemFC: (props: GroupProps) => JSX.Element;
|
|
256
268
|
EditFC: (props: GroupProps) => JSX.Element;
|
|
257
269
|
};
|
|
270
|
+
export type ListType = {
|
|
271
|
+
Item: ListItem;
|
|
272
|
+
ItemFC: (props: ListProps) => JSX.Element;
|
|
273
|
+
EditFC: (props: ListProps) => JSX.Element;
|
|
274
|
+
};
|
|
258
275
|
export type SubmitType = {
|
|
259
276
|
Item: SubmitItem;
|
|
260
277
|
ItemFC: (props: SubmitProps) => JSX.Element;
|
|
@@ -354,6 +371,9 @@ export type FieldProps = BaseItemProps & {
|
|
|
354
371
|
export type GroupProps = BaseItemProps & {
|
|
355
372
|
item: GroupItem;
|
|
356
373
|
};
|
|
374
|
+
export type ListProps = BaseItemProps & {
|
|
375
|
+
item: ListItem;
|
|
376
|
+
};
|
|
357
377
|
export type HTMLProps = BaseItemProps & {
|
|
358
378
|
item: HTMLItem;
|
|
359
379
|
};
|
|
@@ -396,7 +416,11 @@ export type AutocompleteProps = FieldProps & {
|
|
|
396
416
|
export type PhoneProps = FieldProps & {
|
|
397
417
|
item: PhoneSubtype;
|
|
398
418
|
};
|
|
399
|
-
export type
|
|
419
|
+
export type ListItemProps = ItemProps & {
|
|
420
|
+
index: number;
|
|
421
|
+
parentItem: ListItem;
|
|
422
|
+
};
|
|
423
|
+
export type ItemProps = BaseItemProps | GroupProps | ListProps | HiddenProps | HTMLProps | SubmitProps | FieldProps | SelectProps | RadioProps | CheckboxProps | TextProps | EmailProps | NumberProps | DateProps | BooleanProps | AutocompleteProps | PhoneProps;
|
|
400
424
|
export declare function isGroup(item: AnyItem): item is GroupItem;
|
|
401
425
|
export declare function isHidden(item: AnyItem): item is HiddenItem;
|
|
402
426
|
export declare function isField(item: AnyItem): item is FieldItem;
|
|
@@ -415,6 +439,8 @@ export declare function isAutocomplete(item: AnyItem): item is AutocompleteSubty
|
|
|
415
439
|
export declare function isPhone(item: AnyItem): item is PhoneSubtype;
|
|
416
440
|
export declare function isOption(item: AnyItem): item is OptionSubtype;
|
|
417
441
|
export declare function isNamed(item: AnyItem): item is NamedItem;
|
|
442
|
+
export declare function isList(item: AnyItem): item is ListItem;
|
|
443
|
+
export declare function isListItem(item: AnyItem): item is InListItem;
|
|
418
444
|
export declare function hasFiles(items: AnyItem[], allItems?: AnyItem[]): boolean;
|
|
419
445
|
export declare function itemsCloneDeep(items: AnyItem[]): AnyItem[];
|
|
420
446
|
export declare function itemCloneDeep(item: AnyItem): AnyItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StoryObj } from '@storybook/react';
|
|
3
|
+
import { ListItem } from "../Items";
|
|
4
|
+
declare const meta: {
|
|
5
|
+
title: string;
|
|
6
|
+
component: ({ Items, SetItems, Options }: import("../../index").RenderProps) => React.JSX.Element;
|
|
7
|
+
tags: string[];
|
|
8
|
+
argTypes: {
|
|
9
|
+
Items: ListItem[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof meta>;
|
|
14
|
+
export declare const Basic: Story;
|
|
15
|
+
export declare const grouplist: Story;
|
|
16
|
+
export declare const Filter: Story;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ type AllowedSubtypes = {
|
|
|
22
22
|
[key: string]: AnyFieldType;
|
|
23
23
|
};
|
|
24
24
|
type AllowedItems = {
|
|
25
|
-
[key: string]: ItemType | HTMLType | GroupType | FieldType | SubmitType | HiddenType;
|
|
25
|
+
[key: string]: ItemType | HTMLType | GroupType | ListType | FieldType | SubmitType | HiddenType;
|
|
26
26
|
};
|
|
27
27
|
type BuildErrors = {
|
|
28
28
|
[key: string]: string;
|
|
@@ -34,7 +34,7 @@ type Options = {
|
|
|
34
34
|
onSave?: (Items: AnyItem[]) => void;
|
|
35
35
|
SetItem: Dispatch<SetStateAction<AnyItem>>;
|
|
36
36
|
setItems: Dispatch<SetStateAction<AnyItem[]>>;
|
|
37
|
-
setModal?: Dispatch<SetStateAction<
|
|
37
|
+
setModal?: Dispatch<SetStateAction<ModalProps | undefined>>;
|
|
38
38
|
Mode?: string;
|
|
39
39
|
getError: (error: string, item: any) => string | undefined;
|
|
40
40
|
searchableOptions?: {
|
|
@@ -140,6 +140,17 @@ type SubmitItem = BaseItem & {
|
|
|
140
140
|
label?: string;
|
|
141
141
|
color?: string;
|
|
142
142
|
};
|
|
143
|
+
type ListItem = BaseItem & {
|
|
144
|
+
type: 'List';
|
|
145
|
+
label?: string;
|
|
146
|
+
addButton?: string;
|
|
147
|
+
addColor?: string;
|
|
148
|
+
list?: InListItem[];
|
|
149
|
+
deprecated?: boolean;
|
|
150
|
+
minListSize: number;
|
|
151
|
+
maxListSize: number;
|
|
152
|
+
baseItem: InListItem;
|
|
153
|
+
};
|
|
143
154
|
type GroupItem = NamedItem & {
|
|
144
155
|
type: 'Group';
|
|
145
156
|
label?: string;
|
|
@@ -253,7 +264,8 @@ type BooleanSubtype = FieldItem & {
|
|
|
253
264
|
description: string;
|
|
254
265
|
value?: boolean;
|
|
255
266
|
};
|
|
256
|
-
type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | FileSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
267
|
+
type AnyItem = BaseItem | FieldItem | GroupItem | ListItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | FileSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
|
|
268
|
+
type InListItem = FieldItem | GroupItem;
|
|
257
269
|
type ItemType = {
|
|
258
270
|
Item: AnyItem;
|
|
259
271
|
ItemFC: (props: ItemProps | HiddenProps | FieldProps | SubmitProps | HTMLProps | GroupProps) => JSX.Element;
|
|
@@ -269,6 +281,11 @@ type GroupType = {
|
|
|
269
281
|
ItemFC: (props: GroupProps) => JSX.Element;
|
|
270
282
|
EditFC: (props: GroupProps) => JSX.Element;
|
|
271
283
|
};
|
|
284
|
+
type ListType = {
|
|
285
|
+
Item: ListItem;
|
|
286
|
+
ItemFC: (props: ListProps) => JSX.Element;
|
|
287
|
+
EditFC: (props: ListProps) => JSX.Element;
|
|
288
|
+
};
|
|
272
289
|
type SubmitType = {
|
|
273
290
|
Item: SubmitItem;
|
|
274
291
|
ItemFC: (props: SubmitProps) => JSX.Element;
|
|
@@ -368,6 +385,9 @@ type FieldProps = BaseItemProps & {
|
|
|
368
385
|
type GroupProps = BaseItemProps & {
|
|
369
386
|
item: GroupItem;
|
|
370
387
|
};
|
|
388
|
+
type ListProps = BaseItemProps & {
|
|
389
|
+
item: ListItem;
|
|
390
|
+
};
|
|
371
391
|
type HTMLProps = BaseItemProps & {
|
|
372
392
|
item: HTMLItem;
|
|
373
393
|
};
|
|
@@ -410,7 +430,11 @@ type AutocompleteProps = FieldProps & {
|
|
|
410
430
|
type PhoneProps = FieldProps & {
|
|
411
431
|
item: PhoneSubtype;
|
|
412
432
|
};
|
|
413
|
-
type
|
|
433
|
+
type ListItemProps = ItemProps & {
|
|
434
|
+
index: number;
|
|
435
|
+
parentItem: ListItem;
|
|
436
|
+
};
|
|
437
|
+
type ItemProps = BaseItemProps | GroupProps | ListProps | HiddenProps | HTMLProps | SubmitProps | FieldProps | SelectProps | RadioProps | CheckboxProps | TextProps | EmailProps | NumberProps | DateProps | BooleanProps | AutocompleteProps | PhoneProps;
|
|
414
438
|
declare function isGroup(item: AnyItem): item is GroupItem;
|
|
415
439
|
declare function isHidden(item: AnyItem): item is HiddenItem;
|
|
416
440
|
declare function isField(item: AnyItem): item is FieldItem;
|
|
@@ -429,6 +453,8 @@ declare function isAutocomplete(item: AnyItem): item is AutocompleteSubtype;
|
|
|
429
453
|
declare function isPhone(item: AnyItem): item is PhoneSubtype;
|
|
430
454
|
declare function isOption(item: AnyItem): item is OptionSubtype;
|
|
431
455
|
declare function isNamed(item: AnyItem): item is NamedItem;
|
|
456
|
+
declare function isList(item: AnyItem): item is ListItem;
|
|
457
|
+
declare function isListItem(item: AnyItem): item is InListItem;
|
|
432
458
|
declare function hasFiles(items: AnyItem[], allItems?: AnyItem[]): boolean;
|
|
433
459
|
declare function itemsCloneDeep(items: AnyItem[]): AnyItem[];
|
|
434
460
|
declare function itemCloneDeep(item: AnyItem): AnyItem;
|
|
@@ -489,6 +515,10 @@ type BuilderUseOptions = {
|
|
|
489
515
|
submitColors?: string[];
|
|
490
516
|
fileTypes?: Accept;
|
|
491
517
|
};
|
|
518
|
+
type ModalProps = {
|
|
519
|
+
item: AnyItem;
|
|
520
|
+
inList?: boolean;
|
|
521
|
+
};
|
|
492
522
|
type BuilderProps = {
|
|
493
523
|
AllowedItems?: AllowedItems;
|
|
494
524
|
AdditionalItems?: AllowedItems;
|
|
@@ -532,4 +562,4 @@ declare const RenderedFlatObject: (items: AnyItem[], files?: Files, allItems?: A
|
|
|
532
562
|
declare const RenderedArray: (items: AnyItem[], files?: Files, allItems?: AnyItem[]) => {} | [];
|
|
533
563
|
declare const RenderedFlatArray: (items: AnyItem[], files?: Files, allItems?: AnyItem[]) => object[];
|
|
534
564
|
|
|
535
|
-
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, Files, 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, hasFiles, 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, itemCloneDeep, itemsCloneDeep, validateNameChange };
|
|
565
|
+
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, Files, FilterType, GetNamedItem as GetItem, GroupItem, GroupProps, GroupType, GtFilter, GteFilter, HTMLItem, HTMLProps, HTMLType, HiddenItem, HiddenProps, HiddenType, InFilter, InListItem, ItemProps, ItemType, ListItem, ListItemProps, ListProps, ListType, 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, hasFiles, isAndFilter, isAutocomplete, isBoolean, isCheckbox, isComparisonFilter, isDate, isEmail, isEqFilter, isField, isFieldFilter, isFile, isGroup, isGtFilter, isGteFilter, isHidden, isHtml, isInFilter, isList, isListItem, isLtFilter, isLteFilter, isNamed, isNotFilter, isNumber, isOption, isOrFilter, isPhone, isRadio, isSelect, isSubmit, isText, itemCloneDeep, itemsCloneDeep, validateNameChange };
|
package/package.json
CHANGED