eat-js-sdk 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7077,10 +7077,10 @@ function useImageModalSize() {
7077
7077
  };
7078
7078
  }
7079
7079
  var root_4$8 = /* @__PURE__ */ from_html(`<span class="w-6 h-6 flex items-center justify-center"><!></span>`);
7080
- var root_5$8 = /* @__PURE__ */ from_html(`<span class="w-6 h-6 flex items-center justify-center"><!></span>`);
7080
+ var root_5$9 = /* @__PURE__ */ from_html(`<span class="w-6 h-6 flex items-center justify-center"><!></span>`);
7081
7081
  var root_7$7 = /* @__PURE__ */ from_html(`<span class="sr-only"><!></span>`);
7082
7082
  var root_6$4 = /* @__PURE__ */ from_html(`<div><!> <span aria-hidden="true"><!></span></div>`);
7083
- var root_10$3 = /* @__PURE__ */ from_html(`<span class="w-4 h-4 flex items-center justify-center"><!></span>`);
7083
+ var root_10$4 = /* @__PURE__ */ from_html(`<span class="w-4 h-4 flex items-center justify-center"><!></span>`);
7084
7084
  var root_11$2 = /* @__PURE__ */ from_html(`<span class="w-4 h-4 flex items-center justify-center"><!></span>`);
7085
7085
  var root_2$f = /* @__PURE__ */ from_html(`<div class="absolute inset-0 m-0"><div class="w-full h-full px-0 md:px-[82px] lg:px-[128px] pt-14 pb-[72px] relative lg:py-24 flex flex-col items-center justify-center"><div aria-live="polite" aria-atomic="true" class="sr-only"><!> <!></div> <div class="w-full h-full flex flex-col md:flex-row md:justify-center items-center justify-between"><div class="md:hidden"></div> <!> <!> <div><div class="flex-shrink-0 flex items-center justify-between py-1 px-2 md:px-4 border-border-minimal border rounded-t-md lg:rounded-t-lg md:gap-4 h-8.5 md:h-fit"><!> <!> <!></div> <div class="rounded-b-md"><img class="mx-auto block rounded-b-md lg:rounded-b-lg object-contain max-w-full max-h-[calc(100vh-168px-34px)] md:max-h-[calc(100vh-128px-54px)] lg:max-h-[calc(100vh-192px-54px)] pointer-events-none"/></div></div> <div class="md:hidden flex justify-center items-center gap-1 flex-shrink-0 h-6 mt-4"><!> <!></div></div></div></div>`);
