@pie-element/match-list 7.2.2-beta.2 → 7.2.2
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 +41 -24
- package/controller/CHANGELOG.md +6 -38
- package/controller/package.json +1 -1
- package/lib/answer-area.js +46 -28
- package/lib/answer-area.js.map +1 -1
- package/lib/answer.js +159 -29
- package/lib/answer.js.map +1 -1
- package/lib/arrow.js +8 -3
- package/lib/arrow.js.map +1 -1
- package/lib/choices-list.js +13 -4
- package/lib/choices-list.js.map +1 -1
- package/lib/droppable-placeholder.js +12 -1
- package/lib/droppable-placeholder.js.map +1 -1
- package/lib/keyboard-coordinates.js +154 -0
- package/lib/keyboard-coordinates.js.map +1 -0
- package/lib/main.js +240 -22
- package/lib/main.js.map +1 -1
- package/package.json +5 -5
package/lib/answer.js
CHANGED
|
@@ -4,17 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.Answer = void 0;
|
|
7
|
+
exports.default = exports.buildDragId = exports.Answer = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _core = require("@dnd-kit/core");
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _react =
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _debug = _interopRequireDefault(require("debug"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
15
|
var _drag = require("@pie-lib/drag");
|
|
16
16
|
var _lodashEs = require("lodash-es");
|
|
17
17
|
var _renderUi = require("@pie-lib/render-ui");
|
|
18
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (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 (const 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); }
|
|
18
19
|
const log = (0, _debug.default)('pie-elements:match-title:answer');
|
|
19
20
|
const HolderNumber = (0, _styles.styled)('div')(({
|
|
20
21
|
theme
|
|
@@ -48,15 +49,15 @@ Holder.propTypes = {
|
|
|
48
49
|
type: _propTypes.default.string
|
|
49
50
|
};
|
|
50
51
|
const AnswerContentContainer = (0, _styles.styled)('div')(({
|
|
51
|
-
theme,
|
|
52
52
|
isDragging,
|
|
53
|
+
isSelected,
|
|
53
54
|
isOver,
|
|
54
55
|
disabled,
|
|
55
56
|
outcome
|
|
56
57
|
}) => ({
|
|
57
58
|
color: _renderUi.color.text(),
|
|
58
59
|
backgroundColor: _renderUi.color.white(),
|
|
59
|
-
border: `1px solid ${outcome === 'correct' ? _renderUi.color.correct() : outcome === 'incorrect' ? _renderUi.color.incorrect() :
|
|
60
|
+
border: `1px solid ${outcome === 'correct' ? _renderUi.color.correct() : outcome === 'incorrect' ? _renderUi.color.incorrect() : _renderUi.color.border()}`,
|
|
60
61
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
61
62
|
width: '100%',
|
|
62
63
|
padding: '10px',
|
|
@@ -64,12 +65,13 @@ const AnswerContentContainer = (0, _styles.styled)('div')(({
|
|
|
64
65
|
overflow: 'hidden',
|
|
65
66
|
transition: 'opacity 200ms linear',
|
|
66
67
|
wordBreak: 'break-word',
|
|
67
|
-
opacity: isDragging && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,
|
|
68
|
+
opacity: (isDragging || isSelected) && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,
|
|
68
69
|
touchAction: 'none'
|
|
69
70
|
}));
|
|
70
71
|
const AnswerContent = props => {
|
|
71
72
|
const {
|
|
72
73
|
isDragging,
|
|
74
|
+
isSelected,
|
|
73
75
|
isOver,
|
|
74
76
|
title,
|
|
75
77
|
disabled,
|
|
@@ -88,6 +90,7 @@ const AnswerContent = props => {
|
|
|
88
90
|
} else {
|
|
89
91
|
return /*#__PURE__*/_react.default.createElement(AnswerContentContainer, {
|
|
90
92
|
isDragging: isDragging,
|
|
93
|
+
isSelected: isSelected,
|
|
91
94
|
isOver: isOver,
|
|
92
95
|
disabled: disabled,
|
|
93
96
|
outcome: outcome,
|
|
@@ -139,6 +142,7 @@ class Answer extends _react.default.Component {
|
|
|
139
142
|
id,
|
|
140
143
|
title,
|
|
141
144
|
isDragging = false,
|
|
145
|
+
isSelected = false,
|
|
142
146
|
className,
|
|
143
147
|
disabled,
|
|
144
148
|
isOver = false,
|
|
@@ -156,15 +160,35 @@ class Answer extends _react.default.Component {
|
|
|
156
160
|
isOver: isOver,
|
|
157
161
|
empty: (0, _lodashEs.isEmpty)(title),
|
|
158
162
|
isDragging: isDragging,
|
|
163
|
+
isSelected: isSelected,
|
|
159
164
|
disabled: disabled,
|
|
160
165
|
type: type
|
|
161
166
|
}));
|
|
162
167
|
}
|
|
163
168
|
}
|
|
169
|
+
|
|
170
|
+
// dnd-kit keys its entire draggable registry off this string, and derives both
|
|
171
|
+
// `isDragging` and the drag transform from `active.id === id`. It therefore has to
|
|
172
|
+
// identify the *rendered tile*, not the answer choice the tile happens to hold.
|
|
173
|
+
//
|
|
174
|
+
// A placed answer is identified by the response area it sits in: with `config.duplicates`
|
|
175
|
+
// enabled the same choice can occupy several response areas at once, and naming those
|
|
176
|
+
// tiles after the choice would register all of them under one id. dnd-kit's
|
|
177
|
+
// `draggableNodes` is a Map, so they would collapse into a single entry — every tile
|
|
178
|
+
// with that id reporting `isDragging` and picking up the transform together (all of them
|
|
179
|
+
// appearing to move at once), the last-registered tile's data resolving as the drag
|
|
180
|
+
// payload (so the wrong response area is the one that actually changes), and unmounting
|
|
181
|
+
// any one of them deleting the entry the still-mounted siblings depend on (leaving a
|
|
182
|
+
// visible tile that is focusable but no longer draggable or reachable by the keyboard
|
|
183
|
+
// sensor).
|
|
184
|
+
//
|
|
185
|
+
// Pool choices stay keyed by choice id: the pool renders each choice at most once, and
|
|
186
|
+
// a choice there has no response area to be identified by.
|
|
164
187
|
exports.Answer = Answer;
|
|
165
188
|
(0, _defineProperty2.default)(Answer, "propTypes", {
|
|
166
189
|
className: _propTypes.default.string,
|
|
167
190
|
isDragging: _propTypes.default.bool,
|
|
191
|
+
isSelected: _propTypes.default.bool,
|
|
168
192
|
id: _propTypes.default.any,
|
|
169
193
|
title: _propTypes.default.string,
|
|
170
194
|
isOver: _propTypes.default.bool,
|
|
@@ -173,6 +197,12 @@ exports.Answer = Answer;
|
|
|
173
197
|
disabled: _propTypes.default.bool,
|
|
174
198
|
correct: _propTypes.default.bool
|
|
175
199
|
});
|
|
200
|
+
const buildDragId = ({
|
|
201
|
+
type,
|
|
202
|
+
id,
|
|
203
|
+
promptId
|
|
204
|
+
}) => promptId !== undefined && promptId !== null ? `${type || 'answer'}-prompt-${promptId}` : `${type || 'answer'}-${id}`;
|
|
205
|
+
exports.buildDragId = buildDragId;
|
|
176
206
|
function DragAndDropAnswer(props) {
|
|
177
207
|
const {
|
|
178
208
|
id,
|
|
@@ -180,11 +210,33 @@ function DragAndDropAnswer(props) {
|
|
|
180
210
|
promptId,
|
|
181
211
|
draggable = true,
|
|
182
212
|
disabled = false,
|
|
183
|
-
type
|
|
213
|
+
type,
|
|
214
|
+
selectedAnswer,
|
|
215
|
+
onSelectClick,
|
|
216
|
+
onPlacementClick
|
|
184
217
|
} = props;
|
|
185
|
-
const dragId =
|
|
218
|
+
const dragId = buildDragId({
|
|
219
|
+
type,
|
|
220
|
+
id,
|
|
221
|
+
promptId
|
|
222
|
+
});
|
|
186
223
|
// droppable only if promptId exists
|
|
187
224
|
const dropId = promptId !== undefined && promptId !== null ? `drop-${promptId}` : undefined;
|
|
225
|
+
|
|
226
|
+
// Built once and reused for both dnd-kit's own data and the click handlers below, so
|
|
227
|
+
// a click carries exactly the same shape dnd-kit's onDragStart/onDragEnd would.
|
|
228
|
+
const activeData = {
|
|
229
|
+
type: type || 'answer',
|
|
230
|
+
id,
|
|
231
|
+
instanceId,
|
|
232
|
+
value: props.title,
|
|
233
|
+
promptId
|
|
234
|
+
};
|
|
235
|
+
const dropZoneData = dropId ? {
|
|
236
|
+
type: 'drop-zone',
|
|
237
|
+
promptId,
|
|
238
|
+
instanceId
|
|
239
|
+
} : undefined;
|
|
188
240
|
const {
|
|
189
241
|
attributes,
|
|
190
242
|
listeners,
|
|
@@ -194,63 +246,138 @@ function DragAndDropAnswer(props) {
|
|
|
194
246
|
isDragging
|
|
195
247
|
} = (0, _core.useDraggable)({
|
|
196
248
|
id: dragId,
|
|
197
|
-
data:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
249
|
+
data: activeData,
|
|
250
|
+
disabled: !draggable || disabled,
|
|
251
|
+
// dnd-kit's own `attributes` default tabIndex to 0 unconditionally, even when
|
|
252
|
+
// `disabled` — so a non-draggable (empty) tile stays a native Tab stop of its own.
|
|
253
|
+
// For a drop-zone (dropId set), that duplicates the outer wrapper's own tab stop
|
|
254
|
+
// (see isNativeTabStop below) at the exact same position, so Tab/Shift+Tab has to
|
|
255
|
+
// pass through both to move anywhere visibly, making every other press look like a
|
|
256
|
+
// no-op. Drop it out of the tab order here whenever it isn't independently
|
|
257
|
+
// reachable/interactive, leaving the outer wrapper (for an empty drop-zone) or
|
|
258
|
+
// nothing (for a disabled choice) as the sole stop.
|
|
259
|
+
attributes: {
|
|
260
|
+
tabIndex: draggable && !disabled ? 0 : -1
|
|
261
|
+
}
|
|
205
262
|
});
|
|
206
263
|
const droppable = (0, _core.useDroppable)({
|
|
207
264
|
id: dropId,
|
|
208
|
-
data:
|
|
209
|
-
type: 'drop-zone',
|
|
210
|
-
promptId,
|
|
211
|
-
instanceId
|
|
212
|
-
} : undefined,
|
|
265
|
+
data: dropZoneData,
|
|
213
266
|
disabled: disabled || !dropId
|
|
214
267
|
});
|
|
215
268
|
const setDropRef = droppable.setNodeRef;
|
|
216
269
|
const isOver = droppable.isOver;
|
|
217
270
|
|
|
271
|
+
// dnd-kit's own isOver only reflects real collision detection during an active drag,
|
|
272
|
+
// so it stays false while an answer is merely click-selected (no drag in progress).
|
|
273
|
+
// Track hovering locally and fold it into the same isOver signal used everywhere
|
|
274
|
+
// below, so hovering a response area while something is selected gets the exact same
|
|
275
|
+
// treatment as hovering it during a real drag — one code path, no duplicated CSS.
|
|
276
|
+
const [isHovered, setIsHovered] = (0, _react.useState)(false);
|
|
277
|
+
const hasSelection = !!selectedAnswer;
|
|
278
|
+
const showsHoverEffect = isOver || hasSelection && isHovered && !disabled;
|
|
279
|
+
const isSelected = !!selectedAnswer && selectedAnswer.type === activeData.type && selectedAnswer.id === activeData.id && selectedAnswer.promptId === activeData.promptId;
|
|
280
|
+
|
|
218
281
|
// compute style: apply transform to the element that actually moves
|
|
219
282
|
const transformStyle = transform ? `translate3d(${transform.x}px, ${transform.y}px, 0)` : undefined;
|
|
220
283
|
|
|
221
284
|
// If this item is a drop-zone (prompt slot), we render an outer droppable wrapper.
|
|
222
|
-
//
|
|
285
|
+
// The outer wrapper's rect is what dnd-kit measures for this slot's own droppable
|
|
286
|
+
// ("drop-{promptId}"), so it must stay untransformed — applying the drag transform
|
|
287
|
+
// there would make the slot's own droppable rect chase the dragged item during the
|
|
288
|
+
// drag, corrupting collision/keyboard-navigation results. The transform belongs on
|
|
289
|
+
// the inner draggable node instead.
|
|
223
290
|
if (dropId) {
|
|
291
|
+
const handleResponseAreaClick = () => {
|
|
292
|
+
if (disabled) return;
|
|
293
|
+
if (isSelected) {
|
|
294
|
+
// Clicking the already-selected placed answer again deselects it, same as
|
|
295
|
+
// for a choice in the pool.
|
|
296
|
+
onSelectClick?.(activeData);
|
|
297
|
+
} else if (selectedAnswer) {
|
|
298
|
+
// Something else is selected — place it here, same whether this area is
|
|
299
|
+
// currently empty or already occupied.
|
|
300
|
+
onPlacementClick?.(dropZoneData);
|
|
301
|
+
} else if (draggable) {
|
|
302
|
+
// Nothing selected yet, and this response area holds an answer — clicking it
|
|
303
|
+
// selects that answer for moving elsewhere, the same way Tab+Space/Enter does.
|
|
304
|
+
onSelectClick?.(activeData);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Empty response area clicked with nothing selected: nothing to place or select.
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
// An empty response area isn't draggable, so dnd-kit's own attributes (only
|
|
311
|
+
// applied to the inner node, and only when draggable) never make it tabbable —
|
|
312
|
+
// this outer wrapper needs its own focus/activation handling so "select a choice,
|
|
313
|
+
// then Tab to a response area and press Space/Enter" works even when the area is
|
|
314
|
+
// empty. This is independent of, and doesn't change, the existing in-drag
|
|
315
|
+
// Tab-cycling (that's driven by an active dnd-kit drag, not native focus).
|
|
316
|
+
//
|
|
317
|
+
// Only made a native Tab stop when NOT draggable (i.e. empty): when the target is
|
|
318
|
+
// filled, the inner node is already independently tabbable via dnd-kit's own
|
|
319
|
+
// attributes for the existing pick-up-to-move gesture, and adding a second,
|
|
320
|
+
// outer Tab stop for the same visual tile would add an extra stop to the existing
|
|
321
|
+
// Tab order. Placing into an occupied area is still fully reachable by mouse click
|
|
322
|
+
// here, or by the existing keyboard drag flow (Tab+Space/Enter on the choice,
|
|
323
|
+
// Tab-cycle to the occupied target, Space/Enter to swap).
|
|
324
|
+
const isNativeTabStop = !draggable && !disabled;
|
|
325
|
+
const handleResponseAreaKeyDown = e => {
|
|
326
|
+
if (e.code === 'Space' || e.code === 'Enter') {
|
|
327
|
+
e.preventDefault();
|
|
328
|
+
handleResponseAreaClick();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
224
331
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
225
332
|
ref: setDropRef,
|
|
333
|
+
role: "button",
|
|
334
|
+
tabIndex: isNativeTabStop ? 0 : -1,
|
|
335
|
+
onClick: handleResponseAreaClick,
|
|
336
|
+
onKeyDown: isNativeTabStop ? handleResponseAreaKeyDown : undefined,
|
|
337
|
+
onMouseEnter: () => setIsHovered(true),
|
|
338
|
+
onMouseLeave: () => setIsHovered(false),
|
|
226
339
|
style: {
|
|
227
340
|
flex: 1,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
backgroundColor: isOver ? 'rgba(0,0,0,0.05)' : 'transparent'
|
|
341
|
+
opacity: isDragging || isSelected ? 0.5 : 1,
|
|
342
|
+
backgroundColor: isDragging || isSelected || showsHoverEffect ? 'rgba(0,0,0,0.05)' : 'transparent',
|
|
343
|
+
cursor: hasSelection && !disabled ? 'pointer' : undefined
|
|
232
344
|
}
|
|
233
345
|
}, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
234
346
|
ref: setDragRef
|
|
235
|
-
}, listeners, attributes
|
|
347
|
+
}, listeners, attributes, {
|
|
348
|
+
style: {
|
|
349
|
+
transform: transformStyle,
|
|
350
|
+
transition
|
|
351
|
+
}
|
|
352
|
+
}), /*#__PURE__*/_react.default.createElement(Answer, (0, _extends2.default)({}, props, {
|
|
236
353
|
isDragging: isDragging,
|
|
237
|
-
|
|
354
|
+
isSelected: isSelected,
|
|
355
|
+
isOver: showsHoverEffect
|
|
238
356
|
}))));
|
|
239
357
|
}
|
|
358
|
+
const handleChoiceClick = e => {
|
|
359
|
+
if (disabled) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
e.stopPropagation();
|
|
363
|
+
onSelectClick?.(activeData);
|
|
364
|
+
};
|
|
240
365
|
|
|
241
366
|
// if there is NO dropId (this is a choice / draggable-only), render only draggable node and apply transform to it.
|
|
242
367
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
243
368
|
ref: setDragRef
|
|
244
369
|
}, listeners, attributes, {
|
|
370
|
+
onClick: handleChoiceClick,
|
|
245
371
|
style: {
|
|
246
372
|
transform: transformStyle,
|
|
247
373
|
transition,
|
|
248
374
|
cursor: disabled ? 'not-allowed' : 'grab',
|
|
249
|
-
opacity: isDragging ? 0.5 : 1,
|
|
375
|
+
opacity: isDragging || isSelected ? 0.5 : 1,
|
|
250
376
|
touchAction: draggable && !disabled ? 'none' : 'auto'
|
|
251
377
|
}
|
|
252
378
|
}), /*#__PURE__*/_react.default.createElement(Answer, (0, _extends2.default)({}, props, {
|
|
253
379
|
isDragging: isDragging,
|
|
380
|
+
isSelected: isSelected,
|
|
254
381
|
isOver: false
|
|
255
382
|
})));
|
|
256
383
|
}
|
|
@@ -261,7 +388,10 @@ DragAndDropAnswer.propTypes = {
|
|
|
261
388
|
title: _propTypes.default.string,
|
|
262
389
|
draggable: _propTypes.default.bool,
|
|
263
390
|
disabled: _propTypes.default.bool,
|
|
264
|
-
type: _propTypes.default.string
|
|
391
|
+
type: _propTypes.default.string,
|
|
392
|
+
selectedAnswer: _propTypes.default.object,
|
|
393
|
+
onSelectClick: _propTypes.default.func,
|
|
394
|
+
onPlacementClick: _propTypes.default.func
|
|
265
395
|
};
|
|
266
396
|
var _default = exports.default = DragAndDropAnswer;
|
|
267
397
|
//# sourceMappingURL=answer.js.map
|
package/lib/answer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer.js","names":["_core","require","_propTypes","_interopRequireDefault","_react","_debug","_styles","_drag","_lodashEs","_renderUi","log","debug","HolderNumber","styled","theme","width","fontSize","textAlign","color","palette","common","black","Holder","index","isOver","disabled","type","default","createElement","PlaceHolder","extraStyles","display","padding","alignItems","justifyContent","height","undefined","propTypes","PropTypes","number","bool","string","AnswerContentContainer","isDragging","outcome","text","backgroundColor","white","border","correct","incorrect","grey","cursor","boxSizing","overflow","transition","wordBreak","opacity","touchAction","AnswerContent","props","title","empty","guideIndex","dangerouslySetInnerHTML","__html","AnswerContainer","minHeight","minWidth","margin","spacing","Answer","React","Component","constructor","args","_defineProperty2","e","componentDidMount","ref","addEventListener","handleTouchStart","passive","componentWillUnmount","removeEventListener","render","id","className","isEmpty","exports","any","DragAndDropAnswer","instanceId","promptId","draggable","dragId","dropId","attributes","listeners","setNodeRef","setDragRef","transform","useDraggable","data","value","droppable","useDroppable","setDropRef","transformStyle","x","y","style","flex","_extends2","_default"],"sources":["../src/answer.jsx"],"sourcesContent":["import { useDraggable, useDroppable } from '@dnd-kit/core';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport { styled } from '@mui/material/styles';\nimport { PlaceHolder } from '@pie-lib/drag';\nimport { isEmpty } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nconst log = debug('pie-elements:match-title:answer');\n\nconst HolderNumber = styled('div')(({ theme }) => ({\n width: '100%',\n fontSize: '18px',\n textAlign: 'center',\n color: `rgba(${theme.palette.common.black}, 0.6)`,\n}));\n\nconst Holder = ({ index, isOver, disabled, type }) => (\n <PlaceHolder\n extraStyles={{\n display: 'flex',\n padding: '0',\n alignItems: 'center',\n justifyContent: 'center',\n height: '40px',\n }}\n disabled={disabled}\n isOver={isOver}\n type={type}\n >\n {index !== undefined && <HolderNumber>{index}</HolderNumber>}\n </PlaceHolder>\n);\n\nHolder.propTypes = {\n index: PropTypes.number,\n isOver: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n};\n\nconst AnswerContentContainer = styled('div')(({ theme, isDragging, isOver, disabled, outcome }) => ({\n color: color.text(),\n backgroundColor: color.white(),\n border: `1px solid ${outcome === 'correct' ? color.correct() :\n outcome === 'incorrect' ? color.incorrect() :\n theme.palette.grey[400]\n }`,\n cursor: disabled ? 'not-allowed' : 'pointer',\n width: '100%',\n padding: '10px',\n boxSizing: 'border-box',\n overflow: 'hidden',\n transition: 'opacity 200ms linear',\n wordBreak: 'break-word',\n opacity: isDragging && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,\n touchAction: 'none'\n}));\n\nconst AnswerContent = (props) => {\n const { isDragging, isOver, title, disabled, empty, outcome, guideIndex, type } = props;\n\n if (empty) {\n return <Holder\n index={guideIndex}\n isOver={isOver}\n disabled={disabled}\n type={type}\n\n />;\n } else {\n return (\n <AnswerContentContainer\n isDragging={isDragging}\n isOver={isOver}\n disabled={disabled}\n outcome={outcome}\n dangerouslySetInnerHTML={{ __html: title }}\n />\n );\n }\n};\n\nconst AnswerContainer = styled('div')(({ correct, theme }) => ({\n boxSizing: 'border-box',\n minHeight: 40,\n minWidth: '200px',\n overflow: 'hidden',\n margin: theme.spacing(0.5),\n padding: '0px',\n textAlign: 'center',\n height: 'initial',\n border: correct === true ? `1px solid var(--feedback-correct-bg-color, ${color.correct()})` :\n correct === false ? `1px solid var(--feedback-incorrect-bg-color, ${color.incorrect()})` :\n 'none',\n}));\n\nexport class Answer extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n isDragging: PropTypes.bool,\n id: PropTypes.any,\n title: PropTypes.string,\n isOver: PropTypes.bool,\n empty: PropTypes.bool,\n type: PropTypes.string,\n disabled: PropTypes.bool,\n correct: PropTypes.bool,\n };\n\n componentDidMount() {\n if (this.ref) {\n // NOTE: preventing default on touchstart can block dnd-kit pointer handling on some devices.\n // Consider removing this if you have issues on touch devices.\n this.ref.addEventListener('touchstart', this.handleTouchStart, { passive: true });\n }\n }\n\n componentWillUnmount() {\n if (this.ref) {\n this.ref.removeEventListener('touchstart', this.handleTouchStart);\n }\n }\n\n handleTouchStart = (e) => {\n // do NOT call e.preventDefault() here — it prevents pointer events necessary for dnd-kit.\n // Keep this handler empty or remove it if you don't need it.\n // e.preventDefault();\n };\n\n render() {\n const {\n id,\n title,\n isDragging = false,\n className,\n disabled,\n isOver = false,\n type,\n correct,\n } = this.props;\n\n log('[render], props: ', this.props);\n\n return (\n <AnswerContainer correct={correct} className={className} ref={(ref) => (this.ref = ref)}>\n <AnswerContent\n title={title}\n id={id}\n isOver={isOver}\n empty={isEmpty(title)}\n isDragging={isDragging}\n disabled={disabled}\n type={type}\n />\n </AnswerContainer>\n );\n }\n}\n\nfunction DragAndDropAnswer(props) {\n const { id, instanceId, promptId, draggable = true, disabled = false, type } = props;\n\n const dragId = `${type || 'answer'}-${id}`;\n // droppable only if promptId exists\n const dropId = promptId !== undefined && promptId !== null ? `drop-${promptId}` : undefined;\n\n const {\n attributes,\n listeners,\n setNodeRef: setDragRef,\n transform,\n transition,\n isDragging,\n } = useDraggable({\n id: dragId,\n data: {\n type: type || 'answer',\n id,\n instanceId,\n value: props.title,\n promptId,\n },\n disabled: !draggable || disabled,\n });\n\n const droppable = useDroppable({\n id: dropId,\n data: dropId ? { type: 'drop-zone', promptId, instanceId } : undefined,\n disabled: disabled || !dropId,\n });\n\n const setDropRef = droppable.setNodeRef;\n const isOver = droppable.isOver;\n\n // compute style: apply transform to the element that actually moves\n const transformStyle = transform\n ? `translate3d(${transform.x}px, ${transform.y}px, 0)`\n : undefined;\n\n // If this item is a drop-zone (prompt slot), we render an outer droppable wrapper.\n // For droppable wrapper we apply style to the outer wrapper\n if (dropId) {\n return (\n <div\n ref={setDropRef}\n style={{\n flex: 1,\n transform: transformStyle,\n transition,\n opacity: isDragging ? 0.5 : 1,\n backgroundColor: isOver ? 'rgba(0,0,0,0.05)' : 'transparent',\n }}\n >\n <div ref={setDragRef} {...listeners} {...attributes}>\n <Answer {...props} isDragging={isDragging} isOver={isOver} />\n </div>\n </div>\n );\n }\n\n // if there is NO dropId (this is a choice / draggable-only), render only draggable node and apply transform to it.\n return (\n <div\n ref={setDragRef}\n {...listeners}\n {...attributes}\n style={{\n transform: transformStyle,\n transition,\n cursor: disabled ? 'not-allowed' : 'grab',\n opacity: isDragging ? 0.5 : 1,\n touchAction: draggable && !disabled ? 'none' : 'auto',\n }}\n >\n <Answer {...props} isDragging={isDragging} isOver={false} />\n </div>\n );\n}\n\nDragAndDropAnswer.propTypes = {\n id: PropTypes.any,\n instanceId: PropTypes.string,\n promptId: PropTypes.any,\n title: PropTypes.string,\n draggable: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n};\n\nexport default DragAndDropAnswer;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAEA,MAAMS,GAAG,GAAG,IAAAC,cAAK,EAAC,iCAAiC,CAAC;AAEpD,MAAMC,YAAY,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACjDC,KAAK,EAAE,MAAM;EACbC,QAAQ,EAAE,MAAM;EAChBC,SAAS,EAAE,QAAQ;EACnBC,KAAK,EAAE,QAAQJ,KAAK,CAACK,OAAO,CAACC,MAAM,CAACC,KAAK;AAC3C,CAAC,CAAC,CAAC;AAEH,MAAMC,MAAM,GAAGA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC,QAAQ;EAAEC;AAAK,CAAC,kBAC/CtB,MAAA,CAAAuB,OAAA,CAAAC,aAAA,CAACrB,KAAA,CAAAsB,WAAW;EACVC,WAAW,EAAE;IACXC,OAAO,EAAE,MAAM;IACfC,OAAO,EAAE,GAAG;IACZC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,MAAM,EAAE;EACV,CAAE;EACFV,QAAQ,EAAEA,QAAS;EACnBD,MAAM,EAAEA,MAAO;EACfE,IAAI,EAAEA;AAAK,GAEVH,KAAK,KAAKa,SAAS,iBAAIhC,MAAA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,GAAG,MAAM;MACzCgC,OAAO,EAAEd,UAAU,GAAG,GAAG,GAAG,CAAC;MAC7Be,WAAW,EAAEoC,SAAS,IAAI,CAACrE,QAAQ,GAAG,MAAM,GAAG;IACjD;EAAE,iBAEFrB,MAAA,CAAAuB,OAAA,CAAAC,aAAA,CAAC2C,MAAM,MAAA0C,SAAA,CAAAtF,OAAA,MAAKiC,KAAK;IAAEjB,UAAU,EAAEA,UAAW;IAACnB,MAAM,EAAE;EAAM,EAAE,CACxD,CAAC;AAEV;AAEAmE,iBAAiB,CAACtD,SAAS,GAAG;EAC5BiD,EAAE,EAAEhD,kBAAS,CAACoD,GAAG;EACjBE,UAAU,EAAEtD,kBAAS,CAACG,MAAM;EAC5BoD,QAAQ,EAAEvD,kBAAS,CAACoD,GAAG;EACvB7B,KAAK,EAAEvB,kBAAS,CAACG,MAAM;EACvBqD,SAAS,EAAExD,kBAAS,CAACE,IAAI;EACzBf,QAAQ,EAAEa,kBAAS,CAACE,IAAI;EACxBd,IAAI,EAAEY,kBAAS,CAACG;AAClB,CAAC;AAAC,IAAAyE,QAAA,GAAAzB,OAAA,CAAA9D,OAAA,GAEagE,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"answer.js","names":["_core","require","_propTypes","_interopRequireDefault","_react","_interopRequireWildcard","_debug","_styles","_drag","_lodashEs","_renderUi","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","log","debug","HolderNumber","styled","theme","width","fontSize","textAlign","color","palette","common","black","Holder","index","isOver","disabled","type","createElement","PlaceHolder","extraStyles","display","padding","alignItems","justifyContent","height","undefined","propTypes","PropTypes","number","bool","string","AnswerContentContainer","isDragging","isSelected","outcome","text","backgroundColor","white","border","correct","incorrect","cursor","boxSizing","overflow","transition","wordBreak","opacity","touchAction","AnswerContent","props","title","empty","guideIndex","dangerouslySetInnerHTML","__html","AnswerContainer","minHeight","minWidth","margin","spacing","Answer","React","Component","constructor","args","_defineProperty2","componentDidMount","ref","addEventListener","handleTouchStart","passive","componentWillUnmount","removeEventListener","render","id","className","isEmpty","exports","any","buildDragId","promptId","DragAndDropAnswer","instanceId","draggable","selectedAnswer","onSelectClick","onPlacementClick","dragId","dropId","activeData","value","dropZoneData","attributes","listeners","setNodeRef","setDragRef","transform","useDraggable","data","tabIndex","droppable","useDroppable","setDropRef","isHovered","setIsHovered","useState","hasSelection","showsHoverEffect","transformStyle","x","y","handleResponseAreaClick","isNativeTabStop","handleResponseAreaKeyDown","code","preventDefault","role","onClick","onKeyDown","onMouseEnter","onMouseLeave","style","flex","_extends2","handleChoiceClick","stopPropagation","object","func","_default"],"sources":["../src/answer.jsx"],"sourcesContent":["import { useDraggable, useDroppable } from '@dnd-kit/core';\nimport PropTypes from 'prop-types';\nimport React, { useState } from 'react';\nimport debug from 'debug';\nimport { styled } from '@mui/material/styles';\nimport { PlaceHolder } from '@pie-lib/drag';\nimport { isEmpty } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nconst log = debug('pie-elements:match-title:answer');\n\nconst HolderNumber = styled('div')(({ theme }) => ({\n width: '100%',\n fontSize: '18px',\n textAlign: 'center',\n color: `rgba(${theme.palette.common.black}, 0.6)`,\n}));\n\nconst Holder = ({ index, isOver, disabled, type }) => (\n <PlaceHolder\n extraStyles={{\n display: 'flex',\n padding: '0',\n alignItems: 'center',\n justifyContent: 'center',\n height: '40px',\n }}\n disabled={disabled}\n isOver={isOver}\n type={type}\n >\n {index !== undefined && <HolderNumber>{index}</HolderNumber>}\n </PlaceHolder>\n);\n\nHolder.propTypes = {\n index: PropTypes.number,\n isOver: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n};\n\nconst AnswerContentContainer = styled('div')(({ isDragging, isSelected, isOver, disabled, outcome }) => ({\n color: color.text(),\n backgroundColor: color.white(),\n border: `1px solid ${\n outcome === 'correct' ? color.correct() : outcome === 'incorrect' ? color.incorrect() : color.border()\n }`,\n cursor: disabled ? 'not-allowed' : 'pointer',\n width: '100%',\n padding: '10px',\n boxSizing: 'border-box',\n overflow: 'hidden',\n transition: 'opacity 200ms linear',\n wordBreak: 'break-word',\n opacity: (isDragging || isSelected) && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,\n touchAction: 'none',\n}));\n\nconst AnswerContent = (props) => {\n const { isDragging, isSelected, isOver, title, disabled, empty, outcome, guideIndex, type } = props;\n\n if (empty) {\n return <Holder index={guideIndex} isOver={isOver} disabled={disabled} type={type} />;\n } else {\n return (\n <AnswerContentContainer\n isDragging={isDragging}\n isSelected={isSelected}\n isOver={isOver}\n disabled={disabled}\n outcome={outcome}\n dangerouslySetInnerHTML={{ __html: title }}\n />\n );\n }\n};\n\nconst AnswerContainer = styled('div')(({ correct, theme }) => ({\n boxSizing: 'border-box',\n minHeight: 40,\n minWidth: '200px',\n overflow: 'hidden',\n margin: theme.spacing(0.5),\n padding: '0px',\n textAlign: 'center',\n height: 'initial',\n border:\n correct === true\n ? `1px solid var(--feedback-correct-bg-color, ${color.correct()})`\n : correct === false\n ? `1px solid var(--feedback-incorrect-bg-color, ${color.incorrect()})`\n : 'none',\n}));\n\nexport class Answer extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n isDragging: PropTypes.bool,\n isSelected: PropTypes.bool,\n id: PropTypes.any,\n title: PropTypes.string,\n isOver: PropTypes.bool,\n empty: PropTypes.bool,\n type: PropTypes.string,\n disabled: PropTypes.bool,\n correct: PropTypes.bool,\n };\n\n componentDidMount() {\n if (this.ref) {\n // NOTE: preventing default on touchstart can block dnd-kit pointer handling on some devices.\n // Consider removing this if you have issues on touch devices.\n this.ref.addEventListener('touchstart', this.handleTouchStart, { passive: true });\n }\n }\n\n componentWillUnmount() {\n if (this.ref) {\n this.ref.removeEventListener('touchstart', this.handleTouchStart);\n }\n }\n\n handleTouchStart = (e) => {\n // do NOT call e.preventDefault() here — it prevents pointer events necessary for dnd-kit.\n // Keep this handler empty or remove it if you don't need it.\n // e.preventDefault();\n };\n\n render() {\n const {\n id,\n title,\n isDragging = false,\n isSelected = false,\n className,\n disabled,\n isOver = false,\n type,\n correct,\n } = this.props;\n\n log('[render], props: ', this.props);\n\n return (\n <AnswerContainer correct={correct} className={className} ref={(ref) => (this.ref = ref)}>\n <AnswerContent\n title={title}\n id={id}\n isOver={isOver}\n empty={isEmpty(title)}\n isDragging={isDragging}\n isSelected={isSelected}\n disabled={disabled}\n type={type}\n />\n </AnswerContainer>\n );\n }\n}\n\n// dnd-kit keys its entire draggable registry off this string, and derives both\n// `isDragging` and the drag transform from `active.id === id`. It therefore has to\n// identify the *rendered tile*, not the answer choice the tile happens to hold.\n//\n// A placed answer is identified by the response area it sits in: with `config.duplicates`\n// enabled the same choice can occupy several response areas at once, and naming those\n// tiles after the choice would register all of them under one id. dnd-kit's\n// `draggableNodes` is a Map, so they would collapse into a single entry — every tile\n// with that id reporting `isDragging` and picking up the transform together (all of them\n// appearing to move at once), the last-registered tile's data resolving as the drag\n// payload (so the wrong response area is the one that actually changes), and unmounting\n// any one of them deleting the entry the still-mounted siblings depend on (leaving a\n// visible tile that is focusable but no longer draggable or reachable by the keyboard\n// sensor).\n//\n// Pool choices stay keyed by choice id: the pool renders each choice at most once, and\n// a choice there has no response area to be identified by.\nexport const buildDragId = ({ type, id, promptId }) =>\n promptId !== undefined && promptId !== null ? `${type || 'answer'}-prompt-${promptId}` : `${type || 'answer'}-${id}`;\n\nfunction DragAndDropAnswer(props) {\n const {\n id,\n instanceId,\n promptId,\n draggable = true,\n disabled = false,\n type,\n selectedAnswer,\n onSelectClick,\n onPlacementClick,\n } = props;\n\n const dragId = buildDragId({ type, id, promptId });\n // droppable only if promptId exists\n const dropId = promptId !== undefined && promptId !== null ? `drop-${promptId}` : undefined;\n\n // Built once and reused for both dnd-kit's own data and the click handlers below, so\n // a click carries exactly the same shape dnd-kit's onDragStart/onDragEnd would.\n const activeData = {\n type: type || 'answer',\n id,\n instanceId,\n value: props.title,\n promptId,\n };\n const dropZoneData = dropId\n ? {\n type: 'drop-zone',\n promptId,\n instanceId,\n }\n : undefined;\n\n const {\n attributes,\n listeners,\n setNodeRef: setDragRef,\n transform,\n transition,\n isDragging,\n } = useDraggable({\n id: dragId,\n data: activeData,\n disabled: !draggable || disabled,\n // dnd-kit's own `attributes` default tabIndex to 0 unconditionally, even when\n // `disabled` — so a non-draggable (empty) tile stays a native Tab stop of its own.\n // For a drop-zone (dropId set), that duplicates the outer wrapper's own tab stop\n // (see isNativeTabStop below) at the exact same position, so Tab/Shift+Tab has to\n // pass through both to move anywhere visibly, making every other press look like a\n // no-op. Drop it out of the tab order here whenever it isn't independently\n // reachable/interactive, leaving the outer wrapper (for an empty drop-zone) or\n // nothing (for a disabled choice) as the sole stop.\n attributes: { tabIndex: draggable && !disabled ? 0 : -1 },\n });\n\n const droppable = useDroppable({\n id: dropId,\n data: dropZoneData,\n disabled: disabled || !dropId,\n });\n\n const setDropRef = droppable.setNodeRef;\n const isOver = droppable.isOver;\n\n // dnd-kit's own isOver only reflects real collision detection during an active drag,\n // so it stays false while an answer is merely click-selected (no drag in progress).\n // Track hovering locally and fold it into the same isOver signal used everywhere\n // below, so hovering a response area while something is selected gets the exact same\n // treatment as hovering it during a real drag — one code path, no duplicated CSS.\n const [isHovered, setIsHovered] = useState(false);\n const hasSelection = !!selectedAnswer;\n const showsHoverEffect = isOver || (hasSelection && isHovered && !disabled);\n\n const isSelected =\n !!selectedAnswer &&\n selectedAnswer.type === activeData.type &&\n selectedAnswer.id === activeData.id &&\n selectedAnswer.promptId === activeData.promptId;\n\n // compute style: apply transform to the element that actually moves\n const transformStyle = transform ? `translate3d(${transform.x}px, ${transform.y}px, 0)` : undefined;\n\n // If this item is a drop-zone (prompt slot), we render an outer droppable wrapper.\n // The outer wrapper's rect is what dnd-kit measures for this slot's own droppable\n // (\"drop-{promptId}\"), so it must stay untransformed — applying the drag transform\n // there would make the slot's own droppable rect chase the dragged item during the\n // drag, corrupting collision/keyboard-navigation results. The transform belongs on\n // the inner draggable node instead.\n if (dropId) {\n const handleResponseAreaClick = () => {\n if (disabled) return;\n\n if (isSelected) {\n // Clicking the already-selected placed answer again deselects it, same as\n // for a choice in the pool.\n onSelectClick?.(activeData);\n } else if (selectedAnswer) {\n // Something else is selected — place it here, same whether this area is\n // currently empty or already occupied.\n onPlacementClick?.(dropZoneData);\n } else if (draggable) {\n // Nothing selected yet, and this response area holds an answer — clicking it\n // selects that answer for moving elsewhere, the same way Tab+Space/Enter does.\n onSelectClick?.(activeData);\n }\n\n // Empty response area clicked with nothing selected: nothing to place or select.\n };\n\n // An empty response area isn't draggable, so dnd-kit's own attributes (only\n // applied to the inner node, and only when draggable) never make it tabbable —\n // this outer wrapper needs its own focus/activation handling so \"select a choice,\n // then Tab to a response area and press Space/Enter\" works even when the area is\n // empty. This is independent of, and doesn't change, the existing in-drag\n // Tab-cycling (that's driven by an active dnd-kit drag, not native focus).\n //\n // Only made a native Tab stop when NOT draggable (i.e. empty): when the target is\n // filled, the inner node is already independently tabbable via dnd-kit's own\n // attributes for the existing pick-up-to-move gesture, and adding a second,\n // outer Tab stop for the same visual tile would add an extra stop to the existing\n // Tab order. Placing into an occupied area is still fully reachable by mouse click\n // here, or by the existing keyboard drag flow (Tab+Space/Enter on the choice,\n // Tab-cycle to the occupied target, Space/Enter to swap).\n const isNativeTabStop = !draggable && !disabled;\n\n const handleResponseAreaKeyDown = (e) => {\n if (e.code === 'Space' || e.code === 'Enter') {\n e.preventDefault();\n handleResponseAreaClick();\n }\n };\n\n return (\n <div\n ref={setDropRef}\n role=\"button\"\n tabIndex={isNativeTabStop ? 0 : -1}\n onClick={handleResponseAreaClick}\n onKeyDown={isNativeTabStop ? handleResponseAreaKeyDown : undefined}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{\n flex: 1,\n opacity: isDragging || isSelected ? 0.5 : 1,\n backgroundColor: isDragging || isSelected || showsHoverEffect ? 'rgba(0,0,0,0.05)' : 'transparent',\n cursor: hasSelection && !disabled ? 'pointer' : undefined,\n }}\n >\n <div ref={setDragRef} {...listeners} {...attributes} style={{ transform: transformStyle, transition }}>\n <Answer {...props} isDragging={isDragging} isSelected={isSelected} isOver={showsHoverEffect} />\n </div>\n </div>\n );\n }\n\n const handleChoiceClick = (e) => {\n if (disabled) {\n return;\n }\n\n e.stopPropagation();\n onSelectClick?.(activeData);\n };\n\n // if there is NO dropId (this is a choice / draggable-only), render only draggable node and apply transform to it.\n return (\n <div\n ref={setDragRef}\n {...listeners}\n {...attributes}\n onClick={handleChoiceClick}\n style={{\n transform: transformStyle,\n transition,\n cursor: disabled ? 'not-allowed' : 'grab',\n opacity: isDragging || isSelected ? 0.5 : 1,\n touchAction: draggable && !disabled ? 'none' : 'auto',\n }}\n >\n <Answer {...props} isDragging={isDragging} isSelected={isSelected} isOver={false} />\n </div>\n );\n}\n\nDragAndDropAnswer.propTypes = {\n id: PropTypes.any,\n instanceId: PropTypes.string,\n promptId: PropTypes.any,\n title: PropTypes.string,\n draggable: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n selectedAnswer: PropTypes.object,\n onSelectClick: PropTypes.func,\n onPlacementClick: PropTypes.func,\n};\n\nexport default DragAndDropAnswer;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAA2C,SAAAI,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAM,CA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I;EAC7BzC,gBAAgB,EAAE3D,kBAAS,CAACoG;AAC9B,CAAC;AAAC,IAAAC,QAAA,GAAAnD,OAAA,CAAAtF,OAAA,GAEa0F,iBAAiB","ignoreList":[]}
|
package/lib/arrow.js
CHANGED
|
@@ -10,16 +10,19 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
|
|
12
12
|
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
13
14
|
const ArrowContainer = (0, _styles.styled)('div')({
|
|
14
15
|
display: 'inline-block',
|
|
15
16
|
position: 'relative',
|
|
16
17
|
width: '100%'
|
|
17
18
|
});
|
|
19
|
+
|
|
20
|
+
// A 1px rule joining a prompt to its answer: it is the connector, so it needs to
|
|
21
|
+
// stay perceivable on every scheme's surface.
|
|
18
22
|
const Line = (0, _styles.styled)('span')(({
|
|
19
|
-
theme,
|
|
20
23
|
isRight
|
|
21
24
|
}) => ({
|
|
22
|
-
backgroundColor:
|
|
25
|
+
backgroundColor: _renderUi.color.border(),
|
|
23
26
|
bottom: isRight ? 20 : 19,
|
|
24
27
|
content: '""',
|
|
25
28
|
display: 'block',
|
|
@@ -41,7 +44,9 @@ class Arrow extends _react.default.Component {
|
|
|
41
44
|
}, /*#__PURE__*/_react.default.createElement(_ArrowDropDown.default, {
|
|
42
45
|
style: {
|
|
43
46
|
transform: 'rotate(90deg)',
|
|
44
|
-
|
|
47
|
+
// Pairs with Line above: head and shaft are one connector and have to
|
|
48
|
+
// step together, or the arrow loses its point on a dark scheme.
|
|
49
|
+
color: _renderUi.color.border(),
|
|
45
50
|
fontSize: 40
|
|
46
51
|
}
|
|
47
52
|
}), /*#__PURE__*/_react.default.createElement(Line, {
|
package/lib/arrow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow.js","names":["_react","_interopRequireDefault","require","_propTypes","_ArrowDropDown","_styles","ArrowContainer","styled","display","position","width","Line","
|
|
1
|
+
{"version":3,"file":"arrow.js","names":["_react","_interopRequireDefault","require","_propTypes","_ArrowDropDown","_styles","_renderUi","ArrowContainer","styled","display","position","width","Line","isRight","backgroundColor","color","border","bottom","content","height","left","Arrow","React","Component","render","direction","props","extraStyle","transform","default","createElement","style","fontSize","exports","_defineProperty2","PropTypes","string","_default"],"sources":["../src/arrow.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport ArrowHead from '@mui/icons-material/ArrowDropDown';\nimport { styled } from '@mui/material/styles';\nimport { color } from '@pie-lib/render-ui';\n\nconst ArrowContainer = styled('div')({\n display: 'inline-block',\n position: 'relative',\n width: '100%',\n});\n\n// A 1px rule joining a prompt to its answer: it is the connector, so it needs to\n// stay perceivable on every scheme's surface.\nconst Line = styled('span')(({ isRight }) => ({\n backgroundColor: color.border(),\n bottom: isRight ? 20 : 19,\n content: '\"\"',\n display: 'block',\n height: 1,\n left: 20,\n position: 'absolute',\n width: '100%',\n}));\n\nexport class Arrow extends React.Component {\n static propTypes = {\n direction: PropTypes.string,\n };\n\n render() {\n const { direction } = this.props;\n\n const extraStyle =\n direction === 'left'\n ? {}\n : {\n transform: 'rotate(180deg)',\n };\n\n return (\n <ArrowContainer style={extraStyle}>\n <ArrowHead\n style={{\n transform: 'rotate(90deg)',\n // Pairs with Line above: head and shaft are one connector and have to\n // step together, or the arrow loses its point on a dark scheme.\n color: color.border(),\n fontSize: 40,\n }}\n />\n <Line isRight={direction !== 'left'} />\n </ArrowContainer>\n );\n }\n}\n\nexport default Arrow;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IA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KAAA,GAAAA,KAAA;AAAA,IAAAa,gBAAA,CAAAL,OAAA,EA9BYR,KAAK,eACG;EACjBI,SAAS,EAAEU,kBAAS,CAACC;AACvB,CAAC;AAAA,IAAAC,QAAA,GAAAJ,OAAA,CAAAJ,OAAA,GA6BYR,KAAK","ignoreList":[]}
|
package/lib/choices-list.js
CHANGED
|
@@ -25,7 +25,10 @@ class ChoicesList extends _react.default.Component {
|
|
|
25
25
|
disabled,
|
|
26
26
|
session,
|
|
27
27
|
instanceId,
|
|
28
|
-
onRemoveAnswer
|
|
28
|
+
onRemoveAnswer,
|
|
29
|
+
selectedAnswer,
|
|
30
|
+
onChoiceClick,
|
|
31
|
+
onPlacementClick
|
|
29
32
|
} = this.props;
|
|
30
33
|
const {
|
|
31
34
|
config
|
|
@@ -39,12 +42,15 @@ class ChoicesList extends _react.default.Component {
|
|
|
39
42
|
draggable: true,
|
|
40
43
|
disabled: disabled,
|
|
41
44
|
session: session,
|
|
42
|
-
type: "choice"
|
|
45
|
+
type: "choice",
|
|
46
|
+
selectedAnswer: selectedAnswer,
|
|
47
|
+
onSelectClick: onChoiceClick
|
|
43
48
|
}, answer)));
|
|
44
49
|
return /*#__PURE__*/_react.default.createElement(ChoicesContainer, null, /*#__PURE__*/_react.default.createElement(_droppablePlaceholder.DroppablePlaceholder, {
|
|
45
50
|
id: "choices-pool",
|
|
46
51
|
disabled: disabled,
|
|
47
|
-
onRemoveAnswer: onRemoveAnswer
|
|
52
|
+
onRemoveAnswer: onRemoveAnswer,
|
|
53
|
+
onPlacementClick: onPlacementClick
|
|
48
54
|
}, filteredAnswers));
|
|
49
55
|
}
|
|
50
56
|
}
|
|
@@ -54,7 +60,10 @@ exports.ChoicesList = ChoicesList;
|
|
|
54
60
|
instanceId: _propTypes.default.string.isRequired,
|
|
55
61
|
model: _propTypes.default.object.isRequired,
|
|
56
62
|
disabled: _propTypes.default.bool.isRequired,
|
|
57
|
-
onRemoveAnswer: _propTypes.default.func
|
|
63
|
+
onRemoveAnswer: _propTypes.default.func,
|
|
64
|
+
selectedAnswer: _propTypes.default.object,
|
|
65
|
+
onChoiceClick: _propTypes.default.func,
|
|
66
|
+
onPlacementClick: _propTypes.default.func
|
|
58
67
|
});
|
|
59
68
|
var _default = exports.default = ChoicesList;
|
|
60
69
|
//# sourceMappingURL=choices-list.js.map
|
package/lib/choices-list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choices-list.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_lodashEs","_answer","_droppablePlaceholder","ChoicesContainer","styled","theme","marginBottom","spacing","ChoicesList","React","Component","render","model","disabled","session","instanceId","onRemoveAnswer","props","config","duplicates","filteredAnswers","answers","filter","answer","isEmpty","value","isUndefined","find","val","id","map","default","createElement","_extends2","key","draggable","type","DroppablePlaceholder","exports","_defineProperty2","PropTypes","object","isRequired","string","bool","func","_default"],"sources":["../src/choices-list.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { find, isEmpty, isUndefined } from 'lodash-es';\nimport DragAndDropAnswer from './answer';\nimport { DroppablePlaceholder } from './droppable-placeholder';\n\nconst ChoicesContainer = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(2),\n}));\n\nexport class ChoicesList extends React.Component {\n static propTypes = {\n session: PropTypes.object.isRequired,\n instanceId: PropTypes.string.isRequired,\n model: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n onRemoveAnswer: PropTypes.func,\n };\n\n render() {\n const {
|
|
1
|
+
{"version":3,"file":"choices-list.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_lodashEs","_answer","_droppablePlaceholder","ChoicesContainer","styled","theme","marginBottom","spacing","ChoicesList","React","Component","render","model","disabled","session","instanceId","onRemoveAnswer","selectedAnswer","onChoiceClick","onPlacementClick","props","config","duplicates","filteredAnswers","answers","filter","answer","isEmpty","value","isUndefined","find","val","id","map","default","createElement","_extends2","key","draggable","type","onSelectClick","DroppablePlaceholder","exports","_defineProperty2","PropTypes","object","isRequired","string","bool","func","_default"],"sources":["../src/choices-list.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { find, isEmpty, isUndefined } from 'lodash-es';\nimport DragAndDropAnswer from './answer';\nimport { DroppablePlaceholder } from './droppable-placeholder';\n\nconst ChoicesContainer = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(2),\n}));\n\nexport class ChoicesList extends React.Component {\n static propTypes = {\n session: PropTypes.object.isRequired,\n instanceId: PropTypes.string.isRequired,\n model: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n onRemoveAnswer: PropTypes.func,\n selectedAnswer: PropTypes.object,\n onChoiceClick: PropTypes.func,\n onPlacementClick: PropTypes.func,\n };\n\n render() {\n const {\n model,\n disabled,\n session,\n instanceId,\n onRemoveAnswer,\n selectedAnswer,\n onChoiceClick,\n onPlacementClick,\n } = this.props;\n const { config } = model;\n const { duplicates } = config;\n\n const filteredAnswers = config.answers\n .filter(\n (answer) =>\n duplicates ||\n isEmpty(session) ||\n !session.value ||\n isUndefined(find(session.value, (val) => val === answer.id)),\n )\n .map((answer) => (\n <DragAndDropAnswer\n key={answer.id}\n instanceId={instanceId}\n draggable={true}\n disabled={disabled}\n session={session}\n type=\"choice\"\n selectedAnswer={selectedAnswer}\n onSelectClick={onChoiceClick}\n {...answer}\n />\n ));\n\n return (\n <ChoicesContainer>\n <DroppablePlaceholder\n id=\"choices-pool\"\n disabled={disabled}\n onRemoveAnswer={onRemoveAnswer}\n onPlacementClick={onPlacementClick}\n >\n {filteredAnswers}\n </DroppablePlaceholder>\n </ChoicesContainer>\n );\n }\n}\n\nexport default ChoicesList;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA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AAM,CACX,CACF,CAAC;IAEJ,oBACE/B,MAAA,CAAAuC,OAAA,CAAAC,aAAA,CAAChC,gBAAgB,qBACfR,MAAA,CAAAuC,OAAA,CAAAC,aAAA,CAACjC,qBAAA,CAAAuC,oBAAoB;MACnBT,EAAE,EAAC,cAAc;MACjBnB,QAAQ,EAAEA,QAAS;MACnBG,cAAc,EAAEA,cAAe;MAC/BG,gBAAgB,EAAEA;IAAiB,GAElCI,eACmB,CACN,CAAC;EAEvB;AACF;AAACmB,OAAA,CAAAlC,WAAA,GAAAA,WAAA;AAAA,IAAAmC,gBAAA,CAAAT,OAAA,EA7DY1B,WAAW,eACH;EACjBM,OAAO,EAAE8B,kBAAS,CAACC,MAAM,CAACC,UAAU;EACpC/B,UAAU,EAAE6B,kBAAS,CAACG,MAAM,CAACD,UAAU;EACvClC,KAAK,EAAEgC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCjC,QAAQ,EAAE+B,kBAAS,CAACI,IAAI,CAACF,UAAU;EACnC9B,cAAc,EAAE4B,kBAAS,CAACK,IAAI;EAC9BhC,cAAc,EAAE2B,kBAAS,CAACC,MAAM;EAChC3B,aAAa,EAAE0B,kBAAS,CAACK,IAAI;EAC7B9B,gBAAgB,EAAEyB,kBAAS,CAACK;AAC9B,CAAC;AAAA,IAAAC,QAAA,GAAAR,OAAA,CAAAR,OAAA,GAqDY1B,WAAW","ignoreList":[]}
|
|
@@ -29,6 +29,7 @@ function DroppablePlaceholder({
|
|
|
29
29
|
id,
|
|
30
30
|
disabled,
|
|
31
31
|
children,
|
|
32
|
+
onPlacementClick,
|
|
32
33
|
...rest
|
|
33
34
|
}) {
|
|
34
35
|
const {
|
|
@@ -41,8 +42,17 @@ function DroppablePlaceholder({
|
|
|
41
42
|
},
|
|
42
43
|
disabled
|
|
43
44
|
});
|
|
45
|
+
const handleClick = () => {
|
|
46
|
+
if (disabled) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
onPlacementClick?.({
|
|
50
|
+
type: 'choices-pool'
|
|
51
|
+
});
|
|
52
|
+
};
|
|
44
53
|
return /*#__PURE__*/_react.default.createElement(Container, (0, _extends2.default)({
|
|
45
54
|
ref: setNodeRef,
|
|
55
|
+
onClick: handleClick,
|
|
46
56
|
style: {
|
|
47
57
|
backgroundColor: isOver ? 'rgba(0,0,0,0.05)' : 'transparent'
|
|
48
58
|
}
|
|
@@ -54,7 +64,8 @@ function DroppablePlaceholder({
|
|
|
54
64
|
DroppablePlaceholder.propTypes = {
|
|
55
65
|
id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
56
66
|
disabled: _propTypes.default.bool,
|
|
57
|
-
children: _propTypes.default.node
|
|
67
|
+
children: _propTypes.default.node,
|
|
68
|
+
onPlacementClick: _propTypes.default.func
|
|
58
69
|
};
|
|
59
70
|
var _default = exports.default = DroppablePlaceholder;
|
|
60
71
|
//# sourceMappingURL=droppable-placeholder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"droppable-placeholder.js","names":["_react","_interopRequireDefault","require","_propTypes","_core","_styles","_drag","Container","styled","theme","alignItems","display","flexDirection","flexWrap","justifyContent","marginTop","spacing","marginBottom","minHeight","transition","DroppablePlaceholder","id","disabled","children","rest","setNodeRef","isOver","useDroppable","data","type","default","createElement","_extends2","ref","style","backgroundColor","MatchDroppablePlaceholder","propTypes","PropTypes","oneOfType","string","number","bool","node","_default","exports"],"sources":["../src/droppable-placeholder.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useDroppable } from '@dnd-kit/core';\nimport { styled } from '@mui/material/styles';\nimport { MatchDroppablePlaceholder } from '@pie-lib/drag';\n\nconst Container = styled('div')(({ theme }) => ({\n alignItems: 'center',\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'space-between',\n marginTop: theme.spacing(1),\n marginBottom: theme.spacing(1),\n minHeight: 50,\n transition: 'background-color 200ms ease',\n}));\n\nexport function DroppablePlaceholder({ id, disabled, children, ...rest }) {\n const { setNodeRef, isOver } = useDroppable({\n id: id || 'choices-pool',\n data: { type: 'choices-pool' },\n disabled,\n });\n\n return (\n <Container\n ref={setNodeRef}\n style={{ backgroundColor: isOver ? 'rgba(0,0,0,0.05)' : 'transparent' }}\n {...rest}\n >\n <MatchDroppablePlaceholder id={id} disabled={disabled}>\n {children}\n </MatchDroppablePlaceholder>\n </Container>\n );\n}\n\nDroppablePlaceholder.propTypes = {\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n disabled: PropTypes.bool,\n children: PropTypes.node,\n};\n\nexport default DroppablePlaceholder;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC5CC,UAAU,EAAE,QAAQ;EACpBC,OAAO,EAAE,MAAM;EACfC,aAAa,EAAE,KAAK;EACpBC,QAAQ,EAAE,MAAM;EAChBC,cAAc,EAAE,eAAe;EAC/BC,SAAS,EAAEN,KAAK,CAACO,OAAO,CAAC,CAAC,CAAC;EAC3BC,YAAY,EAAER,KAAK,CAACO,OAAO,CAAC,CAAC,CAAC;EAC9BE,SAAS,EAAE,EAAE;EACbC,UAAU,EAAE;AAChB,CAAC,CAAC,CAAC;AAEI,SAASC,oBAAoBA,CAAC;EAAEC,EAAE;EAAEC,QAAQ;EAAEC,QAAQ;EAAE,GAAGC;AAAK,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"droppable-placeholder.js","names":["_react","_interopRequireDefault","require","_propTypes","_core","_styles","_drag","Container","styled","theme","alignItems","display","flexDirection","flexWrap","justifyContent","marginTop","spacing","marginBottom","minHeight","transition","DroppablePlaceholder","id","disabled","children","onPlacementClick","rest","setNodeRef","isOver","useDroppable","data","type","handleClick","default","createElement","_extends2","ref","onClick","style","backgroundColor","MatchDroppablePlaceholder","propTypes","PropTypes","oneOfType","string","number","bool","node","func","_default","exports"],"sources":["../src/droppable-placeholder.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useDroppable } from '@dnd-kit/core';\nimport { styled } from '@mui/material/styles';\nimport { MatchDroppablePlaceholder } from '@pie-lib/drag';\n\nconst Container = styled('div')(({ theme }) => ({\n alignItems: 'center',\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'space-between',\n marginTop: theme.spacing(1),\n marginBottom: theme.spacing(1),\n minHeight: 50,\n transition: 'background-color 200ms ease',\n}));\n\nexport function DroppablePlaceholder({ id, disabled, children, onPlacementClick, ...rest }) {\n const { setNodeRef, isOver } = useDroppable({\n id: id || 'choices-pool',\n data: { type: 'choices-pool' },\n disabled,\n });\n\n const handleClick = () => {\n if (disabled) {\n return;\n }\n\n onPlacementClick?.({ type: 'choices-pool' });\n };\n\n return (\n <Container\n ref={setNodeRef}\n onClick={handleClick}\n style={{ backgroundColor: isOver ? 'rgba(0,0,0,0.05)' : 'transparent' }}\n {...rest}\n >\n <MatchDroppablePlaceholder id={id} disabled={disabled}>\n {children}\n </MatchDroppablePlaceholder>\n </Container>\n );\n}\n\nDroppablePlaceholder.propTypes = {\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n disabled: PropTypes.bool,\n children: PropTypes.node,\n onPlacementClick: PropTypes.func,\n};\n\nexport default DroppablePlaceholder;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,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