@pie-lib/mask-markup 3.1.6-beta.2 → 4.0.0-next.20261002094057
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/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/choices/choice.d.ts +28 -0
- package/dist/choices/choice.js +92 -0
- package/dist/choices/index.d.ts +29 -0
- package/dist/choices/index.js +59 -0
- package/dist/componentize.d.ts +12 -0
- package/dist/componentize.js +4 -0
- package/dist/components/blank.d.ts +45 -0
- package/dist/components/blank.js +273 -0
- package/dist/components/dropdown.d.ts +37 -0
- package/dist/components/dropdown.js +311 -0
- package/dist/constructed-response.d.ts +44 -0
- package/dist/constructed-response.js +56 -0
- package/dist/customizable.d.ts +43 -0
- package/dist/customizable.js +8 -0
- package/dist/drag-in-the-blank.d.ts +47 -0
- package/dist/drag-in-the-blank.js +220 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +7 -0
- package/dist/inline-dropdown.d.ts +44 -0
- package/dist/inline-dropdown.js +24 -0
- package/dist/keyboard-coordinates.d.ts +25 -0
- package/dist/keyboard-coordinates.js +49 -0
- package/dist/mask.d.ts +30 -0
- package/dist/mask.js +95 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/index.js +17 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssPrefix.js +9 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssUnitless.js +26 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/hasOwn.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isFunction.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isObject.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixInfo.js +24 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixProperties.js +32 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixer.js +29 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/camelize.js +14 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenRe.js +8 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenate.js +12 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/separate.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toLowerFirst.js +10 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toUpperFirst.js +10 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleObject.js +55 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleString.js +16 -0
- package/dist/serialization.d.ts +34 -0
- package/dist/serialization.js +132 -0
- package/dist/with-mask.d.ts +55 -0
- package/dist/with-mask.js +45 -0
- package/package.json +35 -19
- package/CHANGELOG.json +0 -17
- package/CHANGELOG.md +0 -1256
- package/lib/choices/choice.js +0 -120
- package/lib/choices/choice.js.map +0 -1
- package/lib/choices/index.js +0 -103
- package/lib/choices/index.js.map +0 -1
- package/lib/componentize.js +0 -21
- package/lib/componentize.js.map +0 -1
- package/lib/components/blank.js +0 -412
- package/lib/components/blank.js.map +0 -1
- package/lib/components/correct-input.js +0 -94
- package/lib/components/correct-input.js.map +0 -1
- package/lib/components/dropdown.js +0 -483
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/input.js +0 -50
- package/lib/components/input.js.map +0 -1
- package/lib/constructed-response.js +0 -101
- package/lib/constructed-response.js.map +0 -1
- package/lib/customizable.js +0 -42
- package/lib/customizable.js.map +0 -1
- package/lib/drag-in-the-blank.js +0 -254
- package/lib/drag-in-the-blank.js.map +0 -1
- package/lib/index.js +0 -55
- package/lib/index.js.map +0 -1
- package/lib/inline-dropdown.js +0 -40
- package/lib/inline-dropdown.js.map +0 -1
- package/lib/keyboard-coordinates.js +0 -156
- package/lib/mask.js +0 -198
- package/lib/mask.js.map +0 -1
- package/lib/serialization.js +0 -261
- package/lib/serialization.js.map +0 -1
- package/lib/with-mask.js +0 -97
- package/lib/with-mask.js.map +0 -1
- package/src/choices/choice.jsx +0 -100
- package/src/choices/index.jsx +0 -64
- package/src/componentize.js +0 -13
- package/src/components/blank.jsx +0 -431
- package/src/components/correct-input.jsx +0 -82
- package/src/components/dropdown.jsx +0 -423
- package/src/components/input.jsx +0 -48
- package/src/constructed-response.jsx +0 -87
- package/src/customizable.jsx +0 -34
- package/src/drag-in-the-blank.jsx +0 -241
- package/src/index.js +0 -16
- package/src/inline-dropdown.jsx +0 -29
- package/src/mask.jsx +0 -172
- package/src/serialization.js +0 -260
- package/src/with-mask.jsx +0 -75
package/src/components/blank.jsx
DELETED
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { renderMath } from '@pie-lib/math-rendering';
|
|
4
|
-
import debug from 'debug';
|
|
5
|
-
import { useDraggable, useDroppable } from '@dnd-kit/core';
|
|
6
|
-
import { CSS } from '@dnd-kit/utilities';
|
|
7
|
-
import { styled } from '@mui/material/styles';
|
|
8
|
-
import Chip from '@mui/material/Chip';
|
|
9
|
-
import classnames from 'classnames';
|
|
10
|
-
import { color } from '@pie-lib/render-ui';
|
|
11
|
-
import { grey } from '@mui/material/colors';
|
|
12
|
-
|
|
13
|
-
const log = debug('pie-lib:mask-markup:blank');
|
|
14
|
-
|
|
15
|
-
const StyledContent = styled('span')(({ dragged, over }) => ({
|
|
16
|
-
border: `solid 0px ${color.primary()}`,
|
|
17
|
-
minWidth: '200px',
|
|
18
|
-
touchAction: 'none',
|
|
19
|
-
overflow: 'hidden',
|
|
20
|
-
whiteSpace: 'nowrap',
|
|
21
|
-
opacity: 1,
|
|
22
|
-
...(over && {
|
|
23
|
-
whiteSpace: 'nowrap',
|
|
24
|
-
overflow: 'hidden',
|
|
25
|
-
}),
|
|
26
|
-
...(dragged && {
|
|
27
|
-
opacity: 0.5,
|
|
28
|
-
}),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
const StyledChip = styled(Chip)(() => ({
|
|
32
|
-
backgroundColor: color.background(),
|
|
33
|
-
border: `2px dashed ${color.text()}`,
|
|
34
|
-
touchAction: 'none',
|
|
35
|
-
color: color.text(),
|
|
36
|
-
fontSize: 'inherit',
|
|
37
|
-
maxWidth: '374px',
|
|
38
|
-
position: 'relative',
|
|
39
|
-
borderRadius: '3px',
|
|
40
|
-
'&.over': {
|
|
41
|
-
whiteSpace: 'nowrap',
|
|
42
|
-
overflow: 'hidden',
|
|
43
|
-
},
|
|
44
|
-
'&.parentOver': {
|
|
45
|
-
border: `1px solid ${grey[500]}`,
|
|
46
|
-
backgroundColor: `${grey[300]}`,
|
|
47
|
-
},
|
|
48
|
-
'&.correct': {
|
|
49
|
-
border: `solid 1px ${color.correct()}`,
|
|
50
|
-
},
|
|
51
|
-
'&.incorrect': {
|
|
52
|
-
border: `solid 1px ${color.incorrect()}`,
|
|
53
|
-
},
|
|
54
|
-
'&.Mui-disabled': {
|
|
55
|
-
opacity: 1,
|
|
56
|
-
},
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
const StyledChipLabel = styled('span')(() => ({
|
|
60
|
-
whiteSpace: 'normal',
|
|
61
|
-
// Added for touch devices, for image content.
|
|
62
|
-
// This will prevent the context menu from appearing and not allowing other interactions with the image.
|
|
63
|
-
// If interactions with the image in the token will be requested we should handle only the context Menu.
|
|
64
|
-
pointerEvents: 'none',
|
|
65
|
-
'& img': {
|
|
66
|
-
display: 'block',
|
|
67
|
-
padding: '2px 0',
|
|
68
|
-
},
|
|
69
|
-
// Remove default <p> margins to ensure consistent spacing across all wrapped content (p, span, div, math)
|
|
70
|
-
// Padding for top and bottom will instead be controlled by the container for consistent layout
|
|
71
|
-
// Ensures consistent behavior with pie-api-browser, where marginTop is already removed by a Bootstrap stylesheet
|
|
72
|
-
'& p': {
|
|
73
|
-
marginTop: '0',
|
|
74
|
-
marginBottom: '0',
|
|
75
|
-
},
|
|
76
|
-
'& mjx-frac': {
|
|
77
|
-
fontSize: '120% !important',
|
|
78
|
-
},
|
|
79
|
-
'& mjx-mn:has(~ mjx-mfrac), mjx-mfrac ~ mjx-mn': {
|
|
80
|
-
fontSize: '120% !important',
|
|
81
|
-
},
|
|
82
|
-
'&.over': {
|
|
83
|
-
whiteSpace: 'nowrap',
|
|
84
|
-
overflow: 'hidden',
|
|
85
|
-
},
|
|
86
|
-
'&.hidden': {
|
|
87
|
-
color: 'transparent',
|
|
88
|
-
opacity: 0,
|
|
89
|
-
},
|
|
90
|
-
'&.dragged': {
|
|
91
|
-
position: 'absolute',
|
|
92
|
-
left: 16,
|
|
93
|
-
maxWidth: '60px',
|
|
94
|
-
top: '50%',
|
|
95
|
-
transform: 'translateY(-50%)',
|
|
96
|
-
},
|
|
97
|
-
}));
|
|
98
|
-
|
|
99
|
-
function BlankContent({
|
|
100
|
-
disabled,
|
|
101
|
-
choice,
|
|
102
|
-
isOver,
|
|
103
|
-
isDragging,
|
|
104
|
-
dragItem,
|
|
105
|
-
correct,
|
|
106
|
-
emptyResponseAreaWidth,
|
|
107
|
-
emptyResponseAreaHeight,
|
|
108
|
-
}) {
|
|
109
|
-
const rootRef = useRef(null);
|
|
110
|
-
const spanRef = useRef(null);
|
|
111
|
-
const frozenRef = useRef(null); // to use during dragging to prevent flickering
|
|
112
|
-
const measuringRef = useRef(false); // guard against ResizeObserver feedback loops
|
|
113
|
-
const [dimensions, setDimensions] = useState({ height: 0, width: 0 });
|
|
114
|
-
|
|
115
|
-
const handleImageLoad = () => {
|
|
116
|
-
updateDimensions();
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const handleElements = () => {
|
|
120
|
-
const imageElement = spanRef.current?.querySelector('img');
|
|
121
|
-
if (imageElement) {
|
|
122
|
-
imageElement.onload = handleImageLoad;
|
|
123
|
-
} else {
|
|
124
|
-
setTimeout(() => {
|
|
125
|
-
updateDimensions();
|
|
126
|
-
}, 300);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const getMeasureNode = () => {
|
|
131
|
-
if (!spanRef.current) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const mjx = spanRef.current.querySelector('mjx-container');
|
|
136
|
-
|
|
137
|
-
if (mjx && spanRef.current.parentElement) {
|
|
138
|
-
return spanRef.current.parentElement;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const img = spanRef.current.querySelector('img');
|
|
142
|
-
|
|
143
|
-
if (img) {
|
|
144
|
-
// If there's text alongside the image, measure the full span to capture both dimensions
|
|
145
|
-
const hasTextContent = spanRef.current.textContent.trim().length > 0;
|
|
146
|
-
|
|
147
|
-
return hasTextContent ? spanRef.current : img;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return spanRef.current;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const updateDimensions = () => {
|
|
154
|
-
if (spanRef.current && rootRef.current && !measuringRef.current) {
|
|
155
|
-
measuringRef.current = true;
|
|
156
|
-
// Temporarily set rootRef width to 'auto' for natural measurement
|
|
157
|
-
rootRef.current.style.width = 'auto';
|
|
158
|
-
rootRef.current.style.height = 'auto';
|
|
159
|
-
rootRef.current.offsetHeight;
|
|
160
|
-
|
|
161
|
-
const measureNode = getMeasureNode();
|
|
162
|
-
const node = measureNode || spanRef.current;
|
|
163
|
-
const rect = node.getBoundingClientRect();
|
|
164
|
-
const width = node.offsetWidth || rect.width || 0;
|
|
165
|
-
const height = Math.max(
|
|
166
|
-
node.offsetHeight || 0,
|
|
167
|
-
rect.height || 0,
|
|
168
|
-
node.scrollHeight || 0,
|
|
169
|
-
spanRef.current.scrollHeight || 0,
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
const PADDING = 12;
|
|
173
|
-
const BORDER_WIDTH = 2;
|
|
174
|
-
const ADDITIONAL_SPACE = 1;
|
|
175
|
-
// padding and border on each side
|
|
176
|
-
const widthWithPadding = width + 2 * PADDING + 2 * BORDER_WIDTH + ADDITIONAL_SPACE;
|
|
177
|
-
// padding and border on top and bottom
|
|
178
|
-
const heightWithPadding = height + 2 * PADDING + 2 * BORDER_WIDTH + ADDITIONAL_SPACE;
|
|
179
|
-
|
|
180
|
-
const responseAreaWidth = parseFloat(emptyResponseAreaWidth) || 0;
|
|
181
|
-
const responseAreaHeight = parseFloat(emptyResponseAreaHeight) || 0;
|
|
182
|
-
|
|
183
|
-
const adjustedWidth = widthWithPadding <= responseAreaWidth ? responseAreaWidth : widthWithPadding;
|
|
184
|
-
const adjustedHeight = heightWithPadding <= responseAreaHeight ? responseAreaHeight : heightWithPadding;
|
|
185
|
-
|
|
186
|
-
setDimensions((prevState) => ({
|
|
187
|
-
width: adjustedWidth > responseAreaWidth ? adjustedWidth : prevState.width,
|
|
188
|
-
height: adjustedHeight > responseAreaHeight ? adjustedHeight : prevState.height,
|
|
189
|
-
}));
|
|
190
|
-
|
|
191
|
-
const nextWidth = `${adjustedWidth}px`;
|
|
192
|
-
const nextHeight = `${adjustedHeight}px`;
|
|
193
|
-
if (rootRef.current.style.width !== nextWidth) {
|
|
194
|
-
rootRef.current.style.width = nextWidth;
|
|
195
|
-
}
|
|
196
|
-
if (rootRef.current.style.height !== nextHeight) {
|
|
197
|
-
rootRef.current.style.height = nextHeight;
|
|
198
|
-
}
|
|
199
|
-
measuringRef.current = false;
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const getRootDimensions = () => {
|
|
204
|
-
// Handle potential non-numeric values
|
|
205
|
-
const responseAreaWidth = !isNaN(parseFloat(emptyResponseAreaWidth)) ? parseFloat(emptyResponseAreaWidth) : 0;
|
|
206
|
-
const responseAreaHeight = !isNaN(parseFloat(emptyResponseAreaHeight)) ? parseFloat(emptyResponseAreaHeight) : 0;
|
|
207
|
-
|
|
208
|
-
const rootStyle = {
|
|
209
|
-
height: dimensions.height || responseAreaHeight,
|
|
210
|
-
width: dimensions.width || responseAreaWidth,
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// add minWidth, minHeight if width and height are not defined
|
|
214
|
-
return {
|
|
215
|
-
...rootStyle,
|
|
216
|
-
...(responseAreaWidth ? {} : { minWidth: 90 }),
|
|
217
|
-
...(responseAreaHeight ? {} : { minHeight: 32 }),
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
useEffect(() => {
|
|
222
|
-
handleElements();
|
|
223
|
-
}, []);
|
|
224
|
-
|
|
225
|
-
// Re-measure when the element first becomes visible — covers the tabbed-view case
|
|
226
|
-
// where the initial measurement happened while the tab was hidden (size 0).
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
if (typeof IntersectionObserver === 'undefined' || !rootRef.current) return undefined;
|
|
229
|
-
const io = new IntersectionObserver(
|
|
230
|
-
(entries) => {
|
|
231
|
-
if (entries.some((e) => e.isIntersecting)) updateDimensions();
|
|
232
|
-
},
|
|
233
|
-
{ threshold: 0 },
|
|
234
|
-
);
|
|
235
|
-
io.observe(rootRef.current);
|
|
236
|
-
return () => io.disconnect();
|
|
237
|
-
}, []);
|
|
238
|
-
|
|
239
|
-
// Render math for the placeholder/preview when dragging over
|
|
240
|
-
useEffect(() => {
|
|
241
|
-
if (rootRef.current) {
|
|
242
|
-
renderMath(rootRef.current);
|
|
243
|
-
}
|
|
244
|
-
}, [correct, isOver, dragItem?.choice?.value]);
|
|
245
|
-
|
|
246
|
-
useEffect(() => {
|
|
247
|
-
if (!choice) {
|
|
248
|
-
setDimensions({ height: 0, width: 0 });
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
handleElements();
|
|
252
|
-
}, [choice?.value]);
|
|
253
|
-
|
|
254
|
-
useEffect(() => {
|
|
255
|
-
if (!isOver && !isDragging) {
|
|
256
|
-
frozenRef.current = {
|
|
257
|
-
width: rootRef.current.offsetWidth,
|
|
258
|
-
height: rootRef.current.offsetHeight,
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
}, [choice, isOver, isDragging]);
|
|
262
|
-
|
|
263
|
-
const draggedLabel = dragItem && isOver && dragItem.choice && dragItem.choice.value;
|
|
264
|
-
const label = choice && choice.value;
|
|
265
|
-
const style =
|
|
266
|
-
isOver || isDragging
|
|
267
|
-
? {
|
|
268
|
-
width: frozenRef.current?.width,
|
|
269
|
-
height: frozenRef.current?.height,
|
|
270
|
-
}
|
|
271
|
-
: getRootDimensions();
|
|
272
|
-
|
|
273
|
-
return (
|
|
274
|
-
<StyledChip
|
|
275
|
-
clickable={false}
|
|
276
|
-
disabled={disabled}
|
|
277
|
-
ref={rootRef}
|
|
278
|
-
component="span"
|
|
279
|
-
label={
|
|
280
|
-
<React.Fragment>
|
|
281
|
-
<StyledChipLabel
|
|
282
|
-
ref={spanRef}
|
|
283
|
-
draggable={true}
|
|
284
|
-
className={classnames({
|
|
285
|
-
over: isOver,
|
|
286
|
-
hidden: draggedLabel,
|
|
287
|
-
})}
|
|
288
|
-
dangerouslySetInnerHTML={{ __html: label || '' }}
|
|
289
|
-
/>
|
|
290
|
-
{draggedLabel && (
|
|
291
|
-
<StyledChipLabel
|
|
292
|
-
draggable={true}
|
|
293
|
-
className={classnames({
|
|
294
|
-
over: isOver,
|
|
295
|
-
dragged: true,
|
|
296
|
-
})}
|
|
297
|
-
dangerouslySetInnerHTML={{ __html: draggedLabel || '' }}
|
|
298
|
-
/>
|
|
299
|
-
)}
|
|
300
|
-
</React.Fragment>
|
|
301
|
-
}
|
|
302
|
-
className={classnames({
|
|
303
|
-
over: isOver,
|
|
304
|
-
parentOver: isOver,
|
|
305
|
-
correct: correct !== undefined && correct,
|
|
306
|
-
incorrect: correct !== undefined && !correct,
|
|
307
|
-
})}
|
|
308
|
-
variant={disabled ? 'outlined' : undefined}
|
|
309
|
-
style={style}
|
|
310
|
-
/>
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
BlankContent.defaultProps = {
|
|
315
|
-
emptyResponseAreaWidth: 0,
|
|
316
|
-
emptyResponseAreaHeight: 0,
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
BlankContent.propTypes = {
|
|
320
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
321
|
-
disabled: PropTypes.bool,
|
|
322
|
-
duplicates: PropTypes.bool,
|
|
323
|
-
choice: PropTypes.object,
|
|
324
|
-
isOver: PropTypes.bool,
|
|
325
|
-
dragItem: PropTypes.object,
|
|
326
|
-
correct: PropTypes.bool,
|
|
327
|
-
onChange: PropTypes.func,
|
|
328
|
-
emptyResponseAreaWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
329
|
-
emptyResponseAreaHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
330
|
-
instanceId: PropTypes.string,
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
// New functional component using @dnd-kit hooks
|
|
334
|
-
function DragDropBlank({
|
|
335
|
-
id,
|
|
336
|
-
disabled,
|
|
337
|
-
duplicates,
|
|
338
|
-
choice,
|
|
339
|
-
correct,
|
|
340
|
-
onChange,
|
|
341
|
-
emptyResponseAreaWidth,
|
|
342
|
-
emptyResponseAreaHeight,
|
|
343
|
-
instanceId,
|
|
344
|
-
}) {
|
|
345
|
-
// Setup draggable functionality
|
|
346
|
-
const {
|
|
347
|
-
attributes: dragAttributes,
|
|
348
|
-
listeners: dragListeners,
|
|
349
|
-
setNodeRef: setDragNodeRef,
|
|
350
|
-
transform,
|
|
351
|
-
isDragging,
|
|
352
|
-
} = useDraggable({
|
|
353
|
-
id: `mask-blank-drag-${id}`,
|
|
354
|
-
disabled: disabled || !choice,
|
|
355
|
-
data: {
|
|
356
|
-
id: id,
|
|
357
|
-
choice: choice,
|
|
358
|
-
instanceId: instanceId,
|
|
359
|
-
fromChoice: false, // This is from a blank, not from choices
|
|
360
|
-
type: 'MaskBlank',
|
|
361
|
-
},
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
// Setup droppable functionality
|
|
365
|
-
const {
|
|
366
|
-
setNodeRef: setDropNodeRef,
|
|
367
|
-
isOver,
|
|
368
|
-
active: dragItem,
|
|
369
|
-
} = useDroppable({
|
|
370
|
-
id: `mask-blank-drop-${id}`,
|
|
371
|
-
data: {
|
|
372
|
-
id: id,
|
|
373
|
-
accepts: ['MaskBlank'],
|
|
374
|
-
instanceId: instanceId,
|
|
375
|
-
},
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
// Combine refs for both drag and drop
|
|
379
|
-
const setNodeRef = (node) => {
|
|
380
|
-
setDragNodeRef(node);
|
|
381
|
-
setDropNodeRef(node);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
const style = {
|
|
385
|
-
transform: CSS.Translate.toString(transform),
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
return (
|
|
389
|
-
<StyledContent
|
|
390
|
-
ref={setNodeRef}
|
|
391
|
-
style={style}
|
|
392
|
-
dragged={isDragging}
|
|
393
|
-
over={isOver}
|
|
394
|
-
{...dragAttributes}
|
|
395
|
-
{...dragListeners}
|
|
396
|
-
>
|
|
397
|
-
<BlankContent
|
|
398
|
-
id={id}
|
|
399
|
-
disabled={disabled}
|
|
400
|
-
duplicates={duplicates}
|
|
401
|
-
choice={choice}
|
|
402
|
-
isOver={isOver}
|
|
403
|
-
dragItem={dragItem?.data?.current}
|
|
404
|
-
correct={correct}
|
|
405
|
-
onChange={onChange}
|
|
406
|
-
emptyResponseAreaWidth={emptyResponseAreaWidth}
|
|
407
|
-
emptyResponseAreaHeight={emptyResponseAreaHeight}
|
|
408
|
-
instanceId={instanceId}
|
|
409
|
-
/>
|
|
410
|
-
</StyledContent>
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
DragDropBlank.defaultProps = {
|
|
415
|
-
emptyResponseAreaWidth: 0,
|
|
416
|
-
emptyResponseAreaHeight: 0,
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
DragDropBlank.propTypes = {
|
|
420
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
421
|
-
disabled: PropTypes.bool,
|
|
422
|
-
duplicates: PropTypes.bool,
|
|
423
|
-
choice: PropTypes.object,
|
|
424
|
-
correct: PropTypes.bool,
|
|
425
|
-
onChange: PropTypes.func,
|
|
426
|
-
emptyResponseAreaWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
427
|
-
emptyResponseAreaHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
428
|
-
instanceId: PropTypes.string,
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
export default DragDropBlank;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import OutlinedInput from '@mui/material/OutlinedInput';
|
|
3
|
-
import classnames from 'classnames';
|
|
4
|
-
import { styled } from '@mui/material/styles';
|
|
5
|
-
import { color } from '@pie-lib/render-ui';
|
|
6
|
-
|
|
7
|
-
const StyledOutlinedInput = styled(OutlinedInput)(() => ({
|
|
8
|
-
padding: '2px',
|
|
9
|
-
borderRadius: '4px',
|
|
10
|
-
fontSize: 'inherit',
|
|
11
|
-
display: 'inline-block',
|
|
12
|
-
verticalAlign: 'middle',
|
|
13
|
-
'& fieldset': {
|
|
14
|
-
border: 0,
|
|
15
|
-
},
|
|
16
|
-
'& .MuiOutlinedInput-input': {
|
|
17
|
-
color: color.text(),
|
|
18
|
-
backgroundColor: color.background(),
|
|
19
|
-
borderRadius: '4px !important',
|
|
20
|
-
borderWidth: '1px',
|
|
21
|
-
borderStyle: 'solid',
|
|
22
|
-
padding: '10px 20px 10px 10px',
|
|
23
|
-
'&:disabled': {
|
|
24
|
-
opacity: 0.8,
|
|
25
|
-
cursor: 'not-allowed !important',
|
|
26
|
-
},
|
|
27
|
-
'&:hover': {
|
|
28
|
-
borderColor: color.primary(),
|
|
29
|
-
'&:disabled': {
|
|
30
|
-
borderColor: 'initial',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
'&.Mui-focused': {
|
|
34
|
-
borderColor: color.primaryDark(),
|
|
35
|
-
},
|
|
36
|
-
'&.crInput': {
|
|
37
|
-
padding: '8px !important',
|
|
38
|
-
},
|
|
39
|
-
'&.correct': {
|
|
40
|
-
borderColor: `${color.correct()} !important`,
|
|
41
|
-
},
|
|
42
|
-
'&.incorrect': {
|
|
43
|
-
borderColor: `${color.incorrect()} !important`,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
const CorrectInput = (props) => {
|
|
49
|
-
const { correct, charactersLimit, disabled, isBox, isConstructedResponse, width, spellCheck, ...rest } = props;
|
|
50
|
-
|
|
51
|
-
const label = typeof correct === 'boolean' ? (correct ? 'correct' : 'incorrect') : undefined;
|
|
52
|
-
const inputProps = charactersLimit
|
|
53
|
-
? { maxLength: charactersLimit, 'aria-label': 'Enter answer' }
|
|
54
|
-
: { 'aria-label': 'Enter answer' };
|
|
55
|
-
|
|
56
|
-
if (width) {
|
|
57
|
-
inputProps.style = {
|
|
58
|
-
width: `${width + Math.round(width / 10) + 1}ch`, // added some extra space for capital letters
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<StyledOutlinedInput
|
|
64
|
-
className={classnames({
|
|
65
|
-
disabledInput: disabled,
|
|
66
|
-
box: isBox,
|
|
67
|
-
})}
|
|
68
|
-
classes={{
|
|
69
|
-
input: classnames({
|
|
70
|
-
[label]: label,
|
|
71
|
-
crInput: isConstructedResponse,
|
|
72
|
-
}),
|
|
73
|
-
}}
|
|
74
|
-
inputProps={inputProps}
|
|
75
|
-
disabled={disabled}
|
|
76
|
-
spellCheck={spellCheck}
|
|
77
|
-
{...rest}
|
|
78
|
-
/>
|
|
79
|
-
);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default CorrectInput;
|