@pie-element/hotspot 11.2.0-beta.0 → 11.2.0-next.18

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 (236) hide show
  1. package/author.js +2 -0
  2. package/configure.js +2 -0
  3. package/controller.js +1 -0
  4. package/dist/author/DeleteWidget.d.ts +38 -0
  5. package/dist/author/DeleteWidget.js +46 -0
  6. package/dist/author/button.d.ts +31 -0
  7. package/dist/author/button.js +27 -0
  8. package/dist/author/buttons/circle.d.ts +18 -0
  9. package/dist/author/buttons/circle.js +25 -0
  10. package/dist/author/buttons/polygon.d.ts +18 -0
  11. package/dist/author/buttons/polygon.js +36 -0
  12. package/dist/author/buttons/rectangle.d.ts +18 -0
  13. package/dist/author/buttons/rectangle.js +36 -0
  14. package/dist/author/defaults.d.ts +157 -0
  15. package/dist/author/defaults.js +119 -0
  16. package/dist/author/hotspot-circle.d.ts +21 -0
  17. package/dist/author/hotspot-circle.js +124 -0
  18. package/dist/author/hotspot-container.d.ts +29 -0
  19. package/dist/author/hotspot-container.js +210 -0
  20. package/dist/author/hotspot-drawable.d.ts +31 -0
  21. package/dist/author/hotspot-drawable.js +312 -0
  22. package/dist/author/hotspot-palette.d.ts +14 -0
  23. package/dist/author/hotspot-palette.js +72 -0
  24. package/dist/author/hotspot-polygon.d.ts +38 -0
  25. package/dist/author/hotspot-polygon.js +200 -0
  26. package/dist/author/hotspot-rectangle.d.ts +20 -0
  27. package/dist/author/hotspot-rectangle.js +119 -0
  28. package/dist/author/icons.d.ts +9 -0
  29. package/dist/author/icons.js +4 -0
  30. package/dist/author/image-konva.d.ts +19 -0
  31. package/dist/author/image-konva.js +49 -0
  32. package/dist/author/index.d.ts +53 -0
  33. package/dist/author/index.js +146 -0
  34. package/dist/author/root.d.ts +15 -0
  35. package/dist/author/root.js +215 -0
  36. package/dist/author/shapes/circle.d.ts +18 -0
  37. package/dist/author/shapes/circle.js +47 -0
  38. package/dist/author/shapes/index.d.ts +12 -0
  39. package/dist/author/shapes/polygon.d.ts +19 -0
  40. package/dist/author/shapes/polygon.js +51 -0
  41. package/dist/author/shapes/rectagle.d.ts +18 -0
  42. package/dist/author/shapes/rectagle.js +57 -0
  43. package/dist/author/shapes/utils.d.ts +19 -0
  44. package/dist/author/shapes/utils.js +16 -0
  45. package/dist/author/upload-control.d.ts +29 -0
  46. package/dist/author/upload-control.js +28 -0
  47. package/dist/author/utils.d.ts +24 -0
  48. package/dist/author/utils.js +83 -0
  49. package/dist/browser/ReactKonva-e9jPRlPL.js +19304 -0
  50. package/dist/browser/ReactKonva-e9jPRlPL.js.map +1 -0
  51. package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
  52. package/dist/browser/author/index.js +37002 -0
  53. package/dist/browser/author/index.js.map +1 -0
  54. package/dist/browser/browser-D4gLESxz.js +226 -0
  55. package/dist/browser/browser-D4gLESxz.js.map +1 -0
  56. package/dist/browser/controller/index.js +198 -0
  57. package/dist/browser/controller/index.js.map +1 -0
  58. package/dist/browser/delivery/index.js +2673 -0
  59. package/dist/browser/delivery/index.js.map +1 -0
  60. package/dist/browser/dist-CJeYAWp3.js +100 -0
  61. package/dist/browser/dist-CJeYAWp3.js.map +1 -0
  62. package/dist/controller/defaults.d.ts +35 -0
  63. package/dist/controller/defaults.js +29 -0
  64. package/dist/controller/index.d.ts +22 -0
  65. package/dist/controller/index.js +154 -0
  66. package/dist/controller/utils.d.ts +10 -0
  67. package/dist/controller/utils.js +12 -0
  68. package/dist/delivery/hotspot/circle.d.ts +22 -0
  69. package/dist/delivery/hotspot/circle.js +113 -0
  70. package/dist/delivery/hotspot/container.d.ts +21 -0
  71. package/dist/delivery/hotspot/container.js +217 -0
  72. package/dist/delivery/hotspot/icons.d.ts +10 -0
  73. package/dist/delivery/hotspot/icons.js +4 -0
  74. package/dist/delivery/hotspot/image-konva-tooltip.d.ts +19 -0
  75. package/dist/delivery/hotspot/image-konva-tooltip.js +66 -0
  76. package/dist/delivery/hotspot/index.d.ts +18 -0
  77. package/dist/delivery/hotspot/index.js +119 -0
  78. package/dist/delivery/hotspot/polygon.d.ts +24 -0
  79. package/dist/delivery/hotspot/polygon.js +121 -0
  80. package/dist/delivery/hotspot/rectangle.d.ts +22 -0
  81. package/dist/delivery/hotspot/rectangle.js +116 -0
  82. package/dist/delivery/index.d.ts +20 -0
  83. package/dist/delivery/index.js +109 -0
  84. package/dist/delivery/session-updater.d.ts +10 -0
  85. package/dist/delivery/session-updater.js +14 -0
  86. package/dist/index.d.ts +1 -0
  87. package/dist/index.iife.d.ts +8 -0
  88. package/dist/index.iife.js +169 -0
  89. package/dist/index.js +2 -0
  90. package/dist/runtime-support.d.ts +12 -0
  91. package/dist/runtime-support.js +12 -0
  92. package/package.json +84 -19
  93. package/CHANGELOG.json +0 -997
  94. package/CHANGELOG.md +0 -2230
  95. package/LICENSE.md +0 -5
  96. package/README.md +0 -1
  97. package/configure/CHANGELOG.json +0 -682
  98. package/configure/CHANGELOG.md +0 -1964
  99. package/configure/lib/DeleteWidget.js +0 -64
  100. package/configure/lib/DeleteWidget.js.map +0 -1
  101. package/configure/lib/button.js +0 -42
  102. package/configure/lib/button.js.map +0 -1
  103. package/configure/lib/buttons/circle.js +0 -33
  104. package/configure/lib/buttons/circle.js.map +0 -1
  105. package/configure/lib/buttons/polygon.js +0 -39
  106. package/configure/lib/buttons/polygon.js.map +0 -1
  107. package/configure/lib/buttons/rectangle.js +0 -39
  108. package/configure/lib/buttons/rectangle.js.map +0 -1
  109. package/configure/lib/defaults.js +0 -155
  110. package/configure/lib/defaults.js.map +0 -1
  111. package/configure/lib/hotspot-circle.js +0 -192
  112. package/configure/lib/hotspot-circle.js.map +0 -1
  113. package/configure/lib/hotspot-container.js +0 -320
  114. package/configure/lib/hotspot-container.js.map +0 -1
  115. package/configure/lib/hotspot-drawable.js +0 -519
  116. package/configure/lib/hotspot-drawable.js.map +0 -1
  117. package/configure/lib/hotspot-palette.js +0 -107
  118. package/configure/lib/hotspot-palette.js.map +0 -1
  119. package/configure/lib/hotspot-polygon.js +0 -293
  120. package/configure/lib/hotspot-polygon.js.map +0 -1
  121. package/configure/lib/hotspot-rectangle.js +0 -190
  122. package/configure/lib/hotspot-rectangle.js.map +0 -1
  123. package/configure/lib/icons.js +0 -7
  124. package/configure/lib/icons.js.map +0 -1
  125. package/configure/lib/image-konva.js +0 -66
  126. package/configure/lib/image-konva.js.map +0 -1
  127. package/configure/lib/index.js +0 -198
  128. package/configure/lib/index.js.map +0 -1
  129. package/configure/lib/root.js +0 -331
  130. package/configure/lib/root.js.map +0 -1
  131. package/configure/lib/shapes/circle.js +0 -84
  132. package/configure/lib/shapes/circle.js.map +0 -1
  133. package/configure/lib/shapes/index.js +0 -50
  134. package/configure/lib/shapes/index.js.map +0 -1
  135. package/configure/lib/shapes/polygon.js +0 -82
  136. package/configure/lib/shapes/polygon.js.map +0 -1
  137. package/configure/lib/shapes/rectagle.js +0 -84
  138. package/configure/lib/shapes/rectagle.js.map +0 -1
  139. package/configure/lib/shapes/utils.js +0 -21
  140. package/configure/lib/shapes/utils.js.map +0 -1
  141. package/configure/lib/upload-control.js +0 -41
  142. package/configure/lib/upload-control.js.map +0 -1
  143. package/configure/lib/utils.js +0 -185
  144. package/configure/lib/utils.js.map +0 -1
  145. package/configure/package.json +0 -26
  146. package/configure/src/DeleteWidget.jsx +0 -51
  147. package/configure/src/__tests__/DeleteWidget.test.jsx +0 -366
  148. package/configure/src/__tests__/button.test.jsx +0 -198
  149. package/configure/src/__tests__/hotspot-circle.test.jsx +0 -259
  150. package/configure/src/__tests__/hotspot-container.test.js +0 -366
  151. package/configure/src/__tests__/hotspot-drawable.test.js +0 -271
  152. package/configure/src/__tests__/hotspot-palette.test.jsx +0 -71
  153. package/configure/src/__tests__/image-konva.test.jsx +0 -226
  154. package/configure/src/__tests__/index.test.js +0 -329
  155. package/configure/src/__tests__/root.test.js +0 -400
  156. package/configure/src/__tests__/utils.test.js +0 -241
  157. package/configure/src/button.jsx +0 -35
  158. package/configure/src/buttons/circle.jsx +0 -18
  159. package/configure/src/buttons/polygon.jsx +0 -29
  160. package/configure/src/buttons/rectangle.jsx +0 -29
  161. package/configure/src/defaults.js +0 -109
  162. package/configure/src/hotspot-circle.jsx +0 -183
  163. package/configure/src/hotspot-container.jsx +0 -330
  164. package/configure/src/hotspot-drawable.jsx +0 -527
  165. package/configure/src/hotspot-palette.jsx +0 -90
  166. package/configure/src/hotspot-polygon.jsx +0 -294
  167. package/configure/src/hotspot-rectangle.jsx +0 -169
  168. package/configure/src/icons.js +0 -5
  169. package/configure/src/image-konva.jsx +0 -63
  170. package/configure/src/index.js +0 -213
  171. package/configure/src/root.jsx +0 -342
  172. package/configure/src/shapes/circle.js +0 -81
  173. package/configure/src/shapes/index.js +0 -4
  174. package/configure/src/shapes/polygon.js +0 -81
  175. package/configure/src/shapes/rectagle.js +0 -82
  176. package/configure/src/shapes/utils.js +0 -16
  177. package/configure/src/upload-control.jsx +0 -33
  178. package/configure/src/utils.js +0 -210
  179. package/controller/CHANGELOG.json +0 -362
  180. package/controller/CHANGELOG.md +0 -1310
  181. package/controller/lib/defaults.js +0 -33
  182. package/controller/lib/defaults.js.map +0 -1
  183. package/controller/lib/index.js +0 -342
  184. package/controller/lib/index.js.map +0 -1
  185. package/controller/lib/utils.js +0 -32
  186. package/controller/lib/utils.js.map +0 -1
  187. package/controller/package.json +0 -18
  188. package/controller/src/__tests__/index.test.js +0 -419
  189. package/controller/src/__tests__/utils.test.js +0 -5
  190. package/controller/src/defaults.js +0 -19
  191. package/controller/src/index.js +0 -330
  192. package/controller/src/utils.js +0 -29
  193. package/docs/config-schema.json +0 -2023
  194. package/docs/config-schema.json.md +0 -1495
  195. package/docs/demo/config.js +0 -8
  196. package/docs/demo/generate.js +0 -122
  197. package/docs/demo/index.html +0 -1
  198. package/docs/demo/session.js +0 -11
  199. package/docs/pie-schema.json +0 -1204
  200. package/docs/pie-schema.json.md +0 -851
  201. package/lib/hotspot/circle.js +0 -160
  202. package/lib/hotspot/circle.js.map +0 -1
  203. package/lib/hotspot/container.js +0 -291
  204. package/lib/hotspot/container.js.map +0 -1
  205. package/lib/hotspot/icons.js +0 -8
  206. package/lib/hotspot/icons.js.map +0 -1
  207. package/lib/hotspot/image-konva-tooltip.js +0 -86
  208. package/lib/hotspot/image-konva-tooltip.js.map +0 -1
  209. package/lib/hotspot/index.js +0 -174
  210. package/lib/hotspot/index.js.map +0 -1
  211. package/lib/hotspot/polygon.js +0 -207
  212. package/lib/hotspot/polygon.js.map +0 -1
  213. package/lib/hotspot/rectangle.js +0 -178
  214. package/lib/hotspot/rectangle.js.map +0 -1
  215. package/lib/index.js +0 -214
  216. package/lib/index.js.map +0 -1
  217. package/lib/session-updater.js +0 -42
  218. package/lib/session-updater.js.map +0 -1
  219. package/src/__tests__/container.test.jsx +0 -58
  220. package/src/__tests__/index.test.js +0 -123
  221. package/src/__tests__/session-updater.test.jsx +0 -69
  222. package/src/hotspot/__tests__/circle.test.jsx +0 -464
  223. package/src/hotspot/__tests__/container.test.jsx +0 -546
  224. package/src/hotspot/__tests__/image-konva-tooltip.test.jsx +0 -510
  225. package/src/hotspot/__tests__/index.test.jsx +0 -64
  226. package/src/hotspot/__tests__/polygon.test.jsx +0 -502
  227. package/src/hotspot/__tests__/rectangle.test.jsx +0 -418
  228. package/src/hotspot/circle.jsx +0 -154
  229. package/src/hotspot/container.jsx +0 -297
  230. package/src/hotspot/icons.js +0 -7
  231. package/src/hotspot/image-konva-tooltip.jsx +0 -76
  232. package/src/hotspot/index.jsx +0 -179
  233. package/src/hotspot/polygon.jsx +0 -197
  234. package/src/hotspot/rectangle.jsx +0 -172
  235. package/src/index.js +0 -227
  236. package/src/session-updater.js +0 -29
