react-survey-builder 1.0.72 → 1.0.74
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 +129 -122
- 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/sortable-element.js
CHANGED
@@ -44,6 +44,9 @@ var cardTarget = {
|
|
44
44
|
var item = monitor.getItem();
|
45
45
|
var hoverIndex = props.index;
|
46
46
|
var dragIndex = item.index;
|
47
|
+
|
48
|
+
// console.log('drop', props, hoverIndex, dragIndex, item);
|
49
|
+
|
47
50
|
if (props.item && props.item.isContainer || item.itemType === ItemTypes.CARD) {
|
48
51
|
// console.log('cardTarget - Drop', item.itemType);
|
49
52
|
return;
|
@@ -58,6 +61,9 @@ var cardTarget = {
|
|
58
61
|
hover: function hover(props, monitor, component) {
|
59
62
|
var _props$item, _item$item;
|
60
63
|
var item = monitor.getItem();
|
64
|
+
|
65
|
+
// console.log('hover', props, item);
|
66
|
+
|
61
67
|
if (item.itemType === ItemTypes.BOX && item.index === -1) return;
|
62
68
|
|
63
69
|
// Don't replace multi-column component unless both drag & hover are multi-column
|
@@ -71,11 +77,13 @@ var cardTarget = {
|
|
71
77
|
}
|
72
78
|
if (dragIndex === -1) {
|
73
79
|
if (props.item && props.item.isContainer) {
|
80
|
+
// console.log('hover over container');
|
74
81
|
return;
|
75
82
|
}
|
76
83
|
// console.log('CARD', item);
|
77
84
|
item.index = hoverIndex;
|
78
85
|
props.insertCard(item.onCreate(item.item), hoverIndex);
|
86
|
+
return; // fixed bug where cards were getting wiped out when you dragged another card over a card to insert it. card should be inserted, not replacing existing cards. If an existing card should be removed, the remove button should be used
|
79
87
|
}
|
80
88
|
|
81
89
|
// Determine rectangle on screen
|
@@ -131,6 +139,7 @@ export default function (ComposedComponent) {
|
|
131
139
|
value: function render() {
|
132
140
|
var _this$props = this.props,
|
133
141
|
isDragging = _this$props.isDragging,
|
142
|
+
connectDragSource = _this$props.connectDragSource,
|
134
143
|
connectDragPreview = _this$props.connectDragPreview,
|
135
144
|
connectDropTarget = _this$props.connectDropTarget;
|
136
145
|
var opacity = isDragging ? 0 : 1;
|
@@ -1,9 +1,34 @@
|
|
1
1
|
import SortableElement from './sortable-element';
|
2
2
|
import PlaceHolder from './survey-place-holder';
|
3
|
-
import
|
3
|
+
import BaseSurveyElements from './survey-elements';
|
4
4
|
import { TwoColumnRow, ThreeColumnRow, MultiColumnRow } from './multi-column';
|
5
|
-
import FieldSet from './fieldset';
|
5
|
+
import { FieldSet } from './fieldset';
|
6
|
+
import { Step } from './step';
|
6
7
|
import CustomElement from './survey-elements/custom-element';
|
8
|
+
var Header = BaseSurveyElements.Header,
|
9
|
+
Paragraph = BaseSurveyElements.Paragraph,
|
10
|
+
ContentBody = BaseSurveyElements.ContentBody,
|
11
|
+
Label = BaseSurveyElements.Label,
|
12
|
+
LineBreak = BaseSurveyElements.LineBreak,
|
13
|
+
TextInput = BaseSurveyElements.TextInput,
|
14
|
+
EmailInput = BaseSurveyElements.EmailInput,
|
15
|
+
PhoneNumber = BaseSurveyElements.PhoneNumber,
|
16
|
+
NumberInput = BaseSurveyElements.NumberInput,
|
17
|
+
TextArea = BaseSurveyElements.TextArea,
|
18
|
+
Dropdown = BaseSurveyElements.Dropdown,
|
19
|
+
Checkboxes = BaseSurveyElements.Checkboxes,
|
20
|
+
DatePicker = BaseSurveyElements.DatePicker,
|
21
|
+
RadioButtons = BaseSurveyElements.RadioButtons,
|
22
|
+
Image = BaseSurveyElements.Image,
|
23
|
+
Rating = BaseSurveyElements.Rating,
|
24
|
+
Tags = BaseSurveyElements.Tags,
|
25
|
+
Signature = BaseSurveyElements.Signature,
|
26
|
+
HyperLink = BaseSurveyElements.HyperLink,
|
27
|
+
Download = BaseSurveyElements.Download,
|
28
|
+
Camera = BaseSurveyElements.Camera,
|
29
|
+
Range = BaseSurveyElements.Range,
|
30
|
+
FileUpload = BaseSurveyElements.FileUpload,
|
31
|
+
Checkbox = BaseSurveyElements.Checkbox;
|
7
32
|
var SortableFormElements = {};
|
8
33
|
SortableFormElements.Header = SortableElement(Header);
|
9
34
|
SortableFormElements.Paragraph = SortableElement(Paragraph);
|
@@ -34,5 +59,6 @@ SortableFormElements.FieldSet = SortableElement(FieldSet);
|
|
34
59
|
SortableFormElements.TwoColumnRow = SortableElement(TwoColumnRow);
|
35
60
|
SortableFormElements.ThreeColumnRow = SortableElement(ThreeColumnRow);
|
36
61
|
SortableFormElements.MultiColumnRow = SortableElement(MultiColumnRow);
|
62
|
+
SortableFormElements.Step = SortableElement(Step);
|
37
63
|
SortableFormElements.CustomElement = SortableElement(CustomElement);
|
38
64
|
export default SortableFormElements;
|
package/lib/step/Step.js
ADDED
@@ -0,0 +1,147 @@
|
|
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
|
+
var _excluded = ["item", "controls", "items", "answers", "editModeOn", "getItemById", "setAsChild", "removeChild", "seq", "index", "style"];
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
4
|
+
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; }
|
5
|
+
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; }
|
6
|
+
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; }
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
8
|
+
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); }
|
9
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
10
|
+
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."); }
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
14
|
+
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."); }
|
15
|
+
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); }
|
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
|
+
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; } }
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
19
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
21
|
+
/* eslint-disable camelcase */
|
22
|
+
import React from "react";
|
23
|
+
import ComponentHeader from "../survey-elements/component-header";
|
24
|
+
import FieldsetDustbin from '../multi-column/dustbin';
|
25
|
+
import ItemTypes from "../ItemTypes";
|
26
|
+
import { Col, Container, Row } from "react-bootstrap";
|
27
|
+
import { isListNotEmpty, isObjectNotEmpty } from "../utils/objectUtils";
|
28
|
+
var accepts = [ItemTypes.BOX, ItemTypes.CARD];
|
29
|
+
var StepBase = function StepBase(_ref) {
|
30
|
+
var _item$conditional;
|
31
|
+
var item = _ref.item,
|
32
|
+
controls = _ref.controls,
|
33
|
+
items = _ref.items,
|
34
|
+
answers = _ref.answers,
|
35
|
+
editModeOn = _ref.editModeOn,
|
36
|
+
getItemById = _ref.getItemById,
|
37
|
+
setAsChild = _ref.setAsChild,
|
38
|
+
removeChild = _ref.removeChild,
|
39
|
+
seq = _ref.seq,
|
40
|
+
index = _ref.index,
|
41
|
+
style = _ref.style,
|
42
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
43
|
+
var pageBreakBefore = item.pageBreakBefore;
|
44
|
+
var baseClasses = "SortableItem rfb-item";
|
45
|
+
if (pageBreakBefore) {
|
46
|
+
baseClasses += " alwaysbreak";
|
47
|
+
}
|
48
|
+
var _React$useState = React.useState((_item$conditional = item === null || item === void 0 ? void 0 : item.conditional) !== null && _item$conditional !== void 0 ? _item$conditional : false),
|
49
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
50
|
+
hidden = _React$useState2[0],
|
51
|
+
setHidden = _React$useState2[1];
|
52
|
+
var _React$useState3 = React.useState(isObjectNotEmpty(item) && isListNotEmpty(item === null || item === void 0 ? void 0 : item.childItems) ? _toConsumableArray(item === null || item === void 0 ? void 0 : item.childItems) : [null]),
|
53
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
54
|
+
childItemIds = _React$useState4[0],
|
55
|
+
setChildItemIds = _React$useState4[1];
|
56
|
+
var _onDropSuccess = function onDropSuccess(droppedIndex) {
|
57
|
+
// let updatedItem = isObjectNotEmpty(item) ? { ...item } : {};
|
58
|
+
// let existingChildItemIds = isListNotEmpty(updatedItem.childItems) ? [...updatedItem.childItems] : [null];
|
59
|
+
// const isLastChild = existingChildItemIds === (droppedIndex + 1);
|
60
|
+
// console.log('onDropSuccess', droppedIndex, existingChildItemIds, childItemIds, item, isLastChild);
|
61
|
+
|
62
|
+
// if (isLastChild) {
|
63
|
+
// let updatedChildItemIds = Array.from({ length: existingChildItemIds.length + 1 }, (v, i) => { return existingChildItemIds[i] ? existingChildItemIds[i] : null });
|
64
|
+
// setChildItemIds(updatedChildItemIds);
|
65
|
+
// }
|
66
|
+
};
|
67
|
+
React.useEffect(function () {
|
68
|
+
if (isObjectNotEmpty(item) && isListNotEmpty(item === null || item === void 0 ? void 0 : item.childItems)) {
|
69
|
+
setChildItemIds([].concat(_toConsumableArray(item === null || item === void 0 ? void 0 : item.childItems), [null]));
|
70
|
+
} else {
|
71
|
+
setChildItemIds([null]);
|
72
|
+
}
|
73
|
+
}, [item]);
|
74
|
+
React.useEffect(function () {
|
75
|
+
// console.log('all items', items);
|
76
|
+
var hideStep = false;
|
77
|
+
if ((item === null || item === void 0 ? void 0 : item.conditional) === true) {
|
78
|
+
hideStep = true;
|
79
|
+
if (item.conditionalFieldName && item.conditionalFieldValue && answers !== undefined && answers !== null && answers.length > 0) {
|
80
|
+
var answerField = answers.find(function (i) {
|
81
|
+
return i.name === item.conditionalFieldName;
|
82
|
+
});
|
83
|
+
if (answerField !== undefined && (answerField === null || answerField === void 0 ? void 0 : answerField.value) !== undefined) {
|
84
|
+
if (Array.isArray(item.conditionalFieldValue)) {
|
85
|
+
if (Array.isArray(answerField === null || answerField === void 0 ? void 0 : answerField.value)) {
|
86
|
+
var match = item.conditionalFieldValue.some(function (i) {
|
87
|
+
return answerField.value.includes(i);
|
88
|
+
});
|
89
|
+
if (match) {
|
90
|
+
hideStep = false;
|
91
|
+
}
|
92
|
+
} else if (item.conditionalFieldValue.includes(answerField.value)) {
|
93
|
+
hideStep = false;
|
94
|
+
}
|
95
|
+
} else {
|
96
|
+
if (Array.isArray(answerField === null || answerField === void 0 ? void 0 : answerField.value)) {
|
97
|
+
var _match = answerField.value.includes(item.conditionalFieldValue);
|
98
|
+
if (_match) {
|
99
|
+
hideStep = false;
|
100
|
+
}
|
101
|
+
} else if (item.conditionalFieldValue === answerField.value) {
|
102
|
+
hideStep = false;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
setHidden(hideStep);
|
109
|
+
}, [item, answers]);
|
110
|
+
return /*#__PURE__*/React.createElement("div", {
|
111
|
+
style: _objectSpread({}, style),
|
112
|
+
className: baseClasses
|
113
|
+
}, /*#__PURE__*/React.createElement(ComponentHeader, _extends({
|
114
|
+
item: item,
|
115
|
+
index: index,
|
116
|
+
editModeOn: editModeOn,
|
117
|
+
setAsChild: setAsChild
|
118
|
+
}, otherProps)), /*#__PURE__*/React.createElement("fieldset", {
|
119
|
+
className: hidden ? 'w-100 d-none' : 'w-100'
|
120
|
+
}, childItemIds === null || childItemIds === void 0 ? void 0 : childItemIds.map(function (childItemId, childItemIndex) {
|
121
|
+
return /*#__PURE__*/React.createElement("div", {
|
122
|
+
key: "".concat(childItemIndex, "_").concat(childItemId || "_")
|
123
|
+
}, controls ? controls[childItemIndex] : /*#__PURE__*/React.createElement(FieldsetDustbin, {
|
124
|
+
style: {
|
125
|
+
width: "100%"
|
126
|
+
},
|
127
|
+
item: item,
|
128
|
+
accepts: accepts,
|
129
|
+
items: childItemIds,
|
130
|
+
key: childItemIndex,
|
131
|
+
col: childItemIndex,
|
132
|
+
onDropSuccess: function onDropSuccess() {
|
133
|
+
_onDropSuccess(childItemIndex);
|
134
|
+
},
|
135
|
+
parentIndex: index,
|
136
|
+
editModeOn: editModeOn,
|
137
|
+
_onDestroy: function _onDestroy() {
|
138
|
+
removeChild(item, childItemIndex);
|
139
|
+
},
|
140
|
+
getItemById: getItemById,
|
141
|
+
setAsChild: setAsChild,
|
142
|
+
seq: seq,
|
143
|
+
rowNo: childItemIndex
|
144
|
+
}));
|
145
|
+
})));
|
146
|
+
};
|
147
|
+
export default StepBase;
|
@@ -11,9 +11,7 @@ var layerStyles = {
|
|
11
11
|
width: '100%',
|
12
12
|
height: '100%'
|
13
13
|
};
|
14
|
-
var getItemStyles = function getItemStyles(
|
15
|
-
var initialOffset = _ref.initialOffset,
|
16
|
-
currentOffset = _ref.currentOffset;
|
14
|
+
var getItemStyles = function getItemStyles(initialOffset, currentOffset) {
|
17
15
|
if (!initialOffset || !currentOffset) {
|
18
16
|
return {
|
19
17
|
display: 'none'
|
@@ -27,24 +25,31 @@ var getItemStyles = function getItemStyles(_ref) {
|
|
27
25
|
WebkitTransform: transform
|
28
26
|
};
|
29
27
|
};
|
30
|
-
var CustomDragLayer = function CustomDragLayer(
|
28
|
+
var CustomDragLayer = function CustomDragLayer(_ref) {
|
29
|
+
var itemType = _ref.itemType,
|
30
|
+
item = _ref.item,
|
31
|
+
_ref$isDragging = _ref.isDragging,
|
32
|
+
isDragging = _ref$isDragging === void 0 ? false : _ref$isDragging,
|
33
|
+
initialOffset = _ref.initialOffset,
|
34
|
+
currentOffset = _ref.currentOffset;
|
31
35
|
var renderItem = function renderItem() {
|
32
|
-
switch (
|
36
|
+
switch (itemType) {
|
33
37
|
case ItemTypes.BOX:
|
34
38
|
return /*#__PURE__*/React.createElement(BoxDragPreview, {
|
35
|
-
item:
|
39
|
+
item: item
|
36
40
|
});
|
37
41
|
default:
|
38
42
|
return null;
|
39
43
|
}
|
40
44
|
};
|
41
|
-
if (!
|
45
|
+
if (!isDragging) {
|
42
46
|
return null;
|
43
47
|
}
|
44
48
|
return /*#__PURE__*/React.createElement("div", {
|
49
|
+
id: "custom-drag-layer",
|
45
50
|
style: layerStyles
|
46
51
|
}, /*#__PURE__*/React.createElement("div", {
|
47
|
-
style: getItemStyles(
|
52
|
+
style: getItemStyles(initialOffset, currentOffset)
|
48
53
|
}, renderItem()));
|
49
54
|
};
|
50
55
|
export default DragLayer(function (monitor) {
|
@@ -7,7 +7,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import React from "react";
|
8
8
|
import { useFormContext } from "react-hook-form";
|
9
9
|
import { ErrorMessage } from '@hookform/error-message';
|
10
|
-
import { Alert } from "react-bootstrap
|
10
|
+
import { Alert } from "react-bootstrap";
|
11
11
|
export var getError = function getError(errors, name) {
|
12
12
|
if (name !== undefined && errors !== undefined) {
|
13
13
|
var obj = errors;
|
@@ -1,25 +1,26 @@
|
|
1
|
-
var _excluded = ["item"];
|
2
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
3
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
4
1
|
import React from 'react';
|
5
2
|
import HeaderBar from './header-bar';
|
6
3
|
var ComponentHeader = function ComponentHeader(_ref) {
|
7
4
|
var item = _ref.item,
|
8
|
-
|
5
|
+
isFieldSet = _ref.isFieldSet,
|
6
|
+
index = _ref.index,
|
7
|
+
editModeOn = _ref.editModeOn,
|
8
|
+
setAsChild = _ref.setAsChild,
|
9
|
+
_onDestroy = _ref._onDestroy,
|
10
|
+
onEdit = _ref.onEdit;
|
9
11
|
if (item !== null && item !== void 0 && item.mutable) {
|
10
12
|
return null;
|
11
13
|
}
|
12
14
|
return /*#__PURE__*/React.createElement("div", null, (item === null || item === void 0 ? void 0 : item.pageBreakBefore) && /*#__PURE__*/React.createElement("div", {
|
13
15
|
className: "preview-page-break"
|
14
16
|
}, "Page Break"), /*#__PURE__*/React.createElement(HeaderBar, {
|
15
|
-
isFieldSet:
|
16
|
-
|
17
|
-
editModeOn: props.editModeOn,
|
17
|
+
isFieldSet: isFieldSet,
|
18
|
+
editModeOn: editModeOn,
|
18
19
|
item: item,
|
19
|
-
index:
|
20
|
-
setAsChild:
|
21
|
-
onDestroy:
|
22
|
-
onEdit:
|
20
|
+
index: index,
|
21
|
+
setAsChild: setAsChild,
|
22
|
+
onDestroy: _onDestroy,
|
23
|
+
onEdit: onEdit,
|
23
24
|
"static": item === null || item === void 0 ? void 0 : item["static"],
|
24
25
|
required: item === null || item === void 0 ? void 0 : item.required
|
25
26
|
}));
|
@@ -1,77 +1,66 @@
|
|
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
|
+
var _excluded = ["item", "defaultValue", "style"];
|
2
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3
4
|
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; }
|
4
5
|
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; }
|
5
6
|
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; }
|
6
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
7
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
8
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
9
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
10
8
|
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
|
12
|
-
function
|
13
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
14
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
15
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
16
|
-
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); }
|
17
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
10
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
18
11
|
import React from 'react';
|
19
12
|
import ComponentHeader from './component-header';
|
20
13
|
import ComponentLabel from './component-label';
|
21
|
-
import { Form } from 'react-bootstrap
|
14
|
+
import { Form } from 'react-bootstrap';
|
22
15
|
import ComponentErrorMessage from './component-error-message';
|
23
|
-
var CustomElement =
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
var CustomElement = function CustomElement(_ref) {
|
17
|
+
var _item$fieldName;
|
18
|
+
var item = _ref.item,
|
19
|
+
defaultValue = _ref.defaultValue,
|
20
|
+
style = _ref.style,
|
21
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
22
|
+
var inputField = React.useRef();
|
23
|
+
var inputProps = {
|
24
|
+
name: (_item$fieldName = item.fieldName) !== null && _item$fieldName !== void 0 ? _item$fieldName : item.name,
|
25
|
+
defaultValue: defaultValue
|
26
|
+
};
|
27
|
+
if (item.forwardRef) {
|
28
|
+
inputProps.ref = inputField;
|
29
|
+
}
|
30
|
+
if (item.disabled) {
|
31
|
+
inputProps.disabled = true;
|
30
32
|
}
|
31
|
-
_inherits(CustomElement, _React$Component);
|
32
|
-
return _createClass(CustomElement, [{
|
33
|
-
key: "render",
|
34
|
-
value: function render() {
|
35
|
-
var bare = this.props.item.bare;
|
36
|
-
var props = {};
|
37
|
-
props.name = this.props.item.fieldName;
|
38
|
-
props.defaultValue = this.props.defaultValue;
|
39
|
-
if (this.props.item.forwardRef) {
|
40
|
-
props.ref = this.inputField;
|
41
|
-
}
|
42
|
-
if (this.props.item.disabled) {
|
43
|
-
props.disabled = 'disabled';
|
44
|
-
}
|
45
33
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
34
|
+
// Return if component is invalid.
|
35
|
+
if (!item.component) return null;
|
36
|
+
var Element = item.component;
|
37
|
+
var baseClasses = 'SortableItem rfb-item';
|
38
|
+
if (item.pageBreakBefore) {
|
39
|
+
baseClasses += ' alwaysbreak';
|
40
|
+
}
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
42
|
+
className: baseClasses,
|
43
|
+
style: _objectSpread({}, style)
|
44
|
+
}, /*#__PURE__*/React.createElement(ComponentHeader, _extends({
|
45
|
+
item: item
|
46
|
+
}, props)), item !== null && item !== void 0 && item.bare ? /*#__PURE__*/React.createElement(Element, _extends({
|
47
|
+
id: inputProps.name,
|
48
|
+
item: item
|
49
|
+
}, item.props, inputProps)) : /*#__PURE__*/React.createElement(Form.Group, {
|
50
|
+
className: "form-group mb-3"
|
51
|
+
}, /*#__PURE__*/React.createElement(ComponentLabel, _extends({
|
52
|
+
className: "form-label",
|
53
|
+
item: item
|
54
|
+
}, props, {
|
55
|
+
htmlFor: inputProps.name
|
56
|
+
})), /*#__PURE__*/React.createElement(Element, _extends({
|
57
|
+
id: inputProps.name,
|
58
|
+
item: item
|
59
|
+
}, item.props, inputProps)), item !== null && item !== void 0 && item.help ? /*#__PURE__*/React.createElement(Form.Text, {
|
60
|
+
muted: true
|
61
|
+
}, item.help) : null, /*#__PURE__*/React.createElement(ComponentErrorMessage, {
|
62
|
+
name: inputProps.name
|
63
|
+
})));
|
64
|
+
};
|
76
65
|
CustomElement.propTypes = {};
|
77
66
|
export default CustomElement;
|
@@ -1,59 +1,40 @@
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
4
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
6
|
-
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); }
|
7
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
8
|
-
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); }
|
9
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
10
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
11
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
12
|
-
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); }
|
13
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
14
|
-
/**
|
15
|
-
* <HeaderBar />
|
16
|
-
*/
|
17
|
-
|
18
1
|
import React from 'react';
|
19
|
-
// import Grip from '../multi-column/grip';
|
20
2
|
import DragHandle from './component-drag-handle';
|
21
3
|
import { FaEdit, FaTrash } from 'react-icons/fa';
|
22
|
-
import { Badge, Button, ButtonToolbar } from 'react-bootstrap
|
23
|
-
var HeaderBar =
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
return
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
className: "is-isolated",
|
41
|
-
onClick: this.props.editModeOn.bind(this.props.parent, this.props.item)
|
42
|
-
}, /*#__PURE__*/React.createElement(FaEdit, {
|
43
|
-
className: "is-isolated"
|
44
|
-
})), /*#__PURE__*/React.createElement(Button, {
|
45
|
-
variant: "default",
|
46
|
-
className: "is-isolated",
|
47
|
-
onClick: this.props.onDestroy.bind(this, this.props.item)
|
48
|
-
}, /*#__PURE__*/React.createElement(FaTrash, {
|
49
|
-
className: "is-isolated"
|
50
|
-
})), /*#__PURE__*/React.createElement(DragHandle, {
|
51
|
-
item: this.props.item,
|
52
|
-
index: this.props.index,
|
53
|
-
onDestroy: this.props.onDestroy,
|
54
|
-
setAsChild: this.props.setAsChild
|
55
|
-
})));
|
4
|
+
import { Badge, Button, ButtonToolbar } from 'react-bootstrap';
|
5
|
+
var HeaderBar = function HeaderBar(_ref) {
|
6
|
+
var item = _ref.item,
|
7
|
+
editModeOn = _ref.editModeOn,
|
8
|
+
onDestroy = _ref.onDestroy,
|
9
|
+
setAsChild = _ref.setAsChild,
|
10
|
+
index = _ref.index;
|
11
|
+
return /*#__PURE__*/React.createElement(ButtonToolbar, {
|
12
|
+
className: "d-flex toolbar-header align-items-center justify-content-between p-2"
|
13
|
+
}, /*#__PURE__*/React.createElement(Badge, {
|
14
|
+
bg: "secondary"
|
15
|
+
}, item.text), /*#__PURE__*/React.createElement("div", {
|
16
|
+
className: "toolbar-header-buttons"
|
17
|
+
}, item.element !== 'LineBreak' && /*#__PURE__*/React.createElement(Button, {
|
18
|
+
variant: "default",
|
19
|
+
className: "is-isolated",
|
20
|
+
onClick: function onClick(e) {
|
21
|
+
editModeOn(item, e);
|
56
22
|
}
|
57
|
-
}
|
58
|
-
|
59
|
-
|
23
|
+
}, /*#__PURE__*/React.createElement(FaEdit, {
|
24
|
+
className: "is-isolated"
|
25
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
26
|
+
variant: "default",
|
27
|
+
className: "is-isolated",
|
28
|
+
onClick: function onClick() {
|
29
|
+
onDestroy(item);
|
30
|
+
}
|
31
|
+
}, /*#__PURE__*/React.createElement(FaTrash, {
|
32
|
+
className: "is-isolated"
|
33
|
+
})), /*#__PURE__*/React.createElement(DragHandle, {
|
34
|
+
item: item,
|
35
|
+
index: index,
|
36
|
+
onDestroy: onDestroy,
|
37
|
+
setAsChild: setAsChild
|
38
|
+
})));
|
39
|
+
};
|
40
|
+
export default HeaderBar;
|