lido-player 0.0.2-alpha-59-dev → 0.0.2-alpha-61

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.
Files changed (116) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/lido-avatar_22.cjs.entry.js +73 -29
  3. package/dist/cjs/lido-player.cjs.js +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/{utils-03573882.js → utils-9cf49b55.js} +121 -58
  6. package/dist/collection/components/container/lido-container.js +24 -19
  7. package/dist/collection/components/home/lido-home.js +4 -4
  8. package/dist/collection/components/root/lido-root.js +5 -5
  9. package/dist/collection/components/text/lido-text.js +3 -2
  10. package/dist/collection/stories/Templates/balancing/balancing.stories.js +1 -1
  11. package/dist/collection/stories/Templates/imageMatch/imageMatch.stories.js +80 -0
  12. package/dist/collection/stories/Templates/numberIdentification/numberIdentificationimageTotext.stories.js +9 -7
  13. package/dist/collection/stories/Templates/numberIdentification/numberIdentificationtextTotext.stories.js +8 -6
  14. package/dist/collection/stories/Templates/palEgmaCalculateSum/palEgmaMultiOption.stories.js +3 -3
  15. package/dist/collection/stories/Templates/palEgmaCalculateSum/palEgmaSumTogether.stories.js +3 -5
  16. package/dist/collection/stories/Templates/palEgmaPatternMatching/palEgmaPatternMatching.stories.js +31 -18
  17. package/dist/collection/stories/Templates/palEgmaWordProblem/palEgmaWordProblem.stories.js +5 -5
  18. package/dist/collection/stories/Templates/palEgraInventedSpelling/pal_egra_invented_spelling_schema.stories.js +10 -7
  19. package/dist/collection/stories/Templates/palEgraMCQWithImage/palEgraMCQWithImage.stories.js +10 -6
  20. package/dist/collection/stories/Templates/palEgraOptionWithAudio/palEgraOptionWithAudio.stories.js +103 -0
  21. package/dist/collection/stories/Templates/palEgraStoryMaking/pal_egra_story_making.stories.js +8 -8
  22. package/dist/collection/stories/Templates/palEgraTemplate1/palEgraLetterIdentification.stories.js +17 -10
  23. package/dist/collection/stories/Templates/palEgraWordMatch/palEgraWordMatch.stories.js +97 -0
  24. package/dist/collection/stories/Templates/palEgra_OddOneOut/palEgra_oddOneOut.stories.js +6 -6
  25. package/dist/collection/stories/Templates/palEgra_arrange_pictures/palEgra_arrange_pictures.stories.js +75 -0
  26. package/dist/collection/stories/Templates/palEgra_build_word/palEgra_build_word.stories.js +77 -0
  27. package/dist/collection/stories/Templates/palEgra_word_formation/palEgra_WordFormation.stories.js +22 -19
  28. package/dist/collection/stories/Templates/palStorytale/palStorytale.stories.js +35 -0
  29. package/dist/collection/stories/Templates/pictureClues/pictureClues.stories.js +10 -10
  30. package/dist/collection/stories/Templates/pictureWordMatch/pictureWordMatch1.stories.js +13 -13
  31. package/dist/collection/stories/Templates/pictureWordMatch/pictureWordMatch2.stories.js +9 -9
  32. package/dist/collection/stories/Templates/sentenceMatch/sentenceMatch.stories.js +63 -0
  33. package/dist/collection/stories/Templates/substraction/substractionWithimg.stories.js +7 -7
  34. package/dist/collection/stories/Templates/substraction/substractionWithoutImg.stories.js +13 -13
  35. package/dist/collection/stories/Templates/wordBuilding/wordBuildingwithimg.stories.js +7 -7
  36. package/dist/collection/stories/Templates/wordBuilding/wordBuildingwithoutimg.stories.js +1 -1
  37. package/dist/collection/stories/Templates/writeSet/writeSet.stories.js +6 -5
  38. package/dist/collection/utils/audioPlayer.js +10 -0
  39. package/dist/collection/utils/customEvents.js +2 -1
  40. package/dist/collection/utils/i18n.js +2 -0
  41. package/dist/collection/utils/utils.js +4 -11
  42. package/dist/collection/utils/utilsHandlers/clickHandler.js +12 -7
  43. package/dist/collection/utils/utilsHandlers/dragDropHandler.js +27 -53
  44. package/dist/collection/utils/utilsHandlers/highlightHandler.js +2 -2
  45. package/dist/collection/utils/utilsHandlers/lidoBalanceHandler.js +4 -5
  46. package/dist/collection/utils/utilsHandlers/timer.js +53 -0
  47. package/dist/components/index.js +1 -1
  48. package/dist/components/lido-avatar.js +1 -1
  49. package/dist/components/lido-balance.js +1 -1
  50. package/dist/components/lido-calculator.js +1 -1
  51. package/dist/components/lido-canvas.js +1 -1
  52. package/dist/components/lido-cell.js +1 -1
  53. package/dist/components/lido-col.js +1 -1
  54. package/dist/components/lido-container.js +1 -1
  55. package/dist/components/lido-flash-card.js +1 -1
  56. package/dist/components/lido-float.js +1 -1
  57. package/dist/components/lido-home.js +1 -1
  58. package/dist/components/lido-image.js +1 -1
  59. package/dist/components/lido-keyboard.js +1 -1
  60. package/dist/components/lido-math-matrix.js +1 -1
  61. package/dist/components/lido-pos.js +1 -1
  62. package/dist/components/lido-random.js +1 -1
  63. package/dist/components/lido-root.js +27 -27
  64. package/dist/components/lido-row.js +1 -1
  65. package/dist/components/lido-shape.js +1 -1
  66. package/dist/components/lido-slide-fill.js +1 -1
  67. package/dist/components/lido-text.js +1 -1
  68. package/dist/components/lido-trace.js +1 -1
  69. package/dist/components/lido-wrap.js +1 -1
  70. package/dist/components/{p-ad0f335e.js → p-0f54f212.js} +2 -2
  71. package/dist/components/{p-33b83222.js → p-16a6a6f6.js} +1 -1
  72. package/dist/components/{p-5c990168.js → p-27bfb88f.js} +25 -21
  73. package/dist/components/{p-6bbad90f.js → p-2b0ef6d4.js} +1 -1
  74. package/dist/components/{p-5aa24314.js → p-2ce1503f.js} +1 -1
  75. package/dist/components/{p-6819005f.js → p-2fedf56d.js} +1 -1
  76. package/dist/components/{p-356e56bd.js → p-3c9dd098.js} +1 -1
  77. package/dist/components/{p-3513b1f3.js → p-40afd35f.js} +121 -59
  78. package/dist/components/{p-f9426cbe.js → p-4a1af1bb.js} +1 -1
  79. package/dist/components/{p-4d9462ab.js → p-4c1d15df.js} +2 -2
  80. package/dist/components/{p-e8e9250e.js → p-4ec94e44.js} +1 -1
  81. package/dist/components/{p-d9b17242.js → p-572f8490.js} +1 -1
  82. package/dist/components/{p-84302365.js → p-6bee9883.js} +1 -1
  83. package/dist/components/{p-99fcbae4.js → p-76947363.js} +1 -1
  84. package/dist/components/{p-73e4bb01.js → p-8632f479.js} +25 -25
  85. package/dist/components/{p-aff68c41.js → p-97ca067d.js} +3 -3
  86. package/dist/components/{p-de62d08e.js → p-be063cbd.js} +1 -1
  87. package/dist/components/{p-9b35082a.js → p-d28496a9.js} +1 -1
  88. package/dist/components/{p-f238004e.js → p-df6042b0.js} +1 -1
  89. package/dist/components/{p-5eeaccab.js → p-dfa70e99.js} +1 -1
  90. package/dist/components/{p-2bb1f74d.js → p-e4b71ba1.js} +47 -7
  91. package/dist/components/{p-49ccf573.js → p-f241ab97.js} +1 -1
  92. package/dist/esm/index.js +1 -1
  93. package/dist/esm/lido-avatar_22.entry.js +73 -29
  94. package/dist/esm/lido-player.js +1 -1
  95. package/dist/esm/loader.js +1 -1
  96. package/dist/esm/{utils-3995d2d5.js → utils-01d6cbb5.js} +121 -59
  97. package/dist/lido-player/index.esm.js +1 -1
  98. package/dist/lido-player/lido-player.esm.js +1 -1
  99. package/dist/lido-player/{p-aee89fba.js → p-c5ca9462.js} +2 -2
  100. package/dist/lido-player/p-e4d5dabf.entry.js +1 -0
  101. package/dist/types/components/container/lido-container.d.ts +1 -1
  102. package/dist/types/components/home/lido-home.d.ts +1 -1
  103. package/dist/types/components/root/lido-root.d.ts +1 -1
  104. package/dist/types/components.d.ts +24 -24
  105. package/dist/types/stories/Templates/imageMatch/imageMatch.stories.d.ts +4 -0
  106. package/dist/types/stories/Templates/palEgraOptionWithAudio/palEgraOptionWithAudio.stories.d.ts +4 -0
  107. package/dist/types/stories/Templates/palEgraWordMatch/palEgraWordMatch.stories.d.ts +4 -0
  108. package/dist/types/stories/Templates/palEgra_arrange_pictures/palEgra_arrange_pictures.stories.d.ts +4 -0
  109. package/dist/types/stories/Templates/palEgra_build_word/palEgra_build_word.stories.d.ts +4 -0
  110. package/dist/types/stories/Templates/palStorytale/palStorytale.stories.d.ts +4 -0
  111. package/dist/types/stories/Templates/sentenceMatch/sentenceMatch.stories.d.ts +4 -0
  112. package/dist/types/utils/audioPlayer.d.ts +1 -0
  113. package/dist/types/utils/constants.d.ts +4 -5
  114. package/dist/types/utils/utilsHandlers/timer.d.ts +14 -0
  115. package/package.json +1 -1
  116. package/dist/lido-player/p-75daccb0.entry.js +0 -1
