@cfinnestad/react-form-builder 0.2.53 → 0.3.1

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.
@@ -33,6 +33,7 @@ export type BuilderUseOptions = {
33
33
  [key: string]: (props: SubmitButtonProps) => JSX.Element;
34
34
  };
35
35
  muiTheme?: Theme;
36
+ mode: string;
36
37
  custom?: {
37
38
  [key: string]: any;
38
39
  };
@@ -0,0 +1,14 @@
1
+ import React, { Dispatch, SetStateAction } from "react";
2
+ import { AnyItem } from "../Items";
3
+ import { RenderOptions } from "../Render";
4
+ export type EditorProps = {
5
+ Data: {
6
+ [key: string]: any;
7
+ };
8
+ Items: AnyItem[];
9
+ SetItems?: Dispatch<SetStateAction<AnyItem[]>>;
10
+ Options: RenderOptions;
11
+ };
12
+ declare const Editor: ({ Data, Items, SetItems, Options }: EditorProps) => React.JSX.Element;
13
+ export declare const setDefaults: (items: AnyItem[], data: object) => AnyItem[];
14
+ export default Editor;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import type { StoryObj } from '@storybook/react';
3
+ import { TextSubtype } from "../Items";
4
+ declare const meta: {
5
+ title: string;
6
+ component: ({ Data, Items, SetItems, Options }: import("./Editor").EditorProps) => import("react").JSX.Element;
7
+ tags: string[];
8
+ argTypes: {
9
+ Items: TextSubtype[];
10
+ };
11
+ };
12
+ export default meta;
13
+ type Story = StoryObj<typeof meta>;
14
+ export declare const Primary: Story;
15
+ export declare const EditorWithoutData: Story;
@@ -0,0 +1 @@
1
+ export { default } from './Editor';
@@ -20,7 +20,7 @@ export type Options = {
20
20
  SetItem: Dispatch<SetStateAction<AnyItem>>;
21
21
  setItems: Dispatch<SetStateAction<AnyItem[]>>;
22
22
  setModal?: Dispatch<SetStateAction<boolean>>;
23
- IsBuild: boolean;
23
+ Mode?: String;
24
24
  getError: (error: string, item: AnyItem) => string | undefined;
25
25
  searchableOptions?: {
26
26
  [key: string]: (input?: string) => Promise<Option[]> | Option[];
@@ -111,6 +111,8 @@ export type HiddenItem = NamedItem & {
111
111
  type: 'Hidden';
112
112
  deprecated?: boolean;
113
113
  value: string;
114
+ editable?: boolean;
115
+ backend_only?: boolean;
114
116
  };
115
117
  export type HTMLItem = BaseItem & {
116
118
  type: 'HTML';
@@ -133,6 +135,7 @@ export type FieldItem = NamedItem & {
133
135
  label?: string;
134
136
  deprecated?: boolean;
135
137
  backend_only?: boolean;
138
+ editable?: boolean;
136
139
  helperText?: string;
137
140
  subtype: string;
138
141
  custom?: {
@@ -144,7 +147,6 @@ export type FieldItem = NamedItem & {
144
147
  export type OptionSubtype = FieldItem & {
145
148
  label: string;
146
149
  value?: string | string[];
147
- editable?: boolean;
148
150
  searchableOptionsName?: string;
149
151
  options: Option[];
150
152
  };
@@ -181,7 +183,6 @@ export type TextSubtype = FieldItem & {
181
183
  maxRows?: number;
182
184
  minLength?: number;
183
185
  maxLength?: number;
184
- editable?: boolean;
185
186
  };
186
187
  export type EmailSubtype = FieldItem & {
187
188
  label: string;
@@ -223,7 +224,6 @@ export type BooleanSubtype = FieldItem & {
223
224
  subtype: 'Boolean';
224
225
  description: string;
225
226
  value?: boolean;
226
- editable?: boolean;
227
227
  };
228
228
  export type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
229
229
  export type ItemType = {
@@ -25,6 +25,7 @@ export type RenderOptions = {
25
25
  custom?: {
26
26
  [key: string]: any;
27
27
  };
28
+ mode?: "build" | "edit" | "render";
28
29
  };
29
30
  declare const Render: ({ Items, SetItems, Options }: RenderProps) => JSX.Element;
30
31
  export declare const RenderedObject: (items: AnyItem[]) => {};
package/dist/index.d.ts CHANGED
@@ -33,7 +33,7 @@ type Options = {
33
33
  SetItem: Dispatch<SetStateAction<AnyItem>>;
34
34
  setItems: Dispatch<SetStateAction<AnyItem[]>>;
35
35
  setModal?: Dispatch<SetStateAction<boolean>>;
36
- IsBuild: boolean;
36
+ Mode?: String;
37
37
  getError: (error: string, item: AnyItem) => string | undefined;
38
38
  searchableOptions?: {
39
39
  [key: string]: (input?: string) => Promise<Option[]> | Option[];
@@ -124,6 +124,8 @@ type HiddenItem = NamedItem & {
124
124
  type: 'Hidden';
125
125
  deprecated?: boolean;
126
126
  value: string;
127
+ editable?: boolean;
128
+ backend_only?: boolean;
127
129
  };
128
130
  type HTMLItem = BaseItem & {
129
131
  type: 'HTML';
@@ -146,6 +148,7 @@ type FieldItem = NamedItem & {
146
148
  label?: string;
147
149
  deprecated?: boolean;
148
150
  backend_only?: boolean;
151
+ editable?: boolean;
149
152
  helperText?: string;
150
153
  subtype: string;
151
154
  custom?: {
@@ -157,7 +160,6 @@ type FieldItem = NamedItem & {
157
160
  type OptionSubtype = FieldItem & {
158
161
  label: string;
159
162
  value?: string | string[];
160
- editable?: boolean;
161
163
  searchableOptionsName?: string;
162
164
  options: Option[];
163
165
  };
@@ -194,7 +196,6 @@ type TextSubtype = FieldItem & {
194
196
  maxRows?: number;
195
197
  minLength?: number;
196
198
  maxLength?: number;
197
- editable?: boolean;
198
199
  };
199
200
  type EmailSubtype = FieldItem & {
200
201
  label: string;
@@ -236,7 +237,6 @@ type BooleanSubtype = FieldItem & {
236
237
  subtype: 'Boolean';
237
238
  description: string;
238
239
  value?: boolean;
239
- editable?: boolean;
240
240
  };
241
241
  type AnyItem = BaseItem | FieldItem | GroupItem | HTMLItem | HiddenItem | SelectSubtype | RadioSubtype | CheckboxSubtype | TextSubtype | EmailSubtype | NumberSubtype | DateSubtype | BooleanSubtype | PhoneSubtype | AutocompleteSubtype;
242
242
  type ItemType = {
@@ -454,6 +454,7 @@ type BuilderUseOptions = {
454
454
  [key: string]: (props: SubmitButtonProps) => JSX.Element;
455
455
  };
456
456
  muiTheme?: Theme;
457
+ mode: string;
457
458
  custom?: {
458
459
  [key: string]: any;
459
460
  };
@@ -491,6 +492,7 @@ type RenderOptions = {
491
492
  custom?: {
492
493
  [key: string]: any;
493
494
  };
495
+ mode?: "build" | "edit" | "render";
494
496
  };
495
497
  declare const Render: ({ Items, SetItems, Options }: RenderProps) => JSX.Element;
496
498
  declare const RenderedObject: (items: AnyItem[]) => {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfinnestad/react-form-builder",
3
- "version": "0.2.53",
3
+ "version": "0.3.1",
4
4
  "description": "FormBuilder and FormRender Component library for building and gathering custom form data",
5
5
  "scripts": {
6
6
  "rollup": "rollup -c",