react-survey-builder 1.0.72 → 1.0.73
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/README.md +2 -0
- package/dist/app.css +1 -1
- package/dist/app.css.map +1 -1
- package/dist/bundle.js +628 -35
- package/dist/src_survey-elements-edit_jsx.bundle.js +2 -2
- package/lib/dynamic-option-list.js +140 -155
- package/lib/fieldset/FieldSet.js +118 -0
- package/lib/fieldset/index.js +2 -132
- package/lib/form-fields.js +41 -14
- package/lib/form-steps.js +793 -0
- package/lib/form.js +43 -15
- package/lib/index.js +130 -124
- package/lib/multi-column/MultiColumnRow.js +69 -81
- package/lib/multi-column/dustbin.js +52 -18
- package/lib/preview.js +378 -349
- package/lib/sortable-element.js +9 -0
- package/lib/sortable-form-elements.js +28 -2
- package/lib/step/Step.js +147 -0
- package/lib/step/index.js +2 -0
- package/lib/survey-elements/component-drag-layer.js +13 -8
- package/lib/survey-elements/component-error-message.js +1 -1
- package/lib/survey-elements/component-header.js +12 -11
- package/lib/survey-elements/custom-element.js +51 -62
- package/lib/survey-elements/header-bar.js +36 -55
- package/lib/survey-elements/index.js +372 -370
- package/lib/survey-elements/star-rating.js +232 -282
- package/lib/survey-elements-edit.js +659 -564
- package/lib/survey-place-holder.js +9 -33
- package/lib/survey-validator.js +45 -75
- package/lib/toolbar-draggable-item.js +10 -34
- package/lib/toolbar-group-item.js +1 -1
- package/lib/toolbar.js +578 -558
- package/lib/utils/objectUtils.js +139 -0
- package/package.json +6 -5
- package/types/index.d.ts +5 -0
package/lib/toolbar.js
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
-
function
|
3
|
-
function
|
4
|
-
function
|
5
|
-
function
|
6
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
7
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
8
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
9
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
10
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
13
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
14
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
15
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
16
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
12
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
17
17
|
import React from 'react';
|
18
18
|
import ToolbarItem from './toolbar-draggable-item';
|
19
19
|
import ToolbarGroupItem from './toolbar-group-item';
|
@@ -21,6 +21,303 @@ import store from './stores/store';
|
|
21
21
|
import { FaArrowsAltH, FaBars, FaCamera, FaCaretSquareDown, FaCheckSquare, FaColumns, FaEnvelope, FaFile, FaFont, FaHeading, FaLink, FaParagraph, FaPenSquare, FaPhone, FaPlus, FaRegCalendarAlt, FaRegDotCircle, FaRegImage, FaSlidersH, FaStar, FaTags, FaTextHeight } from 'react-icons/fa';
|
22
22
|
import { PiFileHtml } from 'react-icons/pi';
|
23
23
|
import ID from './UUID';
|
24
|
+
import { GrSteps } from 'react-icons/gr';
|
25
|
+
import { isListNotEmpty } from './utils/objectUtils';
|
26
|
+
var _defaultItems = [{
|
27
|
+
key: 'Header',
|
28
|
+
name: "Header Text",
|
29
|
+
icon: FaHeading,
|
30
|
+
"static": true,
|
31
|
+
content: "Text..."
|
32
|
+
}, {
|
33
|
+
key: 'Label',
|
34
|
+
name: "Label",
|
35
|
+
"static": true,
|
36
|
+
icon: FaFont,
|
37
|
+
content: "Text..."
|
38
|
+
}, {
|
39
|
+
key: 'Paragraph',
|
40
|
+
name: "Paragraph",
|
41
|
+
"static": true,
|
42
|
+
icon: FaParagraph,
|
43
|
+
content: "Text..."
|
44
|
+
}, {
|
45
|
+
key: 'ContentBody',
|
46
|
+
name: "Static Content",
|
47
|
+
"static": true,
|
48
|
+
icon: PiFileHtml,
|
49
|
+
content: "Text..."
|
50
|
+
}, {
|
51
|
+
key: 'LineBreak',
|
52
|
+
name: "Line Break",
|
53
|
+
"static": true,
|
54
|
+
icon: FaArrowsAltH
|
55
|
+
}, {
|
56
|
+
key: 'Dropdown',
|
57
|
+
name: "Dropdown",
|
58
|
+
icon: FaCaretSquareDown,
|
59
|
+
label: "Label",
|
60
|
+
fieldName: 'dropdown_',
|
61
|
+
canHaveHelp: true,
|
62
|
+
options: [],
|
63
|
+
placeholder: 'Select One',
|
64
|
+
canHaveLabelLocation: true,
|
65
|
+
answerType: 'ARRAY',
|
66
|
+
hideLabel: false
|
67
|
+
}, {
|
68
|
+
key: 'Tags',
|
69
|
+
name: "Tags",
|
70
|
+
icon: FaTags,
|
71
|
+
label: "Label",
|
72
|
+
fieldName: 'tags_',
|
73
|
+
canHaveHelp: true,
|
74
|
+
options: [],
|
75
|
+
placeholder: 'Select...',
|
76
|
+
canHaveLabelLocation: true,
|
77
|
+
answerType: 'ARRAY',
|
78
|
+
hideLabel: false
|
79
|
+
}, {
|
80
|
+
key: 'Checkboxes',
|
81
|
+
name: "Checkboxes",
|
82
|
+
icon: FaCheckSquare,
|
83
|
+
label: "Label",
|
84
|
+
fieldName: 'checkboxes_',
|
85
|
+
canHaveHelp: true,
|
86
|
+
options: [],
|
87
|
+
answerType: 'ARRAY',
|
88
|
+
hideLabel: false
|
89
|
+
}, {
|
90
|
+
key: 'Checkbox',
|
91
|
+
name: "Checkbox",
|
92
|
+
icon: FaCheckSquare,
|
93
|
+
label: "Label",
|
94
|
+
fieldName: 'checkbox_',
|
95
|
+
canHaveHelp: true,
|
96
|
+
boxLabel: 'Pick me',
|
97
|
+
answerType: 'BOOLEAN',
|
98
|
+
canHideLabel: true,
|
99
|
+
hideLabel: true
|
100
|
+
}, {
|
101
|
+
key: 'RadioButtons',
|
102
|
+
name: "Radio Buttons",
|
103
|
+
icon: FaRegDotCircle,
|
104
|
+
label: "Label",
|
105
|
+
fieldName: 'radiobuttons_',
|
106
|
+
canHaveHelp: true,
|
107
|
+
options: [],
|
108
|
+
answerType: 'STRING',
|
109
|
+
hideLabel: false
|
110
|
+
}, {
|
111
|
+
key: 'TextInput',
|
112
|
+
name: "Text Input",
|
113
|
+
label: "Label",
|
114
|
+
icon: FaFont,
|
115
|
+
fieldName: 'text_input_',
|
116
|
+
canHaveHelp: true,
|
117
|
+
placeholder: "Label",
|
118
|
+
canHaveLabelLocation: true,
|
119
|
+
answerType: 'STRING',
|
120
|
+
hideLabel: false
|
121
|
+
}, {
|
122
|
+
key: 'EmailInput',
|
123
|
+
name: "Email Input",
|
124
|
+
label: "Email Address",
|
125
|
+
icon: FaEnvelope,
|
126
|
+
fieldName: 'email_input_',
|
127
|
+
canHaveHelp: true,
|
128
|
+
placeholder: "Email Address",
|
129
|
+
canHaveLabelLocation: true,
|
130
|
+
answerType: 'STRING',
|
131
|
+
hideLabel: false
|
132
|
+
}, {
|
133
|
+
key: 'PhoneNumber',
|
134
|
+
name: "Phone Number",
|
135
|
+
label: "Phone Number",
|
136
|
+
icon: FaPhone,
|
137
|
+
fieldName: 'phone_input_',
|
138
|
+
canHaveHelp: true,
|
139
|
+
canHaveLabelLocation: true,
|
140
|
+
answerType: 'STRING',
|
141
|
+
hideLabel: false
|
142
|
+
}, {
|
143
|
+
key: 'DatePicker',
|
144
|
+
canDefaultToday: true,
|
145
|
+
canReadOnly: true,
|
146
|
+
dateFormat: 'MM/DD/YYYY',
|
147
|
+
name: "Date",
|
148
|
+
icon: FaRegCalendarAlt,
|
149
|
+
label: "Label",
|
150
|
+
fieldName: 'date_picker_',
|
151
|
+
canHaveHelp: true,
|
152
|
+
canHaveLabelLocation: true,
|
153
|
+
answerType: 'STRING',
|
154
|
+
hideLabel: false
|
155
|
+
}, {
|
156
|
+
key: 'TextArea',
|
157
|
+
name: "Multi-line Input",
|
158
|
+
label: "Label",
|
159
|
+
icon: FaTextHeight,
|
160
|
+
fieldName: 'text_area_',
|
161
|
+
canHaveHelp: true,
|
162
|
+
canHaveLabelLocation: true,
|
163
|
+
answerType: 'STRING',
|
164
|
+
hideLabel: false
|
165
|
+
}, {
|
166
|
+
key: 'NumberInput',
|
167
|
+
name: "Numerical Input",
|
168
|
+
label: "Label",
|
169
|
+
icon: FaPlus,
|
170
|
+
fieldName: 'number_input_',
|
171
|
+
canHaveHelp: true,
|
172
|
+
step: 1,
|
173
|
+
minValue: 0,
|
174
|
+
maxValue: 5,
|
175
|
+
canHaveLabelLocation: true,
|
176
|
+
answerType: 'NUMBER',
|
177
|
+
hideLabel: false
|
178
|
+
}, {
|
179
|
+
key: 'Rating',
|
180
|
+
name: "Rating",
|
181
|
+
label: "Label",
|
182
|
+
icon: FaStar,
|
183
|
+
fieldName: 'rating_',
|
184
|
+
canHaveHelp: true,
|
185
|
+
answerType: 'NUMBER',
|
186
|
+
hideLabel: false
|
187
|
+
}, {
|
188
|
+
key: 'Range',
|
189
|
+
name: "Range",
|
190
|
+
icon: FaSlidersH,
|
191
|
+
label: "Label",
|
192
|
+
fieldName: 'range_',
|
193
|
+
step: 1,
|
194
|
+
defaultValue: 3,
|
195
|
+
minValue: 1,
|
196
|
+
maxValue: 5,
|
197
|
+
minLabel: "Easy",
|
198
|
+
maxLabel: "Difficult",
|
199
|
+
canHaveHelp: true,
|
200
|
+
answerType: 'NUMBER',
|
201
|
+
hideLabel: false
|
202
|
+
}, {
|
203
|
+
key: 'Signature',
|
204
|
+
canReadOnly: true,
|
205
|
+
name: "Signature",
|
206
|
+
icon: FaPenSquare,
|
207
|
+
label: "Signature",
|
208
|
+
fieldName: 'signature_',
|
209
|
+
canHaveHelp: true,
|
210
|
+
answerType: 'IMAGE',
|
211
|
+
hideLabel: false
|
212
|
+
}, {
|
213
|
+
key: 'Camera',
|
214
|
+
name: "Camera",
|
215
|
+
icon: FaCamera,
|
216
|
+
label: "Label",
|
217
|
+
fieldName: 'camera_',
|
218
|
+
answerType: 'IMAGE',
|
219
|
+
hideLabel: false
|
220
|
+
}, {
|
221
|
+
key: 'FileUpload',
|
222
|
+
name: "File Upload",
|
223
|
+
icon: FaFile,
|
224
|
+
label: "Label",
|
225
|
+
fieldName: 'file_upload_',
|
226
|
+
answerType: 'FILE',
|
227
|
+
hideLabel: false
|
228
|
+
}, {
|
229
|
+
key: 'FieldSet',
|
230
|
+
name: "Fieldset",
|
231
|
+
label: "Fieldset",
|
232
|
+
icon: FaBars,
|
233
|
+
fieldName: 'fieldset-element',
|
234
|
+
"static": true,
|
235
|
+
isContainer: true
|
236
|
+
}, {
|
237
|
+
key: 'Image',
|
238
|
+
name: "Image",
|
239
|
+
label: '',
|
240
|
+
icon: FaRegImage,
|
241
|
+
fieldName: 'image_',
|
242
|
+
src: '',
|
243
|
+
"static": true
|
244
|
+
}, {
|
245
|
+
key: 'HyperLink',
|
246
|
+
name: "Hyperlink",
|
247
|
+
icon: FaLink,
|
248
|
+
content: "Website Link...",
|
249
|
+
href: 'http://www.example.com',
|
250
|
+
"static": true
|
251
|
+
}, {
|
252
|
+
key: 'Download',
|
253
|
+
name: "File Attachment",
|
254
|
+
icon: FaFile,
|
255
|
+
content: "File name...",
|
256
|
+
fieldName: 'download_',
|
257
|
+
filePath: '',
|
258
|
+
href: '',
|
259
|
+
"static": true
|
260
|
+
}, {
|
261
|
+
key: 'TwoColumnRow',
|
262
|
+
name: "Two Column Row",
|
263
|
+
label: '',
|
264
|
+
icon: FaColumns,
|
265
|
+
fieldName: 'two_col_row_',
|
266
|
+
"static": true,
|
267
|
+
isContainer: true
|
268
|
+
}, {
|
269
|
+
key: 'ThreeColumnRow',
|
270
|
+
name: "Three Columns Row",
|
271
|
+
label: '',
|
272
|
+
icon: FaColumns,
|
273
|
+
fieldName: 'three_col_row_',
|
274
|
+
"static": true,
|
275
|
+
isContainer: true
|
276
|
+
}, {
|
277
|
+
key: 'FourColumnRow',
|
278
|
+
element: 'MultiColumnRow',
|
279
|
+
name: "Four Columns Row",
|
280
|
+
label: '',
|
281
|
+
icon: FaColumns,
|
282
|
+
fieldName: 'four_col_row_',
|
283
|
+
colCount: 4,
|
284
|
+
className: 'col-md-3',
|
285
|
+
"static": true,
|
286
|
+
isContainer: true
|
287
|
+
}, {
|
288
|
+
key: 'FiveColumnRow',
|
289
|
+
element: 'MultiColumnRow',
|
290
|
+
name: "Five Columns Row",
|
291
|
+
label: '',
|
292
|
+
icon: FaColumns,
|
293
|
+
fieldName: 'five_col_row_',
|
294
|
+
colCount: 5,
|
295
|
+
className: 'col',
|
296
|
+
"static": true,
|
297
|
+
isContainer: true
|
298
|
+
}, {
|
299
|
+
key: 'SixColumnRow',
|
300
|
+
element: 'MultiColumnRow',
|
301
|
+
name: "Six Columns Row",
|
302
|
+
label: '',
|
303
|
+
icon: FaColumns,
|
304
|
+
fieldName: 'six_col_row_',
|
305
|
+
colCount: 6,
|
306
|
+
className: 'col-md-2',
|
307
|
+
"static": true,
|
308
|
+
isContainer: true
|
309
|
+
}, {
|
310
|
+
key: 'Step',
|
311
|
+
name: "Step",
|
312
|
+
label: "Step",
|
313
|
+
icon: GrSteps,
|
314
|
+
fieldName: 'step_',
|
315
|
+
"static": true,
|
316
|
+
conditional: false,
|
317
|
+
conditionalFieldName: '',
|
318
|
+
conditionalFieldValue: '',
|
319
|
+
isContainer: true
|
320
|
+
}];
|
24
321
|
var groupBy = function groupBy(list, keyGetter) {
|
25
322
|
var map = new Map();
|
26
323
|
list.forEach(function (item) {
|
@@ -34,16 +331,20 @@ var groupBy = function groupBy(list, keyGetter) {
|
|
34
331
|
});
|
35
332
|
return map;
|
36
333
|
};
|
37
|
-
var buildItems = function buildItems(
|
38
|
-
|
39
|
-
|
334
|
+
var buildItems = function buildItems() {
|
335
|
+
var dataItems = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
336
|
+
var defaultDataItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
337
|
+
var customItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
338
|
+
var allItems = [].concat(_toConsumableArray(defaultDataItems), _toConsumableArray(customItems));
|
339
|
+
if (!isListNotEmpty(dataItems)) {
|
340
|
+
return allItems;
|
40
341
|
}
|
41
|
-
return
|
42
|
-
var found =
|
342
|
+
return dataItems.map(function (x) {
|
343
|
+
var found = allItems.find(function (y) {
|
43
344
|
return x.element === y.element && y.key === x.key;
|
44
345
|
});
|
45
346
|
if (!found) {
|
46
|
-
found =
|
347
|
+
found = allItems.find(function (y) {
|
47
348
|
return (x.element || x.key) === (y.element || y.key);
|
48
349
|
});
|
49
350
|
}
|
@@ -57,8 +358,9 @@ var buildItems = function buildItems(items, defaultItems) {
|
|
57
358
|
return found || x;
|
58
359
|
});
|
59
360
|
};
|
60
|
-
var buildGroupItems = function buildGroupItems(
|
61
|
-
var
|
361
|
+
var buildGroupItems = function buildGroupItems() {
|
362
|
+
var allItems = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
363
|
+
var ungroupedItems = allItems.filter(function (x) {
|
62
364
|
return !x.groupName;
|
63
365
|
});
|
64
366
|
var gItems = allItems.filter(function (x) {
|
@@ -73,555 +375,273 @@ var buildGroupItems = function buildGroupItems(allItems) {
|
|
73
375
|
return self.indexOf(v) === i;
|
74
376
|
});
|
75
377
|
return {
|
76
|
-
|
378
|
+
ungroupedItems: ungroupedItems,
|
77
379
|
grouped: grouped,
|
78
380
|
groupKeys: groupKeys
|
79
381
|
};
|
80
382
|
};
|
81
|
-
var Toolbar =
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
383
|
+
var Toolbar = function Toolbar(_ref) {
|
384
|
+
var _ref$items = _ref.items,
|
385
|
+
items = _ref$items === void 0 ? [] : _ref$items,
|
386
|
+
_ref$customItems = _ref.customItems,
|
387
|
+
customItems = _ref$customItems === void 0 ? [] : _ref$customItems;
|
388
|
+
var _React$useState = React.useState(isListNotEmpty(items) ? _toConsumableArray(items) : []),
|
389
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
390
|
+
dataItems = _React$useState2[0],
|
391
|
+
setDataItems = _React$useState2[1];
|
392
|
+
var _defaultItemOptions = function _defaultItemOptions(element) {
|
393
|
+
switch (element) {
|
394
|
+
case 'Dropdown':
|
395
|
+
return [{
|
396
|
+
value: 'place_holder_option_1',
|
397
|
+
text: "Place holder option 1",
|
398
|
+
key: "dropdown_option_".concat(ID.uuid())
|
399
|
+
}, {
|
400
|
+
value: 'place_holder_option_2',
|
401
|
+
text: "Place holder option 2",
|
402
|
+
key: "dropdown_option_".concat(ID.uuid())
|
403
|
+
}, {
|
404
|
+
value: 'place_holder_option_3',
|
405
|
+
text: "Place holder option 3",
|
406
|
+
key: "dropdown_option_".concat(ID.uuid())
|
407
|
+
}];
|
408
|
+
case 'Tags':
|
409
|
+
return [{
|
410
|
+
value: 'place_holder_tag_1',
|
411
|
+
text: "Place holder option 1",
|
412
|
+
key: "tags_option_".concat(ID.uuid())
|
413
|
+
}, {
|
414
|
+
value: 'place_holder_tag_2',
|
415
|
+
text: "Place holder option 2",
|
416
|
+
key: "tags_option_".concat(ID.uuid())
|
417
|
+
}, {
|
418
|
+
value: 'place_holder_tag_3',
|
419
|
+
text: "Place holder option 3",
|
420
|
+
key: "tags_option_".concat(ID.uuid())
|
421
|
+
}];
|
422
|
+
case 'Checkboxes':
|
423
|
+
return [{
|
424
|
+
value: 'place_holder_option_1',
|
425
|
+
text: "Place holder option 1",
|
426
|
+
key: "checkboxes_option_".concat(ID.uuid())
|
427
|
+
}, {
|
428
|
+
value: 'place_holder_option_2',
|
429
|
+
text: "Place holder option 2",
|
430
|
+
key: "checkboxes_option_".concat(ID.uuid())
|
431
|
+
}, {
|
432
|
+
value: 'place_holder_option_3',
|
433
|
+
text: "Place holder option 3",
|
434
|
+
key: "checkboxes_option_".concat(ID.uuid())
|
435
|
+
}];
|
436
|
+
case 'RadioButtons':
|
437
|
+
return [{
|
438
|
+
value: 'place_holder_option_1',
|
439
|
+
text: "Place holder option 1",
|
440
|
+
key: "radiobuttons_option_".concat(ID.uuid())
|
441
|
+
}, {
|
442
|
+
value: 'place_holder_option_2',
|
443
|
+
text: "Place holder option 2",
|
444
|
+
key: "radiobuttons_option_".concat(ID.uuid())
|
445
|
+
}, {
|
446
|
+
value: 'place_holder_option_3',
|
447
|
+
text: "Place holder option 3",
|
448
|
+
key: "radiobuttons_option_".concat(ID.uuid())
|
449
|
+
}];
|
450
|
+
default:
|
451
|
+
return [];
|
452
|
+
}
|
453
|
+
};
|
454
|
+
var addCustomOptions = function addCustomOptions(item, elementOptions) {
|
455
|
+
if (item.type === 'custom') {
|
456
|
+
var customOptions = _objectSpread(_objectSpread({}, item), elementOptions);
|
457
|
+
customOptions.custom = true;
|
458
|
+
customOptions.component = item.component || null;
|
459
|
+
customOptions.customOptions = item.customOptions || [];
|
460
|
+
return customOptions;
|
461
|
+
}
|
462
|
+
return _objectSpread(_objectSpread({}, elementOptions), item);
|
463
|
+
};
|
464
|
+
var create = function create(item) {
|
465
|
+
var _item$static;
|
466
|
+
var element = item.element || item.key;
|
467
|
+
var elementOptions = addCustomOptions(item, {
|
468
|
+
id: ID.uuid(),
|
469
|
+
element: element,
|
470
|
+
text: item.name,
|
471
|
+
"static": (_item$static = item["static"]) !== null && _item$static !== void 0 ? _item$static : false
|
93
472
|
});
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
key: "componentDidMount",
|
104
|
-
value: function componentDidMount() {
|
105
|
-
var _this2 = this;
|
106
|
-
store.subscribe(function (state) {
|
107
|
-
return _this2.setState({
|
108
|
-
store: state
|
109
|
-
});
|
110
|
-
});
|
473
|
+
if (item.groupName) {
|
474
|
+
var _item$groupName;
|
475
|
+
elementOptions.groupName = (_item$groupName = item.groupName) !== null && _item$groupName !== void 0 ? _item$groupName : null;
|
476
|
+
}
|
477
|
+
if (!item["static"]) {
|
478
|
+
elementOptions.required = false;
|
479
|
+
}
|
480
|
+
if (item.isContainer) {
|
481
|
+
elementOptions.isContainer = true;
|
111
482
|
}
|
112
|
-
}, {
|
113
|
-
key: "_defaultItems",
|
114
|
-
value: function _defaultItems() {
|
115
|
-
return [{
|
116
|
-
key: 'Header',
|
117
|
-
name: "Header Text",
|
118
|
-
icon: FaHeading,
|
119
|
-
"static": true,
|
120
|
-
content: "Text..."
|
121
|
-
}, {
|
122
|
-
key: 'Label',
|
123
|
-
name: "Label",
|
124
|
-
"static": true,
|
125
|
-
icon: FaFont,
|
126
|
-
content: "Text..."
|
127
|
-
}, {
|
128
|
-
key: 'Paragraph',
|
129
|
-
name: "Paragraph",
|
130
|
-
"static": true,
|
131
|
-
icon: FaParagraph,
|
132
|
-
content: "Text..."
|
133
|
-
}, {
|
134
|
-
key: 'ContentBody',
|
135
|
-
name: "Static Content",
|
136
|
-
"static": true,
|
137
|
-
icon: PiFileHtml,
|
138
|
-
content: "Text..."
|
139
|
-
}, {
|
140
|
-
key: 'LineBreak',
|
141
|
-
name: "Line Break",
|
142
|
-
"static": true,
|
143
|
-
icon: FaArrowsAltH
|
144
|
-
}, {
|
145
|
-
key: 'Dropdown',
|
146
|
-
name: "Dropdown",
|
147
|
-
icon: FaCaretSquareDown,
|
148
|
-
label: "Label",
|
149
|
-
fieldName: 'dropdown_',
|
150
|
-
canHaveHelp: true,
|
151
|
-
options: [],
|
152
|
-
placeholder: 'Select One',
|
153
|
-
canHaveLabelLocation: true,
|
154
|
-
answerType: 'ARRAY'
|
155
|
-
}, {
|
156
|
-
key: 'Tags',
|
157
|
-
name: "Tags",
|
158
|
-
icon: FaTags,
|
159
|
-
label: "Label",
|
160
|
-
fieldName: 'tags_',
|
161
|
-
canHaveHelp: true,
|
162
|
-
options: [],
|
163
|
-
placeholder: 'Select...',
|
164
|
-
canHaveLabelLocation: true,
|
165
|
-
answerType: 'ARRAY'
|
166
|
-
}, {
|
167
|
-
key: 'Checkboxes',
|
168
|
-
name: "Checkboxes",
|
169
|
-
icon: FaCheckSquare,
|
170
|
-
label: "Label",
|
171
|
-
fieldName: 'checkboxes_',
|
172
|
-
canHaveHelp: true,
|
173
|
-
options: [],
|
174
|
-
answerType: 'ARRAY'
|
175
|
-
}, {
|
176
|
-
key: 'Checkbox',
|
177
|
-
name: "Checkbox",
|
178
|
-
icon: FaCheckSquare,
|
179
|
-
label: "Label",
|
180
|
-
fieldName: 'checkbox_',
|
181
|
-
canHaveHelp: true,
|
182
|
-
boxLabel: 'Pick me',
|
183
|
-
answerType: 'BOOLEAN',
|
184
|
-
canHideLabel: true,
|
185
|
-
hideLabel: true
|
186
|
-
}, {
|
187
|
-
key: 'RadioButtons',
|
188
|
-
name: "Radio Buttons",
|
189
|
-
icon: FaRegDotCircle,
|
190
|
-
label: "Label",
|
191
|
-
fieldName: 'radiobuttons_',
|
192
|
-
canHaveHelp: true,
|
193
|
-
options: [],
|
194
|
-
answerType: 'STRING'
|
195
|
-
}, {
|
196
|
-
key: 'TextInput',
|
197
|
-
name: "Text Input",
|
198
|
-
label: "Label",
|
199
|
-
icon: FaFont,
|
200
|
-
fieldName: 'text_input_',
|
201
|
-
canHaveHelp: true,
|
202
|
-
placeholder: "Label",
|
203
|
-
canHaveLabelLocation: true,
|
204
|
-
answerType: 'STRING'
|
205
|
-
}, {
|
206
|
-
key: 'EmailInput',
|
207
|
-
name: "Email Input",
|
208
|
-
label: "Email Address",
|
209
|
-
icon: FaEnvelope,
|
210
|
-
fieldName: 'email_input_',
|
211
|
-
canHaveHelp: true,
|
212
|
-
placeholder: "Email Address",
|
213
|
-
canHaveLabelLocation: true,
|
214
|
-
answerType: 'STRING'
|
215
|
-
}, {
|
216
|
-
key: 'PhoneNumber',
|
217
|
-
name: "Phone Number",
|
218
|
-
label: "Phone Number",
|
219
|
-
icon: FaPhone,
|
220
|
-
fieldName: 'phone_input_',
|
221
|
-
canHaveHelp: true,
|
222
|
-
canHaveLabelLocation: true,
|
223
|
-
answerType: 'STRING'
|
224
|
-
}, {
|
225
|
-
key: 'DatePicker',
|
226
|
-
canDefaultToday: true,
|
227
|
-
canReadOnly: true,
|
228
|
-
dateFormat: 'MM/DD/YYYY',
|
229
|
-
name: "Date",
|
230
|
-
icon: FaRegCalendarAlt,
|
231
|
-
label: "Label",
|
232
|
-
fieldName: 'date_picker_',
|
233
|
-
canHaveHelp: true,
|
234
|
-
canHaveLabelLocation: true,
|
235
|
-
answerType: 'STRING'
|
236
|
-
}, {
|
237
|
-
key: 'TextArea',
|
238
|
-
name: "Multi-line Input",
|
239
|
-
label: "Label",
|
240
|
-
icon: FaTextHeight,
|
241
|
-
fieldName: 'text_area_',
|
242
|
-
canHaveHelp: true,
|
243
|
-
canHaveLabelLocation: true,
|
244
|
-
answerType: 'STRING'
|
245
|
-
}, {
|
246
|
-
key: 'NumberInput',
|
247
|
-
name: "Numerical Input",
|
248
|
-
label: "Label",
|
249
|
-
icon: FaPlus,
|
250
|
-
fieldName: 'number_input_',
|
251
|
-
canHaveHelp: true,
|
252
|
-
step: 1,
|
253
|
-
minValue: 0,
|
254
|
-
maxValue: 5,
|
255
|
-
canHaveLabelLocation: true,
|
256
|
-
answerType: 'NUMBER'
|
257
|
-
}, {
|
258
|
-
key: 'Rating',
|
259
|
-
name: "Rating",
|
260
|
-
label: "Label",
|
261
|
-
icon: FaStar,
|
262
|
-
fieldName: 'rating_',
|
263
|
-
canHaveHelp: true,
|
264
|
-
answerType: 'NUMBER'
|
265
|
-
}, {
|
266
|
-
key: 'Range',
|
267
|
-
name: "Range",
|
268
|
-
icon: FaSlidersH,
|
269
|
-
label: "Label",
|
270
|
-
fieldName: 'range_',
|
271
|
-
step: 1,
|
272
|
-
defaultValue: 3,
|
273
|
-
minValue: 1,
|
274
|
-
maxValue: 5,
|
275
|
-
minLabel: "Easy",
|
276
|
-
maxLabel: "Difficult",
|
277
|
-
canHaveHelp: true,
|
278
|
-
answerType: 'NUMBER'
|
279
|
-
}, {
|
280
|
-
key: 'Signature',
|
281
|
-
canReadOnly: true,
|
282
|
-
name: "Signature",
|
283
|
-
icon: FaPenSquare,
|
284
|
-
label: "Signature",
|
285
|
-
fieldName: 'signature_',
|
286
|
-
canHaveHelp: true,
|
287
|
-
answerType: 'IMAGE'
|
288
|
-
}, {
|
289
|
-
key: 'Camera',
|
290
|
-
name: "Camera",
|
291
|
-
icon: FaCamera,
|
292
|
-
label: "Label",
|
293
|
-
fieldName: 'camera_',
|
294
|
-
answerType: 'IMAGE'
|
295
|
-
}, {
|
296
|
-
key: 'FileUpload',
|
297
|
-
name: "File Upload",
|
298
|
-
icon: FaFile,
|
299
|
-
label: "Label",
|
300
|
-
fieldName: 'file_upload_',
|
301
|
-
answerType: 'FILE'
|
302
|
-
}, {
|
303
|
-
key: 'FieldSet',
|
304
|
-
name: "Fieldset",
|
305
|
-
label: "Fieldset",
|
306
|
-
icon: FaBars,
|
307
|
-
fieldName: 'fieldset-element',
|
308
|
-
"static": true
|
309
|
-
}, {
|
310
|
-
key: 'Image',
|
311
|
-
name: "Image",
|
312
|
-
label: '',
|
313
|
-
icon: FaRegImage,
|
314
|
-
fieldName: 'image_',
|
315
|
-
src: '',
|
316
|
-
"static": true
|
317
|
-
}, {
|
318
|
-
key: 'HyperLink',
|
319
|
-
name: "Hyperlink",
|
320
|
-
icon: FaLink,
|
321
|
-
content: "Website Link...",
|
322
|
-
href: 'http://www.example.com',
|
323
|
-
"static": true
|
324
|
-
}, {
|
325
|
-
key: 'Download',
|
326
|
-
name: "File Attachment",
|
327
|
-
icon: FaFile,
|
328
|
-
content: "File name...",
|
329
|
-
fieldName: 'download_',
|
330
|
-
filePath: '',
|
331
|
-
href: '',
|
332
|
-
"static": true
|
333
|
-
}, {
|
334
|
-
key: 'TwoColumnRow',
|
335
|
-
name: "Two Column Row",
|
336
|
-
label: '',
|
337
|
-
icon: FaColumns,
|
338
|
-
fieldName: 'two_col_row_',
|
339
|
-
"static": true
|
340
|
-
}, {
|
341
|
-
key: 'ThreeColumnRow',
|
342
|
-
name: "Three Columns Row",
|
343
|
-
label: '',
|
344
|
-
icon: FaColumns,
|
345
|
-
fieldName: 'three_col_row_',
|
346
|
-
"static": true
|
347
|
-
}, {
|
348
|
-
key: 'FourColumnRow',
|
349
|
-
element: 'MultiColumnRow',
|
350
|
-
name: "Four Columns Row",
|
351
|
-
label: '',
|
352
|
-
icon: FaColumns,
|
353
|
-
fieldName: 'four_col_row_',
|
354
|
-
colCount: 4,
|
355
|
-
className: 'col-md-3',
|
356
|
-
"static": true
|
357
|
-
}, {
|
358
|
-
key: 'FiveColumnRow',
|
359
|
-
element: 'MultiColumnRow',
|
360
|
-
name: "Five Columns Row",
|
361
|
-
label: '',
|
362
|
-
icon: FaColumns,
|
363
|
-
fieldName: 'five_col_row_',
|
364
|
-
colCount: 5,
|
365
|
-
className: 'col',
|
366
|
-
"static": true
|
367
|
-
}, {
|
368
|
-
key: 'SixColumnRow',
|
369
|
-
element: 'MultiColumnRow',
|
370
|
-
name: "Six Columns Row",
|
371
|
-
label: '',
|
372
|
-
icon: FaColumns,
|
373
|
-
fieldName: 'six_col_row_',
|
374
|
-
colCount: 6,
|
375
|
-
className: 'col-md-2',
|
376
|
-
"static": true
|
377
|
-
}];
|
378
|
-
}
|
379
|
-
}, {
|
380
|
-
key: "addCustomOptions",
|
381
|
-
value: function addCustomOptions(item, elementOptions) {
|
382
|
-
if (item.type === 'custom') {
|
383
|
-
var customOptions = _objectSpread(_objectSpread({}, item), elementOptions);
|
384
|
-
customOptions.custom = true;
|
385
|
-
customOptions.component = item.component || null;
|
386
|
-
customOptions.customOptions = item.customOptions || [];
|
387
|
-
return customOptions;
|
388
|
-
}
|
389
|
-
return elementOptions;
|
390
|
-
}
|
391
|
-
}, {
|
392
|
-
key: "create",
|
393
|
-
value: function create(item) {
|
394
|
-
var _item$static;
|
395
|
-
var element = item.element || item.key;
|
396
|
-
var elementOptions = this.addCustomOptions(item, {
|
397
|
-
id: ID.uuid(),
|
398
|
-
element: element,
|
399
|
-
text: item.name,
|
400
|
-
"static": (_item$static = item["static"]) !== null && _item$static !== void 0 ? _item$static : false
|
401
|
-
});
|
402
|
-
if (item.groupName) {
|
403
|
-
var _item$groupName;
|
404
|
-
elementOptions.groupName = (_item$groupName = item.groupName) !== null && _item$groupName !== void 0 ? _item$groupName : null;
|
405
|
-
}
|
406
|
-
if (!item["static"]) {
|
407
|
-
elementOptions.required = false;
|
408
|
-
}
|
409
483
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
484
|
+
// add placeholder to form input
|
485
|
+
if (['NumberInput', 'EmailInput', 'TextInput', 'PhoneNumber', 'TextArea', 'DatePicker', 'Dropdown', 'Tags'].indexOf(element) !== -1) {
|
486
|
+
var _item$placeholder;
|
487
|
+
elementOptions.placeholder = (_item$placeholder = item.placeholder) !== null && _item$placeholder !== void 0 ? _item$placeholder : '';
|
488
|
+
}
|
489
|
+
if (item.type === 'custom') {
|
490
|
+
elementOptions.key = item.key;
|
491
|
+
elementOptions.custom = true;
|
492
|
+
elementOptions.forwardRef = item.forwardRef;
|
493
|
+
elementOptions.bare = item.bare;
|
494
|
+
elementOptions.props = item.props;
|
495
|
+
elementOptions.component = item.component || null;
|
496
|
+
elementOptions.customOptions = item.customOptions || [];
|
497
|
+
}
|
498
|
+
if (item["static"] && ['Header', 'Paragraph', 'Label'].indexOf(element) !== -1) {
|
499
|
+
elementOptions.bold = false;
|
500
|
+
elementOptions.italic = false;
|
501
|
+
}
|
502
|
+
if (item.canHaveLabelLocation || item.labelLocation !== undefined) {
|
503
|
+
var _item$labelLocation;
|
504
|
+
elementOptions.labelLocation = (_item$labelLocation = item.labelLocation) !== null && _item$labelLocation !== void 0 ? _item$labelLocation : 'ABOVE';
|
505
|
+
}
|
506
|
+
if (item.canHaveHelp || item.help !== undefined) {
|
507
|
+
var _item$help;
|
508
|
+
elementOptions.help = (_item$help = item.help) !== null && _item$help !== void 0 ? _item$help : '';
|
509
|
+
}
|
510
|
+
if (item.canHideLabel || item.hideLabel !== undefined) {
|
511
|
+
var _item$hideLabel;
|
512
|
+
elementOptions.hideLabel = (_item$hideLabel = item.hideLabel) !== null && _item$hideLabel !== void 0 ? _item$hideLabel : false;
|
513
|
+
}
|
514
|
+
if (item.canReadOnly || item.readOnly !== undefined) {
|
515
|
+
var _item$readOnly;
|
516
|
+
elementOptions.readOnly = (_item$readOnly = item.readOnly) !== null && _item$readOnly !== void 0 ? _item$readOnly : false;
|
517
|
+
}
|
518
|
+
if (item.canDefaultToday || item.defaultToday !== undefined) {
|
519
|
+
var _item$defaultToday;
|
520
|
+
elementOptions.defaultToday = (_item$defaultToday = item.defaultToday) !== null && _item$defaultToday !== void 0 ? _item$defaultToday : false;
|
521
|
+
}
|
522
|
+
if (item.content) {
|
523
|
+
elementOptions.content = item.content;
|
524
|
+
}
|
525
|
+
if (item.href) {
|
526
|
+
elementOptions.href = item.href;
|
527
|
+
}
|
528
|
+
if (item.inherited !== undefined) {
|
529
|
+
elementOptions.inherited = item.inherited;
|
530
|
+
}
|
531
|
+
if (item.canHavePageBreakBefore || item.pageBreakBefore !== undefined) {
|
532
|
+
var _item$pageBreakBefore;
|
533
|
+
elementOptions.pageBreakBefore = (_item$pageBreakBefore = item.pageBreakBefore) !== null && _item$pageBreakBefore !== void 0 ? _item$pageBreakBefore : false;
|
534
|
+
}
|
535
|
+
if (item.canHaveAlternateForm || item.alternateForm !== undefined) {
|
536
|
+
var _item$alternateForm;
|
537
|
+
elementOptions.alternateForm = (_item$alternateForm = item.alternateForm) !== null && _item$alternateForm !== void 0 ? _item$alternateForm : false;
|
538
|
+
}
|
539
|
+
if (item.canHaveDisplayHorizontal || item.inline !== undefined) {
|
540
|
+
var _item$inline;
|
541
|
+
elementOptions.inline = (_item$inline = item.inline) !== null && _item$inline !== void 0 ? _item$inline : false;
|
542
|
+
}
|
543
|
+
if (item.canHaveOptionCorrect) {
|
544
|
+
var _item$canHaveOptionCo;
|
545
|
+
elementOptions.canHaveOptionCorrect = (_item$canHaveOptionCo = item.canHaveOptionCorrect) !== null && _item$canHaveOptionCo !== void 0 ? _item$canHaveOptionCo : false;
|
546
|
+
}
|
547
|
+
if (item.canHaveOptionValue) {
|
548
|
+
var _item$canHaveOptionVa;
|
549
|
+
elementOptions.canHaveOptionValue = (_item$canHaveOptionVa = item.canHaveOptionValue) !== null && _item$canHaveOptionVa !== void 0 ? _item$canHaveOptionVa : false;
|
550
|
+
}
|
551
|
+
if (item.canPopulateFromApi) {
|
552
|
+
var _item$canPopulateFrom;
|
553
|
+
elementOptions.canPopulateFromApi = (_item$canPopulateFrom = item.canPopulateFromApi) !== null && _item$canPopulateFrom !== void 0 ? _item$canPopulateFrom : false;
|
554
|
+
}
|
555
|
+
if (item.className) {
|
556
|
+
elementOptions.className = item.className;
|
557
|
+
}
|
558
|
+
if (element === 'Step') {
|
559
|
+
elementOptions.conditional = item.conditional;
|
560
|
+
elementOptions.conditionalFieldName = item.conditionalFieldName;
|
561
|
+
elementOptions.conditionalFieldValue = item.conditionalFieldValue;
|
562
|
+
}
|
563
|
+
if (element === 'Image') {
|
564
|
+
elementOptions.src = item.src;
|
565
|
+
}
|
566
|
+
if (element === 'DatePicker') {
|
567
|
+
elementOptions.dateFormat = item.dateFormat;
|
568
|
+
}
|
569
|
+
if (element === 'Download') {
|
570
|
+
elementOptions.href = item.href;
|
571
|
+
elementOptions.filePath = item.filePath;
|
572
|
+
}
|
573
|
+
if (element === 'NumberInput') {
|
574
|
+
elementOptions.step = item.step;
|
575
|
+
elementOptions.minValue = item.minValue;
|
576
|
+
elementOptions.maxValue = item.maxValue;
|
577
|
+
}
|
578
|
+
if (element === 'Range') {
|
579
|
+
elementOptions.step = item.step;
|
580
|
+
elementOptions.defaultValue = item.defaultValue;
|
581
|
+
elementOptions.minValue = item.minValue;
|
582
|
+
elementOptions.maxValue = item.maxValue;
|
583
|
+
elementOptions.minLabel = item.minLabel;
|
584
|
+
elementOptions.maxLabel = item.maxLabel;
|
585
|
+
}
|
586
|
+
if (element === 'MultiColumnRow') {
|
587
|
+
elementOptions.colCount = item.colCount;
|
588
|
+
}
|
589
|
+
if (item.defaultValue) {
|
590
|
+
elementOptions.defaultValue = item.defaultValue;
|
591
|
+
}
|
592
|
+
if (item.fieldName) {
|
593
|
+
elementOptions.fieldName = item.fieldName + ID.uuid();
|
594
|
+
}
|
595
|
+
if (!item["static"]) {
|
596
|
+
var _item$customName;
|
597
|
+
elementOptions.customName = (_item$customName = item.customName) !== null && _item$customName !== void 0 ? _item$customName : elementOptions.fieldName;
|
598
|
+
}
|
599
|
+
if (item.label) {
|
600
|
+
elementOptions.label = item.label.trim();
|
601
|
+
}
|
602
|
+
if (item.options) {
|
603
|
+
if (item.options.length > 0) {
|
604
|
+
elementOptions.options = item.options.map(function (x) {
|
605
|
+
return _objectSpread(_objectSpread({}, x), {}, {
|
606
|
+
key: "custom_option_".concat(ID.uuid())
|
529
607
|
});
|
530
|
-
} else {
|
531
|
-
elementOptions.options = Toolbar._defaultItemOptions(elementOptions.element);
|
532
|
-
}
|
533
|
-
}
|
534
|
-
return elementOptions;
|
535
|
-
}
|
536
|
-
}, {
|
537
|
-
key: "_onClick",
|
538
|
-
value: function _onClick(item) {
|
539
|
-
// ElementActions.createElement(this.create(item));
|
540
|
-
store.dispatch('create', this.create(item));
|
541
|
-
}
|
542
|
-
}, {
|
543
|
-
key: "render",
|
544
|
-
value: function render() {
|
545
|
-
var _this3 = this;
|
546
|
-
var _buildGroupItems = buildGroupItems(this.state.items),
|
547
|
-
items = _buildGroupItems.items,
|
548
|
-
grouped = _buildGroupItems.grouped,
|
549
|
-
groupKeys = _buildGroupItems.groupKeys;
|
550
|
-
return /*#__PURE__*/React.createElement("div", {
|
551
|
-
className: "react-survey-builder-toolbar"
|
552
|
-
}, /*#__PURE__*/React.createElement("h4", null, "Survey Blocks Toolbox"), /*#__PURE__*/React.createElement("ul", null, items.map(this.renderItem), groupKeys.map(function (k) {
|
553
|
-
return /*#__PURE__*/React.createElement(ToolbarGroupItem, {
|
554
|
-
key: k,
|
555
|
-
name: k,
|
556
|
-
group: grouped.get(k),
|
557
|
-
renderItem: _this3.renderItem
|
558
608
|
});
|
559
|
-
}
|
560
|
-
|
561
|
-
}], [{
|
562
|
-
key: "_defaultItemOptions",
|
563
|
-
value: function _defaultItemOptions(element) {
|
564
|
-
switch (element) {
|
565
|
-
case 'Dropdown':
|
566
|
-
return [{
|
567
|
-
value: 'place_holder_option_1',
|
568
|
-
text: "Place holder option 1",
|
569
|
-
key: "dropdown_option_".concat(ID.uuid())
|
570
|
-
}, {
|
571
|
-
value: 'place_holder_option_2',
|
572
|
-
text: "Place holder option 2",
|
573
|
-
key: "dropdown_option_".concat(ID.uuid())
|
574
|
-
}, {
|
575
|
-
value: 'place_holder_option_3',
|
576
|
-
text: "Place holder option 3",
|
577
|
-
key: "dropdown_option_".concat(ID.uuid())
|
578
|
-
}];
|
579
|
-
case 'Tags':
|
580
|
-
return [{
|
581
|
-
value: 'place_holder_tag_1',
|
582
|
-
text: "Place holder option 1",
|
583
|
-
key: "tags_option_".concat(ID.uuid())
|
584
|
-
}, {
|
585
|
-
value: 'place_holder_tag_2',
|
586
|
-
text: "Place holder option 2",
|
587
|
-
key: "tags_option_".concat(ID.uuid())
|
588
|
-
}, {
|
589
|
-
value: 'place_holder_tag_3',
|
590
|
-
text: "Place holder option 3",
|
591
|
-
key: "tags_option_".concat(ID.uuid())
|
592
|
-
}];
|
593
|
-
case 'Checkboxes':
|
594
|
-
return [{
|
595
|
-
value: 'place_holder_option_1',
|
596
|
-
text: "Place holder option 1",
|
597
|
-
key: "checkboxes_option_".concat(ID.uuid())
|
598
|
-
}, {
|
599
|
-
value: 'place_holder_option_2',
|
600
|
-
text: "Place holder option 2",
|
601
|
-
key: "checkboxes_option_".concat(ID.uuid())
|
602
|
-
}, {
|
603
|
-
value: 'place_holder_option_3',
|
604
|
-
text: "Place holder option 3",
|
605
|
-
key: "checkboxes_option_".concat(ID.uuid())
|
606
|
-
}];
|
607
|
-
case 'RadioButtons':
|
608
|
-
return [{
|
609
|
-
value: 'place_holder_option_1',
|
610
|
-
text: "Place holder option 1",
|
611
|
-
key: "radiobuttons_option_".concat(ID.uuid())
|
612
|
-
}, {
|
613
|
-
value: 'place_holder_option_2',
|
614
|
-
text: "Place holder option 2",
|
615
|
-
key: "radiobuttons_option_".concat(ID.uuid())
|
616
|
-
}, {
|
617
|
-
value: 'place_holder_option_3',
|
618
|
-
text: "Place holder option 3",
|
619
|
-
key: "radiobuttons_option_".concat(ID.uuid())
|
620
|
-
}];
|
621
|
-
default:
|
622
|
-
return [];
|
609
|
+
} else {
|
610
|
+
elementOptions.options = _defaultItemOptions(elementOptions.element);
|
623
611
|
}
|
624
612
|
}
|
625
|
-
|
626
|
-
}
|
613
|
+
return elementOptions;
|
614
|
+
};
|
615
|
+
var _onClick = function _onClick(item) {
|
616
|
+
// ElementActions.createElement(create(item));
|
617
|
+
store.dispatch('create', create(item));
|
618
|
+
};
|
619
|
+
var renderItem = function renderItem(item) {
|
620
|
+
return /*#__PURE__*/React.createElement(ToolbarItem, {
|
621
|
+
item: item,
|
622
|
+
key: item.key,
|
623
|
+
onClick: function onClick() {
|
624
|
+
_onClick(item);
|
625
|
+
},
|
626
|
+
onCreate: create
|
627
|
+
});
|
628
|
+
};
|
629
|
+
React.useEffect(function () {
|
630
|
+
setDataItems(buildItems(dataItems, _defaultItems, customItems));
|
631
|
+
}, []);
|
632
|
+
var _buildGroupItems = buildGroupItems(dataItems),
|
633
|
+
ungroupedItems = _buildGroupItems.ungroupedItems,
|
634
|
+
grouped = _buildGroupItems.grouped,
|
635
|
+
groupKeys = _buildGroupItems.groupKeys;
|
636
|
+
return /*#__PURE__*/React.createElement("div", {
|
637
|
+
className: "react-survey-builder-toolbar"
|
638
|
+
}, /*#__PURE__*/React.createElement("h4", null, "Survey Blocks Toolbox"), /*#__PURE__*/React.createElement("ul", null, ungroupedItems.map(renderItem), groupKeys.map(function (k) {
|
639
|
+
return /*#__PURE__*/React.createElement(ToolbarGroupItem, {
|
640
|
+
key: k,
|
641
|
+
name: k,
|
642
|
+
group: grouped.get(k),
|
643
|
+
renderItem: renderItem
|
644
|
+
});
|
645
|
+
})));
|
646
|
+
};
|
627
647
|
export default Toolbar;
|