@pie-element/hotspot 11.1.2-next.0 → 11.1.2-next.10

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 (162) hide show
  1. package/dist/author/hotspot-container.js +2 -2
  2. package/dist/author/hotspot-drawable.js +120 -120
  3. package/dist/author/hotspot-polygon.js +2 -2
  4. package/dist/author/index.d.ts +1 -0
  5. package/dist/author/index.js +5 -2
  6. package/dist/author/root.js +52 -52
  7. package/dist/author/utils.js +10 -10
  8. package/dist/browser/{ReactKonva-Z9-1H-UZ.js → ReactKonva-Cj44B3Ds.js} +3504 -3535
  9. package/dist/browser/ReactKonva-Cj44B3Ds.js.map +1 -0
  10. package/dist/browser/author/index.js +24223 -22027
  11. package/dist/browser/author/index.js.map +1 -1
  12. package/dist/browser/{browser-CfnAFove.js → browser-D4gLESxz.js} +22 -6
  13. package/dist/browser/{browser-CfnAFove.js.map → browser-D4gLESxz.js.map} +1 -1
  14. package/dist/browser/controller/index.js +32 -32
  15. package/dist/browser/controller/index.js.map +1 -1
  16. package/dist/browser/delivery/index.js +628 -519
  17. package/dist/browser/delivery/index.js.map +1 -1
  18. package/dist/browser/dist-CJeYAWp3.js +100 -0
  19. package/dist/browser/dist-CJeYAWp3.js.map +1 -0
  20. package/dist/controller/index.js +51 -51
  21. package/dist/controller/utils.d.ts +1 -1
  22. package/dist/controller/utils.js +2 -3
  23. package/dist/delivery/hotspot/circle.d.ts +3 -0
  24. package/dist/delivery/hotspot/circle.js +40 -27
  25. package/dist/delivery/hotspot/container.d.ts +5 -0
  26. package/dist/delivery/hotspot/container.js +163 -96
  27. package/dist/delivery/hotspot/index.d.ts +1 -0
  28. package/dist/delivery/hotspot/index.js +41 -36
  29. package/dist/delivery/hotspot/polygon.d.ts +3 -0
  30. package/dist/delivery/hotspot/polygon.js +39 -26
  31. package/dist/delivery/hotspot/rectangle.d.ts +3 -0
  32. package/dist/delivery/hotspot/rectangle.js +40 -28
  33. package/dist/delivery/index.js +3 -3
  34. package/dist/index.iife.js +40 -40
  35. package/dist/runtime-support.d.ts +12 -0
  36. package/dist/runtime-support.js +12 -0
  37. package/package.json +20 -17
  38. package/dist/browser/ReactKonva-Z9-1H-UZ.js.map +0 -1
  39. package/dist/browser/isEqual-D3CTSc6W.js +0 -601
  40. package/dist/browser/isEqual-D3CTSc6W.js.map +0 -1
  41. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +0 -6
  42. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +0 -16
  43. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +0 -16
  44. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +0 -6
  45. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +0 -16
  46. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +0 -6
  47. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +0 -6
  48. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_SetCache.js +0 -11
  49. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +0 -14
  50. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +0 -5
  51. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +0 -5
  52. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +0 -6
  53. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +0 -7
  54. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +0 -10
  55. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +0 -15
  56. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +0 -7
  57. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arraySome.js +0 -7
  58. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +0 -10
  59. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +0 -8
  60. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +0 -8
  61. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +0 -8
  62. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +0 -12
  63. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +0 -57
  64. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +0 -14
  65. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
  66. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +0 -10
  67. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +0 -9
  68. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqual.js +0 -8
  69. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqualDeep.js +0 -30
  70. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +0 -9
  71. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +0 -11
  72. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +0 -9
  73. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +0 -11
  74. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +0 -12
  75. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +0 -13
  76. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +0 -7
  77. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +0 -8
  78. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cacheHas.js +0 -6
  79. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
  80. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +0 -10
  81. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +0 -8
  82. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +0 -8
  83. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +0 -8
  84. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +0 -8
  85. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +0 -8
  86. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +0 -14
  87. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +0 -8
  88. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +0 -8
  89. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +0 -5
  90. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +0 -10
  91. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalArrays.js +0 -35
  92. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalByTag.js +0 -35
  93. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalObjects.js +0 -32
  94. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +0 -4
  95. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +0 -9
  96. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +0 -9
  97. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +0 -8
  98. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +0 -9
  99. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +0 -5
  100. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +0 -14
  101. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +0 -10
  102. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +0 -11
  103. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +0 -23
  104. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +0 -6
  105. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +0 -7
  106. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +0 -7
  107. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +0 -13
  108. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +0 -9
  109. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +0 -9
  110. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +0 -8
  111. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +0 -33
  112. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +0 -9
  113. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +0 -8
  114. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +0 -7
  115. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +0 -11
  116. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +0 -8
  117. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +0 -6
  118. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +0 -9
  119. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +0 -8
  120. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +0 -7
  121. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +0 -8
  122. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +0 -13
  123. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +0 -8
  124. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +0 -7
  125. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +0 -7
  126. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +0 -8
  127. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapToArray.js +0 -9
  128. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +0 -5
  129. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +0 -5
  130. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +0 -8
  131. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +0 -9
  132. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +0 -7
  133. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +0 -8
  134. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +0 -5
  135. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheAdd.js +0 -7
  136. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheHas.js +0 -6
  137. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setToArray.js +0 -9
  138. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +0 -7
  139. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +0 -7
  140. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +0 -6
  141. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +0 -6
  142. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +0 -16
  143. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +0 -15
  144. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +0 -8
  145. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +0 -6
  146. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +0 -10
  147. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +0 -4
  148. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +0 -8
  149. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +0 -6
  150. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +0 -21
  151. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEqual.js +0 -7
  152. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +0 -11
  153. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +0 -7
  154. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +0 -7
  155. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +0 -7
  156. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +0 -6
  157. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +0 -7
  158. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +0 -7
  159. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +0 -9
  160. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +0 -9
  161. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +0 -6
  162. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +0 -6
