@pie-element/match 10.3.4-next.0 → 11.0.0-beta.0
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/configure/lib/add-row.js +27 -73
- package/configure/lib/add-row.js.map +1 -1
- package/configure/lib/answer-config-block.js +260 -333
- package/configure/lib/answer-config-block.js.map +1 -1
- package/configure/lib/common.js +18 -33
- package/configure/lib/common.js.map +1 -1
- package/configure/lib/configure.js +329 -419
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +2 -4
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +123 -190
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/lib/index.js +116 -188
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/row.js +268 -376
- package/configure/lib/row.js.map +1 -1
- package/configure/lib/utils.js +4 -15
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +13 -11
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +172 -298
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +5 -5
- package/lib/answer-grid.js +142 -242
- package/lib/answer-grid.js.map +1 -1
- package/lib/index.js +59 -108
- package/lib/index.js.map +1 -1
- package/lib/main.js +123 -191
- package/lib/main.js.map +1 -1
- package/package.json +12 -9
package/configure/lib/row.js
CHANGED
|
@@ -1,411 +1,303 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
|
8
5
|
value: true
|
|
9
6
|
});
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
7
|
+
exports.default = exports.canDrag = exports.Row = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
24
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
|
-
var _utils = require("./utils");
|
|
27
|
-
|
|
28
10
|
var _react = _interopRequireDefault(require("react"));
|
|
29
|
-
|
|
30
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
-
|
|
32
|
-
var _styles = require("@material-ui/core/styles");
|
|
33
|
-
|
|
34
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
35
|
-
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
36
13
|
var _configUi = require("@pie-lib/config-ui");
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
43
|
-
|
|
44
|
-
var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
|
|
45
|
-
|
|
46
|
-
var _reactDnd = require("react-dnd");
|
|
47
|
-
|
|
14
|
+
var _DragHandle = _interopRequireDefault(require("@mui/icons-material/DragHandle"));
|
|
15
|
+
var _Radio = _interopRequireDefault(require("@mui/material/Radio"));
|
|
16
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
17
|
+
var _Delete = _interopRequireDefault(require("@mui/icons-material/Delete"));
|
|
18
|
+
var _core = require("@dnd-kit/core");
|
|
48
19
|
var _debug = _interopRequireDefault(require("debug"));
|
|
49
|
-
|
|
50
20
|
var _editableHtml = _interopRequireWildcard(require("@pie-lib/editable-html"));
|
|
51
|
-
|
|
52
21
|
var _renderUi = require("@pie-lib/render-ui");
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
22
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
23
|
+
const log = (0, _debug.default)('@pie-element:categorize:configure:choice');
|
|
24
|
+
let canDrag = exports.canDrag = false;
|
|
25
|
+
const DragHandleStyled = (0, _styles.styled)('span')({
|
|
26
|
+
cursor: 'move'
|
|
27
|
+
});
|
|
28
|
+
const RowContainer = (0, _styles.styled)('div')(({
|
|
29
|
+
theme
|
|
30
|
+
}) => ({
|
|
31
|
+
marginTop: theme.spacing(2),
|
|
32
|
+
display: 'flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
flex: 1
|
|
35
|
+
}));
|
|
36
|
+
const RowItem = (0, _styles.styled)('div')(({
|
|
37
|
+
theme
|
|
38
|
+
}) => ({
|
|
39
|
+
flex: 1,
|
|
40
|
+
display: 'flex',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
minWidth: '120px',
|
|
44
|
+
padding: `0 ${theme.spacing(1)}`
|
|
45
|
+
}));
|
|
46
|
+
const RadioButtonStyled = (0, _styles.styled)(_Radio.default)(({
|
|
47
|
+
theme,
|
|
48
|
+
error
|
|
49
|
+
}) => ({
|
|
50
|
+
'& input': {
|
|
51
|
+
width: '100% !important'
|
|
52
|
+
},
|
|
53
|
+
'&.MuiRadio-root': {
|
|
54
|
+
color: `${error ? theme.palette.error.main : _renderUi.color.tertiary()} !important`
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
const DeleteIcon = (0, _styles.styled)('div')(({
|
|
58
|
+
theme
|
|
59
|
+
}) => ({
|
|
60
|
+
flex: 0.5,
|
|
61
|
+
display: 'flex',
|
|
62
|
+
justifyContent: 'center',
|
|
63
|
+
minWidth: '45px',
|
|
64
|
+
padding: `0 ${theme.spacing(1)}`
|
|
65
|
+
}));
|
|
66
|
+
const QuestionText = (0, _styles.styled)(RowItem)(({
|
|
67
|
+
theme
|
|
68
|
+
}) => ({
|
|
69
|
+
flex: 2,
|
|
70
|
+
display: 'flex',
|
|
71
|
+
justifyContent: 'flex-start',
|
|
72
|
+
padding: 0,
|
|
73
|
+
maxWidth: 'unset',
|
|
74
|
+
textAlign: 'left',
|
|
75
|
+
minWidth: '200px',
|
|
76
|
+
marginRight: theme.spacing(1),
|
|
77
|
+
'&> div': {
|
|
78
|
+
width: '100%'
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
const Separator = (0, _styles.styled)('hr')(({
|
|
82
|
+
theme
|
|
83
|
+
}) => ({
|
|
84
|
+
marginTop: theme.spacing(2),
|
|
85
|
+
border: 0,
|
|
86
|
+
borderTop: `2px solid ${theme.palette.grey['A100']}`,
|
|
87
|
+
width: '100%'
|
|
88
|
+
}));
|
|
89
|
+
const ErrorText = (0, _styles.styled)('div')(({
|
|
90
|
+
theme
|
|
91
|
+
}) => ({
|
|
92
|
+
fontSize: theme.typography.fontSize - 2,
|
|
93
|
+
color: theme.palette.error.main,
|
|
94
|
+
paddingTop: theme.spacing(1)
|
|
95
|
+
}));
|
|
96
|
+
class Row extends _react.default.Component {
|
|
97
|
+
constructor(...args) {
|
|
98
|
+
super(...args);
|
|
99
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
86
100
|
dialog: {
|
|
87
101
|
open: false,
|
|
88
102
|
text: ''
|
|
89
103
|
}
|
|
90
104
|
});
|
|
91
|
-
(0, _defineProperty2
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
newModel.rows[rowIndex].title = value;
|
|
100
|
-
onChange(newModel);
|
|
105
|
+
(0, _defineProperty2.default)(this, "onRowTitleChange", rowIndex => value => {
|
|
106
|
+
const {
|
|
107
|
+
model,
|
|
108
|
+
onChange
|
|
109
|
+
} = this.props;
|
|
110
|
+
const newModel = {
|
|
111
|
+
...model
|
|
101
112
|
};
|
|
113
|
+
newModel.rows[rowIndex].title = value;
|
|
114
|
+
onChange(newModel);
|
|
102
115
|
});
|
|
103
|
-
(0, _defineProperty2
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (model.choiceMode === 'radio') {
|
|
112
|
-
for (var i = 0; i < newModel.rows[rowIndex].values.length; i++) {
|
|
113
|
-
newModel.rows[rowIndex].values[i] = false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
newModel.rows[rowIndex].values[rowValueIndex] = event.target.checked;
|
|
118
|
-
onChange(newModel);
|
|
116
|
+
(0, _defineProperty2.default)(this, "onRowValueChange", (rowIndex, rowValueIndex) => event => {
|
|
117
|
+
const {
|
|
118
|
+
model,
|
|
119
|
+
onChange
|
|
120
|
+
} = this.props;
|
|
121
|
+
const newModel = {
|
|
122
|
+
...model
|
|
119
123
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var _this$props3 = _this.props,
|
|
124
|
-
model = _this$props3.model,
|
|
125
|
-
onDeleteRow = _this$props3.onDeleteRow,
|
|
126
|
-
minQuestions = _this$props3.minQuestions;
|
|
127
|
-
|
|
128
|
-
if (model.rows && model.rows.length === minQuestions) {
|
|
129
|
-
_this.setState({
|
|
130
|
-
dialog: {
|
|
131
|
-
open: true,
|
|
132
|
-
text: "There should be at least ".concat(minQuestions, " question row") + (minQuestions > 1 ? 's' : '') + '.'
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
} else {
|
|
136
|
-
onDeleteRow(idx);
|
|
124
|
+
if (model.choiceMode === 'radio') {
|
|
125
|
+
for (let i = 0; i < newModel.rows[rowIndex].values.length; i++) {
|
|
126
|
+
newModel.rows[rowIndex].values[i] = false;
|
|
137
127
|
}
|
|
138
|
-
}
|
|
128
|
+
}
|
|
129
|
+
newModel.rows[rowIndex].values[rowValueIndex] = event.target.checked;
|
|
130
|
+
onChange(newModel);
|
|
131
|
+
});
|
|
132
|
+
(0, _defineProperty2.default)(this, "onDeleteRow", idx => () => {
|
|
133
|
+
const {
|
|
134
|
+
model,
|
|
135
|
+
onDeleteRow,
|
|
136
|
+
minQuestions
|
|
137
|
+
} = this.props;
|
|
138
|
+
if (model.rows && model.rows.length === minQuestions) {
|
|
139
|
+
this.setState({
|
|
140
|
+
dialog: {
|
|
141
|
+
open: true,
|
|
142
|
+
text: `There should be at least ${minQuestions} question row` + (minQuestions > 1 ? 's' : '') + '.'
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
onDeleteRow(idx);
|
|
147
|
+
}
|
|
139
148
|
});
|
|
140
|
-
(0, _defineProperty2
|
|
141
|
-
exports.canDrag =
|
|
149
|
+
(0, _defineProperty2.default)(this, "onMouseDownOnHandle", () => {
|
|
150
|
+
exports.canDrag = canDrag = true;
|
|
142
151
|
});
|
|
143
|
-
(0, _defineProperty2
|
|
144
|
-
exports.canDrag =
|
|
152
|
+
(0, _defineProperty2.default)(this, "onMouseUpOnHandle", () => {
|
|
153
|
+
exports.canDrag = canDrag = false;
|
|
145
154
|
});
|
|
146
|
-
return _this;
|
|
147
155
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
223
|
-
key: rowIdx,
|
|
224
|
-
className: classes.rowItem
|
|
225
|
-
}, model.choiceMode === 'radio' ? /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
|
|
226
|
-
className: (0, _classnames["default"])(classes.radioButton, classes.customColor, (0, _defineProperty2["default"])({}, classes.errorResponse, error === null || error === void 0 ? void 0 : error.includes('No correct response defined.'))),
|
|
227
|
-
onChange: _this2.onRowValueChange(idx, rowIdx),
|
|
228
|
-
checked: rowValue === true
|
|
229
|
-
}) : /*#__PURE__*/_react["default"].createElement(_configUi.Checkbox, {
|
|
230
|
-
onChange: _this2.onRowValueChange(idx, rowIdx),
|
|
231
|
-
checked: rowValue === true,
|
|
232
|
-
label: '',
|
|
233
|
-
error: error === null || error === void 0 ? void 0 : error.includes('No correct response defined.')
|
|
234
|
-
}));
|
|
235
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
236
|
-
className: classes.deleteIcon
|
|
237
|
-
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
238
|
-
onClick: this.onDeleteRow(idx),
|
|
239
|
-
"aria-label": "Delete"
|
|
240
|
-
}, /*#__PURE__*/_react["default"].createElement(_Delete["default"], null)))), error && /*#__PURE__*/_react["default"].createElement("div", {
|
|
241
|
-
className: classes.errorText
|
|
242
|
-
}, error), /*#__PURE__*/_react["default"].createElement("hr", {
|
|
243
|
-
className: classes.separator
|
|
244
|
-
}), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
245
|
-
open: dialog.open,
|
|
246
|
-
title: "Warning",
|
|
247
|
-
text: dialog.text,
|
|
248
|
-
onConfirm: function onConfirm() {
|
|
249
|
-
return _this2.setState({
|
|
250
|
-
dialog: {
|
|
251
|
-
open: false
|
|
252
|
-
}
|
|
253
|
-
});
|
|
156
|
+
componentDidMount() {
|
|
157
|
+
document.addEventListener('mouseup', this.onMouseUpOnHandle);
|
|
158
|
+
}
|
|
159
|
+
render() {
|
|
160
|
+
const {
|
|
161
|
+
imageSupport,
|
|
162
|
+
model,
|
|
163
|
+
row,
|
|
164
|
+
idx,
|
|
165
|
+
inputConfiguration = {},
|
|
166
|
+
toolbarOpts,
|
|
167
|
+
spellCheck,
|
|
168
|
+
error,
|
|
169
|
+
maxImageWidth,
|
|
170
|
+
maxImageHeight,
|
|
171
|
+
uploadSoundSupport,
|
|
172
|
+
mathMlOptions = {}
|
|
173
|
+
} = this.props;
|
|
174
|
+
const {
|
|
175
|
+
dialog
|
|
176
|
+
} = this.state;
|
|
177
|
+
const filteredDefaultPlugins = (_editableHtml.DEFAULT_PLUGINS || []).filter(p => p !== 'bulleted-list' && p !== 'numbered-list');
|
|
178
|
+
const content = /*#__PURE__*/_react.default.createElement("div", {
|
|
179
|
+
style: {
|
|
180
|
+
width: '100%'
|
|
181
|
+
}
|
|
182
|
+
}, /*#__PURE__*/_react.default.createElement(DragHandleStyled, {
|
|
183
|
+
itemID: 'handle',
|
|
184
|
+
onMouseDown: this.onMouseDownOnHandle
|
|
185
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.default, {
|
|
186
|
+
color: 'primary'
|
|
187
|
+
})), /*#__PURE__*/_react.default.createElement(RowContainer, null, /*#__PURE__*/_react.default.createElement(QuestionText, null, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
|
|
188
|
+
imageSupport: imageSupport,
|
|
189
|
+
autoWidthToolbar: true,
|
|
190
|
+
disableUnderline: true,
|
|
191
|
+
label: 'label',
|
|
192
|
+
markup: row.title,
|
|
193
|
+
onChange: this.onRowTitleChange(idx),
|
|
194
|
+
pluginProps: inputConfiguration,
|
|
195
|
+
toolbarOpts: toolbarOpts,
|
|
196
|
+
activePlugins: filteredDefaultPlugins,
|
|
197
|
+
spellCheck: spellCheck,
|
|
198
|
+
maxImageWidth: maxImageWidth,
|
|
199
|
+
maxImageHeight: maxImageHeight,
|
|
200
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
201
|
+
languageCharactersProps: [{
|
|
202
|
+
language: 'spanish'
|
|
203
|
+
}, {
|
|
204
|
+
language: 'special'
|
|
205
|
+
}],
|
|
206
|
+
error: error && error !== 'No correct response defined.',
|
|
207
|
+
mathMlOptions: mathMlOptions
|
|
208
|
+
})), row.values.map((rowValue, rowIdx) => /*#__PURE__*/_react.default.createElement(RowItem, {
|
|
209
|
+
key: rowIdx
|
|
210
|
+
}, model.choiceMode === 'radio' ? /*#__PURE__*/_react.default.createElement(RadioButtonStyled, {
|
|
211
|
+
error: error?.includes('No correct response defined.'),
|
|
212
|
+
onChange: this.onRowValueChange(idx, rowIdx),
|
|
213
|
+
checked: rowValue === true
|
|
214
|
+
}) : /*#__PURE__*/_react.default.createElement(_configUi.Checkbox, {
|
|
215
|
+
onChange: this.onRowValueChange(idx, rowIdx),
|
|
216
|
+
checked: rowValue === true,
|
|
217
|
+
label: '',
|
|
218
|
+
error: error?.includes('No correct response defined.')
|
|
219
|
+
}))), /*#__PURE__*/_react.default.createElement(DeleteIcon, null, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
220
|
+
onClick: this.onDeleteRow(idx),
|
|
221
|
+
"aria-label": "Delete",
|
|
222
|
+
size: "large"
|
|
223
|
+
}, /*#__PURE__*/_react.default.createElement(_Delete.default, null)))), error && /*#__PURE__*/_react.default.createElement(ErrorText, null, error), /*#__PURE__*/_react.default.createElement(Separator, null), /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
|
|
224
|
+
open: dialog.open,
|
|
225
|
+
title: "Warning",
|
|
226
|
+
text: dialog.text,
|
|
227
|
+
onConfirm: () => this.setState({
|
|
228
|
+
dialog: {
|
|
229
|
+
open: false
|
|
254
230
|
}
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return Row;
|
|
261
|
-
}(_react["default"].Component);
|
|
231
|
+
})
|
|
232
|
+
}));
|
|
233
|
+
return content;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
262
236
|
|
|
237
|
+
// Create a wrapper component for drag and drop functionality
|
|
263
238
|
exports.Row = Row;
|
|
264
|
-
(0, _defineProperty2
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
connectDropTarget: _propTypes["default"].func.isRequired,
|
|
276
|
-
onMoveRow: _propTypes["default"].func.isRequired,
|
|
277
|
-
imageSupport: _propTypes["default"].shape({
|
|
278
|
-
add: _propTypes["default"].func.isRequired,
|
|
279
|
-
"delete": _propTypes["default"].func.isRequired
|
|
239
|
+
(0, _defineProperty2.default)(Row, "propTypes", {
|
|
240
|
+
model: _propTypes.default.object.isRequired,
|
|
241
|
+
row: _propTypes.default.object.isRequired,
|
|
242
|
+
idx: _propTypes.default.number.isRequired,
|
|
243
|
+
maxImageWidth: _propTypes.default.object,
|
|
244
|
+
maxImageHeight: _propTypes.default.object,
|
|
245
|
+
onDeleteRow: _propTypes.default.func.isRequired,
|
|
246
|
+
onChange: _propTypes.default.func.isRequired,
|
|
247
|
+
imageSupport: _propTypes.default.shape({
|
|
248
|
+
add: _propTypes.default.func.isRequired,
|
|
249
|
+
delete: _propTypes.default.func.isRequired
|
|
280
250
|
}),
|
|
281
|
-
uploadSoundSupport: _propTypes
|
|
282
|
-
add: _propTypes
|
|
283
|
-
|
|
251
|
+
uploadSoundSupport: _propTypes.default.shape({
|
|
252
|
+
add: _propTypes.default.func.isRequired,
|
|
253
|
+
delete: _propTypes.default.func.isRequired
|
|
284
254
|
}),
|
|
285
|
-
inputConfiguration: _propTypes
|
|
286
|
-
toolbarOpts: _propTypes
|
|
287
|
-
error: _propTypes
|
|
288
|
-
spellCheck: _propTypes
|
|
289
|
-
minQuestions: _propTypes
|
|
255
|
+
inputConfiguration: _propTypes.default.object,
|
|
256
|
+
toolbarOpts: _propTypes.default.object,
|
|
257
|
+
error: _propTypes.default.string,
|
|
258
|
+
spellCheck: _propTypes.default.bool,
|
|
259
|
+
minQuestions: _propTypes.default.number
|
|
290
260
|
});
|
|
291
|
-
(0, _defineProperty2
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
dragDisabled: {
|
|
307
|
-
cursor: 'inherit'
|
|
308
|
-
},
|
|
309
|
-
container: {
|
|
310
|
-
marginTop: theme.spacing.unit * 2,
|
|
311
|
-
display: 'flex',
|
|
312
|
-
flexDirection: 'column'
|
|
313
|
-
},
|
|
314
|
-
rowContainer: {
|
|
315
|
-
marginTop: theme.spacing.unit * 2,
|
|
316
|
-
display: 'flex',
|
|
317
|
-
alignItems: 'center',
|
|
318
|
-
flex: 1
|
|
319
|
-
},
|
|
320
|
-
rowItem: {
|
|
321
|
-
flex: 1,
|
|
322
|
-
display: 'flex',
|
|
323
|
-
justifyContent: 'center',
|
|
324
|
-
alignItems: 'center',
|
|
325
|
-
minWidth: '120px',
|
|
326
|
-
padding: "0 ".concat(theme.spacing.unit, "px")
|
|
327
|
-
},
|
|
328
|
-
radioButton: {
|
|
329
|
-
'& input': {
|
|
330
|
-
width: '100% !important'
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
|
-
customColor: {
|
|
334
|
-
color: "".concat(_renderUi.color.tertiary(), " !important")
|
|
335
|
-
},
|
|
336
|
-
deleteIcon: {
|
|
337
|
-
flex: 0.5,
|
|
338
|
-
display: 'flex',
|
|
339
|
-
justifyContent: 'center',
|
|
340
|
-
minWidth: '45px',
|
|
341
|
-
padding: "0 ".concat(theme.spacing.unit, "px")
|
|
342
|
-
},
|
|
343
|
-
questionText: {
|
|
344
|
-
flex: 2,
|
|
345
|
-
display: 'flex',
|
|
346
|
-
justifyContent: 'flex-start',
|
|
347
|
-
padding: 0,
|
|
348
|
-
maxWidth: 'unset',
|
|
349
|
-
textAlign: 'left',
|
|
350
|
-
minWidth: '200px',
|
|
351
|
-
marginRight: theme.spacing.unit,
|
|
352
|
-
'&> div': {
|
|
353
|
-
width: '100%'
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
separator: {
|
|
357
|
-
marginTop: theme.spacing.unit * 2,
|
|
358
|
-
border: 0,
|
|
359
|
-
borderTop: "2px solid ".concat(theme.palette.grey['A100']),
|
|
360
|
-
width: '100%'
|
|
361
|
-
},
|
|
362
|
-
errorText: {
|
|
363
|
-
fontSize: theme.typography.fontSize - 2,
|
|
364
|
-
color: theme.palette.error.main,
|
|
365
|
-
paddingTop: theme.spacing.unit
|
|
366
|
-
},
|
|
367
|
-
errorResponse: {
|
|
368
|
-
color: theme.palette.error.main
|
|
261
|
+
(0, _defineProperty2.default)(Row, "defaultProps", {});
|
|
262
|
+
function DraggableRow(props) {
|
|
263
|
+
const {
|
|
264
|
+
attributes,
|
|
265
|
+
listeners,
|
|
266
|
+
setNodeRef: setDragRef,
|
|
267
|
+
transform,
|
|
268
|
+
transition,
|
|
269
|
+
isDragging
|
|
270
|
+
} = (0, _core.useDraggable)({
|
|
271
|
+
id: `row-${props.row.id}`,
|
|
272
|
+
data: {
|
|
273
|
+
type: 'row',
|
|
274
|
+
index: props.idx,
|
|
275
|
+
id: props.row.id
|
|
369
276
|
}
|
|
277
|
+
});
|
|
278
|
+
const {
|
|
279
|
+
setNodeRef: setDropRef,
|
|
280
|
+
isOver
|
|
281
|
+
} = (0, _core.useDroppable)({
|
|
282
|
+
id: `row-drop-${props.row.id}`,
|
|
283
|
+
data: {
|
|
284
|
+
type: 'row',
|
|
285
|
+
index: props.idx,
|
|
286
|
+
id: props.row.id
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
const style = {
|
|
290
|
+
transform: transform ? `translate3d(${transform.x}px, ${transform.y}px, 0)` : undefined,
|
|
291
|
+
transition,
|
|
292
|
+
opacity: isDragging ? 0.5 : 1,
|
|
293
|
+
backgroundColor: isOver ? 'rgba(0, 0, 0, 0.1)' : 'transparent'
|
|
370
294
|
};
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
beginDrag: function beginDrag(props) {
|
|
380
|
-
return {
|
|
381
|
-
id: props.row.id,
|
|
382
|
-
index: props.idx
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
exports.choiceSource = choiceSource;
|
|
387
|
-
var StyledSource = (0, _reactDnd.DragSource)(NAME, choiceSource, function (connect, monitor) {
|
|
388
|
-
return {
|
|
389
|
-
connectDragSource: connect.dragSource(),
|
|
390
|
-
isDragging: monitor.isDragging()
|
|
391
|
-
};
|
|
392
|
-
})(StyledRow);
|
|
393
|
-
var choiceTarget = {
|
|
394
|
-
hover: function hover() {
|
|
395
|
-
log('[hover]');
|
|
396
|
-
},
|
|
397
|
-
drop: function drop(props, monitor) {
|
|
398
|
-
var item = monitor.getItem();
|
|
399
|
-
log('[drop] item: ', item, 'didDrop?', monitor.didDrop());
|
|
400
|
-
props.onMoveRow(item.index, props.idx);
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
exports.choiceTarget = choiceTarget;
|
|
404
|
-
var StyledSourceAndTarget = (0, _reactDnd.DropTarget)(NAME, choiceTarget, function (connect) {
|
|
405
|
-
return {
|
|
406
|
-
connectDropTarget: connect.dropTarget()
|
|
407
|
-
};
|
|
408
|
-
})(StyledSource);
|
|
409
|
-
var _default = StyledSourceAndTarget;
|
|
410
|
-
exports["default"] = _default;
|
|
295
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
296
|
+
ref: setDropRef,
|
|
297
|
+
style: style
|
|
298
|
+
}, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
299
|
+
ref: setDragRef
|
|
300
|
+
}, listeners, attributes), /*#__PURE__*/_react.default.createElement(Row, props)));
|
|
301
|
+
}
|
|
302
|
+
var _default = exports.default = DraggableRow;
|
|
411
303
|
//# sourceMappingURL=row.js.map
|