@pie-element/categorize 11.3.4-next.0 → 12.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/defaults.js +2 -5
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/builder.js +15 -33
- package/configure/lib/design/builder.js.map +1 -1
- package/configure/lib/design/buttons.js +41 -95
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/RowLabel.js +32 -45
- package/configure/lib/design/categories/RowLabel.js.map +1 -1
- package/configure/lib/design/categories/alternateResponses.js +96 -251
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +135 -208
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +61 -126
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +73 -165
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +195 -384
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +155 -264
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +42 -98
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +148 -236
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +57 -111
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +631 -476
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +93 -149
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/design/utils.js +4 -15
- package/configure/lib/design/utils.js.map +1 -1
- package/configure/lib/index.js +120 -183
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +30 -74
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +22 -32
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +15 -15
- package/controller/lib/defaults.js +2 -5
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +237 -318
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +28 -65
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +5 -5
- package/lib/categorize/categories.js +106 -164
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +73 -123
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +118 -245
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +66 -131
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +46 -103
- package/lib/categorize/droppable-placeholder.js.map +1 -1
- package/lib/categorize/grid-content.js +39 -87
- package/lib/categorize/grid-content.js.map +1 -1
- package/lib/categorize/index.js +341 -317
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +285 -306
- package/lib/index.js.map +1 -1
- package/package.json +16 -14
package/lib/categorize/choice.js
CHANGED
|
@@ -1,264 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
7
|
+
exports.default = exports.Layout = exports.ChoiceType = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
22
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
10
|
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
-
|
|
28
|
-
var _styles = require("@material
|
|
29
|
-
|
|
30
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
31
|
-
|
|
32
|
-
var _reactDnd = require("react-dnd");
|
|
33
|
-
|
|
12
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
+
var _styles = require("@mui/material/styles");
|
|
14
|
+
var _core = require("@dnd-kit/core");
|
|
34
15
|
var _drag = require("@pie-lib/drag");
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var _CardContent = _interopRequireDefault(require("@material-ui/core/CardContent"));
|
|
39
|
-
|
|
16
|
+
var _Card = _interopRequireDefault(require("@mui/material/Card"));
|
|
17
|
+
var _CardContent = _interopRequireDefault(require("@mui/material/CardContent"));
|
|
40
18
|
var _renderUi = require("@pie-lib/render-ui");
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
47
|
-
|
|
48
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
49
|
-
|
|
50
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
51
|
-
|
|
52
|
-
var log = (0, _debug["default"])('@pie-ui:categorize:choice');
|
|
53
|
-
var ChoiceType = {
|
|
54
|
-
content: _propTypes["default"].string.isRequired,
|
|
55
|
-
id: _propTypes["default"].string
|
|
19
|
+
const log = (0, _debug.default)('@pie-ui:categorize:choice');
|
|
20
|
+
const ChoiceType = exports.ChoiceType = {
|
|
21
|
+
content: _propTypes.default.string.isRequired,
|
|
22
|
+
id: _propTypes.default.string
|
|
56
23
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
24
|
+
const ChoiceContainer = (0, _styles.styled)('div', {
|
|
25
|
+
shouldForwardProp: prop => !['isDragging', 'disabled', 'correct'].includes(prop)
|
|
26
|
+
})(({
|
|
27
|
+
isDragging,
|
|
28
|
+
disabled,
|
|
29
|
+
correct
|
|
30
|
+
}) => ({
|
|
31
|
+
direction: 'initial',
|
|
32
|
+
cursor: disabled ? 'not-allowed' : isDragging ? 'move' : 'pointer',
|
|
33
|
+
width: '100%',
|
|
34
|
+
borderRadius: '6px',
|
|
35
|
+
...(correct === true && {
|
|
36
|
+
border: `solid 2px ${_renderUi.color.correct()}`
|
|
37
|
+
}),
|
|
38
|
+
...(correct === false && {
|
|
39
|
+
border: `solid 2px ${_renderUi.color.incorrect()}`
|
|
40
|
+
})
|
|
41
|
+
}));
|
|
42
|
+
const StyledCard = (0, _styles.styled)(_Card.default)({
|
|
43
|
+
color: _renderUi.color.text(),
|
|
44
|
+
backgroundColor: _renderUi.color.background(),
|
|
45
|
+
width: '100%'
|
|
46
|
+
});
|
|
47
|
+
const StyledCardContent = (0, _styles.styled)(_CardContent.default)(({
|
|
48
|
+
theme
|
|
49
|
+
}) => ({
|
|
50
|
+
color: _renderUi.color.text(),
|
|
51
|
+
backgroundColor: _renderUi.color.white(),
|
|
52
|
+
'&:last-child': {
|
|
53
|
+
paddingBottom: theme.spacing(2)
|
|
54
|
+
},
|
|
55
|
+
borderRadius: '4px',
|
|
56
|
+
border: '1px solid'
|
|
57
|
+
}));
|
|
58
|
+
class Layout extends _react.default.Component {
|
|
59
|
+
render() {
|
|
60
|
+
const {
|
|
61
|
+
content,
|
|
62
|
+
isDragging,
|
|
63
|
+
disabled,
|
|
64
|
+
correct
|
|
65
|
+
} = this.props;
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(ChoiceContainer, {
|
|
67
|
+
isDragging: isDragging,
|
|
68
|
+
disabled: disabled,
|
|
69
|
+
correct: correct
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(StyledCard, null, /*#__PURE__*/_react.default.createElement(StyledCardContent, {
|
|
71
|
+
dangerouslySetInnerHTML: {
|
|
72
|
+
__html: content
|
|
73
|
+
}
|
|
74
|
+
})));
|
|
67
75
|
}
|
|
68
|
-
|
|
69
|
-
(0, _createClass2["default"])(Layout, [{
|
|
70
|
-
key: "render",
|
|
71
|
-
value: function render() {
|
|
72
|
-
var _this$props = this.props,
|
|
73
|
-
classes = _this$props.classes,
|
|
74
|
-
className = _this$props.className,
|
|
75
|
-
content = _this$props.content,
|
|
76
|
-
isDragging = _this$props.isDragging,
|
|
77
|
-
disabled = _this$props.disabled,
|
|
78
|
-
correct = _this$props.correct;
|
|
79
|
-
var rootNames = (0, _classnames["default"])(correct === true && 'correct', correct === false && 'incorrect', classes.choice, isDragging && classes.dragging, disabled && classes.disabled, className);
|
|
80
|
-
var cardNames = (0, _classnames["default"])(classes.card);
|
|
81
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
82
|
-
className: rootNames
|
|
83
|
-
}, /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
84
|
-
className: cardNames
|
|
85
|
-
}, /*#__PURE__*/_react["default"].createElement(_CardContent["default"], {
|
|
86
|
-
classes: {
|
|
87
|
-
root: classes.cardRoot
|
|
88
|
-
},
|
|
89
|
-
dangerouslySetInnerHTML: {
|
|
90
|
-
__html: content
|
|
91
|
-
}
|
|
92
|
-
})));
|
|
93
|
-
}
|
|
94
|
-
}]);
|
|
95
|
-
return Layout;
|
|
96
|
-
}(_react["default"].Component);
|
|
97
|
-
|
|
76
|
+
}
|
|
98
77
|
exports.Layout = Layout;
|
|
99
|
-
(0, _defineProperty2
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})
|
|
105
|
-
(0, _defineProperty2
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
dragging: {
|
|
134
|
-
cursor: 'move'
|
|
78
|
+
(0, _defineProperty2.default)(Layout, "propTypes", {
|
|
79
|
+
...ChoiceType,
|
|
80
|
+
disabled: _propTypes.default.bool,
|
|
81
|
+
correct: _propTypes.default.bool,
|
|
82
|
+
isDragging: _propTypes.default.bool
|
|
83
|
+
});
|
|
84
|
+
(0, _defineProperty2.default)(Layout, "defaultProps", {});
|
|
85
|
+
const DraggableChoice = ({
|
|
86
|
+
id,
|
|
87
|
+
content,
|
|
88
|
+
disabled,
|
|
89
|
+
correct,
|
|
90
|
+
extraStyle,
|
|
91
|
+
categoryId,
|
|
92
|
+
choiceIndex
|
|
93
|
+
}) => {
|
|
94
|
+
// Generate unique draggable ID for each instance
|
|
95
|
+
// If in choices board (categoryId is undefined), use 'board' suffix
|
|
96
|
+
// If in a category, include categoryId and choiceIndex to make it unique
|
|
97
|
+
const draggableId = categoryId !== undefined ? `choice-${id}-${categoryId}-${choiceIndex}` : `choice-${id}-board`;
|
|
98
|
+
const {
|
|
99
|
+
attributes,
|
|
100
|
+
listeners,
|
|
101
|
+
setNodeRef,
|
|
102
|
+
isDragging
|
|
103
|
+
} = (0, _core.useDraggable)({
|
|
104
|
+
id: draggableId,
|
|
105
|
+
data: {
|
|
106
|
+
id,
|
|
107
|
+
categoryId,
|
|
108
|
+
choiceIndex,
|
|
109
|
+
value: content,
|
|
110
|
+
itemType: 'categorize',
|
|
111
|
+
type: 'choice'
|
|
135
112
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
113
|
+
disabled
|
|
114
|
+
});
|
|
115
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
116
|
+
ref: setNodeRef,
|
|
117
|
+
style: {
|
|
118
|
+
margin: '4px',
|
|
119
|
+
...extraStyle
|
|
143
120
|
}
|
|
144
|
-
}
|
|
121
|
+
}, listeners, attributes), /*#__PURE__*/_react.default.createElement(Layout, {
|
|
122
|
+
id: id,
|
|
123
|
+
content: content,
|
|
124
|
+
disabled: disabled,
|
|
125
|
+
correct: correct,
|
|
126
|
+
isDragging: isDragging
|
|
127
|
+
}));
|
|
145
128
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var _super2 = _createSuper(Choice);
|
|
153
|
-
|
|
154
|
-
function Choice() {
|
|
155
|
-
var _this;
|
|
156
|
-
|
|
157
|
-
(0, _classCallCheck2["default"])(this, Choice);
|
|
158
|
-
|
|
159
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
160
|
-
args[_key] = arguments[_key];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
_this = _super2.call.apply(_super2, [this].concat(args));
|
|
164
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleTouchStart", function (e) {
|
|
165
|
-
e.preventDefault();
|
|
166
|
-
});
|
|
167
|
-
return _this;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
(0, _createClass2["default"])(Choice, [{
|
|
171
|
-
key: "componentDidMount",
|
|
172
|
-
value: function componentDidMount() {
|
|
173
|
-
if (this.ref) {
|
|
174
|
-
this.ref.addEventListener('touchstart', this.handleTouchStart, {
|
|
175
|
-
passive: false
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}, {
|
|
180
|
-
key: "componentWillUnmount",
|
|
181
|
-
value: function componentWillUnmount() {
|
|
182
|
-
if (this.ref) {
|
|
183
|
-
this.ref.removeEventListener('touchstart', this.handleTouchStart);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}, {
|
|
187
|
-
key: "render",
|
|
188
|
-
value: function render() {
|
|
189
|
-
var _this2 = this;
|
|
190
|
-
|
|
191
|
-
var _this$props2 = this.props,
|
|
192
|
-
connectDragSource = _this$props2.connectDragSource,
|
|
193
|
-
id = _this$props2.id,
|
|
194
|
-
content = _this$props2.content,
|
|
195
|
-
disabled = _this$props2.disabled,
|
|
196
|
-
isDragging = _this$props2.isDragging,
|
|
197
|
-
correct = _this$props2.correct,
|
|
198
|
-
extraStyle = _this$props2.extraStyle;
|
|
199
|
-
return connectDragSource( /*#__PURE__*/_react["default"].createElement("div", {
|
|
200
|
-
style: _objectSpread({
|
|
201
|
-
margin: '4px'
|
|
202
|
-
}, extraStyle),
|
|
203
|
-
ref: function ref(_ref) {
|
|
204
|
-
return _this2.ref = _ref;
|
|
205
|
-
},
|
|
206
|
-
draggable: !disabled
|
|
207
|
-
}, /*#__PURE__*/_react["default"].createElement(Styled, {
|
|
208
|
-
id: id,
|
|
209
|
-
content: content,
|
|
210
|
-
disabled: disabled,
|
|
211
|
-
correct: correct,
|
|
212
|
-
isDragging: isDragging
|
|
213
|
-
})));
|
|
214
|
-
}
|
|
215
|
-
}]);
|
|
216
|
-
return Choice;
|
|
217
|
-
}(_react["default"].Component);
|
|
218
|
-
|
|
219
|
-
exports.Choice = Choice;
|
|
220
|
-
(0, _defineProperty2["default"])(Choice, "propTypes", _objectSpread(_objectSpread({}, ChoiceType), {}, {
|
|
221
|
-
extraStyle: _propTypes["default"].object,
|
|
222
|
-
connectDragSource: _propTypes["default"].func.isRequired
|
|
223
|
-
}));
|
|
224
|
-
var spec = {
|
|
225
|
-
canDrag: function canDrag(props) {
|
|
226
|
-
return !props.disabled;
|
|
227
|
-
},
|
|
228
|
-
beginDrag: function beginDrag(props) {
|
|
229
|
-
var out = {
|
|
230
|
-
id: props.id,
|
|
231
|
-
categoryId: props.categoryId,
|
|
232
|
-
choiceIndex: props.choiceIndex,
|
|
233
|
-
value: props.content,
|
|
234
|
-
itemType: 'categorize'
|
|
235
|
-
};
|
|
236
|
-
log('[beginDrag] out:', out);
|
|
237
|
-
return out;
|
|
238
|
-
},
|
|
239
|
-
endDrag: function endDrag(props, monitor) {
|
|
240
|
-
if (!monitor.didDrop()) {
|
|
241
|
-
var item = monitor.getItem();
|
|
242
|
-
|
|
243
|
-
if (item.categoryId) {
|
|
244
|
-
log('wasnt droppped - what to do?');
|
|
245
|
-
props.onRemoveChoice(item);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
129
|
+
DraggableChoice.propTypes = {
|
|
130
|
+
...ChoiceType,
|
|
131
|
+
extraStyle: _propTypes.default.object,
|
|
132
|
+
categoryId: _propTypes.default.string,
|
|
133
|
+
choiceIndex: _propTypes.default.number,
|
|
134
|
+
onRemoveChoice: _propTypes.default.func
|
|
249
135
|
};
|
|
250
|
-
exports.
|
|
251
|
-
var DraggableChoice = (0, _reactDnd.DragSource)(function (_ref2) {
|
|
252
|
-
var uid = _ref2.uid;
|
|
253
|
-
return uid;
|
|
254
|
-
}, spec, function (connect, monitor) {
|
|
255
|
-
return {
|
|
256
|
-
connectDragSource: connect.dragSource(),
|
|
257
|
-
isDragging: monitor.isDragging()
|
|
258
|
-
};
|
|
259
|
-
})(Choice);
|
|
260
|
-
|
|
261
|
-
var _default = _drag.uid.withUid(DraggableChoice);
|
|
262
|
-
|
|
263
|
-
exports["default"] = _default;
|
|
136
|
+
var _default = exports.default = _drag.uid.withUid(DraggableChoice);
|
|
264
137
|
//# sourceMappingURL=choice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_debug","_styles","_core","_drag","_Card","_CardContent","_renderUi","log","debug","ChoiceType","exports","content","PropTypes","string","isRequired","id","ChoiceContainer","styled","shouldForwardProp","prop","includes","isDragging","disabled","correct","direction","cursor","width","borderRadius","border","color","incorrect","StyledCard","Card","text","backgroundColor","background","StyledCardContent","CardContent","theme","white","paddingBottom","spacing","Layout","React","Component","render","props","default","createElement","dangerouslySetInnerHTML","__html","_defineProperty2","bool","DraggableChoice","extraStyle","categoryId","choiceIndex","draggableId","undefined","attributes","listeners","setNodeRef","useDraggable","data","value","itemType","type","_extends2","ref","style","margin","propTypes","object","number","onRemoveChoice","func","_default","uid","withUid"],"sources":["../../src/categorize/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport debug from 'debug';\nimport { styled } from '@mui/material/styles';\nimport { useDraggable } from '@dnd-kit/core';\nimport { uid } from '@pie-lib/drag';\nimport Card from '@mui/material/Card';\nimport CardContent from '@mui/material/CardContent';\nimport { color } from '@pie-lib/render-ui';\n\nconst log = debug('@pie-ui:categorize:choice');\n\nexport const ChoiceType = {\n content: PropTypes.string.isRequired,\n id: PropTypes.string,\n};\n\nconst ChoiceContainer = styled('div', {\n shouldForwardProp: (prop) => !['isDragging', 'disabled', 'correct'].includes(prop),\n})(({ isDragging, disabled, correct }) => ({\n direction: 'initial',\n cursor: disabled ? 'not-allowed' : isDragging ? 'move' : 'pointer',\n width: '100%',\n borderRadius: '6px',\n ...(correct === true && {\n border: `solid 2px ${color.correct()}`,\n }),\n ...(correct === false && {\n border: `solid 2px ${color.incorrect()}`,\n }),\n}));\n\nconst StyledCard = styled(Card)({\n color: color.text(),\n backgroundColor: color.background(),\n width: '100%',\n});\n\nconst StyledCardContent = styled(CardContent)(({ theme }) => ({\n color: color.text(),\n backgroundColor: color.white(),\n '&:last-child': {\n paddingBottom: theme.spacing(2),\n },\n borderRadius: '4px',\n border: '1px solid',\n}));\n\nexport class Layout extends React.Component {\n static propTypes = {\n ...ChoiceType,\n disabled: PropTypes.bool,\n correct: PropTypes.bool,\n isDragging: PropTypes.bool,\n };\n static defaultProps = {};\n render() {\n const { content, isDragging, disabled, correct } = this.props;\n\n return (\n <ChoiceContainer isDragging={isDragging} disabled={disabled} correct={correct}>\n <StyledCard>\n <StyledCardContent dangerouslySetInnerHTML={{ __html: content }} />\n </StyledCard>\n </ChoiceContainer>\n );\n }\n}\n\nconst DraggableChoice = ({ id, content, disabled, correct, extraStyle, categoryId, choiceIndex }) => {\n // Generate unique draggable ID for each instance\n // If in choices board (categoryId is undefined), use 'board' suffix\n // If in a category, include categoryId and choiceIndex to make it unique\n const draggableId = categoryId !== undefined ? `choice-${id}-${categoryId}-${choiceIndex}` : `choice-${id}-board`;\n\n const { attributes, listeners, setNodeRef, isDragging } = useDraggable({\n id: draggableId,\n data: {\n id,\n categoryId,\n choiceIndex,\n value: content,\n itemType: 'categorize',\n type: 'choice',\n },\n disabled,\n });\n\n return (\n <div ref={setNodeRef} style={{ margin: '4px', ...extraStyle }} {...listeners} {...attributes}>\n <Layout id={id} content={content} disabled={disabled} correct={correct} isDragging={isDragging} />\n </div>\n );\n};\n\nDraggableChoice.propTypes = {\n ...ChoiceType,\n extraStyle: PropTypes.object,\n categoryId: PropTypes.string,\n choiceIndex: PropTypes.number,\n onRemoveChoice: PropTypes.func,\n};\n\nexport default uid.withUid(DraggableChoice);\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,YAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAEA,MAAMS,GAAG,GAAG,IAAAC,cAAK,EAAC,2BAA2B,CAAC;AAEvC,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACxBE,OAAO,EAAEC,kBAAS,CAACC,MAAM,CAACC,UAAU;EACpCC,EAAE,EAAEH,kBAAS,CAACC;AAChB,CAAC;AAED,MAAMG,eAAe,GAAG,IAAAC,cAAM,EAAC,KAAK,EAAE;EACpCC,iBAAiB,EAAGC,IAAI,IAAK,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC,CAACC,QAAQ,CAACD,IAAI;AACnF,CAAC,CAAC,CAAC,CAAC;EAAEE,UAAU;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,MAAM;EACzCC,SAAS,EAAE,SAAS;EACpBC,MAAM,EAAEH,QAAQ,GAAG,aAAa,GAAGD,UAAU,GAAG,MAAM,GAAG,SAAS;EAClEK,KA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