react-survey-builder 1.0.82 → 1.0.84
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 +1 -0
- package/dist/bundle.js +14 -14
- package/lib/fieldset/{FieldSet.js → Fieldset.js} +2 -2
- package/lib/fieldset/index.js +2 -2
- package/lib/form-fields.js +8 -5
- package/lib/form-steps.js +8 -5
- package/lib/form.js +8 -5
- package/lib/index.js +11 -1
- package/lib/multi-column/dustbin.js +13 -7
- package/lib/preview.js +24 -2
- package/lib/sortable-form-elements.js +2 -2
- package/lib/survey-elements/index.js +69 -64
- package/lib/toolbar.js +1 -1
- package/lib/utils/objectUtils.js +6 -0
- package/package.json +1 -1
- package/types/index.d.ts +2 -0
@@ -39,7 +39,7 @@ var ComponentLegend = function ComponentLegend(_ref) {
|
|
39
39
|
}
|
40
40
|
});
|
41
41
|
};
|
42
|
-
var
|
42
|
+
var FieldsetBase = function FieldsetBase(_ref2) {
|
43
43
|
var item = _ref2.item,
|
44
44
|
controls = _ref2.controls,
|
45
45
|
items = _ref2.items,
|
@@ -115,4 +115,4 @@ var FieldSetBase = function FieldSetBase(_ref2) {
|
|
115
115
|
}));
|
116
116
|
})));
|
117
117
|
};
|
118
|
-
export default
|
118
|
+
export default FieldsetBase;
|
package/lib/fieldset/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import
|
2
|
-
export {
|
1
|
+
import Fieldset from './Fieldset';
|
2
|
+
export { Fieldset };
|
package/lib/form-fields.js
CHANGED
@@ -19,7 +19,7 @@ import React from 'react';
|
|
19
19
|
import ReactDOM from 'react-dom';
|
20
20
|
import SurveyElements, { Image, Checkboxes, Signature, Download, Camera, FileUpload, PhoneNumber, DatePicker, TextInput, EmailInput, NumberInput, TextArea, Dropdown, Tags } from './survey-elements';
|
21
21
|
import { TwoColumnRow, ThreeColumnRow, MultiColumnRow } from './multi-column';
|
22
|
-
import {
|
22
|
+
import { Fieldset } from './fieldset';
|
23
23
|
import { Step } from './step';
|
24
24
|
import CustomElement from './survey-elements/custom-element';
|
25
25
|
import Registry from './stores/registry';
|
@@ -49,6 +49,7 @@ var ReactSurveyFormFields = function ReactSurveyFormFields(_ref) {
|
|
49
49
|
_ref$hideLabels = _ref.hideLabels,
|
50
50
|
hideLabels = _ref$hideLabels === void 0 ? false : _ref$hideLabels,
|
51
51
|
variables = _ref.variables,
|
52
|
+
staticVariables = _ref.staticVariables,
|
52
53
|
buttonClassName = _ref.buttonClassName,
|
53
54
|
checkboxButtonClassName = _ref.checkboxButtonClassName,
|
54
55
|
headerClassName = _ref.headerClassName,
|
@@ -281,7 +282,8 @@ var ReactSurveyFormFields = function ReactSurveyFormFields(_ref) {
|
|
281
282
|
name: (_$dataItem$fieldName = $dataItem.fieldName) !== null && _$dataItem$fieldName !== void 0 ? _$dataItem$fieldName : $dataItem.name,
|
282
283
|
key: "form_".concat($dataItem.id),
|
283
284
|
item: $dataItem,
|
284
|
-
|
285
|
+
defaultValue: _getDefaultValue($dataItem),
|
286
|
+
staticVariables: staticVariables
|
285
287
|
});
|
286
288
|
}
|
287
289
|
return null;
|
@@ -296,7 +298,7 @@ var ReactSurveyFormFields = function ReactSurveyFormFields(_ref) {
|
|
296
298
|
name: item.fieldName,
|
297
299
|
key: "form_".concat(item.id),
|
298
300
|
item: item,
|
299
|
-
|
301
|
+
defaultValue: _getDefaultValue(item),
|
300
302
|
onChange: handleChange
|
301
303
|
});
|
302
304
|
};
|
@@ -454,6 +456,7 @@ var ReactSurveyFormFields = function ReactSurveyFormFields(_ref) {
|
|
454
456
|
item.hideLabel = (_ref8 = hideLabels || item.hideLabel) !== null && _ref8 !== void 0 ? _ref8 : false;
|
455
457
|
item.disabled = (_ref9 = readOnly || item.readOnly) !== null && _ref9 !== void 0 ? _ref9 : false;
|
456
458
|
item.mutable = true;
|
459
|
+
item.staticVariables = staticVariables;
|
457
460
|
switch (item.element) {
|
458
461
|
case 'RadioButtons':
|
459
462
|
case 'Range':
|
@@ -479,8 +482,8 @@ var ReactSurveyFormFields = function ReactSurveyFormFields(_ref) {
|
|
479
482
|
return getContainerElement(item, TwoColumnRow);
|
480
483
|
case 'Step':
|
481
484
|
return getContainerElement(item, Step);
|
482
|
-
case '
|
483
|
-
return getContainerElement(item,
|
485
|
+
case 'Fieldset':
|
486
|
+
return getContainerElement(item, Fieldset);
|
484
487
|
case 'Signature':
|
485
488
|
return /*#__PURE__*/React.createElement(Controller, {
|
486
489
|
key: "form_".concat(item.id),
|
package/lib/form-steps.js
CHANGED
@@ -19,7 +19,7 @@ import React from 'react';
|
|
19
19
|
import ReactDOM from 'react-dom';
|
20
20
|
import SurveyElements, { Image, Checkboxes, Signature, Download, Camera, FileUpload, PhoneNumber, DatePicker, TextInput, EmailInput, NumberInput, TextArea, Dropdown, Tags } from './survey-elements';
|
21
21
|
import { TwoColumnRow, ThreeColumnRow, MultiColumnRow } from './multi-column';
|
22
|
-
import {
|
22
|
+
import { Fieldset } from './fieldset';
|
23
23
|
import { Step } from './step';
|
24
24
|
import CustomElement from './survey-elements/custom-element';
|
25
25
|
import Registry from './stores/registry';
|
@@ -50,6 +50,7 @@ var ReactSurveyFormSteps = function ReactSurveyFormSteps(_ref) {
|
|
50
50
|
_ref$hideLabels = _ref.hideLabels,
|
51
51
|
hideLabels = _ref$hideLabels === void 0 ? false : _ref$hideLabels,
|
52
52
|
variables = _ref.variables,
|
53
|
+
staticVariables = _ref.staticVariables,
|
53
54
|
buttonClassName = _ref.buttonClassName,
|
54
55
|
checkboxButtonClassName = _ref.checkboxButtonClassName,
|
55
56
|
headerClassName = _ref.headerClassName,
|
@@ -283,7 +284,8 @@ var ReactSurveyFormSteps = function ReactSurveyFormSteps(_ref) {
|
|
283
284
|
name: (_$dataItem$fieldName = $dataItem.fieldName) !== null && _$dataItem$fieldName !== void 0 ? _$dataItem$fieldName : $dataItem.name,
|
284
285
|
key: "form_".concat($dataItem.id),
|
285
286
|
item: $dataItem,
|
286
|
-
|
287
|
+
defaultValue: _getDefaultValue($dataItem),
|
288
|
+
staticVariables: staticVariables
|
287
289
|
});
|
288
290
|
}
|
289
291
|
return null;
|
@@ -298,7 +300,7 @@ var ReactSurveyFormSteps = function ReactSurveyFormSteps(_ref) {
|
|
298
300
|
name: item.fieldName,
|
299
301
|
key: "form_".concat(item.id),
|
300
302
|
item: item,
|
301
|
-
|
303
|
+
defaultValue: _getDefaultValue(item),
|
302
304
|
onChange: handleChange
|
303
305
|
});
|
304
306
|
};
|
@@ -456,6 +458,7 @@ var ReactSurveyFormSteps = function ReactSurveyFormSteps(_ref) {
|
|
456
458
|
item.hideLabel = (_ref8 = hideLabels || item.hideLabel) !== null && _ref8 !== void 0 ? _ref8 : false;
|
457
459
|
item.disabled = (_ref9 = readOnly || item.readOnly) !== null && _ref9 !== void 0 ? _ref9 : false;
|
458
460
|
item.mutable = true;
|
461
|
+
item.staticVariables = staticVariables;
|
459
462
|
switch (item.element) {
|
460
463
|
case 'RadioButtons':
|
461
464
|
case 'Range':
|
@@ -481,8 +484,8 @@ var ReactSurveyFormSteps = function ReactSurveyFormSteps(_ref) {
|
|
481
484
|
return getContainerElement(item, TwoColumnRow);
|
482
485
|
case 'Step':
|
483
486
|
return getContainerElement(item, Step);
|
484
|
-
case '
|
485
|
-
return getContainerElement(item,
|
487
|
+
case 'Fieldset':
|
488
|
+
return getContainerElement(item, Fieldset);
|
486
489
|
case 'Signature':
|
487
490
|
return /*#__PURE__*/React.createElement(Controller, {
|
488
491
|
key: "form_".concat(item.id),
|
package/lib/form.js
CHANGED
@@ -19,7 +19,7 @@ import React from 'react';
|
|
19
19
|
import ReactDOM from 'react-dom';
|
20
20
|
import SurveyElements, { Image, Checkboxes, Signature, Download, Camera, FileUpload, PhoneNumber, DatePicker, TextInput, EmailInput, NumberInput, TextArea } from './survey-elements';
|
21
21
|
import { TwoColumnRow, ThreeColumnRow, MultiColumnRow } from './multi-column';
|
22
|
-
import {
|
22
|
+
import { Fieldset } from './fieldset';
|
23
23
|
import { Step } from './step';
|
24
24
|
import CustomElement from './survey-elements/custom-element';
|
25
25
|
import Registry from './stores/registry';
|
@@ -49,6 +49,7 @@ var ReactSurvey = function ReactSurvey(_ref) {
|
|
49
49
|
_ref$hideLabels = _ref.hideLabels,
|
50
50
|
hideLabels = _ref$hideLabels === void 0 ? false : _ref$hideLabels,
|
51
51
|
variables = _ref.variables,
|
52
|
+
staticVariables = _ref.staticVariables,
|
52
53
|
buttonClassName = _ref.buttonClassName,
|
53
54
|
checkboxButtonClassName = _ref.checkboxButtonClassName,
|
54
55
|
headerClassName = _ref.headerClassName,
|
@@ -291,7 +292,8 @@ var ReactSurvey = function ReactSurvey(_ref) {
|
|
291
292
|
name: (_$dataItem$fieldName = $dataItem.fieldName) !== null && _$dataItem$fieldName !== void 0 ? _$dataItem$fieldName : $dataItem.name,
|
292
293
|
key: "form_".concat($dataItem.id),
|
293
294
|
item: $dataItem,
|
294
|
-
|
295
|
+
defaultValue: _getDefaultValue($dataItem),
|
296
|
+
staticVariables: staticVariables
|
295
297
|
});
|
296
298
|
}
|
297
299
|
return null;
|
@@ -307,7 +309,7 @@ var ReactSurvey = function ReactSurvey(_ref) {
|
|
307
309
|
name: (_item$fieldName = item.fieldName) !== null && _item$fieldName !== void 0 ? _item$fieldName : item.name,
|
308
310
|
key: "form_".concat(item.id),
|
309
311
|
item: item,
|
310
|
-
|
312
|
+
defaultValue: _getDefaultValue(item),
|
311
313
|
onChange: handleChange
|
312
314
|
});
|
313
315
|
};
|
@@ -465,6 +467,7 @@ var ReactSurvey = function ReactSurvey(_ref) {
|
|
465
467
|
item.hideLabel = (_ref8 = hideLabels || item.hideLabel) !== null && _ref8 !== void 0 ? _ref8 : false;
|
466
468
|
item.disabled = (_ref9 = readOnly || item.readOnly) !== null && _ref9 !== void 0 ? _ref9 : false;
|
467
469
|
item.mutable = true;
|
470
|
+
item.staticVariables = staticVariables;
|
468
471
|
switch (item.element) {
|
469
472
|
case 'RadioButtons':
|
470
473
|
case 'Range':
|
@@ -490,8 +493,8 @@ var ReactSurvey = function ReactSurvey(_ref) {
|
|
490
493
|
return getContainerElement(item, TwoColumnRow);
|
491
494
|
case 'Step':
|
492
495
|
return getContainerElement(item, Step);
|
493
|
-
case '
|
494
|
-
return getContainerElement(item,
|
496
|
+
case 'Fieldset':
|
497
|
+
return getContainerElement(item, Fieldset);
|
495
498
|
case 'Signature':
|
496
499
|
return /*#__PURE__*/React.createElement(Controller, {
|
497
500
|
key: "form_".concat(item.id),
|
package/lib/index.js
CHANGED
@@ -38,6 +38,11 @@ var ReactSurveyBuilder = function ReactSurveyBuilder(_ref) {
|
|
38
38
|
previewSurveyBlock = _ref$previewSurveyBlo === void 0 ? null : _ref$previewSurveyBlo,
|
39
39
|
renderEditForm = _ref.renderEditForm,
|
40
40
|
variables = _ref.variables,
|
41
|
+
staticVariables = _ref.staticVariables,
|
42
|
+
checkboxButtonClassName = _ref.checkboxButtonClassName,
|
43
|
+
headerClassName = _ref.headerClassName,
|
44
|
+
labelClassName = _ref.labelClassName,
|
45
|
+
paragraphClassName = _ref.paragraphClassName,
|
41
46
|
onPost = _ref.onPost,
|
42
47
|
onLoad = _ref.onLoad,
|
43
48
|
url = _ref.url,
|
@@ -78,11 +83,16 @@ var ReactSurveyBuilder = function ReactSurveyBuilder(_ref) {
|
|
78
83
|
editMode: editMode,
|
79
84
|
setEditMode: setEditMode,
|
80
85
|
variables: variables,
|
86
|
+
staticVariables: staticVariables,
|
81
87
|
registry: Registry,
|
82
88
|
editElement: editElement,
|
83
89
|
setEditElement: setEditElement,
|
84
90
|
renderEditForm: renderEditForm,
|
85
|
-
saveAlways: saveAlways
|
91
|
+
saveAlways: saveAlways,
|
92
|
+
checkboxButtonClassName: checkboxButtonClassName,
|
93
|
+
headerClassName: headerClassName,
|
94
|
+
labelClassName: labelClassName,
|
95
|
+
paragraphClassName: paragraphClassName
|
86
96
|
})), /*#__PURE__*/React.createElement(Col, {
|
87
97
|
xs: 3,
|
88
98
|
className: "overflow-hidden h-100"
|
@@ -42,7 +42,7 @@ var getElement = function getElement(item, props) {
|
|
42
42
|
if (item.custom) {
|
43
43
|
return getCustomElement(item, props);
|
44
44
|
}
|
45
|
-
console.log('getDustbinElement', item);
|
45
|
+
// console.log('getDustbinElement', item);
|
46
46
|
var Element = SurveyElements[item.element || item.key];
|
47
47
|
return /*#__PURE__*/React.createElement(Element, _extends({}, props, {
|
48
48
|
id: item.id,
|
@@ -98,7 +98,7 @@ var Dustbin = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
98
98
|
React.useImperativeHandle(ref, function () {
|
99
99
|
return {
|
100
100
|
onDrop: function onDrop(dropped) {
|
101
|
-
console.log("dropped item", dropped);
|
101
|
+
// console.log("dropped item", dropped);
|
102
102
|
var item = dropped.item;
|
103
103
|
if (item) {
|
104
104
|
if (onDropSuccess) {
|
@@ -135,17 +135,18 @@ export default DropTarget(function (props) {
|
|
135
135
|
return props.accepts;
|
136
136
|
}, {
|
137
137
|
drop: function drop(props, monitor, component) {
|
138
|
-
console.log('droptargetprops', props)
|
138
|
+
// console.log('droptargetprops', props)
|
139
139
|
if (!component) {
|
140
140
|
return;
|
141
141
|
}
|
142
142
|
|
143
|
-
// //Do nothing
|
143
|
+
// //Do nothing with busy dustbin
|
144
144
|
// if(props.items[props.col]) return;
|
145
145
|
// Allow swap column if target and source are in same multi column row
|
146
146
|
var isBusy = !!props.items[props.col];
|
147
147
|
var item = monitor.getItem();
|
148
|
-
|
148
|
+
|
149
|
+
// console.log('dustbin', props, item, isBusy);
|
149
150
|
|
150
151
|
// Do nothing when moving the box inside the same column
|
151
152
|
if (props.col === item.col && props.items[props.col] === item.id) return;
|
@@ -157,11 +158,16 @@ export default DropTarget(function (props) {
|
|
157
158
|
//store.dispatch('deleteLastItem');
|
158
159
|
return;
|
159
160
|
}
|
161
|
+
|
162
|
+
// do not allow an existing child to be dropped in the dropzone as it will duplicate the child with the same id for both instances
|
163
|
+
if ((props.item.element === 'Fieldset' || props.item.element === 'Step') && isListNotEmpty(props.item.childItems) && item.col === props.item.childItems.length) {
|
164
|
+
return;
|
165
|
+
}
|
160
166
|
if (!isContainer(item)) {
|
161
167
|
component.onDrop(item);
|
162
|
-
console.log("calling on Drop from 137", item)
|
168
|
+
// console.log("calling on Drop from 137", item)
|
163
169
|
if (item.item && typeof props.setAsChild === 'function') {
|
164
|
-
console.log('setAsChild function being called');
|
170
|
+
// console.log('setAsChild function being called');
|
165
171
|
var isNew = !item.item.id;
|
166
172
|
var $dataItem = isNew ? item.onCreate(item.item) : item.item;
|
167
173
|
props.setAsChild(props.item, $dataItem, isNew, item.index, props.col, isBusy);
|
package/lib/preview.js
CHANGED
@@ -42,6 +42,12 @@ var Preview = function Preview(_ref) {
|
|
42
42
|
setEditElement = _ref.setEditElement,
|
43
43
|
_ref$variables = _ref.variables,
|
44
44
|
variables = _ref$variables === void 0 ? {} : _ref$variables,
|
45
|
+
_ref$staticVariables = _ref.staticVariables,
|
46
|
+
staticVariables = _ref$staticVariables === void 0 ? {} : _ref$staticVariables,
|
47
|
+
checkboxButtonClassName = _ref.checkboxButtonClassName,
|
48
|
+
headerClassName = _ref.headerClassName,
|
49
|
+
labelClassName = _ref.labelClassName,
|
50
|
+
paragraphClassName = _ref.paragraphClassName,
|
45
51
|
url = _ref.url,
|
46
52
|
saveUrl = _ref.saveUrl,
|
47
53
|
_ref$saveAlways = _ref.saveAlways,
|
@@ -137,8 +143,14 @@ var Preview = function Preview(_ref) {
|
|
137
143
|
}
|
138
144
|
if (!(child.col !== undefined && child.col !== col && item.childItems[col])) {
|
139
145
|
// No child was assigned yet in both source and target.
|
146
|
+
console.log('No child was assigned yet in both source and target.');
|
140
147
|
return false;
|
141
148
|
}
|
149
|
+
|
150
|
+
// if ((item.element === 'Fieldset' || item.element === 'Step') && isListNotEmpty(item.childItems) && child.col === item.childItems.length) {
|
151
|
+
// return false;
|
152
|
+
// }
|
153
|
+
|
142
154
|
var oldItems = _toConsumableArray(items);
|
143
155
|
var oldId = item.childItems[col];
|
144
156
|
var oldItem = oldItems.find(function (i) {
|
@@ -167,12 +179,17 @@ var Preview = function Preview(_ref) {
|
|
167
179
|
};
|
168
180
|
var setAsChild = function setAsChild(item, child, childIsNew, childIndex, col, isBusy) {
|
169
181
|
// console.log('saveAsChild', item, child, childIsNew, childIndex, col, isBusy);
|
182
|
+
|
170
183
|
if (swapChildren(item, child, col)) {
|
171
184
|
return;
|
172
185
|
}
|
173
186
|
if (isBusy) {
|
174
187
|
return;
|
175
188
|
}
|
189
|
+
if (isListNotEmpty(item.childItems) && child.col !== undefined && col === item.childItems.length) {
|
190
|
+
// console.log('Cannot drop in the dropzone');
|
191
|
+
return;
|
192
|
+
}
|
176
193
|
var oldItems = _toConsumableArray(items);
|
177
194
|
|
178
195
|
// eslint-disable-next-line no-param-reassign
|
@@ -247,7 +264,7 @@ var Preview = function Preview(_ref) {
|
|
247
264
|
var updatedItem = _objectSpread({}, item);
|
248
265
|
// for multi-column containers, set back to null
|
249
266
|
// for fieldsets and steps, delete it
|
250
|
-
if (updatedItem.element === '
|
267
|
+
if (updatedItem.element === 'Fieldset' || updatedItem.element === 'Step') {
|
251
268
|
updatedItem.childItems.splice(col, 1);
|
252
269
|
} else {
|
253
270
|
updatedItem.childItems[col] = null;
|
@@ -275,7 +292,7 @@ var Preview = function Preview(_ref) {
|
|
275
292
|
|
276
293
|
// for multi-column containers, set back to null
|
277
294
|
// for fieldsets and steps, delete it
|
278
|
-
if (updatedParent.element === '
|
295
|
+
if (updatedParent.element === 'Fieldset' || updatedParent.element === 'Step') {
|
279
296
|
updatedParent.childItems.splice(oldItem.col, 1);
|
280
297
|
} else {
|
281
298
|
updatedParent.childItems[oldItem.col] = null;
|
@@ -348,6 +365,11 @@ var Preview = function Preview(_ref) {
|
|
348
365
|
key: item.id,
|
349
366
|
sortData: item.id,
|
350
367
|
item: _objectSpread(_objectSpread({}, item), {}, {
|
368
|
+
staticVariables: staticVariables,
|
369
|
+
checkboxButtonClassName: checkboxButtonClassName,
|
370
|
+
headerClassName: headerClassName,
|
371
|
+
labelClassName: labelClassName,
|
372
|
+
paragraphClassName: paragraphClassName,
|
351
373
|
mutable: false,
|
352
374
|
readOnly: false,
|
353
375
|
print: false
|
@@ -2,7 +2,7 @@ import SortableElement from './sortable-element';
|
|
2
2
|
import PlaceHolder from './survey-place-holder';
|
3
3
|
import BaseSurveyElements from './survey-elements';
|
4
4
|
import { TwoColumnRow, ThreeColumnRow, MultiColumnRow } from './multi-column';
|
5
|
-
import {
|
5
|
+
import { Fieldset } from './fieldset';
|
6
6
|
import { Step } from './step';
|
7
7
|
import CustomElement from './survey-elements/custom-element';
|
8
8
|
var Header = BaseSurveyElements.Header,
|
@@ -55,7 +55,7 @@ SortableFormElements.Camera = SortableElement(Camera);
|
|
55
55
|
SortableFormElements.FileUpload = SortableElement(FileUpload);
|
56
56
|
SortableFormElements.Range = SortableElement(Range);
|
57
57
|
SortableFormElements.PlaceHolder = SortableElement(PlaceHolder);
|
58
|
-
SortableFormElements.
|
58
|
+
SortableFormElements.Fieldset = SortableElement(Fieldset);
|
59
59
|
SortableFormElements.TwoColumnRow = SortableElement(TwoColumnRow);
|
60
60
|
SortableFormElements.ThreeColumnRow = SortableElement(ThreeColumnRow);
|
61
61
|
SortableFormElements.MultiColumnRow = SortableElement(MultiColumnRow);
|