@pie-lib/mask-markup 1.33.2 → 1.33.3-next.155
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/CHANGELOG.md +6 -76
- package/esm/package.json +3 -0
- package/lib/choices/choice.js +98 -203
- package/lib/choices/choice.js.map +1 -1
- package/lib/choices/index.js +21 -53
- package/lib/choices/index.js.map +1 -1
- package/lib/componentize.js +1 -5
- package/lib/componentize.js.map +1 -1
- package/lib/components/blank.js +303 -361
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js +41 -65
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js +218 -257
- package/lib/components/dropdown.js.map +1 -1
- package/lib/components/input.js +10 -17
- package/lib/components/input.js.map +1 -1
- package/lib/constructed-response.js +38 -52
- package/lib/constructed-response.js.map +1 -1
- package/lib/customizable.js +5 -9
- package/lib/customizable.js.map +1 -1
- package/lib/drag-in-the-blank.js +140 -105
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +1 -1
- package/lib/inline-dropdown.js +4 -12
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js +60 -118
- package/lib/mask.js.map +1 -1
- package/lib/serialization.js +8 -48
- package/lib/serialization.js.map +1 -1
- package/lib/with-mask.js +30 -58
- package/lib/with-mask.js.map +1 -1
- package/package.json +20 -12
- package/src/__tests__/drag-in-the-blank.test.js +66 -26
- package/src/__tests__/mask.test.js +147 -112
- package/src/__tests__/with-mask.test.js +44 -19
- package/src/choices/__tests__/index.test.js +38 -25
- package/src/choices/choice.jsx +86 -153
- package/src/choices/index.jsx +9 -3
- package/src/components/__tests__/blank.test.js +92 -156
- package/src/components/__tests__/correct-input.test.js +60 -19
- package/src/components/__tests__/dropdown.test.js +61 -19
- package/src/components/__tests__/input.test.js +72 -20
- package/src/components/blank.jsx +273 -272
- package/src/components/correct-input.jsx +33 -39
- package/src/components/dropdown.jsx +173 -161
- package/src/constructed-response.jsx +22 -18
- package/src/drag-in-the-blank.jsx +131 -42
- package/src/mask.jsx +38 -29
- package/src/with-mask.jsx +7 -4
- package/src/__tests__/__snapshots__/drag-in-the-blank.test.js.snap +0 -316
- package/src/__tests__/__snapshots__/mask.test.js.snap +0 -55
- package/src/__tests__/__snapshots__/with-mask.test.js.snap +0 -62
- package/src/choices/__tests__/__snapshots__/index.test.js.snap +0 -209
- package/src/components/__tests__/__snapshots__/blank.test.js.snap +0 -111
- package/src/components/__tests__/__snapshots__/correct-input.test.js.snap +0 -64
- package/src/components/__tests__/__snapshots__/dropdown.test.js.snap +0 -136
- package/src/components/__tests__/__snapshots__/input.test.js.snap +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -7,153 +7,83 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
10
|
## [1.33.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.29.2...@pie-lib/mask-markup@1.33.1) (2025-10-22)
|
|
15
11
|
|
|
16
12
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
14
|
# [1.33.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.32.0...@pie-lib/mask-markup@1.33.0) (2025-10-16)
|
|
23
15
|
|
|
24
16
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
18
|
# [1.32.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.29.0...@pie-lib/mask-markup@1.32.0) (2025-10-16)
|
|
31
19
|
|
|
32
20
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
33
21
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
22
|
# [1.31.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.29.0...@pie-lib/mask-markup@1.31.0) (2025-10-16)
|
|
39
23
|
|
|
40
24
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
26
|
# [1.30.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.29.0...@pie-lib/mask-markup@1.30.0) (2025-10-16)
|
|
47
27
|
|
|
48
28
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
49
29
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
30
|
## [1.29.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.29.1...@pie-lib/mask-markup@1.29.2) (2025-10-14)
|
|
55
31
|
|
|
56
32
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
57
33
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
34
|
## [1.29.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.29.0...@pie-lib/mask-markup@1.29.1) (2025-10-09)
|
|
63
35
|
|
|
64
36
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
65
37
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
38
|
# [1.29.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.13.46...@pie-lib/mask-markup@1.29.0) (2025-09-25)
|
|
71
39
|
|
|
72
|
-
|
|
73
40
|
### Bug Fixes
|
|
74
41
|
|
|
75
|
-
|
|
76
|
-
|
|
42
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
77
43
|
|
|
78
44
|
### Features
|
|
79
45
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
46
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
85
47
|
|
|
86
48
|
# [1.28.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.27.0...@pie-lib/mask-markup@1.28.0) (2025-09-18)
|
|
87
49
|
|
|
88
50
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
89
51
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
52
|
# [1.27.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.26.0...@pie-lib/mask-markup@1.27.0) (2025-09-18)
|
|
95
53
|
|
|
96
54
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
97
55
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
56
|
# [1.26.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.13.46...@pie-lib/mask-markup@1.26.0) (2025-09-18)
|
|
103
57
|
|
|
104
|
-
|
|
105
58
|
### Bug Fixes
|
|
106
59
|
|
|
107
|
-
|
|
108
|
-
|
|
60
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
109
61
|
|
|
110
62
|
### Features
|
|
111
63
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
64
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
117
65
|
|
|
118
66
|
# [1.25.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.24.0...@pie-lib/mask-markup@1.25.0) (2025-09-17)
|
|
119
67
|
|
|
120
68
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
121
69
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
70
|
# [1.24.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.23.0...@pie-lib/mask-markup@1.24.0) (2025-09-17)
|
|
127
71
|
|
|
128
72
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
129
73
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
74
|
# [1.23.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.22.1...@pie-lib/mask-markup@1.23.0) (2025-09-17)
|
|
135
75
|
|
|
136
76
|
**Note:** Version bump only for package @pie-lib/mask-markup
|
|
137
77
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
78
|
## [1.22.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.13.46...@pie-lib/mask-markup@1.22.1) (2025-08-11)
|
|
143
79
|
|
|
144
|
-
|
|
145
80
|
### Bug Fixes
|
|
146
81
|
|
|
147
|
-
|
|
148
|
-
|
|
82
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
149
83
|
|
|
150
84
|
### Features
|
|
151
85
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
86
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
157
87
|
|
|
158
88
|
# [1.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/mask-markup@1.13.46...@pie-lib/mask-markup@1.22.0) (2025-08-07)
|
|
159
89
|
|
package/esm/package.json
ADDED
package/lib/choices/choice.js
CHANGED
|
@@ -1,221 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
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
|
-
|
|
8
|
+
exports.DRAG_TYPE = void 0;
|
|
9
|
+
exports["default"] = Choice;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
22
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
27
|
-
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
28
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
-
|
|
30
|
-
var _styles = require("@material
|
|
31
|
-
|
|
32
|
-
var _Chip = _interopRequireDefault(require("@material-ui/core/Chip"));
|
|
33
|
-
|
|
34
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
35
|
-
|
|
14
|
+
var _core = require("@dnd-kit/core");
|
|
15
|
+
var _styles = require("@mui/material/styles");
|
|
16
|
+
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
36
17
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
37
|
-
|
|
38
18
|
var _renderUi = require("@pie-lib/render-ui");
|
|
39
|
-
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_this.longPressTimer = setTimeout(function () {
|
|
76
|
-
_this.startDrag(e);
|
|
77
|
-
}, 500);
|
|
78
|
-
});
|
|
79
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleTouchEnd", function () {
|
|
80
|
-
clearTimeout(_this.longPressTimer);
|
|
81
|
-
});
|
|
82
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleTouchMove", function () {
|
|
83
|
-
clearTimeout(_this.longPressTimer);
|
|
84
|
-
});
|
|
85
|
-
return _this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
(0, _createClass2["default"])(BlankContentComp, [{
|
|
89
|
-
key: "componentDidMount",
|
|
90
|
-
value: function componentDidMount() {
|
|
91
|
-
if (this.dragContainerRef) {
|
|
92
|
-
this.dragContainerRef.addEventListener('touchstart', this.handleTouchStart, {
|
|
93
|
-
passive: false
|
|
94
|
-
});
|
|
95
|
-
this.dragContainerRef.addEventListener('touchend', this.handleTouchEnd);
|
|
96
|
-
this.dragContainerRef.addEventListener('touchmove', this.handleTouchMove);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "componentWillUnmount",
|
|
101
|
-
value: function componentWillUnmount() {
|
|
102
|
-
if (this.dragContainerRef) {
|
|
103
|
-
this.dragContainerRef.removeEventListener('touchstart', this.handleTouchStart);
|
|
104
|
-
this.dragContainerRef.removeEventListener('touchend', this.handleTouchEnd);
|
|
105
|
-
this.dragContainerRef.removeEventListener('touchmove', this.handleTouchMove);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
key: "componentDidUpdate",
|
|
110
|
-
value: function componentDidUpdate() {
|
|
111
|
-
(0, _mathRendering.renderMath)(this.rootRef);
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "render",
|
|
115
|
-
value: function render() {
|
|
116
|
-
var _this2 = this;
|
|
117
|
-
|
|
118
|
-
var _this$props2 = this.props,
|
|
119
|
-
connectDragSource = _this$props2.connectDragSource,
|
|
120
|
-
choice = _this$props2.choice,
|
|
121
|
-
classes = _this$props2.classes,
|
|
122
|
-
disabled = _this$props2.disabled; // TODO the Chip element is causing drag problems on touch devices. Avoid using Chip and consider refactoring the code. Keep in mind that Chip is a span with a button role, which interferes with seamless touch device dragging.
|
|
123
|
-
|
|
124
|
-
return connectDragSource( /*#__PURE__*/_react["default"].createElement("span", {
|
|
125
|
-
className: (0, _classnames["default"])(classes.choice, disabled && classes.disabled),
|
|
126
|
-
ref: function ref(_ref3) {
|
|
127
|
-
//eslint-disable-next-line
|
|
128
|
-
_this2.dragContainerRef = _reactDom["default"].findDOMNode(_ref3);
|
|
129
|
-
}
|
|
130
|
-
}, /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
131
|
-
clickable: false,
|
|
132
|
-
disabled: true,
|
|
133
|
-
ref: function ref(_ref2) {
|
|
134
|
-
//eslint-disable-next-line
|
|
135
|
-
_this2.rootRef = _reactDom["default"].findDOMNode(_ref2);
|
|
136
|
-
},
|
|
137
|
-
className: classes.chip,
|
|
138
|
-
label: /*#__PURE__*/_react["default"].createElement("span", {
|
|
139
|
-
className: classes.chipLabel,
|
|
140
|
-
ref: function ref(_ref) {
|
|
141
|
-
if (_ref) {
|
|
142
|
-
_ref.innerHTML = choice.value || ' ';
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}, ' '),
|
|
146
|
-
variant: disabled ? 'outlined' : undefined
|
|
147
|
-
})), {});
|
|
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
|
|
148
55
|
}
|
|
149
|
-
}
|
|
150
|
-
return BlankContentComp;
|
|
151
|
-
}(_react["default"].Component);
|
|
152
|
-
|
|
153
|
-
(0, _defineProperty2["default"])(BlankContentComp, "propTypes", {
|
|
154
|
-
disabled: _propTypes["default"].bool,
|
|
155
|
-
choice: _propTypes["default"].object,
|
|
156
|
-
classes: _propTypes["default"].object,
|
|
157
|
-
connectDragSource: _propTypes["default"].func
|
|
56
|
+
};
|
|
158
57
|
});
|
|
159
|
-
var
|
|
58
|
+
var StyledChipLabel = (0, _styles.styled)('span')(function () {
|
|
160
59
|
return {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
transform: 'translate(0, 0)'
|
|
166
|
-
},
|
|
167
|
-
chip: {
|
|
168
|
-
backgroundColor: _renderUi.color.white(),
|
|
169
|
-
border: "1px solid ".concat(_renderUi.color.text()),
|
|
170
|
-
color: _renderUi.color.text(),
|
|
171
|
-
alignItems: 'center',
|
|
172
|
-
display: 'inline-flex',
|
|
173
|
-
height: 'initial',
|
|
174
|
-
minHeight: '32px',
|
|
175
|
-
fontSize: 'inherit',
|
|
176
|
-
whiteSpace: 'pre-wrap',
|
|
177
|
-
maxWidth: '374px',
|
|
178
|
-
// Added for touch devices, for image content.
|
|
179
|
-
// This will prevent the context menu from appearing and not allowing other interactions with the image.
|
|
180
|
-
// If interactions with the image in the token will be requested we should handle only the context Menu.
|
|
181
|
-
pointerEvents: 'none',
|
|
182
|
-
borderRadius: '3px',
|
|
183
|
-
paddingTop: '12px',
|
|
184
|
-
paddingBottom: '12px'
|
|
185
|
-
},
|
|
186
|
-
chipLabel: {
|
|
187
|
-
whiteSpace: 'normal',
|
|
188
|
-
'& img': {
|
|
189
|
-
display: 'block',
|
|
190
|
-
padding: '2px 0'
|
|
191
|
-
},
|
|
192
|
-
'& mjx-frac': {
|
|
193
|
-
fontSize: '120% !important'
|
|
194
|
-
}
|
|
60
|
+
whiteSpace: 'normal',
|
|
61
|
+
'& img': {
|
|
62
|
+
display: 'block',
|
|
63
|
+
padding: '2px 0'
|
|
195
64
|
},
|
|
196
|
-
|
|
197
|
-
|
|
65
|
+
'& mjx-frac': {
|
|
66
|
+
fontSize: '120% !important'
|
|
198
67
|
}
|
|
199
68
|
};
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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])
|
|
212
115
|
};
|
|
213
|
-
var DragDropTile = (0, _drag.DragSource)(DRAG_TYPE, tileSource, function (connect, monitor) {
|
|
214
|
-
return {
|
|
215
|
-
connectDragSource: connect.dragSource(),
|
|
216
|
-
isDragging: monitor.isDragging()
|
|
217
|
-
};
|
|
218
|
-
})(BlankContent);
|
|
219
|
-
var _default = DragDropTile;
|
|
220
|
-
exports["default"] = _default;
|
|
221
116
|
//# sourceMappingURL=choice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAA2C,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,wBAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,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