@@ -19,118 +19,185 @@ var f = d(l, "Stage"), p = d(c, "Layer"), m = s("div")(({ theme: e }) => ({
19
19
  position: "relative",
20
20
  background: e.palette.common.white,
21
21
  border: `${e.spacing(1)} solid ${e.palette.common.white}`,
22
- width: "fit-content"
23
- })), h = s("div")({
22
+ width: "fit-content",
23
+ maxWidth: "100%",
24
+ overflowX: "auto"
25
+ })), h = s("span")({
26
+ position: "absolute",
27
+ width: 1,
28
+ height: 1,
29
+ overflow: "hidden",
30
+ clip: "rect(0, 0, 0, 0)",
31
+ whiteSpace: "nowrap"
32
+ }), g = s("div")({
24
33
  position: "relative",
25
34
  width: "fit-content"
26
- }), g = s("img")({
35
+ }), _ = s("img")({
27
36
  alignItems: "center",
28
37
  display: "flex",
29
38
  justifyContent: "center"
30
- }), _ = s(f)({
39
+ }), v = s(f)({
31
40
  left: 0,
32
41
  top: 0,
33
42
  position: "absolute"
34
- }), v = class extends r.Component {
43
+ }), y = class extends r.Component {
44
+ constructor(e) {
45
+ super(e), this.state = { focusedShapeId: null };
46
+ }
35
47
  isSelected(e) {
36
48
  return !!this.props.session.answers.filter((t) => t.id === e.id)[0];
37
49
  }
38
50
  correctness = (e, t) => e ? t : !t;
39
51
  getEvaluateText = (e, t) => t && e ? "Correctly\nselected" : t && !e ? "Should not have\nbeen selected" : !t && e ? "Should have\nbeen selected" : null;
52
+ getAllShapesSorted = () => {
53
+ let { shapes: { rectangles: e = [], polygons: t = [], circles: n = [] } } = this.props, r = [
54
+ ...e.map((e) => ({
55
+ ...e,
56
+ type: "rectangle"
57
+ })),
58
+ ...t.map((e) => ({
59
+ ...e,
60
+ type: "polygon"
61
+ })),
62
+ ...n.map((e) => ({
63
+ ...e,
64
+ type: "circle"
65
+ }))
66
+ ];
67
+ return r.sort((e, t) => String(e.id).localeCompare(String(t.id), void 0, { numeric: !0 })), r;
68
+ };
69
+ handleShapeFocus = (e) => {
70
+ this.setState({ focusedShapeId: e });
71
+ };
72
+ handleShapeBlur = () => {
73
+ this.setState({ focusedShapeId: null });
74
+ };
75
+ handleShapeKeyDown = (e, t) => {
76
+ if (e.key === "Enter" || e.key === " ") {
77
+ e.preventDefault();
78
+ let { onSelectChoice: n, disabled: r } = this.props;
79
+ if (!r) {
80
+ let e = this.getAllShapesSorted().find((e) => e.id === t);
81
+ e && n({
82
+ id: t,
83
+ selected: !this.isSelected(e),
84
+ selector: "Keyboard"
85
+ });
86
+ }
87
+ }
88
+ };
40
89
  render() {
41
- let { dimensions: { width: r, height: i }, disabled: s, hotspotColor: c, hoverOutlineColor: l, selectedHotspotColor: u, imageUrl: d, isEvaluateMode: f, outlineColor: v, onSelectChoice: y, shapes: { rectangles: b = [], polygons: x = [], circles: S = [] }, scale: C, strokeWidth: w, showCorrect: T } = this.props, E = r * C, D = i * C;
90
+ let { dimensions: { width: r, height: i }, disabled: s, hotspotColor: c, hoverOutlineColor: l, selectedHotspotColor: u, imageUrl: d, isEvaluateMode: f, outlineColor: y, onSelectChoice: b, shapes: { rectangles: x = [], polygons: S = [], circles: C = [] }, scale: w, strokeWidth: T, showCorrect: E } = this.props, { focusedShapeId: D } = this.state, O = r * w, k = i * w, A = this.getAllShapesSorted();
42
91
  return /* @__PURE__ */ o(m, {
43
- style: { padding: w / 2 },
44
- children: [d ? /* @__PURE__ */ a(h, { children: /* @__PURE__ */ a(g, {
45
- alt: "hotspot-image",
46
- height: "auto",
47
- src: d,
48
- style: {
49
- width: E,
50
- height: D,
51
- maxWidth: E,
52
- maxHeight: D
53
- }
54
- }) }) : null, /* @__PURE__ */ a(_, {
55
- height: D + w,
56
- width: E + w,
57
- x: w / 2,
58
- y: w / 2,
59
- children: /* @__PURE__ */ o(p, { children: [
60
- b.map((t) => {
61
- let n = this.isSelected(t), r = f ? this.correctness(t.correct, n) : void 0, i = f ? this.getEvaluateText(t.correct, n) : null, o = !!(f && T && t.correct);
62
- return /* @__PURE__ */ a(e, {
63
- scale: C,
64
- isEvaluateMode: f,
65
- isCorrect: r,
66
- evaluateText: i,
67
- disabled: s,
68
- selected: n,
69
- height: t.height,
70
- hotspotColor: c,
71
- hoverOutlineColor: l,
72
- selectedHotspotColor: u,
73
- id: t.id,
74
- onClick: y,
75
- outlineColor: v,
76
- width: t.width,
77
- x: t.x,
78
- y: t.y,
79
- strokeWidth: w,
80
- markAsCorrect: o,
81
- showCorrectEnabled: T
82
- }, t.id);
83
- }),
84
- x.map((e) => {
85
- let n = this.isSelected(e), r = f ? this.correctness(e.correct, n) : void 0, i = f ? this.getEvaluateText(e.correct, n) : null, o = !!(f && T && e.correct);
86
- return /* @__PURE__ */ a(t, {
87
- scale: C,
88
- isEvaluateMode: f,
89
- isCorrect: !!r,
90
- evaluateText: i,
91
- disabled: s,
92
- selected: n,
93
- hotspotColor: c,
94
- id: e.id,
95
- onClick: y,
96
- outlineColor: v,
97
- points: e.points,
98
- strokeWidth: w,
99
- markAsCorrect: o,
100
- selectedHotspotColor: u,
101
- hoverOutlineColor: l,
102
- showCorrectEnabled: T
103
- }, e.id);
104
- }),
105
- S.map((e) => {
106
- let t = this.isSelected(e), r = f ? this.correctness(e.correct, t) : void 0, i = f ? this.getEvaluateText(e.correct, t) : null, o = !!(f && T && e.correct);
107
- return /* @__PURE__ */ a(n, {
108
- scale: C,
109
- isEvaluateMode: f,
110
- isCorrect: r,
111
- evaluateText: i,
112
- disabled: s,
113
- selected: t,
114
- radius: e.radius,
115
- hotspotColor: c,
116
- id: e.id,
117
- onClick: y,
118
- outlineColor: v,
119
- x: e.x,
120
- y: e.y,
121
- strokeWidth: w,
122
- markAsCorrect: o,
123
- selectedHotspotColor: u,
124
- hoverOutlineColor: l,
125
- showCorrectEnabled: T
126
- }, e.id);
127
- })
128
- ] })
129
- })]
92
+ style: { padding: T / 2 },
93
+ children: [
94
+ d ? /* @__PURE__ */ a(g, { children: /* @__PURE__ */ a(_, {
95
+ alt: "hotspot-image",
96
+ height: "auto",
97
+ src: d,
98
+ style: {
99
+ width: O,
100
+ height: k,
101
+ maxWidth: O,
102
+ maxHeight: k
103
+ }
104
+ }) }) : null,
105
+ /* @__PURE__ */ a(v, {
106
+ height: k + T,
107
+ width: O + T,
108
+ x: T / 2,
109
+ y: T / 2,
110
+ children: /* @__PURE__ */ o(p, { children: [
111
+ x.map((t) => {
112
+ let n = this.isSelected(t), r = f ? this.correctness(t.correct, n) : void 0, i = f ? this.getEvaluateText(t.correct, n) : null, o = !!(f && E && t.correct);
113
+ return /* @__PURE__ */ a(e, {
114
+ scale: w,
115
+ isEvaluateMode: f,
116
+ isCorrect: r,
117
+ evaluateText: i,
118
+ disabled: s,
119
+ selected: n,
120
+ height: t.height,
121
+ hotspotColor: c,
122
+ hoverOutlineColor: l,
123
+ selectedHotspotColor: u,
124
+ id: t.id,
125
+ onClick: b,
126
+ outlineColor: y,
127
+ width: t.width,
128
+ x: t.x,
129
+ y: t.y,
130
+ strokeWidth: T,
131
+ markAsCorrect: o,
132
+ showCorrectEnabled: E,
133
+ focused: D === t.id
134
+ }, t.id);
135
+ }),
136
+ S.map((e) => {
137
+ let n = this.isSelected(e), r = f ? this.correctness(e.correct, n) : void 0, i = f ? this.getEvaluateText(e.correct, n) : null, o = !!(f && E && e.correct);
138
+ return /* @__PURE__ */ a(t, {
139
+ scale: w,
140
+ isEvaluateMode: f,
141
+ isCorrect: !!r,
142
+ evaluateText: i,
143
+ disabled: s,
144
+ selected: n,
145
+ hotspotColor: c,
146
+ id: e.id,
147
+ onClick: b,
148
+ outlineColor: y,
149
+ points: e.points,
150
+ strokeWidth: T,
151
+ markAsCorrect: o,
152
+ selectedHotspotColor: u,
153
+ hoverOutlineColor: l,
154
+ showCorrectEnabled: E,
155
+ focused: D === e.id
156
+ }, e.id);
157
+ }),
158
+ C.map((e) => {
159
+ let t = this.isSelected(e), r = f ? this.correctness(e.correct, t) : void 0, i = f ? this.getEvaluateText(e.correct, t) : null, o = !!(f && E && e.correct);
160
+ return /* @__PURE__ */ a(n, {
161
+ scale: w,
162
+ isEvaluateMode: f,
163
+ isCorrect: r,
164
+ evaluateText: i,
165
+ disabled: s,
166
+ selected: t,
167
+ radius: e.radius,
168
+ hotspotColor: c,
169
+ id: e.id,
170
+ onClick: b,
171
+ outlineColor: y,
172
+ x: e.x,
173
+ y: e.y,
174
+ strokeWidth: T,
175
+ markAsCorrect: o,
176
+ selectedHotspotColor: u,
177
+ hoverOutlineColor: l,
178
+ showCorrectEnabled: E,
179
+ focused: D === e.id
180
+ }, e.id);
181
+ })
182
+ ] })
183
+ }),
184
+ A.map((e) => {
185
+ let t = this.isSelected(e);
186
+ return /* @__PURE__ */ a(h, {
187
+ tabIndex: s ? -1 : 0,
188
+ role: "button",
189
+ "aria-label": e.ariaLabel || "",
190
+ "aria-pressed": t,
191
+ onFocus: () => this.handleShapeFocus(e.id),
192
+ onBlur: this.handleShapeBlur,
193
+ onKeyDown: (t) => this.handleShapeKeyDown(t, e.id)
194
+ }, `focus-${e.id}`);
195
+ })
196
+ ]
130
197
  });
131
198
  }
132
199
  };