@@ -0,0 +1,66 @@
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ import { Group as i, Image as a, Label as o, Tag as s, Text as c } from "react-konva";
5
+ //#region src/delivery/hotspot/image-konva-tooltip.tsx
6
+ function l(e) {
7
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
8
+ }
9
+ function u(e, t) {
10
+ return !e || l(e) ? e : l(e.default) ? e.default : t && l(e[t]) ? e[t] : t && l(e[t]?.default) ? e[t].default : e;
11
+ }
12
+ var d = u(o, "Label"), f = u(s, "Tag"), p = u(c, "Text"), m = u(a, "Image"), h = u(i, "Group"), g = class extends e.Component {
13
+ constructor(e) {
14
+ super(e), this.state = {
15
+ image: null,
16
+ showTooltip: !1
17
+ };
18
+ }
19
+ componentDidMount() {
20
+ this.loadImage();
21
+ }
22
+ componentDidUpdate(e) {
23
+ e.src !== this.props.src && this.loadImage();
24
+ }
25
+ componentWillUnmount() {
26
+ this.image.removeEventListener("load", this.handleLoad);
27
+ }
28
+ loadImage() {
29
+ let { src: e } = this.props;
30
+ this.image = new window.Image(), this.image.src = e, this.image.addEventListener("load", this.handleLoad);
31
+ }
32
+ handleLoad = () => {
33
+ this.setState({ image: this.image });
34
+ };
35
+ render() {
36
+ let { x: e, y: t, tooltip: i } = this.props, { image: a, showTooltip: o } = this.state;
37
+ return /* @__PURE__ */ r(h, { children: [/* @__PURE__ */ n(m, {
38
+ width: 20,
39
+ height: 20,
40
+ x: e,
41
+ y: t,
42
+ image: a,
43
+ onMouseEnter: () => this.setState({ showTooltip: !0 }),
44
+ onMouseLeave: () => this.setState({ showTooltip: !1 })
45
+ }), o && i && /* @__PURE__ */ r(d, {
46
+ x: e - 30,
47
+ y: t + 25,
48
+ children: [/* @__PURE__ */ n(f, {
49
+ fill: "white",
50
+ cornerRadius: 5,
51
+ opacity: .9
52
+ }), /* @__PURE__ */ n(p, {
53
+ text: i,
54
+ padding: 5
55
+ })]
56
+ })] });
57
+ }
58
+ };
59
+ g.propTypes = {
60
+ src: t.string.isRequired,
61
+ x: t.number.isRequired,
62
+ y: t.number.isRequired,
63
+ tooltip: t.string.isRequired
64
+ };
65
+ //#endregion
66
+ export { g as default };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/hotspot/src/hotspot/index.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ declare class HotspotComponent extends React.Component {
11
+ constructor(props: any);
12
+ componentDidMount(): void;
13
+ componentDidUpdate(): void;
14
+ componentWillUnmount(): void;
15
+ onToggle: any;
16
+ render(): React.JSX.Element;
17
+ }
18
+ export default HotspotComponent;
@@ -0,0 +1,119 @@
1
+ import { Container as e } from "./container.js";
2
+ import t from "react";
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";
11
+ //#region src/delivery/hotspot/index.tsx
12
+ function g(e) {
13
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
14
+ }
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;
17
+ }
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(),
21
+ position: "relative"
22
+ }), T = h(b)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), E = class extends t.Component {
23
+ constructor(e) {
24
+ super(e), this.state = {
25
+ showCorrect: !1,
26
+ observer: null,
27
+ scale: 1
28
+ };
29
+ }
30
+ componentDidMount() {
31
+ this.observer = new MutationObserver((e) => {
32
+ e.forEach(() => {
33
+ let e = document.getElementById("question-container")?.style?.cssText, t = (e?.substring(e.indexOf("--pie-zoom") + 11, e.lastIndexOf("%")))?.replace(/\s/g, "");
34
+ t ? parseFloat(t) / 100 !== this.state.scale && this.setState({ scale: parseFloat(t) / 100 }) : !t && this.state.scale !== 1 && this.setState({ scale: 1 });
35
+ });
36
+ });
37
+ let e = document.getElementById("question-container");
38
+ e && this.observer.observe(e, {
39
+ attributes: !0,
40
+ attributeFilter: ["style"]
41
+ }), n(u.findDOMNode(this));
42
+ }
43
+ componentDidUpdate() {
44
+ n(u.findDOMNode(this));
45
+ }
46
+ componentWillUnmount() {
47
+ this.observer?.disconnect();
48
+ }
49
+ onToggle = () => {
50
+ let { showCorrect: e } = this.state;
51
+ this.setState({ showCorrect: !e });
52
+ };
53
+ render() {
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, {
56
+ extraCSSRules: r,
57
+ id: "main-container",
58
+ fontSizeFactor: O,
59
+ children: [
60
+ S && (l(S) || c(S)) && /* @__PURE__ */ p(T, {
61
+ labels: {
62
+ hidden: "Show Teacher Instructions",
63
+ visible: "Hide Teacher Instructions"
64
+ },
65
+ children: /* @__PURE__ */ p(y, {
66
+ className: "prompt",
67
+ prompt: S
68
+ })
69
+ }),
70
+ a && /* @__PURE__ */ p(y, {
71
+ className: "prompt",
72
+ prompt: a,
73
+ autoplayAudioEnabled: k,
74
+ customAudioButton: A
75
+ }),
76
+ F && /* @__PURE__ */ p(f, {
77
+ show: F,
78
+ toggled: M,
79
+ onToggle: this.onToggle.bind(this),
80
+ language: D
81
+ }),
82
+ i ? /* @__PURE__ */ p(e, {
83
+ isEvaluateMode: N,
84
+ session: t,
85
+ dimensions: v,
86
+ imageUrl: i,
87
+ hotspotColor: h,
88
+ hoverOutlineColor: P ? g : void 0,
89
+ selectedHotspotColor: _,
90
+ multipleCorrect: s,
91
+ outlineColor: d,
92
+ onSelectChoice: j,
93
+ shapes: u,
94
+ disabled: n,
95
+ strokeWidth: C,
96
+ scale: this.state.scale,
97
+ showCorrect: M
98
+ }) : null,
99
+ I && /* @__PURE__ */ p(b, {
100
+ labels: {
101
+ hidden: "Show Rationale",
102
+ visible: "Hide Rationale"
103
+ },
104
+ children: /* @__PURE__ */ p(y, {
105
+ className: "prompt",
106
+ prompt: x
107
+ })
108
+ })
109
+ ]
110
+ });
111
+ }
112
+ };
113
+ E.propTypes = {
114
+ model: d.object.isRequired,
115
+ onSelectChoice: d.func.isRequired,
116
+ session: d.object.isRequired
117
+ };
118
+ //#endregion
119
+ export { E as default };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/hotspot/src/hotspot/polygon.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ declare class PolygonComponent extends React.Component {
11
+ constructor(props: any);
12
+ componentDidMount(): void;
13
+ componentDidUpdate(prevProps: any): void;
14
+ moveGroupToTop: any;
15
+ getPolygonCenter: any;
16
+ parsePointsForKonva: any;
17
+ handleClick: any;
18
+ handleMouseEnter: any;
19
+ handleMouseLeave: any;
20
+ getEvaluateOutlineColor: (isCorrect: any, markAsCorrect: any, outlineColor: any) => any;
21
+ getOutlineWidth: (showCorrectEnabled: any, selected: any, markAsCorrect: any, strokeWidth: any) => any;
22
+ render(): React.JSX.Element;
23
+ }
24
+ export default PolygonComponent;
@@ -0,0 +1,121 @@
1
+ import e from "./image-konva-tooltip.js";
2
+ import { faCorrect as t, faWrong as n } from "./icons.js";
3
+ import r from "react";
4
+ import i from "prop-types";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ import { Group as s, Line as c, Rect as l } from "react-konva";
7
+ //#region src/delivery/hotspot/polygon.tsx
8
+ function u(e) {
9
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
10
+ }
11
+ function d(e, t) {
12
+ return !e || u(e) ? e : u(e.default) ? e.default : t && u(e[t]) ? e[t] : t && u(e[t]?.default) ? e[t].default : e;
13
+ }
14
+ var f = d(l, "Rect"), p = d(s, "Group"), m = d(c, "Line"), h = class extends r.Component {
15
+ constructor(e) {
16
+ super(e), this.state = { hovered: !1 }, this.groupRef = r.createRef();
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
+ };
27
+ getPolygonCenter = (e) => {
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);
29
+ return [(r + i) / 2, (a + o) / 2];
30
+ };
31
+ parsePointsForKonva = (e) => {
32
+ let t = [];
33
+ return e.forEach(({ x: e, y: n }) => {
34
+ t.push(e), t.push(n);
35
+ }), t;
36
+ };
37
+ handleClick = (e) => {
38
+ let { onClick: t, id: n, selected: r, disabled: i } = this.props;
39
+ i || (e.cancelBubble = !0, t({
40
+ id: n,
41
+ selected: !r,
42
+ selector: "Mouse"
43
+ }));
44
+ };
45
+ handleMouseEnter = () => {
46
+ let { disabled: e } = this.props;
47
+ e || (document.body.style.cursor = "pointer"), this.setState({ hovered: !0 }), this.moveGroupToTop();
48
+ };
49
+ handleMouseLeave = () => {
50
+ document.body.style.cursor = "default", this.setState({ hovered: !1 });
51
+ };
52
+ getEvaluateOutlineColor = (e, t, n) => t ? "green" : e ? n : "red";
53
+ getOutlineWidth = (e, t, n, r) => n || !n && !e && t ? r : 0;
54
+ render() {
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;
58
+ return /* @__PURE__ */ o(p, {
59
+ ref: this.groupRef,
60
+ scaleX: v,
61
+ scaleY: v,
62
+ onMouseEnter: this.handleMouseEnter,
63
+ onMouseLeave: this.handleMouseLeave,
64
+ children: [
65
+ /* @__PURE__ */ a(m, {
66
+ points: T,
67
+ closed: !0,
68
+ fill: u && b ? b : r,
69
+ onClick: this.handleClick,
70
+ onTap: this.handleClick,
71
+ draggable: !1,
72
+ stroke: A && !u ? "transparent" : C,
73
+ strokeWidth: A && !u ? 0 : w,
74
+ cursor: "pointer",
75
+ position: "relative"
76
+ }),
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
91
+ }) : null
92
+ ]
93
+ });
94
+ }
95
+ };
96
+ h.propTypes = {
97
+ hotspotColor: i.string.isRequired,
98
+ id: i.string.isRequired,
99
+ isCorrect: i.bool.isRequired,
100
+ isEvaluateMode: i.bool.isRequired,
101
+ hoverOutlineColor: i.string,
102
+ disabled: i.bool.isRequired,
103
+ focused: i.bool,
104
+ onClick: i.func.isRequired,
105
+ outlineColor: i.string.isRequired,
106
+ points: i.array.isRequired,
107
+ selected: i.bool.isRequired,
108
+ evaluateText: i.string,
109
+ selectedHotspotColor: i.string,
110
+ strokeWidth: i.number,
111
+ scale: i.number,
112
+ markAsCorrect: i.bool.isRequired,
113
+ showCorrectEnabled: i.bool.isRequired
114
+ }, h.defaultProps = {
115
+ evaluateText: null,
116
+ focused: !1,
117
+ strokeWidth: 5,
118
+ scale: 1
119
+ };
120
+ //#endregion
121
+ export { h as default };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/hotspot/src/hotspot/rectangle.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ declare class RectComponent extends React.Component {
11
+ constructor(props: any);
12
+ componentDidMount(): void;
13
+ componentDidUpdate(prevProps: any): void;
14
+ moveGroupToTop: any;
15
+ handleClick: any;
16
+ handleMouseEnter: any;
17
+ handleMouseLeave: any;
18
+ getEvaluateOutlineColor: (isCorrect: any, markAsCorrect: any, outlineColor: any) => any;
19
+ getOutlineWidth: (showCorrectEnabled: any, selected: any, markAsCorrect: any, strokeWidth: any) => any;
20
+ render(): React.JSX.Element;
21
+ }
22
+ export default RectComponent;
@@ -0,0 +1,116 @@
1
+ import e from "./image-konva-tooltip.js";
2
+ import { faCorrect as t, faWrong as n } from "./icons.js";
3
+ import r from "react";
4
+ import i from "prop-types";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ import { Group as s, Rect as c } from "react-konva";
7
+ //#region src/delivery/hotspot/rectangle.tsx
8
+ function l(e) {
9
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
10
+ }
11
+ function u(e, t) {
12
+ return !e || l(e) ? e : l(e.default) ? e.default : t && l(e[t]) ? e[t] : t && l(e[t]?.default) ? e[t].default : e;
13
+ }
14
+ var d = u(s, "Group"), f = u(c, "Rect"), p = class extends r.Component {
15
+ constructor(e) {
16
+ super(e), this.state = { hovered: !1 }, this.groupRef = r.createRef();
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
+ };
27
+ handleClick = (e) => {
28
+ let { onClick: t, id: n, selected: r, disabled: i } = this.props;
29
+ i || (e.cancelBubble = !0, t({
30
+ id: n,
31
+ selected: !r,
32
+ selector: "Mouse"
33
+ }));
34
+ };
35
+ handleMouseEnter = () => {
36
+ let { disabled: e } = this.props;
37
+ e || (document.body.style.cursor = "pointer"), this.setState({ hovered: !0 }), this.moveGroupToTop();
38
+ };
39
+ handleMouseLeave = () => {
40
+ document.body.style.cursor = "default", this.setState({ hovered: !1 });
41
+ };
42
+ getEvaluateOutlineColor = (e, t, n) => t ? "green" : e ? n : "red";
43
+ getOutlineWidth = (e, t, n, r) => n || !n && !e && t ? r : 0;
44
+ render() {
45
+ let { height: r, hotspotColor: i, hoverOutlineColor: s, selectedHotspotColor: c, isCorrect: l, isEvaluateMode: u, outlineColor: p, selected: m, focused: h, width: g, x: _, y: v, evaluateText: y, strokeWidth: b, scale: x, markAsCorrect: S, showCorrectEnabled: C } = this.props, { hovered: w } = this.state, T = u ? this.getEvaluateOutlineColor(l, S, p) : p, E = this.getOutlineWidth(C, m, S, b), D = _ + g / 2 - 10, O = v + r / 2 - 10, k;
46
+ C ? (m && l || !m && !l) && (k = t) : m ? k = l ? t : n : l || (k = n);
47
+ let A = (w || h) && s;
48
+ return /* @__PURE__ */ o(d, {
49
+ ref: this.groupRef,
50
+ scaleX: x,
51
+ scaleY: x,
52
+ onMouseLeave: this.handleMouseLeave,
53
+ onMouseEnter: this.handleMouseEnter,
54
+ children: [
55
+ /* @__PURE__ */ a(f, {
56
+ x: _,
57
+ y: v,
58
+ width: g,
59
+ height: r,
60
+ fill: m && c ? c : i,
61
+ onClick: this.handleClick,
62
+ onTap: this.handleClick,
63
+ draggable: !1,
64
+ stroke: A && !m ? "transparent" : T,
65
+ strokeWidth: A && !m ? 0 : E,
66
+ cursor: "pointer"
67
+ }),
68
+ A && /* @__PURE__ */ a(f, {
69
+ x: _,
70
+ y: v,
71
+ width: g,
72
+ height: r,
73
+ stroke: s,
74
+ strokeWidth: b,
75
+ listening: !1
76
+ }),
77
+ u && k ? /* @__PURE__ */ a(e, {
78
+ src: k,
79
+ x: D,
80
+ y: O,
81
+ tooltip: y
82
+ }) : null
83
+ ]
84
+ });
85
+ }
86
+ };
87
+ p.propTypes = {
88
+ height: i.number.isRequired,
89
+ hotspotColor: i.string.isRequired,
90
+ id: i.string.isRequired,
91
+ isCorrect: i.oneOfType([i.bool, i.string]),
92
+ isEvaluateMode: i.bool.isRequired,
93
+ hoverOutlineColor: i.string,
94
+ disabled: i.bool.isRequired,
95
+ focused: i.bool,
96
+ onClick: i.func.isRequired,
97
+ outlineColor: i.string.isRequired,
98
+ selected: i.bool.isRequired,
99
+ width: i.number.isRequired,
100
+ x: i.number.isRequired,
101
+ y: i.number.isRequired,
102
+ evaluateText: i.string,
103
+ strokeWidth: i.number,
104
+ scale: i.number,
105
+ selectedHotspotColor: i.string,
106
+ markAsCorrect: i.bool.isRequired,
107
+ showCorrectEnabled: i.bool.isRequired
108
+ }, p.defaultProps = {
109
+ isCorrect: !1,
110
+ evaluateText: null,
111
+ focused: !1,
112
+ strokeWidth: 5,
113
+ scale: 1
114
+ };
115
+ //#endregion
116
+ export { p as default };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/hotspot/src/index.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export default class Hotspot extends HTMLElement {
10
+ constructor();
11
+ set model(m: any);
12
+ isComplete(): boolean;
13
+ set session(s: any);
14
+ get session(): any;
15
+ onSelectChoice(data: any): void;
16
+ _createAudioInfoToast(): HTMLDivElement;
17
+ connectedCallback(): void;
18
+ _render(): void;
19
+ disconnectedCallback(): void;
20
+ }
@@ -0,0 +1,109 @@
1
+ import e from "./hotspot/index.js";
2
+ import { updateSessionMetadata as t, updateSessionValue as n } from "./session-updater.js";
3
+ import r from "react";
4
+ import { createRoot as i } from "react-dom/client";
5
+ import { renderMath as a } from "@pie-element/shared-math-rendering-mathjax";
6
+ import * as o from "@pie-lib/render-ui";
7
+ import { EnableAudioAutoplayImage as s } from "@pie-lib/render-ui";
8
+ import { ModelSetEvent as c, SessionChangedEvent as l } from "@pie-element/shared-player-events";
9
+ //#region src/delivery/index.ts
10
+ function u(e) {
11
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
12
+ }
13
+ function d(e, t) {
14
+ return !e || u(e) ? e : u(e.default) ? e.default : t && u(e[t]) ? e[t] : t && u(e[t]?.default) ? e[t].default : e;
15
+ }
16
+ var f = d(s, "EnableAudioAutoplayImage") || d(h.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), p = o, m = p.default, h = m && typeof m == "object" ? m : p, g = class extends HTMLElement {
17
+ constructor() {
18
+ super(), this._model = null, this._session = null, this._audioInitialized = !1, this.audioComplete = !1, this._root = null;
19
+ }
20
+ set model(e) {
21
+ this._model = e, this.dispatchEvent(new c(this.tagName.toLowerCase(), this.isComplete(), !!this._model)), this._audioInitialized = !1, this._render();
22
+ }
23
+ isComplete() {
24
+ if (!this._session || !this._session.answers) return !1;
25
+ let { completeAudioEnabled: e } = this._model || {}, t = this;
26
+ if (e && !this.audioComplete && t) {
27
+ let e = t.querySelector("audio"), n = e && e.closest(".preview-prompt");
28
+ if (e && n) return !1;
29
+ }
30
+ return Array.isArray(this._session.answers) ? this._session.answers.length > 0 : !1;
31
+ }
32
+ set session(e) {
33
+ e && !e.answers && (e.answers = []), this._session = e, this._render();
34
+ }
35
+ get session() {
36
+ return this._session;
37
+ }
38
+ onSelectChoice(e) {
39
+ n(this._session, this._model, e), this.dispatchEvent(new l(this.tagName.toLowerCase(), this.isComplete())), this._render();
40
+ }
41
+ _createAudioInfoToast() {
42
+ let e = document.createElement("div");
43
+ e.id = "play-audio-info", Object.assign(e.style, {
44
+ position: "absolute",
45
+ top: 0,
46
+ width: "100%",
47
+ height: "100%",
48
+ display: "flex",
49
+ justifyContent: "center",
50
+ alignItems: "center",
51
+ background: "white",
52
+ zIndex: "1000",
53
+ cursor: "pointer"
54
+ });
55
+ let t = document.createElement("img");
56
+ return t.src = f, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
57
+ }
58
+ connectedCallback() {
59
+ this._render(), new MutationObserver((e, n) => {
60
+ e.forEach((e) => {
61
+ if (e.type === "childList") {
62
+ if (this._audioInitialized) return;
63
+ let e = this.querySelector("audio"), r = e && e.closest(".preview-prompt");
64
+ if (!this._model) return;
65
+ let { autoplayAudioEnabled: i, completeAudioEnabled: a } = this._model;
66
+ if (!i && !a || e && !r || !e) return;
67
+ let o = this._createAudioInfoToast(), s = this.querySelector("#main-container"), c = () => {
68
+ this.querySelector("#play-audio-info") && (e.play(), s.removeChild(o)), document.removeEventListener("click", c);
69
+ };
70
+ i && setTimeout(() => {
71
+ e.paused && !this.querySelector("#play-audio-info") ? (s.appendChild(o), document.addEventListener("click", c)) : document.removeEventListener("click", c);
72
+ }, 500);
73
+ let u = () => {
74
+ t(this._session, { audioStartTime: (/* @__PURE__ */ new Date()).getTime() });
75
+ let n = this.querySelector("#play-audio-info");
76
+ n && s.removeChild(n), e.removeEventListener("playing", u);
77
+ };
78
+ e.addEventListener("playing", u);
79
+ let d = () => {
80
+ t(this._session, { audioEndTime: (/* @__PURE__ */ new Date()).getTime() });
81
+ let { audioStartTime: n, audioEndTime: r, waitTime: i } = this._session;
82
+ !i && n && r && (this._session.waitTime = r - n), this.audioComplete = !0, this.dispatchEvent(new l(this.tagName.toLowerCase(), this.isComplete())), e.removeEventListener("ended", d);
83
+ };
84
+ e.addEventListener("ended", d), this._audio = e, this._handlePlaying = u, this._handleEnded = d, this._enableAudio = c, this._audioInitialized = !0, n.disconnect();
85
+ }
86
+ });
87
+ }).observe(this, {
88
+ childList: !0,
89
+ subtree: !0
90
+ });
91
+ }
92
+ _render() {
93
+ if (this._model && this._session) {
94
+ let t = r.createElement(e, {
95
+ model: this._model,
96
+ session: this._session,
97
+ onSelectChoice: this.onSelectChoice.bind(this)
98
+ });
99
+ this._root ||= i(this), this._root.render(t), queueMicrotask(() => {
100
+ a(this);
101
+ });
102
+ }
103
+ }
104
+ disconnectedCallback() {
105
+ document.removeEventListener("click", this._enableAudio), this._audio &&= (this._audio.removeEventListener("playing", this._handlePlaying), this._audio.removeEventListener("ended", this._handleEnded), null), this._root &&= (this._root.unmount(), null);
106
+ }
107
+ };
108
+ //#endregion
109
+ export { g as default };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/hotspot/src/session-updater.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export declare function updateSessionValue(session: any, model: any, data: any): void;
10
+ export declare function updateSessionMetadata(session: any, metadata: any): void;
@@ -0,0 +1,14 @@
1
+ //#region src/delivery/session-updater.ts
2
+ function e(e, t, n) {
3
+ let { id: r, selected: i } = n, { multipleCorrect: a } = t || {};
4
+ if (e.answers = e.answers || [], !i) e.answers = e.answers.filter((e) => e.id !== r);
5
+ else {
6
+ let t = { id: r };
7
+ a ? e.answers.push(t) : e.answers = [t], e.selector = n.selector;
8
+ }
9
+ }
10
+ function t(e, t) {
11
+ e.audioStartTime = e.audioStartTime || t.audioStartTime, e.audioEndTime = e.audioEndTime || t.audioEndTime, !e.waitTime && e.audioStartTime && e.audioEndTime && (e.waitTime = e.audioEndTime - e.audioStartTime);
12
+ }
13
+ //#endregion
14
+ export { t as updateSessionMetadata, e as updateSessionValue };
@@ -0,0 +1 @@
1
+ export { default } from './delivery/index.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * IIFE entry point for hotspot element
3
+ * This file is only used for IIFE builds and includes auto-registration
4
+ *
5
+ * @sync-generated - Auto-generated during sync from pie-elements
6
+ */
7
+ import Element from './index.js';
8
+ export default Element;