@cuemath/leap 4.1.7-link.0 → 4.1.7-link.1
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.
|
@@ -1,65 +1,70 @@
|
|
|
1
|
-
import { jsxs as C, jsx as
|
|
2
|
-
import { memo as z, useMemo as T, useCallback as
|
|
3
|
-
import
|
|
1
|
+
import { jsxs as C, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { memo as z, useMemo as T, useCallback as a, useEffect as G } from "react";
|
|
3
|
+
import d from "../../../ui/layout/flex-view.js";
|
|
4
4
|
import S from "../../../ui/separator/separator.js";
|
|
5
5
|
import M from "../slide-header/index.js";
|
|
6
|
-
import { MAXIMUM_TOPICS_TO_SELECT as
|
|
6
|
+
import { MAXIMUM_TOPICS_TO_SELECT as E, RIGHT_PANEL_CONTENT_WIDTH as N } from "../../trial-session-constants.js";
|
|
7
7
|
import { useTrialSessionContext as O } from "../../context/use-trial-session-context.js";
|
|
8
8
|
import { getTopicsToShow as j } from "./topic-selection-helpers.js";
|
|
9
9
|
import F from "./topic-item.js";
|
|
10
|
-
import
|
|
10
|
+
import p from "../../../ui/inputs/select-input/select-input.js";
|
|
11
11
|
import { getGradesFromConfig as H, getPreferencesFromConfig as P } from "../../../milestone/create/milestone-create-helpers.js";
|
|
12
12
|
import { COURSE_STREAMS as B, PREFERENCE_CATEGORY as U } from "../../../milestone/constants.js";
|
|
13
13
|
import { getCourseOptions as V } from "../student-info/student-info-helpers.js";
|
|
14
14
|
const W = z(() => {
|
|
15
15
|
const {
|
|
16
|
-
formData:
|
|
17
|
-
trialHomeData:
|
|
18
|
-
milestoneConfig:
|
|
19
|
-
trialTopics:
|
|
20
|
-
updateSlideConfig:
|
|
21
|
-
updateButtonState:
|
|
22
|
-
} = O(), { grade:
|
|
23
|
-
() => P(
|
|
24
|
-
grade:
|
|
16
|
+
formData: y,
|
|
17
|
+
trialHomeData: _,
|
|
18
|
+
milestoneConfig: l,
|
|
19
|
+
trialTopics: c,
|
|
20
|
+
updateSlideConfig: t,
|
|
21
|
+
updateButtonState: f
|
|
22
|
+
} = O(), { grade: o = "2", course: i, selectedTopics: n = [], personalizedLevel: s = [] } = y || {}, { demo_info: v } = _, { region_data: L } = v, { opportunity_country: u = "US" } = L || {}, $ = H(l), m = V(Number(o)), g = !!(n.length === E && (!(m.length > 0) || i) && o && s.length > 0), I = T(
|
|
23
|
+
() => P(l, {
|
|
24
|
+
grade: o ?? "",
|
|
25
25
|
courseStream: B.MATH,
|
|
26
26
|
preferenceCategory: U.LEVEL
|
|
27
27
|
}),
|
|
28
|
-
[
|
|
29
|
-
), w = T(() =>
|
|
28
|
+
[o, l]
|
|
29
|
+
), w = T(() => c ? j(c, { countryCode: u, grade: o, course: i }) : [], [u, i, o, c]), x = a(
|
|
30
30
|
(e) => {
|
|
31
|
-
|
|
31
|
+
e !== o && t({
|
|
32
|
+
grade: e,
|
|
33
|
+
course: void 0,
|
|
34
|
+
selectedTopics: [],
|
|
35
|
+
personalizedLevel: []
|
|
36
|
+
});
|
|
32
37
|
},
|
|
33
|
-
[o]
|
|
34
|
-
), A =
|
|
38
|
+
[o, t]
|
|
39
|
+
), A = a(
|
|
35
40
|
(e) => {
|
|
36
|
-
|
|
41
|
+
s[0] !== e && t({ personalizedLevel: [e], selectedTopics: [] });
|
|
37
42
|
},
|
|
38
|
-
[
|
|
39
|
-
), D =
|
|
43
|
+
[s, t]
|
|
44
|
+
), D = a(
|
|
40
45
|
(e) => {
|
|
41
|
-
|
|
46
|
+
e !== i && t({ course: e, selectedTopics: [] });
|
|
42
47
|
},
|
|
43
|
-
[
|
|
44
|
-
), R =
|
|
48
|
+
[i, t]
|
|
49
|
+
), R = a(
|
|
45
50
|
(e) => {
|
|
46
51
|
const h = n.includes(e), b = h ? n.filter((k) => k !== e) : [...n, e];
|
|
47
|
-
!h && n.length >=
|
|
52
|
+
!h && n.length >= E || t({ selectedTopics: b });
|
|
48
53
|
},
|
|
49
|
-
[n,
|
|
54
|
+
[n, t]
|
|
50
55
|
);
|
|
51
56
|
return G(() => {
|
|
52
|
-
|
|
53
|
-
}, [g,
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */ C(
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
|
|
57
|
+
f("right", { isDisabled: !g, isLoading: !1 });
|
|
58
|
+
}, [g, f]), /* @__PURE__ */ C(d, { $justifyContent: "center", $alignItems: "center", children: [
|
|
59
|
+
/* @__PURE__ */ r(S, { height: 60 }),
|
|
60
|
+
/* @__PURE__ */ r(M, { marginBottom: 25 }),
|
|
61
|
+
/* @__PURE__ */ C(d, { $flexDirection: "row", $justifyContent: "center", $alignItems: "center", $flexGapX: 1.5, children: [
|
|
62
|
+
/* @__PURE__ */ r(
|
|
63
|
+
p,
|
|
59
64
|
{
|
|
60
65
|
renderAs: "primary",
|
|
61
66
|
label: "Grade",
|
|
62
|
-
value:
|
|
67
|
+
value: o,
|
|
63
68
|
options: $,
|
|
64
69
|
shape: "curved",
|
|
65
70
|
size: "small",
|
|
@@ -68,13 +73,13 @@ const W = z(() => {
|
|
|
68
73
|
width: 100
|
|
69
74
|
}
|
|
70
75
|
),
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
m.length > 0 ? /* @__PURE__ */ r(
|
|
77
|
+
p,
|
|
73
78
|
{
|
|
74
79
|
renderAs: "primary",
|
|
75
80
|
label: "Course",
|
|
76
81
|
value: i,
|
|
77
|
-
options:
|
|
82
|
+
options: m,
|
|
78
83
|
size: "small",
|
|
79
84
|
shape: "curved",
|
|
80
85
|
onChange: D,
|
|
@@ -82,12 +87,12 @@ const W = z(() => {
|
|
|
82
87
|
width: 137
|
|
83
88
|
}
|
|
84
89
|
) : void 0,
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
90
|
+
/* @__PURE__ */ r(
|
|
91
|
+
p,
|
|
87
92
|
{
|
|
88
93
|
renderAs: "primary",
|
|
89
94
|
label: "Level",
|
|
90
|
-
value:
|
|
95
|
+
value: s[0] ?? "",
|
|
91
96
|
options: I,
|
|
92
97
|
shape: "curved",
|
|
93
98
|
size: "small",
|
|
@@ -97,16 +102,16 @@ const W = z(() => {
|
|
|
97
102
|
}
|
|
98
103
|
)
|
|
99
104
|
] }),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
|
|
105
|
+
/* @__PURE__ */ r(S, { height: 25 }),
|
|
106
|
+
/* @__PURE__ */ r(
|
|
107
|
+
d,
|
|
103
108
|
{
|
|
104
109
|
$width: N - 100,
|
|
105
110
|
$justifyContent: "center",
|
|
106
111
|
$alignItems: "center",
|
|
107
112
|
$flexDirection: "row",
|
|
108
113
|
$flexWrap: !0,
|
|
109
|
-
children: w.map((e) => /* @__PURE__ */
|
|
114
|
+
children: w.map((e) => /* @__PURE__ */ r(
|
|
110
115
|
F,
|
|
111
116
|
{
|
|
112
117
|
selectedTopics: n,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic-selection.js","sources":["../../../../../src/features/trial-session/comps/topic-selection/topic-selection.tsx"],"sourcesContent":["import { memo, useCallback, useEffect, useMemo } from 'react';\n\nimport FlexView from '../../../ui/layout/flex-view';\nimport Separator from '../../../ui/separator/separator';\nimport SlideHeader from '../slide-header';\nimport { MAXIMUM_TOPICS_TO_SELECT, RIGHT_PANEL_CONTENT_WIDTH } from '../../trial-session-constants';\nimport { useTrialSessionContext } from '../../context/use-trial-session-context';\nimport { getTopicsToShow } from './topic-selection-helpers';\nimport TopicItem from './topic-item';\nimport SelectInput from '../../../ui/inputs/select-input/select-input';\nimport {\n getGradesFromConfig,\n getPreferencesFromConfig,\n} from '../../../milestone/create/milestone-create-helpers';\nimport { COURSE_STREAMS, PREFERENCE_CATEGORY } from '../../../milestone/constants';\nimport { getCourseOptions } from '../student-info/student-info-helpers';\n\nconst TopicSelection = memo(() => {\n const {\n formData,\n trialHomeData,\n milestoneConfig,\n trialTopics,\n updateSlideConfig,\n updateButtonState,\n } = useTrialSessionContext();\n const { grade = '2', course, selectedTopics = [], personalizedLevel = [] } = formData || {}; // reset grade\n const { demo_info: demoInfo } = trialHomeData;\n const { region_data: regionData } = demoInfo;\n const { opportunity_country: countryCode = 'US' } = regionData || {};\n\n const grades = getGradesFromConfig(milestoneConfig);\n const courses = getCourseOptions(Number(grade));\n\n const hasRequiredFields = Boolean(\n selectedTopics.length === MAXIMUM_TOPICS_TO_SELECT &&\n (courses.length > 0 ? course : true) &&\n grade &&\n personalizedLevel.length > 0,\n );\n\n const levelList = useMemo(\n () =>\n getPreferencesFromConfig(milestoneConfig, {\n grade: grade ?? '',\n courseStream: COURSE_STREAMS.MATH,\n preferenceCategory: PREFERENCE_CATEGORY.LEVEL,\n }),\n [grade, milestoneConfig],\n );\n\n const topicsToShow = useMemo(() => {\n if (!trialTopics) return [];\n\n return getTopicsToShow(trialTopics, { countryCode, grade, course });\n }, [countryCode, course, grade, trialTopics]);\n\n const onGradeChange = useCallback(\n (value: string) => {\n updateSlideConfig({
|
|
1
|
+
{"version":3,"file":"topic-selection.js","sources":["../../../../../src/features/trial-session/comps/topic-selection/topic-selection.tsx"],"sourcesContent":["import { memo, useCallback, useEffect, useMemo } from 'react';\n\nimport FlexView from '../../../ui/layout/flex-view';\nimport Separator from '../../../ui/separator/separator';\nimport SlideHeader from '../slide-header';\nimport { MAXIMUM_TOPICS_TO_SELECT, RIGHT_PANEL_CONTENT_WIDTH } from '../../trial-session-constants';\nimport { useTrialSessionContext } from '../../context/use-trial-session-context';\nimport { getTopicsToShow } from './topic-selection-helpers';\nimport TopicItem from './topic-item';\nimport SelectInput from '../../../ui/inputs/select-input/select-input';\nimport {\n getGradesFromConfig,\n getPreferencesFromConfig,\n} from '../../../milestone/create/milestone-create-helpers';\nimport { COURSE_STREAMS, PREFERENCE_CATEGORY } from '../../../milestone/constants';\nimport { getCourseOptions } from '../student-info/student-info-helpers';\n\nconst TopicSelection = memo(() => {\n const {\n formData,\n trialHomeData,\n milestoneConfig,\n trialTopics,\n updateSlideConfig,\n updateButtonState,\n } = useTrialSessionContext();\n const { grade = '2', course, selectedTopics = [], personalizedLevel = [] } = formData || {}; // reset grade\n const { demo_info: demoInfo } = trialHomeData;\n const { region_data: regionData } = demoInfo;\n const { opportunity_country: countryCode = 'US' } = regionData || {};\n\n const grades = getGradesFromConfig(milestoneConfig);\n const courses = getCourseOptions(Number(grade));\n\n const hasRequiredFields = Boolean(\n selectedTopics.length === MAXIMUM_TOPICS_TO_SELECT &&\n (courses.length > 0 ? course : true) &&\n grade &&\n personalizedLevel.length > 0,\n );\n\n const levelList = useMemo(\n () =>\n getPreferencesFromConfig(milestoneConfig, {\n grade: grade ?? '',\n courseStream: COURSE_STREAMS.MATH,\n preferenceCategory: PREFERENCE_CATEGORY.LEVEL,\n }),\n [grade, milestoneConfig],\n );\n\n const topicsToShow = useMemo(() => {\n if (!trialTopics) return [];\n\n return getTopicsToShow(trialTopics, { countryCode, grade, course });\n }, [countryCode, course, grade, trialTopics]);\n\n const onGradeChange = useCallback(\n (value: string) => {\n if (value === grade) return;\n\n updateSlideConfig({\n grade: value,\n course: undefined,\n selectedTopics: [],\n personalizedLevel: [],\n });\n },\n [grade, updateSlideConfig],\n );\n\n const onLevelChange = useCallback(\n (value: string) => {\n if (personalizedLevel[0] === value) return;\n\n updateSlideConfig({ personalizedLevel: [value], selectedTopics: [] });\n },\n [personalizedLevel, updateSlideConfig],\n );\n\n const onCourseChange = useCallback(\n (value: string) => {\n if (value === course) return;\n updateSlideConfig({ course: value, selectedTopics: [] });\n },\n [course, updateSlideConfig],\n );\n\n const handleClick = useCallback(\n (topicTitle: string) => {\n const isAlreadySelected = selectedTopics.includes(topicTitle);\n const updatedTopics = isAlreadySelected\n ? selectedTopics.filter(topic => topic !== topicTitle)\n : [...selectedTopics, topicTitle];\n\n if (!isAlreadySelected && selectedTopics.length >= MAXIMUM_TOPICS_TO_SELECT) return;\n\n updateSlideConfig({ selectedTopics: updatedTopics });\n },\n [selectedTopics, updateSlideConfig],\n );\n\n useEffect(() => {\n updateButtonState('right', { isDisabled: !hasRequiredFields, isLoading: false });\n }, [hasRequiredFields, updateButtonState]);\n\n return (\n <FlexView $justifyContent=\"center\" $alignItems=\"center\">\n <Separator height={60} />\n <SlideHeader marginBottom={25} />\n <FlexView $flexDirection=\"row\" $justifyContent=\"center\" $alignItems=\"center\" $flexGapX={1.5}>\n <SelectInput\n renderAs=\"primary\"\n label=\"Grade\"\n value={grade}\n options={grades}\n shape=\"curved\"\n size=\"small\"\n onChange={onGradeChange}\n theme=\"dark\"\n width={100}\n />\n {courses.length > 0 ? (\n <SelectInput\n renderAs=\"primary\"\n label=\"Course\"\n value={course}\n options={courses}\n size=\"small\"\n shape=\"curved\"\n onChange={onCourseChange}\n theme=\"dark\"\n width={137}\n />\n ) : undefined}\n <SelectInput\n renderAs=\"primary\"\n label=\"Level\"\n value={personalizedLevel[0] ?? ''}\n options={levelList}\n shape=\"curved\"\n size=\"small\"\n onChange={onLevelChange}\n theme=\"dark\"\n width={127}\n />\n </FlexView>\n <Separator height={25} />\n <FlexView\n $width={RIGHT_PANEL_CONTENT_WIDTH - 100}\n $justifyContent=\"center\"\n $alignItems=\"center\"\n $flexDirection=\"row\"\n $flexWrap\n >\n {topicsToShow.map(topic => (\n <TopicItem\n key={topic.topic_name}\n selectedTopics={selectedTopics}\n topic={topic}\n onClick={handleClick}\n />\n ))}\n </FlexView>\n </FlexView>\n );\n});\n\nTopicSelection.displayName = 'TopicSelection';\n\nexport default TopicSelection;\n"],"names":["TopicSelection","memo","formData","trialHomeData","milestoneConfig","trialTopics","updateSlideConfig","updateButtonState","useTrialSessionContext","grade","course","selectedTopics","personalizedLevel","demoInfo","regionData","countryCode","grades","getGradesFromConfig","courses","getCourseOptions","hasRequiredFields","MAXIMUM_TOPICS_TO_SELECT","levelList","useMemo","getPreferencesFromConfig","COURSE_STREAMS","PREFERENCE_CATEGORY","topicsToShow","getTopicsToShow","onGradeChange","useCallback","value","onLevelChange","onCourseChange","handleClick","topicTitle","isAlreadySelected","updatedTopics","topic","useEffect","jsxs","FlexView","jsx","Separator","SlideHeader","SelectInput","RIGHT_PANEL_CONTENT_WIDTH","TopicItem"],"mappings":";;;;;;;;;;;;;AAiBM,MAAAA,IAAiBC,EAAK,MAAM;AAC1B,QAAA;AAAA,IACJ,UAAAC;AAAA,IACA,eAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,mBAAAC;AAAA,MACEC,EAAuB,GACrB,EAAE,OAAAC,IAAQ,KAAK,QAAAC,GAAQ,gBAAAC,IAAiB,IAAI,mBAAAC,IAAoB,CAAC,EAAA,IAAMV,KAAY,IACnF,EAAE,WAAWW,EAAa,IAAAV,GAC1B,EAAE,aAAaW,EAAe,IAAAD,GAC9B,EAAE,qBAAqBE,IAAc,KAAK,IAAID,KAAc,CAAA,GAE5DE,IAASC,EAAoBb,CAAe,GAC5Cc,IAAUC,EAAiB,OAAOV,CAAK,CAAC,GAExCW,IAAoB,GACxBT,EAAe,WAAWU,MACvB,EAAAH,EAAQ,SAAS,MAAIR,MACtBD,KACAG,EAAkB,SAAS,IAGzBU,IAAYC;AAAA,IAChB,MACEC,EAAyBpB,GAAiB;AAAA,MACxC,OAAOK,KAAS;AAAA,MAChB,cAAcgB,EAAe;AAAA,MAC7B,oBAAoBC,EAAoB;AAAA,IAAA,CACzC;AAAA,IACH,CAACjB,GAAOL,CAAe;AAAA,EAAA,GAGnBuB,IAAeJ,EAAQ,MACtBlB,IAEEuB,EAAgBvB,GAAa,EAAE,aAAAU,GAAa,OAAAN,GAAO,QAAAC,GAAQ,IAFzC,IAGxB,CAACK,GAAaL,GAAQD,GAAOJ,CAAW,CAAC,GAEtCwB,IAAgBC;AAAA,IACpB,CAACC,MAAkB;AACjB,MAAIA,MAAUtB,KAEIH,EAAA;AAAA,QAChB,OAAOyB;AAAA,QACP,QAAQ;AAAA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