react-form-builder-more-flexibility 1.0.0
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/LICENSE +7 -0
- package/README.md +248 -0
- package/dist/1.app.js +1 -0
- package/dist/app.css +38 -0
- package/dist/app.js +71 -0
- package/lib/ItemTypes.js +11 -0
- package/lib/UUID.js +71 -0
- package/lib/dynamic-option-list.js +207 -0
- package/lib/form-dynamic-edit.js +74 -0
- package/lib/form-elements/component-drag-handle.js +114 -0
- package/lib/form-elements/component-drag-layer.js +85 -0
- package/lib/form-elements/component-drag-preview.js +74 -0
- package/lib/form-elements/component-header.js +35 -0
- package/lib/form-elements/component-label.js +31 -0
- package/lib/form-elements/custom-element.js +102 -0
- package/lib/form-elements/date-picker.js +220 -0
- package/lib/form-elements/header-bar.js +68 -0
- package/lib/form-elements/index.js +1450 -0
- package/lib/form-elements/myxss.js +33 -0
- package/lib/form-elements/star-rating.js +364 -0
- package/lib/form-elements-edit.js +737 -0
- package/lib/form-place-holder.js +70 -0
- package/lib/form-validator.js +121 -0
- package/lib/form.js +648 -0
- package/lib/functions/index.js +65 -0
- package/lib/index.js +170 -0
- package/lib/language-provider/IntlMessages.js +22 -0
- package/lib/language-provider/entries/en-us.js +23 -0
- package/lib/language-provider/entries/vi-vn.js +23 -0
- package/lib/language-provider/index.js +31 -0
- package/lib/language-provider/locales/en-us.json +108 -0
- package/lib/language-provider/locales/vi-vn.json +87 -0
- package/lib/multi-column/MultiColumnRow.js +175 -0
- package/lib/multi-column/dustbin.js +179 -0
- package/lib/multi-column/grip.js +60 -0
- package/lib/multi-column/index.js +25 -0
- package/lib/preview.js +455 -0
- package/lib/sortable-element.js +198 -0
- package/lib/sortable-form-elements.js +73 -0
- package/lib/stores/registry.js +50 -0
- package/lib/stores/requests.js +36 -0
- package/lib/stores/store.js +153 -0
- package/lib/toolbar-draggable-item.js +77 -0
- package/lib/toolbar-group-item.js +50 -0
- package/lib/toolbar.js +710 -0
- package/package.json +116 -0
- package/types/index.d.ts +176 -0
package/package.json
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-form-builder-more-flexibility",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A complete form builder for react.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ljorgens/react-form-builder.git"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"lib",
|
|
14
|
+
"dist",
|
|
15
|
+
"types"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react",
|
|
19
|
+
"react-component",
|
|
20
|
+
"form",
|
|
21
|
+
"builder",
|
|
22
|
+
"ui",
|
|
23
|
+
"drag",
|
|
24
|
+
"drop"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=12.0.0"
|
|
28
|
+
},
|
|
29
|
+
"author": "Lee Jorgensen",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"beedle": "^0.8.1",
|
|
32
|
+
"classnames": "^2.2.6",
|
|
33
|
+
"date-fns": "^2.16.1",
|
|
34
|
+
"draft-js": "^0.11.7",
|
|
35
|
+
"draftjs-to-html": "^0.8.4",
|
|
36
|
+
"es6-promise": "^4.2.8",
|
|
37
|
+
"fbemitter": "^3.0.0",
|
|
38
|
+
"file-saver": "^2.0.5",
|
|
39
|
+
"immutability-helper": "^3.1.1",
|
|
40
|
+
"isomorphic-fetch": "^3.0.0",
|
|
41
|
+
"prop-types": "^15.7.2",
|
|
42
|
+
"react-bootstrap-slider": "^2.2.3",
|
|
43
|
+
"react-datepicker": "^3.4.1",
|
|
44
|
+
"react-dnd": "^11.1.3",
|
|
45
|
+
"react-dnd-html5-backend": "^11.1.3",
|
|
46
|
+
"react-draft-wysiwyg": "^1.14.7",
|
|
47
|
+
"react-intl": "^5.24.3",
|
|
48
|
+
"react-select": "^3.2.0",
|
|
49
|
+
"react-signature-canvas": "^1.0.3",
|
|
50
|
+
"react-textarea-autosize": "^7.1.2",
|
|
51
|
+
"xss": "^1.0.8"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"react": ">=16.8.6",
|
|
55
|
+
"react-dom": ">=16.8.6"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@babel/cli": "^7.12.10",
|
|
59
|
+
"@babel/core": "^7.12.10",
|
|
60
|
+
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
|
61
|
+
"@babel/plugin-proposal-json-strings": "^7.12.1",
|
|
62
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
63
|
+
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
|
64
|
+
"@babel/plugin-transform-runtime": "^7.17.10",
|
|
65
|
+
"@babel/preset-env": "^7.12.11",
|
|
66
|
+
"@babel/preset-react": "^7.14.5",
|
|
67
|
+
"@babel/runtime-corejs2": "^7.12.5",
|
|
68
|
+
"add": "^2.0.6",
|
|
69
|
+
"babel-eslint": "^10.1.0",
|
|
70
|
+
"babel-loader": "^8.2.2",
|
|
71
|
+
"copyfiles": "^2.4.1",
|
|
72
|
+
"css-loader": "^3.6.0",
|
|
73
|
+
"ejs": "^2.7.4",
|
|
74
|
+
"eslint": "^6.8.0",
|
|
75
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
76
|
+
"eslint-plugin-import": "^2.22.1",
|
|
77
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
78
|
+
"eslint-plugin-react": "^7.22.0",
|
|
79
|
+
"express": "^4.17.1",
|
|
80
|
+
"multer": "^1.4.2",
|
|
81
|
+
"node-sass": "^7.0.1",
|
|
82
|
+
"react": "^16.14.0",
|
|
83
|
+
"react-dom": "^16.14.0",
|
|
84
|
+
"rimraf": "^3.0.2",
|
|
85
|
+
"sass": "^1.52.3",
|
|
86
|
+
"sass-loader": "^10.0.0",
|
|
87
|
+
"style-loader": "^1.3.0",
|
|
88
|
+
"webpack": "^4.46.0",
|
|
89
|
+
"webpack-cli": "^3.3.12",
|
|
90
|
+
"webpack-dev-server": "^3.11.2"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "webpack --mode production --config webpack.production.config.js",
|
|
94
|
+
"build:dev": "webpack --mode development",
|
|
95
|
+
"build:umd": "webpack --mode development --config webpack.production.config.js",
|
|
96
|
+
"build:style": "node-sass ./scss/application.scss dist/app.css --output-style compressed",
|
|
97
|
+
"build:lib": "npm run transpile && npm run build:style",
|
|
98
|
+
"build:dist": "npm run build && npm run copy:dist",
|
|
99
|
+
"clean": "rimraf dist",
|
|
100
|
+
"copy:dist": "copyfiles -f \"./dist/*\" \"./public/dist\"",
|
|
101
|
+
"prepublishOnly": "npm run clean && npm run build:lib && npm run build",
|
|
102
|
+
"watch": "webpack --watch",
|
|
103
|
+
"start": "webpack-dev-server --hot --mode development",
|
|
104
|
+
"serve:api": "node server/index.js",
|
|
105
|
+
"pretranspile": "rimraf lib",
|
|
106
|
+
"transpile": "babel --out-dir lib src --copy-files"
|
|
107
|
+
},
|
|
108
|
+
"bugs": {
|
|
109
|
+
"url": "https://github.com/ljorgens/react-form-builder/issues"
|
|
110
|
+
},
|
|
111
|
+
"homepage": "https://github.com/ljorgens/react-form-builder#readme",
|
|
112
|
+
"directories": {
|
|
113
|
+
"doc": "docs",
|
|
114
|
+
"example": "examples"
|
|
115
|
+
}
|
|
116
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
type BaseElement = {
|
|
5
|
+
id: string;
|
|
6
|
+
element:
|
|
7
|
+
| "Header Text"
|
|
8
|
+
| "Label"
|
|
9
|
+
| "Paragraph"
|
|
10
|
+
| "Line Break"
|
|
11
|
+
| "Dropdown"
|
|
12
|
+
| "Tags"
|
|
13
|
+
| "Checkboxes"
|
|
14
|
+
| "Multiple Choice"
|
|
15
|
+
| "Text Input"
|
|
16
|
+
| "Number Input"
|
|
17
|
+
| "Multi-line Input"
|
|
18
|
+
| "Two Column Row"
|
|
19
|
+
| "Three Column Row"
|
|
20
|
+
| "Multi Column Row"
|
|
21
|
+
| "Image"
|
|
22
|
+
| "Rating"
|
|
23
|
+
| "Date"
|
|
24
|
+
| "Signature"
|
|
25
|
+
| "Web site"
|
|
26
|
+
| "File Attachment"
|
|
27
|
+
| "Range"
|
|
28
|
+
| "Camera";
|
|
29
|
+
showDescription?: boolean;
|
|
30
|
+
required: boolean;
|
|
31
|
+
canHaveAlternateForm: boolean;
|
|
32
|
+
canHaveDisplayHorizontal: boolean;
|
|
33
|
+
canHaveOptionCorrect: boolean;
|
|
34
|
+
canHaveOptionValue: boolean;
|
|
35
|
+
canHavePageBreakBefore: boolean;
|
|
36
|
+
canPopulateFromApi: boolean;
|
|
37
|
+
text: string;
|
|
38
|
+
};
|
|
39
|
+
export type StaticElement = {
|
|
40
|
+
bold: boolean;
|
|
41
|
+
content: string;
|
|
42
|
+
inline?: boolean;
|
|
43
|
+
italic: boolean;
|
|
44
|
+
static: true;
|
|
45
|
+
};
|
|
46
|
+
export type FormBuilderInput = {
|
|
47
|
+
canHaveAnswer?: true;
|
|
48
|
+
field_name: string;
|
|
49
|
+
label: string;
|
|
50
|
+
};
|
|
51
|
+
export type Option = {
|
|
52
|
+
key: string;
|
|
53
|
+
label?: string;
|
|
54
|
+
text: string;
|
|
55
|
+
value: string;
|
|
56
|
+
};
|
|
57
|
+
export type SelectableElement = {
|
|
58
|
+
options: Option[];
|
|
59
|
+
} & FormBuilderInput;
|
|
60
|
+
export type ImageElement = {
|
|
61
|
+
field_name: string;
|
|
62
|
+
src: string;
|
|
63
|
+
};
|
|
64
|
+
export type DateElement = {
|
|
65
|
+
dateFormat: string;
|
|
66
|
+
defaultToday: boolean;
|
|
67
|
+
readOnly: boolean;
|
|
68
|
+
showTimeSelect: boolean;
|
|
69
|
+
showTimeSelectOnly: boolean;
|
|
70
|
+
showTimeInput: boolean;
|
|
71
|
+
timeFormat: string;
|
|
72
|
+
} & FormBuilderInput;
|
|
73
|
+
export type RangeElement = {
|
|
74
|
+
max_label: string;
|
|
75
|
+
max_value: number;
|
|
76
|
+
min_label: string;
|
|
77
|
+
min_value: number;
|
|
78
|
+
} & FormBuilderInput;
|
|
79
|
+
export type FileElement = {
|
|
80
|
+
_href: string;
|
|
81
|
+
file_path: string;
|
|
82
|
+
field_name: string;
|
|
83
|
+
} & StaticElement;
|
|
84
|
+
export type WebsiteElement = {
|
|
85
|
+
href: string;
|
|
86
|
+
} & StaticElement;
|
|
87
|
+
export type SignatureElement = {
|
|
88
|
+
readOnly: boolean;
|
|
89
|
+
} & FormBuilderInput;
|
|
90
|
+
export type TaskData = BaseElement &
|
|
91
|
+
(| StaticElement
|
|
92
|
+
| FormBuilderInput
|
|
93
|
+
| SelectableElement
|
|
94
|
+
| ImageElement
|
|
95
|
+
| DateElement
|
|
96
|
+
| RangeElement
|
|
97
|
+
| WebsiteElement
|
|
98
|
+
| FileElement
|
|
99
|
+
| SignatureElement
|
|
100
|
+
// eslint-disable-next-line no-use-before-define
|
|
101
|
+
| FormBuilderLayout
|
|
102
|
+
);
|
|
103
|
+
export type FormBuilderLayout = {
|
|
104
|
+
isContainer: true;
|
|
105
|
+
childItems: TaskData[];
|
|
106
|
+
field_name: string;
|
|
107
|
+
};
|
|
108
|
+
export type FormBuilderPostData = {
|
|
109
|
+
task_data: TaskData[];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type ToolbarItem = {
|
|
113
|
+
key: string;
|
|
114
|
+
name: string;
|
|
115
|
+
static: boolean;
|
|
116
|
+
icon: string;
|
|
117
|
+
content: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export interface FormBuilderProps {
|
|
121
|
+
toolbarItems?: ToolbarItem[];
|
|
122
|
+
files?: any[];
|
|
123
|
+
url?: string;
|
|
124
|
+
showCorrectColumn?: boolean;
|
|
125
|
+
show_description?: boolean;
|
|
126
|
+
onLoad?: () => Promise<FormBuilderPostData>;
|
|
127
|
+
onPost?: (data: FormBuilderPostData) => void;
|
|
128
|
+
saveUrl?: string;
|
|
129
|
+
saveAlways?: boolean;
|
|
130
|
+
editMode?: boolean;
|
|
131
|
+
renderEditForm?: (props: BaseElement) => React.ReactNode;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export class ReactFormBuilder extends React.Component<FormBuilderProps> {}
|
|
135
|
+
|
|
136
|
+
export interface FormGeneratorOnSubmitParams {
|
|
137
|
+
name: string;
|
|
138
|
+
custom_name: string;
|
|
139
|
+
value: string | string[];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface FormGeneratorProps {
|
|
143
|
+
form_action: string;
|
|
144
|
+
form_method: string;
|
|
145
|
+
action_name?: string;
|
|
146
|
+
onSubmit?: (info: FormGeneratorOnSubmitParams[]) => void;
|
|
147
|
+
data: any[];
|
|
148
|
+
back_action?: string;
|
|
149
|
+
back_name?: string;
|
|
150
|
+
task_id?: number;
|
|
151
|
+
answer_data?: any[];
|
|
152
|
+
authenticity_token?: string;
|
|
153
|
+
hide_actions?: boolean;
|
|
154
|
+
skip_validations?: boolean;
|
|
155
|
+
display_short?: boolean;
|
|
156
|
+
read_only?: boolean;
|
|
157
|
+
// eslint-disable-next-line no-undef
|
|
158
|
+
variables?: Record<any, any>;
|
|
159
|
+
submitButton?: JSX.Element;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export class ReactFormGenerator extends React.Component<FormGeneratorProps> {}
|
|
163
|
+
|
|
164
|
+
export type ActionType = "load" | "updateOrder" | "delete";
|
|
165
|
+
|
|
166
|
+
export class ElementStore {
|
|
167
|
+
static dispatch: (type: ActionType, data: any) => void;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export class Registry {
|
|
171
|
+
static register: (name: string, component: React.ReactNode) => void;
|
|
172
|
+
|
|
173
|
+
static list: () => string[];
|
|
174
|
+
|
|
175
|
+
static get: (name: string) => React.ReactNode;
|
|
176
|
+
}
|