eat-js-sdk 2.2.19 → 2.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/interaction-builder.mjs +14 -21
- package/package.json +1 -1
|
@@ -19670,13 +19670,14 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
19670
19670
|
return stripTags2(s.text) + (s.trailingPunctuation ?? "");
|
|
19671
19671
|
}).join(" ").replace(/\s+/g, " ").trim());
|
|
19672
19672
|
let passageReaderLabel = /* @__PURE__ */ user_derived(() => `${get$1(passagePlainText)}`);
|
|
19673
|
-
const getSegmentAriaLabel = (segment, seg) => {
|
|
19673
|
+
const getSegmentAriaLabel = (segment, seg, segmentId) => {
|
|
19674
19674
|
const text = stripTags2(segment.text);
|
|
19675
19675
|
const parts = [`Option: ${text}`];
|
|
19676
19676
|
if (seg.isCorrect) parts.push("correct");
|
|
19677
19677
|
else if (seg.isIncorrect) parts.push("incorrect");
|
|
19678
19678
|
else if (seg.isMissing) parts.push("missing answer");
|
|
19679
19679
|
else if (seg.isSegmentSelected) parts.push("selected");
|
|
19680
|
+
else if (deselectedIds.has(segmentId)) parts.push("unselected");
|
|
19680
19681
|
return parts.length > 1 ? `${parts[0]} (${parts.slice(1).join(", ")})` : parts[0];
|
|
19681
19682
|
};
|
|
19682
19683
|
const handleSegmentClick = (segmentId, refocus = false) => {
|
|
@@ -19689,6 +19690,12 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
19689
19690
|
}
|
|
19690
19691
|
return;
|
|
19691
19692
|
}
|
|
19693
|
+
const currentSeg = get$1(segmentStates).find((s) => s.segment.id === segmentId)?.seg;
|
|
19694
|
+
if (currentSeg?.isSegmentSelected) {
|
|
19695
|
+
deselectedIds.add(segmentId);
|
|
19696
|
+
} else {
|
|
19697
|
+
deselectedIds.delete(segmentId);
|
|
19698
|
+
}
|
|
19692
19699
|
onselection()?.(new CustomEvent("selection", { detail: { segmentId } }));
|
|
19693
19700
|
if (refocus) {
|
|
19694
19701
|
tick().then(() => {
|
|
@@ -19709,9 +19716,10 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
19709
19716
|
const focusSegment = (el) => {
|
|
19710
19717
|
el?.focus();
|
|
19711
19718
|
};
|
|
19712
|
-
const handleSegmentFocus = (
|
|
19719
|
+
const handleSegmentFocus = (segmentId) => {
|
|
19713
19720
|
set(exitSegmentId, null);
|
|
19714
19721
|
if (!get$1(passageMode)) set(passageMode, true);
|
|
19722
|
+
deselectedIds.delete(segmentId);
|
|
19715
19723
|
};
|
|
19716
19724
|
const handleSegmentKeydown = (e2, segmentId) => {
|
|
19717
19725
|
set(
|
|
@@ -19721,21 +19729,7 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
19721
19729
|
);
|
|
19722
19730
|
const focusable = getFocusableSegments();
|
|
19723
19731
|
const posInDom = focusable.findIndex((el) => el.dataset.segmentId === segmentId);
|
|
19724
|
-
if (e2.key === "
|
|
19725
|
-
e2.preventDefault();
|
|
19726
|
-
suppressAutoJump = true;
|
|
19727
|
-
set(passageMode, true);
|
|
19728
|
-
get$1(passageEl)?.focus();
|
|
19729
|
-
setTimeout(
|
|
19730
|
-
() => {
|
|
19731
|
-
suppressAutoJump = false;
|
|
19732
|
-
const firstSeg = getFocusableSegments()[0];
|
|
19733
|
-
firstSeg?.focus();
|
|
19734
|
-
},
|
|
19735
|
-
400
|
|
19736
|
-
);
|
|
19737
|
-
return;
|
|
19738
|
-
} else if (e2.key === " ") {
|
|
19732
|
+
if (e2.key === " ") {
|
|
19739
19733
|
e2.preventDefault();
|
|
19740
19734
|
if (!get$1(sharedState).isPreviewMode) handleSegmentClick(segmentId, true);
|
|
19741
19735
|
} else if (e2.key === "Enter") {
|
|
@@ -19776,6 +19770,7 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
19776
19770
|
].filter(Boolean).join(" ");
|
|
19777
19771
|
};
|
|
19778
19772
|
let pinnedTooltipIds = new SvelteSet();
|
|
19773
|
+
let deselectedIds = new SvelteSet();
|
|
19779
19774
|
let leavingViaLastSegmentTab = false;
|
|
19780
19775
|
const handlePassageFocusOut = (e2) => {
|
|
19781
19776
|
if (leavingViaLastSegmentTab) {
|
|
@@ -19787,9 +19782,7 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
19787
19782
|
set(passageMode, false);
|
|
19788
19783
|
}
|
|
19789
19784
|
};
|
|
19790
|
-
let suppressAutoJump = false;
|
|
19791
19785
|
const handleMainFocus = () => {
|
|
19792
|
-
if (suppressAutoJump) return;
|
|
19793
19786
|
requestAnimationFrame(() => {
|
|
19794
19787
|
const firstSeg = getFocusableSegments()[0];
|
|
19795
19788
|
if (firstSeg) {
|
|
@@ -20243,14 +20236,14 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
20243
20236
|
set_class(span_6, 1, `${$0 ?? ""}${$1 ?? ""}`);
|
|
20244
20237
|
set_attribute(span_6, "aria-label", $2);
|
|
20245
20238
|
set_attribute(span_6, "aria-selected", get$1(computed_const).seg.isSegmentSelected && !get$1(sharedState).isPreviewMode ? true : void 0);
|
|
20246
|
-
set_attribute(span_6, "aria-disabled",
|
|
20239
|
+
set_attribute(span_6, "aria-disabled", get$1(sharedState).isPreviewMode || get$1(isSessionLocked));
|
|
20247
20240
|
set_attribute(span_6, "data-segment-id", get$1(segment).id);
|
|
20248
20241
|
set_attribute(span_6, "data-testid", $3);
|
|
20249
20242
|
},
|
|
20250
20243
|
[
|
|
20251
20244
|
() => getSegmentClasses(get$1(computed_const).seg, get$1(isSessionLocked)),
|
|
20252
20245
|
() => pinnedTooltipIds.has(get$1(segment).id) ? " tooltip-pinned" : "",
|
|
20253
|
-
() => getSegmentAriaLabel(get$1(segment), get$1(computed_const).seg),
|
|
20246
|
+
() => getSegmentAriaLabel(get$1(segment), get$1(computed_const).seg, get$1(segment).id),
|
|
20254
20247
|
() => getSegmentTestId(get$1(computed_const).seg)
|
|
20255
20248
|
]
|
|
20256
20249
|
);
|