@@ -55,6 +55,60 @@ const nextUrl = 'https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/publ
55
55
  const speakUrl = 'https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/Navbar-buttons/audio.png';
56
56
  const fingerUrl = 'https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/trace/Tracing-hand.svg';
57
57
 
58
+ class Timer {
59
+ constructor() {
60
+ this.startTime = 0;
61
+ this.elapsedTime = 0;
62
+ this.intervalId = null;
63
+ }
64
+ static getI(onTick) {
65
+ if (!Timer.instance) {
66
+ Timer.instance = new Timer();
67
+ }
68
+ if (onTick) {
69
+ Timer.instance.onTick = onTick;
70
+ }
71
+ return Timer.instance;
72
+ }
73
+ start() {
74
+ if (this.intervalId)
75
+ return;
76
+ this.startTime = Date.now() - this.elapsedTime;
77
+ this.intervalId = window.setInterval(() => {
78
+ var _a;
79
+ this.elapsedTime = Date.now() - this.startTime;
80
+ (_a = this.onTick) === null || _a === void 0 ? void 0 : _a.call(this, this.elapsedTime);
81
+ }, 1000);
82
+ }
83
+ pause() {
84
+ if (!this.intervalId)
85
+ return;
86
+ clearInterval(this.intervalId);
87
+ this.intervalId = null;
88
+ this.elapsedTime = Date.now() - this.startTime;
89
+ }
90
+ resume() {
91
+ if (this.intervalId)
92
+ return;
93
+ this.start();
94
+ }
95
+ stop() {
96
+ var _a;
97
+ if (this.intervalId) {
98
+ clearInterval(this.intervalId);
99
+ this.intervalId = null;
100
+ }
101
+ this.startTime = 0;
102
+ this.elapsedTime = 0;
103
+ (_a = this.onTick) === null || _a === void 0 ? void 0 : _a.call(this, 0);
104
+ }
105
+ getElapsed() {
106
+ return this.intervalId
107
+ ? Date.now() - this.startTime
108
+ : this.elapsedTime;
109
+ }
110
+ }
111
+
58
112
  function dispatchCustomEvent(eventName, detail) {
59
113
  console.log("👍Event Name : ", eventName, "Detail : ", detail.toString());
60
114
  const event = new CustomEvent(eventName, { detail });
@@ -64,7 +118,7 @@ function dispatchActivityEndEvent(index, totalIndex, score) {
64
118
  dispatchCustomEvent(ActivityEndKey, { index, totalIndex, score });
65
119
  }
66
120
  function dispatchLessonEndEvent(score) {
67
- dispatchCustomEvent(LessonEndKey, { score });
121
+ dispatchCustomEvent(LessonEndKey, { score, timeSpent: Math.floor(Timer.getI().getElapsed() / 1000) });
68
122
  }
69
123
  function dispatchNextContainerEvent() {
70
124
  dispatchCustomEvent(NextContainerKey, {});
@@ -120,7 +174,7 @@ function updateBalanceOnDrop(dragElement, dropElement) {
120
174
  }
121
175
  function calculateValue(elements, operation) {
122
176
  if (elements.length === 0)
123
- return 0;
177
+ return null;
124
178
  if (operation === "count") {
125
179
  return elements.length;
126
180
  }
@@ -152,18 +206,15 @@ function calculateValue(elements, operation) {
152
206
  }
153
207
  }
154
208
  function balanceResult(container, objectiveString) {
155
- var _a, _b, _c, _d, _e, _f;
156
209
  const additionalCheck = container.getAttribute('equationCheck');
157
210
  if (!additionalCheck)
158
211
  return false;
159
212
  const balanceEl = document.querySelector('lido-balance');
160
213
  if (!balanceEl)
161
214
  return false;
162
- const leftVal = Number((_c = (_a = balanceEl.leftVal) !== null && _a !== void 0 ? _a : (_b = balanceEl.dataset) === null || _b === void 0 ? void 0 : _b.leftVal) !== null && _c !== void 0 ? _c : 0);
163
- const rightVal = Number((_f = (_d = balanceEl.rightVal) !== null && _d !== void 0 ? _d : (_e = balanceEl.dataset) === null || _e === void 0 ? void 0 : _e.rightVal) !== null && _f !== void 0 ? _f : 0);
164
- const hasLeft = !isNaN(leftVal);
165
- const hasRight = !isNaN(rightVal);
166
- if (!hasLeft || !hasRight) {
215
+ const leftVal = balanceEl.leftVal;
216
+ const rightVal = balanceEl.rightVal;
217
+ if (leftVal == null || rightVal == null) {
167
218
  return false;
168
219
  }
169
220
  const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
@@ -291,6 +342,7 @@ function enableDraggingWithScaling(element) {
291
342
  handlingElementFlexibleWidth(element, 'drag');
292
343
  const onStart = (event) => {
293
344
  var _a, _b;
345
+ console.log("moving start");
294
346
  if (isDraggingDisabled) {
295
347
  isDragging = false;
296
348
  return;
@@ -434,22 +486,24 @@ function enableDraggingWithScaling(element) {
434
486
  const storedTabIndexes = Object.keys(dropObject).map(Number);
435
487
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
436
488
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
437
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
438
- if (otherElement.tagName.toLowerCase() === 'lido-image') {
439
- otherElement.style.opacity = '0';
489
+ if (otherElement) {
490
+ otherElement.style.opacity = "0.3";
440
491
  }
441
492
  }
442
493
  }
443
494
  else {
444
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
445
- if (otherElement.tagName.toLowerCase() === 'lido-image' || 'lido-cell') {
446
- otherElement.style.opacity = '1';
495
+ if (otherElement) {
496
+ otherElement.style.opacity = "1";
447
497
  }
448
498
  }
449
499
  });
450
500
  // Apply styles only to the most overlapped element
451
501
  if (mostOverlappedElement) {
452
- if (mostOverlappedElement.tagName.toLowerCase() === 'lido-text') ;
502
+ if (mostOverlappedElement.tagName.toLowerCase() === 'lido-text') {
503
+ // mostOverlappedElement.style.border = '2px dashed #ff0000'; // Red dashed border
504
+ // mostOverlappedElement.style.backgroundColor = 'rgba(255, 0, 0, 0.1)'; // Light red background
505
+ mostOverlappedElement.style.opacity = "0.3";
506
+ }
453
507
  else {
454
508
  if (!document.getElementById('unitsDrop') || !document.getElementById('tensDrop') || !document.getElementById('hundredsDrop')) {
455
509
  mostOverlappedElement.style.opacity = '0.3';
@@ -485,9 +539,8 @@ function enableDraggingWithScaling(element) {
485
539
  const storedTabIndexes = Object.keys(dropObject).map(Number);
486
540
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
487
541
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
488
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
489
- else if (otherElement.tagName.toLowerCase() === 'lido-image') {
490
- otherElement.style.opacity = '0';
542
+ if (otherElement) {
543
+ otherElement.style.opacity = "0";
491
544
  }
492
545
  else {
493
546
  otherElement.style.opacity = '1';
@@ -495,9 +548,8 @@ function enableDraggingWithScaling(element) {
495
548
  }
496
549
  }
497
550
  else {
498
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
499
- if (otherElement.tagName.toLowerCase() === 'lido-image' || 'lido-cell') {
500
- otherElement.style.opacity = '1';
551
+ if (otherElement) {
552
+ otherElement.style.opacity = "1";
501
553
  }
502
554
  }
503
555
  });
@@ -548,6 +600,7 @@ function enableDraggingWithScaling(element) {
548
600
  element.addEventListener('touchstart', onStart);
549
601
  element.addEventListener('click', ev => {
550
602
  if (isClicked) {
603
+ console.log("clicked drag elkement");
551
604
  onClickDropOrDragElement(element, 'drag');
552
605
  }
553
606
  });
@@ -675,18 +728,14 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
675
728
  const storedTabIndexes = Object.keys(dropObject).map(Number);
676
729
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
677
730
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
678
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
679
- if (otherElement.tagName.toLowerCase() === 'lido-image') {
680
- otherElement.style.opacity = '0';
681
- otherElement.style.backgroundColor = 'transparent';
731
+ if (otherElement.tagName.toLowerCase() === 'lido-text') {
732
+ otherElement.style.opacity = "0";
682
733
  }
683
734
  }
684
735
  }
685
736
  else {
686
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
687
- if (otherElement.tagName.toLowerCase() === 'lido-image') {
688
- otherElement.style.opacity = '1';
689
- otherElement.style.backgroundColor = 'transparent';
737
+ if (otherElement) {
738
+ otherElement.style.opacity = "1";
690
739
  }
691
740
  }
692
741
  });
@@ -700,16 +749,18 @@ async function onElementDropComplete(dragElement, dropElement) {
700
749
  const dragSelectedData = JSON.stringify(buildDragSelectedMapFromDOM());
701
750
  const dropSelectedDataobject = buildDragSelectedMapFromDOM();
702
751
  JSON.stringify(dropSelectedDataobject);
703
- console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
704
752
  let dropHasDrag = buildDropHasDragFromDOM();
705
753
  if (!dropElement) {
706
754
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
707
755
  }
708
- const dropTabIndex = dropElement.getAttribute('tab-index');
709
- const isAllowOnlyOneDrop = dropElement.getAttribute('is-allow-only-one-drop') === 'false';
710
- if (((_b = dropHasDrag[dropTabIndex]) === null || _b === void 0 ? void 0 : _b.isFull) && !isAllowOnlyOneDrop) {
711
- handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
712
- return;
756
+ let dropTabIndex;
757
+ if (dropElement) {
758
+ dropTabIndex = dropElement.getAttribute('tab-index');
759
+ const isAllowOnlyOneDrop = dropElement.getAttribute('is-allow-only-one-drop') === 'false';
760
+ if (((_b = dropHasDrag[dropTabIndex]) === null || _b === void 0 ? void 0 : _b.isFull) && !isAllowOnlyOneDrop) {
761
+ handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
762
+ return;
763
+ }
713
764
  }
714
765
  const isAllowOnlyCorrect = container.getAttribute('is-allow-only-correct') === 'true';
715
766
  if (isAllowOnlyCorrect) {
@@ -742,7 +793,6 @@ async function onElementDropComplete(dragElement, dropElement) {
742
793
  dragElement.style.transition = 'transform 0.5s ease';
743
794
  animateDragToTarget(dragElement, dropElement, container);
744
795
  const onInCorrect = dropElement.getAttribute('onInCorrect');
745
- console.log("onincorrectttt", onInCorrect);
746
796
  await executeActions(onInCorrect, dropElement, dragElement);
747
797
  setTimeout(() => {
748
798
  dragElement.style.transform = 'translate(0, 0)';
@@ -849,15 +899,13 @@ async function onElementDropComplete(dragElement, dropElement) {
849
899
  const storedTabIndexes = Object.keys(dropObject).map(Number);
850
900
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
851
901
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
852
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
853
- if (otherElement.tagName.toLowerCase() === 'lido-image') {
902
+ if (otherElement) {
854
903
  otherElement.style.opacity = '0';
855
904
  }
856
905
  }
857
906
  }
858
907
  else {
859
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
860
- if (otherElement.tagName.toLowerCase() === 'lido-image' || 'lido-cell') {
908
+ if (otherElement) {
861
909
  otherElement.style.opacity = '1';
862
910
  }
863
911
  }
@@ -933,6 +981,7 @@ function updateDropBorder(element) {
933
981
  if (dragSelectedElements.length > 0) {
934
982
  element.classList.add('filled');
935
983
  element.classList.remove('empty');
984
+ element.classList.remove('highlight-element');
936
985
  }
937
986
  else {
938
987
  if (!element.classList.contains('math-matrix')) {
@@ -982,8 +1031,9 @@ async function onClickDropOrDragElement(element, type) {
982
1031
  element.ariaPressed = 'true';
983
1032
  const selectedDropElement = type === 'drop' ? element : document.querySelector("[type='drop'].highlight-element");
984
1033
  const selectedDragElement = type === 'drag' ? element : document.querySelector("[type='drag'].highlight-element");
985
- if (!selectedDropElement) {
1034
+ if (!selectedDropElement || element.classList.contains("dropped")) {
986
1035
  onClickDragElement(element);
1036
+ return;
987
1037
  }
988
1038
  if (selectedDropElement && selectedDragElement) {
989
1039
  if (selectedDragElement.getAttribute('drop-to'))
@@ -1164,7 +1214,7 @@ function highlightElement() {
1164
1214
  }
1165
1215
  // Highlight corresponding drag elements if mistakes are more than 2
1166
1216
  const dragElements = container.querySelectorAll(`[type="drag"]`);
1167
- if (countOfMistakes > 2) {
1217
+ if (countOfMistakes > 2 && container.getAttribute("is-continue-on-correct") === "true") {
1168
1218
  dragElements.forEach(dragEl => {
1169
1219
  dragEl.classList.remove('highlight-element');
1170
1220
  if (dragEl.getAttribute('value') === dropEle.getAttribute('value')) {
@@ -1181,7 +1231,7 @@ function highlightElement() {
1181
1231
  }
1182
1232
  }
1183
1233
  else {
1184
- if (countOfMistakes <= 2)
1234
+ if (countOfMistakes <= 2 || container.getAttribute("is-continue-on-correct") === "false")
1185
1235
  return;
1186
1236
  const clickTemplate = container.querySelectorAll("[type='click']");
1187
1237
  clickTemplate.forEach(clickEl => {
@@ -1196,6 +1246,9 @@ function highlightElement() {
1196
1246
 
1197
1247
  class AudioPlayer {
1198
1248
  constructor() {
1249
+ this.handleUserClick = () => {
1250
+ this.stop();
1251
+ };
1199
1252
  this.audioElement = document.createElement('audio');
1200
1253
  this.audioElement.id = 'audio';
1201
1254
  document.body.appendChild(this.audioElement);
@@ -1232,6 +1285,10 @@ class AudioPlayer {
1232
1285
  catch (e) {
1233
1286
  console.error('Error stopping audio before speak action:', e);
1234
1287
  }
1288
+ const text = targetElement.closest('lido-text');
1289
+ if (text && text.getAttribute('disable-speak') === 'true') {
1290
+ return;
1291
+ }
1235
1292
  // then play the target element audio.
1236
1293
  let audioUrl = targetElement.getAttribute('audio') || '';
1237
1294
  // If no direct audio attribute, check childrens for audio
@@ -1252,6 +1309,7 @@ class AudioPlayer {
1252
1309
  try {
1253
1310
  setDraggingDisabled(true);
1254
1311
  highlightSpeakingElement(targetElement);
1312
+ window.addEventListener('click', this.handleUserClick, true);
1255
1313
  await this.audioElement.play();
1256
1314
  await new Promise(resolve => {
1257
1315
  this.audioElement.onended = () => {
@@ -1263,6 +1321,7 @@ class AudioPlayer {
1263
1321
  console.log('🎧 Audio play error:', error);
1264
1322
  }
1265
1323
  finally {
1324
+ window.removeEventListener('click', this.handleUserClick, true);
1266
1325
  this.audioElement.onended = null; // cleanup
1267
1326
  setDraggingDisabled(false);
1268
1327
  stopHighlightForSpeakingElement(targetElement);
@@ -1272,6 +1331,7 @@ class AudioPlayer {
1272
1331
  else if (targetElement.textContent) {
1273
1332
  try {
1274
1333
  highlightSpeakingElement(targetElement);
1334
+ window.addEventListener('click', this.handleUserClick, true);
1275
1335
  await speakText(targetElement.textContent, targetElement);
1276
1336
  const highlightedElements = document.querySelectorAll('.speaking-highlight');
1277
1337
  highlightedElements.forEach(element => stopHighlightForSpeakingElement(element));
@@ -3199,7 +3259,7 @@ function onTouchListenerForOnTouch(element) {
3199
3259
  setDraggingDisabled(false);
3200
3260
  };
3201
3261
  const onPointerDown = (event) => {
3202
- event.stopPropagation();
3262
+ // event.stopPropagation();
3203
3263
  onholdTriggered = false;
3204
3264
  onholdTimer = setTimeout(() => {
3205
3265
  playAudio();
@@ -3207,13 +3267,18 @@ function onTouchListenerForOnTouch(element) {
3207
3267
  };
3208
3268
  const onPointerUp = async (event) => {
3209
3269
  clearTimeout(onholdTimer);
3210
- if (!onholdTriggered && onTouch) {
3270
+ // If long-press happened → do nothing else
3271
+ if (onholdTriggered) {
3272
+ setDraggingDisabled(false);
3273
+ return;
3274
+ }
3275
+ // If an onTouch action is defined, execute it on tap.
3276
+ if (onTouch) {
3211
3277
  await executeActions(onTouch, element);
3212
3278
  }
3213
- else if (!onTouch) {
3214
- if (['category', 'option'].includes(element.getAttribute('type') || '')) {
3215
- element.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
3216
- }
3279
+ const type = element.getAttribute('type') || '';
3280
+ if (['category', 'option', 'click'].includes(type)) {
3281
+ element.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
3217
3282
  }
3218
3283
  setDraggingDisabled(false);
3219
3284
  };
@@ -3259,7 +3324,7 @@ function addClickListenerForClickType(element) {
3259
3324
  container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
3260
3325
  const isCorrect = objective.includes(element['value']);
3261
3326
  dispatchClickEvent(element, isCorrect);
3262
- if (isCorrect) {
3327
+ if (isCorrect || container.getAttribute('is-continue-on-correct') === 'false') {
3263
3328
  const onCorrect = element.getAttribute('onCorrect');
3264
3329
  if (!(element.id && element.id.startsWith('key-button'))) {
3265
3330
  element.style.pointerEvents = 'none';
@@ -68720,6 +68785,7 @@ const executeActions = async (actionsString, thisElement, element) => {
68720
68785
  const container = document.getElementById(LidoContainer);
68721
68786
  if (container.getAttribute('is-continue-on-correct') !== 'true') {
68722
68787
  targetElement.style.pointerEvents = 'none';
68788
+ AudioPlayer.getI().stop();
68723
68789
  }
68724
68790
  await validateObjectiveStatus();
68725
68791
  break;
@@ -68951,7 +69017,7 @@ const afterDropDragHandling = (dragElement, dropElement) => {
68951
69017
  const scaledLeft = (dropCenterX - dragCenterX) / containerScale;
68952
69018
  const scaledTop = (dropCenterY - dragCenterY) / containerScale;
68953
69019
  dragElement.style.transform = `translate(${scaledLeft}px, ${scaledTop}px)`;
68954
- }, 100);
69020
+ }, 700);
68955
69021
  }
68956
69022
  };
68957
69023
  // function cloneElementWithComputedStyles(originalEl: HTMLElement): HTMLElement {
@@ -69135,18 +69201,14 @@ async function onActivityComplete(dragElement, dropElement) {
69135
69201
  const storedTabIndexes = Object.keys(dragScore).map(Number);
69136
69202
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
69137
69203
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
69138
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
69139
- if (otherElement.tagName.toLowerCase() === 'lido-image') {
69140
- otherElement.style.opacity = '0';
69141
- otherElement.style.backgroundColor = 'transparent';
69204
+ if (otherElement) {
69205
+ otherElement.style.opacity = "0";
69142
69206
  }
69143
69207
  }
69144
69208
  }
69145
69209
  else {
69146
- if (otherElement.tagName.toLowerCase() === 'lido-text') ;
69147
- if (otherElement.tagName.toLowerCase() === 'lido-image') {
69210
+ if (otherElement.tagName.toLowerCase() === 'lido-text') {
69148
69211
  otherElement.style.opacity = '1';
69149
- otherElement.style.backgroundColor = 'transparent';
69150
69212
  }
69151
69213
  }
69152
69214
  });
@@ -69947,6 +70009,7 @@ exports.PrevContainerKey = PrevContainerKey;
69947
70009
  exports.RiveService = RiveService;
69948
70010
  exports.SelectedValuesKey = SelectedValuesKey;
69949
70011
  exports.TemplateID = TemplateID;
70012
+ exports.Timer = Timer;
69950
70013
  exports.attachSpeakIcon = attachSpeakIcon;
69951
70014
  exports.calculateScale = calculateScale;
69952
70015
  exports.calculateScore = calculateScore;
@@ -3,6 +3,7 @@ import { convertUrlToRelative, initEventsForElement, calculateScale } from "../.
3
3
  import i18next from "../../utils/i18n";
4
4
  import { highlightElement } from "../../utils/utilsHandlers/highlightHandler";
5
5
  import { TemplateID } from "../../utils/constants";
6
+ import { Timer } from "../../utils/utilsHandlers/timer";
6
7
  /**
7
8
  * @component LidoContainer
8
9
  *
@@ -12,7 +13,7 @@ import { TemplateID } from "../../utils/constants";
12
13
  */
13
14
  export class LidoContainer {
14
15
  constructor() {
15
- this.locale = '';
16
+ this.Lang = '';
16
17
  this.showDropBorder = true;
17
18
  this.appendToDropOnCompletion = false;
18
19
  this.id = '';
@@ -65,13 +66,13 @@ export class LidoContainer {
65
66
  }
66
67
  resolveInstructionAudio() {
67
68
  var _a;
68
- this.instructName =
69
- (_a = {
70
- flashcard: "Review the flashcards to reinforce your learning." /* templateAudio.flashcards */,
71
- mcq: "Select the correct answer from the options provided." /* templateAudio.mcq */,
72
- tracing: "Trace the shape by following the outline carefully." /* templateAudio.tracing */,
73
- dragAndDrop: "Match the items by dragging and dropping them into the correct places." /* templateAudio.dragAndDrop */,
74
- }[this.templateId]) !== null && _a !== void 0 ? _a : '';
69
+ const key = (_a = {
70
+ flashcard: "instruction.flashcards" /* templateAudio.flashcards */,
71
+ mcq: "instruction.mcq" /* templateAudio.mcq */,
72
+ tracing: "instruction.tracing" /* templateAudio.tracing */,
73
+ dragAndDrop: "instruction.dragAndDrop" /* templateAudio.dragAndDrop */,
74
+ }[this.templateId]) !== null && _a !== void 0 ? _a : '';
75
+ this.instructName = key ? i18next.t(key) : '';
75
76
  const home = document.querySelector('lido-home');
76
77
  if (!home)
77
78
  return;
@@ -84,16 +85,16 @@ export class LidoContainer {
84
85
  resolveLanguage() {
85
86
  var _a, _b;
86
87
  const rootEl = this.el.closest('lido-root');
87
- const rootLang = (rootEl === null || rootEl === void 0 ? void 0 : rootEl.locale) || '';
88
+ const rootLang = (rootEl === null || rootEl === void 0 ? void 0 : rootEl.Lang) || '';
88
89
  if (rootLang === null || rootLang === void 0 ? void 0 : rootLang.trim())
89
90
  return rootLang;
90
91
  const homeEl = this.el.closest('lido-home');
91
- const homeLang = (homeEl === null || homeEl === void 0 ? void 0 : homeEl.locale) || '';
92
+ const homeLang = (homeEl === null || homeEl === void 0 ? void 0 : homeEl.Lang) || '';
92
93
  if (homeLang === null || homeLang === void 0 ? void 0 : homeLang.trim())
93
94
  return homeLang;
94
- if ((_a = this.locale) === null || _a === void 0 ? void 0 : _a.trim())
95
- return this.locale;
96
- const xmlLang = this.el.getAttribute('locale');
95
+ if ((_a = this.Lang) === null || _a === void 0 ? void 0 : _a.trim())
96
+ return this.Lang;
97
+ const xmlLang = this.el.getAttribute('Lang');
97
98
  if (xmlLang === null || xmlLang === void 0 ? void 0 : xmlLang.trim())
98
99
  return xmlLang;
99
100
  return (_b = this.el.textContent) === null || _b === void 0 ? void 0 : _b.trim();
@@ -165,7 +166,7 @@ export class LidoContainer {
165
166
  i18next.changeLanguage(appliedLang);
166
167
  const texts = this.el.querySelectorAll('lido-text');
167
168
  texts.forEach((textEl) => {
168
- textEl.locale = appliedLang;
169
+ textEl.Lang = appliedLang;
169
170
  textEl.dispatchEvent(new CustomEvent('languageChanged', { bubbles: true }));
170
171
  });
171
172
  }
@@ -201,13 +202,17 @@ export class LidoContainer {
201
202
  }
202
203
  const langToApply = this.resolveLanguage();
203
204
  this.updateChildTextLanguage(langToApply);
204
- highlightElement();
205
+ setTimeout(() => {
206
+ highlightElement();
207
+ }, 100);
208
+ Timer.getI().start();
205
209
  }
206
210
  disconnectedCallback() {
207
211
  window.removeEventListener('resize', () => this.scaleContainer(this.el));
208
212
  window.removeEventListener('load', () => this.scaleContainer(this.el));
209
213
  document.body.style.backgroundColor = '';
210
214
  document.body.style.backgroundImage = '';
215
+ Timer.getI().stop();
211
216
  }
212
217
  render() {
213
218
  // Define the styles for the container element
@@ -221,7 +226,7 @@ export class LidoContainer {
221
226
  userSelect: 'none', // Prevent any field selection
222
227
  };
223
228
  console.log('🚀 ~ LidoContainer ~ canplay:', this.canplay);
224
- return (h(Host, { key: '062e67bfc3b71a1dca4502d9a233b312e20d5b0e', id: "lido-container", locale: this.locale, "tab-index": 0, class: "lido-container", objective: this.objective, baseUrl: this.baseUrl, style: style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, onTouch: this.onTouch, onInCorrect: this.onInCorrect, onCorrect: this.onCorrect, onEntry: this.onEntry, "show-check": `${this.showCheck}`, "is-continue-on-correct": `${this.isContinueOnCorrect}`, "is-allow-only-correct": `${this.isAllowOnlyCorrect}`, canplay: `${this.canplay}`, appendToDropOnCompletion: `${this.appendToDropOnCompletion}`, "show-prev-button": `${this.showPrevButton}`, "show-next-button": `${this.showNextButton}`, "show-drop-border": `${this.showDropBorder}`, "bg-image": this.bgImage, "exit-button-url": this.exitButtonUrl, "prev-button-url": this.prevButtonUrl, "next-button-url": this.nextButtonUrl, "speaker-button-url": this.speakerButtonUrl, "disable-speak": this.disableSpeak, "template-id": this.templateId, audio: this.audio }, h("lido-text", { key: 'a297a1aad38160b3bbf13386c92a3b9623bd7276', visible: "false", id: this.templateId, audio: "", string: this.instructName }), h("slot", { key: '49d014ea8cbda57b9b7b683a4b8150df5c3d9b40' })));
229
+ return (h(Host, { key: 'b2b35ac6c3be99cabf0eeaf2708611bfd4c3360c', id: "lido-container", Lang: this.Lang, "tab-index": 0, class: "lido-container", objective: this.objective, baseUrl: this.baseUrl, style: style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, onTouch: this.onTouch, onInCorrect: this.onInCorrect, onCorrect: this.onCorrect, onEntry: this.onEntry, "show-check": `${this.showCheck}`, "is-continue-on-correct": `${this.isContinueOnCorrect}`, "is-allow-only-correct": `${this.isAllowOnlyCorrect}`, canplay: `${this.canplay}`, appendToDropOnCompletion: `${this.appendToDropOnCompletion}`, "show-prev-button": `${this.showPrevButton}`, "show-next-button": `${this.showNextButton}`, "show-drop-border": `${this.showDropBorder}`, "bg-image": this.bgImage, "exit-button-url": this.exitButtonUrl, "prev-button-url": this.prevButtonUrl, "next-button-url": this.nextButtonUrl, "speaker-button-url": this.speakerButtonUrl, "disable-speak": this.disableSpeak, "template-id": this.templateId, audio: this.audio }, h("lido-text", { key: 'ebd91c0603caa4e52d583dd86a1692b57b99afb4', visible: "false", id: this.templateId, audio: "", string: this.instructName }), h("slot", { key: '76f7f53558af814bbd0ce4516b80d4fa970e3c48' })));
225
230
  }
226
231
  static get is() { return "lido-container"; }
227
232
  static get originalStyleUrls() {
@@ -236,7 +241,7 @@ export class LidoContainer {
236
241
  }
237
242
  static get properties() {
238
243
  return {
239
- "locale": {
244
+ "Lang": {
240
245
  "type": "string",
241
246
  "mutable": false,
242
247
  "complexType": {
@@ -250,7 +255,7 @@ export class LidoContainer {
250
255
  "tags": [],
251
256
  "text": "Language to apply to all texts"
252
257
  },
253
- "attribute": "locale",
258
+ "attribute": "lang",
254
259
  "reflect": false,
255
260
  "defaultValue": "''"
256
261
  },
@@ -945,7 +950,7 @@ export class LidoContainer {
945
950
  static get elementRef() { return "el"; }
946
951
  static get watchers() {
947
952
  return [{
948
- "propName": "locale",
953
+ "propName": "Lang",
949
954
  "methodName": "languageChanged"
950
955
  }];
951
956
  }
@@ -111,7 +111,7 @@ export class LidoHome {
111
111
  this.commonAudioPath = "";
112
112
  this.showNav = true;
113
113
  this.activeContainerIndexes = [];
114
- this.locale = '';
114
+ this.Lang = '';
115
115
  this.xmlData = '';
116
116
  this.initialIndex = 0;
117
117
  this.canplay = true;
@@ -543,7 +543,7 @@ export class LidoHome {
543
543
  },
544
544
  "defaultValue": "[]"
545
545
  },
546
- "locale": {
546
+ "Lang": {
547
547
  "type": "string",
548
548
  "mutable": false,
549
549
  "complexType": {
@@ -557,7 +557,7 @@ export class LidoHome {
557
557
  "tags": [],
558
558
  "text": "Language to apply to all texts"
559
559
  },
560
- "attribute": "locale",
560
+ "attribute": "lang",
561
561
  "reflect": false,
562
562
  "defaultValue": "''"
563
563
  },
@@ -768,7 +768,7 @@ export class LidoHome {
768
768
  static get elementRef() { return "el"; }
769
769
  static get watchers() {
770
770
  return [{
771
- "propName": "locale",
771
+ "propName": "Lang",
772
772
  "methodName": "onLangChange"
773
773
  }, {
774
774
  "propName": "commonAudioPath",
@@ -9,7 +9,7 @@ import i18next from "../../utils/i18n";
9
9
  */
10
10
  export class LidoRoot {
11
11
  constructor() {
12
- this.locale = '';
12
+ this.Lang = '';
13
13
  this.xmlPath = '';
14
14
  this.initialIndex = 0;
15
15
  this.margin = '';
@@ -26,7 +26,7 @@ export class LidoRoot {
26
26
  * It fetches the XML data from the specified path or URL and sets it to the component's state.
27
27
  */
28
28
  connectedCallback() {
29
- this.setLanguage(this.locale);
29
+ this.setLanguage(this.Lang);
30
30
  }
31
31
  onLangChange(newLang) {
32
32
  this.setLanguage(newLang);
@@ -80,7 +80,7 @@ export class LidoRoot {
80
80
  static get assetsDirs() { return ["assets"]; }
81
81
  static get properties() {
82
82
  return {
83
- "locale": {
83
+ "Lang": {
84
84
  "type": "string",
85
85
  "mutable": false,
86
86
  "complexType": {
@@ -94,7 +94,7 @@ export class LidoRoot {
94
94
  "tags": [],
95
95
  "text": "Language to apply to all texts"
96
96
  },
97
- "attribute": "locale",
97
+ "attribute": "lang",
98
98
  "reflect": false,
99
99
  "defaultValue": "''"
100
100
  },
@@ -265,7 +265,7 @@ export class LidoRoot {
265
265
  }
266
266
  static get watchers() {
267
267
  return [{
268
- "propName": "locale",
268
+ "propName": "Lang",
269
269
  "methodName": "onLangChange"
270
270
  }];
271
271
  }
@@ -82,7 +82,8 @@ export class LidoText {
82
82
  const base = window[LIDO_COMMON_AUDIO_PATH];
83
83
  if (!base || !this.string)
84
84
  return null;
85
- const fileName = this.string.toLowerCase().trim().replace(/\s+/g, "_").replace(/[^\w-]/g, "");
85
+ const fileName = this.string;
86
+ console.log(fileName, "filename😂");
86
87
  return `${base}/${fileName}.mp3`;
87
88
  }
88
89
  /**
@@ -149,7 +150,7 @@ export class LidoText {
149
150
  }
150
151
  }
151
152
  render() {
152
- return (h(Host, { key: '9635bba385679026c4f90aac9467612f06a21f1b', class: "lido-text", value: this.value, type: this.type, "tab-index": this.tabIndex, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry, minDrops: this.minDrops, maxDrops: this.maxDrops, id: this.id, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, "span-type": this.spanType, "disable-speak": this.disableSpeak }, this.spanType !== '' ? h("div", { class: "lido-text-content" }, " ", i18next.t(this.string)) : i18next.t(this.string)));
153
+ return (h(Host, { key: '7b3c230890775e489b3d2bc2abca683078211377', class: "lido-text", value: this.value, type: this.type, "tab-index": this.tabIndex, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry, minDrops: this.minDrops, maxDrops: this.maxDrops, id: this.id, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, "span-type": this.spanType, "disable-speak": this.disableSpeak }, this.spanType !== '' ? h("div", { class: "lido-text-content" }, " ", i18next.t(this.string)) : i18next.t(this.string)));
153
154
  }
154
155
  static get is() { return "lido-text"; }
155
156
  static get originalStyleUrls() {
@@ -46,7 +46,7 @@ function getContainerXml(args) {
46
46
  </lido-text>
47
47
  </lido-pos>
48
48
  <!-- question -->
49
- <lido-text visible="true" tab-index="12" height="landscape.100px,portrait.175px" font-family="'Baloo Bhai 2'" font-size="60px" width="landscape.auto,portrait.86%" string="Drop the elements to match the given symbol '${objective}'" font-color="black" bg-color="white" y="landscape.0%,portrait.-12%" onEntry="this.font-weight='600'; this.position='relative';">
49
+ <lido-text visible="true" audio="https://aeakbcdznktpsbrfsgys.supabase.co/storage/v1/object/public/template-assets/fill-in-the-blanks/fill-upAudio.mp3" id="heading" tab-index="12" height="landscape.100px,portrait.175px" font-family="'Baloo Bhai 2'" font-size="60px" width="landscape.auto,portrait.86%" string="Drop the elements to match the given symbol '${objective}'" font-color="black" bg-color="white" y="landscape.0%,portrait.-12%" onEntry="this.speak='true';this.font-weight='600'; this.position='relative';">
50
50
  </lido-text>
51
51
  <lido-balance tilt="0" operation="add" visible="true" height="landscape.456px,portrait.500px" y="landscape.4%,portrait.0%" width="landscape.1136px,portrait.876px">
52
52
  <!-- drop Element -->