@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.
Files changed (63) hide show
  1. package/configure/lib/defaults.js +2 -5
  2. package/configure/lib/defaults.js.map +1 -1
  3. package/configure/lib/design/builder.js +15 -33
  4. package/configure/lib/design/builder.js.map +1 -1
  5. package/configure/lib/design/buttons.js +41 -95
  6. package/configure/lib/design/buttons.js.map +1 -1
  7. package/configure/lib/design/categories/RowLabel.js +32 -45
  8. package/configure/lib/design/categories/RowLabel.js.map +1 -1
  9. package/configure/lib/design/categories/alternateResponses.js +96 -251
  10. package/configure/lib/design/categories/alternateResponses.js.map +1 -1
  11. package/configure/lib/design/categories/category.js +135 -208
  12. package/configure/lib/design/categories/category.js.map +1 -1
  13. package/configure/lib/design/categories/choice-preview.js +61 -126
  14. package/configure/lib/design/categories/choice-preview.js.map +1 -1
  15. package/configure/lib/design/categories/droppable-placeholder.js +73 -165
  16. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
  17. package/configure/lib/design/categories/index.js +195 -384
  18. package/configure/lib/design/categories/index.js.map +1 -1
  19. package/configure/lib/design/choices/choice.js +155 -264
  20. package/configure/lib/design/choices/choice.js.map +1 -1
  21. package/configure/lib/design/choices/config.js +42 -98
  22. package/configure/lib/design/choices/config.js.map +1 -1
  23. package/configure/lib/design/choices/index.js +148 -236
  24. package/configure/lib/design/choices/index.js.map +1 -1
  25. package/configure/lib/design/header.js +57 -111
  26. package/configure/lib/design/header.js.map +1 -1
  27. package/configure/lib/design/index.js +631 -476
  28. package/configure/lib/design/index.js.map +1 -1
  29. package/configure/lib/design/input-header.js +93 -149
  30. package/configure/lib/design/input-header.js.map +1 -1
  31. package/configure/lib/design/utils.js +4 -15
  32. package/configure/lib/design/utils.js.map +1 -1
  33. package/configure/lib/index.js +120 -183
  34. package/configure/lib/index.js.map +1 -1
  35. package/configure/lib/main.js +30 -74
  36. package/configure/lib/main.js.map +1 -1
  37. package/configure/lib/utils.js +22 -32
  38. package/configure/lib/utils.js.map +1 -1
  39. package/configure/package.json +15 -15
  40. package/controller/lib/defaults.js +2 -5
  41. package/controller/lib/defaults.js.map +1 -1
  42. package/controller/lib/index.js +237 -318
  43. package/controller/lib/index.js.map +1 -1
  44. package/controller/lib/utils.js +28 -65
  45. package/controller/lib/utils.js.map +1 -1
  46. package/controller/package.json +5 -5
  47. package/lib/categorize/categories.js +106 -164
  48. package/lib/categorize/categories.js.map +1 -1
  49. package/lib/categorize/category.js +73 -123
  50. package/lib/categorize/category.js.map +1 -1
  51. package/lib/categorize/choice.js +118 -245
  52. package/lib/categorize/choice.js.map +1 -1
  53. package/lib/categorize/choices.js +66 -131
  54. package/lib/categorize/choices.js.map +1 -1
  55. package/lib/categorize/droppable-placeholder.js +46 -103
  56. package/lib/categorize/droppable-placeholder.js.map +1 -1
  57. package/lib/categorize/grid-content.js +39 -87
  58. package/lib/categorize/grid-content.js.map +1 -1
  59. package/lib/categorize/index.js +341 -317
  60. package/lib/categorize/index.js.map +1 -1
  61. package/lib/index.js +285 -306
  62. package/lib/index.js.map +1 -1
  63. package/package.json +16 -14
