react-survey-builder 1.0.71 → 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 +45 -16
- package/lib/form-steps.js +793 -0
- package/lib/form.js +47 -17
- 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
@@ -1,119 +1,108 @@
|
|
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", "className"],
|
2
|
+
var _excluded = ["controls", "item", "items", "editModeOn", "getItemById", "setAsChild", "removeChild", "seq", "className", "index", "style"],
|
3
3
|
_excluded2 = ["item", "className"],
|
4
|
-
_excluded3 = ["item"]
|
4
|
+
_excluded3 = ["item", "className"],
|
5
|
+
_excluded4 = ["item"];
|
5
6
|
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); }
|
6
|
-
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; }
|
7
|
-
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; }
|
8
7
|
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; }
|
9
8
|
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; }
|
10
9
|
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; }
|
11
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
12
|
-
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); } }
|
13
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
14
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
15
11
|
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); }
|
16
|
-
function
|
17
|
-
function
|
18
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
19
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
20
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
21
|
-
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); }
|
22
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
12
|
+
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; }
|
13
|
+
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; }
|
23
14
|
/* eslint-disable camelcase */
|
24
15
|
import React from 'react';
|
25
16
|
import ComponentHeader from '../survey-elements/component-header';
|
26
17
|
import ComponentLabel from '../survey-elements/component-label';
|
27
18
|
import Dustbin from './dustbin';
|
28
19
|
import ItemTypes from '../ItemTypes';
|
29
|
-
import { Row } from 'react-bootstrap
|
20
|
+
import { Row } from 'react-bootstrap';
|
30
21
|
var accepts = [ItemTypes.BOX, ItemTypes.CARD];
|
31
|
-
var MultiColumnRowBase =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
var _this$props = this.props,
|
41
|
-
controls = _this$props.controls,
|
42
|
-
item = _this$props.item,
|
43
|
-
editModeOn = _this$props.editModeOn,
|
44
|
-
getItemById = _this$props.getItemById,
|
45
|
-
setAsChild = _this$props.setAsChild,
|
46
|
-
removeChild = _this$props.removeChild,
|
47
|
-
seq = _this$props.seq,
|
48
|
-
className = _this$props.className,
|
49
|
-
index = _this$props.index;
|
50
|
-
var childItems = item.childItems,
|
51
|
-
pageBreakBefore = item.pageBreakBefore;
|
52
|
-
var baseClasses = 'SortableItem rfb-item';
|
53
|
-
if (pageBreakBefore) {
|
54
|
-
baseClasses += ' alwaysbreak';
|
55
|
-
}
|
56
|
-
return /*#__PURE__*/React.createElement("div", {
|
57
|
-
style: _objectSpread({}, this.props.style),
|
58
|
-
className: baseClasses
|
59
|
-
}, /*#__PURE__*/React.createElement(ComponentHeader, this.props), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ComponentLabel, this.props), /*#__PURE__*/React.createElement(Row, null, childItems.map(function (x, i) {
|
60
|
-
return /*#__PURE__*/React.createElement("div", {
|
61
|
-
key: "".concat(i, "_").concat(x || '_'),
|
62
|
-
className: className
|
63
|
-
}, controls ? controls[i] : /*#__PURE__*/React.createElement(Dustbin, {
|
64
|
-
style: {
|
65
|
-
width: '100%'
|
66
|
-
},
|
67
|
-
item: item,
|
68
|
-
accepts: accepts,
|
69
|
-
items: childItems,
|
70
|
-
col: i,
|
71
|
-
parentIndex: index,
|
72
|
-
editModeOn: editModeOn,
|
73
|
-
_onDestroy: function _onDestroy() {
|
74
|
-
return removeChild(item, i);
|
75
|
-
},
|
76
|
-
getItemById: getItemById,
|
77
|
-
setAsChild: setAsChild,
|
78
|
-
seq: seq
|
79
|
-
}));
|
80
|
-
}))));
|
81
|
-
}
|
82
|
-
}]);
|
83
|
-
}(React.Component);
|
84
|
-
var TwoColumnRow = function TwoColumnRow(_ref) {
|
85
|
-
var item = _ref.item,
|
22
|
+
var MultiColumnRowBase = function MultiColumnRowBase(_ref) {
|
23
|
+
var controls = _ref.controls,
|
24
|
+
item = _ref.item,
|
25
|
+
items = _ref.items,
|
26
|
+
editModeOn = _ref.editModeOn,
|
27
|
+
getItemById = _ref.getItemById,
|
28
|
+
setAsChild = _ref.setAsChild,
|
29
|
+
removeChild = _ref.removeChild,
|
30
|
+
seq = _ref.seq,
|
86
31
|
className = _ref.className,
|
87
|
-
|
32
|
+
index = _ref.index,
|
33
|
+
style = _ref.style,
|
34
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
35
|
+
var childItems = item.childItems,
|
36
|
+
pageBreakBefore = item.pageBreakBefore;
|
37
|
+
var baseClasses = 'SortableItem rfb-item';
|
38
|
+
if (pageBreakBefore) {
|
39
|
+
baseClasses += ' alwaysbreak';
|
40
|
+
}
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
42
|
+
style: _objectSpread({}, style),
|
43
|
+
className: baseClasses
|
44
|
+
}, /*#__PURE__*/React.createElement(ComponentHeader, _extends({
|
45
|
+
item: item,
|
46
|
+
isFieldSet: false,
|
47
|
+
index: index,
|
48
|
+
editModeOn: editModeOn,
|
49
|
+
setAsChild: setAsChild
|
50
|
+
}, otherProps)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ComponentLabel, _extends({
|
51
|
+
item: item
|
52
|
+
}, otherProps)), /*#__PURE__*/React.createElement(Row, null, childItems.map(function (childItemId, childItemIndex) {
|
53
|
+
return /*#__PURE__*/React.createElement("div", {
|
54
|
+
key: "".concat(childItemIndex, "_").concat(childItemId || '_'),
|
55
|
+
className: className
|
56
|
+
}, controls ? controls[childItemIndex] : /*#__PURE__*/React.createElement(Dustbin, {
|
57
|
+
style: {
|
58
|
+
width: '100%'
|
59
|
+
},
|
60
|
+
item: item,
|
61
|
+
accepts: accepts,
|
62
|
+
items: childItems,
|
63
|
+
col: childItemIndex,
|
64
|
+
parentIndex: index,
|
65
|
+
editModeOn: editModeOn,
|
66
|
+
_onDestroy: function _onDestroy() {
|
67
|
+
removeChild(item, childItemIndex);
|
68
|
+
},
|
69
|
+
getItemById: getItemById,
|
70
|
+
setAsChild: setAsChild,
|
71
|
+
seq: seq
|
72
|
+
}));
|
73
|
+
}))));
|
74
|
+
};
|
75
|
+
var TwoColumnRow = function TwoColumnRow(_ref2) {
|
76
|
+
var item = _ref2.item,
|
77
|
+
className = _ref2.className,
|
78
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
88
79
|
var classNameVal = className || 'col-md-6';
|
89
80
|
if (!item.childItems) {
|
90
81
|
// eslint-disable-next-line no-param-reassign
|
91
82
|
item.childItems = [null, null];
|
92
|
-
item.isContainer = true;
|
93
83
|
}
|
94
84
|
return /*#__PURE__*/React.createElement(MultiColumnRowBase, _extends({}, rest, {
|
95
85
|
className: classNameVal,
|
96
86
|
item: item
|
97
87
|
}));
|
98
88
|
};
|
99
|
-
var ThreeColumnRow = function ThreeColumnRow(
|
100
|
-
var item =
|
101
|
-
className =
|
102
|
-
rest = _objectWithoutProperties(
|
89
|
+
var ThreeColumnRow = function ThreeColumnRow(_ref3) {
|
90
|
+
var item = _ref3.item,
|
91
|
+
className = _ref3.className,
|
92
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
103
93
|
var classNameVal = className || 'col-md-4';
|
104
94
|
if (!item.childItems) {
|
105
95
|
// eslint-disable-next-line no-param-reassign
|
106
96
|
item.childItems = [null, null, null];
|
107
|
-
item.isContainer = true;
|
108
97
|
}
|
109
98
|
return /*#__PURE__*/React.createElement(MultiColumnRowBase, _extends({}, rest, {
|
110
99
|
className: classNameVal,
|
111
100
|
item: item
|
112
101
|
}));
|
113
102
|
};
|
114
|
-
var MultiColumnRow = function MultiColumnRow(
|
115
|
-
var item =
|
116
|
-
rest = _objectWithoutProperties(
|
103
|
+
var MultiColumnRow = function MultiColumnRow(_ref4) {
|
104
|
+
var item = _ref4.item,
|
105
|
+
rest = _objectWithoutProperties(_ref4, _excluded4);
|
117
106
|
var colCount = item.colCount || 4;
|
118
107
|
var classNameVal = item.className || (colCount === 4 ? 'col-md-3' : 'col');
|
119
108
|
if (!item.childItems) {
|
@@ -123,7 +112,6 @@ var MultiColumnRow = function MultiColumnRow(_ref3) {
|
|
123
112
|
}, function (v, i) {
|
124
113
|
return null;
|
125
114
|
});
|
126
|
-
item.isContainer = true;
|
127
115
|
}
|
128
116
|
return /*#__PURE__*/React.createElement(MultiColumnRowBase, _extends({}, rest, {
|
129
117
|
className: classNameVal,
|
@@ -1,7 +1,13 @@
|
|
1
1
|
var _excluded = ["onDropSuccess", "seq", "draggedItem", "parentIndex", "canDrop", "isOver", "isOverCurrent", "connectDropTarget", "items", "col", "getItemById"];
|
2
|
+
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
3
|
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
4
|
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
5
|
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); }
|
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; }
|
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; }
|
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; }
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
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); }
|
5
11
|
import React from 'react';
|
6
12
|
import { DropTarget } from 'react-dnd';
|
7
13
|
import SurveyElements from '../survey-elements';
|
@@ -10,6 +16,7 @@ import CustomElement from '../survey-elements/custom-element';
|
|
10
16
|
import Registry from '../stores/registry';
|
11
17
|
import store from '../stores/store';
|
12
18
|
function getCustomElement(item, props) {
|
19
|
+
var _item$fieldName;
|
13
20
|
if (!item.component || typeof item.component !== 'function') {
|
14
21
|
item.component = Registry.get(item.key);
|
15
22
|
if (!item.component) {
|
@@ -19,23 +26,38 @@ function getCustomElement(item, props) {
|
|
19
26
|
return /*#__PURE__*/React.createElement(CustomElement, _extends({}, props, {
|
20
27
|
mutable: false,
|
21
28
|
key: "form_".concat(item.id),
|
22
|
-
|
29
|
+
id: item.id,
|
30
|
+
name: (_item$fieldName = item.fieldName) !== null && _item$fieldName !== void 0 ? _item$fieldName : item.name,
|
31
|
+
item: _objectSpread(_objectSpread({}, item), {}, {
|
32
|
+
mutable: false,
|
33
|
+
readOnly: false,
|
34
|
+
print: false
|
35
|
+
})
|
23
36
|
}));
|
24
37
|
}
|
25
|
-
function getElement(item, props) {
|
38
|
+
var getElement = function getElement(item, props) {
|
39
|
+
var _item$fieldName2;
|
26
40
|
if (!item) return null;
|
27
41
|
if (item.custom) {
|
28
42
|
return getCustomElement(item, props);
|
29
43
|
}
|
44
|
+
console.log('getDustbinElement', item);
|
30
45
|
var Element = SurveyElements[item.element || item.key];
|
31
46
|
return /*#__PURE__*/React.createElement(Element, _extends({}, props, {
|
47
|
+
id: item.id,
|
32
48
|
key: "form_".concat(item.id),
|
33
|
-
item: item
|
49
|
+
name: (_item$fieldName2 = item.fieldName) !== null && _item$fieldName2 !== void 0 ? _item$fieldName2 : item.name,
|
50
|
+
mutable: false,
|
51
|
+
item: _objectSpread(_objectSpread({}, item), {}, {
|
52
|
+
mutable: false,
|
53
|
+
readOnly: false,
|
54
|
+
print: false
|
55
|
+
})
|
34
56
|
}));
|
35
|
-
}
|
36
|
-
function getStyle(backgroundColor) {
|
57
|
+
};
|
58
|
+
var getStyle = function getStyle(backgroundColor) {
|
37
59
|
return {
|
38
|
-
border: '1px
|
60
|
+
border: '1px dashed rgba(0,0,0,0.2)',
|
39
61
|
minHeight: '2rem',
|
40
62
|
minWidth: '7rem',
|
41
63
|
width: '100%',
|
@@ -43,10 +65,10 @@ function getStyle(backgroundColor) {
|
|
43
65
|
padding: 0,
|
44
66
|
"float": 'left'
|
45
67
|
};
|
46
|
-
}
|
47
|
-
function isContainer(
|
48
|
-
if (
|
49
|
-
var item =
|
68
|
+
};
|
69
|
+
var isContainer = function isContainer(containerItem) {
|
70
|
+
if (containerItem.itemType !== ItemTypes.CARD) {
|
71
|
+
var item = containerItem.item;
|
50
72
|
if (item) {
|
51
73
|
if (item.isContainer) {
|
52
74
|
return true;
|
@@ -57,7 +79,7 @@ function isContainer($containerItem) {
|
|
57
79
|
}
|
58
80
|
}
|
59
81
|
return false;
|
60
|
-
}
|
82
|
+
};
|
61
83
|
var Dustbin = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
62
84
|
var onDropSuccess = _ref.onDropSuccess,
|
63
85
|
seq = _ref.seq,
|
@@ -70,21 +92,23 @@ var Dustbin = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
70
92
|
items = _ref.items,
|
71
93
|
col = _ref.col,
|
72
94
|
getItemById = _ref.getItemById,
|
73
|
-
|
95
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
74
96
|
var item = getItemById(items[col]);
|
75
97
|
React.useImperativeHandle(ref, function () {
|
76
98
|
return {
|
77
99
|
onDrop: function onDrop(dropped) {
|
78
|
-
console.log("dropped
|
100
|
+
console.log("dropped item", dropped);
|
79
101
|
var item = dropped.item;
|
80
102
|
if (item) {
|
81
|
-
|
103
|
+
if (onDropSuccess) {
|
104
|
+
onDropSuccess();
|
105
|
+
}
|
82
106
|
store.dispatch('deleteLastItem');
|
83
107
|
}
|
84
108
|
}
|
85
109
|
};
|
86
110
|
}, []);
|
87
|
-
var element = getElement(item,
|
111
|
+
var element = getElement(item, otherProps);
|
88
112
|
var sameCard = draggedItem ? draggedItem.index === parentIndex : false;
|
89
113
|
|
90
114
|
// console.log('dragIndex:',draggedItem?.index)
|
@@ -99,12 +123,18 @@ var Dustbin = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
99
123
|
// console.log('sameCard, canDrop', sameCard, canDrop);
|
100
124
|
return connectDropTarget( /*#__PURE__*/React.createElement("div", {
|
101
125
|
style: !sameCard ? getStyle(backgroundColor) : getStyle('rgba(0, 0, 0, .03')
|
102
|
-
}, !element && /*#__PURE__*/React.createElement("
|
126
|
+
}, !element && /*#__PURE__*/React.createElement("div", {
|
127
|
+
className: "w-100 text-center",
|
128
|
+
style: {
|
129
|
+
margin: 20
|
130
|
+
}
|
131
|
+
}, "Drop your element here "), element));
|
103
132
|
});
|
104
133
|
export default DropTarget(function (props) {
|
105
134
|
return props.accepts;
|
106
135
|
}, {
|
107
136
|
drop: function drop(props, monitor, component) {
|
137
|
+
console.log('droptargetprops', props);
|
108
138
|
if (!component) {
|
109
139
|
return;
|
110
140
|
}
|
@@ -114,22 +144,26 @@ export default DropTarget(function (props) {
|
|
114
144
|
// Allow swap column if target and source are in same multi column row
|
115
145
|
var isBusy = !!props.items[props.col];
|
116
146
|
var item = monitor.getItem();
|
147
|
+
console.log('dustbin', props, item, isBusy);
|
117
148
|
|
118
149
|
// Do nothing when moving the box inside the same column
|
119
150
|
if (props.col === item.col && props.items[props.col] === item.id) return;
|
120
151
|
|
121
152
|
// Do not allow replace component other than both items in same multi column row
|
122
153
|
if (item.col === undefined && props.items[props.col]) {
|
123
|
-
store.dispatch('resetLastItem');
|
154
|
+
//store.dispatch('resetLastItem');
|
155
|
+
//console.log('dropping item in dustbin');
|
156
|
+
//store.dispatch('deleteLastItem');
|
124
157
|
return;
|
125
158
|
}
|
126
159
|
if (!isContainer(item)) {
|
127
160
|
component.onDrop(item);
|
128
161
|
console.log("calling on Drop from 137", item);
|
129
162
|
if (item.item && typeof props.setAsChild === 'function') {
|
163
|
+
console.log('setAsChild function being called');
|
130
164
|
var isNew = !item.item.id;
|
131
165
|
var $dataItem = isNew ? item.onCreate(item.item) : item.item;
|
132
|
-
props.setAsChild(props.item, $dataItem, props.col, isBusy);
|
166
|
+
props.setAsChild(props.item, $dataItem, isNew, item.index, props.col, isBusy);
|
133
167
|
}
|
134
168
|
}
|
135
169
|
}
|