@citolab/qti-components 7.6.0 → 7.9.0
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 +173 -133
- package/custom-elements.json +20023 -19863
- package/dist/chunks/{chunk-GG4NR5OR.js → chunk-4QSZJYSB.js} +2 -2
- package/dist/chunks/{chunk-G7ZPPP7O.js → chunk-7YO5JFT3.js} +86 -34
- package/dist/chunks/chunk-7YO5JFT3.js.map +1 -0
- package/dist/chunks/{chunk-LSEB52SP.js → chunk-PT5ASWGQ.js} +49 -29
- package/dist/chunks/chunk-PT5ASWGQ.js.map +1 -0
- package/dist/chunks/{chunk-2WTHXWS3.js → chunk-YD7FVKDP.js} +43 -19
- package/dist/chunks/chunk-YD7FVKDP.js.map +1 -0
- package/dist/chunks/{chunk-FQWMCONA.js → chunk-ZZ7XZ5GG.js} +11 -6
- package/dist/chunks/{chunk-FQWMCONA.js.map → chunk-ZZ7XZ5GG.js.map} +1 -1
- package/dist/index.js +212 -10
- package/dist/index.js.map +1 -1
- package/dist/item.css +48 -28
- package/dist/qti-components/index.d.ts +2 -0
- package/dist/qti-components/index.js +2 -2
- package/dist/qti-components-jsx.d.ts +244 -225
- package/dist/qti-item/index.js +2 -2
- package/dist/qti-test/index.js +3 -3
- package/dist/vscode.html-custom-data.json +1 -1
- package/package.json +2 -2
- package/dist/chunks/chunk-2WTHXWS3.js.map +0 -1
- package/dist/chunks/chunk-G7ZPPP7O.js.map +0 -1
- package/dist/chunks/chunk-LSEB52SP.js.map +0 -1
- /package/dist/chunks/{chunk-GG4NR5OR.js.map → chunk-4QSZJYSB.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
item_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PT5ASWGQ.js";
|
|
4
4
|
import {
|
|
5
5
|
watch
|
|
6
6
|
} from "./chunk-ELDMXTUQ.js";
|
|
@@ -362,4 +362,4 @@ export {
|
|
|
362
362
|
ItemShowCorrectResponse,
|
|
363
363
|
QtiItem
|
|
364
364
|
};
|
|
365
|
-
//# sourceMappingURL=chunk-
|
|
365
|
+
//# sourceMappingURL=chunk-4QSZJYSB.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
convertNumberToUniversalFormat,
|
|
4
4
|
liveQuery,
|
|
5
5
|
removeDoubleSlashes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YD7FVKDP.js";
|
|
7
7
|
import {
|
|
8
8
|
watch
|
|
9
9
|
} from "./chunk-ELDMXTUQ.js";
|
|
@@ -744,6 +744,9 @@ var DragDropInteractionMixin = (superClass, draggablesSelector, droppablesSelect
|
|
|
744
744
|
// Last touch target
|
|
745
745
|
this.currentDropTarget = null;
|
|
746
746
|
// Current droppable element
|
|
747
|
+
this.onMove = this.handleTouchMove.bind(this);
|
|
748
|
+
this.onEnd = this.handleTouchEnd.bind(this);
|
|
749
|
+
this.onCancel = this.handleTouchCancel.bind(this);
|
|
747
750
|
this.MIN_DRAG_DISTANCE = 5;
|
|
748
751
|
// Minimum pixel movement to start dragging
|
|
749
752
|
this.DRAG_CLONE_OPACITY = 1;
|
|
@@ -852,11 +855,11 @@ var DragDropInteractionMixin = (superClass, draggablesSelector, droppablesSelect
|
|
|
852
855
|
if (this.isMatchTabular()) return;
|
|
853
856
|
const disabled = this.hasAttribute("disabled");
|
|
854
857
|
if (!disabled) {
|
|
855
|
-
document.addEventListener("
|
|
856
|
-
document.addEventListener("
|
|
857
|
-
document.addEventListener("
|
|
858
|
-
document.addEventListener("
|
|
859
|
-
document.addEventListener("touchcancel", this.
|
|
858
|
+
document.addEventListener("mousemove", this.onMove, { passive: false });
|
|
859
|
+
document.addEventListener("mouseup", this.onEnd, { passive: false });
|
|
860
|
+
document.addEventListener("touchmove", this.onMove, { passive: false });
|
|
861
|
+
document.addEventListener("touchend", this.onEnd, { passive: false });
|
|
862
|
+
document.addEventListener("touchcancel", this.onCancel, { passive: false });
|
|
860
863
|
}
|
|
861
864
|
const draggables = Array.from(this.querySelectorAll(draggablesSelector) || []).concat(
|
|
862
865
|
Array.from(this.shadowRoot?.querySelectorAll(draggablesSelector) || [])
|
|
@@ -995,11 +998,11 @@ var DragDropInteractionMixin = (superClass, draggablesSelector, droppablesSelect
|
|
|
995
998
|
this.resizeObserver.disconnect();
|
|
996
999
|
this.resizeObserver = null;
|
|
997
1000
|
}
|
|
998
|
-
document.removeEventListener("
|
|
999
|
-
document.removeEventListener("
|
|
1000
|
-
document.removeEventListener("
|
|
1001
|
-
document.removeEventListener("
|
|
1002
|
-
document.removeEventListener("touchcancel", this.
|
|
1001
|
+
document.removeEventListener("mousemove", this.onMove);
|
|
1002
|
+
document.removeEventListener("mouseup", this.onEnd);
|
|
1003
|
+
document.removeEventListener("touchmove", this.onMove);
|
|
1004
|
+
document.removeEventListener("touchend", this.onEnd);
|
|
1005
|
+
document.removeEventListener("touchcancel", this.onCancel);
|
|
1003
1006
|
}
|
|
1004
1007
|
handleTouchMove(e) {
|
|
1005
1008
|
if (this.isMatchTabular()) return;
|
|
@@ -1031,7 +1034,7 @@ var DragDropInteractionMixin = (superClass, draggablesSelector, droppablesSelect
|
|
|
1031
1034
|
}
|
|
1032
1035
|
handleTouchEnd(e) {
|
|
1033
1036
|
if (this.isMatchTabular()) return;
|
|
1034
|
-
if (this.isDragging) {
|
|
1037
|
+
if (this.isDragging || this.isDraggable || this.dragClone) {
|
|
1035
1038
|
this.resetDragState();
|
|
1036
1039
|
}
|
|
1037
1040
|
this._internals.states.delete("--dragzone-active");
|
|
@@ -1285,30 +1288,38 @@ var DragDropInteractionMixin = (superClass, draggablesSelector, droppablesSelect
|
|
|
1285
1288
|
const yDist = Math.abs(touch.clientY - this.touchStartPoint.y);
|
|
1286
1289
|
return xDist + yDist;
|
|
1287
1290
|
}
|
|
1291
|
+
getDropzoneRect(el) {
|
|
1292
|
+
const slot = el.shadowRoot?.querySelector('slot[part="dropslot"]');
|
|
1293
|
+
return (slot ?? el).getBoundingClientRect();
|
|
1294
|
+
}
|
|
1288
1295
|
findClosestDropzone() {
|
|
1289
|
-
const
|
|
1290
|
-
if (!this.dragClone ||
|
|
1296
|
+
const activeDrops = this.allDropzones.filter((d) => !d.hasAttribute("disabled"));
|
|
1297
|
+
if (!this.dragClone || activeDrops.length === 0) return null;
|
|
1291
1298
|
const dragRect = this.dragClone.getBoundingClientRect();
|
|
1292
1299
|
let closestDropzone = null;
|
|
1293
|
-
let
|
|
1294
|
-
|
|
1295
|
-
const
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
+
let maxArea = 0;
|
|
1301
|
+
const prefer = (elements) => {
|
|
1302
|
+
for (const dz of elements) {
|
|
1303
|
+
const dzRect = this.getDropzoneRect(dz);
|
|
1304
|
+
const area = this.calculateOverlapArea(dragRect, dzRect);
|
|
1305
|
+
if (area > maxArea) {
|
|
1306
|
+
maxArea = area;
|
|
1307
|
+
closestDropzone = dz;
|
|
1308
|
+
}
|
|
1300
1309
|
}
|
|
1310
|
+
};
|
|
1311
|
+
prefer(this.droppables.filter((droppable) => !droppable.hasAttribute("disabled")));
|
|
1312
|
+
if (!closestDropzone) {
|
|
1313
|
+
prefer(this.dragContainers.filter((drags) => !drags.hasAttribute("disabled")));
|
|
1301
1314
|
}
|
|
1302
1315
|
if (!closestDropzone) {
|
|
1303
|
-
let
|
|
1304
|
-
for (const
|
|
1305
|
-
const
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
minDistance = distance;
|
|
1311
|
-
closestDropzone = dropzone;
|
|
1316
|
+
let minDist = Number.POSITIVE_INFINITY;
|
|
1317
|
+
for (const dz of activeDrops) {
|
|
1318
|
+
const dzRect = this.getDropzoneRect(dz);
|
|
1319
|
+
const dist = Math.hypot(dragRect.left - dzRect.left, dragRect.top - dzRect.top);
|
|
1320
|
+
if (dist < minDist) {
|
|
1321
|
+
minDist = dist;
|
|
1322
|
+
closestDropzone = dz;
|
|
1312
1323
|
}
|
|
1313
1324
|
}
|
|
1314
1325
|
}
|
|
@@ -1453,6 +1464,15 @@ var qti_associate_interaction_styles_default = css4`
|
|
|
1453
1464
|
gap: 0.5rem;
|
|
1454
1465
|
}
|
|
1455
1466
|
|
|
1467
|
+
[part='drop-list'][active] {
|
|
1468
|
+
border-color: var(--qti-border-active) !important;
|
|
1469
|
+
background-color: var(--qti-bg-active) !important;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
[part='drop-list'][enabled] {
|
|
1473
|
+
background-color: var(--qti-bg-active) !important;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1456
1476
|
:host::part(associables-container) {
|
|
1457
1477
|
display: flex;
|
|
1458
1478
|
padding: 0.5rem;
|
|
@@ -3142,11 +3162,13 @@ import { css as css15 } from "lit";
|
|
|
3142
3162
|
var qti_hotspot_interaction_styles_default = css15`
|
|
3143
3163
|
slot:not([name='prompt']) {
|
|
3144
3164
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
3145
|
-
display: block;
|
|
3165
|
+
display: inline-block;
|
|
3146
3166
|
width: fit-content; /* hotspots not stretching further if image is at max size */
|
|
3167
|
+
line-height: 0; /* remove gaps below image */
|
|
3147
3168
|
}
|
|
3148
3169
|
::slotted(img) {
|
|
3149
3170
|
/* image not selectable anymore */
|
|
3171
|
+
display: block;
|
|
3150
3172
|
pointer-events: none;
|
|
3151
3173
|
user-select: none;
|
|
3152
3174
|
/* width:100%; */
|
|
@@ -3155,19 +3177,40 @@ var qti_hotspot_interaction_styles_default = css15`
|
|
|
3155
3177
|
|
|
3156
3178
|
// src/lib/qti-components/qti-interaction/qti-hotspot-interaction/qti-hotspot-interaction.ts
|
|
3157
3179
|
var QtiHotspotInteraction = class extends ChoicesMixin(Interaction, "qti-hotspot-choice") {
|
|
3180
|
+
constructor() {
|
|
3181
|
+
super(...arguments);
|
|
3182
|
+
this.imageLoadPromise = null;
|
|
3183
|
+
}
|
|
3158
3184
|
render() {
|
|
3159
3185
|
return html18`
|
|
3160
3186
|
<slot name="prompt"></slot>
|
|
3161
3187
|
<slot></slot>
|
|
3162
3188
|
`;
|
|
3163
3189
|
}
|
|
3164
|
-
|
|
3190
|
+
getImageLoadPromise(img) {
|
|
3191
|
+
if (!this.imageLoadPromise) {
|
|
3192
|
+
if (img.naturalWidth > 0 && img.naturalHeight > 0) {
|
|
3193
|
+
this.imageLoadPromise = Promise.resolve(img);
|
|
3194
|
+
} else {
|
|
3195
|
+
this.imageLoadPromise = new Promise((resolve) => {
|
|
3196
|
+
const handler = () => {
|
|
3197
|
+
img.removeEventListener("load", handler);
|
|
3198
|
+
resolve(img);
|
|
3199
|
+
};
|
|
3200
|
+
img.addEventListener("load", handler);
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
return this.imageLoadPromise;
|
|
3205
|
+
}
|
|
3206
|
+
async positionHotspotOnRegister(e) {
|
|
3165
3207
|
const img = this.querySelector("img");
|
|
3166
3208
|
const hotspot = e.target;
|
|
3167
3209
|
const coords = hotspot.getAttribute("coords");
|
|
3168
3210
|
const shape = hotspot.getAttribute("shape");
|
|
3169
3211
|
const coordsNumber = coords.split(",").map((s) => parseInt(s));
|
|
3170
|
-
|
|
3212
|
+
const loadedImg = await this.getImageLoadPromise(img);
|
|
3213
|
+
positionShapes(shape, coordsNumber, loadedImg, hotspot);
|
|
3171
3214
|
}
|
|
3172
3215
|
connectedCallback() {
|
|
3173
3216
|
super.connectedCallback();
|
|
@@ -3882,6 +3925,15 @@ var qti_order_interaction_styles_default = css22`
|
|
|
3882
3925
|
flex: 1;
|
|
3883
3926
|
}
|
|
3884
3927
|
|
|
3928
|
+
[part='drop-list'][active] {
|
|
3929
|
+
border-color: var(--qti-border-active) !important;
|
|
3930
|
+
background-color: var(--qti-bg-active) !important;
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
[part='drop-list'][enabled] {
|
|
3934
|
+
background-color: var(--qti-bg-active) !important;
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3885
3937
|
[part='container'] {
|
|
3886
3938
|
display: flex;
|
|
3887
3939
|
gap: 0.5rem;
|
|
@@ -8761,4 +8813,4 @@ export {
|
|
|
8761
8813
|
QtiOutcomeDeclaration,
|
|
8762
8814
|
QtiResponseDeclaration
|
|
8763
8815
|
};
|
|
8764
|
-
//# sourceMappingURL=chunk-
|
|
8816
|
+
//# sourceMappingURL=chunk-7YO5JFT3.js.map
|