133
- v.propTypes = {
200
+ y.propTypes = {
134
201
  dimensions: i.object.isRequired,
135
202
  disabled: i.bool.isRequired,
136
203
  hotspotColor: i.string.isRequired,
@@ -145,6 +212,6 @@ v.propTypes = {
145
212
  strokeWidth: i.number,
146
213
  scale: i.number,
147
214
  showCorrect: i.bool
148
- }, v.defaultProps = { scale: 1 };
215
+ }, y.defaultProps = { scale: 1 };
149
216
  //#endregion
150
- export { v as default };
217
+ export { y as Container, y as default };
@@ -10,6 +10,7 @@ import React from 'react';
10
10
  declare class HotspotComponent extends React.Component {
11
11
  constructor(props: any);
12
12
  componentDidMount(): void;
13
+ componentDidUpdate(): void;
13
14
  componentWillUnmount(): void;
14
15
  onToggle: any;
15
16
  render(): React.JSX.Element;
@@ -1,23 +1,25 @@
1
- import e from "./container.js";
1
+ import { Container as e } from "./container.js";
2
2
  import t from "react";
3
- import * as n from "@pie-lib/render-ui";
4
- import { Collapsible as r, PreviewPrompt as i, UiLayout as a, color as o, hasMedia as s, hasText as c } from "@pie-lib/render-ui";
5
- import l from "prop-types";
6
- import u from "@pie-lib/correct-answer-toggle";
7
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
- import { styled as p } from "@mui/material/styles";
3
+ import { renderMath as n } from "@pie-element/shared-math-rendering-mathjax";
4
+ import * as r from "@pie-lib/render-ui";
5
+ import { Collapsible as i, PreviewPrompt as a, UiLayout as o, color as s, hasMedia as c, hasText as l } from "@pie-lib/render-ui";
6
+ import u from "react-dom";
7
+ import d from "prop-types";
8
+ import f from "@pie-lib/correct-answer-toggle";
9
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
+ import { styled as h } from "@mui/material/styles";
9
11
  //#region src/delivery/hotspot/index.tsx
10
- function m(e) {
12
+ function g(e) {
11
13
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
12
14
  }
13
- function h(e, t) {
14
- return !e || m(e) ? e : m(e.default) ? e.default : t && m(e[t]) ? e[t] : t && m(e[t]?.default) ? e[t].default : e;
15
+ function _(e, t) {
16
+ return !e || g(e) ? e : g(e.default) ? e.default : t && g(e[t]) ? e[t] : t && g(e[t]?.default) ? e[t].default : e;
15
17
  }
16
- var g = h(a, "UiLayout") || h(x.UiLayout, "UiLayout"), _ = h(i, "PreviewPrompt") || h(x.PreviewPrompt, "PreviewPrompt"), v = h(r, "Collapsible") || h(x.Collapsible, "Collapsible"), y = n, b = y.default, x = b && typeof b == "object" ? b : y, S = p(g)({
17
- color: o.text(),
18
- backgroundColor: o.background(),
18
+ var v = _(o, "UiLayout") || _(C.UiLayout, "UiLayout"), y = _(a, "PreviewPrompt") || _(C.PreviewPrompt, "PreviewPrompt"), b = _(i, "Collapsible") || _(C.Collapsible, "Collapsible"), x = r, S = x.default, C = S && typeof S == "object" ? S : x, w = h(v)({
19
+ color: s.text(),
20
+ backgroundColor: s.background(),
19
21
  position: "relative"
20
- }), C = p(v)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), w = class extends t.Component {
22
+ }), T = h(b)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), E = class extends t.Component {
21
23
  constructor(e) {
22
24
  super(e), this.state = {
23
25
  showCorrect: !1,
@@ -36,7 +38,10 @@ var g = h(a, "UiLayout") || h(x.UiLayout, "UiLayout"), _ = h(i, "PreviewPrompt")
36
38
  e && this.observer.observe(e, {
37
39
  attributes: !0,
38
40
  attributeFilter: ["style"]
39
- });
41
+ }), n(u.findDOMNode(this));
42
+ }
43
+ componentDidUpdate() {
44
+ n(u.findDOMNode(this));
40
45
  }
41
46
  componentWillUnmount() {
42
47
  this.observer?.disconnect();
@@ -46,57 +51,57 @@ var g = h(a, "UiLayout") || h(x.UiLayout, "UiLayout"), _ = h(i, "PreviewPrompt")
46
51
  this.setState({ showCorrect: !e });
47
52
  };
48
53
  render() {
49
- let { session: t, model: { disabled: n, extraCSSRules: r, imageUrl: i, prompt: a, mode: o, multipleCorrect: l, shapes: p, outlineColor: m, hotspotColor: h, hoverOutlineColor: g, selectedHotspotColor: y, dimensions: b, rationale: x, teacherInstructions: w, strokeWidth: T, responseCorrect: E, language: D, fontSizeFactor: O, autoplayAudioEnabled: k, customAudioButton: A }, onSelectChoice: j } = this.props, { showCorrect: M } = this.state, N = o === "evaluate", P = o === "gather", F = N && !E, I = x && (c(x) || s(x));
50
- return /* @__PURE__ */ f(S, {
54
+ let { session: t, model: { disabled: n, extraCSSRules: r, imageUrl: i, prompt: a, mode: o, multipleCorrect: s, shapes: u, outlineColor: d, hotspotColor: h, hoverOutlineColor: g, selectedHotspotColor: _, dimensions: v, rationale: x, teacherInstructions: S, strokeWidth: C, responseCorrect: E, language: D, fontSizeFactor: O, autoplayAudioEnabled: k, customAudioButton: A }, onSelectChoice: j } = this.props, { showCorrect: M } = this.state, N = o === "evaluate", P = o === "gather", F = N && !E, I = x && (l(x) || c(x));
55
+ return /* @__PURE__ */ m(w, {
51
56
  extraCSSRules: r,
52
57
  id: "main-container",
53
58
  fontSizeFactor: O,
54
59
  children: [
55
- w && (c(w) || s(w)) && /* @__PURE__ */ d(C, {
60
+ S && (l(S) || c(S)) && /* @__PURE__ */ p(T, {
56
61
  labels: {
57
62
  hidden: "Show Teacher Instructions",
58
63
  visible: "Hide Teacher Instructions"
59
64
  },
60
- children: /* @__PURE__ */ d(_, {
65
+ children: /* @__PURE__ */ p(y, {
61
66
  className: "prompt",
62
- prompt: w
67
+ prompt: S
63
68
  })
64
69
  }),
65
- a && /* @__PURE__ */ d(_, {
70
+ a && /* @__PURE__ */ p(y, {
66
71
  className: "prompt",
67
72
  prompt: a,
68
73
  autoplayAudioEnabled: k,
69
74
  customAudioButton: A
70
75
  }),
71
- F && /* @__PURE__ */ d(u, {
76
+ F && /* @__PURE__ */ p(f, {
72
77
  show: F,
73
78
  toggled: M,
74
79
  onToggle: this.onToggle.bind(this),
75
80
  language: D
76
81
  }),
77
- i ? /* @__PURE__ */ d(e, {
82
+ i ? /* @__PURE__ */ p(e, {
78
83
  isEvaluateMode: N,
79
84
  session: t,
80
- dimensions: b,
85
+ dimensions: v,
81
86
  imageUrl: i,
82
87
  hotspotColor: h,
83
88
  hoverOutlineColor: P ? g : void 0,
84
- selectedHotspotColor: y,
85
- multipleCorrect: l,
86
- outlineColor: m,
89
+ selectedHotspotColor: _,
90
+ multipleCorrect: s,
91
+ outlineColor: d,
87
92
  onSelectChoice: j,
88
- shapes: p,
93
+ shapes: u,
89
94
  disabled: n,
90
- strokeWidth: T,
95
+ strokeWidth: C,
91
96
  scale: this.state.scale,
92
97
  showCorrect: M
93
98
  }) : null,
94
- I && /* @__PURE__ */ d(v, {
99
+ I && /* @__PURE__ */ p(b, {
95
100
  labels: {
96
101
  hidden: "Show Rationale",
97
102
  visible: "Hide Rationale"
98
103
  },
99
- children: /* @__PURE__ */ d(_, {
104
+ children: /* @__PURE__ */ p(y, {
100
105
  className: "prompt",
101
106
  prompt: x
102
107
  })
@@ -105,10 +110,10 @@ var g = h(a, "UiLayout") || h(x.UiLayout, "UiLayout"), _ = h(i, "PreviewPrompt")
105
110
  });
106
111
  }
107
112
  };
108
- w.propTypes = {
109
- model: l.object.isRequired,
110
- onSelectChoice: l.func.isRequired,
111
- session: l.object.isRequired
113
+ E.propTypes = {
114
+ model: d.object.isRequired,
115
+ onSelectChoice: d.func.isRequired,
116
+ session: d.object.isRequired
112
117
  };
113
118
  //#endregion
114
- export { w as default };
119
+ export { E as default };
@@ -9,6 +9,9 @@
9
9
  import React from 'react';
10
10
  declare class PolygonComponent extends React.Component {
11
11
  constructor(props: any);
12
+ componentDidMount(): void;
13
+ componentDidUpdate(prevProps: any): void;
14
+ moveGroupToTop: any;
12
15
  getPolygonCenter: any;
13
16
  parsePointsForKonva: any;
14
17
  handleClick: any;
@@ -13,8 +13,17 @@ function d(e, t) {
13
13
  }
14
14
  var f = d(l, "Rect"), p = d(s, "Group"), m = d(c, "Line"), h = class extends r.Component {
15
15
  constructor(e) {
16
- super(e), this.state = { hovered: !1 };
16
+ super(e), this.state = { hovered: !1 }, this.groupRef = r.createRef();
17
17
  }
18
+ componentDidMount() {
19
+ this.props.focused && this.moveGroupToTop();
20
+ }
21
+ componentDidUpdate(e) {
22
+ !e.focused && this.props.focused && this.moveGroupToTop();
23
+ }
24
+ moveGroupToTop = () => {
25
+ this.groupRef.current && this.groupRef.current.moveToTop();
26
+ };
18
27
  getPolygonCenter = (e) => {
19
28
  let t = e.map(({ x: e }) => e), n = e.map(({ y: e }) => e), r = Math.min.apply(null, t), i = Math.max.apply(null, t), a = Math.min.apply(null, n), o = Math.max.apply(null, n);
20
29
  return [(r + i) / 2, (a + o) / 2];
@@ -35,7 +44,7 @@ var f = d(l, "Rect"), p = d(s, "Group"), m = d(c, "Line"), h = class extends r.C
35
44
  };
36
45
  handleMouseEnter = () => {
37
46
  let { disabled: e } = this.props;
38
- e || (document.body.style.cursor = "pointer"), this.setState({ hovered: !0 });
47
+ e || (document.body.style.cursor = "pointer"), this.setState({ hovered: !0 }), this.moveGroupToTop();
39
48
  };
40
49
  handleMouseLeave = () => {
41
50
  document.body.style.cursor = "default", this.setState({ hovered: !1 });
@@ -43,40 +52,42 @@ var f = d(l, "Rect"), p = d(s, "Group"), m = d(c, "Line"), h = class extends r.C
43
52
  getEvaluateOutlineColor = (e, t, n) => t ? "green" : e ? n : "red";
44
53
  getOutlineWidth = (e, t, n, r) => n || !n && !e && t ? r : 0;
45
54
  render() {
46
- let { hotspotColor: r, isCorrect: i, isEvaluateMode: s, hoverOutlineColor: c, outlineColor: l, selected: u, points: d, evaluateText: h, strokeWidth: g, scale: _, markAsCorrect: v, selectedHotspotColor: y, showCorrectEnabled: b } = this.props, { hovered: x } = this.state, S = s ? this.getEvaluateOutlineColor(i, v, l) : l, C = this.getOutlineWidth(b, u, v, g), w = this.parsePointsForKonva(d), T = this.getPolygonCenter(d), E = T[0], D = T[1], O;
47
- b ? (u && i || !u && !i) && (O = t) : u ? O = i ? t : n : i || (O = n);
48
- let k = x && c, A = w.filter((e, t) => t % 2 == 0), j = w.filter((e, t) => t % 2 != 0), M = Math.min(...A), N = Math.max(...A), P = Math.min(...j), F = Math.max(...j), I = M, L = P, R = N - M, z = F - P;
55
+ let { hotspotColor: r, isCorrect: i, isEvaluateMode: s, hoverOutlineColor: c, outlineColor: l, selected: u, focused: d, points: h, evaluateText: g, strokeWidth: _, scale: v, markAsCorrect: y, selectedHotspotColor: b, showCorrectEnabled: x } = this.props, { hovered: S } = this.state, C = s ? this.getEvaluateOutlineColor(i, y, l) : l, w = this.getOutlineWidth(x, u, y, _), T = this.parsePointsForKonva(h), E = this.getPolygonCenter(h), D = E[0], O = E[1], k;
56
+ x ? (u && i || !u && !i) && (k = t) : u ? k = i ? t : n : i || (k = n);
57
+ let A = (S || d) && c, j = T.filter((e, t) => t % 2 == 0), M = T.filter((e, t) => t % 2 != 0), N = Math.min(...j), P = Math.max(...j), F = Math.min(...M), I = Math.max(...M), L = N, R = F, z = P - N, B = I - F;
49
58
  return /* @__PURE__ */ o(p, {
50
- scaleX: _,
51
- scaleY: _,
59
+ ref: this.groupRef,
60
+ scaleX: v,
61
+ scaleY: v,
62
+ onMouseEnter: this.handleMouseEnter,
63
+ onMouseLeave: this.handleMouseLeave,
52
64
  children: [
53
- k && /* @__PURE__ */ a(f, {
54
- x: I,
55
- y: L,
56
- width: R,
57
- height: z,
58
- stroke: u ? "transparent" : c,
59
- strokeWidth: g
60
- }),
61
65
  /* @__PURE__ */ a(m, {
62
- points: w,
66
+ points: T,
63
67
  closed: !0,
64
- fill: u && y ? y : r,
68
+ fill: u && b ? b : r,
65
69
  onClick: this.handleClick,
66
70
  onTap: this.handleClick,
67
71
  draggable: !1,
68
- stroke: k && !u ? "transparent" : S,
69
- strokeWidth: k && !u ? 0 : C,
70
- onMouseLeave: this.handleMouseLeave,
71
- onMouseEnter: this.handleMouseEnter,
72
+ stroke: A && !u ? "transparent" : C,
73
+ strokeWidth: A && !u ? 0 : w,
72
74
  cursor: "pointer",
73
75
  position: "relative"
74
76
  }),
75
- s && O ? /* @__PURE__ */ a(e, {
76
- src: O,
77
- x: E,
78
- y: D,
79
- tooltip: h
77
+ A && /* @__PURE__ */ a(f, {
78
+ x: L,
79
+ y: R,
80
+ width: z,
81
+ height: B,
82
+ stroke: c,
83
+ strokeWidth: _,
84
+ listening: !1
85
+ }),
86
+ s && k ? /* @__PURE__ */ a(e, {
87
+ src: k,
88
+ x: D,
89
+ y: O,
90
+ tooltip: g
80
91
  }) : null
81
92
  ]
82
93
  });
@@ -89,6 +100,7 @@ h.propTypes = {
89
100
  isEvaluateMode: i.bool.isRequired,
90
101
  hoverOutlineColor: i.string,
91
102
  disabled: i.bool.isRequired,
103
+ focused: i.bool,
92
104
  onClick: i.func.isRequired,
93
105
  outlineColor: i.string.isRequired,
94
106
  points: i.array.isRequired,
@@ -101,6 +113,7 @@ h.propTypes = {
101
113
  showCorrectEnabled: i.bool.isRequired
102
114
  }, h.defaultProps = {
103
115
  evaluateText: null,
116
+ focused: !1,
104
117
  strokeWidth: 5,
105
118
  scale: 1
106
119
  };
@@ -9,6 +9,9 @@
9
9
  import React from 'react';
10
10
  declare class RectComponent extends React.Component {
11
11
  constructor(props: any);
12
+ componentDidMount(): void;
13
+ componentDidUpdate(prevProps: any): void;
14
+ moveGroupToTop: any;
12
15
  handleClick: any;
13
16
  handleMouseEnter: any;
14
17
  handleMouseLeave: any;