@pie-lib/mask-markup 3.0.4-next.33 → 3.0.4-next.36

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 (107) hide show
  1. package/CHANGELOG.json +17 -0
  2. package/CHANGELOG.md +1256 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/choices/choice.js +116 -0
  5. package/lib/choices/choice.js.map +1 -0
  6. package/lib/choices/index.js +103 -0
  7. package/lib/choices/index.js.map +1 -0
  8. package/lib/componentize.js +21 -0
  9. package/lib/componentize.js.map +1 -0
  10. package/lib/components/blank.js +371 -0
  11. package/lib/components/blank.js.map +1 -0
  12. package/lib/components/correct-input.js +94 -0
  13. package/lib/components/correct-input.js.map +1 -0
  14. package/lib/components/dropdown.js +483 -0
  15. package/lib/components/dropdown.js.map +1 -0
  16. package/lib/components/input.js +50 -0
  17. package/lib/components/input.js.map +1 -0
  18. package/lib/constructed-response.js +101 -0
  19. package/lib/constructed-response.js.map +1 -0
  20. package/lib/customizable.js +42 -0
  21. package/lib/customizable.js.map +1 -0
  22. package/lib/drag-in-the-blank.js +254 -0
  23. package/lib/drag-in-the-blank.js.map +1 -0
  24. package/lib/index.js +55 -0
  25. package/lib/index.js.map +1 -0
  26. package/lib/inline-dropdown.js +40 -0
  27. package/lib/inline-dropdown.js.map +1 -0
  28. package/lib/mask.js +198 -0
  29. package/lib/mask.js.map +1 -0
  30. package/lib/serialization.js +261 -0
  31. package/lib/serialization.js.map +1 -0
  32. package/lib/with-mask.js +97 -0
  33. package/lib/with-mask.js.map +1 -0
  34. package/package.json +20 -39
  35. package/src/__tests__/drag-in-the-blank.test.js +111 -0
  36. package/src/__tests__/index.test.js +38 -0
  37. package/src/__tests__/mask.test.js +381 -0
  38. package/src/__tests__/serialization.test.js +54 -0
  39. package/src/__tests__/utils.js +1 -0
  40. package/src/__tests__/with-mask.test.js +76 -0
  41. package/src/choices/__tests__/index.test.js +75 -0
  42. package/src/choices/choice.jsx +97 -0
  43. package/src/choices/index.jsx +64 -0
  44. package/src/componentize.js +13 -0
  45. package/src/components/__tests__/blank.test.js +199 -0
  46. package/src/components/__tests__/correct-input.test.js +90 -0
  47. package/src/components/__tests__/dropdown.test.js +129 -0
  48. package/src/components/__tests__/input.test.js +102 -0
  49. package/src/components/blank.jsx +386 -0
  50. package/src/components/correct-input.jsx +82 -0
  51. package/src/components/dropdown.jsx +423 -0
  52. package/src/components/input.jsx +48 -0
  53. package/src/constructed-response.jsx +87 -0
  54. package/src/customizable.jsx +34 -0
  55. package/src/drag-in-the-blank.jsx +241 -0
  56. package/src/index.js +16 -0
  57. package/src/inline-dropdown.jsx +29 -0
  58. package/src/mask.jsx +172 -0
  59. package/src/serialization.js +260 -0
  60. package/src/with-mask.jsx +75 -0
  61. package/dist/_virtual/_rolldown/runtime.js +0 -4
  62. package/dist/choices/choice.d.ts +0 -24
  63. package/dist/choices/choice.js +0 -77
  64. package/dist/choices/index.d.ts +0 -25
  65. package/dist/choices/index.js +0 -49
  66. package/dist/componentize.d.ts +0 -12
  67. package/dist/componentize.js +0 -4
  68. package/dist/components/blank.d.ts +0 -39
  69. package/dist/components/blank.js +0 -240
  70. package/dist/components/correct-input.d.ts +0 -11
  71. package/dist/components/dropdown.d.ts +0 -37
  72. package/dist/components/dropdown.js +0 -320
  73. package/dist/components/input.d.ts +0 -37
  74. package/dist/constructed-response.d.ts +0 -44
  75. package/dist/constructed-response.js +0 -55
  76. package/dist/customizable.d.ts +0 -43
  77. package/dist/customizable.js +0 -8
  78. package/dist/drag-in-the-blank.d.ts +0 -37
  79. package/dist/drag-in-the-blank.js +0 -164
  80. package/dist/index.d.ts +0 -15
  81. package/dist/index.js +0 -7
  82. package/dist/inline-dropdown.d.ts +0 -44
  83. package/dist/inline-dropdown.js +0 -24
  84. package/dist/mask.d.ts +0 -30
  85. package/dist/mask.js +0 -99
  86. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  87. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/index.js +0 -17
  88. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssPrefix.js +0 -9
  89. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssUnitless.js +0 -26
  90. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/hasOwn.js +0 -11
  91. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isFunction.js +0 -11
  92. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isObject.js +0 -11
  93. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixInfo.js +0 -24
  94. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixProperties.js +0 -32
  95. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixer.js +0 -29
  96. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/camelize.js +0 -14
  97. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenRe.js +0 -8
  98. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenate.js +0 -12
  99. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/separate.js +0 -11
  100. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toLowerFirst.js +0 -10
  101. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toUpperFirst.js +0 -10
  102. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleObject.js +0 -55
  103. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleString.js +0 -16
  104. package/dist/serialization.d.ts +0 -34
  105. package/dist/serialization.js +0 -132
  106. package/dist/with-mask.d.ts +0 -55
  107. package/dist/with-mask.js +0 -45