@@ -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.spec = exports["default"] = exports.Layout = exports.ChoiceType = exports.Choice = void 0;
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-ui/core/styles");
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 _Card = _interopRequireDefault(require("@material-ui/core/Card"));
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
- var _debug = _interopRequireDefault(require("debug"));
43
-
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
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
- exports.ChoiceType = ChoiceType;
58
-
59
- var Layout = /*#__PURE__*/function (_React$Component) {
60
- (0, _inherits2["default"])(Layout, _React$Component);
61
-
62
- var _super = _createSuper(Layout);
63
-
64
- function Layout() {
65
- (0, _classCallCheck2["default"])(this, Layout);
66
- return _super.apply(this, arguments);
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["default"])(Layout, "propTypes", _objectSpread(_objectSpread({}, ChoiceType), {}, {
100
- classes: _propTypes["default"].object.isRequired,
101
- className: _propTypes["default"].string,
102
- disabled: _propTypes["default"].bool,
103
- correct: _propTypes["default"].bool
104
- }));
105
- (0, _defineProperty2["default"])(Layout, "defaultProps", {});
106
-
107
- var styles = function styles(theme) {
108
- return {
109
- choice: {
110
- direction: 'initial',
111
- cursor: 'pointer',
112
- width: '100%',
113
- '&.correct': {
114
- border: "solid 2px ".concat(_renderUi.color.correct())
115
- },
116
- '&.incorrect': {
117
- border: "solid 2px ".concat(_renderUi.color.incorrect())
118
- },
119
- borderRadius: '6px'
120
- },
121
- cardRoot: {
122
- color: _renderUi.color.text(),
123
- backgroundColor: _renderUi.color.white(),
124
- '&:last-child': {
125
- paddingBottom: theme.spacing.unit * 2
126
- },
127
- borderRadius: '4px',
128
- border: '1px solid'
129
- },
130
- disabled: {
131
- cursor: 'not-allowed'
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
- card: {
137
- color: _renderUi.color.text(),
138
- backgroundColor: _renderUi.color.background(),
139
- width: '100%',
140
- // Added for touch devices, for image content.
141
- // This will prevent the context menu from appearing and not allowing other interactions with the image.
142
- pointerEvents: 'none'
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
- var Styled = (0, _styles.withStyles)(styles)(Layout);
148
-
149
- var Choice = /*#__PURE__*/function (_React$Component2) {
150
- (0, _inherits2["default"])(Choice, _React$Component2);
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.spec = spec;
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,"sources":["../../src/categorize/choice.jsx"],"names":["log","ChoiceType","content","PropTypes","string","isRequired","id","Layout","props","classes","className","isDragging","disabled","correct","rootNames","choice","dragging","cardNames","card","root","cardRoot","__html","React","Component","object","bool","styles","theme","direction","cursor","width","border","color","incorrect","borderRadius","text","backgroundColor","white","paddingBottom","spacing","unit","background","pointerEvents","Styled","Choice","e","preventDefault","ref","addEventListener","handleTouchStart","passive","removeEventListener","connectDragSource","extraStyle","margin","func","spec","canDrag","beginDrag","out","categoryId","choiceIndex","value","itemType","endDrag","monitor","didDrop","item","getItem","onRemoveChoice","DraggableChoice","uid","connect","dragSource","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,2BAAN,CAAZ;AAEO,IAAMC,UAAU,GAAG;AACxBC,EAAAA,OAAO,EAAEC,sBAAUC,MAAV,CAAiBC,UADF;AAExBC,EAAAA,EAAE,EAAEH,sBAAUC;AAFU,CAAnB;;;IAKMG,M;;;;;;;;;;;;WASX,kBAAS;AACP,wBAAuE,KAAKC,KAA5E;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,SAAjB,eAAiBA,SAAjB;AAAA,UAA4BR,OAA5B,eAA4BA,OAA5B;AAAA,UAAqCS,UAArC,eAAqCA,UAArC;AAAA,UAAiDC,QAAjD,eAAiDA,QAAjD;AAAA,UAA2DC,OAA3D,eAA2DA,OAA3D;AAEA,UAAMC,SAAS,GAAG,4BAChBD,OAAO,KAAK,IAAZ,IAAoB,SADJ,EAEhBA,OAAO,KAAK,KAAZ,IAAqB,WAFL,EAGhBJ,OAAO,CAACM,MAHQ,EAIhBJ,UAAU,IAAIF,OAAO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,UAAMC,IAAI,GAAGF,OAAO,CAACG,OAAR,EAAb;;AACA,UAAID,IAAI,CAACP,UAAT,EAAqB;AACnB5D,QAAAA,GAAG,CAAC,8BAAD,CAAH;AACAQ,QAAAA,KAAK,CAAC6D,cAAN,CAAqBF,IAArB;AACD;AACF;AACF;AArBiB,CAAb;;AAwBP,IAAMG,eAAe,GAAG,0BACtB;AAAA,MAAGC,GAAH,SAAGA,GAAH;AAAA,SAAaA,GAAb;AAAA,CADsB,EAEtBf,IAFsB,EAGtB,UAACgB,OAAD,EAAUP,OAAV;AAAA,SAAuB;AACrBb,IAAAA,iBAAiB,EAAEoB,OAAO,CAACC,UAAR,EADE;AAErB9D,IAAAA,UAAU,EAAEsD,OAAO,CAACtD,UAAR;AAFS,GAAvB;AAAA,CAHsB,EAOtBiC,MAPsB,CAAxB;;eASe2B,UAAIG,OAAJ,CAAYJ,eAAZ,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { DragSource } from 'react-dnd';\nimport { uid } from '@pie-lib/drag';\nimport Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport { color } from '@pie-lib/render-ui';\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:categorize:choice');\n\nexport const ChoiceType = {\n content: PropTypes.string.isRequired,\n id: PropTypes.string,\n};\n\nexport class Layout extends React.Component {\n static propTypes = {\n ...ChoiceType,\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n disabled: PropTypes.bool,\n correct: PropTypes.bool,\n };\n static defaultProps = {};\n render() {\n const { classes, className, content, isDragging, disabled, correct } = this.props;\n\n const rootNames = classNames(\n correct === true && 'correct',\n correct === false && 'incorrect',\n classes.choice,\n isDragging && classes.dragging,\n disabled && classes.disabled,\n className,\n );\n const cardNames = classNames(classes.card);\n return (\n <div className={rootNames}>\n <Card className={cardNames}>\n <CardContent classes={{ root: classes.cardRoot }} dangerouslySetInnerHTML={{ __html: content }} />\n </Card>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n choice: {\n direction: 'initial',\n cursor: 'pointer',\n width: '100%',\n '&.correct': {\n border: `solid 2px ${color.correct()}`,\n },\n '&.incorrect': {\n border: `solid 2px ${color.incorrect()}`,\n },\n borderRadius: '6px',\n },\n cardRoot: {\n color: color.text(),\n backgroundColor: color.white(),\n '&:last-child': {\n paddingBottom: theme.spacing.unit * 2,\n },\n borderRadius: '4px',\n border: '1px solid',\n },\n disabled: {\n cursor: 'not-allowed',\n },\n dragging: {\n cursor: 'move',\n },\n card: {\n color: color.text(),\n backgroundColor: color.background(),\n width: '100%',\n // Added for touch devices, for image content.\n // This will prevent the context menu from appearing and not allowing other interactions with the image.\n pointerEvents: 'none',\n },\n});\n\nconst Styled = withStyles(styles)(Layout);\n\nexport class Choice extends React.Component {\n static propTypes = {\n ...ChoiceType,\n extraStyle: PropTypes.object,\n connectDragSource: PropTypes.func.isRequired,\n };\n\n componentDidMount() {\n if (this.ref) {\n this.ref.addEventListener('touchstart', this.handleTouchStart, { passive: false });\n }\n }\n\n componentWillUnmount() {\n if (this.ref) {\n this.ref.removeEventListener('touchstart', this.handleTouchStart);\n }\n }\n\n handleTouchStart = (e) => {\n e.preventDefault();\n };\n\n render() {\n const { connectDragSource, id, content, disabled, isDragging, correct, extraStyle } = this.props;\n\n return connectDragSource(\n <div style={{ margin: '4px', ...extraStyle }} ref={(ref) => (this.ref = ref)} draggable={!disabled}>\n <Styled id={id} content={content} disabled={disabled} correct={correct} isDragging={isDragging} />\n </div>,\n );\n }\n}\n\nexport const spec = {\n canDrag: (props) => !props.disabled,\n beginDrag: (props) => {\n const out = {\n id: props.id,\n categoryId: props.categoryId,\n choiceIndex: props.choiceIndex,\n value: props.content,\n itemType: 'categorize',\n };\n log('[beginDrag] out:', out);\n return out;\n },\n endDrag: (props, monitor) => {\n if (!monitor.didDrop()) {\n const item = monitor.getItem();\n if (item.categoryId) {\n log('wasnt droppped - what to do?');\n props.onRemoveChoice(item);\n }\n }\n },\n};\n\nconst DraggableChoice = DragSource(\n ({ uid }) => uid,\n spec,\n (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging(),\n }),\n)(Choice);\n\nexport default uid.withUid(DraggableChoice);\n"],"file":"choice.js"}
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,sBA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