@cuemath/leap 3.2.6 → 3.2.7-ppa-0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ import { jsxs as i, jsx as l } from "react/jsx-runtime";
2
+ const t = (L) => /* @__PURE__ */ i(
3
+ "svg",
4
+ {
5
+ xmlns: "http://www.w3.org/2000/svg",
6
+ width: "24",
7
+ height: "24",
8
+ viewBox: "0 0 24 24",
9
+ fill: "none",
10
+ ...L,
11
+ children: [
12
+ /* @__PURE__ */ l(
13
+ "path",
14
+ {
15
+ fillRule: "evenodd",
16
+ clipRule: "evenodd",
17
+ d: "M12.5 3.69923V2.70001H11.5V3.70001L12.5 3.69923ZM20 10.2015H19V11.2015H20V10.2015ZM17.9424 7.0043L18.8084 6.5043L19.3084 7.37033L18.4424 7.87033L17.9424 7.0043ZM15.8043 3.66699L15.3043 4.53302L16.1703 5.03302L16.6703 4.16699L15.8043 3.66699ZM5 11.2015H4V10.2015H5V11.2015ZM9.11621 4.59494L8.61621 3.72891L7.75019 4.22891L8.25019 5.09494L9.11621 4.59494ZM5.60211 6.35647L6.46813 6.85647L5.96813 7.7225L5.10211 7.2225L5.60211 6.35647ZM7.6 10.8499C7.6 8.41986 9.56995 6.44991 12 6.44991C14.4301 6.44991 16.4 8.41986 16.4 10.8499C16.4 12.422 15.5758 13.8022 14.3334 14.581H9.66658C8.42416 13.8022 7.6 12.422 7.6 10.8499ZM12 5.24991C8.90721 5.24991 6.4 7.75712 6.4 10.8499C6.4 12.9235 7.52729 14.733 9.19957 15.7004L9.33896 15.781H14.661L14.8004 15.7004C16.4727 14.733 17.6 12.9235 17.6 10.8499C17.6 7.75712 15.0928 5.24991 12 5.24991ZM9.5 16.6112V17.8112H14.5V16.6112H9.5ZM10.5 19.7526V18.5526H13.5V19.7526H10.5Z",
18
+ fill: "currentColor"
19
+ }
20
+ ),
21
+ /* @__PURE__ */ l(
22
+ "path",
23
+ {
24
+ className: "hint-fill-icon-path",
25
+ d: "M12 6.44991C9.56995 6.44991 7.6 8.41986 7.6 10.8499C7.6 12.422 8.42416 13.8022 9.66658 14.581H14.3334C15.5758 13.8022 16.4 12.422 16.4 10.8499C16.4 8.41986 14.4301 6.44991 12 6.44991Z",
26
+ fill: "#FFB700"
27
+ }
28
+ )
29
+ ]
30
+ }
31
+ ), o = t;
32
+ export {
33
+ o as default
34
+ };
35
+ //# sourceMappingURL=hint-fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hint-fill.js","sources":["../../../../src/assets/line-icons/icons/hint-fill.tsx"],"sourcesContent":["const HintFillIcon: React.FC<React.SVGProps<SVGSVGElement>> = props => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n {...props}\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5 3.69923V2.70001H11.5V3.70001L12.5 3.69923ZM20 10.2015H19V11.2015H20V10.2015ZM17.9424 7.0043L18.8084 6.5043L19.3084 7.37033L18.4424 7.87033L17.9424 7.0043ZM15.8043 3.66699L15.3043 4.53302L16.1703 5.03302L16.6703 4.16699L15.8043 3.66699ZM5 11.2015H4V10.2015H5V11.2015ZM9.11621 4.59494L8.61621 3.72891L7.75019 4.22891L8.25019 5.09494L9.11621 4.59494ZM5.60211 6.35647L6.46813 6.85647L5.96813 7.7225L5.10211 7.2225L5.60211 6.35647ZM7.6 10.8499C7.6 8.41986 9.56995 6.44991 12 6.44991C14.4301 6.44991 16.4 8.41986 16.4 10.8499C16.4 12.422 15.5758 13.8022 14.3334 14.581H9.66658C8.42416 13.8022 7.6 12.422 7.6 10.8499ZM12 5.24991C8.90721 5.24991 6.4 7.75712 6.4 10.8499C6.4 12.9235 7.52729 14.733 9.19957 15.7004L9.33896 15.781H14.661L14.8004 15.7004C16.4727 14.733 17.6 12.9235 17.6 10.8499C17.6 7.75712 15.0928 5.24991 12 5.24991ZM9.5 16.6112V17.8112H14.5V16.6112H9.5ZM10.5 19.7526V18.5526H13.5V19.7526H10.5Z\"\n fill=\"currentColor\"\n />\n <path\n className=\"hint-fill-icon-path\"\n d=\"M12 6.44991C9.56995 6.44991 7.6 8.41986 7.6 10.8499C7.6 12.422 8.42416 13.8022 9.66658 14.581H14.3334C15.5758 13.8022 16.4 12.422 16.4 10.8499C16.4 8.41986 14.4301 6.44991 12 6.44991Z\"\n fill=\"#FFB700\"\n />\n </svg>\n);\n\nexport default HintFillIcon;\n"],"names":["HintFillIcon","props","jsxs","jsx","HintFillIcon$1"],"mappings":";AAAA,MAAMA,IAAwD,CAC5DC,MAAA,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAM;AAAA,IACN,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACJ,GAAGD;AAAA,IAEJ,UAAA;AAAA,MAAA,gBAAAE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,UAAS;AAAA,UACT,UAAS;AAAA,UACT,GAAE;AAAA,UACF,MAAK;AAAA,QAAA;AAAA,MACP;AAAA,MACA,gBAAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA,UACF,MAAK;AAAA,QAAA;AAAA,MACP;AAAA,IAAA;AAAA,EAAA;AACF,GAGFC,IAAeJ;"}
@@ -0,0 +1,112 @@
1
+ import o from "styled-components";
2
+ import n from "../../../assets/line-icons/icons/hint-fill.js";
3
+ import e from "../../ui/layout/flex-view.js";
4
+ import r from "../../ui/text/text.js";
5
+ import { getPuzzleCardPattern as p } from "../utils/puzzle-pattern.js";
6
+ const d = o(e)(({ theme: t, $visible: i }) => {
7
+ const { gutter: l } = t.layout;
8
+ return i ? `
9
+ padding-top: ${l * 1.5}px;
10
+ padding-bottom: ${l * 2}px;
11
+ ` : "";
12
+ }), g = o(e)`
13
+ position: relative;
14
+ margin: 0 auto;
15
+ box-shadow: inset 0px 0px 0px 4px ${({ theme: t, $imageHue: i }) => t.colors[`${i}_4`]};
16
+ max-width: 343px;
17
+ width: 100%;
18
+ min-height: 412px;
19
+
20
+ &::before {
21
+ content: '';
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ right: 0;
26
+ bottom: 0;
27
+ background-image: ${({ $imageHue: t }) => `url(${p(t)})`};
28
+ background-size: cover;
29
+ opacity: 0.2;
30
+ }
31
+ `, x = o(e)`
32
+ background-color: transparent;
33
+
34
+ .puzzle-question-content {
35
+ font-size: 16px;
36
+ line-height: 1.6em;
37
+ color: ${({ theme: t }) => t.colors.BLACK};
38
+ font-family: 'Noto Serif', serif;
39
+
40
+ em {
41
+ font-style: italic;
42
+ }
43
+
44
+ ul,
45
+ ol {
46
+ list-style-type: initial;
47
+ padding-left: 32px;
48
+ }
49
+
50
+ ol {
51
+ list-style-type: decimal;
52
+ }
53
+
54
+ p {
55
+ margin: 12px 0;
56
+ }
57
+
58
+ li {
59
+ margin: 4px 0;
60
+ }
61
+ }
62
+ `, u = o(n)`
63
+ color: ${({ theme: t }) => t.colors.BLACK_1};
64
+
65
+ & .hint-fill-icon-path {
66
+ fill: ${({ theme: t }) => t.colors.WHITE_1};
67
+ }
68
+ `, y = o(r)`
69
+ & span {
70
+ font-weight: 700;
71
+ margin-right: 4px;
72
+ }
73
+ `, h = o.div`
74
+ color: ${({ theme: t }) => t.colors.BLACK};
75
+ font-size: 14px;
76
+ line-height: 1.2;
77
+ font-family: 'Athletics';
78
+
79
+ font-weight: 400;
80
+ font-style: normal;
81
+
82
+ em {
83
+ font-style: italic;
84
+ }
85
+
86
+ ul,
87
+ ol {
88
+ list-style-type: initial;
89
+ padding-left: 32px;
90
+ }
91
+
92
+ ol {
93
+ list-style-type: decimal;
94
+ }
95
+
96
+ p {
97
+ margin: 0;
98
+ }
99
+
100
+ li {
101
+ margin: 4px 0;
102
+ }
103
+ `;
104
+ export {
105
+ d as PuzzleAppWrapper,
106
+ g as PuzzleContainer,
107
+ h as PuzzleQuestionWrapper,
108
+ x as QuestionCard,
109
+ y as StyledFeedbackText,
110
+ u as StyledHintFillIcon
111
+ };
112
+ //# sourceMappingURL=puzzle-app-styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puzzle-app-styled.js","sources":["../../../../src/features/puzzles/app/puzzle-app-styled.tsx"],"sourcesContent":["import type { THueNames } from '../../ui/types';\n\nimport styled from 'styled-components';\n\nimport HintFillIcon from '../../../assets/line-icons/icons/hint-fill';\nimport FlexView from '../../ui/layout/flex-view';\nimport Text from '../../ui/text/text';\nimport { getPuzzleCardPattern } from '../utils/puzzle-pattern';\n\nconst PuzzleAppWrapper = styled(FlexView)<{ $visible: boolean }>(({ theme, $visible }) => {\n const { gutter } = theme.layout;\n\n if (!$visible) {\n return ``;\n }\n\n return `\n padding-top: ${gutter * 1.5}px;\n padding-bottom: ${gutter * 2}px;\n `;\n});\n\nconst PuzzleContainer = styled(FlexView)<{ $imageHue: THueNames; $backgroundOpacity?: number }>`\n position: relative;\n margin: 0 auto;\n box-shadow: inset 0px 0px 0px 4px ${({ theme, $imageHue }) => theme.colors[`${$imageHue}_4`]};\n max-width: 343px;\n width: 100%;\n min-height: 412px;\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-image: ${({ $imageHue }) => `url(${getPuzzleCardPattern($imageHue)})`};\n background-size: cover;\n opacity: 0.2;\n }\n`;\n\nconst QuestionCard = styled(FlexView)`\n background-color: transparent;\n\n .puzzle-question-content {\n font-size: 16px;\n line-height: 1.6em;\n color: ${({ theme }) => theme.colors.BLACK};\n font-family: 'Noto Serif', serif;\n\n em {\n font-style: italic;\n }\n\n ul,\n ol {\n list-style-type: initial;\n padding-left: 32px;\n }\n\n ol {\n list-style-type: decimal;\n }\n\n p {\n margin: 12px 0;\n }\n\n li {\n margin: 4px 0;\n }\n }\n`;\n\nconst StyledHintFillIcon = styled(HintFillIcon)`\n color: ${({ theme }) => theme.colors.BLACK_1};\n\n & .hint-fill-icon-path {\n fill: ${({ theme }) => theme.colors.WHITE_1};\n }\n`;\n\nconst StyledFeedbackText = styled(Text)`\n & span {\n font-weight: 700;\n margin-right: 4px;\n }\n`;\n\nconst PuzzleQuestionWrapper = styled.div`\n color: ${({ theme }) => theme.colors.BLACK};\n font-size: 14px;\n line-height: 1.2;\n font-family: 'Athletics';\n\n font-weight: 400;\n font-style: normal;\n\n em {\n font-style: italic;\n }\n\n ul,\n ol {\n list-style-type: initial;\n padding-left: 32px;\n }\n\n ol {\n list-style-type: decimal;\n }\n\n p {\n margin: 0;\n }\n\n li {\n margin: 4px 0;\n }\n`;\n\nexport {\n PuzzleAppWrapper,\n PuzzleContainer,\n QuestionCard,\n StyledFeedbackText,\n StyledHintFillIcon,\n PuzzleQuestionWrapper,\n};\n"],"names":["PuzzleAppWrapper","styled","FlexView","theme","$visible","gutter","PuzzleContainer","$imageHue","getPuzzleCardPattern","QuestionCard","StyledHintFillIcon","HintFillIcon","StyledFeedbackText","Text","PuzzleQuestionWrapper"],"mappings":";;;;;AASM,MAAAA,IAAmBC,EAAOC,CAAQ,EAAyB,CAAC,EAAE,OAAAC,GAAO,UAAAC,QAAe;AAClF,QAAA,EAAE,QAAAC,EAAO,IAAIF,EAAM;AAEzB,SAAKC,IAIE;AAAA,mBACUC,IAAS,GAAG;AAAA,sBACTA,IAAS,CAAC;AAAA,MALrB;AAOX,CAAC,GAEKC,IAAkBL,EAAOC,CAAQ;AAAA;AAAA;AAAA,sCAGD,CAAC,EAAE,OAAAC,GAAO,WAAAI,QAAgBJ,EAAM,OAAO,GAAGI,CAAS,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAYtE,CAAC,EAAE,WAAAA,EAAU,MAAM,OAAOC,EAAqBD,CAAS,CAAC,GAAG;AAAA;AAAA;AAAA;AAAA,GAM9EE,IAAeR,EAAOC,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMvB,CAAC,EAAE,OAAAC,EAAA,MAAYA,EAAM,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA2BxCO,IAAqBT,EAAOU,CAAY;AAAA,WACnC,CAAC,EAAE,OAAAR,EAAA,MAAYA,EAAM,OAAO,OAAO;AAAA;AAAA;AAAA,YAGlC,CAAC,EAAE,OAAAA,EAAA,MAAYA,EAAM,OAAO,OAAO;AAAA;AAAA,GAIzCS,IAAqBX,EAAOY,CAAI;AAAA;AAAA;AAAA;AAAA;AAAA,GAOhCC,IAAwBb,EAAO;AAAA,WAC1B,CAAC,EAAE,OAAAE,EAAA,MAAYA,EAAM,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -0,0 +1,119 @@
1
+ import { jsxs as S, jsx as a } from "react/jsx-runtime";
2
+ import { memo as T, useRef as $, useCallback as _, useEffect as p, useMemo as A } from "react";
3
+ import H from "../../ui/image/image.js";
4
+ import M from "../../ui/separator/separator.js";
5
+ import f from "../../worksheet/constants/events.js";
6
+ import Q from "../../worksheet/worksheet/hooks/use-learnosity.js";
7
+ import x from "../../worksheet/worksheet/hooks/use-worksheet-data-helper.js";
8
+ import { getQuestionsFromItems as V } from "../../worksheet/worksheet/worksheet-helpers.js";
9
+ import { QuestionCard as C, PuzzleQuestionWrapper as L, PuzzleContainer as N } from "./puzzle-app-styled.js";
10
+ const P = (u) => {
11
+ if (!u) return null;
12
+ const t = u.match(/<img[^>]+src="([^">]+)"/);
13
+ return t ? t[1] : null;
14
+ }, j = ({
15
+ worksheetData: u,
16
+ loggerRef: t,
17
+ onWorksheetErrored: i,
18
+ imageHue: I,
19
+ onLoaded: d
20
+ }) => {
21
+ const { signed_request: z, questions_signed_request: g } = u, w = $(null), {
22
+ loadingState: r,
23
+ data: o,
24
+ error: m
25
+ } = x({
26
+ attemptId: void 0,
27
+ signedRequest: z,
28
+ loggerRef: t
29
+ }), E = _(
30
+ (s) => {
31
+ i({
32
+ code: s.code,
33
+ message: s.detail
34
+ });
35
+ },
36
+ [i]
37
+ ), { learnosity: n } = Q(g, E, t);
38
+ p(() => {
39
+ r === "error" && i({
40
+ message: m ?? "Error loading worksheet"
41
+ });
42
+ }, [r, i, m]), p(() => {
43
+ n && t.current(f.WORKSHEET_V3_LEARNOSITY_INITIALIZED);
44
+ }, [n, t]), p(() => {
45
+ n && r === "success" && d && (t.current(f.WORKSHEET_V3_READY), d());
46
+ }, [n, r, t, d]);
47
+ const c = A(() => r === "success" && (o != null && o.learnosityItems) ? (t.current(f.WORKSHEET_V3_READY), V(o.learnosityItems, {
48
+ sectioned: !1,
49
+ adaptive: !1
50
+ }).map((e) => ({
51
+ response_id: e.response_id,
52
+ type: e.type,
53
+ stimulus: e.stimulus,
54
+ template: e.template,
55
+ stimulus_review: e.stimulus_review,
56
+ options: e.options,
57
+ metadata: e.metadata,
58
+ validation: e.validation
59
+ // Add other properties as needed
60
+ }))) : r === "error" || m ? [] : [], [r, o, m, t]);
61
+ p(() => {
62
+ if (n && c.length > 0) {
63
+ const l = requestAnimationFrame(() => {
64
+ try {
65
+ n.renderMath("mathjax");
66
+ } catch (e) {
67
+ i({
68
+ message: `MathJax rendering failed: ${e instanceof Error ? e.message : "Unknown error"}`
69
+ });
70
+ }
71
+ });
72
+ return () => {
73
+ cancelAnimationFrame(l);
74
+ };
75
+ }
76
+ }, [n, i, c]);
77
+ const y = _((s) => {
78
+ const { stimulus: l = "", template: e = "", response_id: v } = s, h = P(l);
79
+ return /* @__PURE__ */ S(
80
+ C,
81
+ {
82
+ $alignItems: "center",
83
+ className: "puzzle-app-view-question-card",
84
+ children: [
85
+ h && /* @__PURE__ */ a(
86
+ H,
87
+ {
88
+ src: h,
89
+ alt: "Puzzle illustration",
90
+ width: 183,
91
+ height: 183,
92
+ withLoader: !0
93
+ }
94
+ ),
95
+ /* @__PURE__ */ a(M, { heightX: 1 }),
96
+ e && /* @__PURE__ */ a(L, { children: /* @__PURE__ */ a("div", { dangerouslySetInnerHTML: { __html: e } }) })
97
+ ]
98
+ },
99
+ v
100
+ );
101
+ }, []);
102
+ return c.length ? /* @__PURE__ */ a(
103
+ N,
104
+ {
105
+ ref: w,
106
+ $gapX: 1,
107
+ $gutterX: 1,
108
+ $imageHue: I,
109
+ $background: "WHITE_1",
110
+ className: "puzzle-app-view-container",
111
+ $justifyContent: "center",
112
+ children: c.map((s) => /* @__PURE__ */ a("div", { children: y(s) }, `question-${s.response_id}`))
113
+ }
114
+ ) : null;
115
+ }, b = T(j);
116
+ export {
117
+ b as default
118
+ };
119
+ //# sourceMappingURL=puzzle-app-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puzzle-app-view.js","sources":["../../../../src/features/puzzles/app/puzzle-app-view.tsx"],"sourcesContent":["import type {\n ILearnosityError,\n ILearnosityQuestion,\n} from '../../worksheet/worksheet/worksheet-types';\nimport type { IPuzzleAppViewProps } from './puzzle-app-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport Image from '../../ui/image/image';\nimport Separator from '../../ui/separator/separator';\nimport EVENTS from '../../worksheet/constants/events';\nimport useLearnosity from '../../worksheet/worksheet/hooks/use-learnosity';\nimport useWorksheetDataHelper from '../../worksheet/worksheet/hooks/use-worksheet-data-helper';\nimport { getQuestionsFromItems } from '../../worksheet/worksheet/worksheet-helpers';\nimport * as Styled from './puzzle-app-styled';\n\nconst extractImageFromHTML = (htmlString: string) => {\n if (!htmlString) return null;\n\n const imgMatch = htmlString.match(/<img[^>]+src=\"([^\">]+)\"/);\n\n return imgMatch ? imgMatch[1] : null;\n};\n\nconst PuzzleAppView: FC<IPuzzleAppViewProps> = ({\n worksheetData,\n loggerRef,\n onWorksheetErrored,\n imageHue,\n onLoaded,\n}) => {\n const { signed_request: itemsSignedRequest, questions_signed_request: questionSignedRequest } =\n worksheetData;\n\n // Ref for the container to trigger MathJax rendering\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Get Learnosity items using the signed_request (not questions_signed_request)\n const {\n loadingState,\n data: learnosityData,\n error: worksheetError,\n } = useWorksheetDataHelper({\n attemptId: undefined,\n signedRequest: itemsSignedRequest,\n loggerRef,\n });\n\n const onLearnosityErrored = useCallback(\n (err: ILearnosityError) => {\n onWorksheetErrored({\n code: err.code,\n message: err.detail,\n });\n },\n [onWorksheetErrored],\n );\n\n // Initialize Learnosity using questions_signed_request (needed for interactive questions)\n const { learnosity } = useLearnosity(questionSignedRequest, onLearnosityErrored, loggerRef);\n\n useEffect(() => {\n if (loadingState === 'error') {\n onWorksheetErrored({\n message: worksheetError ?? 'Error loading worksheet',\n });\n }\n }, [loadingState, onWorksheetErrored, worksheetError]);\n\n // Log when learnosity is ready for future interactive features\n useEffect(() => {\n if (learnosity) {\n loggerRef.current(EVENTS.WORKSHEET_V3_LEARNOSITY_INITIALIZED);\n }\n }, [learnosity, loggerRef]);\n\n useEffect(() => {\n if (learnosity && loadingState === 'success' && onLoaded) {\n loggerRef.current(EVENTS.WORKSHEET_V3_READY);\n onLoaded();\n }\n }, [learnosity, loadingState, loggerRef, onLoaded]);\n\n // Memoize questions processing to prevent re-render loops\n const questions = useMemo(() => {\n // Extract questions from Learnosity items when data is loaded successfully\n if (loadingState === 'success' && learnosityData?.learnosityItems) {\n loggerRef.current(EVENTS.WORKSHEET_V3_READY);\n\n // Convert learnosityItems to questions using the worksheet helper\n const worksheetQuestions = getQuestionsFromItems(learnosityData.learnosityItems, {\n sectioned: false,\n adaptive: false,\n });\n\n // Extract just the Learnosity questions from worksheet questions\n const learnosityQuestions: ILearnosityQuestion[] = worksheetQuestions.map(q => ({\n response_id: q.response_id,\n type: q.type,\n stimulus: q.stimulus,\n template: q.template,\n stimulus_review: q.stimulus_review,\n options: q.options,\n metadata: q.metadata,\n validation: q.validation,\n // Add other properties as needed\n }));\n\n return learnosityQuestions;\n }\n\n if (loadingState === 'error' || worksheetError) {\n return [];\n }\n\n return [];\n }, [loadingState, learnosityData, worksheetError, loggerRef]);\n\n // Force MathJax rendering after questions are loaded and rendered\n // Similar to how useLearnosityAppend does it\n useEffect(() => {\n if (learnosity && questions.length > 0) {\n // Use requestAnimationFrame to ensure DOM is updated before rendering math\n const renderMath = () => {\n try {\n learnosity.renderMath('mathjax');\n } catch (error) {\n onWorksheetErrored({\n message: `MathJax rendering failed: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n });\n }\n };\n\n const animationId = requestAnimationFrame(renderMath);\n\n return () => {\n cancelAnimationFrame(animationId);\n };\n }\n }, [learnosity, onWorksheetErrored, questions]);\n\n const renderQuestionContent = useCallback((question: ILearnosityQuestion) => {\n const { stimulus = '', template = '', response_id: responseId } = question;\n const imageUrl = extractImageFromHTML(stimulus);\n\n return (\n <Styled.QuestionCard\n key={responseId}\n $alignItems=\"center\"\n className=\"puzzle-app-view-question-card\"\n >\n {/* Main Image or Interactive Content */}\n {imageUrl && (\n <Image\n src={imageUrl}\n alt=\"Puzzle illustration\"\n width={183}\n height={183}\n withLoader={true}\n />\n )}\n\n <Separator heightX={1} />\n\n {/* Question HTML Content */}\n {template && (\n <Styled.PuzzleQuestionWrapper>\n <div dangerouslySetInnerHTML={{ __html: template }} />\n </Styled.PuzzleQuestionWrapper>\n )}\n </Styled.QuestionCard>\n );\n }, []);\n\n if (!questions.length) return null;\n\n return (\n <Styled.PuzzleContainer\n ref={containerRef}\n $gapX={1}\n $gutterX={1}\n $imageHue={imageHue}\n $background=\"WHITE_1\"\n className=\"puzzle-app-view-container\"\n $justifyContent=\"center\"\n >\n {questions.map(question => (\n <div key={`question-${question.response_id}`}>{renderQuestionContent(question)}</div>\n ))}\n </Styled.PuzzleContainer>\n );\n};\n\nexport default memo(PuzzleAppView);\n"],"names":["extractImageFromHTML","htmlString","imgMatch","PuzzleAppView","worksheetData","loggerRef","onWorksheetErrored","imageHue","onLoaded","itemsSignedRequest","questionSignedRequest","containerRef","useRef","loadingState","learnosityData","worksheetError","useWorksheetDataHelper","onLearnosityErrored","useCallback","err","learnosity","useLearnosity","useEffect","EVENTS","questions","useMemo","getQuestionsFromItems","q","animationId","error","renderQuestionContent","question","stimulus","template","responseId","imageUrl","jsxs","Styled.QuestionCard","jsx","Image","Separator","Styled.PuzzleQuestionWrapper","Styled.PuzzleContainer","PuzzleAppView$1","memo"],"mappings":";;;;;;;;;AAiBA,MAAMA,IAAuB,CAACC,MAAuB;AAC/C,MAAA,CAACA,EAAmB,QAAA;AAElB,QAAAC,IAAWD,EAAW,MAAM,yBAAyB;AAEpD,SAAAC,IAAWA,EAAS,CAAC,IAAI;AAClC,GAEMC,IAAyC,CAAC;AAAA,EAC9C,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgBC,GAAoB,0BAA0BC,MACpEN,GAGIO,IAAeC,EAAuB,IAAI,GAG1C;AAAA,IACJ,cAAAC;AAAA,IACA,MAAMC;AAAA,IACN,OAAOC;AAAA,MACLC,EAAuB;AAAA,IACzB,WAAW;AAAA,IACX,eAAeP;AAAA,IACf,WAAAJ;AAAA,EAAA,CACD,GAEKY,IAAsBC;AAAA,IAC1B,CAACC,MAA0B;AACN,MAAAb,EAAA;AAAA,QACjB,MAAMa,EAAI;AAAA,QACV,SAASA,EAAI;AAAA,MAAA,CACd;AAAA,IACH;AAAA,IACA,CAACb,CAAkB;AAAA,EAAA,GAIf,EAAE,YAAAc,EAAW,IAAIC,EAAcX,GAAuBO,GAAqBZ,CAAS;AAE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ragment as W } from "react/jsx-runtime";
2
+ import { memo as P, useState as d, useRef as v, useCallback as n, useEffect as y } from "react";
3
+ import R from "../../ui/error/error.js";
4
+ import h from "../../ui/layout/flex-view.js";
5
+ import F from "../../ui/loader/app-loader/app-loader.js";
6
+ import p from "../../ui/text/text.js";
7
+ import { usePreviewWorksheetGet as I } from "../../worksheet/worksheet-preview/api/get-preview-worksheet.js";
8
+ import { PuzzleAppWrapper as L, StyledFeedbackText as T, StyledHintFillIcon as j } from "./puzzle-app-styled.js";
9
+ import C from "./puzzle-app-view.js";
10
+ const D = ({ itemRef: s, title: m, imageHue: i, feedbackComments: l, tip: f }) => {
11
+ const [u, $] = d(), [r, g] = d(!1), { isProcessing: k, get: a, data: c, error: w } = I(), z = v(() => null), A = f || "Celebrate persistence more than correct answers - it's a life skill worth building.", t = n(() => {
12
+ a("test", {
13
+ action: "review",
14
+ node_type: "PUZZLE_CARD",
15
+ items: [s]
16
+ });
17
+ }, [a, s]);
18
+ y(() => {
19
+ t();
20
+ }, [t]);
21
+ const b = n((E) => {
22
+ $(E.message);
23
+ }, []), x = n(() => {
24
+ g(!0);
25
+ }, []);
26
+ return u || w ? /* @__PURE__ */ e(R, { height: "100vh", onTryAgain: t }) : k ? /* @__PURE__ */ e(F, { height: "100vh" }) : /* @__PURE__ */ o(
27
+ L,
28
+ {
29
+ className: "puzzle-app-container",
30
+ $background: `${i}_2`,
31
+ $alignItems: "center",
32
+ $justifyContent: "center",
33
+ $flexGapX: 1,
34
+ $gutterX: 1,
35
+ $height: "100%",
36
+ $visible: r,
37
+ children: [
38
+ r && /* @__PURE__ */ e(p, { $renderAs: "ab1-bold", children: m }),
39
+ c && /* @__PURE__ */ e(
40
+ C,
41
+ {
42
+ onWorksheetErrored: b,
43
+ worksheetData: c,
44
+ loggerRef: z,
45
+ imageHue: i,
46
+ onLoaded: x
47
+ }
48
+ ),
49
+ r && /* @__PURE__ */ e(W, { children: l ? /* @__PURE__ */ o(T, { $renderAs: "ab2", children: [
50
+ /* @__PURE__ */ e("span", { children: "Tutor Remark:" }),
51
+ l
52
+ ] }) : /* @__PURE__ */ o(h, { $flexDirection: "row", $alignItems: "center", $flexGap: 8, children: [
53
+ /* @__PURE__ */ e(h, { $width: 24, $height: 24, children: /* @__PURE__ */ e(j, {}) }),
54
+ /* @__PURE__ */ e(p, { $renderAs: "ab2", children: A })
55
+ ] }) })
56
+ ]
57
+ }
58
+ );
59
+ }, B = P(D);
60
+ export {
61
+ B as default
62
+ };
63
+ //# sourceMappingURL=puzzle-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puzzle-app.js","sources":["../../../../src/features/puzzles/app/puzzle-app.tsx"],"sourcesContent":["import type { IPuzzleAppProps } from './puzzle-app-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useRef, useState } from 'react';\n\nimport Error from '../../ui/error/error';\nimport FlexView from '../../ui/layout/flex-view';\nimport AppLoader from '../../ui/loader/app-loader/app-loader';\nimport Text from '../../ui/text/text';\nimport { usePreviewWorksheetGet } from '../../worksheet/worksheet-preview/api/get-preview-worksheet';\nimport * as Styled from './puzzle-app-styled';\nimport PuzzleAppView from './puzzle-app-view';\n\nconst PuzzleApp: FC<IPuzzleAppProps> = ({ itemRef, title, imageHue, feedbackComments, tip }) => {\n const [error, setError] = useState<string>();\n const [worksheetRendered, setWorksheetRendered] = useState<boolean>(false);\n\n const { isProcessing, get, data: worksheetData, error: fetchError } = usePreviewWorksheetGet();\n const loggerRef = useRef(() => null);\n\n const tipInfo =\n tip || `Celebrate persistence more than correct answers - it's a life skill worth building.`;\n\n const fetchWorksheet = useCallback(() => {\n get('test', {\n action: 'review',\n node_type: 'PUZZLE_CARD',\n items: [itemRef],\n });\n }, [get, itemRef]);\n\n useEffect(() => {\n fetchWorksheet();\n }, [fetchWorksheet]);\n\n const handleWorksheetErrored = useCallback((err: { code?: number; message: string }) => {\n setError(err.message);\n }, []);\n\n const handleWorksheetLoaded = useCallback(() => {\n setWorksheetRendered(true);\n }, []);\n\n if (error || fetchError) {\n return <Error height=\"100vh\" onTryAgain={fetchWorksheet} />;\n }\n\n if (isProcessing) {\n return <AppLoader height=\"100vh\" />;\n }\n\n return (\n <Styled.PuzzleAppWrapper\n className=\"puzzle-app-container\"\n $background={`${imageHue}_2`}\n $alignItems=\"center\"\n $justifyContent=\"center\"\n $flexGapX={1}\n $gutterX={1}\n $height=\"100%\"\n $visible={worksheetRendered}\n >\n {worksheetRendered && <Text $renderAs=\"ab1-bold\">{title}</Text>}\n\n {worksheetData && (\n <PuzzleAppView\n onWorksheetErrored={handleWorksheetErrored}\n worksheetData={worksheetData}\n loggerRef={loggerRef}\n imageHue={imageHue}\n onLoaded={handleWorksheetLoaded}\n />\n )}\n\n {worksheetRendered && (\n <>\n {feedbackComments ? (\n <Styled.StyledFeedbackText $renderAs=\"ab2\">\n <span>Tutor Remark:</span>\n {feedbackComments}\n </Styled.StyledFeedbackText>\n ) : (\n <FlexView $flexDirection=\"row\" $alignItems=\"center\" $flexGap={8}>\n <FlexView $width={24} $height={24}>\n <Styled.StyledHintFillIcon />\n </FlexView>\n <Text $renderAs=\"ab2\">{tipInfo}</Text>\n </FlexView>\n )}\n </>\n )}\n </Styled.PuzzleAppWrapper>\n );\n};\n\nexport default memo(PuzzleApp);\n"],"names":["PuzzleApp","itemRef","title","imageHue","feedbackComments","tip","error","setError","useState","worksheetRendered","setWorksheetRendered","isProcessing","get","worksheetData","fetchError","usePreviewWorksheetGet","loggerRef","useRef","tipInfo","fetchWorksheet","useCallback","useEffect","handleWorksheetErrored","err","handleWorksheetLoaded","jsx","Error","AppLoader","jsxs","Styled.PuzzleAppWrapper","Text","PuzzleAppView","Styled.StyledFeedbackText","FlexView","Styled.StyledHintFillIcon","puzzleApp","memo"],"mappings":";;;;;;;;;AAaA,MAAMA,IAAiC,CAAC,EAAE,SAAAC,GAAS,OAAAC,GAAO,UAAAC,GAAU,kBAAAC,GAAkB,KAAAC,QAAU;AAC9F,QAAM,CAACC,GAAOC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A,QACZ;AAAA,QAGDf,4BAEI,UACCL,IAAA,gBAAAwB,EAACI,GAAA,EAA0B,WAAU,OACnC,UAAA;AAAA,UAAA,gBAAAP,EAAC,UAAK,UAAa,gBAAA,CAAA;AAAA,UAClBrB;AAAA,QACH,EAAA,CAAA,sBAEC6B,GAAS,EAAA,gBAAe,OAAM,aAAY,UAAS,UAAU,GAC5D,UAAA;AAAA,UAAC,gBAAAR,EAAAQ,GAAA,EAAS,QAAQ,IAAI,SAAS,IAC7B,UAAC,gBAAAR,EAAAS,GAAA,CAAA,CAA0B,EAC7B,CAAA;AAAA,UACC,gBAAAT,EAAAK,GAAA,EAAK,WAAU,OAAO,UAAQZ,GAAA;AAAA,QAAA,EAAA,CACjC,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,GAEeiB,IAAAC,EAAKpC,CAAS;"}
package/dist/index.d.ts CHANGED
@@ -564,6 +564,8 @@ export declare const HelpIcon: React_2.FC<React_2.SVGProps<SVGSVGElement>>;
564
564
 