package/LICENSE.md ADDED
@@ -0,0 +1,5 @@
1
+ Copyright 2019 CoreSpring Inc
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.DRAG_TYPE = void 0;
9
+ exports["default"] = Choice;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _core = require("@dnd-kit/core");
15
+ var _styles = require("@mui/material/styles");
16
+ var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
17
+ var _mathRendering = require("@pie-lib/math-rendering");
18
+ var _renderUi = require("@pie-lib/render-ui");
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(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 (var _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); }
20
+ 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; }
21
+ 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) { (0, _defineProperty2["default"])(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; }
22
+ var DRAG_TYPE = exports.DRAG_TYPE = 'MaskBlank';
23
+ var StyledChoice = (0, _styles.styled)('span')(function (_ref) {
24
+ var theme = _ref.theme,
25
+ disabled = _ref.disabled;
26
+ return _objectSpread({
27
+ border: "solid 0px ".concat(theme.palette.primary.main),
28
+ borderRadius: theme.spacing(2),
29
+ margin: theme.spacing(0.5),
30
+ transform: 'translate(0, 0)',
31
+ display: 'inline-flex'
32
+ }, disabled && {});
33
+ });
34
+ var StyledChip = (0, _styles.styled)(_Chip["default"])(function () {
35
+ return {
36
+ backgroundColor: _renderUi.color.white(),
37
+ border: "1px solid ".concat(_renderUi.color.text()),
38
+ color: _renderUi.color.text(),
39
+ alignItems: 'center',
40
+ display: 'inline-flex',
41
+ height: 'initial',
42
+ minHeight: '32px',
43
+ fontSize: 'inherit',
44
+ whiteSpace: 'pre-wrap',
45
+ maxWidth: '374px',
46
+ // Added for touch devices, for image content.
47
+ // This will prevent the context menu from appearing and not allowing other interactions with the image.
48
+ // If interactions with the image in the token will be requested we should handle only the context Menu.
49
+ pointerEvents: 'none',
50
+ borderRadius: '3px',
51
+ paddingTop: '12px',
52
+ paddingBottom: '12px',
53
+ '&.Mui-disabled': {
54
+ opacity: 1
55
+ }
56
+ };
57
+ });
58
+ var StyledChipLabel = (0, _styles.styled)('span')(function () {
59
+ return {
60
+ whiteSpace: 'normal',
61
+ '& img': {
62
+ display: 'block',
63
+ padding: '2px 0'
64
+ },
65
+ '& mjx-frac': {
66
+ fontSize: '120% !important'
67
+ }
68
+ };
69
+ });
70
+ function Choice(_ref2) {
71
+ var _rootRef$current, _rootRef$current2;
72
+ var choice = _ref2.choice,
73
+ disabled = _ref2.disabled,
74
+ instanceId = _ref2.instanceId;
75
+ var rootRef = (0, _react.useRef)(null);
76
+ var _useDraggable = (0, _core.useDraggable)({
77
+ id: "choice-".concat(choice.id),
78
+ data: {
79
+ choice: choice,
80
+ instanceId: instanceId,
81
+ fromChoice: true,
82
+ type: DRAG_TYPE
83
+ },
84
+ disabled: disabled
85
+ }),
86
+ attributes = _useDraggable.attributes,
87
+ listeners = _useDraggable.listeners,
88
+ setNodeRef = _useDraggable.setNodeRef,
89
+ isDragging = _useDraggable.isDragging;
90
+ (0, _react.useEffect)(function () {
91
+ (0, _mathRendering.renderMath)(rootRef.current);
92
+ }, [choice.value]);
93
+ return /*#__PURE__*/_react["default"].createElement(StyledChoice, (0, _extends2["default"])({
94
+ ref: setNodeRef,
95
+ style: isDragging ? {
96
+ width: (_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.offsetWidth,
97
+ height: (_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.offsetHeight
98
+ } : {},
99
+ disabled: disabled
100
+ }, listeners, attributes), /*#__PURE__*/_react["default"].createElement(StyledChip, {
101
+ clickable: false,
102
+ disabled: disabled,
103
+ ref: rootRef,
104
+ label: /*#__PURE__*/_react["default"].createElement(StyledChipLabel, {
105
+ dangerouslySetInnerHTML: {
106
+ __html: choice.value
107
+ }
108
+ })
109
+ }));
110
+ }
111
+ Choice.propTypes = {
112
+ choice: _propTypes["default"].object.isRequired,
113
+ disabled: _propTypes["default"].bool,
114
+ instanceId: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])
115
+ };
116
+ //# sourceMappingURL=choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choice.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_core","_styles","_Chip","_mathRendering","_renderUi","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","DRAG_TYPE","exports","StyledChoice","styled","_ref","theme","disabled","border","concat","palette","primary","main","borderRadius","spacing","margin","transform","display","StyledChip","Chip","backgroundColor","color","white","text","alignItems","height","minHeight","fontSize","whiteSpace","maxWidth","pointerEvents","paddingTop","paddingBottom","opacity","StyledChipLabel","padding","Choice","_ref2","_rootRef$current","_rootRef$current2","choice","instanceId","rootRef","useRef","_useDraggable","useDraggable","id","data","fromChoice","type","attributes","listeners","setNodeRef","isDragging","useEffect","renderMath","current","value","createElement","_extends2","ref","style","width","offsetWidth","offsetHeight","clickable","label","dangerouslySetInnerHTML","__html","propTypes","PropTypes","object","isRequired","bool","oneOfType","string","number"],"sources":["../../src/choices/choice.jsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport PropTypes from 'prop-types';\nimport { useDraggable } from '@dnd-kit/core';\nimport { styled } from '@mui/material/styles';\nimport Chip from '@mui/material/Chip';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { color } from '@pie-lib/render-ui';\n\nexport const DRAG_TYPE = 'MaskBlank';\n\nconst StyledChoice = styled('span')(({ theme, disabled }) => ({\n border: `solid 0px ${theme.palette.primary.main}`,\n borderRadius: theme.spacing(2),\n margin: theme.spacing(0.5),\n transform: 'translate(0, 0)',\n display: 'inline-flex',\n ...(disabled && {}),\n}));\n\nconst StyledChip = styled(Chip)(() => ({\n backgroundColor: color.white(),\n border: `1px solid ${color.text()}`,\n color: color.text(),\n alignItems: 'center',\n display: 'inline-flex',\n height: 'initial',\n minHeight: '32px',\n fontSize: 'inherit',\n whiteSpace: 'pre-wrap',\n maxWidth: '374px',\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 // If interactions with the image in the token will be requested we should handle only the context Menu.\n pointerEvents: 'none',\n borderRadius: '3px',\n paddingTop: '12px',\n paddingBottom: '12px',\n\n '&.Mui-disabled': {\n opacity: 1,\n },\n}));\n\nconst StyledChipLabel = styled('span')(() => ({\n whiteSpace: 'normal',\n '& img': {\n display: 'block',\n padding: '2px 0',\n },\n '& mjx-frac': {\n fontSize: '120% !important',\n },\n}));\n\nexport default function Choice({ choice, disabled, instanceId }) {\n const rootRef = useRef(null);\n\n const { attributes, listeners, setNodeRef, isDragging } = useDraggable({\n id: `choice-${choice.id}`,\n data: { choice, instanceId, fromChoice: true, type: DRAG_TYPE },\n disabled,\n });\n\n useEffect(() => {\n renderMath(rootRef.current);\n }, [choice.value]);\n\n return (\n <StyledChoice\n ref={setNodeRef}\n style={\n isDragging\n ? {\n width: rootRef.current?.offsetWidth,\n height: rootRef.current?.offsetHeight,\n }\n : {}\n }\n disabled={disabled}\n {...listeners}\n {...attributes}\n >\n <StyledChip\n clickable={false}\n disabled={disabled}\n ref={rootRef}\n label={<StyledChipLabel dangerouslySetInnerHTML={{ __html: choice.value }} />}\n />\n </StyledChoice>\n );\n}\n\nChoice.propTypes = {\n choice: PropTypes.object.isRequired,\n disabled: PropTypes.bool,\n instanceId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAA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AG,EAAElB,OAAQ;IACbwB,KAAK,eAAE7G,MAAA,YAAAqG,aAAA,CAACxB,eAAe;MAACiC,uBAAuB,EAAE;QAAEC,MAAM,EAAE5B,MAAM,CAACiB;MAAM;IAAE,CAAE;EAAE,CAC/E,CACW,CAAC;AAEnB;AAEArB,MAAM,CAACiC,SAAS,GAAG;EACjB7B,MAAM,EAAE8B,qBAAS,CAACC,MAAM,CAACC,UAAU;EACnCjE,QAAQ,EAAE+D,qBAAS,CAACG,IAAI;EACxBhC,UAAU,EAAE6B,qBAAS,CAACI,SAAS,CAAC,CAACJ,qBAAS,CAACK,MAAM,EAAEL,qBAAS,CAACM,MAAM,CAAC;AACtE,CAAC","ignoreList":[]}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _propTypes = _interopRequireDefault(require("prop-types"));
16
+ var _lodashEs = require("lodash-es");
17
+ var _choice = _interopRequireDefault(require("./choice"));
18
+ var _drag = require("@pie-lib/drag");
19
+ 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; }
20
+ 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) { (0, _defineProperty2["default"])(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; }
21
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
22
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
23
+ var Choices = exports["default"] = /*#__PURE__*/function (_React$Component) {
24
+ function Choices() {
25
+ var _this;
26
+ (0, _classCallCheck2["default"])(this, Choices);
27
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
+ args[_key] = arguments[_key];
29
+ }
30
+ _this = _callSuper(this, Choices, [].concat(args));
31
+ (0, _defineProperty2["default"])(_this, "getStyleForWrapper", function () {
32
+ var choicePosition = _this.props.choicePosition;
33
+ switch (choicePosition) {
34
+ case 'above':
35
+ return {
36
+ margin: '0 0 40px 0'
37
+ };
38
+ case 'below':
39
+ return {
40
+ margin: '40px 0 0 0'
41
+ };
42
+ case 'right':
43
+ return {
44
+ margin: '0 0 0 40px'
45
+ };
46
+ default:
47
+ return {
48
+ margin: '0 40px 0 0'
49
+ };
50
+ }
51
+ });
52
+ return _this;
53
+ }
54
+ (0, _inherits2["default"])(Choices, _React$Component);
55
+ return (0, _createClass2["default"])(Choices, [{
56
+ key: "render",
57
+ value: function render() {
58
+ var _this$props = this.props,
59
+ disabled = _this$props.disabled,
60
+ duplicates = _this$props.duplicates,
61
+ choices = _this$props.choices,
62
+ value = _this$props.value,
63
+ instanceId = _this$props.instanceId;
64
+ var filteredChoices = choices.filter(function (c) {
65
+ if (duplicates === true) {
66
+ return true;
67
+ }
68
+ var foundChoice = (0, _lodashEs.findKey)(value, function (v) {
69
+ return v === c.id;
70
+ });
71
+ return foundChoice === undefined;
72
+ });
73
+ var elementStyle = _objectSpread(_objectSpread({}, this.getStyleForWrapper()), {}, {
74
+ minWidth: '100px'
75
+ });
76
+ return /*#__PURE__*/_react["default"].createElement("div", {
77
+ style: elementStyle
78
+ }, /*#__PURE__*/_react["default"].createElement(_drag.DragDroppablePlaceholder, {
79
+ disabled: disabled,
80
+ instanceId: instanceId
81
+ }, filteredChoices.map(function (c, index) {
82
+ return /*#__PURE__*/_react["default"].createElement(_choice["default"], {
83
+ key: "".concat(c.value, "-").concat(index),
84
+ disabled: disabled,
85
+ choice: c,
86
+ instanceId: instanceId
87
+ });
88
+ })));
89
+ }
90
+ }]);
91
+ }(_react["default"].Component);
92
+ (0, _defineProperty2["default"])(Choices, "propTypes", {
93
+ disabled: _propTypes["default"].bool,
94
+ duplicates: _propTypes["default"].bool,
95
+ choices: _propTypes["default"].arrayOf(_propTypes["default"].shape({
96
+ label: _propTypes["default"].string,
97
+ value: _propTypes["default"].string
98
+ })),
99
+ value: _propTypes["default"].object,
100
+ choicePosition: _propTypes["default"].string.isRequired,
101
+ instanceId: _propTypes["default"].string // Added for drag isolation
102
+ });
103
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_lodashEs","_choice","_drag","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","Boolean","prototype","valueOf","call","Choices","exports","_React$Component","_this","_classCallCheck2","_len","args","Array","_key","concat","choicePosition","props","margin","_inherits2","_createClass2","key","value","render","_this$props","disabled","duplicates","choices","instanceId","filteredChoices","c","foundChoice","findKey","v","id","undefined","elementStyle","getStyleForWrapper","minWidth","createElement","style","DragDroppablePlaceholder","map","index","choice","React","Component","PropTypes","bool","arrayOf","shape","label","string","object","isRequired"],"sources":["../../src/choices/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { findKey } from 'lodash-es';\nimport Choice from './choice';\nimport { DragDroppablePlaceholder } from '@pie-lib/drag';\n\nexport default class Choices extends React.Component {\n static propTypes = {\n disabled: PropTypes.bool,\n duplicates: PropTypes.bool,\n choices: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string, value: PropTypes.string })),\n value: PropTypes.object,\n choicePosition: PropTypes.string.isRequired,\n instanceId: PropTypes.string, // Added for drag isolation\n };\n\n getStyleForWrapper = () => {\n const { choicePosition } = this.props;\n\n switch (choicePosition) {\n case 'above':\n return {\n margin: '0 0 40px 0',\n };\n\n case 'below':\n return {\n margin: '40px 0 0 0',\n };\n\n case 'right':\n return {\n margin: '0 0 0 40px',\n };\n\n default:\n return {\n margin: '0 40px 0 0',\n };\n }\n };\n\n render() {\n const { disabled, duplicates, choices, value, instanceId } = this.props;\n const filteredChoices = choices.filter((c) => {\n if (duplicates === true) {\n return true;\n }\n const foundChoice = findKey(value, (v) => v === c.id);\n return foundChoice === undefined;\n });\n const elementStyle = { ...this.getStyleForWrapper(), minWidth: '100px' };\n\n return (\n <div style={elementStyle}>\n <DragDroppablePlaceholder disabled={disabled} instanceId={instanceId}>\n {filteredChoices.map((c, index) => (\n <Choice key={`${c.value}-${index}`} disabled={disabled} choice={c} instanceId={instanceId} />\n ))}\n </DragDroppablePlaceholder>\n </div>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAA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AAA,CAC9F,CACuB,CACvB,CAAC;IAEV;EAAC;AAAA,EAxDkCiB,iBAAK,CAACC,SAAS;AAAA,IAAAvD,gBAAA,aAA/Be,OAAO,eACP;EACjBmB,QAAQ,EAAEsB,qBAAS,CAACC,IAAI;EACxBtB,UAAU,EAAEqB,qBAAS,CAACC,IAAI;EAC1BrB,OAAO,EAAEoB,qBAAS,CAACE,OAAO,CAACF,qBAAS,CAACG,KAAK,CAAC;IAAEC,KAAK,EAAEJ,qBAAS,CAACK,MAAM;IAAE9B,KAAK,EAAEyB,qBAAS,CAACK;EAAO,CAAC,CAAC,CAAC;EACjG9B,KAAK,EAAEyB,qBAAS,CAACM,MAAM;EACvBrC,cAAc,EAAE+B,qBAAS,CAACK,MAAM,CAACE,UAAU;EAC3C1B,UAAU,EAAEmB,qBAAS,CAACK,MAAM,CAAE;AAChC,CAAC","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var REGEX = /\{\{(\d+)\}\}/g;
8
+ var _default = exports["default"] = function _default(s, t) {
9
+ if (!s) {
10
+ return {
11
+ markup: ''
12
+ };
13
+ }
14
+ var markup = s.replace(REGEX, function (match, g) {
15
+ return "<span data-component=\"".concat(t, "\" data-id=\"").concat(g, "\"></span>");
16
+ });
17
+ return {
18
+ markup: markup
19
+ };
20
+ };
21
+ //# sourceMappingURL=componentize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentize.js","names":["REGEX","_default","exports","s","t","markup","replace","match","g","concat"],"sources":["../src/componentize.js"],"sourcesContent":["const REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport default (s, t) => {\n if (!s) {\n return { markup: '' };\n }\n\n const markup = s.replace(REGEX, (match, g) => {\n return `<span data-component=\"${t}\" data-id=\"${g}\"></span>`;\n });\n\n return { markup };\n};\n"],"mappings":";;;;;;AAAA,IAAMA,KAAK,GAAG,gBAAgB;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEhB,SAAAD,SAACE,CAAC,EAAEC,CAAC,EAAK;EACvB,IAAI,CAACD,CAAC,EAAE;IACN,OAAO;MAAEE,MAAM,EAAE;IAAG,CAAC;EACvB;EAEA,IAAMA,MAAM,GAAGF,CAAC,CAACG,OAAO,CAACN,KAAK,EAAE,UAACO,KAAK,EAAEC,CAAC,EAAK;IAC5C,iCAAAC,MAAA,CAAgCL,CAAC,mBAAAK,MAAA,CAAcD,CAAC;EAClD,CAAC,CAAC;EAEF,OAAO;IAAEH,MAAM,EAANA;EAAO,CAAC;AACnB,CAAC","ignoreList":[]}
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _mathRendering = require("@pie-lib/math-rendering");
15
+ var _debug = _interopRequireDefault(require("debug"));
16
+ var _core = require("@dnd-kit/core");
17
+ var _utilities = require("@dnd-kit/utilities");
18
+ var _styles = require("@mui/material/styles");
19
+ var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
20
+ var _classnames = _interopRequireDefault(require("classnames"));
21
+ var _renderUi = require("@pie-lib/render-ui");
22
+ var _colors = require("@mui/material/colors");
23
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(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 (var _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); }
24
+ 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; }
25
+ 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) { (0, _defineProperty2["default"])(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; }
26
+ var log = (0, _debug["default"])('pie-lib:mask-markup:blank');
27
+ var StyledContent = (0, _styles.styled)('span')(function (_ref) {
28
+ var dragged = _ref.dragged,
29
+ over = _ref.over;
30
+ return _objectSpread(_objectSpread({
31
+ border: "solid 0px ".concat(_renderUi.color.primary()),
32
+ minWidth: '200px',
33
+ touchAction: 'none',
34
+ overflow: 'hidden',
35
+ whiteSpace: 'nowrap',
36
+ opacity: 1
37
+ }, over && {
38
+ whiteSpace: 'nowrap',
39
+ overflow: 'hidden'
40
+ }), dragged && {
41
+ opacity: 0.5
42
+ });
43
+ });
44
+ var StyledChip = (0, _styles.styled)(_Chip["default"])(function () {
45
+ return {
46
+ backgroundColor: _renderUi.color.background(),
47
+ border: "2px dashed ".concat(_renderUi.color.text()),
48
+ touchAction: 'none',
49
+ color: _renderUi.color.text(),
50
+ fontSize: 'inherit',
51
+ maxWidth: '374px',
52
+ position: 'relative',
53
+ borderRadius: '3px',
54
+ '&.over': {
55
+ whiteSpace: 'nowrap',
56
+ overflow: 'hidden'
57
+ },
58
+ '&.parentOver': {
59
+ border: "1px solid ".concat(_colors.grey[500]),
60
+ backgroundColor: "".concat(_colors.grey[300])
61
+ },
62
+ '&.correct': {
63
+ border: "solid 1px ".concat(_renderUi.color.correct())
64
+ },
65
+ '&.incorrect': {
66
+ border: "solid 1px ".concat(_renderUi.color.incorrect())
67
+ },
68
+ '&.Mui-disabled': {
69
+ opacity: 1
70
+ }
71
+ };
72
+ });
73
+ var StyledChipLabel = (0, _styles.styled)('span')(function () {
74
+ return {
75
+ whiteSpace: 'normal',
76
+ // Added for touch devices, for image content.
77
+ // This will prevent the context menu from appearing and not allowing other interactions with the image.
78
+ // If interactions with the image in the token will be requested we should handle only the context Menu.
79
+ pointerEvents: 'none',
80
+ '& img': {
81
+ display: 'block',
82
+ padding: '2px 0'
83
+ },
84
+ // Remove default <p> margins to ensure consistent spacing across all wrapped content (p, span, div, math)
85
+ // Padding for top and bottom will instead be controlled by the container for consistent layout
86
+ // Ensures consistent behavior with pie-api-browser, where marginTop is already removed by a Bootstrap stylesheet
87
+ '& p': {
88
+ marginTop: '0',
89
+ marginBottom: '0'
90
+ },
91
+ '& mjx-frac': {
92
+ fontSize: '120% !important'
93
+ },
94
+ '&.over': {
95
+ whiteSpace: 'nowrap',
96
+ overflow: 'hidden'
97
+ },
98
+ '&.hidden': {
99
+ color: 'transparent',
100
+ opacity: 0
101
+ },
102
+ '&.dragged': {
103
+ position: 'absolute',
104
+ left: 16,
105
+ maxWidth: '60px',
106
+ top: '50%',
107
+ transform: 'translateY(-50%)'
108
+ }
109
+ };
110
+ });
111
+ function BlankContent(_ref2) {
112
+ var _dragItem$choice, _frozenRef$current, _frozenRef$current2;
113
+ var disabled = _ref2.disabled,
114
+ choice = _ref2.choice,
115
+ isOver = _ref2.isOver,
116
+ isDragging = _ref2.isDragging,
117
+ dragItem = _ref2.dragItem,
118
+ correct = _ref2.correct,
119
+ emptyResponseAreaWidth = _ref2.emptyResponseAreaWidth,
120
+ emptyResponseAreaHeight = _ref2.emptyResponseAreaHeight;
121
+ var rootRef = (0, _react.useRef)(null);
122
+ var spanRef = (0, _react.useRef)(null);
123
+ var frozenRef = (0, _react.useRef)(null); // to use during dragging to prevent flickering
124
+ var _useState = (0, _react.useState)({
125
+ height: 0,
126
+ width: 0
127
+ }),
128
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
129
+ dimensions = _useState2[0],
130
+ setDimensions = _useState2[1];
131
+ var handleImageLoad = function handleImageLoad() {
132
+ updateDimensions();
133
+ };
134
+ var handleElements = function handleElements() {
135
+ var _spanRef$current;
136
+ var imageElement = (_spanRef$current = spanRef.current) === null || _spanRef$current === void 0 ? void 0 : _spanRef$current.querySelector('img');
137
+ if (imageElement) {
138
+ imageElement.onload = handleImageLoad;
139
+ } else {
140
+ setTimeout(function () {
141
+ updateDimensions();
142
+ }, 300);
143
+ }
144
+ };
145
+ var getMeasureNode = function getMeasureNode() {
146
+ if (!spanRef.current) return null;
147
+ var mjx = spanRef.current.querySelector('mjx-container');
148
+ if (mjx && spanRef.current.parentElement) return spanRef.current.parentElement;
149
+ var img = spanRef.current.querySelector('img');
150
+ if (img) return img;
151
+ return spanRef.current;
152
+ };
153
+ var updateDimensions = function updateDimensions() {
154
+ if (spanRef.current && rootRef.current) {
155
+ // Temporarily set rootRef width to 'auto' for natural measurement
156
+ rootRef.current.style.width = 'auto';
157
+ rootRef.current.style.height = 'auto';
158
+ rootRef.current.offsetHeight;
159
+ var measureNode = getMeasureNode();
160
+ var node = measureNode || spanRef.current;
161
+ var rect = node.getBoundingClientRect();
162
+ var width = rect.width || node.offsetWidth || 0;
163
+ var height = Math.max(rect.height || 0, node.offsetHeight || 0, node.scrollHeight || 0, spanRef.current.scrollHeight || 0);
164
+ var widthWithPadding = width + 24; // 12px padding on each side
165
+ var heightWithPadding = height + 24; // 12px padding on top and bottom
166
+
167
+ var responseAreaWidth = parseFloat(emptyResponseAreaWidth) || 0;
168
+ var responseAreaHeight = parseFloat(emptyResponseAreaHeight) || 0;
169
+ var adjustedWidth = widthWithPadding <= responseAreaWidth ? responseAreaWidth : widthWithPadding;
170
+ var adjustedHeight = heightWithPadding <= responseAreaHeight ? responseAreaHeight : heightWithPadding;
171
+ setDimensions(function (prevState) {
172
+ return {
173
+ width: adjustedWidth > responseAreaWidth ? adjustedWidth : prevState.width,
174
+ height: adjustedHeight > responseAreaHeight ? adjustedHeight : prevState.height
175
+ };
176
+ });
177
+ rootRef.current.style.width = "".concat(adjustedWidth, "px");
178
+ rootRef.current.style.height = "".concat(adjustedHeight, "px");
179
+ }
180
+ };
181
+ var getRootDimensions = function getRootDimensions() {
182
+ // Handle potential non-numeric values
183
+ var responseAreaWidth = !isNaN(parseFloat(emptyResponseAreaWidth)) ? parseFloat(emptyResponseAreaWidth) : 0;
184
+ var responseAreaHeight = !isNaN(parseFloat(emptyResponseAreaHeight)) ? parseFloat(emptyResponseAreaHeight) : 0;
185
+ var rootStyle = {
186
+ height: dimensions.height || responseAreaHeight,
187
+ width: dimensions.width || responseAreaWidth
188
+ };
189
+
190
+ // add minWidth, minHeight if width and height are not defined
191
+ return _objectSpread(_objectSpread(_objectSpread({}, rootStyle), responseAreaWidth ? {} : {
192
+ minWidth: 90
193
+ }), responseAreaHeight ? {} : {
194
+ minHeight: 32
195
+ });
196
+ };
197
+ (0, _react.useEffect)(function () {
198
+ handleElements();
199
+ }, []);
200
+
201
+ // Render math for the placeholder/preview when dragging over
202
+ (0, _react.useEffect)(function () {
203
+ if (rootRef.current) {
204
+ (0, _mathRendering.renderMath)(rootRef.current);
205
+ }
206
+ }, [correct, isOver, dragItem === null || dragItem === void 0 || (_dragItem$choice = dragItem.choice) === null || _dragItem$choice === void 0 ? void 0 : _dragItem$choice.value]);
207
+ (0, _react.useEffect)(function () {
208
+ if (!choice) {
209
+ setDimensions({
210
+ height: 0,
211
+ width: 0
212
+ });
213
+ return;
214
+ }
215
+ handleElements();
216
+ }, [choice]);
217
+ (0, _react.useEffect)(function () {
218
+ if (!isOver && !isDragging) {
219
+ frozenRef.current = {
220
+ width: rootRef.current.offsetWidth,
221
+ height: rootRef.current.offsetHeight
222
+ };
223
+ }
224
+ }, [choice, isOver, isDragging]);
225
+ var draggedLabel = dragItem && isOver && dragItem.choice && dragItem.choice.value;
226
+ var label = choice && choice.value;
227
+ var style = isOver || isDragging ? {
228
+ width: (_frozenRef$current = frozenRef.current) === null || _frozenRef$current === void 0 ? void 0 : _frozenRef$current.width,
229
+ height: (_frozenRef$current2 = frozenRef.current) === null || _frozenRef$current2 === void 0 ? void 0 : _frozenRef$current2.height
230
+ } : getRootDimensions();
231
+ return /*#__PURE__*/_react["default"].createElement(StyledChip, {
232
+ clickable: false,
233
+ disabled: disabled,
234
+ ref: rootRef,
235
+ component: "span",
236
+ label: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(StyledChipLabel, {
237
+ ref: spanRef,
238
+ draggable: true,
239
+ className: (0, _classnames["default"])({
240
+ over: isOver,
241
+ hidden: draggedLabel
242
+ }),
243
+ dangerouslySetInnerHTML: {
244
+ __html: label || ''
245
+ }
246
+ }), draggedLabel && /*#__PURE__*/_react["default"].createElement(StyledChipLabel, {
247
+ draggable: true,
248
+ className: (0, _classnames["default"])({
249
+ over: isOver,
250
+ dragged: true
251
+ }),
252
+ dangerouslySetInnerHTML: {
253
+ __html: draggedLabel || ''
254
+ }
255
+ })),
256
+ className: (0, _classnames["default"])({
257
+ over: isOver,
258
+ parentOver: isOver,
259
+ correct: correct !== undefined && correct,
260
+ incorrect: correct !== undefined && !correct
261
+ }),
262
+ variant: disabled ? 'outlined' : undefined,
263
+ style: style
264
+ });
265
+ }
266
+ BlankContent.defaultProps = {
267
+ emptyResponseAreaWidth: 0,
268
+ emptyResponseAreaHeight: 0
269
+ };
270
+ BlankContent.propTypes = {
271
+ id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
272
+ disabled: _propTypes["default"].bool,
273
+ duplicates: _propTypes["default"].bool,
274
+ choice: _propTypes["default"].object,
275
+ isOver: _propTypes["default"].bool,
276
+ dragItem: _propTypes["default"].object,
277
+ correct: _propTypes["default"].bool,
278
+ onChange: _propTypes["default"].func,
279
+ emptyResponseAreaWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
280
+ emptyResponseAreaHeight: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
281
+ instanceId: _propTypes["default"].string
282
+ };
283
+
284
+ // New functional component using @dnd-kit hooks
285
+ function DragDropBlank(_ref3) {
286
+ var _dragItem$data;
287
+ var id = _ref3.id,
288
+ disabled = _ref3.disabled,
289
+ duplicates = _ref3.duplicates,
290
+ choice = _ref3.choice,
291
+ correct = _ref3.correct,
292
+ onChange = _ref3.onChange,
293
+ emptyResponseAreaWidth = _ref3.emptyResponseAreaWidth,
294
+ emptyResponseAreaHeight = _ref3.emptyResponseAreaHeight,
295
+ instanceId = _ref3.instanceId;
296
+ // Setup draggable functionality
297
+ var _useDraggable = (0, _core.useDraggable)({
298
+ id: "mask-blank-drag-".concat(id),
299
+ disabled: disabled || !choice,
300
+ data: {
301
+ id: id,
302
+ choice: choice,
303
+ instanceId: instanceId,
304
+ fromChoice: false,
305
+ // This is from a blank, not from choices
306
+ type: 'MaskBlank'
307
+ }
308
+ }),
309
+ dragAttributes = _useDraggable.attributes,
310
+ dragListeners = _useDraggable.listeners,
311
+ setDragNodeRef = _useDraggable.setNodeRef,
312
+ transform = _useDraggable.transform,
313
+ isDragging = _useDraggable.isDragging;
314
+
315
+ // Setup droppable functionality
316
+ var _useDroppable = (0, _core.useDroppable)({
317
+ id: "mask-blank-drop-".concat(id),
318
+ data: {
319
+ id: id,
320
+ accepts: ['MaskBlank'],
321
+ instanceId: instanceId
322
+ }
323
+ }),
324
+ setDropNodeRef = _useDroppable.setNodeRef,
325
+ isOver = _useDroppable.isOver,
326
+ dragItem = _useDroppable.active;
327
+
328
+ // Combine refs for both drag and drop
329
+ var setNodeRef = function setNodeRef(node) {
330
+ setDragNodeRef(node);
331
+ setDropNodeRef(node);
332
+ };
333
+ var style = {
334
+ transform: _utilities.CSS.Translate.toString(transform)
335
+ };
336
+ return /*#__PURE__*/_react["default"].createElement(StyledContent, (0, _extends2["default"])({
337
+ ref: setNodeRef,
338
+ style: style,
339
+ dragged: isDragging,
340
+ over: isOver
341
+ }, dragAttributes, dragListeners), /*#__PURE__*/_react["default"].createElement(BlankContent, {
342
+ id: id,
343
+ disabled: disabled,
344
+ duplicates: duplicates,
345
+ choice: choice,
346
+ isOver: isOver,
347
+ dragItem: dragItem === null || dragItem === void 0 || (_dragItem$data = dragItem.data) === null || _dragItem$data === void 0 ? void 0 : _dragItem$data.current,
348
+ correct: correct,
349
+ onChange: onChange,
350
+ emptyResponseAreaWidth: emptyResponseAreaWidth,
351
+ emptyResponseAreaHeight: emptyResponseAreaHeight,
352
+ instanceId: instanceId
353
+ }));
354
+ }
355
+ DragDropBlank.defaultProps = {
356
+ emptyResponseAreaWidth: 0,
357
+ emptyResponseAreaHeight: 0
358
+ };
359
+ DragDropBlank.propTypes = {
360
+ id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
361
+ disabled: _propTypes["default"].bool,
362
+ duplicates: _propTypes["default"].bool,
363
+ choice: _propTypes["default"].object,
364
+ correct: _propTypes["default"].bool,
365
+ onChange: _propTypes["default"].func,
366
+ emptyResponseAreaWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
367
+ emptyResponseAreaHeight: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
368
+ instanceId: _propTypes["default"].string
369
+ };
370
+ var _default = exports["default"] = DragDropBlank;
371
+ //# sourceMappingURL=blank.js.map