@citolab/qti-components 10.0.0-next.15 → 10.0.0-next.16
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/cdn/index.global.js +1 -1
- package/cdn/index.js +1535 -2737
- package/dist/base.d.ts +31 -7
- package/dist/base.js +7 -1
- package/dist/{chunk-IWNRQVNW.js → chunk-4DC5Z2LQ.js} +2 -2
- package/dist/{chunk-G2EIC7H2.js → chunk-7MYZHZWV.js} +955 -364
- package/dist/chunk-7MYZHZWV.js.map +1 -0
- package/dist/{chunk-URYYGVTA.js → chunk-H3Z3TMFB.js} +55 -60
- package/dist/chunk-H3Z3TMFB.js.map +1 -0
- package/dist/{chunk-F553IZPL.js → chunk-J3F3JSCW.js} +2 -2
- package/dist/{chunk-32PI7KWX.js → chunk-L3LBSAGZ.js} +2 -2
- package/dist/{chunk-WIUPAUJV.js → chunk-L7J2ZOJL.js} +2 -2
- package/dist/{chunk-MIQZBDTB.js → chunk-LQ65RILE.js} +140 -105
- package/dist/chunk-LQ65RILE.js.map +1 -0
- package/dist/{chunk-QT7WQXCS.js → chunk-M4TZIB3W.js} +33 -37
- package/dist/chunk-M4TZIB3W.js.map +1 -0
- package/dist/{chunk-HT3LSWXL.js → chunk-NWSDBYK7.js} +2 -2
- package/dist/{chunk-IM5AKPIJ.js → chunk-NZ7ZC4SP.js} +96 -4
- package/dist/chunk-NZ7ZC4SP.js.map +1 -0
- package/dist/{chunk-XY5DHYIH.js → chunk-OG5HIRHE.js} +3 -3
- package/dist/{chunk-5AJZGRWI.js → chunk-UDJ7MHLF.js} +4 -4
- package/dist/chunk-UDJ7MHLF.js.map +1 -0
- package/dist/chunk-WWY2H2YO.js +7 -0
- package/dist/chunk-WWY2H2YO.js.map +1 -0
- package/dist/{computed.types.d-IXACuBr7.d.ts → computed.types.d-n3K2VvB0.d.ts} +2 -2
- package/dist/corrections.d.ts +117 -13
- package/dist/corrections.js +8 -8
- package/dist/elements.d.ts +44 -21
- package/dist/elements.js +3 -3
- package/dist/index.d.ts +8 -8
- package/dist/index.js +19 -13
- package/dist/interactions.d.ts +82 -16
- package/dist/interactions.js +3 -3
- package/dist/item.css +1057 -2383
- package/dist/item.d.ts +3 -3
- package/dist/item.js +4 -4
- package/dist/loader.d.ts +1 -1
- package/dist/processing.js +3 -3
- package/dist/qti-components-jsx.d.ts +1198 -201
- package/dist/{qti-feedback.d-GAqMqAt6.d.ts → qti-feedback.d-1JL_qHjc.d.ts} +1 -1
- package/dist/{qti-item.d-pFcNk0th.d.ts → qti-item.d-DDMDjWIk.d.ts} +1 -1
- package/dist/{qti-test.d-BjhVQnQy.d.ts → qti-test.d-CDdyCp6e.d.ts} +19 -16
- package/dist/{qti-text-entry-interaction.d-DECzpIzi.d.ts → qti-text-entry-interaction.d-BTAKmr4b.d.ts} +142 -42
- package/dist/{record.d-CljDLwRz.d.ts → record.d-Bojj6_LW.d.ts} +33 -2
- package/dist/{session.context.d-DW09Lrie.d.ts → session.context.d-BNxGeyh9.d.ts} +1 -1
- package/dist/test.d.ts +7 -7
- package/dist/test.js +5 -5
- package/package.json +9 -9
- package/dist/chunk-5AJZGRWI.js.map +0 -1
- package/dist/chunk-G2EIC7H2.js.map +0 -1
- package/dist/chunk-IM5AKPIJ.js.map +0 -1
- package/dist/chunk-MIQZBDTB.js.map +0 -1
- package/dist/chunk-QT7WQXCS.js.map +0 -1
- package/dist/chunk-RNLSNH4N.js +0 -7
- package/dist/chunk-RNLSNH4N.js.map +0 -1
- package/dist/chunk-URYYGVTA.js.map +0 -1
- /package/dist/{chunk-IWNRQVNW.js.map → chunk-4DC5Z2LQ.js.map} +0 -0
- /package/dist/{chunk-F553IZPL.js.map → chunk-J3F3JSCW.js.map} +0 -0
- /package/dist/{chunk-32PI7KWX.js.map → chunk-L3LBSAGZ.js.map} +0 -0
- /package/dist/{chunk-WIUPAUJV.js.map → chunk-L7J2ZOJL.js.map} +0 -0
- /package/dist/{chunk-HT3LSWXL.js.map → chunk-NWSDBYK7.js.map} +0 -0
- /package/dist/{chunk-XY5DHYIH.js.map → chunk-OG5HIRHE.js.map} +0 -0
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
boxSizing,
|
|
7
7
|
configContext,
|
|
8
8
|
dropRegion,
|
|
9
|
+
hasState,
|
|
9
10
|
inferRecordFieldBaseType,
|
|
10
11
|
interactionContext,
|
|
11
12
|
isRecordValue,
|
|
@@ -16,8 +17,9 @@ import {
|
|
|
16
17
|
removeDoubleSlashes,
|
|
17
18
|
responseAttributeConverter,
|
|
18
19
|
serializeResponseAttribute,
|
|
20
|
+
setState,
|
|
19
21
|
validationMessage
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-NZ7ZC4SP.js";
|
|
21
23
|
|
|
22
24
|
// ../interactions/core/dist/elements/qti-associable-hotspot/qti-associable-hotspot.js
|
|
23
25
|
import { LitElement, html } from "lit";
|
|
@@ -55,7 +57,7 @@ var qti_associable_hotspot_styles_default = [
|
|
|
55
57
|
|
|
56
58
|
/* A placed chip keeps the box it had in the bank, even in a hotspot narrower than it (a boxed
|
|
57
59
|
word on a small region): shrinking would wrap or squeeze its text (drag-drop.invariance). */
|
|
58
|
-
[part~='
|
|
60
|
+
[part~='chip'] {
|
|
59
61
|
flex-shrink: 0;
|
|
60
62
|
}
|
|
61
63
|
`
|
|
@@ -344,7 +346,7 @@ function ActiveElementMixin(Base, type, { activateOn = "click" } = {}) {
|
|
|
344
346
|
this.#pressActivated = false;
|
|
345
347
|
if (activateOn !== "press" || event.button !== 0 || !event.isPrimary)
|
|
346
348
|
return;
|
|
347
|
-
if (this.hasAttribute("
|
|
349
|
+
if (this.hasAttribute("data-draggable") || this.disabled || this.readonly)
|
|
348
350
|
return;
|
|
349
351
|
this.#pressActivated = true;
|
|
350
352
|
this.focus();
|
|
@@ -474,7 +476,7 @@ var qti_gap_text_styles_default = [
|
|
|
474
476
|
/*
|
|
475
477
|
* Centred wherever it lives — this is the one-line follow-up the note here used to promise.
|
|
476
478
|
*
|
|
477
|
-
* It read :host(:not([part~='
|
|
479
|
+
* It read :host(:not([part~='chip'])), which reproduced an older accident: the centring rule
|
|
478
480
|
* used to be a document selector ('qti-gap-match-interaction qti-gap-text'), and a placed chip
|
|
479
481
|
* lives inside qti-gap's shadow root where no document selector reaches. So a chip in the bank was
|
|
480
482
|
* centred and the same chip in a gap was not, and the stylesheet gave no hint why.
|
|
@@ -576,6 +578,15 @@ var QtiHotspotChoice = class extends ActiveElementMixin(LitElement5, "qti-hotspo
|
|
|
576
578
|
static {
|
|
577
579
|
this.styles = qti_hotspot_choice_styles_default;
|
|
578
580
|
}
|
|
581
|
+
updated(changed) {
|
|
582
|
+
super.updated(changed);
|
|
583
|
+
if (changed.has("order")) {
|
|
584
|
+
if (this.order === void 0 || this.order === null)
|
|
585
|
+
this.removeAttribute("data-order");
|
|
586
|
+
else
|
|
587
|
+
this.setAttribute("data-order", String(this.order));
|
|
588
|
+
}
|
|
589
|
+
}
|
|
579
590
|
};
|
|
580
591
|
__decorate6([
|
|
581
592
|
property6({ attribute: "aria-ordervalue", type: Number, reflect: true })
|
|
@@ -758,9 +769,9 @@ var qti_simple_associable_choice_styles_default = [
|
|
|
758
769
|
* draggable chip; in match's last match-set it is a drop target. In tabular match it is neither —
|
|
759
770
|
* drag-drop is off and it is a row or column header in a grid.
|
|
760
771
|
*
|
|
761
|
-
* So the drop-target rules key on :state(
|
|
772
|
+
* So the drop-target rules key on :state(drop), which the interaction sets on exactly the
|
|
762
773
|
* elements it tracks as droppables. Keying on the *absence* of a chip marker instead
|
|
763
|
-
* (:not(:state(
|
|
774
|
+
* (:not(:state(chip))) swept up every tabular header cell and gave each one a 4rem minimum.
|
|
764
775
|
*
|
|
765
776
|
* A state rather than an attribute, and this used to be written both ways. An attribute cannot
|
|
766
777
|
* be used by every host: the editor renders these choices inside a ProseMirror document, whose
|
|
@@ -769,7 +780,7 @@ var qti_simple_associable_choice_styles_default = [
|
|
|
769
780
|
* that observer, so the state is the form that works everywhere and the [qti-droppable]
|
|
770
781
|
* attribute that used to accompany it is gone. Positive opt-in, so tabular headers are untouched.
|
|
771
782
|
*/
|
|
772
|
-
:host(:is(:state(
|
|
783
|
+
:host(:is(:state(drop), [data-state~='drop'])) {
|
|
773
784
|
/*
|
|
774
785
|
* The CARD token, not the slot one. This element is a droppable only in match, and match
|
|
775
786
|
* publishes no measurement — so reading --qti-dropzone-min-height here meant reading a name
|
|
@@ -795,7 +806,7 @@ var qti_simple_associable_choice_styles_default = [
|
|
|
795
806
|
justify-content: space-between;
|
|
796
807
|
}
|
|
797
808
|
|
|
798
|
-
:host(:is(:state(
|
|
809
|
+
:host(:is(:state(drop), [data-state~='drop'])) [part~='drop'] {
|
|
799
810
|
/*
|
|
800
811
|
* Match's dropzones are NOT auto-sized from the chips: a match target is a category, and
|
|
801
812
|
* should look able to hold several answers rather than hugging the widest one. So this reads
|
|
@@ -835,7 +846,7 @@ var qti_simple_associable_choice_styles_default = [
|
|
|
835
846
|
}
|
|
836
847
|
|
|
837
848
|
/* The label sits against the drop region below it. */
|
|
838
|
-
:host(:is(:state(
|
|
849
|
+
:host(:is(:state(drop), [data-state~='drop'])) [part~='label'] {
|
|
839
850
|
align-content: flex-end;
|
|
840
851
|
}
|
|
841
852
|
|
|
@@ -845,12 +856,12 @@ var qti_simple_associable_choice_styles_default = [
|
|
|
845
856
|
* bank. The <slot> this replaced collapsed to nothing by accident; a div has to be told.
|
|
846
857
|
*
|
|
847
858
|
* Two conditions, because a chip identifies itself two ways:
|
|
848
|
-
* :state(
|
|
849
|
-
* [part~='
|
|
859
|
+
* :state(chip) a chip in the light-DOM bank, from the interaction's draggablesSelector
|
|
860
|
+
* [part~='chip'] a chip a drop target renders, where that selector cannot reach it — match's
|
|
850
861
|
* selector names a light-DOM ancestry the placed clone no longer has
|
|
851
862
|
*/
|
|
852
|
-
:host(:is(:state(
|
|
853
|
-
:host([part~='
|
|
863
|
+
:host(:is(:state(chip), [data-state~='chip'])) [part~='drop'],
|
|
864
|
+
:host([part~='chip']) [part~='drop'] {
|
|
854
865
|
display: none;
|
|
855
866
|
}
|
|
856
867
|
|
|
@@ -1107,7 +1118,7 @@ function applyDropzoneAutoSizing(host, draggables, droppables, dragContainers, o
|
|
|
1107
1118
|
}
|
|
1108
1119
|
});
|
|
1109
1120
|
}
|
|
1110
|
-
var DropzoneAutoSizeMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part
|
|
1121
|
+
var DropzoneAutoSizeMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part~="bank"]') => {
|
|
1111
1122
|
class DropzoneAutoSizeElement extends superClass {
|
|
1112
1123
|
constructor() {
|
|
1113
1124
|
super(...arguments);
|
|
@@ -1293,22 +1304,22 @@ var [Observable, Subscriber] = (() => {
|
|
|
1293
1304
|
const AsyncFromSyncIteratorPrototype = {
|
|
1294
1305
|
next(...args) {
|
|
1295
1306
|
const O = this;
|
|
1296
|
-
const
|
|
1297
|
-
if (!
|
|
1307
|
+
const state17 = privateState.get(O);
|
|
1308
|
+
if (!state17?.syncIteratorRecord)
|
|
1298
1309
|
throw new TypeError(
|
|
1299
1310
|
"AsyncFromSyncIteratorPrototype.next called on invalid object"
|
|
1300
1311
|
);
|
|
1301
|
-
const { syncIteratorRecord } =
|
|
1312
|
+
const { syncIteratorRecord } = state17;
|
|
1302
1313
|
return pTry(() => syncIteratorRecord.next(...args));
|
|
1303
1314
|
},
|
|
1304
1315
|
return(...args) {
|
|
1305
1316
|
const O = this;
|
|
1306
|
-
const
|
|
1307
|
-
if (!
|
|
1317
|
+
const state17 = privateState.get(O);
|
|
1318
|
+
if (!state17?.syncIteratorRecord)
|
|
1308
1319
|
throw new TypeError(
|
|
1309
1320
|
"AsyncFromSyncIteratorPrototype.return called on invalid object"
|
|
1310
1321
|
);
|
|
1311
|
-
const { syncIteratorRecord } =
|
|
1322
|
+
const { syncIteratorRecord } = state17;
|
|
1312
1323
|
return pTry(() => {
|
|
1313
1324
|
if (!syncIteratorRecord.return) return { value: void 0, done: true };
|
|
1314
1325
|
return syncIteratorRecord.return(...args);
|
|
@@ -1316,12 +1327,12 @@ var [Observable, Subscriber] = (() => {
|
|
|
1316
1327
|
},
|
|
1317
1328
|
throw(...args) {
|
|
1318
1329
|
const O = this;
|
|
1319
|
-
const
|
|
1320
|
-
if (!
|
|
1330
|
+
const state17 = privateState.get(O);
|
|
1331
|
+
if (!state17?.syncIteratorRecord)
|
|
1321
1332
|
throw new TypeError(
|
|
1322
1333
|
"AsyncFromSyncIteratorPrototype.throw called on invalid object"
|
|
1323
1334
|
);
|
|
1324
|
-
const { syncIteratorRecord } =
|
|
1335
|
+
const { syncIteratorRecord } = state17;
|
|
1325
1336
|
return pTry(() => {
|
|
1326
1337
|
if (!syncIteratorRecord.throw) {
|
|
1327
1338
|
syncIteratorRecord.return();
|
|
@@ -1387,11 +1398,11 @@ var [Observable, Subscriber] = (() => {
|
|
|
1387
1398
|
}
|
|
1388
1399
|
}
|
|
1389
1400
|
function closeASubscription(subscriber, reason) {
|
|
1390
|
-
const
|
|
1391
|
-
if (!
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
for (const teardown of
|
|
1401
|
+
const state17 = privateState.get(subscriber);
|
|
1402
|
+
if (!state17?.active) return;
|
|
1403
|
+
state17.active = false;
|
|
1404
|
+
state17.subscriptionController.abort(reason);
|
|
1405
|
+
for (const teardown of state17.teardowns.reverse()) {
|
|
1395
1406
|
if (isBrowserContext() && !isDocumentFullyActive(document)) return;
|
|
1396
1407
|
try {
|
|
1397
1408
|
teardown();
|
|
@@ -1472,10 +1483,10 @@ var [Observable, Subscriber] = (() => {
|
|
|
1472
1483
|
if (!(this instanceof Subscriber2))
|
|
1473
1484
|
throw new TypeError("illegal invocation");
|
|
1474
1485
|
if (!arguments.length) throw new TypeError("too few arguments");
|
|
1475
|
-
const
|
|
1476
|
-
if (!
|
|
1486
|
+
const state17 = privateState.get(this);
|
|
1487
|
+
if (!state17?.active) return;
|
|
1477
1488
|
if (isBrowserContext() && !isDocumentFullyActive(document)) return;
|
|
1478
|
-
const internalObservers = new Set(
|
|
1489
|
+
const internalObservers = new Set(state17.observers);
|
|
1479
1490
|
for (const observer of internalObservers) {
|
|
1480
1491
|
observer.next(value);
|
|
1481
1492
|
}
|
|
@@ -1485,14 +1496,14 @@ var [Observable, Subscriber] = (() => {
|
|
|
1485
1496
|
if (!(this instanceof Subscriber2))
|
|
1486
1497
|
throw new TypeError("illegal invocation");
|
|
1487
1498
|
if (!arguments.length) throw new TypeError("too few arguments");
|
|
1488
|
-
const
|
|
1489
|
-
if (!
|
|
1499
|
+
const state17 = privateState.get(this);
|
|
1500
|
+
if (!state17?.active) {
|
|
1490
1501
|
reportError(error);
|
|
1491
1502
|
return;
|
|
1492
1503
|
}
|
|
1493
1504
|
if (isBrowserContext() && !isDocumentFullyActive(document)) return;
|
|
1494
1505
|
closeASubscription(this, error);
|
|
1495
|
-
const internalObservers = new Set(
|
|
1506
|
+
const internalObservers = new Set(state17.observers);
|
|
1496
1507
|
for (const observer of internalObservers) {
|
|
1497
1508
|
observer.error(error);
|
|
1498
1509
|
}
|
|
@@ -1501,11 +1512,11 @@ var [Observable, Subscriber] = (() => {
|
|
|
1501
1512
|
complete() {
|
|
1502
1513
|
if (!(this instanceof Subscriber2))
|
|
1503
1514
|
throw new TypeError("illegal invocation");
|
|
1504
|
-
const
|
|
1505
|
-
if (!
|
|
1515
|
+
const state17 = privateState.get(this);
|
|
1516
|
+
if (!state17?.active) return;
|
|
1506
1517
|
if (isBrowserContext() && !isDocumentFullyActive(document)) return;
|
|
1507
1518
|
closeASubscription(this);
|
|
1508
|
-
const internalObservers = new Set(
|
|
1519
|
+
const internalObservers = new Set(state17.observers);
|
|
1509
1520
|
for (const observer of internalObservers) {
|
|
1510
1521
|
observer.complete();
|
|
1511
1522
|
}
|
|
@@ -1518,9 +1529,9 @@ var [Observable, Subscriber] = (() => {
|
|
|
1518
1529
|
throw new TypeError(`Parameter 1 is not of type 'Function'`);
|
|
1519
1530
|
}
|
|
1520
1531
|
if (isBrowserContext() && !isDocumentFullyActive(document)) return;
|
|
1521
|
-
const
|
|
1522
|
-
if (
|
|
1523
|
-
|
|
1532
|
+
const state17 = privateState.get(this);
|
|
1533
|
+
if (state17?.active)
|
|
1534
|
+
state17.teardowns.push(teardown);
|
|
1524
1535
|
else teardown();
|
|
1525
1536
|
}
|
|
1526
1537
|
get active() {
|
|
@@ -2575,7 +2586,7 @@ function containsPoint(zone, x, y) {
|
|
|
2575
2586
|
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
|
2576
2587
|
}
|
|
2577
2588
|
function closestCornersWithInventoryPriorityCollision(dropzones, clientX, clientY, dragElement, dragContainers) {
|
|
2578
|
-
const identifiedDragContainers = dragContainers && dragContainers.length > 0 ? dropzones.filter((zone) => dragContainers.includes(zone)) : dropzones.filter((zone) => zone.tagName === "SLOT" && zone.hasAttribute("part") && zone.getAttribute("part")?.includes("
|
|
2589
|
+
const identifiedDragContainers = dragContainers && dragContainers.length > 0 ? dropzones.filter((zone) => dragContainers.includes(zone)) : dropzones.filter((zone) => zone.tagName === "SLOT" && zone.hasAttribute("part") && zone.getAttribute("part")?.split(/\s+/).includes("bank"));
|
|
2579
2590
|
const allRegularDroppables = dropzones.filter((zone) => !identifiedDragContainers.includes(zone));
|
|
2580
2591
|
const regularDroppables = allRegularDroppables;
|
|
2581
2592
|
if (identifiedDragContainers.length === 0 && regularDroppables.length === 0)
|
|
@@ -2684,10 +2695,10 @@ function findDraggableTarget(event, draggablesSelector) {
|
|
|
2684
2695
|
const composedPath = event.composedPath ? event.composedPath() : [event.target];
|
|
2685
2696
|
for (const element of composedPath) {
|
|
2686
2697
|
if (element instanceof HTMLElement && element.tagName !== "SLOT") {
|
|
2687
|
-
if (element.matches(draggablesSelector) || element.hasAttribute("
|
|
2698
|
+
if (element.matches(draggablesSelector) || element.hasAttribute("data-draggable")) {
|
|
2688
2699
|
return element;
|
|
2689
2700
|
}
|
|
2690
|
-
const closest = element.closest(draggablesSelector) || element.closest('[
|
|
2701
|
+
const closest = element.closest(draggablesSelector) || element.closest('[data-draggable="true"]');
|
|
2691
2702
|
if (closest) {
|
|
2692
2703
|
return closest;
|
|
2693
2704
|
}
|
|
@@ -2704,50 +2715,61 @@ function isDraggableDisabled(target) {
|
|
|
2704
2715
|
return internals?.states?.has("disabled") ?? false;
|
|
2705
2716
|
}
|
|
2706
2717
|
var internalsOf = (el) => el?.internals;
|
|
2707
|
-
function setDragChipState(el,
|
|
2708
|
-
|
|
2709
|
-
if (!states)
|
|
2710
|
-
return;
|
|
2711
|
-
if (on)
|
|
2712
|
-
states.add(state16);
|
|
2713
|
-
else
|
|
2714
|
-
states.delete(state16);
|
|
2718
|
+
function setDragChipState(el, state17, on) {
|
|
2719
|
+
setState(internalsOf(el)?.states, state17, on);
|
|
2715
2720
|
}
|
|
2716
|
-
function hasDragChipState(el,
|
|
2717
|
-
return internalsOf(el)?.states
|
|
2721
|
+
function hasDragChipState(el, state17) {
|
|
2722
|
+
return hasState(internalsOf(el)?.states, state17);
|
|
2718
2723
|
}
|
|
2719
2724
|
function clearDragChipStates(el) {
|
|
2720
|
-
setDragChipState(el, "
|
|
2721
|
-
setDragChipState(el, "
|
|
2722
|
-
setDragChipState(el, "return-
|
|
2725
|
+
setDragChipState(el, "lifted", false);
|
|
2726
|
+
setDragChipState(el, "used", false);
|
|
2727
|
+
setDragChipState(el, "return-target", false);
|
|
2723
2728
|
}
|
|
2724
2729
|
function isDragChipHidden(el) {
|
|
2725
|
-
return hasDragChipState(el, "
|
|
2730
|
+
return hasDragChipState(el, "lifted") || hasDragChipState(el, "used");
|
|
2726
2731
|
}
|
|
2732
|
+
var DROP_FLAG_ALIASES = {
|
|
2733
|
+
filled: [],
|
|
2734
|
+
full: [],
|
|
2735
|
+
"drag-active": ["active", "enabled"],
|
|
2736
|
+
"drag-over": ["hover"]
|
|
2737
|
+
};
|
|
2727
2738
|
function setDropFlag(el, flag, on) {
|
|
2728
2739
|
if (!el)
|
|
2729
2740
|
return;
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
else
|
|
2733
|
-
el.removeAttribute(flag);
|
|
2734
|
-
const states = internalsOf(el)?.states;
|
|
2735
|
-
if (states) {
|
|
2741
|
+
const names = [flag, ...DROP_FLAG_ALIASES[flag]];
|
|
2742
|
+
for (const name of names) {
|
|
2736
2743
|
if (on)
|
|
2737
|
-
|
|
2744
|
+
el.setAttribute(name, "");
|
|
2738
2745
|
else
|
|
2739
|
-
|
|
2746
|
+
el.removeAttribute(name);
|
|
2747
|
+
}
|
|
2748
|
+
const states = internalsOf(el)?.states;
|
|
2749
|
+
if (states) {
|
|
2750
|
+
setState(states, flag, on, DROP_FLAG_ALIASES[flag]);
|
|
2740
2751
|
return;
|
|
2741
2752
|
}
|
|
2742
2753
|
const tokens = new Set((el.getAttribute("part") ?? "").split(/\s+/).filter(Boolean));
|
|
2743
|
-
if (!tokens.has("drop"))
|
|
2754
|
+
if (!tokens.has("drop") && !tokens.has("bank"))
|
|
2744
2755
|
return;
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2756
|
+
for (const name of names) {
|
|
2757
|
+
if (on)
|
|
2758
|
+
tokens.add(name);
|
|
2759
|
+
else
|
|
2760
|
+
tokens.delete(name);
|
|
2761
|
+
}
|
|
2749
2762
|
el.setAttribute("part", [...tokens].join(" "));
|
|
2750
2763
|
}
|
|
2764
|
+
function setDropFull(el, full) {
|
|
2765
|
+
if (!el)
|
|
2766
|
+
return;
|
|
2767
|
+
if (full)
|
|
2768
|
+
el.setAttribute("disabled", "");
|
|
2769
|
+
else
|
|
2770
|
+
el.removeAttribute("disabled");
|
|
2771
|
+
setDropFlag(el, "full", full);
|
|
2772
|
+
}
|
|
2751
2773
|
function setDropFilled(el, filled) {
|
|
2752
2774
|
setDropFlag(el, "filled", filled);
|
|
2753
2775
|
}
|
|
@@ -2842,7 +2864,7 @@ function patchWindow(window2) {
|
|
|
2842
2864
|
patchedWindows.add(window2);
|
|
2843
2865
|
}
|
|
2844
2866
|
var hasStates = (el) => !!el.internals?.states;
|
|
2845
|
-
var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part
|
|
2867
|
+
var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part~="bank"]', defaultCollisionAlgorithm = "pointerWithin") => {
|
|
2846
2868
|
class DragDropCoreElement extends superClass {
|
|
2847
2869
|
constructor() {
|
|
2848
2870
|
super(...arguments);
|
|
@@ -2862,6 +2884,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
2862
2884
|
returnAnchorItems: []
|
|
2863
2885
|
};
|
|
2864
2886
|
this.cloneFrame = IDENTITY_FIXED_FRAME;
|
|
2887
|
+
this.cursorBeforeDrag = null;
|
|
2865
2888
|
this.cloneZoom = 1;
|
|
2866
2889
|
this.subscriptions = [];
|
|
2867
2890
|
this.dragSubscriptions = [];
|
|
@@ -2960,8 +2983,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
2960
2983
|
const collect = (selector, scope) => Array.from(scope?.querySelectorAll(selector) ?? []);
|
|
2961
2984
|
const lightDraggables = collect(draggablesSelector, this);
|
|
2962
2985
|
const shadowDraggables = collect(draggablesSelector, this.shadowRoot);
|
|
2963
|
-
const lightClones = collect('[
|
|
2964
|
-
const shadowClones = collect('[
|
|
2986
|
+
const lightClones = collect('[data-draggable="true"]:not([data-drag-clone])', this);
|
|
2987
|
+
const shadowClones = collect('[data-draggable="true"]:not([data-drag-clone])', this.shadowRoot);
|
|
2965
2988
|
const registeredDraggables = this.registeredMatching(draggablesSelector);
|
|
2966
2989
|
this.trackedDraggables = Array.from(/* @__PURE__ */ new Set([...lightDraggables, ...shadowDraggables, ...lightClones, ...shadowClones, ...registeredDraggables]));
|
|
2967
2990
|
const lightDroppables = collect(droppablesSelector, this);
|
|
@@ -2980,20 +3003,14 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
2980
3003
|
for (const el of this.#statefulRoleElements) {
|
|
2981
3004
|
if (currentStateful.has(el))
|
|
2982
3005
|
continue;
|
|
2983
|
-
el.internals.states
|
|
2984
|
-
el.internals.states
|
|
3006
|
+
setState(el.internals.states, "chip", false);
|
|
3007
|
+
setState(el.internals.states, "drop", false);
|
|
2985
3008
|
}
|
|
2986
3009
|
for (const el of currentStateful) {
|
|
2987
3010
|
const isDrag = dragRoleSet.has(el);
|
|
2988
3011
|
const isDrop = !isDrag && effectiveDroppableSet.has(el);
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
else
|
|
2992
|
-
el.internals.states.delete("drag");
|
|
2993
|
-
if (isDrop)
|
|
2994
|
-
el.internals.states.add("droppable");
|
|
2995
|
-
else
|
|
2996
|
-
el.internals.states.delete("droppable");
|
|
3012
|
+
setState(el.internals.states, "chip", isDrag);
|
|
3013
|
+
setState(el.internals.states, "drop", isDrop);
|
|
2997
3014
|
}
|
|
2998
3015
|
this.#statefulRoleElements = currentStateful;
|
|
2999
3016
|
this.trackedDraggables.forEach((draggable) => {
|
|
@@ -3005,7 +3022,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3005
3022
|
draggable.style.touchAction = "none";
|
|
3006
3023
|
draggable.style.webkitUserSelect = "none";
|
|
3007
3024
|
draggable.style.webkitTouchCallout = "none";
|
|
3008
|
-
draggable.setAttribute("
|
|
3025
|
+
draggable.setAttribute("data-draggable", "true");
|
|
3009
3026
|
draggable.setAttribute("tabindex", "0");
|
|
3010
3027
|
} else {
|
|
3011
3028
|
draggable.style.cursor = "";
|
|
@@ -3013,7 +3030,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3013
3030
|
draggable.style.touchAction = "";
|
|
3014
3031
|
draggable.style.webkitUserSelect = "";
|
|
3015
3032
|
draggable.style.webkitTouchCallout = "";
|
|
3016
|
-
draggable.removeAttribute("
|
|
3033
|
+
draggable.removeAttribute("data-draggable");
|
|
3017
3034
|
if (draggable.getAttribute("tabindex") === "0") {
|
|
3018
3035
|
draggable.removeAttribute("tabindex");
|
|
3019
3036
|
}
|
|
@@ -3125,6 +3142,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3125
3142
|
if (target && ["Space", "Enter"].includes(e.code) && !hostDisabled && !targetDisabled) {
|
|
3126
3143
|
e.preventDefault();
|
|
3127
3144
|
target.setAttribute("data-keyboard-dragging", "true");
|
|
3145
|
+
setDragChipState(target, "lifted", true);
|
|
3146
|
+
this.activateAllDroppables(this.trackedDroppables.some((d) => d.contains(target) || !!d.shadowRoot?.contains(target)));
|
|
3128
3147
|
keyboardState = {
|
|
3129
3148
|
dragging: true,
|
|
3130
3149
|
dragElement: target,
|
|
@@ -3161,7 +3180,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3161
3180
|
this.handleInvalidDrop(keyboardState.dragElement);
|
|
3162
3181
|
}
|
|
3163
3182
|
}
|
|
3164
|
-
this.
|
|
3183
|
+
this.endKeyboardDrag();
|
|
3165
3184
|
this.saveResponse();
|
|
3166
3185
|
keyboardState = {
|
|
3167
3186
|
dragging: false,
|
|
@@ -3174,7 +3193,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3174
3193
|
}
|
|
3175
3194
|
case "Escape": {
|
|
3176
3195
|
e.preventDefault();
|
|
3177
|
-
this.
|
|
3196
|
+
this.endKeyboardDrag();
|
|
3178
3197
|
keyboardState = {
|
|
3179
3198
|
dragging: false,
|
|
3180
3199
|
dragElement: null,
|
|
@@ -3186,9 +3205,9 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3186
3205
|
}
|
|
3187
3206
|
}
|
|
3188
3207
|
}
|
|
3189
|
-
this.allDropzones.forEach((zone) => zone
|
|
3208
|
+
this.allDropzones.forEach((zone) => setDropFlag(zone, "drag-over", false));
|
|
3190
3209
|
if (keyboardState.dragging && keyboardState.dropElement) {
|
|
3191
|
-
keyboardState.dropElement
|
|
3210
|
+
setDropFlag(keyboardState.dropElement, "drag-over", true);
|
|
3192
3211
|
if (keyboardState.dropElement.hasAttribute("tabindex") && keyboardState.dropElement.getAttribute("tabindex") !== "-1") {
|
|
3193
3212
|
keyboardState.dropElement.focus();
|
|
3194
3213
|
}
|
|
@@ -3230,22 +3249,28 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3230
3249
|
this.dragState.dragClone?.setAttribute("data-drag-origin", "droppable");
|
|
3231
3250
|
this.removeChipFromDroppable(sourceDroppable, dragElement);
|
|
3232
3251
|
this.cacheInteractiveElements();
|
|
3252
|
+
setDropFull(sourceDroppable, false);
|
|
3233
3253
|
if (sourceDroppable) {
|
|
3234
3254
|
sourceDroppable.setAttribute("data-drag-source", "true");
|
|
3235
3255
|
}
|
|
3236
3256
|
const identifier = dragElement.getAttribute("identifier");
|
|
3237
3257
|
if (identifier) {
|
|
3238
3258
|
const anchors = findInventoryItems(this.trackedDragContainers, identifier);
|
|
3239
|
-
anchors.forEach((item) => setDragChipState(item, "return-
|
|
3259
|
+
anchors.forEach((item) => setDragChipState(item, "return-target", true));
|
|
3240
3260
|
this.dragState.returnAnchorItems = anchors;
|
|
3241
3261
|
}
|
|
3242
3262
|
} else {
|
|
3243
3263
|
this.dragState.dragClone?.setAttribute("data-drag-origin", "inventory");
|
|
3244
|
-
setDragChipState(dragElement, "
|
|
3264
|
+
setDragChipState(dragElement, "lifted", true);
|
|
3245
3265
|
}
|
|
3246
3266
|
this.updateClonePosition(startX, startY);
|
|
3247
|
-
this.activateAllDroppables();
|
|
3267
|
+
this.activateAllDroppables(isCloneInDroppable);
|
|
3248
3268
|
this.watchDragCloneHost();
|
|
3269
|
+
if (eventSource === "pointer") {
|
|
3270
|
+
const root = this.ownerDocument.documentElement;
|
|
3271
|
+
this.cursorBeforeDrag = root.style.cursor;
|
|
3272
|
+
root.style.cursor = "grabbing";
|
|
3273
|
+
}
|
|
3249
3274
|
this.setupMoveObservables(inputType, eventSource);
|
|
3250
3275
|
}
|
|
3251
3276
|
setupMoveObservables(inputType, eventSource = "pointer") {
|
|
@@ -3372,9 +3397,9 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3372
3397
|
const MIN_TARGET_SWITCH_INTERVAL = 50;
|
|
3373
3398
|
if (dropTarget !== this.dragState.currentTarget) {
|
|
3374
3399
|
if (dropTarget === null || timeSinceLastChange >= MIN_TARGET_SWITCH_INTERVAL) {
|
|
3375
|
-
this.allDropzones.forEach((zone) => setDropFlag(zone, "
|
|
3400
|
+
this.allDropzones.forEach((zone) => setDropFlag(zone, "drag-over", false));
|
|
3376
3401
|
if (dropTarget) {
|
|
3377
|
-
setDropFlag(dropTarget, "
|
|
3402
|
+
setDropFlag(dropTarget, "drag-over", true);
|
|
3378
3403
|
}
|
|
3379
3404
|
this.dragState.currentTarget = dropTarget;
|
|
3380
3405
|
this.dragState.lastTargetChangeTime = now;
|
|
@@ -3394,7 +3419,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3394
3419
|
const canDrop = !!dragSource && !!dropTarget && this.allowDrop(dragSource, dropTarget);
|
|
3395
3420
|
if (canDrop && dragSource && dropTarget) {
|
|
3396
3421
|
this.handleDrop(dragSource, dropTarget);
|
|
3397
|
-
setDragChipState(dragSource, "
|
|
3422
|
+
setDragChipState(dragSource, "lifted", false);
|
|
3398
3423
|
} else {
|
|
3399
3424
|
this.handleInvalidDrop(dragSource);
|
|
3400
3425
|
}
|
|
@@ -3402,7 +3427,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3402
3427
|
dragClone.remove();
|
|
3403
3428
|
}
|
|
3404
3429
|
(this.dragState.returnAnchorItems || []).forEach((item) => {
|
|
3405
|
-
setDragChipState(item, "return-
|
|
3430
|
+
setDragChipState(item, "return-target", false);
|
|
3406
3431
|
});
|
|
3407
3432
|
if (this.dragState.touchCleanup) {
|
|
3408
3433
|
this.dragState.touchCleanup();
|
|
@@ -3429,8 +3454,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3429
3454
|
const clone = element.cloneNode(true);
|
|
3430
3455
|
const computedStyles = window.getComputedStyle(element);
|
|
3431
3456
|
for (let i = 0; i < computedStyles.length; i++) {
|
|
3432
|
-
const
|
|
3433
|
-
clone.style.setProperty(
|
|
3457
|
+
const property28 = computedStyles[i];
|
|
3458
|
+
clone.style.setProperty(property28, computedStyles.getPropertyValue(property28));
|
|
3434
3459
|
}
|
|
3435
3460
|
clone.style.removeProperty("box-shadow");
|
|
3436
3461
|
const host = resolveDragCloneHost(element.isConnected ? element : this, this.dragCloneRoot());
|
|
@@ -3443,7 +3468,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3443
3468
|
clone.style.pointerEvents = "none";
|
|
3444
3469
|
clone.style.touchAction = "none";
|
|
3445
3470
|
clone.style.userSelect = "none";
|
|
3446
|
-
clone.removeAttribute("
|
|
3471
|
+
clone.removeAttribute("data-draggable");
|
|
3447
3472
|
clone.removeAttribute("tabindex");
|
|
3448
3473
|
clone.setAttribute("data-drag-clone", "true");
|
|
3449
3474
|
clone.setAttribute("data-drag-interaction", this.tagName.toLowerCase());
|
|
@@ -3507,29 +3532,44 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3507
3532
|
}
|
|
3508
3533
|
});
|
|
3509
3534
|
}
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3535
|
+
/**
|
|
3536
|
+
* A drag is in progress: the host and every target carry `drag-active` (CONTRACT.md §3). The
|
|
3537
|
+
* bank carries it only when the chip comes from a target: then the bank can take it back, and
|
|
3538
|
+
* lights up as a place to drop. A chip lifted out of the bank itself gives the bank nothing to
|
|
3539
|
+
* say. The host's old pair `dragzone-enabled` + `dragzone-active` is set alongside for one major.
|
|
3540
|
+
*/
|
|
3541
|
+
activateAllDroppables(fromDroppable = false) {
|
|
3542
|
+
this.setDragActive(true);
|
|
3513
3543
|
this.allDropzones.forEach((zone) => {
|
|
3514
|
-
|
|
3515
|
-
setDropFlag(zone, "active",
|
|
3544
|
+
const isBank = this.trackedDragContainers.includes(zone);
|
|
3545
|
+
setDropFlag(zone, "drag-active", fromDroppable || !isBank);
|
|
3516
3546
|
});
|
|
3517
3547
|
}
|
|
3518
3548
|
deactivateAllDroppables() {
|
|
3519
|
-
this.
|
|
3520
|
-
this.setInternalsState("dragzone-active", false);
|
|
3549
|
+
this.setDragActive(false);
|
|
3521
3550
|
this.allDropzones.forEach((zone) => {
|
|
3522
|
-
setDropFlag(zone, "
|
|
3523
|
-
setDropFlag(zone, "
|
|
3524
|
-
setDropFlag(zone, "hover", false);
|
|
3551
|
+
setDropFlag(zone, "drag-active", false);
|
|
3552
|
+
setDropFlag(zone, "drag-over", false);
|
|
3525
3553
|
});
|
|
3526
3554
|
}
|
|
3555
|
+
/** The keyboard drag is over, dropped or cancelled: clear what the pick-up set. */
|
|
3556
|
+
endKeyboardDrag() {
|
|
3557
|
+
this.trackedDraggables.forEach((d) => {
|
|
3558
|
+
if (d.hasAttribute("data-keyboard-dragging"))
|
|
3559
|
+
setDragChipState(d, "lifted", false);
|
|
3560
|
+
d.removeAttribute("data-keyboard-dragging");
|
|
3561
|
+
});
|
|
3562
|
+
this.deactivateAllDroppables();
|
|
3563
|
+
}
|
|
3564
|
+
setDragActive(on) {
|
|
3565
|
+
setState(this._internals?.states, "drag-active", on, ["dragzone-active", "dragzone-enabled"]);
|
|
3566
|
+
}
|
|
3527
3567
|
resetDragState() {
|
|
3528
3568
|
if (this.dragState.activationTimeout) {
|
|
3529
3569
|
clearTimeout(this.dragState.activationTimeout);
|
|
3530
3570
|
}
|
|
3531
3571
|
(this.dragState.returnAnchorItems || []).forEach((item) => {
|
|
3532
|
-
setDragChipState(item, "return-
|
|
3572
|
+
setDragChipState(item, "return-target", false);
|
|
3533
3573
|
});
|
|
3534
3574
|
if (this.dragState.touchCleanup) {
|
|
3535
3575
|
try {
|
|
@@ -3550,6 +3590,10 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3550
3590
|
this.dragSubscriptions = [];
|
|
3551
3591
|
this.cloneFrame = IDENTITY_FIXED_FRAME;
|
|
3552
3592
|
this.cloneZoom = 1;
|
|
3593
|
+
if (this.cursorBeforeDrag !== null) {
|
|
3594
|
+
this.ownerDocument.documentElement.style.cursor = this.cursorBeforeDrag;
|
|
3595
|
+
this.cursorBeforeDrag = null;
|
|
3596
|
+
}
|
|
3553
3597
|
this.dragState = {
|
|
3554
3598
|
dragging: false,
|
|
3555
3599
|
dragSource: null,
|
|
@@ -3564,14 +3608,14 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3564
3608
|
returnAnchorItems: []
|
|
3565
3609
|
};
|
|
3566
3610
|
}
|
|
3567
|
-
setInternalsState(
|
|
3611
|
+
setInternalsState(state17, enabled) {
|
|
3568
3612
|
const internals = this._internals;
|
|
3569
3613
|
if (!internals?.states)
|
|
3570
3614
|
return;
|
|
3571
3615
|
if (enabled) {
|
|
3572
|
-
internals.states.add(
|
|
3616
|
+
internals.states.add(state17);
|
|
3573
3617
|
} else {
|
|
3574
|
-
internals.states.delete(
|
|
3618
|
+
internals.states.delete(state17);
|
|
3575
3619
|
}
|
|
3576
3620
|
}
|
|
3577
3621
|
cleanup() {
|
|
@@ -3588,8 +3632,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
|
|
|
3588
3632
|
for (const el of this.#statefulRoleElements) {
|
|
3589
3633
|
if (!hasStates(el))
|
|
3590
3634
|
continue;
|
|
3591
|
-
el.internals.states
|
|
3592
|
-
el.internals.states
|
|
3635
|
+
setState(el.internals.states, "chip", false);
|
|
3636
|
+
setState(el.internals.states, "drop", false);
|
|
3593
3637
|
}
|
|
3594
3638
|
this.#statefulRoleElements.clear();
|
|
3595
3639
|
this.resetDragState();
|
|
@@ -3697,7 +3741,7 @@ var __decorate11 = function(decorators, target, key, desc) {
|
|
|
3697
3741
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3698
3742
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3699
3743
|
};
|
|
3700
|
-
var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part
|
|
3744
|
+
var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part~="bank"]', collisionAlgorithm = "closestCornersWithInventoryPriority") => {
|
|
3701
3745
|
const AutoSized = DropzoneAutoSizeMixin(superClass, draggablesSelector, droppablesSelector, dragContainersSelector);
|
|
3702
3746
|
const Core = DragDropCoreMixin(AutoSized, draggablesSelector, droppablesSelector, dragContainersSelector, collisionAlgorithm);
|
|
3703
3747
|
class DragDropSlottedElement extends Core {
|
|
@@ -3807,7 +3851,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
3807
3851
|
if (!targetId)
|
|
3808
3852
|
continue;
|
|
3809
3853
|
const bySelector = this.chipsIn(droppable);
|
|
3810
|
-
const byAttribute = this.isDeclarativeTarget(droppable) ? bySelector : Array.from(droppable.querySelectorAll('[
|
|
3854
|
+
const byAttribute = this.isDeclarativeTarget(droppable) ? bySelector : Array.from(droppable.querySelectorAll('[data-draggable="true"]'));
|
|
3811
3855
|
dragsByTarget[targetId] = bySelector.map((chip) => chip.getAttribute("identifier")).filter((id) => Boolean(id));
|
|
3812
3856
|
countByTarget[targetId] = Math.max(bySelector.length, byAttribute.length);
|
|
3813
3857
|
nodesByTarget[targetId] = bySelector;
|
|
@@ -3910,6 +3954,8 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
3910
3954
|
this._response = typeof value === "string" && value.length > 0 ? [value] : [];
|
|
3911
3955
|
}
|
|
3912
3956
|
this._internals.setFormValue(JSON.stringify(this._response));
|
|
3957
|
+
if (this.trackedDroppables?.length)
|
|
3958
|
+
this.validate();
|
|
3913
3959
|
}
|
|
3914
3960
|
afterCache() {
|
|
3915
3961
|
this.updateMinDimensionsForDropZones();
|
|
@@ -3981,7 +4027,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
3981
4027
|
this.updateInventoryBasedOnMatchMax(identifier);
|
|
3982
4028
|
}
|
|
3983
4029
|
this.validate();
|
|
3984
|
-
this.reportValidity();
|
|
4030
|
+
this.reportValidity({ trigger: "change" });
|
|
3985
4031
|
}
|
|
3986
4032
|
handleInvalidDrop(dragSource) {
|
|
3987
4033
|
const sourceDroppable = this.dragState.sourceDroppable;
|
|
@@ -3995,7 +4041,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
3995
4041
|
this.dropDraggableInDroppable(dragSource, inventoryReturnTarget);
|
|
3996
4042
|
} else if (sourceDroppable && this.trackedDroppables.includes(sourceDroppable)) {
|
|
3997
4043
|
this.dropDraggableInDroppable(dragSource, sourceDroppable, this.dragState.dragClone?.getBoundingClientRect());
|
|
3998
|
-
} else if (hasDragChipState(dragSource, "
|
|
4044
|
+
} else if (hasDragChipState(dragSource, "lifted")) {
|
|
3999
4045
|
this.restoreInventoryItem(dragSource, this.dragState.dragClone?.getBoundingClientRect());
|
|
4000
4046
|
const identifier = dragSource.getAttribute("identifier");
|
|
4001
4047
|
if (identifier) {
|
|
@@ -4009,7 +4055,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4009
4055
|
const attemptedDisabledTarget = !!currentTarget && currentTarget.hasAttribute("disabled") && !currentTarget.hasAttribute("data-drag-source");
|
|
4010
4056
|
this._dropBlockedDueToMax = attemptedDisabledTarget && maxReached;
|
|
4011
4057
|
this.validate();
|
|
4012
|
-
this.reportValidity();
|
|
4058
|
+
this.reportValidity({ trigger: "change" });
|
|
4013
4059
|
}
|
|
4014
4060
|
/**
|
|
4015
4061
|
* Fly a chip home from wherever it was last seen on screen.
|
|
@@ -4078,10 +4124,10 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4078
4124
|
const parsedMatchMax = parseInt(droppable.getAttribute("match-max") || "1", 10);
|
|
4079
4125
|
const matchMax = Number.isNaN(parsedMatchMax) ? 1 : parsedMatchMax;
|
|
4080
4126
|
const allowsMultiple = matchMax === 0 || matchMax > 1;
|
|
4081
|
-
const existingChildren = Array.from(droppable.querySelectorAll('[
|
|
4127
|
+
const existingChildren = Array.from(droppable.querySelectorAll('[data-draggable="true"]'));
|
|
4082
4128
|
const flipStates = this.enableFlipAnimations && existingChildren.length > 0 ? captureMultipleFlipStates(existingChildren) : null;
|
|
4083
4129
|
if (!allowsMultiple) {
|
|
4084
|
-
const existing = this.chipsIn(droppable)[0] ?? (this.isDeclarativeTarget(droppable) ? null : droppable.querySelector('[
|
|
4130
|
+
const existing = this.chipsIn(droppable)[0] ?? (this.isDeclarativeTarget(droppable) ? null : droppable.querySelector('[data-draggable="true"]'));
|
|
4085
4131
|
if (existing) {
|
|
4086
4132
|
const existingId = existing.getAttribute("identifier");
|
|
4087
4133
|
const evictedFrom = existing.getBoundingClientRect();
|
|
@@ -4100,11 +4146,15 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4100
4146
|
const cleanClone = draggable.cloneNode(true);
|
|
4101
4147
|
cleanClone.removeAttribute("style");
|
|
4102
4148
|
cleanClone.removeAttribute("data-keyboard-dragging");
|
|
4103
|
-
cleanClone.setAttribute("
|
|
4149
|
+
cleanClone.setAttribute("data-draggable", "true");
|
|
4104
4150
|
cleanClone.setAttribute("tabindex", "0");
|
|
4105
4151
|
if (this.isDeclarativeTarget(droppable)) {
|
|
4106
|
-
cleanClone.setAttribute("part", cleanClone.localName === "qti-gap-text" ? "drag drag-text" : "drag");
|
|
4107
|
-
cleanClone.setAttribute("exportparts",
|
|
4152
|
+
cleanClone.setAttribute("part", cleanClone.localName === "qti-gap-text" ? "chip text drag drag-text" : "chip drag");
|
|
4153
|
+
cleanClone.setAttribute("exportparts", [
|
|
4154
|
+
"control: chip-control, control: drag-control, label: chip-label, label: drag-label",
|
|
4155
|
+
"correction, candidate-correct, candidate-incorrect, candidate-partial",
|
|
4156
|
+
"correction-correct, correction-incorrect, correction-partially-correct"
|
|
4157
|
+
].join(", "));
|
|
4108
4158
|
this.placeChip(droppable, cleanClone);
|
|
4109
4159
|
} else if (droppable.tagName === "SLOT") {
|
|
4110
4160
|
cleanClone.setAttribute("slot", droppable.getAttribute("name") || "");
|
|
@@ -4165,7 +4215,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4165
4215
|
const returning = new Set(inventoryItems);
|
|
4166
4216
|
const shiftingItems = [];
|
|
4167
4217
|
this.trackedDragContainers.forEach((container) => {
|
|
4168
|
-
container.querySelectorAll('[
|
|
4218
|
+
container.querySelectorAll('[data-draggable="true"]').forEach((item) => !returning.has(item) && shiftingItems.push(item));
|
|
4169
4219
|
});
|
|
4170
4220
|
const flipStates = this.enableFlipAnimations && shiftingItems.length > 0 ? captureMultipleFlipStates(shiftingItems) : null;
|
|
4171
4221
|
inventoryItems.forEach((item) => {
|
|
@@ -4188,7 +4238,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4188
4238
|
return count + droppable.querySelectorAll(`[identifier="${identifier}"]`).length;
|
|
4189
4239
|
}, 0);
|
|
4190
4240
|
inventoryItems.forEach((item) => {
|
|
4191
|
-
setDragChipState(item, "
|
|
4241
|
+
setDragChipState(item, "used", matchMax !== 0 && placedInDropzones >= matchMax);
|
|
4192
4242
|
});
|
|
4193
4243
|
}
|
|
4194
4244
|
checkAllMaxAssociations() {
|
|
@@ -4198,11 +4248,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4198
4248
|
this.trackedDroppables.forEach((droppable) => {
|
|
4199
4249
|
const isDragSource = droppable.hasAttribute("data-drag-source");
|
|
4200
4250
|
const isAtCapacity = this.droppableAtCapacityFromState(droppable);
|
|
4201
|
-
|
|
4202
|
-
droppable.setAttribute("disabled", "");
|
|
4203
|
-
} else {
|
|
4204
|
-
droppable.removeAttribute("disabled");
|
|
4205
|
-
}
|
|
4251
|
+
setDropFull(droppable, (isAtCapacity || disableAtMax && maxReached) && !isDragSource);
|
|
4206
4252
|
});
|
|
4207
4253
|
}
|
|
4208
4254
|
saveResponse(value) {
|
|
@@ -4236,6 +4282,9 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4236
4282
|
});
|
|
4237
4283
|
this.resetDragState();
|
|
4238
4284
|
this.cacheInteractiveElements();
|
|
4285
|
+
this.trackedDroppables.forEach((droppable) => setDropFull(droppable, false));
|
|
4286
|
+
this.checkAllMaxAssociations();
|
|
4287
|
+
this.resetValidityReport();
|
|
4239
4288
|
this._response = [];
|
|
4240
4289
|
this._internals.setFormValue(JSON.stringify(this._response));
|
|
4241
4290
|
if (save) {
|
|
@@ -4249,13 +4298,17 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4249
4298
|
const belowMin = this.minAssociations > 0 && totalAssociations < this.minAssociations;
|
|
4250
4299
|
let validityMessage = "";
|
|
4251
4300
|
let isValid = true;
|
|
4301
|
+
let kind = "other";
|
|
4252
4302
|
if (exceedsMax) {
|
|
4303
|
+
kind = "max";
|
|
4253
4304
|
validityMessage = this.getFirstMessageAttribute(["data-max-associations-message", "data-max-selections-message"]) || this.dataset.maxAssociationsMessage || this.dataset.maxSelectionsMessage || `You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`;
|
|
4254
4305
|
isValid = false;
|
|
4255
4306
|
} else if (atMaxCapacity && this._dropBlockedDueToMax && this.shouldTreatBlockedMaxAsInvalid()) {
|
|
4307
|
+
kind = "max";
|
|
4256
4308
|
validityMessage = this.getFirstMessageAttribute(["data-max-associations-message", "data-max-selections-message"]) || this.dataset.maxAssociationsMessage || this.dataset.maxSelectionsMessage || `You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`;
|
|
4257
4309
|
isValid = false;
|
|
4258
4310
|
} else if (belowMin) {
|
|
4311
|
+
kind = "min";
|
|
4259
4312
|
validityMessage = this.getFirstMessageAttribute(["data-min-associations-message", "data-min-selections-message"]) || this.dataset.minAssociationsMessage || this.dataset.minSelectionsMessage || `Please select at least ${this.minAssociations} ${this.minAssociations === 1 ? "association" : "associations"}.`;
|
|
4260
4313
|
isValid = false;
|
|
4261
4314
|
this._dropBlockedDueToMax = false;
|
|
@@ -4263,11 +4316,11 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
|
|
|
4263
4316
|
this._dropBlockedDueToMax = false;
|
|
4264
4317
|
}
|
|
4265
4318
|
const validityAnchor = this.trackedDroppables[0] ?? this.trackedDraggables[0] ?? this;
|
|
4266
|
-
this.setInteractionValidity(isValid, validityMessage, validityAnchor, { suppressInline: true });
|
|
4319
|
+
this.setInteractionValidity(isValid, validityMessage, validityAnchor, { suppressInline: true, kind });
|
|
4267
4320
|
return isValid;
|
|
4268
4321
|
}
|
|
4269
|
-
reportValidity() {
|
|
4270
|
-
return super.reportValidity();
|
|
4322
|
+
reportValidity(options) {
|
|
4323
|
+
return super.reportValidity(options);
|
|
4271
4324
|
}
|
|
4272
4325
|
}
|
|
4273
4326
|
__decorate11([
|
|
@@ -4336,6 +4389,7 @@ function resetSortableDragContext(context) {
|
|
|
4336
4389
|
function createDropPlaceholder(source, rect, config = {}) {
|
|
4337
4390
|
const mergedConfig = { ...defaultPlaceholderConfig, ...config };
|
|
4338
4391
|
const placeholder = document.createElement("div");
|
|
4392
|
+
placeholder.setAttribute("data-drop-preview", "true");
|
|
4339
4393
|
placeholder.setAttribute("data-drop-placeholder", "true");
|
|
4340
4394
|
placeholder.style.width = `${rect.width}px`;
|
|
4341
4395
|
placeholder.style.height = `${rect.height}px`;
|
|
@@ -4358,7 +4412,7 @@ function isElementInContainer(element, containers) {
|
|
|
4358
4412
|
}
|
|
4359
4413
|
|
|
4360
4414
|
// ../interactions/core/dist/mixins/drag-drop-observables/drag-drop-slotted-sortable.mixin.js
|
|
4361
|
-
var DragDropSlottedSortableMixin = (superClass, sortableItemSelector = '[
|
|
4415
|
+
var DragDropSlottedSortableMixin = (superClass, sortableItemSelector = '[data-draggable="true"]') => {
|
|
4362
4416
|
class DragDropSlottedSortableElement extends superClass {
|
|
4363
4417
|
constructor() {
|
|
4364
4418
|
super(...arguments);
|
|
@@ -4515,7 +4569,7 @@ var DragDropSlottedSortableMixin = (superClass, sortableItemSelector = '[qti-dra
|
|
|
4515
4569
|
if (this.#slotAllowsMultiple(slot) && this.#isSlotAtCapacity(slot)) {
|
|
4516
4570
|
return;
|
|
4517
4571
|
}
|
|
4518
|
-
slot
|
|
4572
|
+
setDropFull(slot, false);
|
|
4519
4573
|
this.#temporarilyEnabledSlots.add(slot);
|
|
4520
4574
|
}
|
|
4521
4575
|
});
|
|
@@ -4593,15 +4647,19 @@ var qti_associate_interaction_styles_default = [
|
|
|
4593
4647
|
then compresses the chips instead of moving them down: a bank of six squeezed the last chip
|
|
4594
4648
|
until only its grip was left, at no width the author could see coming. A chip is a fixed
|
|
4595
4649
|
thing, so the only place the overflow can go is the next line. */
|
|
4596
|
-
|
|
4650
|
+
[part~='bank'] {
|
|
4651
|
+
/* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
|
|
4652
|
+
margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
|
|
4653
|
+
in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
|
|
4597
4654
|
display: flex;
|
|
4598
4655
|
flex-wrap: wrap;
|
|
4599
4656
|
align-items: flex-start;
|
|
4600
4657
|
flex: 1;
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4658
|
+
gap: var(--qti-gap, 0.5rem);
|
|
4659
|
+
padding: 0;
|
|
4660
|
+
margin: 0;
|
|
4661
|
+
border: 0;
|
|
4662
|
+
border-radius: var(--qti-radius-box, 0.2rem);
|
|
4605
4663
|
}
|
|
4606
4664
|
|
|
4607
4665
|
/* Drop target. --qti-dropzone-min-height is published by the interaction from the measured
|
|
@@ -4621,7 +4679,7 @@ var qti_associate_interaction_styles_default = [
|
|
|
4621
4679
|
gap: 0.5rem;
|
|
4622
4680
|
}
|
|
4623
4681
|
|
|
4624
|
-
:host::part(
|
|
4682
|
+
:host::part(row) {
|
|
4625
4683
|
display: flex;
|
|
4626
4684
|
justify-content: space-between;
|
|
4627
4685
|
background: linear-gradient(
|
|
@@ -4649,7 +4707,7 @@ var __decorate12 = function(decorators, target, key, desc) {
|
|
|
4649
4707
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4650
4708
|
};
|
|
4651
4709
|
var SlottedBase = DragDropSlottedMixin(Interaction, "qti-simple-associable-choice", `[part~='drop']`, `slot[name='qti-simple-associable-choice']`, "pointerWithin");
|
|
4652
|
-
var QtiAssociateInteraction = class extends DragDropSlottedSortableMixin(SlottedBase, '[
|
|
4710
|
+
var QtiAssociateInteraction = class extends DragDropSlottedSortableMixin(SlottedBase, '[data-draggable="true"]') {
|
|
4653
4711
|
static {
|
|
4654
4712
|
this.styles = qti_associate_interaction_styles_default;
|
|
4655
4713
|
}
|
|
@@ -4733,9 +4791,9 @@ var QtiAssociateInteraction = class extends DragDropSlottedSortableMixin(Slotted
|
|
|
4733
4791
|
}
|
|
4734
4792
|
render() {
|
|
4735
4793
|
return html11` <slot name="prompt"></slot>
|
|
4736
|
-
<slot part="drags" name="qti-simple-associable-choice"></slot>
|
|
4794
|
+
<slot part="bank drags" name="qti-simple-associable-choice"></slot>
|
|
4737
4795
|
<div part="drops">
|
|
4738
|
-
${this._childrenMap.length > 0 && Array.from({ length: this.#rowCount }, (_, index) => html11`<div part="drop-row">
|
|
4796
|
+
${this._childrenMap.length > 0 && Array.from({ length: this.#rowCount }, (_, index) => html11`<div part="row drop-row">
|
|
4739
4797
|
${this.#renderDrop(`droplist${index}_left`, `left${index}`)}
|
|
4740
4798
|
${this.#renderDrop(`droplist${index}_right`, `right${index}`)}
|
|
4741
4799
|
</div>`)}
|
|
@@ -4848,7 +4906,7 @@ var ChoicesMixin = (superClass, selector) => {
|
|
|
4848
4906
|
}
|
|
4849
4907
|
});
|
|
4850
4908
|
this._determineInputType();
|
|
4851
|
-
const validIdentifiers = new Set(this._choiceElements.map((c) => c.identifier));
|
|
4909
|
+
const validIdentifiers = new Set(this._choiceElements.map((c) => c.getAttribute("identifier") ?? c.identifier));
|
|
4852
4910
|
if (Array.isArray(this.response)) {
|
|
4853
4911
|
const filteredResponse = this.response.filter((id) => validIdentifiers.has(id));
|
|
4854
4912
|
if (filteredResponse.length !== this.response.length) {
|
|
@@ -4864,19 +4922,22 @@ var ChoicesMixin = (superClass, selector) => {
|
|
|
4864
4922
|
const selectedCount = selectedChoices.length;
|
|
4865
4923
|
let isValid = true;
|
|
4866
4924
|
let validityMessage = "";
|
|
4925
|
+
let kind = "other";
|
|
4867
4926
|
if (this.maxChoices !== 0 && selectedCount > this.maxChoices) {
|
|
4868
4927
|
isValid = false;
|
|
4928
|
+
kind = "max";
|
|
4869
4929
|
validityMessage = this.dataset.maxSelectionsMessage || `Please select no more than ${this.maxChoices} ${this.maxChoices === 1 ? "option" : "options"}.`;
|
|
4870
4930
|
} else if (selectedCount < this.minChoices) {
|
|
4871
4931
|
isValid = false;
|
|
4932
|
+
kind = "min";
|
|
4872
4933
|
validityMessage = this.dataset.minSelectionsMessage || `Please select at least ${this.minChoices} ${this.minChoices === 1 ? "option" : "options"}.`;
|
|
4873
4934
|
}
|
|
4874
4935
|
const anchor = this._choiceElements.find((c) => this.contains(c)) || this;
|
|
4875
|
-
this.setInteractionValidity(isValid, validityMessage, anchor, { suppressInline: true });
|
|
4936
|
+
this.setInteractionValidity(isValid, validityMessage, anchor, { suppressInline: true, kind });
|
|
4876
4937
|
return isValid;
|
|
4877
4938
|
}
|
|
4878
|
-
reportValidity() {
|
|
4879
|
-
return super.reportValidity();
|
|
4939
|
+
reportValidity(options) {
|
|
4940
|
+
return super.reportValidity(options);
|
|
4880
4941
|
}
|
|
4881
4942
|
/**
|
|
4882
4943
|
* Publish the role the choices should take. Each choice subscribes to
|
|
@@ -4940,7 +5001,7 @@ var ChoicesMixin = (superClass, selector) => {
|
|
|
4940
5001
|
const selectedIdentifiers = selectedChoices.map((choice) => choice.identifier);
|
|
4941
5002
|
this.response = this.maxChoices === 1 ? selectedIdentifiers[0] || "" : selectedIdentifiers;
|
|
4942
5003
|
this.validate();
|
|
4943
|
-
this.reportValidity();
|
|
5004
|
+
this.reportValidity({ trigger: "change" });
|
|
4944
5005
|
this.saveResponse(this.response);
|
|
4945
5006
|
}
|
|
4946
5007
|
/**
|
|
@@ -5132,13 +5193,13 @@ var qti_choice_interaction_styles_default = [
|
|
|
5132
5193
|
|
|
5133
5194
|
/* No gap of its own: a choice carries its own padding, which already spaces a list. A theme sets
|
|
5134
5195
|
--qti-choice-gap where the choices are drawn as separate boxes and need air between them. */
|
|
5135
|
-
[part
|
|
5196
|
+
[part~='choices'] {
|
|
5136
5197
|
display: grid;
|
|
5137
5198
|
gap: var(--qti-choice-gap, 0);
|
|
5138
5199
|
}
|
|
5139
5200
|
|
|
5140
5201
|
/* Define the number of columns dynamically */
|
|
5141
|
-
:host([class*='qti-choices-stacking-']) [part
|
|
5202
|
+
:host([class*='qti-choices-stacking-']) [part~='choices'] {
|
|
5142
5203
|
grid-template-columns: repeat(var(--stacking-count, 1), 1fr);
|
|
5143
5204
|
}
|
|
5144
5205
|
|
|
@@ -5167,24 +5228,24 @@ var qti_choice_interaction_styles_default = [
|
|
|
5167
5228
|
}
|
|
5168
5229
|
|
|
5169
5230
|
/* Orientation styles */
|
|
5170
|
-
:host(.qti-orientation-horizontal) [part
|
|
5231
|
+
:host(.qti-orientation-horizontal) [part~='choices'] {
|
|
5171
5232
|
grid-auto-flow: dense column;
|
|
5172
5233
|
grid-auto-columns: 1fr;
|
|
5173
5234
|
}
|
|
5174
5235
|
|
|
5175
|
-
:host(.qti-orientation-vertical) [part
|
|
5236
|
+
:host(.qti-orientation-vertical) [part~='choices'] {
|
|
5176
5237
|
grid-auto-flow: row;
|
|
5177
5238
|
}
|
|
5178
5239
|
|
|
5179
5240
|
/* Vertical and horizontal stacking logic */
|
|
5180
|
-
:host(.qti-orientation-vertical[class*='qti-choices-stacking-']) [part
|
|
5241
|
+
:host(.qti-orientation-vertical[class*='qti-choices-stacking-']) [part~='choices'] {
|
|
5181
5242
|
grid-auto-flow: dense column;
|
|
5182
5243
|
grid-auto-columns: 1fr;
|
|
5183
5244
|
grid-template-columns: repeat(var(--stacking-count), 1fr);
|
|
5184
5245
|
grid-template-rows: repeat(calc(var(--item-count) / var(--stacking-count)), 1fr);
|
|
5185
5246
|
}
|
|
5186
5247
|
|
|
5187
|
-
:host(.qti-orientation-horizontal[class*='qti-choices-stacking-']) [part
|
|
5248
|
+
:host(.qti-orientation-horizontal[class*='qti-choices-stacking-']) [part~='choices'] {
|
|
5188
5249
|
grid-auto-flow: row;
|
|
5189
5250
|
grid-template-columns: repeat(var(--stacking-count), 1fr);
|
|
5190
5251
|
grid-template-rows: unset;
|
|
@@ -5219,7 +5280,7 @@ var QtiChoiceInteraction = class extends VocabularyMixin(ChoicesMixin(Interactio
|
|
|
5219
5280
|
render() {
|
|
5220
5281
|
return html12`
|
|
5221
5282
|
<slot part="prompt" name="prompt"></slot>
|
|
5222
|
-
<slot part="slot" @slotchange=${this.#handleSlotChange}></slot>
|
|
5283
|
+
<slot part="choices slot" @slotchange=${this.#handleSlotChange}></slot>
|
|
5223
5284
|
<div part="message" role="alert" id="validation-message"></div>
|
|
5224
5285
|
`;
|
|
5225
5286
|
}
|
|
@@ -5943,18 +6004,20 @@ var QtiExtendedTextInteraction = class extends Interaction {
|
|
|
5943
6004
|
} else {
|
|
5944
6005
|
isValid = textarea.checkValidity();
|
|
5945
6006
|
}
|
|
6007
|
+
let kind = "other";
|
|
5946
6008
|
if (isValid && !this.response && this.minStrings >= 1) {
|
|
5947
6009
|
isValid = false;
|
|
6010
|
+
kind = "min";
|
|
5948
6011
|
}
|
|
5949
6012
|
if (!isValid && !validityMessage) {
|
|
5950
6013
|
validityMessage = textarea.validationMessage || "Invalid value.";
|
|
5951
6014
|
}
|
|
5952
|
-
this.setInteractionValidity(isValid, validityMessage, textarea, { suppressInline: true });
|
|
6015
|
+
this.setInteractionValidity(isValid, validityMessage, textarea, { suppressInline: true, kind });
|
|
5953
6016
|
return isValid;
|
|
5954
6017
|
}
|
|
5955
|
-
reportValidity() {
|
|
6018
|
+
reportValidity(options) {
|
|
5956
6019
|
this.validate();
|
|
5957
|
-
return super.reportValidity();
|
|
6020
|
+
return super.reportValidity(options);
|
|
5958
6021
|
}
|
|
5959
6022
|
/*
|
|
5960
6023
|
* The template in named pieces, so a subclass can recompose it.
|
|
@@ -5984,7 +6047,7 @@ var QtiExtendedTextInteraction = class extends Interaction {
|
|
|
5984
6047
|
@keyup="${this.textChanged}"
|
|
5985
6048
|
@change="${this.textChanged}"
|
|
5986
6049
|
@blur="${(_) => {
|
|
5987
|
-
this.reportValidity();
|
|
6050
|
+
this.reportValidity({ trigger: "change" });
|
|
5988
6051
|
}}"
|
|
5989
6052
|
placeholder="${ifDefined(this.placeholderText ? this.placeholderText : void 0)}"
|
|
5990
6053
|
rows="${this._rows}"
|
|
@@ -6007,6 +6070,7 @@ var QtiExtendedTextInteraction = class extends Interaction {
|
|
|
6007
6070
|
if (this.response !== input.value) {
|
|
6008
6071
|
this.value = input.value;
|
|
6009
6072
|
this.saveResponse(input.value);
|
|
6073
|
+
this.reportValidity({ trigger: "change" });
|
|
6010
6074
|
}
|
|
6011
6075
|
}
|
|
6012
6076
|
};
|
|
@@ -6085,28 +6149,32 @@ var qti_gap_match_interaction_styles_default = [
|
|
|
6085
6149
|
}
|
|
6086
6150
|
/* Wraps, for the reason spelled out on associate's identical bank: nowrap does not overflow, it
|
|
6087
6151
|
shrinks, and a squeezed chip is worse than a second line. */
|
|
6088
|
-
[
|
|
6152
|
+
[part~='bank'] {
|
|
6153
|
+
/* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
|
|
6154
|
+
margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
|
|
6155
|
+
in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
|
|
6089
6156
|
display: flex;
|
|
6090
6157
|
flex-wrap: wrap;
|
|
6091
6158
|
align-items: flex-start;
|
|
6092
6159
|
flex: 1;
|
|
6093
|
-
|
|
6094
|
-
padding: 0
|
|
6095
|
-
|
|
6096
|
-
|
|
6160
|
+
gap: var(--qti-gap, 0.5rem);
|
|
6161
|
+
padding: 0;
|
|
6162
|
+
margin: 0;
|
|
6163
|
+
border: 0;
|
|
6164
|
+
border-radius: var(--qti-radius-box, 0.2rem);
|
|
6097
6165
|
}
|
|
6098
6166
|
|
|
6099
6167
|
/* An answer key shows the answer, not the bank you would have dragged it from. The attribute is
|
|
6100
6168
|
set on the clone by the correct-response mixin; the theme used to do this with a
|
|
6101
6169
|
'.full-correct-response' descendant selector, from the document. */
|
|
6102
|
-
:host([answer-key]) [part~='
|
|
6170
|
+
:host([answer-key]) [part~='bank'] {
|
|
6103
6171
|
display: none;
|
|
6104
6172
|
}
|
|
6105
6173
|
`
|
|
6106
6174
|
];
|
|
6107
6175
|
|
|
6108
6176
|
// ../interactions/gap-match-interaction/dist/qti-gap-match-interaction.js
|
|
6109
|
-
var QtiGapMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-gap-text", "qti-gap", `slot[part~='drags']`), '[
|
|
6177
|
+
var QtiGapMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-gap-text", "qti-gap", `slot[part~='drags']`), '[data-draggable="true"]') {
|
|
6110
6178
|
constructor() {
|
|
6111
6179
|
super(...arguments);
|
|
6112
6180
|
this.maxAssociations = 1;
|
|
@@ -6116,7 +6184,7 @@ var QtiGapMatchInteraction = class extends DragDropSlottedSortableMixin(DragDrop
|
|
|
6116
6184
|
}
|
|
6117
6185
|
render() {
|
|
6118
6186
|
return html16`<slot name="prompt"> </slot>
|
|
6119
|
-
<slot part="drags" name="drags"></slot>
|
|
6187
|
+
<slot part="bank drags" name="drags"></slot>
|
|
6120
6188
|
<slot part="drops"></slot>
|
|
6121
6189
|
<div role="alert" part="message" id="validation-message"></div>`;
|
|
6122
6190
|
}
|
|
@@ -6353,6 +6421,25 @@ var qti_graphic_associate_interaction_styles_default = [
|
|
|
6353
6421
|
position: absolute;
|
|
6354
6422
|
top: 0px;
|
|
6355
6423
|
left: 0px;
|
|
6424
|
+
/* Lines take clicks; the empty canvas lets them through to the points underneath. */
|
|
6425
|
+
pointer-events: none;
|
|
6426
|
+
}
|
|
6427
|
+
/* A wide invisible stroke over each line, so removing one does not take a 3px aim. */
|
|
6428
|
+
line[data-hit] {
|
|
6429
|
+
stroke: transparent;
|
|
6430
|
+
stroke-width: 16px;
|
|
6431
|
+
stroke-linecap: round;
|
|
6432
|
+
pointer-events: stroke;
|
|
6433
|
+
cursor: pointer;
|
|
6434
|
+
outline: none;
|
|
6435
|
+
}
|
|
6436
|
+
/* A line under the pointer or keyboard focus shows that it can be removed. */
|
|
6437
|
+
line[data-hit]:hover,
|
|
6438
|
+
line[data-hit]:focus-visible {
|
|
6439
|
+
stroke: color-mix(in srgb, currentColor 18%, transparent);
|
|
6440
|
+
}
|
|
6441
|
+
::slotted(qti-associable-hotspot) {
|
|
6442
|
+
cursor: pointer;
|
|
6356
6443
|
}
|
|
6357
6444
|
`
|
|
6358
6445
|
];
|
|
@@ -6370,23 +6457,55 @@ var QtiGraphicAssociateInteraction = class extends Interaction {
|
|
|
6370
6457
|
}
|
|
6371
6458
|
#hotspots;
|
|
6372
6459
|
#startPoint;
|
|
6373
|
-
#endPoint;
|
|
6374
6460
|
constructor() {
|
|
6375
6461
|
super();
|
|
6376
6462
|
this.#hotspots = [];
|
|
6377
6463
|
this.#startPoint = null;
|
|
6378
|
-
this.#endPoint = null;
|
|
6379
6464
|
this._response = [];
|
|
6465
|
+
this.minAssociations = 0;
|
|
6466
|
+
this.maxAssociations = 1;
|
|
6380
6467
|
this.addEventListener("qti-register-hotspot", this.#positionHotspotOnRegister);
|
|
6381
6468
|
}
|
|
6382
6469
|
reset() {
|
|
6470
|
+
this.resetValidityReport();
|
|
6383
6471
|
this._response = [];
|
|
6472
|
+
this._internals.setFormValue(null);
|
|
6473
|
+
this.validate();
|
|
6474
|
+
this.#startPoint = null;
|
|
6475
|
+
this.#syncHotspotStates();
|
|
6384
6476
|
}
|
|
6385
6477
|
validate() {
|
|
6386
|
-
|
|
6478
|
+
const count = this.#getResponseArray().length;
|
|
6479
|
+
const exceedsMax = this.maxAssociations > 0 && count > this.maxAssociations;
|
|
6480
|
+
const belowMin = count < this.minAssociations;
|
|
6481
|
+
let kind = "other";
|
|
6482
|
+
let message = "";
|
|
6483
|
+
if (exceedsMax) {
|
|
6484
|
+
kind = "max";
|
|
6485
|
+
message = this.dataset.maxAssociationsMessage || this.dataset.maxSelectionsMessage || `You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`;
|
|
6486
|
+
} else if (belowMin) {
|
|
6487
|
+
kind = "min";
|
|
6488
|
+
message = this.dataset.minAssociationsMessage || this.dataset.minSelectionsMessage || `Please select at least ${this.minAssociations} ${this.minAssociations === 1 ? "association" : "associations"}.`;
|
|
6489
|
+
}
|
|
6490
|
+
const isValid = !exceedsMax && !belowMin;
|
|
6491
|
+
this.setInteractionValidity(isValid, message, this, { suppressInline: true, kind });
|
|
6492
|
+
return isValid;
|
|
6493
|
+
}
|
|
6494
|
+
reportValidity(options) {
|
|
6495
|
+
return super.reportValidity(options);
|
|
6387
6496
|
}
|
|
6388
6497
|
set response(val) {
|
|
6389
6498
|
this._response = this.#normalizeResponse(val);
|
|
6499
|
+
this.#responseChanged(false);
|
|
6500
|
+
this.#syncHotspotStates();
|
|
6501
|
+
}
|
|
6502
|
+
/** The form value and the validity follow every change; a candidate's change also reports. */
|
|
6503
|
+
#responseChanged(byCandidate) {
|
|
6504
|
+
const lines = this.#getResponseArray();
|
|
6505
|
+
this._internals.setFormValue(lines.length ? JSON.stringify(lines) : null);
|
|
6506
|
+
this.validate();
|
|
6507
|
+
if (byCandidate)
|
|
6508
|
+
this.reportValidity({ trigger: "change" });
|
|
6390
6509
|
}
|
|
6391
6510
|
get response() {
|
|
6392
6511
|
return this._response;
|
|
@@ -6405,36 +6524,61 @@ var QtiGraphicAssociateInteraction = class extends Interaction {
|
|
|
6405
6524
|
}
|
|
6406
6525
|
render() {
|
|
6407
6526
|
return html17`<slot name="prompt"></slot>
|
|
6408
|
-
<line-container
|
|
6527
|
+
<line-container
|
|
6528
|
+
@click=${(e) => {
|
|
6529
|
+
if (this.#startPoint && !e.composedPath().some((n) => this.#hotspots.includes(n))) {
|
|
6530
|
+
this.#cancel();
|
|
6531
|
+
}
|
|
6532
|
+
}}
|
|
6533
|
+
>
|
|
6409
6534
|
<svg
|
|
6410
6535
|
width=${ifDefined2(this.grImage[0]?.width)}
|
|
6411
6536
|
height=${ifDefined2(this.grImage[0]?.height)}
|
|
6412
6537
|
viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
|
|
6413
6538
|
>
|
|
6414
|
-
${repeat5(this.#getResponseArray(), (line) => line, (line, index) =>
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
e
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6539
|
+
${repeat5(this.#getResponseArray(), (line) => line, (line, index) => {
|
|
6540
|
+
const [a, b] = line.split(" ");
|
|
6541
|
+
const from = this.querySelector(`[identifier=${a}]`);
|
|
6542
|
+
const to = this.querySelector(`[identifier=${b}]`);
|
|
6543
|
+
if (!from || !to)
|
|
6544
|
+
return nothing2;
|
|
6545
|
+
const x1 = parseInt(from.style.left);
|
|
6546
|
+
const y1 = parseInt(from.style.top);
|
|
6547
|
+
const x2 = parseInt(to.style.left);
|
|
6548
|
+
const y2 = parseInt(to.style.top);
|
|
6549
|
+
const remove = (e) => {
|
|
6550
|
+
e.stopPropagation();
|
|
6551
|
+
this.#removeLine(index);
|
|
6552
|
+
};
|
|
6553
|
+
return svg`
|
|
6554
|
+
<line part="line" x1=${x1} y1=${y1} x2=${x2} y2=${y2} stroke="currentColor" stroke-width="3" />
|
|
6555
|
+
<line
|
|
6556
|
+
data-hit
|
|
6557
|
+
x1=${x1}
|
|
6558
|
+
y1=${y1}
|
|
6559
|
+
x2=${x2}
|
|
6560
|
+
y2=${y2}
|
|
6561
|
+
tabindex=${this.disabled || this.readonly ? -1 : 0}
|
|
6562
|
+
role="button"
|
|
6563
|
+
aria-label=${`Remove line ${a} \u2013 ${b}`}
|
|
6564
|
+
@click=${remove}
|
|
6565
|
+
@keydown=${(e) => {
|
|
6566
|
+
if (["Enter", " ", "Delete", "Backspace"].includes(e.key)) {
|
|
6567
|
+
e.preventDefault();
|
|
6568
|
+
remove(e);
|
|
6569
|
+
}
|
|
6570
|
+
}}
|
|
6571
|
+
><title>Remove line ${a} – ${b}</title></line>
|
|
6572
|
+
`;
|
|
6573
|
+
})}
|
|
6430
6574
|
${this.renderSupplementalLines()}
|
|
6431
6575
|
${this.#startPoint && svg`<line
|
|
6432
6576
|
part="point"
|
|
6433
6577
|
x1=${this.startCoord.x}
|
|
6434
6578
|
y1=${this.startCoord.y}
|
|
6435
|
-
x2=${this.mouseCoord.x}
|
|
6436
|
-
y2=${this.mouseCoord.y}
|
|
6437
|
-
stroke="
|
|
6579
|
+
x2=${(this.mouseCoord ?? this.startCoord).x}
|
|
6580
|
+
y2=${(this.mouseCoord ?? this.startCoord).y}
|
|
6581
|
+
stroke="currentColor"
|
|
6438
6582
|
stroke-width="3"
|
|
6439
6583
|
/>`}
|
|
6440
6584
|
</svg>
|
|
@@ -6468,26 +6612,91 @@ var QtiGraphicAssociateInteraction = class extends Interaction {
|
|
|
6468
6612
|
this.#hotspots.forEach((hotspot) => {
|
|
6469
6613
|
hotspot.style.left = hotspot.getAttribute("coords").split(",")[0] + "px";
|
|
6470
6614
|
hotspot.style.top = hotspot.getAttribute("coords").split(",")[1] + "px";
|
|
6471
|
-
hotspot.
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
this
|
|
6481
|
-
this._response = [
|
|
6482
|
-
...this._response,
|
|
6483
|
-
`${this.#startPoint.getAttribute("identifier")} ${this.#endPoint.getAttribute("identifier")}`
|
|
6484
|
-
];
|
|
6485
|
-
this.saveResponse(this.response);
|
|
6486
|
-
this.#startPoint = null;
|
|
6487
|
-
this.#endPoint = null;
|
|
6615
|
+
hotspot.tabIndex = 0;
|
|
6616
|
+
hotspot.setAttribute("role", "button");
|
|
6617
|
+
if (!hotspot.hasAttribute("aria-label")) {
|
|
6618
|
+
hotspot.setAttribute("aria-label", hotspot.getAttribute("hotspot-label") || hotspot.getAttribute("identifier"));
|
|
6619
|
+
}
|
|
6620
|
+
hotspot.addEventListener("click", () => this.#pick(hotspot));
|
|
6621
|
+
hotspot.addEventListener("keydown", (event) => {
|
|
6622
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
6623
|
+
event.preventDefault();
|
|
6624
|
+
this.#pick(hotspot);
|
|
6488
6625
|
}
|
|
6489
6626
|
});
|
|
6490
6627
|
});
|
|
6628
|
+
this.addEventListener("keydown", (event) => {
|
|
6629
|
+
if (event.key === "Escape" && this.#startPoint)
|
|
6630
|
+
this.#cancel();
|
|
6631
|
+
});
|
|
6632
|
+
this.#syncHotspotStates();
|
|
6633
|
+
}
|
|
6634
|
+
/** A point clicked or activated: start a line, finish one, or cancel by picking the start again. */
|
|
6635
|
+
#pick(hotspot) {
|
|
6636
|
+
if (this.disabled || this.readonly)
|
|
6637
|
+
return;
|
|
6638
|
+
if (!this.#startPoint) {
|
|
6639
|
+
if (this.#isFull(hotspot))
|
|
6640
|
+
return;
|
|
6641
|
+
this.#startPoint = hotspot;
|
|
6642
|
+
this.startCoord = this.#centre(hotspot);
|
|
6643
|
+
this.mouseCoord = this.startCoord;
|
|
6644
|
+
this.#syncHotspotStates();
|
|
6645
|
+
return;
|
|
6646
|
+
}
|
|
6647
|
+
if (hotspot === this.#startPoint) {
|
|
6648
|
+
this.#cancel();
|
|
6649
|
+
return;
|
|
6650
|
+
}
|
|
6651
|
+
const a = this.#startPoint.getAttribute("identifier");
|
|
6652
|
+
const b = hotspot.getAttribute("identifier");
|
|
6653
|
+
const current = this.#getResponseArray();
|
|
6654
|
+
const exists = current.some((pair) => this.#samePair(pair, a, b));
|
|
6655
|
+
const roomLeft = this.maxAssociations === 0 || current.length < this.maxAssociations;
|
|
6656
|
+
if (!exists && roomLeft && !this.#isFull(hotspot)) {
|
|
6657
|
+
this._response = [...current, `${a} ${b}`];
|
|
6658
|
+
this.saveResponse(this.response);
|
|
6659
|
+
this.#responseChanged(true);
|
|
6660
|
+
}
|
|
6661
|
+
this.#cancel();
|
|
6662
|
+
}
|
|
6663
|
+
#cancel() {
|
|
6664
|
+
this.#startPoint = null;
|
|
6665
|
+
this.#syncHotspotStates();
|
|
6666
|
+
this.requestUpdate();
|
|
6667
|
+
}
|
|
6668
|
+
#removeLine(index) {
|
|
6669
|
+
if (this.disabled || this.readonly)
|
|
6670
|
+
return;
|
|
6671
|
+
this._response = this.#getResponseArray().filter((_, i) => i !== index);
|
|
6672
|
+
this.saveResponse(this.response);
|
|
6673
|
+
this.#responseChanged(true);
|
|
6674
|
+
this.#syncHotspotStates();
|
|
6675
|
+
}
|
|
6676
|
+
/** Pairs are undirected: "A B" is "B A". */
|
|
6677
|
+
#samePair(pair, a, b) {
|
|
6678
|
+
const [x, y] = pair.split(" ");
|
|
6679
|
+
return x === a && y === b || x === b && y === a;
|
|
6680
|
+
}
|
|
6681
|
+
/** Lines this point takes part in, against its `match-max` (0 = no limit). */
|
|
6682
|
+
#isFull(hotspot) {
|
|
6683
|
+
const max = Number(hotspot.getAttribute("match-max") ?? 0);
|
|
6684
|
+
if (!max)
|
|
6685
|
+
return false;
|
|
6686
|
+
const id = hotspot.getAttribute("identifier");
|
|
6687
|
+
return this.#getResponseArray().filter((pair) => pair.split(" ").includes(id)).length >= max;
|
|
6688
|
+
}
|
|
6689
|
+
#centre(hotspot) {
|
|
6690
|
+
const [x, y] = (hotspot.getAttribute("coords") ?? "0,0").split(",").map((n) => parseInt(n));
|
|
6691
|
+
return { x, y };
|
|
6692
|
+
}
|
|
6693
|
+
/** `checked` on the chosen start point, `full` on a point at its `match-max`. */
|
|
6694
|
+
#syncHotspotStates() {
|
|
6695
|
+
for (const hotspot of this.#hotspots) {
|
|
6696
|
+
const states = hotspot.internals?.states;
|
|
6697
|
+
setState(states, "checked", hotspot === this.#startPoint);
|
|
6698
|
+
setState(states, "full", this.#isFull(hotspot));
|
|
6699
|
+
}
|
|
6491
6700
|
}
|
|
6492
6701
|
disconnectedCallback() {
|
|
6493
6702
|
super.disconnectedCallback();
|
|
@@ -6506,6 +6715,12 @@ __decorate19([
|
|
|
6506
6715
|
__decorate19([
|
|
6507
6716
|
state9()
|
|
6508
6717
|
], QtiGraphicAssociateInteraction.prototype, "_response", void 0);
|
|
6718
|
+
__decorate19([
|
|
6719
|
+
property18({ type: Number, attribute: "min-associations" })
|
|
6720
|
+
], QtiGraphicAssociateInteraction.prototype, "minAssociations", void 0);
|
|
6721
|
+
__decorate19([
|
|
6722
|
+
property18({ type: Number, attribute: "max-associations" })
|
|
6723
|
+
], QtiGraphicAssociateInteraction.prototype, "maxAssociations", void 0);
|
|
6509
6724
|
__decorate19([
|
|
6510
6725
|
property18({
|
|
6511
6726
|
attribute: "response",
|
|
@@ -6580,15 +6795,19 @@ var qti_graphic_gap_match_interaction_styles_default = [
|
|
|
6580
6795
|
}
|
|
6581
6796
|
/* [part='drops'] , */
|
|
6582
6797
|
|
|
6583
|
-
[
|
|
6798
|
+
[part~='bank'] {
|
|
6799
|
+
/* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
|
|
6800
|
+
margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
|
|
6801
|
+
in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
|
|
6584
6802
|
display: flex;
|
|
6585
|
-
align-items: flex-start;
|
|
6586
6803
|
flex-wrap: wrap;
|
|
6804
|
+
align-items: flex-start;
|
|
6587
6805
|
flex: 1;
|
|
6588
|
-
|
|
6589
|
-
padding: 0
|
|
6590
|
-
|
|
6591
|
-
|
|
6806
|
+
gap: var(--qti-gap, 0.5rem);
|
|
6807
|
+
padding: 0;
|
|
6808
|
+
margin: 0;
|
|
6809
|
+
border: 0;
|
|
6810
|
+
border-radius: var(--qti-radius-box, 0.2rem);
|
|
6592
6811
|
}
|
|
6593
6812
|
/*
|
|
6594
6813
|
* Fluid, like the hotspot interaction's graphic: an item declares the graphic at the size its
|
|
@@ -6619,8 +6838,8 @@ var __decorate20 = function(decorators, target, key, desc) {
|
|
|
6619
6838
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6620
6839
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6621
6840
|
};
|
|
6622
|
-
var SlottedBase2 = DragDropSlottedMixin(Interaction, "qti-gap-img, qti-gap-text", "qti-associable-hotspot", `slot[part~='
|
|
6623
|
-
var QtiGraphicGapMatchInteraction = class extends DragDropSlottedSortableMixin(SlottedBase2, '[
|
|
6841
|
+
var SlottedBase2 = DragDropSlottedMixin(Interaction, "qti-gap-img, qti-gap-text", "qti-associable-hotspot", `slot[part~='bank']`);
|
|
6842
|
+
var QtiGraphicGapMatchInteraction = class extends DragDropSlottedSortableMixin(SlottedBase2, '[data-draggable="true"]') {
|
|
6624
6843
|
constructor() {
|
|
6625
6844
|
super(...arguments);
|
|
6626
6845
|
this.maxAssociations = 1;
|
|
@@ -6641,7 +6860,7 @@ var QtiGraphicGapMatchInteraction = class extends DragDropSlottedSortableMixin(S
|
|
|
6641
6860
|
const scale = `--qti-graphic-scale: ${this._graphicScale}`;
|
|
6642
6861
|
return html18` <slot name="prompt"></slot>
|
|
6643
6862
|
<slot part="image" style=${scale}></slot>
|
|
6644
|
-
<slot part="drags" name="drags" class="hover-border" style=${scale}></slot>
|
|
6863
|
+
<slot part="bank drags" name="drags" class="hover-border" style=${scale}></slot>
|
|
6645
6864
|
<div role="alert" part="message" id="validation-message"></div>`;
|
|
6646
6865
|
}
|
|
6647
6866
|
shouldReturnToInventoryOnInventoryDrop() {
|
|
@@ -6832,9 +7051,11 @@ var QtiGraphicOrderInteraction = class _QtiGraphicOrderInteraction extends Choic
|
|
|
6832
7051
|
ordered.push(identifier);
|
|
6833
7052
|
}
|
|
6834
7053
|
this.response = ordered;
|
|
6835
|
-
this.validate();
|
|
6836
|
-
this.reportValidity();
|
|
6837
7054
|
this.saveResponse(this.response);
|
|
7055
|
+
void this.updateComplete.then(() => {
|
|
7056
|
+
this.validate();
|
|
7057
|
+
this.reportValidity({ trigger: "change" });
|
|
7058
|
+
});
|
|
6838
7059
|
}
|
|
6839
7060
|
/** The response as the ordered identifier list this interaction always treats it as. */
|
|
6840
7061
|
#orderedResponse() {
|
|
@@ -7385,7 +7606,7 @@ var own = css21`
|
|
|
7385
7606
|
Rendered as a CSS mask so the theme controls its colour via color:.
|
|
7386
7607
|
The span in the template is empty; this CSS provides the visual.
|
|
7387
7608
|
*/
|
|
7388
|
-
[part~='
|
|
7609
|
+
[part~='icon'] {
|
|
7389
7610
|
flex: 0 0 auto;
|
|
7390
7611
|
display: inline-block;
|
|
7391
7612
|
width: 1em;
|
|
@@ -7397,7 +7618,7 @@ var own = css21`
|
|
|
7397
7618
|
transform-origin: center;
|
|
7398
7619
|
}
|
|
7399
7620
|
|
|
7400
|
-
[part~='
|
|
7621
|
+
[part~='open'] {
|
|
7401
7622
|
transform: rotate(180deg);
|
|
7402
7623
|
}
|
|
7403
7624
|
|
|
@@ -7500,7 +7721,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
|
|
|
7500
7721
|
this.minChoices = 0;
|
|
7501
7722
|
this._handleRequiredChange = () => {
|
|
7502
7723
|
this.validate();
|
|
7503
|
-
this.reportValidity();
|
|
7724
|
+
this.reportValidity({ trigger: "change" });
|
|
7504
7725
|
};
|
|
7505
7726
|
this._pendingResponse = void 0;
|
|
7506
7727
|
this.#onTriggerClick = (event) => {
|
|
@@ -7603,7 +7824,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
|
|
|
7603
7824
|
>
|
|
7604
7825
|
<span part="value">${selected?.content}</span>
|
|
7605
7826
|
<span
|
|
7606
|
-
part="${this._dropdownOpen ? "dropdown-icon dropdown-icon-open" : "dropdown-icon"}"
|
|
7827
|
+
part="${this._dropdownOpen ? "icon open dropdown-icon dropdown-icon-open" : "icon dropdown-icon"}"
|
|
7607
7828
|
aria-hidden="true"
|
|
7608
7829
|
></span>
|
|
7609
7830
|
</button>
|
|
@@ -7622,7 +7843,15 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
|
|
|
7622
7843
|
const nothingChosen = prompt?.selected ?? true;
|
|
7623
7844
|
const hidden = promptEmpty && nothingChosen;
|
|
7624
7845
|
const clear = promptEmpty && !nothingChosen;
|
|
7625
|
-
const parts = [
|
|
7846
|
+
const parts = [
|
|
7847
|
+
"option",
|
|
7848
|
+
"prompt",
|
|
7849
|
+
prompt?.selected ? "selected" : "",
|
|
7850
|
+
clear ? "clear" : "",
|
|
7851
|
+
"option-prompt",
|
|
7852
|
+
prompt?.selected ? "option-selected" : "",
|
|
7853
|
+
clear ? "option-clear" : ""
|
|
7854
|
+
].filter(Boolean).join(" ");
|
|
7626
7855
|
return html22`
|
|
7627
7856
|
<div
|
|
7628
7857
|
id="${this._menuId}"
|
|
@@ -7763,7 +7992,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
|
|
|
7763
7992
|
* up mid-animation.)
|
|
7764
7993
|
*/
|
|
7765
7994
|
menuAutoSizeExtraWidth() {
|
|
7766
|
-
const icon = this.renderRoot.querySelector('span[part~="
|
|
7995
|
+
const icon = this.renderRoot.querySelector('span[part~="icon"]');
|
|
7767
7996
|
if (!icon)
|
|
7768
7997
|
return 0;
|
|
7769
7998
|
const trigger = this.renderRoot.querySelector('button[part="trigger"]');
|
|
@@ -7776,13 +8005,14 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
|
|
|
7776
8005
|
const answerDemanded = this.required || this.minChoices >= 1;
|
|
7777
8006
|
const isValid = hasSelection || !answerDemanded;
|
|
7778
8007
|
const validityMessage = this.dataset.minChoicesMessage || "Please select an option.";
|
|
7779
|
-
this.setInteractionValidity(isValid, isValid ? "" : validityMessage, this, { suppressInline: true });
|
|
8008
|
+
this.setInteractionValidity(isValid, isValid ? "" : validityMessage, this, { suppressInline: true, kind: "min" });
|
|
7780
8009
|
return isValid;
|
|
7781
8010
|
}
|
|
7782
|
-
reportValidity() {
|
|
7783
|
-
return super.reportValidity();
|
|
8011
|
+
reportValidity(options) {
|
|
8012
|
+
return super.reportValidity(options);
|
|
7784
8013
|
}
|
|
7785
8014
|
reset() {
|
|
8015
|
+
this.resetValidityReport();
|
|
7786
8016
|
this.#setDropdownOpen(false);
|
|
7787
8017
|
this.options = this.options.map((option, i) => ({ ...option, selected: i === 0 }));
|
|
7788
8018
|
this.#syncSlottedChoices();
|
|
@@ -7804,7 +8034,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
|
|
|
7804
8034
|
this.options = this.options.map((option) => ({ ...option, selected: option.value === value }));
|
|
7805
8035
|
this.#syncSlottedChoices();
|
|
7806
8036
|
this.validate();
|
|
7807
|
-
this.reportValidity();
|
|
8037
|
+
this.reportValidity({ trigger: "change" });
|
|
7808
8038
|
this.saveResponse(value);
|
|
7809
8039
|
this.#setDropdownOpen(false);
|
|
7810
8040
|
}
|
|
@@ -7860,6 +8090,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
|
|
|
7860
8090
|
}
|
|
7861
8091
|
}
|
|
7862
8092
|
async #syncSlottedChoices() {
|
|
8093
|
+
this._internals.setFormValue(this.response);
|
|
7863
8094
|
await this.updateComplete;
|
|
7864
8095
|
const selectedValue = this.options.find((option) => option.selected)?.value ?? "";
|
|
7865
8096
|
const choices = Array.from(this.querySelectorAll("qti-inline-choice"));
|
|
@@ -8088,19 +8319,19 @@ var qti_match_interaction_tabular_styles_default = [
|
|
|
8088
8319
|
outer grid's tracks. This structure is shared with the editor's tabular
|
|
8089
8320
|
template so both can inherit the same theme CSS. No per-choice inline
|
|
8090
8321
|
style writes are needed — auto-flow + subgrid handle placement. */
|
|
8091
|
-
:host(.qti-match-tabular) [part
|
|
8322
|
+
:host(.qti-match-tabular) [part~='columns'] {
|
|
8092
8323
|
grid-column: 2 / -1;
|
|
8093
8324
|
grid-row: 1;
|
|
8094
8325
|
display: grid;
|
|
8095
8326
|
grid-template-columns: subgrid;
|
|
8096
8327
|
}
|
|
8097
|
-
:host(.qti-match-tabular) [part
|
|
8328
|
+
:host(.qti-match-tabular) [part~='rows'] {
|
|
8098
8329
|
grid-column: 1;
|
|
8099
8330
|
grid-row: 2 / -1;
|
|
8100
8331
|
display: grid;
|
|
8101
8332
|
grid-template-rows: subgrid;
|
|
8102
8333
|
}
|
|
8103
|
-
:host(.qti-match-tabular) [part
|
|
8334
|
+
:host(.qti-match-tabular) [part~='cells'] {
|
|
8104
8335
|
grid-column: 2 / -1;
|
|
8105
8336
|
grid-row: 2 / -1;
|
|
8106
8337
|
display: grid;
|
|
@@ -8118,10 +8349,10 @@ var qti_match_interaction_tabular_styles_default = [
|
|
|
8118
8349
|
:host(.qti-match-tabular.qti-header-hidden) [part='grid'] {
|
|
8119
8350
|
grid-template-rows: repeat(var(--qti-match-rows, 1), auto);
|
|
8120
8351
|
}
|
|
8121
|
-
:host(.qti-match-tabular.qti-header-hidden) :is([part='corner'], [part
|
|
8352
|
+
:host(.qti-match-tabular.qti-header-hidden) :is([part='corner'], [part~='columns']) {
|
|
8122
8353
|
display: none;
|
|
8123
8354
|
}
|
|
8124
|
-
:host(.qti-match-tabular.qti-header-hidden) :is([part
|
|
8355
|
+
:host(.qti-match-tabular.qti-header-hidden) :is([part~='rows'], [part~='cells']) {
|
|
8125
8356
|
grid-row: 1 / -1;
|
|
8126
8357
|
}
|
|
8127
8358
|
|
|
@@ -8150,7 +8381,7 @@ var __decorate23 = function(decorators, target, key, desc) {
|
|
|
8150
8381
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8151
8382
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8152
8383
|
};
|
|
8153
|
-
var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice", "qti-simple-match-set:last-of-type > qti-simple-associable-choice", "qti-simple-match-set:first-of-type"), '[
|
|
8384
|
+
var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice", "qti-simple-match-set:last-of-type > qti-simple-associable-choice", "qti-simple-match-set:first-of-type"), '[data-draggable="true"]') {
|
|
8154
8385
|
constructor() {
|
|
8155
8386
|
super(...arguments);
|
|
8156
8387
|
this.autoSizeDropzones = false;
|
|
@@ -8308,9 +8539,11 @@ var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlo
|
|
|
8308
8539
|
style="--qti-match-rows: ${this.sourceChoices.length}; --qti-match-cols: ${this.targetChoices.length};"
|
|
8309
8540
|
>
|
|
8310
8541
|
<div part="corner">${this.dataFirstColumnHeader ?? nothing3}</div>
|
|
8311
|
-
<div part="cols-wrap" role="row"
|
|
8312
|
-
|
|
8313
|
-
|
|
8542
|
+
<div part="columns cols-wrap" role="row">
|
|
8543
|
+
<slot name="match-cols" part="column-header c-header"></slot>
|
|
8544
|
+
</div>
|
|
8545
|
+
<div part="rows rows-wrap"><slot name="match-rows" part="row-header r-header"></slot></div>
|
|
8546
|
+
<div part="cells checkbox-grid">
|
|
8314
8547
|
${this.sourceChoices.map((row, r) => html23`
|
|
8315
8548
|
<div role="row" style="display: contents;">
|
|
8316
8549
|
${this.targetChoices.map((col, c) => {
|
|
@@ -8327,7 +8560,7 @@ var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlo
|
|
|
8327
8560
|
const disable = row.matchMax === 1 ? false : row.matchMax !== 0 && selectedInRowCount >= row.matchMax && !checked;
|
|
8328
8561
|
return html23`
|
|
8329
8562
|
<label
|
|
8330
|
-
part="input-cell"
|
|
8563
|
+
part="cell input-cell"
|
|
8331
8564
|
role="gridcell"
|
|
8332
8565
|
style="grid-row: ${r + 1}; grid-column: ${c + 1}; display: flex; align-items: center; justify-content: center; cursor: pointer;"
|
|
8333
8566
|
>
|
|
@@ -8457,11 +8690,19 @@ var qti_order_interaction_styles_default = [
|
|
|
8457
8690
|
display: block;
|
|
8458
8691
|
}
|
|
8459
8692
|
|
|
8460
|
-
[part
|
|
8693
|
+
[part~='bank'] {
|
|
8694
|
+
/* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
|
|
8695
|
+
margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
|
|
8696
|
+
in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
|
|
8461
8697
|
display: flex;
|
|
8698
|
+
flex-wrap: wrap;
|
|
8462
8699
|
align-items: flex-start;
|
|
8463
8700
|
flex: 1;
|
|
8464
|
-
|
|
8701
|
+
gap: var(--qti-gap, 0.5rem);
|
|
8702
|
+
padding: 0;
|
|
8703
|
+
margin: 0;
|
|
8704
|
+
border: 0;
|
|
8705
|
+
border-radius: var(--qti-radius-box, 0.2rem);
|
|
8465
8706
|
}
|
|
8466
8707
|
|
|
8467
8708
|
[part='drops'] {
|
|
@@ -8488,8 +8729,8 @@ var qti_order_interaction_styles_default = [
|
|
|
8488
8729
|
gap: 0.5rem;
|
|
8489
8730
|
}
|
|
8490
8731
|
|
|
8491
|
-
:host([orientation='horizontal']) [part
|
|
8492
|
-
:host(.qti-orientation-horizontal) [part
|
|
8732
|
+
:host([orientation='horizontal']) [part~='bank'],
|
|
8733
|
+
:host(.qti-orientation-horizontal) [part~='bank'] {
|
|
8493
8734
|
flex-direction: row;
|
|
8494
8735
|
}
|
|
8495
8736
|
/*
|
|
@@ -8502,8 +8743,8 @@ var qti_order_interaction_styles_default = [
|
|
|
8502
8743
|
* wrapped and the '.qti-orientation-horizontal' class did not. The theme's rule is gone and so
|
|
8503
8744
|
* is this one; both spellings now wrap, which is what the attribute already did.
|
|
8504
8745
|
*/
|
|
8505
|
-
:host([orientation='vertical']) [part
|
|
8506
|
-
:host(.qti-orientation-vertical) [part
|
|
8746
|
+
:host([orientation='vertical']) [part~='bank'],
|
|
8747
|
+
:host(.qti-orientation-vertical) [part~='bank'] {
|
|
8507
8748
|
flex-direction: column;
|
|
8508
8749
|
}
|
|
8509
8750
|
:host([orientation='vertical']) [part='drops'],
|
|
@@ -8555,7 +8796,7 @@ var qti_order_interaction_styles_default = [
|
|
|
8555
8796
|
* never done anything; it is left in the theme rather than deleted here, since removing it is a
|
|
8556
8797
|
* decision about how a long label should behave, not a relocation.
|
|
8557
8798
|
*/
|
|
8558
|
-
[part~='
|
|
8799
|
+
[part~='chip'] {
|
|
8559
8800
|
display: flex;
|
|
8560
8801
|
align-items: center;
|
|
8561
8802
|
overflow: visible;
|
|
@@ -8672,7 +8913,7 @@ var __decorate24 = function(decorators, target, key, desc) {
|
|
|
8672
8913
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8673
8914
|
};
|
|
8674
8915
|
var SlottedBase3 = DragDropSlottedMixin(Interaction, `qti-simple-choice`, `[part~='drop']`, `slot[part~='drags']`);
|
|
8675
|
-
var QtiOrderInteraction = class extends DragDropSlottedSortableMixin(SlottedBase3, '[
|
|
8916
|
+
var QtiOrderInteraction = class extends DragDropSlottedSortableMixin(SlottedBase3, '[data-draggable="true"]') {
|
|
8676
8917
|
constructor() {
|
|
8677
8918
|
super(...arguments);
|
|
8678
8919
|
this.nrChoices = 0;
|
|
@@ -8687,7 +8928,7 @@ var QtiOrderInteraction = class extends DragDropSlottedSortableMixin(SlottedBase
|
|
|
8687
8928
|
}
|
|
8688
8929
|
return html25` <slot name="prompt"> </slot>
|
|
8689
8930
|
<div part="container">
|
|
8690
|
-
<slot part="drags"> </slot>
|
|
8931
|
+
<slot part="bank drags"> </slot>
|
|
8691
8932
|
<div part="drops">
|
|
8692
8933
|
${[...Array(this.nrChoices)].map((_, i) => {
|
|
8693
8934
|
const identifier = `droplist${i}`;
|
|
@@ -9004,18 +9245,18 @@ var QtiPortableCustomInteraction = class extends Interaction {
|
|
|
9004
9245
|
this.#pciCustomValidityMessage = pciCustomValidity;
|
|
9005
9246
|
}
|
|
9006
9247
|
const stateRaw = data?.params?.state;
|
|
9007
|
-
let
|
|
9248
|
+
let state17;
|
|
9008
9249
|
if (stateRaw === void 0) {
|
|
9009
|
-
|
|
9250
|
+
state17 = void 0;
|
|
9010
9251
|
} else if (stateRaw === null) {
|
|
9011
|
-
|
|
9252
|
+
state17 = null;
|
|
9012
9253
|
} else if (typeof stateRaw === "string") {
|
|
9013
|
-
|
|
9254
|
+
state17 = stateRaw;
|
|
9014
9255
|
} else {
|
|
9015
9256
|
try {
|
|
9016
|
-
|
|
9257
|
+
state17 = `__qti_json__::${JSON.stringify(stateRaw)}`;
|
|
9017
9258
|
} catch {
|
|
9018
|
-
|
|
9259
|
+
state17 = null;
|
|
9019
9260
|
}
|
|
9020
9261
|
}
|
|
9021
9262
|
if (converted === null) {
|
|
@@ -9023,13 +9264,13 @@ var QtiPortableCustomInteraction = class extends Interaction {
|
|
|
9023
9264
|
const emptyResponse = cardinality === "record" ? null : cardinality === "single" ? "" : [];
|
|
9024
9265
|
this.response = emptyResponse;
|
|
9025
9266
|
this.validate();
|
|
9026
|
-
this.saveResponse(emptyResponse,
|
|
9267
|
+
this.saveResponse(emptyResponse, state17);
|
|
9027
9268
|
break;
|
|
9028
9269
|
}
|
|
9029
9270
|
const response = converted;
|
|
9030
9271
|
this.response = response;
|
|
9031
9272
|
this.validate();
|
|
9032
|
-
this.saveResponse(response,
|
|
9273
|
+
this.saveResponse(response, state17);
|
|
9033
9274
|
break;
|
|
9034
9275
|
}
|
|
9035
9276
|
case "error":
|
|
@@ -10580,101 +10821,427 @@ __decorate25([
|
|
|
10580
10821
|
], QtiPortableCustomInteraction.prototype, "response", void 0);
|
|
10581
10822
|
|
|
10582
10823
|
// ../interactions/position-object-interaction/dist/qti-position-object-interaction.js
|
|
10583
|
-
import {
|
|
10824
|
+
import { html as html27, nothing as nothing4 } from "lit";
|
|
10825
|
+
import { property as property24, state as state15 } from "lit/decorators.js";
|
|
10826
|
+
import { repeat as repeat7 } from "lit/directives/repeat.js";
|
|
10827
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
10584
10828
|
|
|
10585
10829
|
// ../interactions/position-object-interaction/dist/qti-position-object-interaction.styles.js
|
|
10586
10830
|
import { css as css28 } from "lit";
|
|
10587
10831
|
var qti_position_object_interaction_styles_default = [
|
|
10588
10832
|
boxSizing,
|
|
10833
|
+
validationMessage,
|
|
10589
10834
|
css28`
|
|
10835
|
+
/* Not positioned on purpose: the placed copies are absolutely positioned against the stage
|
|
10836
|
+
(qti-position-object-stage), so they land on its image wherever this tray sits. */
|
|
10590
10837
|
:host {
|
|
10591
|
-
display: block;
|
|
10838
|
+
display: inline-block;
|
|
10839
|
+
vertical-align: top;
|
|
10840
|
+
margin-block-start: var(--qti-gap, 0.5rem);
|
|
10841
|
+
margin-inline-end: var(--qti-gap, 0.5rem);
|
|
10842
|
+
}
|
|
10843
|
+
|
|
10844
|
+
[part~='object'] {
|
|
10845
|
+
display: inline-flex;
|
|
10846
|
+
padding: var(--qti-size-field, 0.125rem);
|
|
10847
|
+
cursor: grab;
|
|
10848
|
+
touch-action: none;
|
|
10849
|
+
user-select: none;
|
|
10850
|
+
}
|
|
10851
|
+
[part~='object'][aria-disabled='true'] {
|
|
10852
|
+
cursor: default;
|
|
10592
10853
|
}
|
|
10593
10854
|
::slotted(img) {
|
|
10855
|
+
display: block;
|
|
10856
|
+
pointer-events: none;
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
[part~='point'] {
|
|
10594
10860
|
position: absolute;
|
|
10595
|
-
cursor:
|
|
10861
|
+
cursor: grab;
|
|
10862
|
+
touch-action: none;
|
|
10596
10863
|
user-select: none;
|
|
10597
|
-
|
|
10598
|
-
|
|
10864
|
+
z-index: 1;
|
|
10865
|
+
}
|
|
10866
|
+
[part~='point'][data-ghost] {
|
|
10867
|
+
pointer-events: none;
|
|
10599
10868
|
}
|
|
10600
10869
|
`
|
|
10601
10870
|
];
|
|
10602
10871
|
|
|
10603
10872
|
// ../interactions/position-object-interaction/dist/qti-position-object-interaction.js
|
|
10604
|
-
var
|
|
10873
|
+
var __decorate26 = function(decorators, target, key, desc) {
|
|
10874
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10875
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10876
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10877
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10878
|
+
};
|
|
10879
|
+
var CLICK_SLOP = 4;
|
|
10880
|
+
var QtiPositionObjectInteraction = class extends Interaction {
|
|
10881
|
+
constructor() {
|
|
10882
|
+
super(...arguments);
|
|
10883
|
+
this.maxChoices = 1;
|
|
10884
|
+
this.minChoices = 0;
|
|
10885
|
+
this.centerPoint = null;
|
|
10886
|
+
this.response = null;
|
|
10887
|
+
this._layout = 0;
|
|
10888
|
+
this._drag = null;
|
|
10889
|
+
this._armed = false;
|
|
10890
|
+
this.#stageImg = null;
|
|
10891
|
+
this.#resize = new ResizeObserver(() => this._layout++);
|
|
10892
|
+
this._handleResponseChange = () => {
|
|
10893
|
+
this._internals.setFormValue(serializeResponseAttribute(this.response) || null);
|
|
10894
|
+
this.validate();
|
|
10895
|
+
setState(this._internals.states, "used", this.#atMax());
|
|
10896
|
+
};
|
|
10897
|
+
this.#onMove = (event) => {
|
|
10898
|
+
if (!this._drag)
|
|
10899
|
+
return;
|
|
10900
|
+
const client = { x: event.clientX, y: event.clientY };
|
|
10901
|
+
const moved = this._drag.moved || Math.hypot(client.x - this._drag.start.x, client.y - this._drag.start.y) > CLICK_SLOP;
|
|
10902
|
+
this._drag = { ...this._drag, client, moved };
|
|
10903
|
+
};
|
|
10904
|
+
this.#onUp = (event) => {
|
|
10905
|
+
window.removeEventListener("pointermove", this.#onMove);
|
|
10906
|
+
const drag = this._drag;
|
|
10907
|
+
this._drag = null;
|
|
10908
|
+
if (!drag)
|
|
10909
|
+
return;
|
|
10910
|
+
if (!drag.moved) {
|
|
10911
|
+
if (drag.index === -1)
|
|
10912
|
+
this._armed = !this._armed;
|
|
10913
|
+
return;
|
|
10914
|
+
}
|
|
10915
|
+
const target = this.#toStage({ x: event.clientX, y: event.clientY });
|
|
10916
|
+
const points = this.#points();
|
|
10917
|
+
if (drag.index === -1) {
|
|
10918
|
+
if (target)
|
|
10919
|
+
this.#place(target);
|
|
10920
|
+
} else if (target) {
|
|
10921
|
+
points[drag.index] = target;
|
|
10922
|
+
this.#write(points);
|
|
10923
|
+
} else {
|
|
10924
|
+
this.#write(points.filter((_, i) => i !== drag.index));
|
|
10925
|
+
}
|
|
10926
|
+
};
|
|
10927
|
+
this.#onStageClick = (event) => {
|
|
10928
|
+
if (!this._armed || this.#locked)
|
|
10929
|
+
return;
|
|
10930
|
+
const target = this.#toStage({ x: event.clientX, y: event.clientY });
|
|
10931
|
+
if (!target)
|
|
10932
|
+
return;
|
|
10933
|
+
this._armed = false;
|
|
10934
|
+
this.#place(target);
|
|
10935
|
+
};
|
|
10936
|
+
}
|
|
10605
10937
|
static {
|
|
10606
10938
|
this.styles = qti_position_object_interaction_styles_default;
|
|
10607
10939
|
}
|
|
10940
|
+
#stageImg;
|
|
10941
|
+
#resize;
|
|
10942
|
+
#points() {
|
|
10943
|
+
return (this.response ?? []).map((entry) => {
|
|
10944
|
+
const [x, y] = entry.split(" ").map(Number);
|
|
10945
|
+
return { x, y };
|
|
10946
|
+
});
|
|
10947
|
+
}
|
|
10948
|
+
#write(points) {
|
|
10949
|
+
this.response = points.map((p) => `${Math.round(p.x)} ${Math.round(p.y)}`);
|
|
10950
|
+
this.saveResponse(this.response);
|
|
10951
|
+
this.validate();
|
|
10952
|
+
this.reportValidity({ trigger: "change" });
|
|
10953
|
+
}
|
|
10954
|
+
#atMax() {
|
|
10955
|
+
return this.maxChoices > 0 && (this.response?.length ?? 0) >= this.maxChoices;
|
|
10956
|
+
}
|
|
10957
|
+
validate() {
|
|
10958
|
+
const count = this.response?.length ?? 0;
|
|
10959
|
+
const exceedsMax = this.maxChoices > 0 && count > this.maxChoices;
|
|
10960
|
+
const belowMin = count < this.minChoices;
|
|
10961
|
+
let kind = "other";
|
|
10962
|
+
let message = "";
|
|
10963
|
+
if (exceedsMax) {
|
|
10964
|
+
kind = "max";
|
|
10965
|
+
message = this.dataset.maxSelectionsMessage || `Please place no more than ${this.maxChoices} ${this.maxChoices === 1 ? "position" : "positions"}.`;
|
|
10966
|
+
} else if (belowMin) {
|
|
10967
|
+
kind = "min";
|
|
10968
|
+
message = this.dataset.minSelectionsMessage || `Please place at least ${this.minChoices} ${this.minChoices === 1 ? "position" : "positions"}.`;
|
|
10969
|
+
}
|
|
10970
|
+
const isValid = !exceedsMax && !belowMin;
|
|
10971
|
+
this.setInteractionValidity(isValid, message, this, { suppressInline: true, kind });
|
|
10972
|
+
return isValid;
|
|
10973
|
+
}
|
|
10974
|
+
reportValidity(options) {
|
|
10975
|
+
return super.reportValidity(options);
|
|
10976
|
+
}
|
|
10977
|
+
reset() {
|
|
10978
|
+
this.resetValidityReport();
|
|
10979
|
+
this._armed = false;
|
|
10980
|
+
this.response = [];
|
|
10981
|
+
this._internals.setFormValue(null);
|
|
10982
|
+
}
|
|
10983
|
+
// ── Geometry ──────────────────────────────────────────────────────────────────────────────────
|
|
10984
|
+
get #stage() {
|
|
10985
|
+
return this.closest("qti-position-object-stage");
|
|
10986
|
+
}
|
|
10987
|
+
/** The stage image's own size: its `width`/`height` attributes, else its natural size. */
|
|
10988
|
+
#stageSize() {
|
|
10989
|
+
const img = this.#stageImg;
|
|
10990
|
+
if (!img)
|
|
10991
|
+
return { width: 1, height: 1 };
|
|
10992
|
+
return {
|
|
10993
|
+
width: parseFloat(img.getAttribute("width") ?? "") || img.naturalWidth || img.clientWidth || 1,
|
|
10994
|
+
height: parseFloat(img.getAttribute("height") ?? "") || img.naturalHeight || img.clientHeight || 1
|
|
10995
|
+
};
|
|
10996
|
+
}
|
|
10997
|
+
/** Stage-image units per CSS pixel. */
|
|
10998
|
+
#scale() {
|
|
10999
|
+
const rect = this.#stageImg?.getBoundingClientRect();
|
|
11000
|
+
if (!rect || rect.width === 0)
|
|
11001
|
+
return 1;
|
|
11002
|
+
return this.#stageSize().width / rect.width;
|
|
11003
|
+
}
|
|
11004
|
+
/** The object's own size and centre point, in the object's pixels. */
|
|
11005
|
+
#object() {
|
|
11006
|
+
const img = this.querySelector("img");
|
|
11007
|
+
const width = parseFloat(img?.getAttribute("width") ?? "") || img?.naturalWidth || 30;
|
|
11008
|
+
const height = parseFloat(img?.getAttribute("height") ?? "") || img?.naturalHeight || 30;
|
|
11009
|
+
const [cx, cy] = (this.centerPoint ?? "").split(/[\s,]+/).map(Number);
|
|
11010
|
+
return {
|
|
11011
|
+
width,
|
|
11012
|
+
height,
|
|
11013
|
+
centre: Number.isFinite(cx) && Number.isFinite(cy) ? { x: cx, y: cy } : { x: width / 2, y: height / 2 }
|
|
11014
|
+
};
|
|
11015
|
+
}
|
|
11016
|
+
/** A client position as a stage point, or null when it is off the stage image. */
|
|
11017
|
+
#toStage(client) {
|
|
11018
|
+
const rect = this.#stageImg?.getBoundingClientRect();
|
|
11019
|
+
if (!rect)
|
|
11020
|
+
return null;
|
|
11021
|
+
if (client.x < rect.left || client.x > rect.right || client.y < rect.top || client.y > rect.bottom)
|
|
11022
|
+
return null;
|
|
11023
|
+
const scale = this.#scale();
|
|
11024
|
+
return { x: (client.x - rect.left) * scale, y: (client.y - rect.top) * scale };
|
|
11025
|
+
}
|
|
11026
|
+
/** Where a copy whose centre point sits at a stage point is drawn, relative to the stage. */
|
|
11027
|
+
#styleFor(point) {
|
|
11028
|
+
const stageRect = this.#stage?.getBoundingClientRect();
|
|
11029
|
+
const imgRect = this.#stageImg?.getBoundingClientRect();
|
|
11030
|
+
if (!stageRect || !imgRect)
|
|
11031
|
+
return { display: "none" };
|
|
11032
|
+
const scale = this.#scale();
|
|
11033
|
+
const object = this.#object();
|
|
11034
|
+
return {
|
|
11035
|
+
left: `${imgRect.left - stageRect.left + point.x / scale - object.centre.x / scale}px`,
|
|
11036
|
+
top: `${imgRect.top - stageRect.top + point.y / scale - object.centre.y / scale}px`,
|
|
11037
|
+
width: `${object.width / scale}px`,
|
|
11038
|
+
height: `${object.height / scale}px`
|
|
11039
|
+
};
|
|
11040
|
+
}
|
|
11041
|
+
// ── Input ─────────────────────────────────────────────────────────────────────────────────────
|
|
11042
|
+
get #locked() {
|
|
11043
|
+
return this.disabled || this.readonly;
|
|
11044
|
+
}
|
|
11045
|
+
#place(point) {
|
|
11046
|
+
if (this.#atMax())
|
|
11047
|
+
return;
|
|
11048
|
+
this.#write([...this.#points(), point]);
|
|
11049
|
+
}
|
|
11050
|
+
#startDrag(event, index) {
|
|
11051
|
+
if (this.#locked || event.button !== 0)
|
|
11052
|
+
return;
|
|
11053
|
+
if (index === -1 && this.#atMax())
|
|
11054
|
+
return;
|
|
11055
|
+
event.preventDefault();
|
|
11056
|
+
const client = { x: event.clientX, y: event.clientY };
|
|
11057
|
+
this._drag = { index, client, start: client, moved: false };
|
|
11058
|
+
window.addEventListener("pointermove", this.#onMove);
|
|
11059
|
+
window.addEventListener("pointerup", this.#onUp, { once: true });
|
|
11060
|
+
}
|
|
11061
|
+
#onMove;
|
|
11062
|
+
#onUp;
|
|
11063
|
+
#onStageClick;
|
|
11064
|
+
#onObjectKey(event) {
|
|
11065
|
+
if (this.#locked)
|
|
11066
|
+
return;
|
|
11067
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
11068
|
+
event.preventDefault();
|
|
11069
|
+
if (this.#atMax())
|
|
11070
|
+
return;
|
|
11071
|
+
const { width, height } = this.#stageSize();
|
|
11072
|
+
this.#place({ x: width / 2, y: height / 2 });
|
|
11073
|
+
void this.updateComplete.then(() => {
|
|
11074
|
+
const copies = this.shadowRoot?.querySelectorAll('[part~="point"]');
|
|
11075
|
+
copies?.[copies.length - 1]?.focus();
|
|
11076
|
+
});
|
|
11077
|
+
} else if (event.key === "Escape") {
|
|
11078
|
+
this._armed = false;
|
|
11079
|
+
}
|
|
11080
|
+
}
|
|
11081
|
+
#onPointKey(event, index) {
|
|
11082
|
+
if (this.#locked)
|
|
11083
|
+
return;
|
|
11084
|
+
const step = event.shiftKey ? 10 : 1;
|
|
11085
|
+
const moves = {
|
|
11086
|
+
ArrowLeft: { x: -step, y: 0 },
|
|
11087
|
+
ArrowRight: { x: step, y: 0 },
|
|
11088
|
+
ArrowUp: { x: 0, y: -step },
|
|
11089
|
+
ArrowDown: { x: 0, y: step }
|
|
11090
|
+
};
|
|
11091
|
+
const points = this.#points();
|
|
11092
|
+
if (moves[event.key]) {
|
|
11093
|
+
event.preventDefault();
|
|
11094
|
+
const { width, height } = this.#stageSize();
|
|
11095
|
+
const p = points[index];
|
|
11096
|
+
points[index] = {
|
|
11097
|
+
x: Math.min(width, Math.max(0, p.x + moves[event.key].x)),
|
|
11098
|
+
y: Math.min(height, Math.max(0, p.y + moves[event.key].y))
|
|
11099
|
+
};
|
|
11100
|
+
this.#write(points);
|
|
11101
|
+
void this.updateComplete.then(() => this.shadowRoot?.querySelectorAll('[part~="point"]')[index]?.focus());
|
|
11102
|
+
} else if (event.key === "Delete" || event.key === "Backspace") {
|
|
11103
|
+
event.preventDefault();
|
|
11104
|
+
this.#write(points.filter((_, i) => i !== index));
|
|
11105
|
+
void this.updateComplete.then(() => this.shadowRoot?.querySelector('[part~="object"]')?.focus());
|
|
11106
|
+
}
|
|
11107
|
+
}
|
|
11108
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────────────────────────
|
|
11109
|
+
connectedCallback() {
|
|
11110
|
+
super.connectedCallback();
|
|
11111
|
+
this.#stageImg = this.#stage?.querySelector(":scope > img, :scope > picture img") ?? null;
|
|
11112
|
+
if (this.#stageImg) {
|
|
11113
|
+
this.#resize.observe(this.#stageImg);
|
|
11114
|
+
this.#stageImg.addEventListener("load", () => this._layout++);
|
|
11115
|
+
this.#stageImg.addEventListener("click", this.#onStageClick);
|
|
11116
|
+
}
|
|
11117
|
+
}
|
|
11118
|
+
disconnectedCallback() {
|
|
11119
|
+
super.disconnectedCallback();
|
|
11120
|
+
this.#resize.disconnect();
|
|
11121
|
+
this.#stageImg?.removeEventListener("click", this.#onStageClick);
|
|
11122
|
+
window.removeEventListener("pointermove", this.#onMove);
|
|
11123
|
+
}
|
|
11124
|
+
// ── Render ────────────────────────────────────────────────────────────────────────────────────
|
|
10608
11125
|
render() {
|
|
10609
|
-
|
|
11126
|
+
void this._layout;
|
|
11127
|
+
const src = this.querySelector("img")?.currentSrc || this.querySelector("img")?.src || "";
|
|
11128
|
+
const alt = this.querySelector("img")?.getAttribute("alt") || "object";
|
|
11129
|
+
const used = this.#atMax();
|
|
11130
|
+
const objectPart = ["object", this._armed ? "selected" : "", used ? "used" : ""].filter(Boolean).join(" ");
|
|
11131
|
+
const points = this.#points();
|
|
11132
|
+
const drag = this._drag;
|
|
11133
|
+
const dragPoint = drag && drag.moved && this.#stageImg ? (() => {
|
|
11134
|
+
const rect = this.#stageImg.getBoundingClientRect();
|
|
11135
|
+
const scale = this.#scale();
|
|
11136
|
+
return { x: (drag.client.x - rect.left) * scale, y: (drag.client.y - rect.top) * scale };
|
|
11137
|
+
})() : null;
|
|
11138
|
+
return html27`
|
|
11139
|
+
<div
|
|
11140
|
+
part=${objectPart}
|
|
11141
|
+
role="button"
|
|
11142
|
+
tabindex=${this.#locked || used ? -1 : 0}
|
|
11143
|
+
aria-disabled=${this.#locked || used ? "true" : "false"}
|
|
11144
|
+
aria-pressed=${this._armed ? "true" : "false"}
|
|
11145
|
+
aria-label=${`Place ${alt}`}
|
|
11146
|
+
@pointerdown=${(e) => this.#startDrag(e, -1)}
|
|
11147
|
+
@keydown=${(e) => this.#onObjectKey(e)}
|
|
11148
|
+
>
|
|
11149
|
+
<slot></slot>
|
|
11150
|
+
</div>
|
|
11151
|
+
${repeat7(points, (_, i) => i, (point, index) => {
|
|
11152
|
+
const shown = drag && drag.index === index && dragPoint ? dragPoint : point;
|
|
11153
|
+
return html27`<img
|
|
11154
|
+
part="point"
|
|
11155
|
+
src=${src}
|
|
11156
|
+
alt=${`${alt} at ${Math.round(point.x)}, ${Math.round(point.y)}`}
|
|
11157
|
+
role="button"
|
|
11158
|
+
tabindex=${this.#locked ? -1 : 0}
|
|
11159
|
+
draggable="false"
|
|
11160
|
+
style=${styleMap(this.#styleFor(shown))}
|
|
11161
|
+
@pointerdown=${(e) => this.#startDrag(e, index)}
|
|
11162
|
+
@keydown=${(e) => this.#onPointKey(e, index)}
|
|
11163
|
+
/>`;
|
|
11164
|
+
})}
|
|
11165
|
+
${drag && drag.index === -1 && dragPoint ? html27`<img part="point" data-ghost src=${src} alt="" style=${styleMap(this.#styleFor(dragPoint))} />` : nothing4}
|
|
11166
|
+
<div part="message" role="alert" id="validation-message" style="display:none;"></div>
|
|
11167
|
+
`;
|
|
10610
11168
|
}
|
|
10611
11169
|
};
|
|
11170
|
+
__decorate26([
|
|
11171
|
+
property24({ type: Number, attribute: "max-choices" })
|
|
11172
|
+
], QtiPositionObjectInteraction.prototype, "maxChoices", void 0);
|
|
11173
|
+
__decorate26([
|
|
11174
|
+
property24({ type: Number, attribute: "min-choices" })
|
|
11175
|
+
], QtiPositionObjectInteraction.prototype, "minChoices", void 0);
|
|
11176
|
+
__decorate26([
|
|
11177
|
+
property24({ type: String, attribute: "center-point" })
|
|
11178
|
+
], QtiPositionObjectInteraction.prototype, "centerPoint", void 0);
|
|
11179
|
+
__decorate26([
|
|
11180
|
+
property24({
|
|
11181
|
+
attribute: "response",
|
|
11182
|
+
reflect: false,
|
|
11183
|
+
converter: {
|
|
11184
|
+
fromAttribute: (value) => {
|
|
11185
|
+
const parsed = parseResponseAttribute(value);
|
|
11186
|
+
if (parsed === null)
|
|
11187
|
+
return null;
|
|
11188
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
11189
|
+
},
|
|
11190
|
+
toAttribute: (value) => serializeResponseAttribute(value)
|
|
11191
|
+
}
|
|
11192
|
+
})
|
|
11193
|
+
], QtiPositionObjectInteraction.prototype, "response", void 0);
|
|
11194
|
+
__decorate26([
|
|
11195
|
+
state15()
|
|
11196
|
+
], QtiPositionObjectInteraction.prototype, "_layout", void 0);
|
|
11197
|
+
__decorate26([
|
|
11198
|
+
state15()
|
|
11199
|
+
], QtiPositionObjectInteraction.prototype, "_drag", void 0);
|
|
11200
|
+
__decorate26([
|
|
11201
|
+
state15()
|
|
11202
|
+
], QtiPositionObjectInteraction.prototype, "_armed", void 0);
|
|
11203
|
+
__decorate26([
|
|
11204
|
+
watch("response")
|
|
11205
|
+
], QtiPositionObjectInteraction.prototype, "_handleResponseChange", void 0);
|
|
10612
11206
|
|
|
10613
11207
|
// ../interactions/position-object-interaction/dist/qti-position-object-stage.js
|
|
10614
|
-
import { LitElement as
|
|
11208
|
+
import { LitElement as LitElement12, html as html28 } from "lit";
|
|
10615
11209
|
|
|
10616
11210
|
// ../interactions/position-object-interaction/dist/qti-position-object-stage.styles.js
|
|
10617
11211
|
import { css as css29 } from "lit";
|
|
10618
11212
|
var qti_position_object_stage_styles_default = [
|
|
10619
11213
|
boxSizing,
|
|
10620
11214
|
css29`
|
|
11215
|
+
/* The containing block of every placed copy. */
|
|
10621
11216
|
:host {
|
|
10622
11217
|
display: inline-block;
|
|
10623
11218
|
position: relative;
|
|
10624
11219
|
}
|
|
11220
|
+
::slotted(img),
|
|
11221
|
+
::slotted(picture) {
|
|
11222
|
+
display: block;
|
|
11223
|
+
max-width: 100%;
|
|
11224
|
+
height: auto;
|
|
11225
|
+
user-select: none;
|
|
11226
|
+
}
|
|
10625
11227
|
`
|
|
10626
11228
|
];
|
|
10627
11229
|
|
|
10628
11230
|
// ../interactions/position-object-interaction/dist/qti-position-object-stage.js
|
|
10629
|
-
var QtiPositionObjectStage = class extends
|
|
11231
|
+
var QtiPositionObjectStage = class extends LitElement12 {
|
|
10630
11232
|
static {
|
|
10631
11233
|
this.styles = qti_position_object_stage_styles_default;
|
|
10632
11234
|
}
|
|
10633
11235
|
render() {
|
|
10634
11236
|
return html28`<slot></slot>`;
|
|
10635
11237
|
}
|
|
10636
|
-
constructor() {
|
|
10637
|
-
super();
|
|
10638
|
-
this.removeMoveListener = this.removeMoveListener.bind(this);
|
|
10639
|
-
this.dragElementHandler = this.dragElementHandler.bind(this);
|
|
10640
|
-
}
|
|
10641
|
-
// Define a function to handle the mousemove event on the draggable element
|
|
10642
|
-
dragElementHandler(event) {
|
|
10643
|
-
event.preventDefault();
|
|
10644
|
-
const deltaX = event.clientX - this.startX;
|
|
10645
|
-
const deltaY = event.clientY - this.startY;
|
|
10646
|
-
this.dragElement.style.left = this.dragElement.offsetLeft + deltaX + "px";
|
|
10647
|
-
this.dragElement.style.top = this.dragElement.offsetTop + deltaY + "px";
|
|
10648
|
-
this.startX = event.clientX;
|
|
10649
|
-
this.startY = event.clientY;
|
|
10650
|
-
}
|
|
10651
|
-
firstUpdated(a) {
|
|
10652
|
-
super.firstUpdated(a);
|
|
10653
|
-
this.dragElement = this.querySelector("qti-position-object-interaction>img");
|
|
10654
|
-
this.startX = 0;
|
|
10655
|
-
this.startY = 0;
|
|
10656
|
-
this.dragElement.addEventListener("mousedown", (event) => {
|
|
10657
|
-
this.startX = event.clientX;
|
|
10658
|
-
this.startY = event.clientY;
|
|
10659
|
-
document.addEventListener("mousemove", this.dragElementHandler, true);
|
|
10660
|
-
});
|
|
10661
|
-
document.addEventListener("mouseup", this.removeMoveListener);
|
|
10662
|
-
}
|
|
10663
|
-
removeMoveListener() {
|
|
10664
|
-
document.removeEventListener("mousemove", this.dragElementHandler, true);
|
|
10665
|
-
}
|
|
10666
|
-
disconnectedCallback() {
|
|
10667
|
-
super.disconnectedCallback();
|
|
10668
|
-
document.removeEventListener("mousemove", this.dragElementHandler);
|
|
10669
|
-
document.removeEventListener("mouseup", this.removeMoveListener);
|
|
10670
|
-
}
|
|
10671
11238
|
};
|
|
10672
11239
|
|
|
10673
11240
|
// ../interactions/select-point-interaction/dist/qti-select-point-interaction.js
|
|
10674
|
-
import { html as html29, nothing as
|
|
10675
|
-
import { property as
|
|
10676
|
-
import { repeat as
|
|
10677
|
-
import { styleMap } from "lit/directives/style-map.js";
|
|
11241
|
+
import { html as html29, nothing as nothing5 } from "lit";
|
|
11242
|
+
import { property as property25, state as state16 } from "lit/decorators.js";
|
|
11243
|
+
import { repeat as repeat8 } from "lit/directives/repeat.js";
|
|
11244
|
+
import { styleMap as styleMap2 } from "lit/directives/style-map.js";
|
|
10678
11245
|
|
|
10679
11246
|
// ../interactions/select-point-interaction/dist/qti-select-point-interaction.styles.js
|
|
10680
11247
|
import { css as css30 } from "lit";
|
|
@@ -10685,12 +11252,15 @@ var qti_select_point_interaction_styles_default = [
|
|
|
10685
11252
|
display: block;
|
|
10686
11253
|
--qti-select-point-marker-size: 1.5rem;
|
|
10687
11254
|
/* Where the marker's shape points: -100% stands it on the point by its bottom (a pin's tip),
|
|
10688
|
-
-50% centres it (a ring, a star). A theme that changes the shape sets --
|
|
10689
|
-
--qti-select-point-marker-anchor: var(--cito-marker-anchor, -100%);
|
|
10690
|
-
/* The marker's shape: a pin by default, or the theme's --
|
|
11255
|
+
-50% centres it (a ring, a star). A theme that changes the shape sets --qc-marker-anchor. */
|
|
11256
|
+
--qti-select-point-marker-anchor: var(--qc-marker-anchor, var(--cito-marker-anchor, -100%));
|
|
11257
|
+
/* The marker's shape: a pin by default, or the theme's --qc-icon-marker (a mask). */
|
|
10691
11258
|
--qti-select-point-icon: var(
|
|
10692
|
-
--
|
|
10693
|
-
|
|
11259
|
+
--qc-icon-marker,
|
|
11260
|
+
var(
|
|
11261
|
+
--cito-icon-marker,
|
|
11262
|
+
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath d='M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z'/%3E%3C/svg%3E")
|
|
11263
|
+
)
|
|
10694
11264
|
);
|
|
10695
11265
|
}
|
|
10696
11266
|
point-container {
|
|
@@ -10745,7 +11315,7 @@ var qti_select_point_interaction_styles_default = [
|
|
|
10745
11315
|
];
|
|
10746
11316
|
|
|
10747
11317
|
// ../interactions/select-point-interaction/dist/qti-select-point-interaction.js
|
|
10748
|
-
var
|
|
11318
|
+
var __decorate27 = function(decorators, target, key, desc) {
|
|
10749
11319
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10750
11320
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10751
11321
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -10759,6 +11329,10 @@ var QtiSelectPointInteraction = class extends Interaction {
|
|
|
10759
11329
|
this.response = null;
|
|
10760
11330
|
this.areaMappings = null;
|
|
10761
11331
|
this._areaEntries = [];
|
|
11332
|
+
this._handleResponseChange = () => {
|
|
11333
|
+
this._internals.setFormValue(serializeResponseAttribute(this.response) || null);
|
|
11334
|
+
this.validate();
|
|
11335
|
+
};
|
|
10762
11336
|
this._handleAreaMappingsChange = () => {
|
|
10763
11337
|
this.#syncAreaEntriesFromAttribute();
|
|
10764
11338
|
};
|
|
@@ -10789,6 +11363,8 @@ var QtiSelectPointInteraction = class extends Interaction {
|
|
|
10789
11363
|
}
|
|
10790
11364
|
}
|
|
10791
11365
|
this.saveResponse(this.response);
|
|
11366
|
+
this.validate();
|
|
11367
|
+
this.reportValidity({ trigger: "change" });
|
|
10792
11368
|
};
|
|
10793
11369
|
this.#onResize = () => {
|
|
10794
11370
|
this.#calculateScale();
|
|
@@ -10847,7 +11423,7 @@ var QtiSelectPointInteraction = class extends Interaction {
|
|
|
10847
11423
|
}
|
|
10848
11424
|
/** Extension hook for optional layers rendered above the response points. */
|
|
10849
11425
|
renderSupplementalLayer() {
|
|
10850
|
-
return
|
|
11426
|
+
return nothing5;
|
|
10851
11427
|
}
|
|
10852
11428
|
/** Positions overlay elements that carry `data-coord` and `data-shape`. */
|
|
10853
11429
|
positionOverlayElements(elements32) {
|
|
@@ -10868,14 +11444,14 @@ var QtiSelectPointInteraction = class extends Interaction {
|
|
|
10868
11444
|
const responseList = Array.isArray(rawResponse) ? rawResponse : rawResponse ? [rawResponse] : [];
|
|
10869
11445
|
return html29` <slot name="prompt"></slot>
|
|
10870
11446
|
<point-container>
|
|
10871
|
-
${
|
|
11447
|
+
${repeat8(responseList.filter((point) => point), (point) => point, (point, index) => {
|
|
10872
11448
|
const [x, y] = point.split(" ").map(Number);
|
|
10873
11449
|
const leftPercentage = x / (this.#imageWidthOriginal || 1) * 100;
|
|
10874
11450
|
const topPercentage = y / (this.#imageHeightOriginal || 1) * 100;
|
|
10875
11451
|
return html29`
|
|
10876
11452
|
<button
|
|
10877
11453
|
part=${this.pointPart(point, index)}
|
|
10878
|
-
style=${
|
|
11454
|
+
style=${styleMap2({
|
|
10879
11455
|
pointerEvents: this.maxChoices === 1 ? "none" : "auto",
|
|
10880
11456
|
position: "absolute",
|
|
10881
11457
|
left: `${leftPercentage}%`,
|
|
@@ -10887,13 +11463,16 @@ var QtiSelectPointInteraction = class extends Interaction {
|
|
|
10887
11463
|
e.stopPropagation();
|
|
10888
11464
|
this.response = (this.response || []).filter((_, i) => i !== index);
|
|
10889
11465
|
this.saveResponse(this.response);
|
|
11466
|
+
this.validate();
|
|
11467
|
+
this.reportValidity({ trigger: "change" });
|
|
10890
11468
|
}}
|
|
10891
11469
|
></button>
|
|
10892
11470
|
`;
|
|
10893
11471
|
})}
|
|
10894
11472
|
${this.renderSupplementalLayer()}
|
|
10895
11473
|
<slot></slot>
|
|
10896
|
-
</point-container
|
|
11474
|
+
</point-container>
|
|
11475
|
+
<div part="message" role="alert" id="validation-message" style="display:none;"></div>`;
|
|
10897
11476
|
}
|
|
10898
11477
|
validate() {
|
|
10899
11478
|
const selectedCount = this.response?.length ?? 0;
|
|
@@ -10901,18 +11480,21 @@ var QtiSelectPointInteraction = class extends Interaction {
|
|
|
10901
11480
|
const belowMin = selectedCount < this.minChoices;
|
|
10902
11481
|
let isValid = true;
|
|
10903
11482
|
let validityMessage = "";
|
|
11483
|
+
let kind = "other";
|
|
10904
11484
|
if (exceedsMax) {
|
|
10905
11485
|
isValid = false;
|
|
11486
|
+
kind = "max";
|
|
10906
11487
|
validityMessage = this.dataset.maxSelectionsMessage || `Please select no more than ${this.maxChoices} ${this.maxChoices === 1 ? "point" : "points"}.`;
|
|
10907
11488
|
} else if (belowMin) {
|
|
10908
11489
|
isValid = false;
|
|
11490
|
+
kind = "min";
|
|
10909
11491
|
validityMessage = this.dataset.minSelectionsMessage || `Please select at least ${this.minChoices} ${this.minChoices === 1 ? "point" : "points"}.`;
|
|
10910
11492
|
}
|
|
10911
|
-
this.setInteractionValidity(isValid, validityMessage, this.#imgElement ?? this, { suppressInline: true });
|
|
11493
|
+
this.setInteractionValidity(isValid, validityMessage, this.#imgElement ?? this, { suppressInline: true, kind });
|
|
10912
11494
|
return isValid;
|
|
10913
11495
|
}
|
|
10914
|
-
reportValidity() {
|
|
10915
|
-
return super.reportValidity();
|
|
11496
|
+
reportValidity(options) {
|
|
11497
|
+
return super.reportValidity(options);
|
|
10916
11498
|
}
|
|
10917
11499
|
#calculateScale() {
|
|
10918
11500
|
this.#imageWidthOriginal = this.#imgElement.getAttribute("width") ? parseFloat(this.#imgElement.getAttribute("width")) : this.#imgElement.naturalWidth;
|
|
@@ -10940,20 +11522,20 @@ var QtiSelectPointInteraction = class extends Interaction {
|
|
|
10940
11522
|
}
|
|
10941
11523
|
}
|
|
10942
11524
|
};
|
|
10943
|
-
|
|
10944
|
-
|
|
11525
|
+
__decorate27([
|
|
11526
|
+
property25({
|
|
10945
11527
|
type: Number,
|
|
10946
11528
|
attribute: "max-choices"
|
|
10947
11529
|
})
|
|
10948
11530
|
], QtiSelectPointInteraction.prototype, "maxChoices", void 0);
|
|
10949
|
-
|
|
10950
|
-
|
|
11531
|
+
__decorate27([
|
|
11532
|
+
property25({
|
|
10951
11533
|
type: Number,
|
|
10952
11534
|
attribute: "min-choices"
|
|
10953
11535
|
})
|
|
10954
11536
|
], QtiSelectPointInteraction.prototype, "minChoices", void 0);
|
|
10955
|
-
|
|
10956
|
-
|
|
11537
|
+
__decorate27([
|
|
11538
|
+
property25({
|
|
10957
11539
|
attribute: "response",
|
|
10958
11540
|
reflect: false,
|
|
10959
11541
|
converter: {
|
|
@@ -10969,19 +11551,22 @@ __decorate26([
|
|
|
10969
11551
|
}
|
|
10970
11552
|
})
|
|
10971
11553
|
], QtiSelectPointInteraction.prototype, "response", void 0);
|
|
10972
|
-
|
|
10973
|
-
|
|
11554
|
+
__decorate27([
|
|
11555
|
+
property25({ attribute: "area-mappings" })
|
|
10974
11556
|
], QtiSelectPointInteraction.prototype, "areaMappings", void 0);
|
|
10975
|
-
|
|
10976
|
-
|
|
11557
|
+
__decorate27([
|
|
11558
|
+
state16()
|
|
10977
11559
|
], QtiSelectPointInteraction.prototype, "_areaEntries", void 0);
|
|
10978
|
-
|
|
11560
|
+
__decorate27([
|
|
11561
|
+
watch("response")
|
|
11562
|
+
], QtiSelectPointInteraction.prototype, "_handleResponseChange", void 0);
|
|
11563
|
+
__decorate27([
|
|
10979
11564
|
watch("areaMappings")
|
|
10980
11565
|
], QtiSelectPointInteraction.prototype, "_handleAreaMappingsChange", void 0);
|
|
10981
11566
|
|
|
10982
11567
|
// ../interactions/slider-interaction/dist/qti-slider-interaction.js
|
|
10983
|
-
import { html as html30, nothing as
|
|
10984
|
-
import { property as
|
|
11568
|
+
import { html as html30, nothing as nothing6 } from "lit";
|
|
11569
|
+
import { property as property26, query as query2 } from "lit/decorators.js";
|
|
10985
11570
|
|
|
10986
11571
|
// ../interactions/slider-interaction/dist/qti-slider-interaction.styles.js
|
|
10987
11572
|
import { css as css31 } from "lit";
|
|
@@ -11059,7 +11644,7 @@ var qti_slider_interaction_styles_default = [
|
|
|
11059
11644
|
];
|
|
11060
11645
|
|
|
11061
11646
|
// ../interactions/slider-interaction/dist/qti-slider-interaction.js
|
|
11062
|
-
var
|
|
11647
|
+
var __decorate28 = function(decorators, target, key, desc) {
|
|
11063
11648
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11064
11649
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11065
11650
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -11114,7 +11699,7 @@ var QtiSliderInteraction = class extends Interaction {
|
|
|
11114
11699
|
}
|
|
11115
11700
|
/** Extension hook for optional content rendered on the slider rail. */
|
|
11116
11701
|
renderRailSupplement() {
|
|
11117
|
-
return
|
|
11702
|
+
return nothing6;
|
|
11118
11703
|
}
|
|
11119
11704
|
/** Moves the knob to `newValue`, clamped to the bounds, or empties the slider. Returns whether it moved. */
|
|
11120
11705
|
#show(newValue) {
|
|
@@ -11155,7 +11740,7 @@ var QtiSliderInteraction = class extends Interaction {
|
|
|
11155
11740
|
|
|
11156
11741
|
<div id="rail" part="rail" @mousedown=${this.#onMouseDown} @touchstart=${this.#onTouchStart}>
|
|
11157
11742
|
<div id="knob" part="knob">
|
|
11158
|
-
${this.#value === null ?
|
|
11743
|
+
${this.#value === null ? nothing6 : html30`<div id="value" part="value">${this.#value}</div>`}
|
|
11159
11744
|
</div>
|
|
11160
11745
|
|
|
11161
11746
|
${this.renderRailSupplement()}
|
|
@@ -11199,25 +11784,25 @@ var QtiSliderInteraction = class extends Interaction {
|
|
|
11199
11784
|
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
11200
11785
|
}
|
|
11201
11786
|
};
|
|
11202
|
-
|
|
11787
|
+
__decorate28([
|
|
11203
11788
|
query2("#rail")
|
|
11204
11789
|
], QtiSliderInteraction.prototype, "_rail", void 0);
|
|
11205
|
-
|
|
11206
|
-
|
|
11790
|
+
__decorate28([
|
|
11791
|
+
property26({ type: Number, attribute: "lower-bound" })
|
|
11207
11792
|
], QtiSliderInteraction.prototype, "min", void 0);
|
|
11208
|
-
|
|
11209
|
-
|
|
11793
|
+
__decorate28([
|
|
11794
|
+
property26({ type: Number, attribute: "upper-bound" })
|
|
11210
11795
|
], QtiSliderInteraction.prototype, "max", void 0);
|
|
11211
|
-
|
|
11212
|
-
|
|
11796
|
+
__decorate28([
|
|
11797
|
+
property26({ type: Number, attribute: "step" })
|
|
11213
11798
|
], QtiSliderInteraction.prototype, "step", void 0);
|
|
11214
|
-
|
|
11215
|
-
|
|
11799
|
+
__decorate28([
|
|
11800
|
+
property26({ attribute: "response", reflect: false, noAccessor: true })
|
|
11216
11801
|
], QtiSliderInteraction.prototype, "response", null);
|
|
11217
11802
|
|
|
11218
11803
|
// ../interactions/text-entry-interaction/dist/qti-text-entry-interaction.js
|
|
11219
11804
|
import { html as html31 } from "lit";
|
|
11220
|
-
import { property as
|
|
11805
|
+
import { property as property27, query as query3 } from "lit/decorators.js";
|
|
11221
11806
|
import { ifDefined as ifDefined4 } from "lit/directives/if-defined.js";
|
|
11222
11807
|
import { createRef } from "lit/directives/ref.js";
|
|
11223
11808
|
|
|
@@ -11318,7 +11903,7 @@ var qti_text_entry_interaction_styles_default = [
|
|
|
11318
11903
|
];
|
|
11319
11904
|
|
|
11320
11905
|
// ../interactions/text-entry-interaction/dist/qti-text-entry-interaction.js
|
|
11321
|
-
var
|
|
11906
|
+
var __decorate29 = function(decorators, target, key, desc) {
|
|
11322
11907
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11323
11908
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11324
11909
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -11361,13 +11946,15 @@ var QtiTextEntryInteraction = class extends Interaction {
|
|
|
11361
11946
|
} else {
|
|
11362
11947
|
isValid = this._input.checkValidity();
|
|
11363
11948
|
}
|
|
11949
|
+
let kind = "other";
|
|
11364
11950
|
if (isValid && this.response === "") {
|
|
11365
11951
|
isValid = false;
|
|
11952
|
+
kind = "min";
|
|
11366
11953
|
}
|
|
11367
11954
|
if (!isValid && !validityMessage) {
|
|
11368
11955
|
validityMessage = this._input.validationMessage || "Invalid value.";
|
|
11369
11956
|
}
|
|
11370
|
-
this.setInteractionValidity(isValid, validityMessage, this._input, { suppressInline: true });
|
|
11957
|
+
this.setInteractionValidity(isValid, validityMessage, this._input, { suppressInline: true, kind });
|
|
11371
11958
|
return isValid;
|
|
11372
11959
|
}
|
|
11373
11960
|
/*
|
|
@@ -11377,7 +11964,7 @@ var QtiTextEntryInteraction = class extends Interaction {
|
|
|
11377
11964
|
*/
|
|
11378
11965
|
/** The answer-key line, revealed above the field when the correct response is shown. */
|
|
11379
11966
|
renderAnswer() {
|
|
11380
|
-
return html31`<div part="answer" aria-hidden="true"></div>`;
|
|
11967
|
+
return html31`<div part="answer-key answer" aria-hidden="true"></div>`;
|
|
11381
11968
|
}
|
|
11382
11969
|
/** The field itself. */
|
|
11383
11970
|
renderInput() {
|
|
@@ -11387,7 +11974,7 @@ var QtiTextEntryInteraction = class extends Interaction {
|
|
|
11387
11974
|
spellcheck="false"
|
|
11388
11975
|
autocomplete="off"
|
|
11389
11976
|
@blur="${(_) => {
|
|
11390
|
-
this.reportValidity();
|
|
11977
|
+
this.reportValidity({ trigger: "change" });
|
|
11391
11978
|
}}"
|
|
11392
11979
|
@keydown="${(event) => event.stopImmediatePropagation()}"
|
|
11393
11980
|
@keyup="${this.textChanged}"
|
|
@@ -11417,33 +12004,33 @@ var QtiTextEntryInteraction = class extends Interaction {
|
|
|
11417
12004
|
this.saveResponse(input.value);
|
|
11418
12005
|
}
|
|
11419
12006
|
}
|
|
11420
|
-
reportValidity() {
|
|
12007
|
+
reportValidity(options) {
|
|
11421
12008
|
this.validate();
|
|
11422
|
-
return super.reportValidity();
|
|
12009
|
+
return super.reportValidity(options);
|
|
11423
12010
|
}
|
|
11424
12011
|
reset() {
|
|
11425
12012
|
this.response = "";
|
|
11426
12013
|
}
|
|
11427
12014
|
};
|
|
11428
|
-
|
|
11429
|
-
|
|
12015
|
+
__decorate29([
|
|
12016
|
+
property27({ type: Number, attribute: "expected-length" })
|
|
11430
12017
|
], QtiTextEntryInteraction.prototype, "expectedLength", void 0);
|
|
11431
|
-
|
|
11432
|
-
|
|
12018
|
+
__decorate29([
|
|
12019
|
+
property27({ type: String, attribute: "pattern-mask" })
|
|
11433
12020
|
], QtiTextEntryInteraction.prototype, "patternMask", void 0);
|
|
11434
|
-
|
|
11435
|
-
|
|
12021
|
+
__decorate29([
|
|
12022
|
+
property27({ type: String, attribute: "placeholder-text" })
|
|
11436
12023
|
], QtiTextEntryInteraction.prototype, "placeholderText", void 0);
|
|
11437
|
-
|
|
11438
|
-
|
|
12024
|
+
__decorate29([
|
|
12025
|
+
property27({ type: String, attribute: "data-patternmask-message" })
|
|
11439
12026
|
], QtiTextEntryInteraction.prototype, "dataPatternmaskMessage", void 0);
|
|
11440
|
-
|
|
11441
|
-
|
|
12027
|
+
__decorate29([
|
|
12028
|
+
property27({ type: String, attribute: "response", reflect: false })
|
|
11442
12029
|
], QtiTextEntryInteraction.prototype, "response", void 0);
|
|
11443
|
-
|
|
12030
|
+
__decorate29([
|
|
11444
12031
|
query3("input")
|
|
11445
12032
|
], QtiTextEntryInteraction.prototype, "_input", void 0);
|
|
11446
|
-
|
|
12033
|
+
__decorate29([
|
|
11447
12034
|
watch("response", { waitUntilFirstUpdate: true })
|
|
11448
12035
|
], QtiTextEntryInteraction.prototype, "_handleValueChange", void 0);
|
|
11449
12036
|
|
|
@@ -11474,8 +12061,10 @@ var QtiUploadInteraction = class extends Interaction {
|
|
|
11474
12061
|
#file = null;
|
|
11475
12062
|
#base64 = null;
|
|
11476
12063
|
reset() {
|
|
12064
|
+
this.resetValidityReport();
|
|
11477
12065
|
this.#file = null;
|
|
11478
12066
|
this.#base64 = null;
|
|
12067
|
+
this._internals.setFormValue(null);
|
|
11479
12068
|
this.saveResponse(null);
|
|
11480
12069
|
}
|
|
11481
12070
|
validate() {
|
|
@@ -11487,6 +12076,7 @@ var QtiUploadInteraction = class extends Interaction {
|
|
|
11487
12076
|
set response(base64) {
|
|
11488
12077
|
if (typeof base64 === "string") {
|
|
11489
12078
|
this.#base64 = base64;
|
|
12079
|
+
this._internals.setFormValue(base64);
|
|
11490
12080
|
this.saveResponse(base64);
|
|
11491
12081
|
} else if (base64 === null) {
|
|
11492
12082
|
this.reset();
|
|
@@ -11518,6 +12108,7 @@ var QtiUploadInteraction = class extends Interaction {
|
|
|
11518
12108
|
if (input.files && input.files.length > 0) {
|
|
11519
12109
|
this.#file = input.files[0];
|
|
11520
12110
|
this.#base64 = await this.#convertToBase64(this.#file);
|
|
12111
|
+
this._internals.setFormValue(this.#base64);
|
|
11521
12112
|
this.saveResponse(this.#base64);
|
|
11522
12113
|
this.dispatchEvent(new CustomEvent("qti-interaction-response", {
|
|
11523
12114
|
detail: { response: this.#base64 }
|
|
@@ -12175,4 +12766,4 @@ export {
|
|
|
12175
12766
|
elements31 as elements21,
|
|
12176
12767
|
qtiInteractionElements
|
|
12177
12768
|
};
|
|
12178
|
-
//# sourceMappingURL=chunk-
|
|
12769
|
+
//# sourceMappingURL=chunk-7MYZHZWV.js.map
|