@cfinnestad/react-form-builder 1.0.31 → 1.0.33

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.
@@ -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;
@@ -19,3 +19,4 @@ declare const meta: {
19
19
  export default meta;
20
20
  type Story = StoryObj<typeof meta>;
21
21
  export declare const Primary: Story;
22
+ export declare const Empty: Story;
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { ItemProps } from "./Items";
3
3
  type EditModalProps = ItemProps & {
4
4
  showModal: boolean;
5
+ inList: boolean;
5
6
  };
6
7
  declare const EditModal: (itemProps: EditModalProps) => React.JSX.Element;
7
8
  export default EditModal;
@@ -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<boolean>>;
23
+ setModal?: Dispatch<SetStateAction<ModalProps | undefined>>;
24
24
  Mode?: string;
25
25
  getError: (error: string, item: any) => string | undefined;
26
26
  searchableOptions?: {
@@ -87,7 +87,7 @@ export type ComparisonFilter = FilterType & {
87
87
  comparison: 'and' | 'or';
88
88
  filters: FilterType[];
89
89
  };
90
- export declare const isComparisonFilter: (filter: FilterType) => filter is AndFilter;
90
+ export declare const isComparisonFilter: (filter: FilterType) => filter is ComparisonFilter;
91
91
  export type AndFilter = ComparisonFilter & {
92
92
  comparison: 'and';
93
93
  };
@@ -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
+ listItems?: 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 ItemProps = BaseItemProps | GroupProps | HiddenProps | HTMLProps | SubmitProps | FieldProps | SelectProps | RadioProps | CheckboxProps | TextProps | EmailProps | NumberProps | DateProps | BooleanProps | AutocompleteProps | PhoneProps;
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,7 @@ 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
- export declare function itemsCloneDeep(items: AnyItem[]): AnyItem[];
420
- export declare function itemCloneDeep(item: AnyItem): AnyItem;
445
+ export declare function itemCloneDeep<T>(items: T): T;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { ListProps } from "../Items";
3
+ declare const ItemList: ({ item, items, options, activeItem, setActiveItem, errorHandler }: ListProps) => React.JSX.Element;
4
+ export default ItemList;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { ListProps } from "../Items";
3
+ declare const ItemListEdit: ({ item, items, options, groupId, errorHandler }: ListProps) => React.JSX.Element;
4
+ export default ItemListEdit;
@@ -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;
@@ -0,0 +1,2 @@
1
+ export { default } from './ItemList';
2
+ export { default as ItemListEdit } from './ItemListEdit';
@@ -1,3 +1,8 @@
1
1
  import { AnyItem } from "./Items";
2
+ type ChangedItemIds = {
3
+ oldId: string;
4
+ newId: string;
5
+ };
6
+ export declare const updateChildItemsInItems: (items: AnyItem[], changedItemIds: ChangedItemIds[], prefix: string) => void;
2
7
  declare const UpdateItemInItems: (item: AnyItem, items: AnyItem[], prefix?: string) => void;
3
8
  export default UpdateItemInItems;