react-survey-builder 1.0.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.
- package/LICENSE +7 -0
- package/README.md +236 -0
- package/dist/967.index.js +1 -0
- package/dist/app.css +1 -0
- package/dist/app.css.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +46 -0
- package/lib/ItemTypes.js +10 -0
- package/lib/UUID.js +65 -0
- package/lib/dynamic-option-list.js +188 -0
- package/lib/fieldset/FieldSet.js +118 -0
- package/lib/fieldset/index.js +13 -0
- package/lib/form.js +604 -0
- package/lib/functions/index.js +45 -0
- package/lib/index.js +139 -0
- package/lib/language-provider/IntlMessages.js +15 -0
- package/lib/language-provider/entries/en-us.js +16 -0
- package/lib/language-provider/entries/it-it.js +16 -0
- package/lib/language-provider/entries/vi-vn.js +16 -0
- package/lib/language-provider/index.js +32 -0
- package/lib/language-provider/locales/en-us.json +97 -0
- package/lib/language-provider/locales/it-it.json +92 -0
- package/lib/language-provider/locales/vi-vn.json +82 -0
- package/lib/multi-column/MultiColumnRow.js +134 -0
- package/lib/multi-column/dustbin.js +152 -0
- package/lib/multi-column/grip.js +51 -0
- package/lib/multi-column/index.js +24 -0
- package/lib/preview.js +388 -0
- package/lib/sortable-element.js +177 -0
- package/lib/sortable-form-elements.js +67 -0
- package/lib/stores/registry.js +42 -0
- package/lib/stores/requests.js +31 -0
- package/lib/stores/store.js +138 -0
- package/lib/survey-dynamic-edit.js +54 -0
- package/lib/survey-elements/component-drag-handle.js +90 -0
- package/lib/survey-elements/component-drag-layer.js +68 -0
- package/lib/survey-elements/component-drag-preview.js +57 -0
- package/lib/survey-elements/component-header.js +29 -0
- package/lib/survey-elements/component-label.js +26 -0
- package/lib/survey-elements/custom-element.js +70 -0
- package/lib/survey-elements/date-picker.js +278 -0
- package/lib/survey-elements/header-bar.js +54 -0
- package/lib/survey-elements/index.js +1196 -0
- package/lib/survey-elements/myxss.js +29 -0
- package/lib/survey-elements/star-rating.js +335 -0
- package/lib/survey-elements-edit.js +613 -0
- package/lib/survey-place-holder.js +51 -0
- package/lib/survey-validator.js +103 -0
- package/lib/toolbar-draggable-item.js +59 -0
- package/lib/toolbar-group-item.js +39 -0
- package/lib/toolbar.js +680 -0
- package/lib/utils/custom-date-picker.js +93 -0
- package/package.json +114 -0
- package/types/index.d.ts +180 -0
package/lib/toolbar.js
ADDED
@@ -0,0 +1,680 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports["default"] = void 0;
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
+
var _react = _interopRequireDefault(require("react"));
|
16
|
+
var _reactIntl = require("react-intl");
|
17
|
+
var _toolbarDraggableItem = _interopRequireDefault(require("./toolbar-draggable-item"));
|
18
|
+
var _toolbarGroupItem = _interopRequireDefault(require("./toolbar-group-item"));
|
19
|
+
var _UUID = _interopRequireDefault(require("./UUID"));
|
20
|
+
var _store = _interopRequireDefault(require("./stores/store"));
|
21
|
+
var _functions = require("./functions");
|
22
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
23
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
24
|
+
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; }
|
25
|
+
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) { (0, _defineProperty2["default"])(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; } /**
|
26
|
+
* <Toolbar />
|
27
|
+
*/
|
28
|
+
// function isDefaultItem(item) {
|
29
|
+
// const keys = Object.keys(item);
|
30
|
+
// return keys.filter(x => x !== 'element' && x !== 'key' && x !== 'group_name').length === 0;
|
31
|
+
// }
|
32
|
+
|
33
|
+
function buildItems(items, defaultItems) {
|
34
|
+
if (!items) {
|
35
|
+
return defaultItems;
|
36
|
+
}
|
37
|
+
return items.map(function (x) {
|
38
|
+
var found = defaultItems.find(function (y) {
|
39
|
+
return x.element === y.element && y.key === x.key;
|
40
|
+
});
|
41
|
+
if (!found) {
|
42
|
+
found = defaultItems.find(function (y) {
|
43
|
+
return (x.element || x.key) === (y.element || y.key);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
if (found) {
|
47
|
+
if (x.inherited !== false) {
|
48
|
+
found = _objectSpread(_objectSpread({}, found), x);
|
49
|
+
} else if (x.group_name) {
|
50
|
+
found.group_name = x.group_name;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return found || x;
|
54
|
+
});
|
55
|
+
}
|
56
|
+
function buildGroupItems(allItems) {
|
57
|
+
var items = allItems.filter(function (x) {
|
58
|
+
return !x.group_name;
|
59
|
+
});
|
60
|
+
var gItems = allItems.filter(function (x) {
|
61
|
+
return !!x.group_name;
|
62
|
+
});
|
63
|
+
var grouped = (0, _functions.groupBy)(gItems, function (x) {
|
64
|
+
return x.group_name;
|
65
|
+
});
|
66
|
+
var groupKeys = gItems.map(function (x) {
|
67
|
+
return x.group_name;
|
68
|
+
}).filter(function (v, i, self) {
|
69
|
+
return self.indexOf(v) === i;
|
70
|
+
});
|
71
|
+
return {
|
72
|
+
items: items,
|
73
|
+
grouped: grouped,
|
74
|
+
groupKeys: groupKeys
|
75
|
+
};
|
76
|
+
}
|
77
|
+
var Toolbar = /*#__PURE__*/function (_React$Component) {
|
78
|
+
(0, _inherits2["default"])(Toolbar, _React$Component);
|
79
|
+
var _super = _createSuper(Toolbar);
|
80
|
+
function Toolbar(props) {
|
81
|
+
var _this;
|
82
|
+
(0, _classCallCheck2["default"])(this, Toolbar);
|
83
|
+
_this = _super.call(this, props);
|
84
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderItem", function (item) {
|
85
|
+
return /*#__PURE__*/_react["default"].createElement(_toolbarDraggableItem["default"], {
|
86
|
+
data: item,
|
87
|
+
key: item.key,
|
88
|
+
onClick: _this._onClick.bind((0, _assertThisInitialized2["default"])(_this), item),
|
89
|
+
onCreate: _this.create
|
90
|
+
});
|
91
|
+
});
|
92
|
+
var intl = _this.props.intl;
|
93
|
+
var items = buildItems(props.items, _this._defaultItems(intl));
|
94
|
+
_this.state = {
|
95
|
+
items: items
|
96
|
+
};
|
97
|
+
_this.create = _this.create.bind((0, _assertThisInitialized2["default"])(_this));
|
98
|
+
return _this;
|
99
|
+
}
|
100
|
+
(0, _createClass2["default"])(Toolbar, [{
|
101
|
+
key: "componentDidMount",
|
102
|
+
value: function componentDidMount() {
|
103
|
+
var _this2 = this;
|
104
|
+
_store["default"].subscribe(function (state) {
|
105
|
+
return _this2.setState({
|
106
|
+
store: state
|
107
|
+
});
|
108
|
+
});
|
109
|
+
}
|
110
|
+
}, {
|
111
|
+
key: "_defaultItems",
|
112
|
+
value: function _defaultItems(intl) {
|
113
|
+
return [{
|
114
|
+
key: 'Header',
|
115
|
+
name: intl.formatMessage({
|
116
|
+
id: 'header-text'
|
117
|
+
}),
|
118
|
+
icon: 'fas fa-heading',
|
119
|
+
"static": true,
|
120
|
+
content: intl.formatMessage({
|
121
|
+
id: 'place-holder-text'
|
122
|
+
})
|
123
|
+
}, {
|
124
|
+
key: 'Label',
|
125
|
+
name: intl.formatMessage({
|
126
|
+
id: 'label'
|
127
|
+
}),
|
128
|
+
"static": true,
|
129
|
+
icon: 'fas fa-font',
|
130
|
+
content: intl.formatMessage({
|
131
|
+
id: 'place-holder-text'
|
132
|
+
})
|
133
|
+
}, {
|
134
|
+
key: 'Paragraph',
|
135
|
+
name: intl.formatMessage({
|
136
|
+
id: 'paragraph'
|
137
|
+
}),
|
138
|
+
"static": true,
|
139
|
+
icon: 'fas fa-paragraph',
|
140
|
+
content: intl.formatMessage({
|
141
|
+
id: 'place-holder-text'
|
142
|
+
})
|
143
|
+
}, {
|
144
|
+
key: 'LineBreak',
|
145
|
+
name: intl.formatMessage({
|
146
|
+
id: 'line-break'
|
147
|
+
}),
|
148
|
+
"static": true,
|
149
|
+
icon: 'fas fa-arrows-alt-h'
|
150
|
+
}, {
|
151
|
+
key: 'Dropdown',
|
152
|
+
canHaveAnswer: true,
|
153
|
+
name: intl.formatMessage({
|
154
|
+
id: 'dropdown'
|
155
|
+
}),
|
156
|
+
icon: 'far fa-caret-square-down',
|
157
|
+
label: intl.formatMessage({
|
158
|
+
id: 'place-holder-label'
|
159
|
+
}),
|
160
|
+
field_name: 'dropdown_',
|
161
|
+
options: []
|
162
|
+
}, {
|
163
|
+
key: 'Tags',
|
164
|
+
canHaveAnswer: true,
|
165
|
+
name: intl.formatMessage({
|
166
|
+
id: 'tags'
|
167
|
+
}),
|
168
|
+
icon: 'fas fa-tags',
|
169
|
+
label: intl.formatMessage({
|
170
|
+
id: 'place-holder-label'
|
171
|
+
}),
|
172
|
+
field_name: 'tags_',
|
173
|
+
options: []
|
174
|
+
}, {
|
175
|
+
key: 'Checkboxes',
|
176
|
+
canHaveAnswer: true,
|
177
|
+
name: intl.formatMessage({
|
178
|
+
id: 'checkboxes'
|
179
|
+
}),
|
180
|
+
icon: 'far fa-check-square',
|
181
|
+
label: intl.formatMessage({
|
182
|
+
id: 'place-holder-label'
|
183
|
+
}),
|
184
|
+
field_name: 'checkboxes_',
|
185
|
+
options: []
|
186
|
+
}, {
|
187
|
+
key: 'Checkbox',
|
188
|
+
canHaveAnswer: true,
|
189
|
+
name: intl.formatMessage({
|
190
|
+
id: 'checkbox'
|
191
|
+
}),
|
192
|
+
icon: 'far fa-check-square',
|
193
|
+
label: intl.formatMessage({
|
194
|
+
id: 'place-holder-label'
|
195
|
+
}),
|
196
|
+
field_name: 'checkbox_',
|
197
|
+
boxLabel: 'Agree To Rules & Regs'
|
198
|
+
}, {
|
199
|
+
key: 'RadioButtons',
|
200
|
+
canHaveAnswer: true,
|
201
|
+
name: intl.formatMessage({
|
202
|
+
id: 'multiple-choice'
|
203
|
+
}),
|
204
|
+
icon: 'far fa-dot-circle',
|
205
|
+
label: intl.formatMessage({
|
206
|
+
id: 'place-holder-label'
|
207
|
+
}),
|
208
|
+
field_name: 'radiobuttons_',
|
209
|
+
options: []
|
210
|
+
}, {
|
211
|
+
key: 'TextInput',
|
212
|
+
canHaveAnswer: true,
|
213
|
+
name: intl.formatMessage({
|
214
|
+
id: 'text-input'
|
215
|
+
}),
|
216
|
+
label: intl.formatMessage({
|
217
|
+
id: 'place-holder-label'
|
218
|
+
}),
|
219
|
+
icon: 'fas fa-font',
|
220
|
+
field_name: 'text_input_'
|
221
|
+
}, {
|
222
|
+
key: 'EmailInput',
|
223
|
+
canHaveAnswer: true,
|
224
|
+
name: intl.formatMessage({
|
225
|
+
id: 'email-input'
|
226
|
+
}),
|
227
|
+
label: intl.formatMessage({
|
228
|
+
id: 'place-holder-email'
|
229
|
+
}),
|
230
|
+
icon: 'fas fa-envelope',
|
231
|
+
field_name: 'email_input_',
|
232
|
+
placeholder: ''
|
233
|
+
}, {
|
234
|
+
key: 'NumberInput',
|
235
|
+
canHaveAnswer: true,
|
236
|
+
name: intl.formatMessage({
|
237
|
+
id: 'number-input'
|
238
|
+
}),
|
239
|
+
label: intl.formatMessage({
|
240
|
+
id: 'place-holder-label'
|
241
|
+
}),
|
242
|
+
icon: 'fas fa-plus',
|
243
|
+
field_name: 'number_input_'
|
244
|
+
}, {
|
245
|
+
key: 'PhoneNumber',
|
246
|
+
canHaveAnswer: true,
|
247
|
+
name: intl.formatMessage({
|
248
|
+
id: 'phone-input'
|
249
|
+
}),
|
250
|
+
label: intl.formatMessage({
|
251
|
+
id: 'place-holder-phone-number'
|
252
|
+
}),
|
253
|
+
icon: 'fas fa-phone',
|
254
|
+
field_name: 'phone_input_'
|
255
|
+
}, {
|
256
|
+
key: 'TextArea',
|
257
|
+
canHaveAnswer: true,
|
258
|
+
name: intl.formatMessage({
|
259
|
+
id: 'multi-line-input'
|
260
|
+
}),
|
261
|
+
label: intl.formatMessage({
|
262
|
+
id: 'place-holder-label'
|
263
|
+
}),
|
264
|
+
icon: 'fas fa-text-height',
|
265
|
+
field_name: 'text_area_'
|
266
|
+
}, {
|
267
|
+
key: 'FieldSet',
|
268
|
+
canHaveAnswer: false,
|
269
|
+
name: intl.formatMessage({
|
270
|
+
id: 'fieldset'
|
271
|
+
}),
|
272
|
+
label: intl.formatMessage({
|
273
|
+
id: 'fieldset'
|
274
|
+
}),
|
275
|
+
icon: 'fas fa-bars',
|
276
|
+
field_name: 'fieldset-element'
|
277
|
+
}, {
|
278
|
+
key: 'TwoColumnRow',
|
279
|
+
canHaveAnswer: false,
|
280
|
+
name: intl.formatMessage({
|
281
|
+
id: 'two-columns-row'
|
282
|
+
}),
|
283
|
+
label: '',
|
284
|
+
icon: 'fas fa-columns',
|
285
|
+
field_name: 'two_col_row_'
|
286
|
+
}, {
|
287
|
+
key: 'ThreeColumnRow',
|
288
|
+
canHaveAnswer: false,
|
289
|
+
name: intl.formatMessage({
|
290
|
+
id: 'three-columns-row'
|
291
|
+
}),
|
292
|
+
label: '',
|
293
|
+
icon: 'fas fa-columns',
|
294
|
+
field_name: 'three_col_row_'
|
295
|
+
}, {
|
296
|
+
key: 'FourColumnRow',
|
297
|
+
element: 'MultiColumnRow',
|
298
|
+
canHaveAnswer: false,
|
299
|
+
name: intl.formatMessage({
|
300
|
+
id: 'four-columns-row'
|
301
|
+
}),
|
302
|
+
label: '',
|
303
|
+
icon: 'fas fa-columns',
|
304
|
+
field_name: 'four_col_row_',
|
305
|
+
col_count: 4,
|
306
|
+
class_name: 'col-md-3'
|
307
|
+
}, {
|
308
|
+
key: 'FiveColumnRow',
|
309
|
+
element: 'MultiColumnRow',
|
310
|
+
canHaveAnswer: false,
|
311
|
+
name: intl.formatMessage({
|
312
|
+
id: 'five-columns-row'
|
313
|
+
}),
|
314
|
+
label: '',
|
315
|
+
icon: 'fas fa-columns',
|
316
|
+
field_name: 'five_col_row_',
|
317
|
+
col_count: 5,
|
318
|
+
class_name: 'col'
|
319
|
+
}, {
|
320
|
+
key: 'SixColumnRow',
|
321
|
+
element: 'MultiColumnRow',
|
322
|
+
canHaveAnswer: false,
|
323
|
+
name: intl.formatMessage({
|
324
|
+
id: 'six-columns-row'
|
325
|
+
}),
|
326
|
+
label: '',
|
327
|
+
icon: 'fas fa-columns',
|
328
|
+
field_name: 'six_col_row_',
|
329
|
+
col_count: 6,
|
330
|
+
class_name: 'col-md-2'
|
331
|
+
}, {
|
332
|
+
key: 'Image',
|
333
|
+
name: intl.formatMessage({
|
334
|
+
id: 'image'
|
335
|
+
}),
|
336
|
+
label: '',
|
337
|
+
icon: 'far fa-image',
|
338
|
+
field_name: 'image_',
|
339
|
+
src: ''
|
340
|
+
}, {
|
341
|
+
key: 'Rating',
|
342
|
+
canHaveAnswer: true,
|
343
|
+
name: intl.formatMessage({
|
344
|
+
id: 'rating'
|
345
|
+
}),
|
346
|
+
label: intl.formatMessage({
|
347
|
+
id: 'place-holder-label'
|
348
|
+
}),
|
349
|
+
icon: 'fas fa-star',
|
350
|
+
field_name: 'rating_'
|
351
|
+
}, {
|
352
|
+
key: 'DatePicker',
|
353
|
+
canDefaultToday: true,
|
354
|
+
canReadOnly: true,
|
355
|
+
dateFormat: 'MM/dd/yyyy',
|
356
|
+
timeFormat: 'hh:mm aa',
|
357
|
+
showTimeSelect: false,
|
358
|
+
showTimeSelectOnly: false,
|
359
|
+
showTimeInput: false,
|
360
|
+
name: intl.formatMessage({
|
361
|
+
id: 'date'
|
362
|
+
}),
|
363
|
+
icon: 'far fa-calendar-alt',
|
364
|
+
label: intl.formatMessage({
|
365
|
+
id: 'place-holder-label'
|
366
|
+
}),
|
367
|
+
field_name: 'date_picker_'
|
368
|
+
}, {
|
369
|
+
key: 'Signature',
|
370
|
+
canReadOnly: true,
|
371
|
+
name: intl.formatMessage({
|
372
|
+
id: 'signature'
|
373
|
+
}),
|
374
|
+
icon: 'fas fa-pen-square',
|
375
|
+
label: intl.formatMessage({
|
376
|
+
id: 'signature'
|
377
|
+
}),
|
378
|
+
field_name: 'signature_'
|
379
|
+
}, {
|
380
|
+
key: 'HyperLink',
|
381
|
+
name: intl.formatMessage({
|
382
|
+
id: 'website'
|
383
|
+
}),
|
384
|
+
icon: 'fas fa-link',
|
385
|
+
"static": true,
|
386
|
+
content: intl.formatMessage({
|
387
|
+
id: 'place-holder-website-link'
|
388
|
+
}),
|
389
|
+
href: 'http://www.example.com'
|
390
|
+
}, {
|
391
|
+
key: 'Download',
|
392
|
+
name: intl.formatMessage({
|
393
|
+
id: 'file-attachment'
|
394
|
+
}),
|
395
|
+
icon: 'fas fa-file',
|
396
|
+
"static": true,
|
397
|
+
content: intl.formatMessage({
|
398
|
+
id: 'place-holder-file-name'
|
399
|
+
}),
|
400
|
+
field_name: 'download_',
|
401
|
+
file_path: '',
|
402
|
+
_href: ''
|
403
|
+
}, {
|
404
|
+
key: 'Range',
|
405
|
+
name: intl.formatMessage({
|
406
|
+
id: 'range'
|
407
|
+
}),
|
408
|
+
icon: 'fas fa-sliders-h',
|
409
|
+
label: intl.formatMessage({
|
410
|
+
id: 'place-holder-label'
|
411
|
+
}),
|
412
|
+
field_name: 'range_',
|
413
|
+
step: 1,
|
414
|
+
default_value: 3,
|
415
|
+
min_value: 1,
|
416
|
+
max_value: 5,
|
417
|
+
min_label: intl.formatMessage({
|
418
|
+
id: 'easy'
|
419
|
+
}),
|
420
|
+
max_label: intl.formatMessage({
|
421
|
+
id: 'difficult'
|
422
|
+
})
|
423
|
+
}, {
|
424
|
+
key: 'Camera',
|
425
|
+
name: intl.formatMessage({
|
426
|
+
id: 'camera'
|
427
|
+
}),
|
428
|
+
icon: 'fas fa-camera',
|
429
|
+
label: intl.formatMessage({
|
430
|
+
id: 'place-holder-label'
|
431
|
+
}),
|
432
|
+
field_name: 'camera_'
|
433
|
+
}, {
|
434
|
+
key: 'FileUpload',
|
435
|
+
name: intl.formatMessage({
|
436
|
+
id: 'file-upload'
|
437
|
+
}),
|
438
|
+
icon: 'fas fa-file',
|
439
|
+
label: intl.formatMessage({
|
440
|
+
id: 'place-holder-label'
|
441
|
+
}),
|
442
|
+
field_name: 'file_upload_'
|
443
|
+
}];
|
444
|
+
}
|
445
|
+
}, {
|
446
|
+
key: "addCustomOptions",
|
447
|
+
value: function addCustomOptions(item, elementOptions) {
|
448
|
+
if (item.type === 'custom') {
|
449
|
+
var customOptions = _objectSpread(_objectSpread({}, item), elementOptions);
|
450
|
+
customOptions.custom = true;
|
451
|
+
customOptions.component = item.component || null;
|
452
|
+
customOptions.custom_options = item.custom_options || [];
|
453
|
+
return customOptions;
|
454
|
+
}
|
455
|
+
return elementOptions;
|
456
|
+
}
|
457
|
+
}, {
|
458
|
+
key: "create",
|
459
|
+
value: function create(item) {
|
460
|
+
var intl = this.props.intl;
|
461
|
+
var element = item.element || item.key;
|
462
|
+
var elementOptions = this.addCustomOptions(item, {
|
463
|
+
id: _UUID["default"].uuid(),
|
464
|
+
element: element,
|
465
|
+
text: item.name,
|
466
|
+
group_name: item.group_name,
|
467
|
+
"static": item["static"],
|
468
|
+
required: false,
|
469
|
+
showDescription: item.showDescription
|
470
|
+
});
|
471
|
+
if (this.props.showDescription === true && !item["static"]) {
|
472
|
+
elementOptions.showDescription = true;
|
473
|
+
}
|
474
|
+
|
475
|
+
// add placeholder to form input
|
476
|
+
if (['NumberInput', 'EmailInput', 'TextInput', 'PhoneNumber', 'TextArea', 'DatePicker'].indexOf(element) !== -1) {
|
477
|
+
elementOptions.showPlaceholder = true;
|
478
|
+
}
|
479
|
+
if (item.type === 'custom') {
|
480
|
+
elementOptions.key = item.key;
|
481
|
+
elementOptions.custom = true;
|
482
|
+
elementOptions.forwardRef = item.forwardRef;
|
483
|
+
elementOptions.bare = item.bare;
|
484
|
+
elementOptions.props = item.props;
|
485
|
+
elementOptions.component = item.component || null;
|
486
|
+
elementOptions.custom_options = item.custom_options || [];
|
487
|
+
}
|
488
|
+
if (item["static"]) {
|
489
|
+
elementOptions.bold = false;
|
490
|
+
elementOptions.italic = false;
|
491
|
+
}
|
492
|
+
elementOptions.show_custom_name = item.show_custom_name;
|
493
|
+
elementOptions.custom_name = item.custom_name;
|
494
|
+
if (item.canHaveAnswer) {
|
495
|
+
elementOptions.canHaveAnswer = item.canHaveAnswer;
|
496
|
+
}
|
497
|
+
if (item.canReadOnly) {
|
498
|
+
elementOptions.readOnly = false;
|
499
|
+
}
|
500
|
+
if (item.canDefaultToday) {
|
501
|
+
elementOptions.defaultToday = false;
|
502
|
+
}
|
503
|
+
if (item.content) {
|
504
|
+
elementOptions.content = item.content;
|
505
|
+
}
|
506
|
+
if (item.href) {
|
507
|
+
elementOptions.href = item.href;
|
508
|
+
}
|
509
|
+
if (item.inherited !== undefined) {
|
510
|
+
elementOptions.inherited = item.inherited;
|
511
|
+
}
|
512
|
+
elementOptions.canHavePageBreakBefore = item.canHavePageBreakBefore !== false;
|
513
|
+
elementOptions.canHaveAlternateForm = item.canHaveAlternateForm !== false;
|
514
|
+
elementOptions.canHaveDisplayHorizontal = item.canHaveDisplayHorizontal !== false;
|
515
|
+
if (elementOptions.canHaveDisplayHorizontal) {
|
516
|
+
elementOptions.inline = item.inline;
|
517
|
+
}
|
518
|
+
elementOptions.canHaveOptionCorrect = item.canHaveOptionCorrect !== false;
|
519
|
+
elementOptions.canHaveOptionValue = item.canHaveOptionValue !== false;
|
520
|
+
elementOptions.canPopulateFromApi = item.canPopulateFromApi !== false;
|
521
|
+
if (item.class_name) {
|
522
|
+
elementOptions.class_name = item.class_name;
|
523
|
+
}
|
524
|
+
if (element === 'Image') {
|
525
|
+
elementOptions.src = item.src;
|
526
|
+
}
|
527
|
+
if (element === 'DatePicker') {
|
528
|
+
elementOptions.dateFormat = item.dateFormat;
|
529
|
+
elementOptions.timeFormat = item.timeFormat;
|
530
|
+
elementOptions.showTimeSelect = item.showTimeSelect;
|
531
|
+
elementOptions.showTimeSelectOnly = item.showTimeSelectOnly;
|
532
|
+
elementOptions.showTimeInput = item.showTimeInput;
|
533
|
+
}
|
534
|
+
if (element === 'Download') {
|
535
|
+
elementOptions._href = item._href;
|
536
|
+
elementOptions.file_path = item.file_path;
|
537
|
+
}
|
538
|
+
if (element === 'Range') {
|
539
|
+
elementOptions.step = item.step;
|
540
|
+
elementOptions.default_value = item.default_value;
|
541
|
+
elementOptions.min_value = item.min_value;
|
542
|
+
elementOptions.max_value = item.max_value;
|
543
|
+
elementOptions.min_label = item.min_label;
|
544
|
+
elementOptions.max_label = item.max_label;
|
545
|
+
}
|
546
|
+
if (element === 'MultiColumnRow') {
|
547
|
+
elementOptions.col_count = item.col_count;
|
548
|
+
}
|
549
|
+
if (item.defaultValue) {
|
550
|
+
elementOptions.defaultValue = item.defaultValue;
|
551
|
+
}
|
552
|
+
if (item.field_name) {
|
553
|
+
elementOptions.field_name = item.field_name + _UUID["default"].uuid();
|
554
|
+
}
|
555
|
+
if (item.label) {
|
556
|
+
elementOptions.label = item.label;
|
557
|
+
}
|
558
|
+
if (item.options) {
|
559
|
+
if (item.options.length > 0) {
|
560
|
+
elementOptions.options = item.options.map(function (x) {
|
561
|
+
return _objectSpread(_objectSpread({}, x), {}, {
|
562
|
+
key: "custom_option_".concat(_UUID["default"].uuid())
|
563
|
+
});
|
564
|
+
});
|
565
|
+
} else {
|
566
|
+
elementOptions.options = Toolbar._defaultItemOptions(elementOptions.element, intl);
|
567
|
+
}
|
568
|
+
}
|
569
|
+
return elementOptions;
|
570
|
+
}
|
571
|
+
}, {
|
572
|
+
key: "_onClick",
|
573
|
+
value: function _onClick(item) {
|
574
|
+
// ElementActions.createElement(this.create(item));
|
575
|
+
_store["default"].dispatch('create', this.create(item));
|
576
|
+
}
|
577
|
+
}, {
|
578
|
+
key: "render",
|
579
|
+
value: function render() {
|
580
|
+
var _this3 = this;
|
581
|
+
var _buildGroupItems = buildGroupItems(this.state.items),
|
582
|
+
items = _buildGroupItems.items,
|
583
|
+
grouped = _buildGroupItems.grouped,
|
584
|
+
groupKeys = _buildGroupItems.groupKeys;
|
585
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
586
|
+
className: "col-md-3 react-survey-builder-toolbar float-end"
|
587
|
+
}, /*#__PURE__*/_react["default"].createElement("h4", null, this.props.intl.formatMessage({
|
588
|
+
id: 'toolbox'
|
589
|
+
})), /*#__PURE__*/_react["default"].createElement("ul", null, items.map(this.renderItem), groupKeys.map(function (k) {
|
590
|
+
return /*#__PURE__*/_react["default"].createElement(_toolbarGroupItem["default"], {
|
591
|
+
key: k,
|
592
|
+
name: k,
|
593
|
+
group: grouped.get(k),
|
594
|
+
renderItem: _this3.renderItem
|
595
|
+
});
|
596
|
+
})));
|
597
|
+
}
|
598
|
+
}], [{
|
599
|
+
key: "_defaultItemOptions",
|
600
|
+
value: function _defaultItemOptions(element, intl) {
|
601
|
+
switch (element) {
|
602
|
+
case 'Dropdown':
|
603
|
+
return [{
|
604
|
+
value: 'place_holder_option_1',
|
605
|
+
text: intl.formatMessage({
|
606
|
+
id: 'place-holder-option-1'
|
607
|
+
}),
|
608
|
+
key: "dropdown_option_".concat(_UUID["default"].uuid())
|
609
|
+
}, {
|
610
|
+
value: 'place_holder_option_2',
|
611
|
+
text: intl.formatMessage({
|
612
|
+
id: 'place-holder-option-2'
|
613
|
+
}),
|
614
|
+
key: "dropdown_option_".concat(_UUID["default"].uuid())
|
615
|
+
}, {
|
616
|
+
value: 'place_holder_option_3',
|
617
|
+
text: intl.formatMessage({
|
618
|
+
id: 'place-holder-option-3'
|
619
|
+
}),
|
620
|
+
key: "dropdown_option_".concat(_UUID["default"].uuid())
|
621
|
+
}];
|
622
|
+
case 'Tags':
|
623
|
+
return [{
|
624
|
+
value: 'place_holder_tag_1',
|
625
|
+
text: intl.formatMessage({
|
626
|
+
id: 'place-holder-tag-1'
|
627
|
+
}),
|
628
|
+
key: "tags_option_".concat(_UUID["default"].uuid())
|
629
|
+
}, {
|
630
|
+
value: 'place_holder_tag_2',
|
631
|
+
text: intl.formatMessage({
|
632
|
+
id: 'place-holder-tag-2'
|
633
|
+
}),
|
634
|
+
key: "tags_option_".concat(_UUID["default"].uuid())
|
635
|
+
}, {
|
636
|
+
value: 'place_holder_tag_3',
|
637
|
+
text: intl.formatMessage({
|
638
|
+
id: 'place-holder-tag-3'
|
639
|
+
}),
|
640
|
+
key: "tags_option_".concat(_UUID["default"].uuid())
|
641
|
+
}];
|
642
|
+
case 'Checkboxes':
|
643
|
+
return [{
|
644
|
+
value: 'place_holder_option_1',
|
645
|
+
text: intl.formatMessage({
|
646
|
+
id: 'place-holder-option-1'
|
647
|
+
}),
|
648
|
+
key: "checkboxes_option_".concat(_UUID["default"].uuid())
|
649
|
+
}
|
650
|
+
// { value: 'place_holder_option_2', text: intl.formatMessage({ id: 'place-holder-option-2' }), key: `checkboxes_option_${ID.uuid()}` },
|
651
|
+
// { value: 'place_holder_option_3', text: intl.formatMessage({ id: 'place-holder-option-3' }), key: `checkboxes_option_${ID.uuid()}` },
|
652
|
+
];
|
653
|
+
case 'RadioButtons':
|
654
|
+
return [{
|
655
|
+
value: 'place_holder_option_1',
|
656
|
+
text: intl.formatMessage({
|
657
|
+
id: 'place-holder-option-1'
|
658
|
+
}),
|
659
|
+
key: "radiobuttons_option_".concat(_UUID["default"].uuid())
|
660
|
+
}, {
|
661
|
+
value: 'place_holder_option_2',
|
662
|
+
text: intl.formatMessage({
|
663
|
+
id: 'place-holder-option-2'
|
664
|
+
}),
|
665
|
+
key: "radiobuttons_option_".concat(_UUID["default"].uuid())
|
666
|
+
}, {
|
667
|
+
value: 'place_holder_option_3',
|
668
|
+
text: intl.formatMessage({
|
669
|
+
id: 'place-holder-option-3'
|
670
|
+
}),
|
671
|
+
key: "radiobuttons_option_".concat(_UUID["default"].uuid())
|
672
|
+
}];
|
673
|
+
default:
|
674
|
+
return [];
|
675
|
+
}
|
676
|
+
}
|
677
|
+
}]);
|
678
|
+
return Toolbar;
|
679
|
+
}(_react["default"].Component);
|
680
|
+
var _default = exports["default"] = (0, _reactIntl.injectIntl)(Toolbar);
|