eat-js-sdk 2.0.29 → 2.0.31

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.
@@ -13649,6 +13649,9 @@ function CategoriseItem($$anchor, $$props) {
13649
13649
  let itemId = prop($$props, "itemId", 7), itemText = prop($$props, "itemText", 7), containerId = prop($$props, "containerId", 7), mode = prop($$props, "mode", 7), isSelected = prop($$props, "isSelected", 7, false), isLocked = prop($$props, "isLocked", 7, false), resultType = prop($$props, "resultType", 7, ""), hasAnyItemSelected = prop($$props, "hasAnyItemSelected", 7, false), isCurrentMobileItem = prop($$props, "isCurrentMobileItem", 7, true), isClonedItem = prop($$props, "isClonedItem", 7, false), isConsideredItem = prop($$props, "isConsideredItem", 7, false), currentTabContainer = prop($$props, "currentTabContainer", 7, null), additionalClasses = prop($$props, "additionalClasses", 7, ""), onclick = prop($$props, "onclick", 7), onkeydown = prop($$props, "onkeydown", 7);
13650
13650
  const ariaWord = useRemoveRichTextHtmlTags(itemText());
13651
13651
  const isWordBin = containerId() === CATEGORISE.CONTAINER_WORD_BIN_ID;
13652
+ let touchStartX = /* @__PURE__ */ state(0);
13653
+ let touchStartY = /* @__PURE__ */ state(0);
13654
+ let isDragging2 = /* @__PURE__ */ state(false);
13652
13655
  const ariaLabel = /* @__PURE__ */ user_derived(() => () => {
13653
13656
  if (resultType() === ANSWER_RESULTS.INCORRECT && isWordBin && !isSelected()) {
13654
13657
  return `Skipped answer: ${ariaWord}`;
@@ -13661,7 +13664,7 @@ function CategoriseItem($$anchor, $$props) {
13661
13664
  }
13662
13665
  return `${isSelected() ? "Selected option" : "Option"}: ${ariaWord}`;
13663
13666
  });
13664
- const handleClick = (event2) => {
13667
+ const selectItem = (event2) => {
13665
13668
  event2.stopPropagation();
13666
13669
  if (isLocked()) return;
13667
13670
  if (resultType() && mode() !== MODES.INTERACTIVE) return;
@@ -13670,6 +13673,28 @@ function CategoriseItem($$anchor, $$props) {
13670
13673
  onclick()();
13671
13674
  }
13672
13675
  };
13676
+ const handleTouchStart = (event2) => {
13677
+ set(isDragging2, false);
13678
+ if (event2.touches.length > 0) {
13679
+ set(touchStartX, event2.touches[0].clientX, true);
13680
+ set(touchStartY, event2.touches[0].clientY, true);
13681
+ }
13682
+ };
13683
+ const handleTouchMove = (event2) => {
13684
+ if (event2.touches.length > 0) {
13685
+ const deltaX = Math.abs(event2.touches[0].clientX - get$1(touchStartX));
13686
+ const deltaY = Math.abs(event2.touches[0].clientY - get$1(touchStartY));
13687
+ if (deltaX > 10 || deltaY > 10) {
13688
+ set(isDragging2, true);
13689
+ }
13690
+ }
13691
+ };
13692
+ const handleTouchEnd = (event2) => {
13693
+ if (!get$1(isDragging2)) {
13694
+ selectItem(event2);
13695
+ }
13696
+ set(isDragging2, false);
13697
+ };
13673
13698
  const handleKeyDown = (event2) => {
13674
13699
  if (event2.key === "Enter" || event2.key === "Escape") {
13675
13700
  event2.preventDefault();
@@ -13877,7 +13902,10 @@ function CategoriseItem($$anchor, $$props) {
13877
13902
  }
13878
13903
  };
13879
13904
  var button = root$6();
13880
- button.__click = handleClick;
13905
+ button.__click = selectItem;
13906
+ button.__touchstart = handleTouchStart;
13907
+ button.__touchmove = handleTouchMove;
13908
+ button.__touchend = handleTouchEnd;
13881
13909
  button.__keydown = handleKeyDown;
13882
13910
  var span = child(button);
13883
13911
  var node = child(span);
@@ -13991,7 +14019,7 @@ function CategoriseItem($$anchor, $$props) {
13991
14019
  append($$anchor, button);
13992
14020
  return pop($$exports);
13993
14021
  }
13994
- delegate(["click", "keydown"]);
14022
+ delegate(["click", "touchstart", "touchmove", "touchend", "keydown"]);
13995
14023
  create_custom_element(
13996
14024
  CategoriseItem,
13997
14025
  {
@@ -14116,9 +14144,7 @@ function CategoriseDndContainer($$anchor, $$props) {
14116
14144
  zoneItemTabIndex: get$1(getZoneItemTabIndex)(),
14117
14145
  zoneTabIndex: -1,
14118
14146
  autoAriaDisabled: true,
14119
- keyboardDisabled: true,
14120
- delayTouchStart: 30
14121
- // 30ms delay - quick enough for dragging, slow enough to detect clicks
14147
+ keyboardDisabled: true
14122
14148
  }));
14123
14149
  const isEmpty = /* @__PURE__ */ user_derived(() => get$1(dndItems).length === 0);
14124
14150
  const isSourceContainer = /* @__PURE__ */ user_derived(() => () => {
@@ -15259,11 +15285,7 @@ function CategoriseModal($$anchor, $$props) {
15259
15285
  const handleReset = () => {
15260
15286
  if (onreset()) onreset()();
15261
15287
  };
15262
- const modalData = /* @__PURE__ */ user_derived(() => ({
15263
- isModalOpen: isOpen(),
15264
- modalAriaLabel: "Reset words",
15265
- isOpenLastStatus: false
15266
- }));
15288
+ const modalData = /* @__PURE__ */ user_derived(() => ({ isModalOpen: isOpen(), modalAriaLabel: "Reset words" }));
15267
15289
  var $$exports = {
15268
15290
  get isOpen() {
15269
15291
  return isOpen();
@@ -15291,9 +15313,8 @@ function CategoriseModal($$anchor, $$props) {
15291
15313
  get modalData() {
15292
15314
  return get$1(modalData);
15293
15315
  },
15294
- onupdateModalSettings: () => {
15295
- },
15296
- modalClass: "bg-charcoal/30",
15316
+ modalClass: "bg-charcoal/30 pointer-events-none",
15317
+ onclose: handleClose,
15297
15318
  children: ($$anchor2, $$slotProps) => {
15298
15319
  var fragment_1 = root_1$5();
15299
15320
  var div = first_child(fragment_1);
@@ -16815,6 +16836,9 @@ function createDropdownState(initialValue) {
16815
16836
  const isAllAnswered$1 = (selections) => {
16816
16837
  return selections.every((item) => item.choice !== "" && item.choice !== "Select Answer");
16817
16838
  };
16839
+ const isAllSkipped = (selections) => {
16840
+ return selections.every((item) => item.choice === "");
16841
+ };
16818
16842
  const calculateAnswerResults = (config, selections) => {
16819
16843
  return selections.map((item) => {
16820
16844
  const correctAnswers = config.correctAnswer[item.id] || [];
@@ -16864,7 +16888,7 @@ function calculateDropdownFeedback(state2, config, validateFn) {
16864
16888
  sessionAnswer: getSessionAnswersForDisplay(selections)
16865
16889
  };
16866
16890
  }
16867
- const isSkipped = config.mode === MODES.SESSION && config.isFinished && !allAnswered;
16891
+ const isSkipped = isAllSkipped(selections);
16868
16892
  let validationResult = {
16869
16893
  isValid: false,
16870
16894
  feedback: ""
@@ -16874,7 +16898,7 @@ function calculateDropdownFeedback(state2, config, validateFn) {
16874
16898
  answer: selections,
16875
16899
  timestamp: state2.lastModified
16876
16900
  });
16877
- } else if (isSkipped) {
16901
+ } else if (config.mode === MODES.SESSION && config.isFinished && !allAnswered) {
16878
16902
  validationResult = {
16879
16903
  isValid: false,
16880
16904
  score: 0,
@@ -17699,10 +17723,11 @@ function DropdownFeedback($$anchor, $$props) {
17699
17723
  push($$props, true);
17700
17724
  let feedbackState = prop($$props, "feedbackState", 7), config = prop($$props, "config", 7), interactionType = prop($$props, "interactionType", 7);
17701
17725
  const alertType = /* @__PURE__ */ user_derived(() => {
17702
- if (feedbackState().isSkipped) return "incorrect";
17726
+ if (feedbackState().isSkipped) return "skipped";
17703
17727
  if (feedbackState().isAllCorrect) return "correct";
17704
17728
  return "incorrect";
17705
17729
  });
17730
+ const shouldShowAlert = /* @__PURE__ */ user_derived(() => !(config().mode === MODES.SESSION && config().isFinished && (feedbackState().isAllCorrect || feedbackState().isSkipped)));
17706
17731
  var $$exports = {
17707
17732
  get feedbackState() {
17708
17733
  return feedbackState();
@@ -17745,7 +17770,7 @@ function DropdownFeedback($$anchor, $$props) {
17745
17770
  });
17746
17771
  };
17747
17772
  if_block(node_1, ($$render) => {
17748
- if (!(MODES.SESSION === config().mode && config().isFinished && feedbackState().isAllCorrect)) $$render(consequent);
17773
+ if (get$1(shouldShowAlert)) $$render(consequent);
17749
17774
  });
17750
17775
  }
17751
17776
  var node_2 = sibling(node_1, 2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eat-js-sdk",
3
- "version": "2.0.29",
3
+ "version": "2.0.31",
4
4
  "change version": "2.0.0",
5
5
  "description": "Authoring tool frontend SDK",
6
6
  "contributors": [