@citolab/qti-components 9.4.0 → 10.0.0-next.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 +262 -223
- package/dist/{chunk-XEWGFAS4.js → chunk-AWTQKBC4.js} +66 -26
- package/dist/chunk-AWTQKBC4.js.map +1 -0
- package/dist/{chunk-MSGYZE6L.js → chunk-CNFVA3AA.js} +127 -47
- package/dist/chunk-CNFVA3AA.js.map +1 -0
- package/dist/{chunk-LKHRHFXO.js → chunk-EPSUZIWL.js} +5 -5
- package/dist/{chunk-GNTO3IFM.js → chunk-EUKU5QKV.js} +79 -106
- package/dist/chunk-EUKU5QKV.js.map +1 -0
- package/dist/{chunk-B74SYQB2.js → chunk-F7R7GSWL.js} +2 -2
- package/dist/{chunk-C3JPUV36.js → chunk-GPNWMLLA.js} +2 -2
- package/dist/{chunk-JHPQJDAV.js → chunk-QD3Y6UK3.js} +2 -2
- package/dist/{chunk-B5XHZI2P.js → chunk-SVYHZIJ7.js} +2 -2
- package/dist/{chunk-BMXG7D2N.js → chunk-WNAOVXXN.js} +2 -2
- package/dist/chunk-ZP6QQYSU.js +7 -0
- package/dist/chunk-ZP6QQYSU.js.map +1 -0
- package/dist/corrections.d.ts +2 -2
- package/dist/corrections.js +6 -6
- package/dist/elements.d.ts +64 -2
- package/dist/elements.js +14 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +21 -11
- package/dist/interactions.d.ts +2 -2
- package/dist/interactions.js +2 -2
- package/dist/item.css +11 -0
- package/dist/item.js +3 -3
- package/dist/loader.d.ts +1 -1
- package/dist/qti-components-jsx.d.ts +18 -191
- package/dist/{qti-test.d-Cud5Gvy0.d.ts → qti-test.d-_THYXPzd.d.ts} +5 -7
- package/dist/{qti-text-entry-interaction.d-DKvz9ncv.d.ts → qti-text-entry-interaction.d-q8u5BiVK.d.ts} +11 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +4 -4
- package/package.json +8 -8
- package/dist/chunk-A32YH4H5.js +0 -7
- package/dist/chunk-A32YH4H5.js.map +0 -1
- package/dist/chunk-GNTO3IFM.js.map +0 -1
- package/dist/chunk-MSGYZE6L.js.map +0 -1
- package/dist/chunk-XEWGFAS4.js.map +0 -1
- /package/dist/{chunk-LKHRHFXO.js.map → chunk-EPSUZIWL.js.map} +0 -0
- /package/dist/{chunk-B74SYQB2.js.map → chunk-F7R7GSWL.js.map} +0 -0
- /package/dist/{chunk-C3JPUV36.js.map → chunk-GPNWMLLA.js.map} +0 -0
- /package/dist/{chunk-JHPQJDAV.js.map → chunk-QD3Y6UK3.js.map} +0 -0
- /package/dist/{chunk-B5XHZI2P.js.map → chunk-SVYHZIJ7.js.map} +0 -0
- /package/dist/{chunk-BMXG7D2N.js.map → chunk-WNAOVXXN.js.map} +0 -0
|
@@ -5830,6 +5830,7 @@ var QtiExtendedTextInteraction = class extends Interaction {
|
|
|
5830
5830
|
warnedAboutXhtml = true;
|
|
5831
5831
|
console.warn('<qti-extended-text-interaction format="xhtml"> renders as plain text. The interaction has no rich-text editor; the recorded response will contain no markup.');
|
|
5832
5832
|
};
|
|
5833
|
+
this.minStrings = 0;
|
|
5833
5834
|
this.response = null;
|
|
5834
5835
|
this._handleResponseChange = () => {
|
|
5835
5836
|
this._internals.setFormValue(this.value);
|
|
@@ -5902,7 +5903,7 @@ var QtiExtendedTextInteraction = class extends Interaction {
|
|
|
5902
5903
|
} else {
|
|
5903
5904
|
isValid = textarea.checkValidity();
|
|
5904
5905
|
}
|
|
5905
|
-
if (isValid && !this.response) {
|
|
5906
|
+
if (isValid && !this.response && this.minStrings >= 1) {
|
|
5906
5907
|
isValid = false;
|
|
5907
5908
|
}
|
|
5908
5909
|
if (!isValid && !validityMessage) {
|
|
@@ -5984,6 +5985,9 @@ __decorate18([
|
|
|
5984
5985
|
__decorate18([
|
|
5985
5986
|
watch("format")
|
|
5986
5987
|
], QtiExtendedTextInteraction.prototype, "_handleFormatChange", void 0);
|
|
5988
|
+
__decorate18([
|
|
5989
|
+
property17({ type: Number, attribute: "min-strings" })
|
|
5990
|
+
], QtiExtendedTextInteraction.prototype, "minStrings", void 0);
|
|
5987
5991
|
__decorate18([
|
|
5988
5992
|
property17({ type: String, attribute: "pattern-mask" })
|
|
5989
5993
|
], QtiExtendedTextInteraction.prototype, "patternMask", void 0);
|
|
@@ -6499,7 +6503,8 @@ var qti_graphic_gap_match_interaction_styles_default = [
|
|
|
6499
6503
|
width: 25%;
|
|
6500
6504
|
}
|
|
6501
6505
|
& [part='image'] {
|
|
6502
|
-
width:
|
|
6506
|
+
/* A cap, not a width: the slot must stay exactly the graphic's box (see below). */
|
|
6507
|
+
max-width: 75%;
|
|
6503
6508
|
}
|
|
6504
6509
|
}
|
|
6505
6510
|
:host(.qti-choices-right) {
|
|
@@ -6508,12 +6513,25 @@ var qti_graphic_gap_match_interaction_styles_default = [
|
|
|
6508
6513
|
width: 25%;
|
|
6509
6514
|
}
|
|
6510
6515
|
& [part='image'] {
|
|
6511
|
-
width:
|
|
6516
|
+
/* A cap, not a width: the slot must stay exactly the graphic's box (see below). */
|
|
6517
|
+
max-width: 75%;
|
|
6512
6518
|
}
|
|
6513
6519
|
}
|
|
6520
|
+
/*
|
|
6521
|
+
* The coordinate space the drop areas sit on. Every qti-associable-hotspot is position:absolute
|
|
6522
|
+
* and placed with left/top percentages of the graphic (positionShapes), so this slot must be
|
|
6523
|
+
* (a) a positioning context and (b) exactly the box of the graphic — the same contract as the
|
|
6524
|
+
* hotspot interaction's slot.
|
|
6525
|
+
*
|
|
6526
|
+
* width: fit-content shrink-wraps the slot to the graphic instead of the full row, so a
|
|
6527
|
+
* percentage of the slot is a percentage of the picture.
|
|
6528
|
+
* max-width: 100% lets the slot, and with it the graphic, narrow to the container.
|
|
6529
|
+
*/
|
|
6514
6530
|
[part='image'] {
|
|
6515
6531
|
display: block;
|
|
6516
6532
|
position: relative;
|
|
6533
|
+
width: fit-content;
|
|
6534
|
+
max-width: 100%;
|
|
6517
6535
|
}
|
|
6518
6536
|
/* [part='drops'] , */
|
|
6519
6537
|
|
|
@@ -6527,8 +6545,22 @@ var qti_graphic_gap_match_interaction_styles_default = [
|
|
|
6527
6545
|
border-radius: 0.3rem;
|
|
6528
6546
|
gap: 0.5rem;
|
|
6529
6547
|
}
|
|
6530
|
-
|
|
6531
|
-
|
|
6548
|
+
/*
|
|
6549
|
+
* Fluid, like the hotspot interaction's graphic: an item declares the graphic at the size its
|
|
6550
|
+
* coords were authored in (often a full-resolution picture, 1600px wide), and it must still fit a
|
|
6551
|
+
* column or a phone. The drop areas are percentages of it, so they scale along.
|
|
6552
|
+
*
|
|
6553
|
+
* max-width: 100% shrinks a graphic wider than its container, never upscales a small one.
|
|
6554
|
+
* height: auto keeps the aspect ratio the width/height attributes declare; without it the
|
|
6555
|
+
* height attribute pins the height while the width shrinks.
|
|
6556
|
+
* display: block no inline descender gap under the picture, which would make the slot
|
|
6557
|
+
* taller than the graphic and skew every vertical percentage.
|
|
6558
|
+
*/
|
|
6559
|
+
::slotted(img),
|
|
6560
|
+
::slotted(object) {
|
|
6561
|
+
display: block;
|
|
6562
|
+
max-width: 100%;
|
|
6563
|
+
height: auto;
|
|
6532
6564
|
user-select: none;
|
|
6533
6565
|
pointer-events: none;
|
|
6534
6566
|
}
|
|
@@ -6550,36 +6582,57 @@ var QtiGraphicGapMatchInteraction = class extends DragDropSlottedSortableMixin(S
|
|
|
6550
6582
|
shouldReturnToInventoryOnInventoryDrop() {
|
|
6551
6583
|
return true;
|
|
6552
6584
|
}
|
|
6553
|
-
|
|
6554
|
-
|
|
6585
|
+
/**
|
|
6586
|
+
* The background graphic: a direct child, as QTI places it. Not `findGraphic(this)`, which
|
|
6587
|
+
* searches every descendant and would pick up a `qti-gap-img`'s picture (or one in the prompt)
|
|
6588
|
+
* when it comes first.
|
|
6589
|
+
*/
|
|
6590
|
+
#graphic() {
|
|
6591
|
+
return this.querySelector(':scope > img, :scope > object[type^="image"]');
|
|
6592
|
+
}
|
|
6593
|
+
/**
|
|
6594
|
+
* Pins the graphic's box to the aspect ratio its width/height attributes declare: the coordinate
|
|
6595
|
+
* space the drop areas are percentages of. With the fluid `height: auto` (see the styles) the box
|
|
6596
|
+
* would otherwise follow the bitmap — an `<object>` gets no ratio from its attributes at all, and
|
|
6597
|
+
* an `<img>` only `auto w / h`, where the loaded bitmap's own ratio wins. Either way a picture
|
|
6598
|
+
* whose pixels differ from its declared size would slide out from under its drop areas. Pinned,
|
|
6599
|
+
* it fills the declared box as it does at its fixed size.
|
|
6600
|
+
*/
|
|
6601
|
+
#keepDeclaredRatio(graphic) {
|
|
6602
|
+
if (graphic.style.aspectRatio)
|
|
6603
|
+
return;
|
|
6604
|
+
const length = (name) => {
|
|
6605
|
+
const raw = (graphic.getAttribute(name) ?? "").trim();
|
|
6606
|
+
const value = parseFloat(raw);
|
|
6607
|
+
return raw.endsWith("%") || !(value > 0) ? null : value;
|
|
6608
|
+
};
|
|
6609
|
+
const width = length("width");
|
|
6610
|
+
const height = length("height");
|
|
6611
|
+
if (width && height)
|
|
6612
|
+
graphic.style.aspectRatio = `${width} / ${height}`;
|
|
6613
|
+
}
|
|
6614
|
+
/**
|
|
6615
|
+
* Places a drop area over the graphic with `positionShapes`, the hotspot interaction's helper:
|
|
6616
|
+
* percentages of the coordinate space the `coords` were authored in, so the areas scale with the
|
|
6617
|
+
* graphic when it is narrower than its declared width (see the styles). They used to be written
|
|
6618
|
+
* in pixels, which only held while the graphic rendered at exactly that width.
|
|
6619
|
+
*/
|
|
6620
|
+
#positionHotspot(hotspot) {
|
|
6621
|
+
const graphic = this.#graphic();
|
|
6555
6622
|
const coords = hotspot.getAttribute("coords");
|
|
6556
6623
|
const shape = hotspot.getAttribute("shape");
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
const [centerX, centerY, radius] = coordsNumber;
|
|
6562
|
-
hotspot.style.left = centerX - radius + "px";
|
|
6563
|
-
hotspot.style.top = centerY - radius + "px";
|
|
6564
|
-
hotspot.style.width = hotspot.style.height = 2 * radius + "px";
|
|
6565
|
-
}
|
|
6566
|
-
break;
|
|
6567
|
-
case "rect":
|
|
6568
|
-
{
|
|
6569
|
-
const [leftX, topY, rightX, bottomY] = coordsNumber;
|
|
6570
|
-
hotspot.style.left = leftX + "px";
|
|
6571
|
-
hotspot.style.top = topY + "px";
|
|
6572
|
-
hotspot.style.width = rightX - leftX + "px";
|
|
6573
|
-
hotspot.style.height = bottomY - topY + "px";
|
|
6574
|
-
}
|
|
6575
|
-
break;
|
|
6576
|
-
default:
|
|
6577
|
-
break;
|
|
6578
|
-
}
|
|
6624
|
+
if (!graphic || !coords || !shape)
|
|
6625
|
+
return;
|
|
6626
|
+
this.#keepDeclaredRatio(graphic);
|
|
6627
|
+
positionShapes(shape, coords.split(",").map((s) => parseFloat(s)), graphic, hotspot);
|
|
6579
6628
|
}
|
|
6629
|
+
#positionHotspotOnRegister = (e) => {
|
|
6630
|
+
this.#positionHotspot(e.target);
|
|
6631
|
+
};
|
|
6580
6632
|
connectedCallback() {
|
|
6581
6633
|
super.connectedCallback();
|
|
6582
6634
|
this.addEventListener("qti-register-hotspot", this.#positionHotspotOnRegister);
|
|
6635
|
+
this.querySelectorAll(":scope > qti-associable-hotspot").forEach((hotspot) => this.#positionHotspot(hotspot));
|
|
6583
6636
|
}
|
|
6584
6637
|
disconnectedCallback() {
|
|
6585
6638
|
super.disconnectedCallback();
|
|
@@ -10655,7 +10708,7 @@ var qti_slider_interaction_styles_default = [
|
|
|
10655
10708
|
transform: translateX(-50%);
|
|
10656
10709
|
cursor: pointer;
|
|
10657
10710
|
border-radius: 9999px; /* rounded-full */
|
|
10658
|
-
left: var(--value-percentage);
|
|
10711
|
+
left: var(--value-percentage, 0%);
|
|
10659
10712
|
}
|
|
10660
10713
|
[part='value'] {
|
|
10661
10714
|
position: absolute;
|
|
@@ -10682,7 +10735,7 @@ var __decorate26 = function(decorators, target, key, desc) {
|
|
|
10682
10735
|
var QtiSliderInteraction = class extends Interaction {
|
|
10683
10736
|
constructor() {
|
|
10684
10737
|
super(...arguments);
|
|
10685
|
-
this.#value =
|
|
10738
|
+
this.#value = null;
|
|
10686
10739
|
this.min = 0;
|
|
10687
10740
|
this.max = 100;
|
|
10688
10741
|
this.step = 1;
|
|
@@ -10690,44 +10743,71 @@ var QtiSliderInteraction = class extends Interaction {
|
|
|
10690
10743
|
static {
|
|
10691
10744
|
this.styles = qti_slider_interaction_styles_default;
|
|
10692
10745
|
}
|
|
10746
|
+
/**
|
|
10747
|
+
* The value the slider shows, or `null` before there is one. A slider has no initial position of
|
|
10748
|
+
* its own (QTI 3): it starts at the response declaration's default, which reaches it through
|
|
10749
|
+
* `response` like any other value the item holds, or it starts empty.
|
|
10750
|
+
*/
|
|
10693
10751
|
#value;
|
|
10694
10752
|
validate() {
|
|
10695
10753
|
return true;
|
|
10696
10754
|
}
|
|
10697
10755
|
connectedCallback() {
|
|
10698
10756
|
super.connectedCallback();
|
|
10699
|
-
if (!this.hasAttribute("response")) {
|
|
10700
|
-
this.#updateValue(this.min);
|
|
10701
|
-
}
|
|
10702
10757
|
this.setAttribute("tabindex", "0");
|
|
10703
10758
|
this.setAttribute("role", "slider");
|
|
10704
10759
|
}
|
|
10760
|
+
willUpdate(changed) {
|
|
10761
|
+
super.willUpdate(changed);
|
|
10762
|
+
this._internals.ariaValueMin = String(this.min);
|
|
10763
|
+
this._internals.ariaValueMax = String(this.max);
|
|
10764
|
+
}
|
|
10765
|
+
/**
|
|
10766
|
+
* Shows the value without publishing it: it came from the item (a default or a restored answer) or
|
|
10767
|
+
* from the host, which hold it already. Only the candidate's input is published.
|
|
10768
|
+
*/
|
|
10705
10769
|
get response() {
|
|
10706
|
-
return this.#value.toString();
|
|
10770
|
+
return this.#value === null ? null : this.#value.toString();
|
|
10707
10771
|
}
|
|
10708
10772
|
set response(val) {
|
|
10709
|
-
if (val === null || val === "")
|
|
10773
|
+
if (val === null || val === void 0 || val === "") {
|
|
10774
|
+
this.#show(null);
|
|
10710
10775
|
return;
|
|
10776
|
+
}
|
|
10711
10777
|
const newValue = parseFloat(val);
|
|
10712
10778
|
if (!isNaN(newValue)) {
|
|
10713
|
-
this.#
|
|
10779
|
+
this.#show(newValue);
|
|
10714
10780
|
}
|
|
10715
10781
|
}
|
|
10716
10782
|
/** Extension hook for optional content rendered on the slider rail. */
|
|
10717
10783
|
renderRailSupplement() {
|
|
10718
10784
|
return nothing5;
|
|
10719
10785
|
}
|
|
10720
|
-
|
|
10786
|
+
/** Moves the knob to `newValue`, clamped to the bounds, or empties the slider. Returns whether it moved. */
|
|
10787
|
+
#show(newValue) {
|
|
10721
10788
|
const oldValue = this.#value;
|
|
10722
|
-
this.#value = Math.min(this.max, Math.max(this.min, newValue));
|
|
10789
|
+
this.#value = newValue === null ? null : Math.min(this.max, Math.max(this.min, newValue));
|
|
10723
10790
|
if (this.#value === oldValue) {
|
|
10724
|
-
return;
|
|
10791
|
+
return false;
|
|
10792
|
+
}
|
|
10793
|
+
if (this.#value === null) {
|
|
10794
|
+
this.style.removeProperty("--value-percentage");
|
|
10795
|
+
this._internals.setFormValue(null);
|
|
10796
|
+
this._internals.ariaValueNow = null;
|
|
10797
|
+
} else {
|
|
10798
|
+
const valuePercentage = (this.#value - this.min) / (this.max - this.min) * 100;
|
|
10799
|
+
this.style.setProperty("--value-percentage", `${valuePercentage}%`);
|
|
10800
|
+
this._internals.setFormValue(this.value);
|
|
10801
|
+
this._internals.ariaValueNow = String(this.#value);
|
|
10725
10802
|
}
|
|
10726
|
-
const valuePercentage = (this.#value - this.min) / (this.max - this.min) * 100;
|
|
10727
|
-
this.style.setProperty("--value-percentage", `${valuePercentage}%`);
|
|
10728
|
-
this._internals.setFormValue(this.value);
|
|
10729
|
-
this.saveResponse(this.response);
|
|
10730
10803
|
this.requestUpdate();
|
|
10804
|
+
return true;
|
|
10805
|
+
}
|
|
10806
|
+
/** The candidate's input: shows it and publishes it. */
|
|
10807
|
+
#commit(newValue) {
|
|
10808
|
+
if (this.#show(newValue)) {
|
|
10809
|
+
this.saveResponse(this.response);
|
|
10810
|
+
}
|
|
10731
10811
|
}
|
|
10732
10812
|
render() {
|
|
10733
10813
|
return html30`
|
|
@@ -10742,7 +10822,7 @@ var QtiSliderInteraction = class extends Interaction {
|
|
|
10742
10822
|
|
|
10743
10823
|
<div id="rail" part="rail" @mousedown=${this.#onMouseDown} @touchstart=${this.#onTouchStart}>
|
|
10744
10824
|
<div id="knob" part="knob">
|
|
10745
|
-
|
|
10825
|
+
${this.#value === null ? nothing5 : html30`<div id="value" part="value">${this.#value}</div>`}
|
|
10746
10826
|
</div>
|
|
10747
10827
|
|
|
10748
10828
|
${this.renderRailSupplement()}
|
|
@@ -10780,7 +10860,7 @@ var QtiSliderInteraction = class extends Interaction {
|
|
|
10780
10860
|
const diffX = pageX - railRect.left;
|
|
10781
10861
|
const percentage = Math.min(1, Math.max(0, diffX / railRect.width));
|
|
10782
10862
|
const steppedValue = this.min + Math.round(percentage * (this.max - this.min) / this.step) * this.step;
|
|
10783
|
-
this.#
|
|
10863
|
+
this.#commit(steppedValue);
|
|
10784
10864
|
}
|
|
10785
10865
|
#onDragEnd() {
|
|
10786
10866
|
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
@@ -11754,4 +11834,4 @@ export {
|
|
|
11754
11834
|
elements31 as elements21,
|
|
11755
11835
|
qtiInteractionElements
|
|
11756
11836
|
};
|
|
11757
|
-
//# sourceMappingURL=chunk-
|
|
11837
|
+
//# sourceMappingURL=chunk-CNFVA3AA.js.map
|