565
565
  export declare const HighlighterIcon: React.FC<React.SVGProps<SVGSVGElement>>;
566
566
 
567
+ export declare const HintFillIcon: React.FC<React.SVGProps<SVGSVGElement>>;
568
+
567
569
  export declare const HomeIcon: React_2.FC<React_2.SVGProps<SVGSVGElement>>;
568
570
 
569
571
  export declare const HomeworkCardList: React_2.NamedExoticComponent<HWCardListProps>;
@@ -2826,6 +2828,14 @@ declare interface IPuzzle extends IBaseProject {
2826
2828
  solved: boolean;
2827
2829
  }
2828
2830
 
2831
+ declare interface IPuzzleAppProps {
2832
+ itemRef: string;
2833
+ title: string;
2834
+ imageHue: THueNames;
2835
+ feedbackComments?: string;
2836
+ tip?: string;
2837
+ }
2838
+
2829
2839
  export declare interface IPuzzleCard {
2830
2840
  sheetData: TLPARSheetData;
2831
2841
  blockStatus?: TPuzzleCardBlockStatus | null;
@@ -2995,6 +3005,7 @@ export declare interface IReviewWorksheetModel {
2995
3005
  title?: string;
2996
3006
  worksheet_id?: string;
2997
3007
  node_type: TNodeTypes;
3008
+ items?: TWorksheetItems[];
2998
3009
  }
2999
3010
 
3000
3011
  declare interface ISATSheetItemCallbacks {
@@ -4606,6 +4617,8 @@ declare const PUZZLE_CARD_STATE: {
4606
4617
 
4607
4618
  declare const PUZZLE_CARDS: "puzzle_cards";
4608
4619
 
4620
+ export declare const PuzzleApp: NamedExoticComponent<IPuzzleAppProps>;
4621
+
4609
4622
  export declare const PuzzleCard: FC<IPuzzleCardContainerProps>;
4610
4623
 
4611
4624
  export declare const PuzzleFeedbackCelebration: FC;
@@ -5942,6 +5955,10 @@ export declare const Tutorial: ({ src, title, onCross, showProgress, onTutorialP
5942
5955
 
5943
5956
  export declare const TutoringIcon: React_2.FC<React_2.SVGProps<SVGSVGElement>>;
5944
5957
 
5958
+ declare type TWorksheetItems = {
5959
+ ref: string;
5960
+ };
5961
+
5945
5962
  declare type TWORKSHHET_QUESTION_MEDIA_TYPE = 'SIMULATION' | 'VIDEO' | 'AUDIO';
5946
5963
 
5947
5964
  export declare type TZIndexMap = Record<keyof typeof ZINDEX, number>;