@cuemath/leap 2.8.62-rj-1 → 2.8.62-rj-3
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.
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel.js +49 -51
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel.js.map +1 -1
- package/dist/features/circle-games/game-launcher/game-launcher.js +67 -73
- package/dist/features/circle-games/game-launcher/game-launcher.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js +85 -90
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js.map +1 -1
- package/dist/features/journey/use-journey/journey-context-provider.js +46 -46
- package/dist/features/journey/use-journey/journey-context-provider.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/package.json +1 -1
@@ -1,42 +1,40 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import { Carousel as
|
8
|
-
const
|
9
|
-
const C = u(null), i =
|
10
|
-
|
11
|
-
),
|
12
|
-
|
13
|
-
}, [
|
14
|
-
|
15
|
-
}, [s]), k = d((r) => {
|
16
|
-
o(r);
|
1
|
+
import { jsxs as y, jsx as e } from "react/jsx-runtime";
|
2
|
+
import { memo as j, forwardRef as x, useMemo as u, useRef as b, useState as z, createRef as B, useCallback as d, useImperativeHandle as D, useEffect as $ } from "react";
|
3
|
+
import E from "../../../../../assets/line-icons/icons/carat-left.js";
|
4
|
+
import F from "../../../../../assets/line-icons/icons/carat-right.js";
|
5
|
+
import R from "../../../../ui/buttons/icon-button/icon-button.js";
|
6
|
+
import g from "../../../../ui/separator/separator.js";
|
7
|
+
import { Carousel as M, CarouselWrapper as S, CarouselItemContainer as H, ExtendedFlexView as T, Indicator as V } from "./carousel-styled.js";
|
8
|
+
const W = ({ items: t, defaultIndex: l = 0, onNext: s, onPrev: c, analyticsPrev: m, analyticsNext: p }, k) => {
|
9
|
+
const f = u(() => m, [m]), C = u(() => p, [p]), h = b(null), i = b(!0), [o, n] = z(l), I = u(() => t.map(() => B()), [t]), w = d(() => {
|
10
|
+
c == null || c(), n((r) => r - 1);
|
11
|
+
}, [c]), A = d(() => {
|
12
|
+
s == null || s(), n((r) => r + 1);
|
13
|
+
}, [s]), L = d((r) => {
|
14
|
+
n(r);
|
17
15
|
}, []);
|
18
|
-
return
|
19
|
-
nextBtnRef:
|
20
|
-
indicatorRefs:
|
21
|
-
currentIndex:
|
16
|
+
return D(k, () => ({
|
17
|
+
nextBtnRef: h,
|
18
|
+
indicatorRefs: I,
|
19
|
+
currentIndex: o,
|
22
20
|
goToIndex: (r) => {
|
23
|
-
|
21
|
+
n(r);
|
24
22
|
}
|
25
|
-
})),
|
23
|
+
})), $(() => {
|
26
24
|
i.current && (i.current = !1);
|
27
|
-
}, []),
|
28
|
-
|
29
|
-
}, [l]), /* @__PURE__ */
|
25
|
+
}, []), $(() => {
|
26
|
+
n(l);
|
27
|
+
}, [l]), /* @__PURE__ */ y(M, { children: [
|
30
28
|
/* @__PURE__ */ e(
|
31
|
-
|
29
|
+
S,
|
32
30
|
{
|
33
|
-
$translate:
|
31
|
+
$translate: o * 100,
|
34
32
|
$translateDuration: i.current ? 0 : 300,
|
35
|
-
children:
|
33
|
+
children: t.map((r, a) => /* @__PURE__ */ e(H, { children: r }, a))
|
36
34
|
}
|
37
35
|
),
|
38
|
-
|
39
|
-
|
36
|
+
t.length > 1 && /* @__PURE__ */ y(
|
37
|
+
T,
|
40
38
|
{
|
41
39
|
$flexDirection: "row",
|
42
40
|
$alignItems: "center",
|
@@ -44,44 +42,44 @@ const H = ({ items: a, defaultIndex: l = 0, onNext: s, onPrev: c, analyticsPrev:
|
|
44
42
|
$position: "absolute",
|
45
43
|
children: [
|
46
44
|
/* @__PURE__ */ e(
|
47
|
-
|
45
|
+
R,
|
48
46
|
{
|
49
47
|
renderAs: "secondary",
|
50
|
-
Icon:
|
51
|
-
onClick:
|
48
|
+
Icon: E,
|
49
|
+
onClick: w,
|
52
50
|
analyticsLabel: f.analyticsLabel,
|
53
51
|
analyticsProps: f.analyticsProps,
|
54
|
-
disabled:
|
52
|
+
disabled: o === 0
|
55
53
|
}
|
56
54
|
),
|
57
|
-
/* @__PURE__ */ e(
|
58
|
-
|
59
|
-
|
55
|
+
/* @__PURE__ */ e(g, { width: 48 }),
|
56
|
+
t.map((r, a) => /* @__PURE__ */ e(
|
57
|
+
V,
|
60
58
|
{
|
61
|
-
ref:
|
62
|
-
$isActive:
|
63
|
-
onClick: () =>
|
59
|
+
ref: I[a],
|
60
|
+
$isActive: a === o,
|
61
|
+
onClick: () => L(a)
|
64
62
|
},
|
65
|
-
|
63
|
+
a
|
66
64
|
)),
|
67
|
-
/* @__PURE__ */ e(
|
68
|
-
/* @__PURE__ */ e("div", { ref:
|
69
|
-
|
65
|
+
/* @__PURE__ */ e(g, { width: 48 }),
|
66
|
+
/* @__PURE__ */ e("div", { ref: h, children: /* @__PURE__ */ e(
|
67
|
+
R,
|
70
68
|
{
|
71
69
|
renderAs: "secondary",
|
72
|
-
Icon:
|
73
|
-
onClick:
|
74
|
-
analyticsLabel:
|
75
|
-
analyticsProps:
|
76
|
-
disabled:
|
70
|
+
Icon: F,
|
71
|
+
onClick: A,
|
72
|
+
analyticsLabel: C.analyticsLabel,
|
73
|
+
analyticsProps: C.analyticsProps,
|
74
|
+
disabled: o === t.length - 1
|
77
75
|
}
|
78
76
|
) })
|
79
77
|
]
|
80
78
|
}
|
81
79
|
)
|
82
80
|
] });
|
83
|
-
},
|
81
|
+
}, Q = j(x(W));
|
84
82
|
export {
|
85
|
-
|
83
|
+
Q as Carousel
|
86
84
|
};
|
87
85
|
//# sourceMappingURL=carousel.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"carousel.js","sources":["../../../../../../src/features/circle-games/game-launcher/comps/carousel/carousel.tsx"],"sourcesContent":["import type { ICarouselProps, ICarouselRefs } from './carousel-types';\nimport type { ForwardRefRenderFunction } from 'react';\n\nimport
|
1
|
+
{"version":3,"file":"carousel.js","sources":["../../../../../../src/features/circle-games/game-launcher/comps/carousel/carousel.tsx"],"sourcesContent":["import type { ICarouselProps, ICarouselRefs } from './carousel-types';\nimport type { ForwardRefRenderFunction } from 'react';\n\nimport {\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n forwardRef,\n useImperativeHandle,\n createRef,\n} from 'react';\n\nimport CaratLeftIcon from '../../../../../assets/line-icons/icons/carat-left';\nimport CaratRightIcon from '../../../../../assets/line-icons/icons/carat-right';\nimport IconButton from '../../../../ui/buttons/icon-button/icon-button';\nimport Separator from '../../../../ui/separator/separator';\nimport * as Styled from './carousel-styled';\n\nconst CarouselComponent: ForwardRefRenderFunction<ICarouselRefs, ICarouselProps> = (\n { items, defaultIndex = 0, onNext, onPrev, analyticsPrev, analyticsNext },\n ref,\n) => {\n const memoizedAnalyticsPrev = useMemo(() => analyticsPrev, [analyticsPrev]);\n const memoizedAnalyticsNext = useMemo(() => analyticsNext, [analyticsNext]);\n\n const nextBtnRef = useRef<HTMLDivElement>(null);\n const isFirstMount = useRef(true);\n const [currIndex, setCurrIndex] = useState(defaultIndex);\n\n // Create a stable array of refs for indicators\n const indicatorRefs = useMemo(() => {\n return items.map(() => createRef<HTMLDivElement>());\n }, [items]);\n\n const handleCarouselPrev = useCallback(() => {\n onPrev?.();\n setCurrIndex(prev => prev - 1);\n }, [onPrev]);\n\n const handleCarouselNext = useCallback(() => {\n onNext?.();\n setCurrIndex(prev => prev + 1);\n }, [onNext]);\n\n const handleCarouselIndicatorClick = useCallback((index: number) => {\n setCurrIndex(index);\n }, []);\n\n useImperativeHandle(ref, () => ({\n nextBtnRef,\n indicatorRefs,\n currentIndex: currIndex,\n goToIndex: (index: number) => {\n setCurrIndex(index);\n },\n }));\n\n useEffect(() => {\n if (isFirstMount.current) {\n isFirstMount.current = false;\n }\n }, []);\n\n // Change index from parent\n useEffect(() => {\n setCurrIndex(defaultIndex);\n }, [defaultIndex]);\n\n return (\n <Styled.Carousel>\n <Styled.CarouselWrapper\n $translate={currIndex * 100}\n $translateDuration={isFirstMount.current ? 0 : 300}\n >\n {items.map((item, index) => (\n <Styled.CarouselItemContainer key={index}>{item}</Styled.CarouselItemContainer>\n ))}\n </Styled.CarouselWrapper>\n\n {items.length > 1 && (\n <Styled.ExtendedFlexView\n $flexDirection=\"row\"\n $alignItems=\"center\"\n $justifyContent=\"center\"\n $position=\"absolute\"\n >\n <IconButton\n renderAs=\"secondary\"\n Icon={CaratLeftIcon}\n onClick={handleCarouselPrev}\n analyticsLabel={memoizedAnalyticsPrev.analyticsLabel}\n analyticsProps={memoizedAnalyticsPrev.analyticsProps}\n disabled={currIndex === 0}\n />\n <Separator width={48} />\n {items.map((_, index) => (\n <Styled.Indicator\n ref={indicatorRefs[index]}\n $isActive={index === currIndex}\n key={index}\n onClick={() => handleCarouselIndicatorClick(index)}\n />\n ))}\n <Separator width={48} />\n <div ref={nextBtnRef}>\n <IconButton\n renderAs=\"secondary\"\n Icon={CaratRightIcon}\n onClick={handleCarouselNext}\n analyticsLabel={memoizedAnalyticsNext.analyticsLabel}\n analyticsProps={memoizedAnalyticsNext.analyticsProps}\n disabled={currIndex === items.length - 1}\n />\n </div>\n </Styled.ExtendedFlexView>\n )}\n </Styled.Carousel>\n );\n};\n\nexport const Carousel = memo(forwardRef(CarouselComponent));\n"],"names":["CarouselComponent","items","defaultIndex","onNext","onPrev","analyticsPrev","analyticsNext","ref","memoizedAnalyticsPrev","useMemo","memoizedAnalyticsNext","nextBtnRef","useRef","isFirstMount","currIndex","setCurrIndex","useState","indicatorRefs","createRef","handleCarouselPrev","useCallback","prev","handleCarouselNext","handleCarouselIndicatorClick","index","useImperativeHandle","useEffect","jsxs","Styled.Carousel","jsx","Styled.CarouselWrapper","item","Styled.CarouselItemContainer","Styled.ExtendedFlexView","IconButton","CaratLeftIcon","Separator","_","Styled.Indicator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AAA,IACF;AAAA,EAEJ,EAAA,CAAA;AAEJ,GAEauC,IAAWC,EAAKC,EAAW1C,CAAiB,CAAC;"}
|
@@ -1,69 +1,62 @@
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
2
|
-
import { memo as
|
2
|
+
import { memo as O, useRef as g, useCallback as n, useMemo as h, useEffect as x } from "react";
|
3
3
|
import { LOTTIE as D } from "../../../assets/lottie/lottie.js";
|
4
|
-
import { JOURNEY_ID_STUDENT as
|
5
|
-
import {
|
6
|
-
import Y from "../../ui/
|
7
|
-
import
|
4
|
+
import { JOURNEY_ID_STUDENT as z } from "../../journey/journey-id/journey-id-student.js";
|
5
|
+
import { useJourney as U } from "../../journey/use-journey/use-journey.js";
|
6
|
+
import { CircularLoader as Y } from "../../ui/loader/circular-loader/circular-loader.js";
|
7
|
+
import B from "../../ui/lottie-animation/lottie-animation.js";
|
8
|
+
import { useCircleSounds as K } from "../hooks/use-circle-sounds/use-circle-sounds.js";
|
8
9
|
import { CircleSoundKey as u } from "../hooks/use-circle-sounds/use-circle-sounds-enums.js";
|
9
|
-
import { GAME_LAUNCHER_SIZE as
|
10
|
-
import { Carousel as
|
11
|
-
import { GAME_LAUNCHER_ASSET_PADDING as
|
12
|
-
import { SegmentedGameCard as
|
13
|
-
import { TablesCard as
|
14
|
-
import { GAME_LAUNCHER_ANALYTICS_EVENTS as
|
15
|
-
import { useGameLauncherJourney as
|
16
|
-
import { useTableLauncherJourney as
|
10
|
+
import { GAME_LAUNCHER_SIZE as H } from "./comps/card-container/constants.js";
|
11
|
+
import { Carousel as G } from "./comps/carousel/carousel.js";
|
12
|
+
import { GAME_LAUNCHER_ASSET_PADDING as Z } from "./comps/segmented-game-card/constants.js";
|
13
|
+
import { SegmentedGameCard as E } from "./comps/segmented-game-card/segmented-game-card.js";
|
14
|
+
import { TablesCard as w } from "./comps/tables-card/tables-card.js";
|
15
|
+
import { GAME_LAUNCHER_ANALYTICS_EVENTS as V } from "./game-launcher-analytics-events.js";
|
16
|
+
import { useGameLauncherJourney as X } from "./hooks/use-game-launcher-journey/use-game-launcher-journey.js";
|
17
|
+
import { useTableLauncherJourney as q } from "./hooks/use-table-launcher-journey/use-table-launcher-journey.js";
|
17
18
|
import { ProjectType as f } from "../games/web-view/enums/project-type-enum.js";
|
18
|
-
const S =
|
19
|
-
({
|
20
|
-
|
21
|
-
journeyId: m,
|
22
|
-
data: e,
|
23
|
-
isLoading: c,
|
24
|
-
isError: V,
|
25
|
-
isTutorialOnboardingDone: E,
|
26
|
-
defaultIndex: M = 0
|
27
|
-
}) => {
|
28
|
-
const t = v(null), { playSwipSound: T, play: o } = B(), p = n(
|
19
|
+
const S = H + Z, pe = O(
|
20
|
+
({ onSegmentClick: r, journeyId: m, data: e, isLoading: p, isTutorialOnboardingDone: a, defaultIndex: J = 0 }) => {
|
21
|
+
const t = g(null), { isJourneyActive: C } = U(), { playSwipSound: L, play: o } = K(), c = n(
|
29
22
|
(l) => {
|
30
23
|
o(u.GAME_CARD_CLICK), r(l, f.TABLE);
|
31
24
|
},
|
32
25
|
[r, o]
|
33
|
-
),
|
26
|
+
), _ = n(
|
34
27
|
(l) => {
|
35
28
|
l.status !== "completed" && (o(u.GAME_CARD_CLICK), r(l, f.LESSON));
|
36
29
|
},
|
37
30
|
[r, o]
|
38
|
-
),
|
31
|
+
), A = n(
|
39
32
|
(l) => {
|
40
33
|
o(u.GAME_CARD_CLICK), r(l, f.GAME);
|
41
34
|
},
|
42
35
|
[r, o]
|
43
|
-
),
|
36
|
+
), b = n(
|
44
37
|
(l) => {
|
45
38
|
o(u.GAME_CARD_CLICK), r(l, f.PUZZLE);
|
46
39
|
},
|
47
40
|
[r, o]
|
48
41
|
), {
|
49
|
-
gameRefs:
|
50
|
-
lessonRefs:
|
51
|
-
puzzleRefs:
|
42
|
+
gameRefs: T,
|
43
|
+
lessonRefs: y,
|
44
|
+
puzzleRefs: R,
|
52
45
|
startJourney: I
|
53
|
-
} =
|
46
|
+
} = X({
|
54
47
|
carouselRefs: t,
|
55
48
|
onSegmentClick: r
|
56
|
-
}), { startJourney:
|
49
|
+
}), { startJourney: P, tableRef: N } = q({
|
57
50
|
carouselRefs: t,
|
58
|
-
onTableSegmentClick:
|
59
|
-
}),
|
51
|
+
onTableSegmentClick: c
|
52
|
+
}), M = h(() => {
|
60
53
|
let l = [];
|
61
54
|
return e && (e.lessons && (l = [
|
62
55
|
...l,
|
63
56
|
/* @__PURE__ */ i(
|
64
|
-
|
57
|
+
E,
|
65
58
|
{
|
66
|
-
ref:
|
59
|
+
ref: y,
|
67
60
|
label: e.lessons.label,
|
68
61
|
value: e.lessons.data.filter((s) => s.status === "completed").length,
|
69
62
|
maxValue: e.lessons.data.length,
|
@@ -72,16 +65,16 @@ const S = K + H, ue = J(
|
|
72
65
|
card: s.cardLottie,
|
73
66
|
name: s.name,
|
74
67
|
isCompleted: s.status === "completed",
|
75
|
-
onPress: () =>
|
68
|
+
onPress: () => _(s)
|
76
69
|
}))
|
77
70
|
}
|
78
71
|
)
|
79
72
|
]), l = [
|
80
73
|
...l,
|
81
74
|
/* @__PURE__ */ i(
|
82
|
-
|
75
|
+
E,
|
83
76
|
{
|
84
|
-
ref:
|
77
|
+
ref: T,
|
85
78
|
label: e.games.label,
|
86
79
|
value: e.games.data.filter((s) => s.isPlayed).length,
|
87
80
|
maxValue: e.games.data.length,
|
@@ -90,14 +83,14 @@ const S = K + H, ue = J(
|
|
90
83
|
card: s.cardLottie,
|
91
84
|
name: s.name,
|
92
85
|
isCompleted: !1,
|
93
|
-
onPress: () =>
|
86
|
+
onPress: () => A(s)
|
94
87
|
}))
|
95
88
|
}
|
96
89
|
),
|
97
90
|
/* @__PURE__ */ i(
|
98
|
-
|
91
|
+
E,
|
99
92
|
{
|
100
|
-
ref:
|
93
|
+
ref: R,
|
101
94
|
label: e.puzzles.label,
|
102
95
|
value: e.puzzles.data.filter((s) => s.solved).length,
|
103
96
|
maxValue: e.puzzles.data.length,
|
@@ -106,37 +99,37 @@ const S = K + H, ue = J(
|
|
106
99
|
card: s.cardLottie,
|
107
100
|
name: s.name,
|
108
101
|
isCompleted: s.solved,
|
109
|
-
onPress: () =>
|
102
|
+
onPress: () => b(s)
|
110
103
|
}))
|
111
104
|
}
|
112
105
|
)
|
113
106
|
], e.tables && (l = [
|
114
107
|
...l,
|
115
108
|
/* @__PURE__ */ i(
|
116
|
-
|
109
|
+
w,
|
117
110
|
{
|
118
111
|
ref: N,
|
119
112
|
label: e.tables.label,
|
120
113
|
data: e.tables.data,
|
121
|
-
onPress:
|
114
|
+
onPress: c,
|
122
115
|
openModesOfTable: e.tables.openModesOfTable
|
123
116
|
}
|
124
117
|
)
|
125
118
|
])), l;
|
126
119
|
}, [
|
127
120
|
e,
|
128
|
-
|
129
|
-
b,
|
121
|
+
T,
|
130
122
|
R,
|
131
|
-
|
132
|
-
|
123
|
+
y,
|
124
|
+
_,
|
133
125
|
A,
|
126
|
+
b,
|
134
127
|
N,
|
135
|
-
|
136
|
-
]),
|
128
|
+
c
|
129
|
+
]), v = h(
|
137
130
|
() => [
|
138
131
|
/* @__PURE__ */ i(
|
139
|
-
|
132
|
+
B,
|
140
133
|
{
|
141
134
|
src: D.SLEEPY_BOI,
|
142
135
|
width: S,
|
@@ -147,51 +140,52 @@ const S = K + H, ue = J(
|
|
147
140
|
[]
|
148
141
|
);
|
149
142
|
return x(() => {
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
console.log("INTRO START", (l = t.current) == null ? void 0 : l.indicatorRefs), I(e == null ? void 0 : e.puzzles, !!(e != null && e.lessons), m);
|
143
|
+
if (!(p || !e || C)) {
|
144
|
+
if (e != null && e.puzzles && m === z.CIRCLE_ACTIVITIES_INTRO_JOURNEY) {
|
145
|
+
I(e == null ? void 0 : e.puzzles, !!(e != null && e.lessons), m);
|
154
146
|
return;
|
155
147
|
}
|
156
|
-
e != null && e.tables && m ===
|
148
|
+
e != null && e.tables && m === z.CIRCLE_TABLES_INTRO_JOURNEY && P(e == null ? void 0 : e.tables, a);
|
157
149
|
}
|
158
150
|
}, [
|
159
151
|
e,
|
160
|
-
|
161
|
-
|
152
|
+
C,
|
153
|
+
p,
|
154
|
+
a,
|
162
155
|
m,
|
163
156
|
I,
|
164
|
-
|
165
|
-
]),
|
166
|
-
|
157
|
+
P
|
158
|
+
]), p ? /* @__PURE__ */ i(Y, {}) : e ? /* @__PURE__ */ i(
|
159
|
+
G,
|
167
160
|
{
|
168
|
-
|
161
|
+
ref: t,
|
162
|
+
items: M,
|
163
|
+
defaultIndex: J,
|
164
|
+
onNext: L,
|
165
|
+
onPrev: L,
|
169
166
|
analyticsNext: {
|
170
|
-
analyticsLabel:
|
167
|
+
analyticsLabel: V.NEXT_ACTIVITY
|
171
168
|
},
|
172
169
|
analyticsPrev: {
|
173
|
-
analyticsLabel:
|
170
|
+
analyticsLabel: V.PREV_ACTIVITY
|
174
171
|
}
|
175
172
|
}
|
176
173
|
) : /* @__PURE__ */ i(
|
177
|
-
|
174
|
+
G,
|
178
175
|
{
|
179
176
|
ref: t,
|
180
|
-
items:
|
181
|
-
defaultIndex: M,
|
182
|
-
onNext: T,
|
183
|
-
onPrev: T,
|
177
|
+
items: v,
|
184
178
|
analyticsNext: {
|
185
|
-
analyticsLabel:
|
179
|
+
analyticsLabel: ""
|
186
180
|
},
|
187
181
|
analyticsPrev: {
|
188
|
-
analyticsLabel:
|
182
|
+
analyticsLabel: ""
|
189
183
|
}
|
190
184
|
}
|
191
185
|
);
|
192
186
|
}
|
193
187
|
);
|
194
188
|
export {
|
195
|
-
|
189
|
+
pe as GameLauncher
|
196
190
|
};
|
197
191
|
//# sourceMappingURL=game-launcher.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"game-launcher.js","sources":["../../../../src/features/circle-games/game-launcher/game-launcher.tsx"],"sourcesContent":["import type { ICarouselRefs } from './comps/carousel/carousel-types';\nimport type { ITableDetails } from './comps/tables-card/tables-card-types';\nimport type {\n Game,\n Lesson,\n Puzzle,\n} from './dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IGameLauncherProps } from './game-launcher-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { LOTTIE } from '../../../assets/lottie/lottie';\nimport { JOURNEY_ID_STUDENT } from '../../journey/journey-id/journey-id-student';\nimport { CircularLoader } from '../../ui/loader/circular-loader/circular-loader';\nimport LottieAnimation from '../../ui/lottie-animation/lottie-animation';\nimport { ProjectType } from '../games/web-view/enums';\nimport { useCircleSounds } from '../hooks/use-circle-sounds/use-circle-sounds';\nimport { CircleSoundKey } from '../hooks/use-circle-sounds/use-circle-sounds-enums';\nimport { GAME_LAUNCHER_SIZE } from './comps/card-container/constants';\nimport { Carousel } from './comps/carousel/carousel';\nimport { GAME_LAUNCHER_ASSET_PADDING } from './comps/segmented-game-card/constants';\nimport { SegmentedGameCard } from './comps/segmented-game-card/segmented-game-card';\nimport { TablesCard } from './comps/tables-card/tables-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from './game-launcher-analytics-events';\nimport { useGameLauncherJourney } from './hooks/use-game-launcher-journey/use-game-launcher-journey';\nimport { useTableLauncherJourney } from './hooks/use-table-launcher-journey/use-table-launcher-journey';\n\nconst sleepyBoiDimension = GAME_LAUNCHER_SIZE + GAME_LAUNCHER_ASSET_PADDING;\n\nexport const GameLauncher: FC<IGameLauncherProps> = memo(\n ({\n onSegmentClick,\n journeyId,\n data,\n isLoading,\n isError,\n isTutorialOnboardingDone,\n defaultIndex = 0,\n }) => {\n const carouselRefs = useRef<ICarouselRefs>(null);\n\n const { playSwipSound, play } = useCircleSounds();\n\n const onTableSegmentClick = useCallback(\n (table: ITableDetails) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(table, ProjectType.TABLE);\n },\n [onSegmentClick, play],\n );\n\n const handleLessonSegmentClick = useCallback(\n (lesson: Lesson) => {\n if (lesson.status !== 'completed') {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(lesson, ProjectType.LESSON);\n }\n },\n [onSegmentClick, play],\n );\n\n const handleGameSegmentClick = useCallback(\n (game: Game) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(game, ProjectType.GAME);\n },\n [onSegmentClick, play],\n );\n\n const handlePuzzleSegmentClick = useCallback(\n (puzzle: Puzzle) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(puzzle, ProjectType.PUZZLE);\n },\n [onSegmentClick, play],\n );\n\n const {\n gameRefs,\n lessonRefs,\n puzzleRefs,\n startJourney: startLessonPuzzleGamesJourney,\n } = useGameLauncherJourney({\n carouselRefs,\n onSegmentClick,\n });\n\n const { startJourney: startTablesJourney, tableRef } = useTableLauncherJourney({\n carouselRefs,\n onTableSegmentClick,\n });\n\n const items = useMemo(() => {\n let itemTypes: ReactNode[] = [];\n\n if (data) {\n if (data.lessons) {\n itemTypes = [\n ...itemTypes,\n <SegmentedGameCard\n ref={lessonRefs}\n label={data.lessons.label}\n value={data.lessons.data.filter(lesson => lesson.status === 'completed').length}\n maxValue={data.lessons.data.length}\n initialValue={data.lessons.initialProgressValue}\n data={data?.lessons.data.map(lesson => ({\n card: lesson.cardLottie,\n name: lesson.name,\n isCompleted: lesson.status === 'completed',\n onPress: () => handleLessonSegmentClick(lesson),\n }))}\n />,\n ];\n }\n\n itemTypes = [\n ...itemTypes,\n <SegmentedGameCard\n ref={gameRefs}\n label={data.games.label}\n value={data.games.data.filter(game => game.isPlayed).length}\n maxValue={data.games.data.length}\n initialValue={data.games.initialProgressValue}\n data={data.games.data.map(game => ({\n card: game.cardLottie,\n name: game.name,\n isCompleted: false,\n onPress: () => handleGameSegmentClick(game),\n }))}\n />,\n <SegmentedGameCard\n ref={puzzleRefs}\n label={data.puzzles.label}\n value={data.puzzles.data.filter(puzzle => puzzle.solved).length}\n maxValue={data.puzzles.data.length}\n initialValue={data.puzzles.initialProgressValue}\n data={data.puzzles.data.map(puzzle => ({\n card: puzzle.cardLottie,\n name: puzzle.name,\n isCompleted: puzzle.solved,\n onPress: () => handlePuzzleSegmentClick(puzzle),\n }))}\n />,\n ];\n\n if (data.tables) {\n itemTypes = [\n ...itemTypes,\n <TablesCard\n ref={tableRef}\n label={data.tables.label}\n data={data.tables.data}\n onPress={onTableSegmentClick}\n openModesOfTable={data.tables.openModesOfTable}\n />,\n ];\n }\n }\n\n return itemTypes;\n }, [\n data,\n gameRefs,\n puzzleRefs,\n lessonRefs,\n handleLessonSegmentClick,\n handleGameSegmentClick,\n handlePuzzleSegmentClick,\n tableRef,\n onTableSegmentClick,\n ]);\n\n const sleepyBoiItem = useMemo(\n () => [\n <LottieAnimation\n src={LOTTIE.SLEEPY_BOI}\n width={sleepyBoiDimension}\n height={sleepyBoiDimension}\n />,\n ],\n [],\n );\n\n // Start game launcher journey only when isLoading has become false and data is available\n useEffect(() => {\n if (isLoading || !data) {\n return;\n }\n\n if (data?.puzzles && journeyId === JOURNEY_ID_STUDENT.CIRCLE_ACTIVITIES_INTRO_JOURNEY) {\n console.log('INTRO START', carouselRefs.current?.indicatorRefs);\n startLessonPuzzleGamesJourney(data?.puzzles, !!data?.lessons, journeyId);\n\n return; // CIRCLE_ACTIVITIES_INTRO_JOURNEY has higher priority\n }\n\n if (data?.tables && journeyId === JOURNEY_ID_STUDENT.CIRCLE_TABLES_INTRO_JOURNEY) {\n console.log('TABLE START', carouselRefs.current?.indicatorRefs);\n startTablesJourney(data?.tables, isTutorialOnboardingDone);\n }\n }, [\n data,\n isLoading,\n isTutorialOnboardingDone,\n journeyId,\n startLessonPuzzleGamesJourney,\n startTablesJourney,\n ]);\n\n if (isLoading) {\n return <CircularLoader />;\n }\n\n if (isError) {\n return (\n <Carousel\n items={sleepyBoiItem}\n analyticsNext={{\n analyticsLabel: '',\n }}\n analyticsPrev={{\n analyticsLabel: '',\n }}\n />\n );\n }\n\n return (\n <Carousel\n ref={carouselRefs}\n items={items}\n defaultIndex={defaultIndex}\n onNext={playSwipSound}\n onPrev={playSwipSound}\n analyticsNext={{\n analyticsLabel: GAME_LAUNCHER_ANALYTICS_EVENTS.NEXT_ACTIVITY,\n }}\n analyticsPrev={{\n analyticsLabel: GAME_LAUNCHER_ANALYTICS_EVENTS.PREV_ACTIVITY,\n }}\n />\n );\n },\n);\n"],"names":["sleepyBoiDimension","GAME_LAUNCHER_SIZE","GAME_LAUNCHER_ASSET_PADDING","GameLauncher","memo","onSegmentClick","journeyId","data","isLoading","isError","isTutorialOnboardingDone","defaultIndex","carouselRefs","useRef","playSwipSound","play","useCircleSounds","onTableSegmentClick","useCallback","table","CircleSoundKey","ProjectType","handleLessonSegmentClick","lesson","handleGameSegmentClick","game","handlePuzzleSegmentClick","puzzle","gameRefs","lessonRefs","puzzleRefs","startLessonPuzzleGamesJourney","useGameLauncherJourney","startTablesJourney","tableRef","useTableLauncherJourney","items","useMemo","itemTypes","jsx","SegmentedGameCard","TablesCard","sleepyBoiItem","LottieAnimation","LOTTIE","useEffect","JOURNEY_ID_STUDENT","_a","_b","CircularLoader","Carousel","GAME_LAUNCHER_ANALYTICS_EVENTS"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAMA,IAAqBC,IAAqBC,GAEnCC,KAAuCC;AAAA,EAClD,CAAC;AAAA,IACC,gBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,EAAA,MACX;AACE,UAAAC,IAAeC,EAAsB,IAAI,GAEzC,EAAE,eAAAC,GAAe,MAAAC,EAAK,IAAIC,EAAgB,GAE1CC,IAAsBC;AAAA,MAC1B,CAACC,MAAyB;AACxB,QAAAJ,EAAKK,EAAe,eAAe,GACpBf,EAAAc,GAAOE,EAAY,KAAK;AAAA,MACzC;AAAA,MACA,CAAChB,GAAgBU,CAAI;AAAA,IAAA,GAGjBO,IAA2BJ;AAAA,MAC/B,CAACK,MAAmB;AACd,QAA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A,UACb,gBAAgB;AAAA,QAClB;AAAA,MAAA;AAAA,IAAA,IAMJ,gBAAAH;AAAA,MAACW;AAAA,MAAA;AAAA,QACC,KAAKtC;AAAA,QACL,OAAAwB;AAAA,QACA,cAAAzB;AAAA,QACA,QAAQG;AAAA,QACR,QAAQA;AAAA,QACR,eAAe;AAAA,UACb,gBAAgBqC,EAA+B;AAAA,QACjD;AAAA,QACA,eAAe;AAAA,UACb,gBAAgBA,EAA+B;AAAA,QACjD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;"}
|
1
|
+
{"version":3,"file":"game-launcher.js","sources":["../../../../src/features/circle-games/game-launcher/game-launcher.tsx"],"sourcesContent":["import type { ICarouselRefs } from './comps/carousel/carousel-types';\nimport type { ITableDetails } from './comps/tables-card/tables-card-types';\nimport type {\n Game,\n Lesson,\n Puzzle,\n} from './dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IGameLauncherProps } from './game-launcher-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { LOTTIE } from '../../../assets/lottie/lottie';\nimport { JOURNEY_ID_STUDENT } from '../../journey/journey-id/journey-id-student';\nimport { useJourney } from '../../journey/use-journey/use-journey';\nimport { CircularLoader } from '../../ui/loader/circular-loader/circular-loader';\nimport LottieAnimation from '../../ui/lottie-animation/lottie-animation';\nimport { ProjectType } from '../games/web-view/enums';\nimport { useCircleSounds } from '../hooks/use-circle-sounds/use-circle-sounds';\nimport { CircleSoundKey } from '../hooks/use-circle-sounds/use-circle-sounds-enums';\nimport { GAME_LAUNCHER_SIZE } from './comps/card-container/constants';\nimport { Carousel } from './comps/carousel/carousel';\nimport { GAME_LAUNCHER_ASSET_PADDING } from './comps/segmented-game-card/constants';\nimport { SegmentedGameCard } from './comps/segmented-game-card/segmented-game-card';\nimport { TablesCard } from './comps/tables-card/tables-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from './game-launcher-analytics-events';\nimport { useGameLauncherJourney } from './hooks/use-game-launcher-journey/use-game-launcher-journey';\nimport { useTableLauncherJourney } from './hooks/use-table-launcher-journey/use-table-launcher-journey';\n\nconst sleepyBoiDimension = GAME_LAUNCHER_SIZE + GAME_LAUNCHER_ASSET_PADDING;\n\nexport const GameLauncher: FC<IGameLauncherProps> = memo(\n ({ onSegmentClick, journeyId, data, isLoading, isTutorialOnboardingDone, defaultIndex = 0 }) => {\n const carouselRefs = useRef<ICarouselRefs>(null);\n\n const { isJourneyActive } = useJourney();\n\n const { playSwipSound, play } = useCircleSounds();\n\n const onTableSegmentClick = useCallback(\n (table: ITableDetails) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(table, ProjectType.TABLE);\n },\n [onSegmentClick, play],\n );\n\n const handleLessonSegmentClick = useCallback(\n (lesson: Lesson) => {\n if (lesson.status !== 'completed') {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(lesson, ProjectType.LESSON);\n }\n },\n [onSegmentClick, play],\n );\n\n const handleGameSegmentClick = useCallback(\n (game: Game) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(game, ProjectType.GAME);\n },\n [onSegmentClick, play],\n );\n\n const handlePuzzleSegmentClick = useCallback(\n (puzzle: Puzzle) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(puzzle, ProjectType.PUZZLE);\n },\n [onSegmentClick, play],\n );\n\n const {\n gameRefs,\n lessonRefs,\n puzzleRefs,\n startJourney: startLessonPuzzleGamesJourney,\n } = useGameLauncherJourney({\n carouselRefs,\n onSegmentClick,\n });\n\n const { startJourney: startTablesJourney, tableRef } = useTableLauncherJourney({\n carouselRefs,\n onTableSegmentClick,\n });\n\n const items = useMemo(() => {\n let itemTypes: ReactNode[] = [];\n\n if (data) {\n if (data.lessons) {\n itemTypes = [\n ...itemTypes,\n <SegmentedGameCard\n ref={lessonRefs}\n label={data.lessons.label}\n value={data.lessons.data.filter(lesson => lesson.status === 'completed').length}\n maxValue={data.lessons.data.length}\n initialValue={data.lessons.initialProgressValue}\n data={data?.lessons.data.map(lesson => ({\n card: lesson.cardLottie,\n name: lesson.name,\n isCompleted: lesson.status === 'completed',\n onPress: () => handleLessonSegmentClick(lesson),\n }))}\n />,\n ];\n }\n\n itemTypes = [\n ...itemTypes,\n <SegmentedGameCard\n ref={gameRefs}\n label={data.games.label}\n value={data.games.data.filter(game => game.isPlayed).length}\n maxValue={data.games.data.length}\n initialValue={data.games.initialProgressValue}\n data={data.games.data.map(game => ({\n card: game.cardLottie,\n name: game.name,\n isCompleted: false,\n onPress: () => handleGameSegmentClick(game),\n }))}\n />,\n <SegmentedGameCard\n ref={puzzleRefs}\n label={data.puzzles.label}\n value={data.puzzles.data.filter(puzzle => puzzle.solved).length}\n maxValue={data.puzzles.data.length}\n initialValue={data.puzzles.initialProgressValue}\n data={data.puzzles.data.map(puzzle => ({\n card: puzzle.cardLottie,\n name: puzzle.name,\n isCompleted: puzzle.solved,\n onPress: () => handlePuzzleSegmentClick(puzzle),\n }))}\n />,\n ];\n\n if (data.tables) {\n itemTypes = [\n ...itemTypes,\n <TablesCard\n ref={tableRef}\n label={data.tables.label}\n data={data.tables.data}\n onPress={onTableSegmentClick}\n openModesOfTable={data.tables.openModesOfTable}\n />,\n ];\n }\n }\n\n return itemTypes;\n }, [\n data,\n gameRefs,\n puzzleRefs,\n lessonRefs,\n handleLessonSegmentClick,\n handleGameSegmentClick,\n handlePuzzleSegmentClick,\n tableRef,\n onTableSegmentClick,\n ]);\n\n const sleepyBoiItem = useMemo(\n () => [\n <LottieAnimation\n src={LOTTIE.SLEEPY_BOI}\n width={sleepyBoiDimension}\n height={sleepyBoiDimension}\n />,\n ],\n [],\n );\n\n // Start game launcher journey only when isLoading has become false and data is available\n useEffect(() => {\n if (isLoading || !data || isJourneyActive) {\n return;\n }\n\n if (data?.puzzles && journeyId === JOURNEY_ID_STUDENT.CIRCLE_ACTIVITIES_INTRO_JOURNEY) {\n startLessonPuzzleGamesJourney(data?.puzzles, !!data?.lessons, journeyId);\n\n return; // CIRCLE_ACTIVITIES_INTRO_JOURNEY has higher priority\n }\n\n if (data?.tables && journeyId === JOURNEY_ID_STUDENT.CIRCLE_TABLES_INTRO_JOURNEY) {\n startTablesJourney(data?.tables, isTutorialOnboardingDone);\n }\n }, [\n data,\n isJourneyActive,\n isLoading,\n isTutorialOnboardingDone,\n journeyId,\n startLessonPuzzleGamesJourney,\n startTablesJourney,\n ]);\n\n if (isLoading) {\n return <CircularLoader />;\n }\n\n if (!data) {\n return (\n <Carousel\n ref={carouselRefs}\n items={sleepyBoiItem}\n analyticsNext={{\n analyticsLabel: '',\n }}\n analyticsPrev={{\n analyticsLabel: '',\n }}\n />\n );\n }\n\n return (\n <Carousel\n ref={carouselRefs}\n items={items}\n defaultIndex={defaultIndex}\n onNext={playSwipSound}\n onPrev={playSwipSound}\n analyticsNext={{\n analyticsLabel: GAME_LAUNCHER_ANALYTICS_EVENTS.NEXT_ACTIVITY,\n }}\n analyticsPrev={{\n analyticsLabel: GAME_LAUNCHER_ANALYTICS_EVENTS.PREV_ACTIVITY,\n }}\n />\n );\n },\n);\n"],"names":["sleepyBoiDimension","GAME_LAUNCHER_SIZE","GAME_LAUNCHER_ASSET_PADDING","GameLauncher","memo","onSegmentClick","journeyId","data","isLoading","isTutorialOnboardingDone","defaultIndex","carouselRefs","useRef","isJourneyActive","useJourney","playSwipSound","play","useCircleSounds","onTableSegmentClick","useCallback","table","CircleSoundKey","ProjectType","handleLessonSegmentClick","lesson","handleGameSegmentClick","game","handlePuzzleSegmentClick","puzzle","gameRefs","lessonRefs","puzzleRefs","startLessonPuzzleGamesJourney","useGameLauncherJourney","startTablesJourney","tableRef","useTableLauncherJourney","items","useMemo","itemTypes","jsx","SegmentedGameCard","TablesCard","sleepyBoiItem","LottieAnimation","LOTTIE","useEffect","JOURNEY_ID_STUDENT","CircularLoader","Carousel","GAME_LAUNCHER_ANALYTICS_EVENTS"],"mappings":";;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AEA,QAAIC,KAAA,QAAAA,EAAM,UAAUD,MAAcyC,EAAmB,+BAChCb,EAAA3B,KAAA,gBAAAA,EAAM,QAAQE,CAAwB;AAAA;AAAA,IAC3D,GACC;AAAA,MACDF;AAAA,MACAM;AAAA,MACAL;AAAA,MACAC;AAAA,MACAH;AAAA,MACA0B;AAAA,MACAE;AAAA,IAAA,CACD,GAEG1B,sBACMwC,GAAe,CAAA,CAAA,IAGpBzC,IAgBH,gBAAAiC;AAAA,MAACS;AAAA,MAAA;AAAA,QACC,KAAKtC;AAAA,QACL,OAAA0B;AAAA,QACA,cAAA3B;AAAA,QACA,QAAQK;AAAA,QACR,QAAQA;AAAA,QACR,eAAe;AAAA,UACb,gBAAgBmC,EAA+B;AAAA,QACjD;AAAA,QACA,eAAe;AAAA,UACb,gBAAgBA,EAA+B;AAAA,QACjD;AAAA,MAAA;AAAA,IAAA,IAzBA,gBAAAV;AAAA,MAACS;AAAA,MAAA;AAAA,QACC,KAAKtC;AAAA,QACL,OAAOgC;AAAA,QACP,eAAe;AAAA,UACb,gBAAgB;AAAA,QAClB;AAAA,QACA,eAAe;AAAA,UACb,gBAAgB;AAAA,QAClB;AAAA,MAAA;AAAA,IAAA;AAAA,EAoBR;AACF;"}
|
@@ -1,63 +1,61 @@
|
|
1
|
-
import { jsx as r, Fragment as
|
2
|
-
import { useRef as
|
3
|
-
import
|
4
|
-
import { PLATFORM_EVENTS_STUDENT as
|
5
|
-
import { JOURNEY_ID_STUDENT as
|
1
|
+
import { jsx as r, Fragment as L } from "react/jsx-runtime";
|
2
|
+
import { useRef as I, useCallback as p, useEffect as M } from "react";
|
3
|
+
import $ from "../../../../../assets/line-icons/icons/carat-right.js";
|
4
|
+
import { PLATFORM_EVENTS_STUDENT as D } from "../../../../analytics-events/platform-events-student.js";
|
5
|
+
import { JOURNEY_ID_STUDENT as x } from "../../../../journey/journey-id/journey-id-student.js";
|
6
6
|
import { IndicatorType as s } from "../../../../journey/use-journey/constants.js";
|
7
7
|
import { useJourney as w } from "../../../../journey/use-journey/use-journey.js";
|
8
8
|
import F from "../../../../ui/buttons/icon-button/icon-button.js";
|
9
|
-
import { useUIContext as
|
10
|
-
import
|
9
|
+
import { useUIContext as J } from "../../../../ui/context/context.js";
|
10
|
+
import O from "../../../../ui/layout/flex-view.js";
|
11
11
|
import m from "../../../../ui/text/text.js";
|
12
|
-
import { CIRCLE_ONBOARDING_ANALYTICS_STEPS as
|
13
|
-
import { useCircleSounds as
|
14
|
-
import { TablesCard as
|
15
|
-
import { GAME_LAUNCHER_ANALYTICS_EVENTS as
|
16
|
-
import { SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS as
|
17
|
-
import { Indicator as
|
18
|
-
const
|
19
|
-
carouselRefs:
|
20
|
-
onTableSegmentClick:
|
12
|
+
import { CIRCLE_ONBOARDING_ANALYTICS_STEPS as W } from "../../../enum/circle-onboarding-steps.js";
|
13
|
+
import { useCircleSounds as V } from "../../../hooks/use-circle-sounds/use-circle-sounds.js";
|
14
|
+
import { TablesCard as Y } from "../../comps/tables-card/tables-card.js";
|
15
|
+
import { GAME_LAUNCHER_ANALYTICS_EVENTS as X } from "../../game-launcher-analytics-events.js";
|
16
|
+
import { SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS as K, SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS as j, START_ANIMATING_CLONED_ELEM as k, TABLE_CARD_INDEX as B, GO_TO_TABLE_LAUNCHER_DURATION_MS as Z, SHOW_CLICK_TABLE_NUDGE_AFTER_MS as q, PUZZLE_CARD_INDEX as z, SHOW_INITIAL_COACHMARK_AFTER_MS as U, LESSON_CARD_INDEX as Q, SHOW_INITIAL_TOOLTIP_AFTER_MS as ee } from "./constants.js";
|
17
|
+
import { Indicator as te } from "./use-table-launcher-journey-styled.js";
|
18
|
+
const fe = ({
|
19
|
+
carouselRefs: a,
|
20
|
+
onTableSegmentClick: b
|
21
21
|
}) => {
|
22
|
-
const
|
22
|
+
const e = x.CIRCLE_TABLES_INTRO_JOURNEY, t = I(null), h = I(null), T = I([]), { playButtonSound: R } = V(), { nextCoachmark: i, setJourney: f, addCoachmark: d, endJourney: N } = w(), { onEvent: _ } = J(), A = p(
|
23
23
|
(o) => {
|
24
24
|
var l, n;
|
25
|
-
o &&
|
26
|
-
step:
|
27
|
-
}), (l =
|
25
|
+
o && b(o), _(D.ONBOARDING_STEP_COMPLETED, {
|
26
|
+
step: W.TABLES
|
27
|
+
}), (l = t == null ? void 0 : t.current) == null || l.setLabelVisiblity(!0), (n = t == null ? void 0 : t.current) == null || n.stopLabelAnimation(), N(e);
|
28
28
|
},
|
29
|
-
[
|
30
|
-
),
|
29
|
+
[N, e, b, _]
|
30
|
+
), S = p(
|
31
31
|
(o, l) => {
|
32
|
-
var g
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
d(t, {
|
37
|
-
originalElementToHighlightRef: e.current.segmentedCardWrapperRef,
|
32
|
+
var g;
|
33
|
+
const n = t.current.labelRef.current.getBoundingClientRect(), u = (g = t.current) == null ? void 0 : g.segmentedCardWrapperRef.current.getBoundingClientRect();
|
34
|
+
d(e, {
|
35
|
+
originalElementToHighlightRef: t.current.segmentedCardWrapperRef,
|
38
36
|
isActive: !1,
|
39
37
|
type: s.TOOLTIP,
|
40
38
|
elementToHighlight: /* @__PURE__ */ r(
|
41
|
-
|
39
|
+
Y,
|
42
40
|
{
|
43
|
-
ref:
|
41
|
+
ref: h,
|
44
42
|
defaultTable: l,
|
45
43
|
label: o.label,
|
46
44
|
data: o.data,
|
47
|
-
onPress:
|
48
|
-
onGoBackFromTableLevel:
|
45
|
+
onPress: A,
|
46
|
+
onGoBackFromTableLevel: A
|
49
47
|
}
|
50
48
|
),
|
51
49
|
indicator: {
|
52
50
|
position: "left",
|
53
51
|
backgroundColor: "YELLOW_4",
|
54
52
|
width: 236,
|
55
|
-
tooltipItem: /* @__PURE__ */ r(
|
53
|
+
tooltipItem: /* @__PURE__ */ r(O, { children: /* @__PURE__ */ r(m, { $renderAs: "ab2-bold", children: "Each table has 3 levels—clear them and earn 3 stars!" }) }),
|
56
54
|
tooltipXCoOrdinates: 0,
|
57
55
|
tooltipYCoOrdinates: n.height * 0.35
|
58
56
|
}
|
59
|
-
}), d(
|
60
|
-
originalElementToHighlightRef:
|
57
|
+
}), d(e, {
|
58
|
+
originalElementToHighlightRef: t.current.segmentedCardWrapperRef,
|
61
59
|
isActive: !1,
|
62
60
|
type: s.NUDGE,
|
63
61
|
indicator: {
|
@@ -66,56 +64,53 @@ const Ae = ({
|
|
66
64
|
nudgePointerX: u.width / 2 + 50,
|
67
65
|
nudgePointerY: u.height * 0.4
|
68
66
|
},
|
69
|
-
elementToHighlight: /* @__PURE__ */ r(
|
70
|
-
}), i(
|
71
|
-
const
|
72
|
-
var
|
73
|
-
clearTimeout(
|
74
|
-
},
|
75
|
-
T.current.push(
|
67
|
+
elementToHighlight: /* @__PURE__ */ r(L, {})
|
68
|
+
}), i(e, !1, K), i(e, !0, j);
|
69
|
+
const c = setTimeout(() => {
|
70
|
+
var E;
|
71
|
+
clearTimeout(c), (E = h.current) == null || E.startLabelAnimation("YELLOW_4");
|
72
|
+
}, k);
|
73
|
+
T.current.push(c);
|
76
74
|
},
|
77
|
-
[d,
|
78
|
-
),
|
79
|
-
|
80
|
-
step:
|
75
|
+
[d, A, e, i]
|
76
|
+
), C = p(() => {
|
77
|
+
R(), a.current.goToIndex(B), i(e, !1, Z), _(D.ONBOARDING_STEP_VIEWED, {
|
78
|
+
step: W.TABLES
|
81
79
|
});
|
82
80
|
const o = setTimeout(() => {
|
83
81
|
var n;
|
84
|
-
clearTimeout(o), (n =
|
85
|
-
},
|
82
|
+
clearTimeout(o), (n = t.current) == null || n.setLabelVisiblity(!1), i(e, !0);
|
83
|
+
}, q);
|
86
84
|
T.current.push(o);
|
87
85
|
const l = setTimeout(() => {
|
88
86
|
var n;
|
89
|
-
clearTimeout(l), (n =
|
90
|
-
},
|
87
|
+
clearTimeout(l), (n = h.current) == null || n.startLabelAnimation("YELLOW_4");
|
88
|
+
}, k);
|
91
89
|
T.current.push(l);
|
92
|
-
}, [
|
90
|
+
}, [a, e, i, R, _]), G = p(
|
93
91
|
(o, l = !1) => {
|
94
|
-
var
|
95
|
-
|
96
|
-
|
97
|
-
const n = c.current.indicatorRefs, u = c.current.nextBtnRef, a = n == null ? void 0 : n[U];
|
98
|
-
if (!((h = e.current) != null && h.segmentedCardWrapperRef.current) || !((f = e.current) != null && f.labelRef.current) || !n || !(u != null && u.current) || !a || !a.current)
|
92
|
+
var P, H, y;
|
93
|
+
const n = a.current.indicatorRefs, u = a.current.nextBtnRef, c = n == null ? void 0 : n[B];
|
94
|
+
if (!((P = t.current) != null && P.segmentedCardWrapperRef.current) || !((H = t.current) != null && H.labelRef.current) || !n || !(u != null && u.current) || !c || !c.current)
|
99
95
|
return;
|
100
|
-
|
101
|
-
|
102
|
-
l ? (I(t, [
|
96
|
+
const g = t.current.labelRef.current.getBoundingClientRect(), E = (y = t.current) == null ? void 0 : y.segmentedCardWrapperRef.current.getBoundingClientRect();
|
97
|
+
l ? (f(e, [
|
103
98
|
{
|
104
|
-
originalElementToHighlightRef:
|
99
|
+
originalElementToHighlightRef: c,
|
105
100
|
isActive: !1,
|
106
101
|
type: s.TOOLTIP,
|
107
|
-
elementToHighlight: /* @__PURE__ */ r(
|
102
|
+
elementToHighlight: /* @__PURE__ */ r(te, { $isActive: !1 }),
|
108
103
|
indicator: {
|
109
104
|
position: "bottom",
|
110
105
|
backgroundColor: "YELLOW_4",
|
111
106
|
width: 52,
|
112
107
|
tooltipItem: /* @__PURE__ */ r(
|
113
|
-
|
108
|
+
O,
|
114
109
|
{
|
115
110
|
$position: "absolute",
|
116
111
|
$flexDirection: "row",
|
117
112
|
style: { top: 6, left: 8, cursor: "pointer" },
|
118
|
-
onClick:
|
113
|
+
onClick: C,
|
119
114
|
children: /* @__PURE__ */ r(m, { $renderAs: "ab2-bold", children: "NEW" })
|
120
115
|
}
|
121
116
|
),
|
@@ -124,7 +119,7 @@ const Ae = ({
|
|
124
119
|
}
|
125
120
|
},
|
126
121
|
{
|
127
|
-
originalElementToHighlightRef:
|
122
|
+
originalElementToHighlightRef: c,
|
128
123
|
isActive: !1,
|
129
124
|
type: s.NUDGE,
|
130
125
|
indicator: {
|
@@ -132,11 +127,11 @@ const Ae = ({
|
|
132
127
|
content: "",
|
133
128
|
nudgePointerY: 20
|
134
129
|
},
|
135
|
-
elementToHighlight: /* @__PURE__ */ r(
|
130
|
+
elementToHighlight: /* @__PURE__ */ r(L, {})
|
136
131
|
}
|
137
|
-
]),
|
132
|
+
]), a.current.goToIndex(Q), i(e, !1, U), i(e, !0, ee)) : (f(e, [
|
138
133
|
{
|
139
|
-
originalElementToHighlightRef:
|
134
|
+
originalElementToHighlightRef: a.current.nextBtnRef,
|
140
135
|
isActive: !1,
|
141
136
|
type: s.NUDGE,
|
142
137
|
indicator: {
|
@@ -149,27 +144,27 @@ const Ae = ({
|
|
149
144
|
F,
|
150
145
|
{
|
151
146
|
renderAs: "secondary",
|
152
|
-
Icon:
|
153
|
-
onClick:
|
154
|
-
analyticsLabel:
|
147
|
+
Icon: $,
|
148
|
+
onClick: C,
|
149
|
+
analyticsLabel: X.JOURNEY_NEXT_ACTIVITY
|
155
150
|
}
|
156
151
|
)
|
157
152
|
}
|
158
|
-
]),
|
159
|
-
originalElementToHighlightRef:
|
153
|
+
]), a.current.goToIndex(z), i(e, !1, U)), d(e, {
|
154
|
+
originalElementToHighlightRef: t.current.labelRef,
|
160
155
|
isActive: !1,
|
161
156
|
type: s.TOOLTIP,
|
162
|
-
elementToHighlight: /* @__PURE__ */ r(
|
157
|
+
elementToHighlight: /* @__PURE__ */ r(L, {}),
|
163
158
|
indicator: {
|
164
159
|
position: "right",
|
165
160
|
backgroundColor: "YELLOW_4",
|
166
161
|
width: 264,
|
167
|
-
tooltipItem: /* @__PURE__ */ r(
|
162
|
+
tooltipItem: /* @__PURE__ */ r(O, { children: /* @__PURE__ */ r(m, { $renderAs: "ab2-bold", children: "Get faster at multiplication! Practice everyday and become a Tables champ." }) }),
|
168
163
|
tooltipXCoOrdinates: g.width + 50,
|
169
164
|
tooltipYCoOrdinates: g.height / 2
|
170
165
|
}
|
171
|
-
}), d(
|
172
|
-
originalElementToHighlightRef:
|
166
|
+
}), d(e, {
|
167
|
+
originalElementToHighlightRef: t.current.segmentedCardWrapperRef,
|
173
168
|
isActive: !1,
|
174
169
|
type: s.NUDGE,
|
175
170
|
indicator: {
|
@@ -179,36 +174,36 @@ const Ae = ({
|
|
179
174
|
nudgePointerY: E.height / 2
|
180
175
|
},
|
181
176
|
elementToHighlight: /* @__PURE__ */ r(
|
182
|
-
|
177
|
+
Y,
|
183
178
|
{
|
184
|
-
ref:
|
179
|
+
ref: h,
|
185
180
|
label: o.label,
|
186
181
|
data: o.data,
|
187
182
|
onPress: () => {
|
188
183
|
},
|
189
|
-
onPressTableSegment: (
|
184
|
+
onPressTableSegment: (v) => S(o, v)
|
190
185
|
}
|
191
186
|
)
|
192
187
|
});
|
193
188
|
},
|
194
189
|
[
|
195
190
|
d,
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
191
|
+
a,
|
192
|
+
C,
|
193
|
+
S,
|
194
|
+
e,
|
200
195
|
i,
|
201
|
-
|
196
|
+
f
|
202
197
|
]
|
203
198
|
);
|
204
|
-
return
|
205
|
-
T.current.forEach((o) => clearTimeout(o)), T.current = []
|
206
|
-
}, [
|
207
|
-
tableRef:
|
208
|
-
startJourney:
|
199
|
+
return M(() => () => {
|
200
|
+
T.current.forEach((o) => clearTimeout(o)), T.current = [];
|
201
|
+
}, [e]), {
|
202
|
+
tableRef: t,
|
203
|
+
startJourney: G
|
209
204
|
};
|
210
205
|
};
|
211
206
|
export {
|
212
|
-
|
207
|
+
fe as useTableLauncherJourney
|
213
208
|
};
|
214
209
|
//# sourceMappingURL=use-table-launcher-journey.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-launcher-journey.js","sources":["../../../../../../src/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.tsx"],"sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport type { IArrowTooltipProps } from '../../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport type { INudgeProps } from '../../../../ui/nudge/nudge-types';\nimport type { ITableCardRef, ITableDetails } from '../../comps/tables-card/tables-card-types';\nimport type {\n ITableInfo,\n ITables,\n} from '../../dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IUseTableJourneyProps } from './use-table-launcher-journey-types';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\nimport CaratRightIcon from '../../../../../assets/line-icons/icons/carat-right';\nimport { PLATFORM_EVENTS_STUDENT } from '../../../../analytics-events/platform-events-student';\nimport { JOURNEY_ID_STUDENT } from '../../../../journey/journey-id/journey-id-student';\nimport { IndicatorType } from '../../../../journey/use-journey/constants';\nimport { useJourney } from '../../../../journey/use-journey/use-journey';\nimport IconButton from '../../../../ui/buttons/icon-button/icon-button';\nimport { useUIContext } from '../../../../ui/context/context';\nimport FlexView from '../../../../ui/layout/flex-view';\nimport Text from '../../../../ui/text/text';\nimport { CIRCLE_ONBOARDING_ANALYTICS_STEPS as Action } from '../../../enum/circle-onboarding-steps';\nimport { useCircleSounds } from '../../../hooks/use-circle-sounds/use-circle-sounds';\nimport { TablesCard } from '../../comps/tables-card/tables-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from '../../game-launcher-analytics-events';\nimport {\n LESSON_CARD_INDEX,\n PUZZLE_CARD_INDEX,\n SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS,\n SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS,\n TABLE_CARD_INDEX,\n} from './constants';\nimport {\n GO_TO_TABLE_LAUNCHER_DURATION_MS,\n SHOW_CLICK_TABLE_NUDGE_AFTER_MS,\n SHOW_INITIAL_COACHMARK_AFTER_MS,\n SHOW_INITIAL_TOOLTIP_AFTER_MS,\n START_ANIMATING_CLONED_ELEM,\n} from './constants';\nimport * as S from './use-table-launcher-journey-styled';\n\nexport const useTableLauncherJourney = ({\n carouselRefs,\n onTableSegmentClick,\n}: IUseTableJourneyProps) => {\n const journeyId = JOURNEY_ID_STUDENT.CIRCLE_TABLES_INTRO_JOURNEY;\n const originalTableRef = useRef<ITableCardRef>(null);\n const highlightedTableRef = useRef<ITableCardRef>(null);\n const isJourneyInProgress = useRef(false);\n\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { playButtonSound } = useCircleSounds();\n const { nextCoachmark, setJourney, addCoachmark, endJourney } = useJourney();\n const { onEvent: trackAnalytics } = useUIContext();\n\n const handleEndJourney = useCallback(\n (tableDetails?: ITableDetails) => {\n // Only when User clicked on play\n if (tableDetails) {\n onTableSegmentClick(tableDetails);\n }\n trackAnalytics(PLATFORM_EVENTS_STUDENT.ONBOARDING_STEP_COMPLETED, {\n step: Action.TABLES,\n });\n\n // Reset original table card ref label\n originalTableRef?.current?.setLabelVisiblity(true);\n originalTableRef?.current?.stopLabelAnimation();\n endJourney(journeyId);\n },\n [endJourney, journeyId, onTableSegmentClick, trackAnalytics],\n );\n\n const handleTableSegmentClick = useCallback(\n (launcherData: ITables, tableData: ITableInfo) => {\n if (\n !originalTableRef.current?.segmentedCardWrapperRef.current ||\n !originalTableRef.current?.labelRef.current\n ) {\n return;\n }\n\n const segmentedCardDims = originalTableRef.current.labelRef.current.getBoundingClientRect();\n const tableCardDims =\n originalTableRef.current?.segmentedCardWrapperRef.current.getBoundingClientRect();\n\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: (\n <TablesCard\n ref={highlightedTableRef}\n defaultTable={tableData}\n label={launcherData.label}\n data={launcherData.data}\n onPress={handleEndJourney}\n onGoBackFromTableLevel={handleEndJourney}\n />\n ),\n indicator: {\n position: 'left',\n backgroundColor: 'YELLOW_4',\n width: 236,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">Each table has 3 levels—clear them and earn 3 stars!</Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: 0,\n tooltipYCoOrdinates: segmentedCardDims.height * 0.35,\n } as IArrowTooltipProps,\n });\n\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Pick a level\n </Text>\n ),\n nudgePointerX: tableCardDims.width / 2 + 50,\n nudgePointerY: tableCardDims.height * 0.4,\n } as INudgeProps,\n elementToHighlight: <></>,\n });\n\n nextCoachmark(journeyId, false, SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS); // Show coachmark => Each table has 3... and Hide the previous two\n nextCoachmark(journeyId, true, SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS); // Show nudge => Pick a level\n\n const startAnimationOnLabelAgain = setTimeout(() => {\n clearTimeout(startAnimationOnLabelAgain);\n highlightedTableRef.current?.startLabelAnimation('YELLOW_4');\n }, START_ANIMATING_CLONED_ELEM);\n\n timerRefs.current.push(startAnimationOnLabelAgain);\n },\n [addCoachmark, handleEndJourney, journeyId, nextCoachmark],\n );\n\n const goToTableLauncher = useCallback(() => {\n playButtonSound();\n carouselRefs.current.goToIndex(TABLE_CARD_INDEX);\n nextCoachmark(journeyId, false, GO_TO_TABLE_LAUNCHER_DURATION_MS);\n\n trackAnalytics(PLATFORM_EVENTS_STUDENT.ONBOARDING_STEP_VIEWED, {\n step: Action.TABLES,\n });\n\n const showNudge = setTimeout(() => {\n clearTimeout(showNudge);\n originalTableRef.current?.setLabelVisiblity(false);\n nextCoachmark(journeyId, true);\n }, SHOW_CLICK_TABLE_NUDGE_AFTER_MS);\n\n timerRefs.current.push(showNudge);\n\n const animateLabel = setTimeout(() => {\n clearTimeout(animateLabel);\n highlightedTableRef.current?.startLabelAnimation('YELLOW_4');\n }, START_ANIMATING_CLONED_ELEM);\n\n timerRefs.current.push(animateLabel);\n }, [carouselRefs, journeyId, nextCoachmark, playButtonSound, trackAnalytics]);\n\n const startJourney = useCallback(\n (tablesData: ITables, isTutorialOnboardingDone: boolean = false) => {\n if (isJourneyInProgress.current) {\n return;\n }\n\n const paginationList = carouselRefs.current.indicatorRefs;\n const carouselNextBtnRef = carouselRefs.current.nextBtnRef;\n const tablePaginationRef = paginationList?.[TABLE_CARD_INDEX];\n\n if (\n !originalTableRef.current?.segmentedCardWrapperRef.current ||\n !originalTableRef.current?.labelRef.current ||\n !paginationList ||\n !carouselNextBtnRef?.current ||\n !tablePaginationRef ||\n !tablePaginationRef.current\n ) {\n return;\n }\n\n isJourneyInProgress.current = true;\n\n const labelDims = originalTableRef.current.labelRef.current.getBoundingClientRect();\n const tableCardDims =\n originalTableRef.current?.segmentedCardWrapperRef.current.getBoundingClientRect();\n\n // TAKE THE USER TO THE TABLE CARD\n if (!isTutorialOnboardingDone) {\n setJourney(journeyId, [\n {\n originalElementToHighlightRef: carouselRefs.current.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to proceed\n </Text>\n ),\n nudgePointerX: 0,\n nudgePointerY: 0,\n } as INudgeProps,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={CaratRightIcon}\n onClick={goToTableLauncher}\n analyticsLabel={GAME_LAUNCHER_ANALYTICS_EVENTS.JOURNEY_NEXT_ACTIVITY}\n />\n ),\n },\n ]);\n carouselRefs.current.goToIndex(PUZZLE_CARD_INDEX);\n nextCoachmark(journeyId, false, SHOW_INITIAL_COACHMARK_AFTER_MS); // Show nudge => Click to proceed\n } else {\n setJourney(journeyId, [\n {\n originalElementToHighlightRef: tablePaginationRef as React.RefObject<HTMLDivElement>,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <S.Indicator $isActive={false} />,\n indicator: {\n position: 'bottom',\n backgroundColor: 'YELLOW_4',\n width: 52,\n tooltipItem: (\n <FlexView\n $position=\"absolute\"\n $flexDirection=\"row\"\n style={{ top: 6, left: 8, cursor: 'pointer' }}\n onClick={goToTableLauncher}\n >\n <Text $renderAs=\"ab2-bold\">NEW</Text>\n </FlexView>\n ),\n tooltipYCoOrdinates: 14, // Need some offset in Y direction from top\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: tablePaginationRef as React.RefObject<HTMLDivElement>,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: '',\n nudgePointerY: 20,\n } as INudgeProps,\n elementToHighlight: <></>,\n },\n ]);\n carouselRefs.current.goToIndex(LESSON_CARD_INDEX);\n nextCoachmark(journeyId, false, SHOW_INITIAL_COACHMARK_AFTER_MS); // Show Coachmark => NEW\n nextCoachmark(journeyId, true, SHOW_INITIAL_TOOLTIP_AFTER_MS); // Show Nudge over Coachmark\n }\n\n // SHOW THE USER SELECT A TABLE\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'YELLOW_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Get faster at multiplication! Practice everyday and become a Tables champ.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: labelDims.width + 50,\n tooltipYCoOrdinates: labelDims.height / 2,\n } as IArrowTooltipProps,\n });\n\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n {'Pick a table to start'}\n </Text>\n ),\n nudgePointerX: tableCardDims.width / 2 + 50,\n nudgePointerY: tableCardDims.height / 2,\n } as INudgeProps,\n elementToHighlight: (\n <TablesCard\n ref={highlightedTableRef}\n label={tablesData.label}\n data={tablesData.data}\n onPress={() => {}}\n onPressTableSegment={tableInfo => handleTableSegmentClick(tablesData, tableInfo)}\n />\n ),\n });\n },\n [\n addCoachmark,\n carouselRefs,\n goToTableLauncher,\n handleTableSegmentClick,\n journeyId,\n nextCoachmark,\n setJourney,\n ],\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n timerRefs.current.forEach(timer => clearTimeout(timer));\n timerRefs.current = [];\n isJourneyInProgress.current = false;\n };\n }, [journeyId]);\n\n return {\n tableRef: originalTableRef,\n startJourney,\n };\n};\n"],"names":["useTableLauncherJourney","carouselRefs","onTableSegmentClick","journeyId","JOURNEY_ID_STUDENT","originalTableRef","useRef","highlightedTableRef","isJourneyInProgress","timerRefs","playButtonSound","useCircleSounds","nextCoachmark","setJourney","addCoachmark","endJourney","useJourney","trackAnalytics","useUIContext","handleEndJourney","useCallback","tableDetails","PLATFORM_EVENTS_STUDENT","Action","_a","_b","handleTableSegmentClick","launcherData","tableData","segmentedCardDims","tableCardDims","_c","IndicatorType","jsx","TablesCard","FlexView","Text","Fragment","SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS","SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS","startAnimationOnLabelAgain","START_ANIMATING_CLONED_ELEM","goToTableLauncher","TABLE_CARD_INDEX","GO_TO_TABLE_LAUNCHER_DURATION_MS","showNudge","SHOW_CLICK_TABLE_NUDGE_AFTER_MS","animateLabel","startJourney","tablesData","isTutorialOnboardingDone","paginationList","carouselNextBtnRef","tablePaginationRef","labelDims","S.Indicator","LESSON_CARD_INDEX","SHOW_INITIAL_COACHMARK_AFTER_MS","SHOW_INITIAL_TOOLTIP_AFTER_MS","IconButton","CaratRightIcon","GAME_LAUNCHER_ANALYTICS_EVENTS","PUZZLE_CARD_INDEX","tableInfo","useEffect","timer"],"mappings":";;;;;;;;;;;;;;;;;AAyCO,MAAMA,KAA0B,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L,CAAS,CAAC,GAEP;AAAA,IACL,UAAUE;AAAA,IACV,cAAA2C;AAAA,EAAA;AAEJ;"}
|
1
|
+
{"version":3,"file":"use-table-launcher-journey.js","sources":["../../../../../../src/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.tsx"],"sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport type { IArrowTooltipProps } from '../../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport type { INudgeProps } from '../../../../ui/nudge/nudge-types';\nimport type { ITableCardRef, ITableDetails } from '../../comps/tables-card/tables-card-types';\nimport type {\n ITableInfo,\n ITables,\n} from '../../dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IUseTableJourneyProps } from './use-table-launcher-journey-types';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\nimport CaratRightIcon from '../../../../../assets/line-icons/icons/carat-right';\nimport { PLATFORM_EVENTS_STUDENT } from '../../../../analytics-events/platform-events-student';\nimport { JOURNEY_ID_STUDENT } from '../../../../journey/journey-id/journey-id-student';\nimport { IndicatorType } from '../../../../journey/use-journey/constants';\nimport { useJourney } from '../../../../journey/use-journey/use-journey';\nimport IconButton from '../../../../ui/buttons/icon-button/icon-button';\nimport { useUIContext } from '../../../../ui/context/context';\nimport FlexView from '../../../../ui/layout/flex-view';\nimport Text from '../../../../ui/text/text';\nimport { CIRCLE_ONBOARDING_ANALYTICS_STEPS as Action } from '../../../enum/circle-onboarding-steps';\nimport { useCircleSounds } from '../../../hooks/use-circle-sounds/use-circle-sounds';\nimport { TablesCard } from '../../comps/tables-card/tables-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from '../../game-launcher-analytics-events';\nimport {\n LESSON_CARD_INDEX,\n PUZZLE_CARD_INDEX,\n SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS,\n SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS,\n TABLE_CARD_INDEX,\n} from './constants';\nimport {\n GO_TO_TABLE_LAUNCHER_DURATION_MS,\n SHOW_CLICK_TABLE_NUDGE_AFTER_MS,\n SHOW_INITIAL_COACHMARK_AFTER_MS,\n SHOW_INITIAL_TOOLTIP_AFTER_MS,\n START_ANIMATING_CLONED_ELEM,\n} from './constants';\nimport * as S from './use-table-launcher-journey-styled';\n\nexport const useTableLauncherJourney = ({\n carouselRefs,\n onTableSegmentClick,\n}: IUseTableJourneyProps) => {\n const journeyId = JOURNEY_ID_STUDENT.CIRCLE_TABLES_INTRO_JOURNEY;\n const originalTableRef = useRef<ITableCardRef>(null);\n const highlightedTableRef = useRef<ITableCardRef>(null);\n\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { playButtonSound } = useCircleSounds();\n const { nextCoachmark, setJourney, addCoachmark, endJourney } = useJourney();\n const { onEvent: trackAnalytics } = useUIContext();\n\n const handleEndJourney = useCallback(\n (tableDetails?: ITableDetails) => {\n // Only when User clicked on play\n if (tableDetails) {\n onTableSegmentClick(tableDetails);\n }\n trackAnalytics(PLATFORM_EVENTS_STUDENT.ONBOARDING_STEP_COMPLETED, {\n step: Action.TABLES,\n });\n\n // Reset original table card ref label\n originalTableRef?.current?.setLabelVisiblity(true);\n originalTableRef?.current?.stopLabelAnimation();\n endJourney(journeyId);\n },\n [endJourney, journeyId, onTableSegmentClick, trackAnalytics],\n );\n\n const handleTableSegmentClick = useCallback(\n (launcherData: ITables, tableData: ITableInfo) => {\n const segmentedCardDims = originalTableRef.current.labelRef.current.getBoundingClientRect();\n const tableCardDims =\n originalTableRef.current?.segmentedCardWrapperRef.current.getBoundingClientRect();\n\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: (\n <TablesCard\n ref={highlightedTableRef}\n defaultTable={tableData}\n label={launcherData.label}\n data={launcherData.data}\n onPress={handleEndJourney}\n onGoBackFromTableLevel={handleEndJourney}\n />\n ),\n indicator: {\n position: 'left',\n backgroundColor: 'YELLOW_4',\n width: 236,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">Each table has 3 levels—clear them and earn 3 stars!</Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: 0,\n tooltipYCoOrdinates: segmentedCardDims.height * 0.35,\n } as IArrowTooltipProps,\n });\n\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Pick a level\n </Text>\n ),\n nudgePointerX: tableCardDims.width / 2 + 50,\n nudgePointerY: tableCardDims.height * 0.4,\n } as INudgeProps,\n elementToHighlight: <></>,\n });\n\n nextCoachmark(journeyId, false, SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS); // Show coachmark => Each table has 3... and Hide the previous two\n nextCoachmark(journeyId, true, SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS); // Show nudge => Pick a level\n\n const startAnimationOnLabelAgain = setTimeout(() => {\n clearTimeout(startAnimationOnLabelAgain);\n highlightedTableRef.current?.startLabelAnimation('YELLOW_4');\n }, START_ANIMATING_CLONED_ELEM);\n\n timerRefs.current.push(startAnimationOnLabelAgain);\n },\n [addCoachmark, handleEndJourney, journeyId, nextCoachmark],\n );\n\n const goToTableLauncher = useCallback(() => {\n playButtonSound();\n carouselRefs.current.goToIndex(TABLE_CARD_INDEX);\n nextCoachmark(journeyId, false, GO_TO_TABLE_LAUNCHER_DURATION_MS);\n\n trackAnalytics(PLATFORM_EVENTS_STUDENT.ONBOARDING_STEP_VIEWED, {\n step: Action.TABLES,\n });\n\n const showNudge = setTimeout(() => {\n clearTimeout(showNudge);\n originalTableRef.current?.setLabelVisiblity(false);\n nextCoachmark(journeyId, true);\n }, SHOW_CLICK_TABLE_NUDGE_AFTER_MS);\n\n timerRefs.current.push(showNudge);\n\n const animateLabel = setTimeout(() => {\n clearTimeout(animateLabel);\n highlightedTableRef.current?.startLabelAnimation('YELLOW_4');\n }, START_ANIMATING_CLONED_ELEM);\n\n timerRefs.current.push(animateLabel);\n }, [carouselRefs, journeyId, nextCoachmark, playButtonSound, trackAnalytics]);\n\n const startJourney = useCallback(\n (tablesData: ITables, isTutorialOnboardingDone: boolean = false) => {\n const paginationList = carouselRefs.current.indicatorRefs;\n const carouselNextBtnRef = carouselRefs.current.nextBtnRef;\n const tablePaginationRef = paginationList?.[TABLE_CARD_INDEX];\n\n if (\n !originalTableRef.current?.segmentedCardWrapperRef.current ||\n !originalTableRef.current?.labelRef.current ||\n !paginationList ||\n !carouselNextBtnRef?.current ||\n !tablePaginationRef ||\n !tablePaginationRef.current\n ) {\n return;\n }\n\n const labelDims = originalTableRef.current.labelRef.current.getBoundingClientRect();\n const tableCardDims =\n originalTableRef.current?.segmentedCardWrapperRef.current.getBoundingClientRect();\n\n // TAKE THE USER TO THE TABLE CARD\n if (!isTutorialOnboardingDone) {\n setJourney(journeyId, [\n {\n originalElementToHighlightRef: carouselRefs.current.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to proceed\n </Text>\n ),\n nudgePointerX: 0,\n nudgePointerY: 0,\n } as INudgeProps,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={CaratRightIcon}\n onClick={goToTableLauncher}\n analyticsLabel={GAME_LAUNCHER_ANALYTICS_EVENTS.JOURNEY_NEXT_ACTIVITY}\n />\n ),\n },\n ]);\n carouselRefs.current.goToIndex(PUZZLE_CARD_INDEX);\n nextCoachmark(journeyId, false, SHOW_INITIAL_COACHMARK_AFTER_MS); // Show nudge => Click to proceed\n } else {\n setJourney(journeyId, [\n {\n originalElementToHighlightRef: tablePaginationRef as React.RefObject<HTMLDivElement>,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <S.Indicator $isActive={false} />,\n indicator: {\n position: 'bottom',\n backgroundColor: 'YELLOW_4',\n width: 52,\n tooltipItem: (\n <FlexView\n $position=\"absolute\"\n $flexDirection=\"row\"\n style={{ top: 6, left: 8, cursor: 'pointer' }}\n onClick={goToTableLauncher}\n >\n <Text $renderAs=\"ab2-bold\">NEW</Text>\n </FlexView>\n ),\n tooltipYCoOrdinates: 14, // Need some offset in Y direction from top\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: tablePaginationRef as React.RefObject<HTMLDivElement>,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: '',\n nudgePointerY: 20,\n } as INudgeProps,\n elementToHighlight: <></>,\n },\n ]);\n carouselRefs.current.goToIndex(LESSON_CARD_INDEX);\n nextCoachmark(journeyId, false, SHOW_INITIAL_COACHMARK_AFTER_MS); // Show Coachmark => NEW\n nextCoachmark(journeyId, true, SHOW_INITIAL_TOOLTIP_AFTER_MS); // Show Nudge over Coachmark\n }\n\n // SHOW THE USER SELECT A TABLE\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'YELLOW_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Get faster at multiplication! Practice everyday and become a Tables champ.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: labelDims.width + 50,\n tooltipYCoOrdinates: labelDims.height / 2,\n } as IArrowTooltipProps,\n });\n\n addCoachmark(journeyId, {\n originalElementToHighlightRef: originalTableRef.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n {'Pick a table to start'}\n </Text>\n ),\n nudgePointerX: tableCardDims.width / 2 + 50,\n nudgePointerY: tableCardDims.height / 2,\n } as INudgeProps,\n elementToHighlight: (\n <TablesCard\n ref={highlightedTableRef}\n label={tablesData.label}\n data={tablesData.data}\n onPress={() => {}}\n onPressTableSegment={tableInfo => handleTableSegmentClick(tablesData, tableInfo)}\n />\n ),\n });\n },\n [\n addCoachmark,\n carouselRefs,\n goToTableLauncher,\n handleTableSegmentClick,\n journeyId,\n nextCoachmark,\n setJourney,\n ],\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n timerRefs.current.forEach(timer => clearTimeout(timer));\n timerRefs.current = [];\n };\n }, [journeyId]);\n\n return {\n tableRef: originalTableRef,\n startJourney,\n };\n};\n"],"names":["useTableLauncherJourney","carouselRefs","onTableSegmentClick","journeyId","JOURNEY_ID_STUDENT","originalTableRef","useRef","highlightedTableRef","timerRefs","playButtonSound","useCircleSounds","nextCoachmark","setJourney","addCoachmark","endJourney","useJourney","trackAnalytics","useUIContext","handleEndJourney","useCallback","tableDetails","PLATFORM_EVENTS_STUDENT","Action","_a","_b","handleTableSegmentClick","launcherData","tableData","segmentedCardDims","tableCardDims","IndicatorType","jsx","TablesCard","FlexView","Text","Fragment","SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS","SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS","startAnimationOnLabelAgain","START_ANIMATING_CLONED_ELEM","goToTableLauncher","TABLE_CARD_INDEX","GO_TO_TABLE_LAUNCHER_DURATION_MS","showNudge","SHOW_CLICK_TABLE_NUDGE_AFTER_MS","animateLabel","startJourney","tablesData","isTutorialOnboardingDone","paginationList","carouselNextBtnRef","tablePaginationRef","labelDims","_c","S.Indicator","LESSON_CARD_INDEX","SHOW_INITIAL_COACHMARK_AFTER_MS","SHOW_INITIAL_TOOLTIP_AFTER_MS","IconButton","CaratRightIcon","GAME_LAUNCHER_ANALYTICS_EVENTS","PUZZLE_CARD_INDEX","tableInfo","useEffect","timer"],"mappings":";;;;;;;;;;;;;;;;;AAyCO,MAAMA,KAA0B,CAAC;AAAA,EACtC,cAAAC;AAAA,EACA,qBAAAC;AACF,MAA6B;AAC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CAAA;AAAA,UAEF,qBAAqBkB,EAAU,QAAQ;AAAA,UACvC,qBAAqBA,EAAU,SAAS;AAAA,QAC1C;AAAA,MAAA,CACD,GAEDvC,EAAaV,GAAW;AAAA,QACtB,+BAA+BE,EAAiB,QAAQ;AAAA,QACxD,UAAU;AAAA,QACV,MAAMyB,EAAc;AAAA,QACpB,WAAW;AAAA,UACT,OAAO;AAAA,UACP,SACG,gBAAAC,EAAAG,GAAA,EAAK,WAAU,OAAM,QAAO,SAC1B,UACH,yBAAA;AAAA,UAEF,eAAeL,EAAc,QAAQ,IAAI;AAAA,UACzC,eAAeA,EAAc,SAAS;AAAA,QACxC;AAAA,QACA,oBACE,gBAAAE;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,KAAKzB;AAAA,YACL,OAAOwC,EAAW;AAAA,YAClB,MAAMA,EAAW;AAAA,YACjB,SAAS,MAAM;AAAA,YAAC;AAAA,YAChB,qBAAqB,CAAAe,MAAarC,EAAwBsB,GAAYe,CAAS;AAAA,UAAA;AAAA,QACjF;AAAA,MAAA,CAEH;AAAA,IACH;AAAA,IACA;AAAA,MACEjD;AAAA,MACAZ;AAAA,MACAuC;AAAA,MACAf;AAAA,MACAtB;AAAA,MACAQ;AAAA,MACAC;AAAA,IACF;AAAA,EAAA;AAIF,SAAAmD,EAAU,MACD,MAAM;AACX,IAAAvD,EAAU,QAAQ,QAAQ,CAASwD,MAAA,aAAaA,CAAK,CAAC,GACtDxD,EAAU,UAAU;EAAC,GAEtB,CAACL,CAAS,CAAC,GAEP;AAAA,IACL,UAAUE;AAAA,IACV,cAAAyC;AAAA,EAAA;AAEJ;"}
|
@@ -1,39 +1,39 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { createContext as
|
1
|
+
import { jsxs as q, jsx as j } from "react/jsx-runtime";
|
2
|
+
import { createContext as D, useState as h, useRef as C, useCallback as l, useMemo as L, useEffect as R } from "react";
|
3
3
|
import { Coachmark as N } from "../comps/coachmark/coachmark.js";
|
4
4
|
import { usePostUserJourney as M, useGetUserJourney as z } from "../user-journey-api/user-journey-api.js";
|
5
5
|
import { Overlay as G } from "./journey-styled.js";
|
6
|
-
const S =
|
7
|
-
const [
|
8
|
-
data:
|
9
|
-
get:
|
10
|
-
isProcessing:
|
11
|
-
} = z(),
|
6
|
+
const S = D(null), Q = ({ children: T, appId: u, userId: s }) => {
|
7
|
+
const [k, v] = h([]), [n, c] = h([]), [g, p] = h(!1), a = C(-1), r = C(), f = C([]), { post: x } = M(), {
|
8
|
+
data: m = null,
|
9
|
+
get: _,
|
10
|
+
isProcessing: O
|
11
|
+
} = z(), U = (u === "" || m && !O) && n.length > 0, A = l(
|
12
12
|
(e, t) => {
|
13
|
-
if (
|
13
|
+
if (n.length > 0) {
|
14
14
|
console.error(
|
15
15
|
`setJourney: Other Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
16
16
|
);
|
17
17
|
return;
|
18
18
|
}
|
19
|
-
|
19
|
+
p(!0), r.current = e, a.current = -1, c([...t]);
|
20
20
|
},
|
21
|
-
[
|
22
|
-
),
|
21
|
+
[n.length]
|
22
|
+
), y = l(() => {
|
23
23
|
f.current.forEach((e) => {
|
24
24
|
clearTimeout(e);
|
25
25
|
}), f.current = [], r.current = void 0, a.current = -1, c([]), p(!1);
|
26
|
-
}, []),
|
26
|
+
}, []), P = l(
|
27
27
|
(e) => {
|
28
|
-
|
28
|
+
v((t) => [...t, e]), x({
|
29
29
|
app_id: u,
|
30
30
|
user_id: s,
|
31
31
|
journey_id: e,
|
32
32
|
journey_status: "COMPLETED"
|
33
|
-
}),
|
33
|
+
}), y();
|
34
34
|
},
|
35
|
-
[u,
|
36
|
-
),
|
35
|
+
[u, y, x, s]
|
36
|
+
), $ = l((e, t) => {
|
37
37
|
if (!r.current || e !== r.current) {
|
38
38
|
console.error(
|
39
39
|
r.current ? `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}` : "addCoachmark was called before setJourney and Journey ID is undefined"
|
@@ -49,57 +49,57 @@ const S = q(null), Q = ({ children: R, appId: u, userId: s }) => {
|
|
49
49
|
);
|
50
50
|
return;
|
51
51
|
}
|
52
|
-
J !== 0 && c((
|
52
|
+
J !== 0 && c((o) => o.map((i) => ({ ...i, isActive: !1 })));
|
53
53
|
const E = setTimeout(() => {
|
54
54
|
clearTimeout(E);
|
55
|
-
const
|
55
|
+
const o = a.current + 1;
|
56
56
|
c((i) => {
|
57
|
-
if (
|
57
|
+
if (o >= i.length || i.length === 0)
|
58
58
|
return r.current = void 0, a.current = -1, [];
|
59
|
-
a.current =
|
60
|
-
const
|
61
|
-
return
|
59
|
+
a.current = o;
|
60
|
+
const d = [...i];
|
61
|
+
return d[o].isActive = !0, o > 0 && (d[o - 1].isActive = t), d;
|
62
62
|
});
|
63
63
|
}, J);
|
64
64
|
f.current.push(E);
|
65
65
|
},
|
66
66
|
[]
|
67
|
-
),
|
67
|
+
), b = L(
|
68
68
|
() => ({
|
69
69
|
nextCoachmark: w,
|
70
|
-
setJourney:
|
71
|
-
addCoachmark:
|
72
|
-
clearJourney:
|
73
|
-
endJourney:
|
74
|
-
coachmarks:
|
75
|
-
userCompletedJourneyIds:
|
76
|
-
isJourneyActive:
|
70
|
+
setJourney: A,
|
71
|
+
addCoachmark: $,
|
72
|
+
clearJourney: y,
|
73
|
+
endJourney: P,
|
74
|
+
coachmarks: n,
|
75
|
+
userCompletedJourneyIds: k,
|
76
|
+
isJourneyActive: g
|
77
77
|
}),
|
78
78
|
[
|
79
79
|
w,
|
80
|
-
_,
|
81
|
-
P,
|
82
|
-
m,
|
83
80
|
A,
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
$,
|
82
|
+
y,
|
83
|
+
P,
|
84
|
+
n,
|
85
|
+
k,
|
86
|
+
g
|
87
87
|
]
|
88
88
|
);
|
89
|
-
return
|
90
|
-
u && s &&
|
89
|
+
return R(() => {
|
90
|
+
u && s && _(s, {
|
91
91
|
app_id: u,
|
92
92
|
user_id: s,
|
93
93
|
journey_status: "COMPLETED"
|
94
94
|
});
|
95
|
-
}, [u,
|
96
|
-
if (
|
97
|
-
const e =
|
98
|
-
|
95
|
+
}, [u, _, s]), R(() => {
|
96
|
+
if (m) {
|
97
|
+
const e = m.map((t) => t.journey_id);
|
98
|
+
v(e);
|
99
99
|
}
|
100
|
-
}, [
|
101
|
-
|
102
|
-
|
100
|
+
}, [m]), /* @__PURE__ */ q(S.Provider, { value: b, children: [
|
101
|
+
U && /* @__PURE__ */ j(G, { children: n.map((e, t) => /* @__PURE__ */ j(N, { coachmark: e }, `coachmark-${t}`)) }),
|
102
|
+
T
|
103
103
|
] });
|
104
104
|
};
|
105
105
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n} from './journey-context-types';\nimport type { FC } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<IJourneyProviderProps> = ({ children, appId, userId }) => {\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[]>([]);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const {\n data: userCompletedJourneys = null,\n get: getJourneyProgress,\n isProcessing,\n } = useGetUserJourney();\n\n const showCoachmarks =\n appId === '' // Otherwise coachmark stories wont work\n ? coachmarkList.length > 0\n : userCompletedJourneys && !isProcessing && coachmarkList.length > 0;\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n console.log(`setJourney: Journey ID: ${id}`);\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n console.log(`setJourney: Journey ID: ${id}`);\n\n setIsJourneyActive(true);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n setUserCompletedJourneyIds(prev => [...prev, journeyId]);\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n clearJourney();\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n\n if (delayInMs !== 0) {\n // If delay is not 0, we will hide all them coachmarks and reveal only after the delay\n setCoachmarkList(prevList => {\n return prevList.map((item: ICoachmarkProps) => {\n return { ...item, isActive: false };\n });\n });\n }\n\n const timer = setTimeout(() => {\n clearTimeout(timer);\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n }, delayInMs);\n\n timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {showCoachmarks && (\n <S.Overlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","userCompletedJourneyIds","setUserCompletedJourneyIds","useState","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","isProcessing","useGetUserJourney","showCoachmarks","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","S.Overlay","index","jsx","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAyBC,CAA0B,IAAIC,EAAuB,CAAE,CAAA,GACjF,CAACC,GAAeC,CAAgB,IAAIF,EAA4B,CAAE,CAAA,GAClE,CAACG,GAAiBC,CAAkB,IAAIJ,EAAS,EAAK,GACtDK,IAAeC,EAAO,EAAE,GACxBC,IAAmBD,KACnBE,IAAYF,EAAwC,CAAA,CAAE,GAEtD,EAAE,MAAMG,EAAsB,IAAIC,EAAmB,GACrD;AAAA,IACJ,MAAMC,IAAwB;AAAA,IAC9B,KAAKC;AAAA,IACL,cAAAC;AAAA,MACEC,EAAkB,GAEhBC,KACJnB,MAAU,MAENe,KAAyB,CAACE,MAAgBZ,EAAc,SAAS,GAEjEe,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAE7C,UADI,QAAA,IAAI,2BAA2BD,CAAE,EAAE,GACvCjB,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEM,EAAiB,OAAO,0BAA0BW,CAAE;AAAA,QAAA;AAGvH;AAAA,MACF;AACQ,cAAA,IAAI,2BAA2BA,CAAE,EAAE,GAE3Cd,EAAmB,EAAI,GACvBG,EAAiB,UAAUW,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AAU;AAExF,MAAAvC,EAA2BsC,CAAwB;AAAA,IACrD;AAAA,EAAA,GACC,CAAC1B,CAAqB,CAAC,GAGvB,gBAAA4B,EAAA/C,EAAe,UAAf,EAAwB,OAAO0C,GAC7B,UAAA;AAAA,IAAAnB,uBACEyB,GAAA,EACE,UAAAvC,EAAc,IAAI,CAACyB,GAAWe,MAC7B,gBAAAC,EAACC,KAAqC,WAAAjB,KAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED9C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
1
|
+
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n} from './journey-context-types';\nimport type { FC } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<IJourneyProviderProps> = ({ children, appId, userId }) => {\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[]>([]);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const {\n data: userCompletedJourneys = null,\n get: getJourneyProgress,\n isProcessing,\n } = useGetUserJourney();\n\n const showCoachmarks =\n appId === '' // Otherwise coachmark stories wont work\n ? coachmarkList.length > 0\n : userCompletedJourneys && !isProcessing && coachmarkList.length > 0;\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n setIsJourneyActive(true);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n setUserCompletedJourneyIds(prev => [...prev, journeyId]);\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n clearJourney();\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n\n if (delayInMs !== 0) {\n // If delay is not 0, we will hide all them coachmarks and reveal only after the delay\n setCoachmarkList(prevList => {\n return prevList.map((item: ICoachmarkProps) => {\n return { ...item, isActive: false };\n });\n });\n }\n\n const timer = setTimeout(() => {\n clearTimeout(timer);\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n }, delayInMs);\n\n timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {showCoachmarks && (\n <S.Overlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","userCompletedJourneyIds","setUserCompletedJourneyIds","useState","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","isProcessing","useGetUserJourney","showCoachmarks","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","S.Overlay","index","jsx","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAyBC,CAA0B,IAAIC,EAAuB,CAAE,CAAA,GACjF,CAACC,GAAeC,CAAgB,IAAIF,EAA4B,CAAE,CAAA,GAClE,CAACG,GAAiBC,CAAkB,IAAIJ,EAAS,EAAK,GACtDK,IAAeC,EAAO,EAAE,GACxBC,IAAmBD,KACnBE,IAAYF,EAAwC,CAAA,CAAE,GAEtD,EAAE,MAAMG,EAAsB,IAAIC,EAAmB,GACrD;AAAA,IACJ,MAAMC,IAAwB;AAAA,IAC9B,KAAKC;AAAA,IACL,cAAAC;AAAA,MACEC,EAAkB,GAEhBC,KACJnB,MAAU,MAENe,KAAyB,CAACE,MAAgBZ,EAAc,SAAS,GAEjEe,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAlB,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEM,EAAiB,OAAO,0BAA0BW,CAAE;AAAA,QAAA;AAGvH;AAAA,MACF;AACA,MAAAd,EAAmB,EAAI,GACvBG,EAAiB,UAAUW,GAC3Bb,EAAa,UAAU,IACNH,EAAA,CAAC,GAAGiB,CAAU,CAAC;AAAA,IAClC;AAAA,IACA,CAAClB,EAAc,MAAM;AAAA,EAAA,GAGjBmB,IAAeH,EAAY,MAAM;AAE3B,IAAAT,EAAA,QAAQ,QAAQ,CAASa,MAAA;AACjC,mBAAaA,CAAK;AAA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GAAWe,MAC7B,gBAAAC,EAACC,KAAqC,WAAAjB,KAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED9C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
package/dist/index.d.ts
CHANGED
@@ -1107,7 +1107,6 @@ declare interface IGame extends IBaseProject {
|
|
1107
1107
|
declare interface IGameLauncherProps {
|
1108
1108
|
onSegmentClick: (projectDetail: Game | Puzzle | Lesson | ITableDetails, projectType: ProjectType) => void;
|
1109
1109
|
isLoading?: boolean;
|
1110
|
-
isError?: boolean;
|
1111
1110
|
data: IProjectData | null;
|
1112
1111
|
defaultIndex?: number;
|
1113
1112
|
journeyId?: TJourneyId;
|