7086
7086
  function MCQImageModal($$anchor, $$props) {
@@ -7351,7 +7351,7 @@ function MCQImageModal($$anchor, $$props) {
7351
7351
  dataTestId: "img-viewer-next",
7352
7352
  onclick: navigateNext,
7353
7353
  children: ($$anchor4, $$slotProps2) => {
7354
- var span_1 = root_5$8();
7354
+ var span_1 = root_5$9();
7355
7355
  var node_6 = child(span_1);
7356
7356
  SvgLoader(node_6, {
7357
7357
  svgName: "smallChevronRight",
@@ -7473,7 +7473,7 @@ function MCQImageModal($$anchor, $$props) {
7473
7473
  dataTestId: "img-viewer-prev",
7474
7474
  onclick: navigatePrevious,
7475
7475
  children: ($$anchor4, $$slotProps2) => {
7476
- var span_4 = root_10$3();
7476
+ var span_4 = root_10$4();
7477
7477
  var node_14 = child(span_4);
7478
7478
  SvgLoader(node_14, {
7479
7479
  svgName: "smallChevronLeft",
@@ -7649,8 +7649,10 @@ function getStimulusTextMaxHeight(fileAlignment, stimulusTextAlignment, hasMedia
7649
7649
  const hasDefaultAlignment = hasMedia && fileAlignment === ALIGNMENT.DEFAULT || hasText && stimulusTextAlignment === ALIGNMENT.DEFAULT;
7650
7650
  return hasDefaultAlignment ? "max-h-[660px]" : "max-h-[470px]";
7651
7651
  }
7652
- function configureHtmlString(htmlString, maxHeight = "") {
7653
- return htmlString.replace(/<table>/g, `<div class="table-container ${maxHeight}" tabindex="0"><table>`).replace(/<\/table>/g, "</table></div>");
7652
+ function configureHtmlString(htmlString, maxHeight = "", tableAriaLabel) {
7653
+ const labelAttr = tableAriaLabel ? ` aria-label="${tableAriaLabel.replace(/"/g, "&quot;")}"` : "";
7654
+ const tableAriaHidden = tableAriaLabel ? ' aria-hidden="true"' : "";
7655
+ return htmlString.replace(/<table>/g, `<div class="table-container ${maxHeight}" tabindex="0"${labelAttr}><table${tableAriaHidden}>`).replace(/<\/table>/g, "</table></div>");
7654
7656
  }
7655
7657
  function PromptSection($$anchor, $$props) {
7656
7658
  push($$props, true);
@@ -7710,7 +7712,7 @@ function InteractionSection($$anchor, $$props) {
7710
7712
  return pop($$exports);
7711
7713
  }
7712
7714
  create_custom_element(InteractionSection, { children: {} }, [], [], true);
7713
- var root_5$7 = /* @__PURE__ */ from_html(`<div></div>`);
7715
+ var root_5$8 = /* @__PURE__ */ from_html(`<div></div>`);
7714
7716
  var root_4$7 = /* @__PURE__ */ from_html(`<div class="px-4 w-full max-w-[1008px] mx-auto flex-shrink-0 text-center font-semibold text-sm md:text-lg leading-[150%] text-white" aria-hidden="true" data-testid="img-viewer-cap-txt"> </div> <!>`, 1);
7715
7717
  var root_7$6 = /* @__PURE__ */ from_html(`<div></div>`);
7716
7718
  var root_2$e = /* @__PURE__ */ from_html(`<div class="absolute inset-0"><div class="w-full h-full flex items-center justify-center pt-14 pb-[72px] lg:py-24"><div aria-live="polite" aria-atomic="true" class="sr-only"> </div> <div class="flex flex-col items-center overflow-y-auto overflow-x-hidden w-full px-0 md:px-6 lg:px-16"><div class="relative bg-white rounded-md md:rounded-lg shadow-sm overflow-hidden flex-shrink-0"><img class="block object-contain w-full h-auto max-w-full mx-auto"/> <!></div> <!></div></div></div>`);
@@ -7884,7 +7886,7 @@ function PromptStimulusImageModal($$anchor, $$props) {
7884
7886
  var node_3 = sibling(div_5, 2);
7885
7887
  {
7886
7888
  var consequent = ($$anchor5) => {
7887
- var div_6 = root_5$7();
7889
+ var div_6 = root_5$8();
7888
7890
  template_effect(() => set_style(div_6, `height:${get$1(bottomSpacerHeight) ?? ""}px`));
7889
7891
  append($$anchor5, div_6);
7890
7892
  };
@@ -8367,7 +8369,7 @@ const shouldRenderSection = (section) => section.condition !== false;
8367
8369
  const getClassString = (classes = []) => classes.join(" ");
8368
8370
  const getStyleString = (styles = {}) => Object.entries(styles).map(([k, v]) => `${k}:${v}`).join(";");
8369
8371
  var root_4$6 = /* @__PURE__ */ from_html(`<p class="text-lg leading-[22px] text-blue-1000 font-semibold mt-4" data-testid="img-cap-txt"> </p>`);
8370
- var root_5$6 = /* @__PURE__ */ from_html(`<div class="mt-6 w-full"><button class="flex items-center font-semibold leading-[1.5] outline-none group w-fit h-11 text-charcoal" aria-controls="long-description-content" aria-labelledby="image-description-label" type="button"><div class="w-6 h-6 flex items-center justify-center mr-2" data-testid="img-desc-txt"><!></div> <div id="image-description-label" class="image-description-accordion group-[.active]:border-b-2">Image Description</div></button> <div id="long-description-content" data-testid="img-desc-txt"><!></div></div>`);
8372
+ var root_5$7 = /* @__PURE__ */ from_html(`<div class="mt-6 w-full"><button class="flex items-center font-semibold leading-[1.5] outline-none group w-fit h-11 text-charcoal" aria-controls="long-description-content" aria-labelledby="image-description-label" type="button"><div class="w-6 h-6 flex items-center justify-center mr-2" data-testid="img-desc-txt"><!></div> <div id="image-description-label" class="image-description-accordion group-[.active]:border-b-2">Image Description</div></button> <div id="long-description-content" data-testid="img-desc-txt"><!></div></div>`);
8371
8373
  var root_2$d = /* @__PURE__ */ from_html(`<div class="flex flex-col justify-center items-center text-center"><div class="flex flex-col items-center"><div class="relative inline-block"><img/> <!></div> <!></div></div> <!>`, 1);
8372
8374
  var root_1$j = /* @__PURE__ */ from_html(`<div class="w-full"><!></div>`);
8373
8375
  function CommonMedia($$anchor, $$props) {
@@ -8500,7 +8502,7 @@ function CommonMedia($$anchor, $$props) {
8500
8502
  var node_4 = sibling(div_1, 2);
8501
8503
  {
8502
8504
  var consequent_1 = ($$anchor4) => {
8503
- var div_4 = root_5$6();
8505
+ var div_4 = root_5$7();
8504
8506
  var button = child(div_4);
8505
8507
  button.__click = toggleLongDescription;
8506
8508
  button.__keydown = handleKeyDown;
@@ -8693,10 +8695,33 @@ function getTranscriptionSRText(html2) {
8693
8695
  return toTranscriptionReadableText(plain);
8694
8696
  }).replace(/<[^>]+>/g, "").replace(/&lt;\/?eat-transcription&gt;/gi, "").replace(/\s{2,}/g, " ").trim();
8695
8697
  }
8698
+ const STRUCTURAL_TAG_RE = /^(table|thead|tbody|tfoot|tr|th|td|caption|p|br|ul|ol|li|h[1-6]|blockquote)$/i;
8699
+ function getTranscriptionSRHtml(html2) {
8700
+ if (!html2) return "";
8701
+ const normalized = normalizeTranscriptionTags(html2);
8702
+ EAT_TRANSCRIPTION_RE.lastIndex = 0;
8703
+ let result = normalized.replace(EAT_TRANSCRIPTION_RE, (_full, content) => {
8704
+ let processed = content.replace(/<u>(.*?)<\/u>/gi, (_m, t2) => `stressed: ${t2.replace(/<[^>]+>/g, "").trim()}`);
8705
+ const plain = processed.replace(/<[^>]+>/g, "").trim();
8706
+ return toTranscriptionReadableText(plain);
8707
+ });
8708
+ result = result.replace(/&lt;\/?eat-transcription&gt;/gi, "");
8709
+ result = result.replace(/<(\/?)([a-zA-Z][a-zA-Z0-9]*)\b([^>]*)>/g, (_match, slash, tag, attrs) => {
8710
+ if (!STRUCTURAL_TAG_RE.test(tag)) return "";
8711
+ if (/^(th|td)$/i.test(tag) && !slash) {
8712
+ const safeAttrs = (attrs.match(/(?:scope|colspan|rowspan)="[^"]*"/gi) ?? []).join(" ");
8713
+ return `<${tag}${safeAttrs ? " " + safeAttrs : ""}>`;
8714
+ }
8715
+ return `<${slash}${tag}>`;
8716
+ });
8717
+ return result.replace(/<p>\s*<\/p>/g, "").replace(/\s{2,}/g, " ").trim();
8718
+ }
8719
+ var root_5$6 = /* @__PURE__ */ from_html(`<div class="sr-only"><!></div>`);
8696
8720
  var root_4$5 = /* @__PURE__ */ from_html(`<div data-testid="stimulus-txt-ctr"><!> <!></div>`);
8697
8721
  var root_6$3 = /* @__PURE__ */ from_html(`<div data-testid="stimulus-img-ctr"><!></div>`);
8698
8722
  var root_3$b = /* @__PURE__ */ from_html(`<!> <!>`, 1);
8699
8723
  var root_8$6 = /* @__PURE__ */ from_html(`<div data-testid="stimulus-img-ctr"><!></div>`);
8724
+ var root_10$3 = /* @__PURE__ */ from_html(`<div class="sr-only"><!></div>`);
8700
8725
  var root_9$4 = /* @__PURE__ */ from_html(`<div data-testid="stimulus-txt-ctr"><!> <!></div>`);
8701
8726
  var root_7$5 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
8702
8727
  var root_1$i = /* @__PURE__ */ from_html(`<div class="stimulus-section flex flex-col w-full"><!> <div><!></div></div>`);
@@ -8716,11 +8741,12 @@ function StimulusSection($$anchor, $$props) {
8716
8741
  let isInlineMedia = /* @__PURE__ */ user_derived(() => stimulusData().fileAlignment === ALIGNMENT.INLINE);
8717
8742
  let isInlineText = /* @__PURE__ */ user_derived(() => stimulusData().stimulusTextAlignment === ALIGNMENT.INLINE);
8718
8743
  let isTextFirst = /* @__PURE__ */ user_derived(() => stimulusData().stimulusLayoutOrder === LAYOUT_ORDER.TEXT_FIRST);
8719
- let configuredStimulusText = /* @__PURE__ */ user_derived(() => configureHtmlString(stimulusData().stimulusText, getStimulusTextMaxHeight(stimulusData().fileAlignment, stimulusData().stimulusTextAlignment, stimulusData().hasMedia, stimulusData().hasText)));
8720
- let configuredLongDescription = /* @__PURE__ */ user_derived(() => configureHtmlString(stimulusData().longDescription, getStimulusTextMaxHeight(stimulusData().fileAlignment, stimulusData().stimulusTextAlignment, stimulusData().hasMedia, stimulusData().hasText)));
8721
- const escapeHtml = (text2) => text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
8722
8744
  let hasTranscription = /* @__PURE__ */ user_derived(() => /&lt;eat-transcription&gt;/i.test(stimulusData().stimulusText ?? ""));
8723
- let stimulusSRText = /* @__PURE__ */ user_derived(() => get$1(hasTranscription) ? getTranscriptionSRText(stimulusData().stimulusText ?? "") : "");
8745
+ let stimulusSRText = /* @__PURE__ */ user_derived(() => get$1(hasTranscription) ? getTranscriptionSRText(stimulusData().stimulusText ?? "") : void 0);
8746
+ let configuredStimulusText = /* @__PURE__ */ user_derived(() => configureHtmlString(stimulusData().stimulusText, getStimulusTextMaxHeight(stimulusData().fileAlignment, stimulusData().stimulusTextAlignment, stimulusData().hasMedia, stimulusData().hasText), get$1(stimulusSRText)));
8747
+ let configuredLongDescription = /* @__PURE__ */ user_derived(() => configureHtmlString(stimulusData().longDescription, getStimulusTextMaxHeight(stimulusData().fileAlignment, stimulusData().stimulusTextAlignment, stimulusData().hasMedia, stimulusData().hasText)));
8748
+ const { segmentAndAnnotate } = useLanguageAnnotator();
8749
+ let stimulusSRHtml = /* @__PURE__ */ user_derived(() => get$1(hasTranscription) ? segmentAndAnnotate(getTranscriptionSRHtml(stimulusData().stimulusText ?? "")) : "");
8724
8750
  const shouldShowText = /* @__PURE__ */ user_derived(() => stimulusData().hasText && (stimulusData().stimulusTextAlignment === stimulusAlignment() || stimulusData().stimulusTextAlignment !== stimulusAlignment() && windowWidth.value < BREAKPOINTS.LG) && (!stimulusType() || stimulusType() === "stimulus-text"));
8725
8751
  const shouldShowMedia = /* @__PURE__ */ user_derived(() => stimulusData().hasMedia && (stimulusData().fileAlignment === stimulusAlignment() || stimulusData().fileAlignment !== stimulusAlignment() && windowWidth.value < BREAKPOINTS.LG) && (!stimulusType() || stimulusType() === "stimulus-media"));
8726
8752
  let textContainerClass = /* @__PURE__ */ user_derived(() => `stimulus-text ${get$1(isInlineText) ? "inline-text" : "block-text"}`);
@@ -8810,36 +8836,31 @@ function StimulusSection($$anchor, $$props) {
8810
8836
  var node_5 = sibling(node_4, 2);
8811
8837
  {
8812
8838
  var consequent_1 = ($$anchor5) => {
8813
- {
8814
- let $0 = /* @__PURE__ */ user_derived(() => escapeHtml(get$1(stimulusSRText)));
8815
- CommonStringToHtml($$anchor5, {
8816
- get htmlString() {
8817
- return get$1($0);
8818
- },
8819
- otherClass: "sr-only",
8820
- tag: "span"
8821
- });
8822
- }
8839
+ var div_3 = root_5$6();
8840
+ var node_6 = child(div_3);
8841
+ html(node_6, () => get$1(stimulusSRHtml));
8842
+ reset(div_3);
8843
+ append($$anchor5, div_3);
8823
8844
  };
8824
8845
  if_block(node_5, ($$render) => {
8825
8846
  if (get$1(hasTranscription)) $$render(consequent_1);
8826
8847
  });
8827
8848
  }
8828
8849
  reset(div_2);
8829
- template_effect(() => set_class(div_2, 1, `stimulus-txt-ctr ${get$1(textContainerClass) ?? ""}`));
8850
+ template_effect(() => set_class(div_2, 1, `relative stimulus-txt-ctr ${get$1(textContainerClass) ?? ""}`));
8830
8851
  append($$anchor4, div_2);
8831
8852
  };
8832
8853
  if_block(node_3, ($$render) => {
8833
8854
  if (get$1(shouldShowText)) $$render(consequent_2);
8834
8855
  });
8835
8856
  }
8836
- var node_6 = sibling(node_3, 2);
8857
+ var node_7 = sibling(node_3, 2);
8837
8858
  {
8838
8859
  var consequent_3 = ($$anchor4) => {
8839
- var div_3 = root_6$3();
8860
+ var div_4 = root_6$3();
8840
8861
  let classes_2;
8841
- var node_7 = child(div_3);
8842
- CommonMedia(node_7, {
8862
+ var node_8 = child(div_4);
8863
+ CommonMedia(node_8, {
8843
8864
  get fileUrl() {
8844
8865
  return stimulusData().fileUrl;
8845
8866
  },
@@ -8860,25 +8881,25 @@ function StimulusSection($$anchor, $$props) {
8860
8881
  return onexpandImage();
8861
8882
  }
8862
8883
  });
8863
- reset(div_3);
8864
- template_effect(() => classes_2 = set_class(div_3, 1, `stimulus-img-ctr ${get$1(mediaContainerClass) ?? ""}`, null, classes_2, { hidden: !get$1(shouldShowMedia) }));
8865
- append($$anchor4, div_3);
8884
+ reset(div_4);
8885
+ template_effect(() => classes_2 = set_class(div_4, 1, `stimulus-img-ctr ${get$1(mediaContainerClass) ?? ""}`, null, classes_2, { hidden: !get$1(shouldShowMedia) }));
8886
+ append($$anchor4, div_4);
8866
8887
  };
8867
- if_block(node_6, ($$render) => {
8888
+ if_block(node_7, ($$render) => {
8868
8889
  if (stimulusData().hasMedia) $$render(consequent_3);
8869
8890
  });
8870
8891
  }
8871
8892
  append($$anchor3, fragment_2);
8872
8893
  };
8873
8894
  var alternate = ($$anchor3) => {
8874
- var fragment_4 = root_7$5();
8875
- var node_8 = first_child(fragment_4);
8895
+ var fragment_3 = root_7$5();
8896
+ var node_9 = first_child(fragment_3);
8876
8897
  {
8877
8898
  var consequent_5 = ($$anchor4) => {
8878
- var div_4 = root_8$6();
8899
+ var div_5 = root_8$6();
8879
8900
  let classes_3;
8880
- var node_9 = child(div_4);
8881
- CommonMedia(node_9, {
8901
+ var node_10 = child(div_5);
8902
+ CommonMedia(node_10, {
8882
8903
  get fileUrl() {
8883
8904
  return stimulusData().fileUrl;
8884
8905
  },
@@ -8899,20 +8920,20 @@ function StimulusSection($$anchor, $$props) {
8899
8920
  return onexpandImage();
8900
8921
  }
8901
8922
  });
8902
- reset(div_4);
8903
- template_effect(() => classes_3 = set_class(div_4, 1, `stimulus-img-ctr ${get$1(mediaContainerClass) ?? ""}`, null, classes_3, { hidden: !get$1(shouldShowMedia) }));
8904
- append($$anchor4, div_4);
8923
+ reset(div_5);
8924
+ template_effect(() => classes_3 = set_class(div_5, 1, `stimulus-img-ctr ${get$1(mediaContainerClass) ?? ""}`, null, classes_3, { hidden: !get$1(shouldShowMedia) }));
8925
+ append($$anchor4, div_5);
8905
8926
  };
8906
- if_block(node_8, ($$render) => {
8927
+ if_block(node_9, ($$render) => {
8907
8928
  if (stimulusData().hasMedia) $$render(consequent_5);
8908
8929
  });
8909
8930
  }
8910
- var node_10 = sibling(node_8, 2);
8931
+ var node_11 = sibling(node_9, 2);
8911
8932
  {
8912
8933
  var consequent_7 = ($$anchor4) => {
8913
- var div_5 = root_9$4();
8914
- var node_11 = child(div_5);
8915
- CommonStringToHtml(node_11, {
8934
+ var div_6 = root_9$4();
8935
+ var node_12 = child(div_6);
8936
+ CommonStringToHtml(node_12, {
8916
8937
  get htmlString() {
8917
8938
  return get$1(configuredStimulusText);
8918
8939
  },
@@ -8923,33 +8944,28 @@ function StimulusSection($$anchor, $$props) {
8923
8944
  return get$1(hasTranscription);
8924
8945
  }
8925
8946
  });
8926
- var node_12 = sibling(node_11, 2);
8947
+ var node_13 = sibling(node_12, 2);
8927
8948
  {
8928
8949
  var consequent_6 = ($$anchor5) => {
8929
- {
8930
- let $0 = /* @__PURE__ */ user_derived(() => escapeHtml(get$1(stimulusSRText)));
8931
- CommonStringToHtml($$anchor5, {
8932
- get htmlString() {
8933
- return get$1($0);
8934
- },
8935
- otherClass: "sr-only",
8936
- tag: "span"
8937
- });
8938
- }
8950
+ var div_7 = root_10$3();
8951
+ var node_14 = child(div_7);
8952
+ html(node_14, () => get$1(stimulusSRHtml));
8953
+ reset(div_7);
8954
+ append($$anchor5, div_7);
8939
8955
  };
8940
- if_block(node_12, ($$render) => {
8956
+ if_block(node_13, ($$render) => {
8941
8957
  if (get$1(hasTranscription)) $$render(consequent_6);
8942
8958
  });
8943
8959
  }
8944
- reset(div_5);
8945
- template_effect(() => set_class(div_5, 1, `stimulus-txt-ctr ${get$1(textContainerClass) ?? ""}`));
8946
- append($$anchor4, div_5);
8960
+ reset(div_6);
8961
+ template_effect(() => set_class(div_6, 1, `relative stimulus-txt-ctr ${get$1(textContainerClass) ?? ""}`));
8962
+ append($$anchor4, div_6);
8947
8963
  };
8948
- if_block(node_10, ($$render) => {
8964
+ if_block(node_11, ($$render) => {
8949
8965
  if (get$1(shouldShowText)) $$render(consequent_7);
8950
8966
  });
8951
8967
  }
8952
- append($$anchor3, fragment_4);
8968
+ append($$anchor3, fragment_3);
8953
8969
  };
8954
8970
  if_block(node_2, ($$render) => {
8955
8971
  if (get$1(isTextFirst)) $$render(consequent_4);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eat-js-sdk",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "change version": "2.7.0",
5
5
  "description": "Authoring tool frontend SDK",
6
6
  "contributors": [