@cuemath/leap 2.8.21-rj-5 → 2.8.21-rj-7

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,149 +1,137 @@
1
- import { jsx as e, Fragment as E, jsxs as R } from "react/jsx-runtime";
2
- import { useRef as g, useCallback as A, useMemo as j } from "react";
3
- import Z from "../../../../assets/line-icons/icons/next.js";
4
- import { IndicatorType as d } from "../../../journey/use-journey/constants.js";
5
- import { useJourney as z } from "../../../journey/use-journey/use-journey.js";
6
- import q from "../../../ui/buttons/icon-button/icon-button.js";
7
- import L from "../../../ui/layout/flex-view.js";
8
- import r from "../../../ui/text/text.js";
9
- import { useCircleSounds as ee } from "../../hooks/use-circle-sounds/use-circle-sounds.js";
10
- import { SegmentedGameCard as te } from "../comps/segmented-game-card/segmented-game-card.js";
11
- import { GO_TO_NEXT_SLIDE_AFTER_MS as re, SHOW_LABEL_HIGHLIGHT_AFTER_MS as ne, SHOW_NUDGE_AFTER_MS as ie } from "./constants.js";
12
- import { ProjectType as oe } from "../../games/web-view/enums/project-type-enum.js";
13
- const be = ({
14
- onSegmentClick: C,
1
+ import { jsx as e, Fragment as R } from "react/jsx-runtime";
2
+ import { useRef as u, useCallback as b, useMemo as Q } from "react";
3
+ import V from "../../../../assets/line-icons/icons/next.js";
4
+ import { IndicatorType as s } from "../../../journey/use-journey/constants.js";
5
+ import { useJourney as j } from "../../../journey/use-journey/use-journey.js";
6
+ import Z from "../../../ui/buttons/icon-button/icon-button.js";
7
+ import C from "../../../ui/layout/flex-view.js";
8
+ import d from "../../../ui/text/text.js";
9
+ import { useCircleSounds as z } from "../../hooks/use-circle-sounds/use-circle-sounds.js";
10
+ import { SegmentedGameCard as ee } from "../comps/segmented-game-card/segmented-game-card.js";
11
+ import { GO_TO_NEXT_SLIDE_AFTER_MS as te, SHOW_LABEL_HIGHLIGHT_AFTER_MS as re, SHOW_NUDGE_AFTER_MS as ne } from "./constants.js";
12
+ import { ProjectType as ie } from "../../games/web-view/enums/project-type-enum.js";
13
+ const Te = ({
14
+ onSegmentClick: L,
15
15
  setCarouselIndex: H,
16
- onJourneyComplete: w
16
+ onJourneyComplete: A
17
17
  }) => {
18
- const a = g(null), o = g(null), t = g(null), s = g(null), b = g(!1), { playButtonSound: y } = ee(), { nextCoachmark: l, setJourney: O } = z(), h = A(
19
- (i, c, n, m = !1) => {
20
- m || (y(), H((T) => T + 1), l(n, !1, re));
18
+ const c = u(null), i = u(null), t = u(null), a = u(null), E = u(!1), { playButtonSound: O } = z(), { nextCoachmark: o, setJourney: y } = j(), h = b(
19
+ (n, l, r, m = !1) => {
20
+ m || (O(), H((T) => T + 1), o(r, !1, te));
21
21
  const f = setTimeout(() => {
22
- clearTimeout(f), i.startLabelAnimation(c);
23
- }, ne), p = setTimeout(() => {
24
- clearTimeout(p), l(n, !0);
25
- }, ie);
22
+ clearTimeout(f), n.startLabelAnimation(l);
23
+ }, re), p = setTimeout(() => {
24
+ clearTimeout(p), o(r, !0);
25
+ }, ne);
26
26
  },
27
- [l, y, H]
28
- ), P = A(
29
- (i, c) => {
30
- C(i, oe.PUZZLE), l(c), w(c);
27
+ [o, O, H]
28
+ ), P = b(
29
+ (n, l) => {
30
+ L(n, ie.PUZZLE), o(l), A(l);
31
31
  },
32
- [l, w, C]
33
- ), _ = A(
34
- (i, c, n) => {
35
- var $, G, v, S, B, x, N, I, U, W, X, M, Y, D, F, J, V;
36
- if (b.current || !(($ = a == null ? void 0 : a.current) != null && $.nextBtnRef.current) || !((G = t == null ? void 0 : t.current) != null && G.segmentedCardWrapperRef.current) || !((v = o == null ? void 0 : o.current) != null && v.labelRef.current) || !((S = t == null ? void 0 : t.current) != null && S.labelRef.current) || !i)
32
+ [o, A, L]
33
+ ), _ = b(
34
+ (n, l, r) => {
35
+ var k, v, G, S, B, N, x, I, U, $, W, X, Y, D, F, J, M;
36
+ if (E.current || !((k = c == null ? void 0 : c.current) != null && k.nextBtnRef.current) || !((v = t == null ? void 0 : t.current) != null && v.segmentedCardWrapperRef.current) || !((G = i == null ? void 0 : i.current) != null && G.labelRef.current) || !((S = t == null ? void 0 : t.current) != null && S.labelRef.current) || !n)
37
37
  return;
38
- b.current = !0;
39
- const m = ((N = (x = (B = s.current) == null ? void 0 : B.labelRef) == null ? void 0 : x.current) == null ? void 0 : N.getBoundingClientRect()) || {
38
+ E.current = !0;
39
+ const m = ((x = (N = (B = a.current) == null ? void 0 : B.labelRef) == null ? void 0 : N.current) == null ? void 0 : x.getBoundingClientRect()) || {
40
40
  height: 0,
41
41
  width: 0
42
- }, f = ((W = (U = (I = o.current) == null ? void 0 : I.labelRef) == null ? void 0 : U.current) == null ? void 0 : W.getBoundingClientRect()) || {
42
+ }, f = (($ = (U = (I = i.current) == null ? void 0 : I.labelRef) == null ? void 0 : U.current) == null ? void 0 : $.getBoundingClientRect()) || {
43
43
  height: 0,
44
44
  width: 0
45
- }, p = ((Y = (M = (X = t.current) == null ? void 0 : X.labelRef) == null ? void 0 : M.current) == null ? void 0 : Y.getBoundingClientRect()) || {
45
+ }, p = ((Y = (X = (W = t.current) == null ? void 0 : W.labelRef) == null ? void 0 : X.current) == null ? void 0 : Y.getBoundingClientRect()) || {
46
46
  height: 0,
47
47
  width: 0
48
48
  }, T = ((J = (F = (D = t.current) == null ? void 0 : D.segmentedCardWrapperRef) == null ? void 0 : F.current) == null ? void 0 : J.getBoundingClientRect()) || {
49
49
  height: 0,
50
50
  width: 0
51
51
  };
52
- let k = [];
53
- c && s.current && (k = [
52
+ let w = [];
53
+ l && a.current && (w = [
54
54
  {
55
- originalElementToHighlightRef: s.current.labelRef,
55
+ originalElementToHighlightRef: a.current.labelRef,
56
56
  isActive: !1,
57
- type: d.TOOLTIP,
58
- elementToHighlight: /* @__PURE__ */ e(E, {}),
57
+ type: s.TOOLTIP,
58
+ elementToHighlight: /* @__PURE__ */ e(R, {}),
59
59
  indicator: {
60
60
  position: "right",
61
61
  backgroundColor: "BLUE_4",
62
- width: 244,
63
- tooltipItem: /* @__PURE__ */ R(L, { children: [
64
- /* @__PURE__ */ e(r, { $renderAs: "ab2-bold", children: "Practice Mental Math" }),
65
- /* @__PURE__ */ e(r, { $renderAs: "ub3", children: "Get faster & stay ahead in school," }),
66
- /* @__PURE__ */ e(r, { $renderAs: "ub3", children: "with 3 new skills everyday." })
67
- ] }),
62
+ width: 264,
63
+ tooltipItem: /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Get faster & stay ahead in school. Practice 3 new skills everyday." }) }),
68
64
  tooltipXCoOrdinates: m.width,
69
65
  tooltipYCoOrdinates: m.height / 2
70
66
  }
71
67
  },
72
68
  {
73
- originalElementToHighlightRef: (V = a.current) == null ? void 0 : V.nextBtnRef,
69
+ originalElementToHighlightRef: (M = c.current) == null ? void 0 : M.nextBtnRef,
74
70
  isActive: !1,
75
- type: d.NUDGE,
71
+ type: s.NUDGE,
76
72
  elementToHighlight: /* @__PURE__ */ e(
77
- q,
73
+ Z,
78
74
  {
79
75
  renderAs: "secondary",
80
- Icon: Z,
81
- onClick: () => h(o.current, "ORANGE_4", n),
76
+ Icon: V,
77
+ onClick: () => h(i.current, "ORANGE_4", r),
82
78
  analyticsLabel: "HELLO "
83
79
  }
84
80
  ),
85
81
  indicator: {
86
82
  nudge: "click",
87
- content: /* @__PURE__ */ e(r, { $renderAs: "ab1", $color: "WHITE", children: "Click to proceed" }),
83
+ content: /* @__PURE__ */ e(d, { $renderAs: "ab1", $color: "WHITE", children: "Click to proceed" }),
88
84
  nudgePointerX: 0,
89
85
  nudgePointerY: 0
90
86
  }
91
87
  }
92
88
  ]);
93
- const K = [
89
+ const q = [
94
90
  {
95
- originalElementToHighlightRef: o.current.labelRef,
91
+ originalElementToHighlightRef: i.current.labelRef,
96
92
  isActive: !1,
97
- type: d.TOOLTIP,
98
- elementToHighlight: /* @__PURE__ */ e(E, {}),
93
+ type: s.TOOLTIP,
94
+ elementToHighlight: /* @__PURE__ */ e(R, {}),
99
95
  indicator: {
100
96
  position: "right",
101
97
  backgroundColor: "ORANGE_4",
102
- width: 244,
103
- tooltipItem: /* @__PURE__ */ R(L, { children: [
104
- /* @__PURE__ */ e(r, { $renderAs: "ab2-bold", children: "Play Strategy Games" }),
105
- /* @__PURE__ */ e(r, { $renderAs: "ub3", children: "Train to think deeper & plan ahead," }),
106
- /* @__PURE__ */ e(r, { $renderAs: "ub3", children: "with 3 new games everyday." })
107
- ] }),
98
+ width: 264,
99
+ tooltipItem: /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Train to think deeper & plan ahead. Play 3 new games everyday." }) }),
108
100
  tooltipXCoOrdinates: f.width,
109
101
  tooltipYCoOrdinates: f.height / 2
110
102
  }
111
103
  },
112
104
  {
113
- originalElementToHighlightRef: a.current.nextBtnRef,
105
+ originalElementToHighlightRef: c.current.nextBtnRef,
114
106
  isActive: !1,
115
- type: d.NUDGE,
107
+ type: s.NUDGE,
116
108
  elementToHighlight: /* @__PURE__ */ e(
117
- q,
109
+ Z,
118
110
  {
119
111
  renderAs: "secondary",
120
- Icon: Z,
121
- onClick: () => h(t.current, "PURPLE_4", n),
112
+ Icon: V,
113
+ onClick: () => h(t.current, "PURPLE_4", r),
122
114
  analyticsLabel: "HELLO "
123
115
  }
124
116
  ),
125
117
  indicator: {
126
118
  nudge: "click",
127
- content: /* @__PURE__ */ e(r, { $renderAs: "ab1", $color: "WHITE", children: "Click to proceed" }),
119
+ content: /* @__PURE__ */ e(d, { $renderAs: "ab1", $color: "WHITE", children: "Click to proceed" }),
128
120
  nudgePointerX: 0,
129
121
  nudgePointerY: 0
130
122
  }
131
123
  }
132
- ], Q = [
124
+ ], K = [
133
125
  {
134
126
  originalElementToHighlightRef: t.current.labelRef,
135
127
  isActive: !1,
136
- type: d.TOOLTIP,
137
- elementToHighlight: /* @__PURE__ */ e(E, {}),
128
+ type: s.TOOLTIP,
129
+ elementToHighlight: /* @__PURE__ */ e(R, {}),
138
130
  indicator: {
139
131
  position: "right",
140
132
  backgroundColor: "PURPLE_4",
141
- width: 244,
142
- tooltipItem: /* @__PURE__ */ R(L, { children: [
143
- /* @__PURE__ */ e(r, { $renderAs: "ab2-bold", children: "Solve Logic Puzzles" }),
144
- /* @__PURE__ */ e(r, { $renderAs: "ub3", children: "Think in new ways & stay sharp," }),
145
- /* @__PURE__ */ e(r, { $renderAs: "ub3", children: "with 3 new puzzles everyday." })
146
- ] }),
133
+ width: 264,
134
+ tooltipItem: /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Think in new ways & stay sharp. Solve 3 new puzzles everyday." }) }),
147
135
  tooltipXCoOrdinates: p.width,
148
136
  tooltipYCoOrdinates: p.height / 2
149
137
  }
@@ -151,48 +139,48 @@ const be = ({
151
139
  {
152
140
  originalElementToHighlightRef: t.current.segmentedCardWrapperRef,
153
141
  isActive: !1,
154
- type: d.NUDGE,
142
+ type: s.NUDGE,
155
143
  elementToHighlight: /* @__PURE__ */ e(
156
- te,
144
+ ee,
157
145
  {
158
146
  label: "",
159
- value: i.data.filter((u) => u.solved).length,
160
- maxValue: i.data.length,
161
- initialValue: i.initialProgressValue,
162
- data: i.data.map((u) => ({
163
- card: u.cardLottie,
147
+ value: n.data.filter((g) => g.solved).length,
148
+ maxValue: n.data.length,
149
+ initialValue: n.initialProgressValue,
150
+ data: n.data.map((g) => ({
151
+ card: g.cardLottie,
164
152
  name: "",
165
153
  // We dont want to show the name of the puzzle in onboarding
166
- isCompleted: u.solved,
167
- onPress: () => P(u, n)
154
+ isCompleted: g.solved,
155
+ onPress: () => P(g, r)
168
156
  }))
169
157
  }
170
158
  ),
171
159
  indicator: {
172
160
  nudge: "click",
173
- content: /* @__PURE__ */ e(r, { $renderAs: "ab1", $color: "WHITE", children: "Click to solve a puzzle" }),
161
+ content: /* @__PURE__ */ e(d, { $renderAs: "ab1", $color: "WHITE", children: "Click to solve a puzzle" }),
174
162
  nudgePointerX: T.width * 0.6,
175
163
  nudgePointerY: T.height * 0.4
176
164
  }
177
165
  }
178
166
  ];
179
- O(n, [...k, ...K, ...Q]), l(n, !0), c && s.current ? h(s.current, "BLUE_4", n, !0) : h(o.current, "ORANGE_4", n, !0);
167
+ y(r, [...w, ...q, ...K]), o(r, !0), l && a.current ? h(a.current, "BLUE_4", r, !0) : h(i.current, "ORANGE_4", r, !0);
180
168
  },
181
- [P, h, l, O]
169
+ [P, h, o, y]
182
170
  );
183
- return j(
171
+ return Q(
184
172
  () => ({
185
- gameRefs: o,
173
+ gameRefs: i,
186
174
  puzzleRefs: t,
187
- lessonRefs: s,
188
- carouselNextBtnRef: a,
189
- isJourneyInProgress: b,
175
+ lessonRefs: a,
176
+ carouselNextBtnRef: c,
177
+ isJourneyInProgress: E,
190
178
  startJourney: _
191
179
  }),
192
180
  [_]
193
181
  );
194
182
  };
195
183
  export {
196
- be as useGameLauncherJourney
184
+ Te as useGameLauncherJourney
197
185
  };
198
186
  //# sourceMappingURL=use-game-launcher-journey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-game-launcher-journey.js","sources":["../../../../../src/features/circle-games/game-launcher/use-game-launcher-journey/use-game-launcher-journey.tsx"],"sourcesContent":["import type { TJourneyId } from '../../../journey/journey-id/journey-id-types';\nimport type { ICoachmarkProps } from '../../../journey/use-journey/journey-context-types';\nimport type { IArrowTooltipProps } from '../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport type { INudgeProps } from '../../../ui/nudge/nudge-types';\nimport type { TColorNames } from '../../../ui/types';\nimport type { ICarouselRefs } from '../comps/carousel/carousel-types';\nimport type { ISegmentedGameCardRefs } from '../comps/segmented-game-card/segmented-game-card-types';\nimport type {\n IProject,\n Puzzle,\n} from '../dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IUseGameLauncherJourneyProps } from './use-game-launcher-journey-types';\n\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport NextIcon from '../../../../assets/line-icons/icons/next';\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 FlexView from '../../../ui/layout/flex-view';\nimport Text from '../../../ui/text/text';\nimport { ProjectType } from '../../games/web-view/enums';\nimport { useCircleSounds } from '../../hooks/use-circle-sounds/use-circle-sounds';\nimport { SegmentedGameCard } from '../comps/segmented-game-card/segmented-game-card';\nimport {\n GO_TO_NEXT_SLIDE_AFTER_MS,\n SHOW_LABEL_HIGHLIGHT_AFTER_MS,\n SHOW_NUDGE_AFTER_MS,\n} from './constants';\n\nexport const useGameLauncherJourney = ({\n onSegmentClick,\n setCarouselIndex,\n onJourneyComplete,\n}: IUseGameLauncherJourneyProps) => {\n const carouselNextBtnRef = useRef<ICarouselRefs>(null);\n const gameRefs = useRef<ISegmentedGameCardRefs>(null);\n const puzzleRefs = useRef<ISegmentedGameCardRefs>(null);\n const lessonRefs = useRef<ISegmentedGameCardRefs>(null);\n\n const isJourneyInProgress = useRef(false);\n\n const { playButtonSound } = useCircleSounds();\n const { nextCoachmark, setJourney } = useJourney();\n\n const goToNextCard = useCallback(\n (\n refOfNextSlide: ISegmentedGameCardRefs,\n color: TColorNames,\n journeyId: TJourneyId,\n isFirstSlide: boolean = false,\n ) => {\n if (!isFirstSlide) {\n playButtonSound();\n setCarouselIndex((prev: number) => prev + 1);\n nextCoachmark(journeyId, false, GO_TO_NEXT_SLIDE_AFTER_MS);\n }\n\n const animateLabelTimer = setTimeout(() => {\n clearTimeout(animateLabelTimer);\n refOfNextSlide.startLabelAnimation(color);\n }, SHOW_LABEL_HIGHLIGHT_AFTER_MS);\n\n const showNudgeTimer = setTimeout(() => {\n clearTimeout(showNudgeTimer);\n nextCoachmark(journeyId, true);\n }, SHOW_NUDGE_AFTER_MS);\n },\n [nextCoachmark, playButtonSound, setCarouselIndex],\n );\n\n const endJourney = useCallback(\n (puzzlesData: Puzzle, journeyId: TJourneyId) => {\n onSegmentClick(puzzlesData, ProjectType.PUZZLE);\n nextCoachmark(journeyId);\n onJourneyComplete(journeyId);\n },\n [nextCoachmark, onJourneyComplete, onSegmentClick],\n );\n\n const startJourney = useCallback(\n (puzzlesData: IProject<Puzzle>, isLessonAvailable: boolean, journeyId: TJourneyId) => {\n if (isJourneyInProgress.current) {\n return;\n }\n\n // If element refs are not available return, this is just for type safety\n if (\n !carouselNextBtnRef?.current?.nextBtnRef.current ||\n !puzzleRefs?.current?.segmentedCardWrapperRef.current ||\n !gameRefs?.current?.labelRef.current ||\n !puzzleRefs?.current?.labelRef.current ||\n !puzzlesData\n ) {\n return;\n }\n\n isJourneyInProgress.current = true;\n const lessonLabelDims = lessonRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const gameLabelDims = gameRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const puzzleLabelDims = puzzleRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n const launcherDims =\n puzzleRefs.current?.segmentedCardWrapperRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n let lessonSteps: ICoachmarkProps[] = [];\n\n if (isLessonAvailable && lessonRefs.current) {\n lessonSteps = [\n {\n originalElementToHighlightRef: lessonRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'BLUE_4',\n width: 244,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">Practice Mental Math</Text>\n <Text $renderAs=\"ub3\">Get faster & stay ahead in school,</Text>\n <Text $renderAs=\"ub3\">with 3 new skills everyday.</Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: lessonLabelDims.width,\n tooltipYCoOrdinates: lessonLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current?.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(gameRefs.current as ISegmentedGameCardRefs, 'ORANGE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\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 },\n ];\n }\n\n const gameSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: gameRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'ORANGE_4',\n width: 244,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">Play Strategy Games</Text>\n <Text $renderAs=\"ub3\">Train to think deeper & plan ahead,</Text>\n <Text $renderAs=\"ub3\">with 3 new games everyday.</Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: gameLabelDims.width,\n tooltipYCoOrdinates: gameLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(puzzleRefs.current as ISegmentedGameCardRefs, 'PURPLE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\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 },\n ];\n\n const puzzleSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: puzzleRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'PURPLE_4',\n width: 244,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">Solve Logic Puzzles</Text>\n <Text $renderAs=\"ub3\">Think in new ways & stay sharp,</Text>\n <Text $renderAs=\"ub3\">with 3 new puzzles everyday.</Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: puzzleLabelDims.width,\n tooltipYCoOrdinates: puzzleLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: puzzleRefs.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <SegmentedGameCard\n label={''} // This is intentionally left blank to avoid showing the label\n value={puzzlesData.data.filter(puzzle => puzzle.solved).length}\n maxValue={puzzlesData.data.length}\n initialValue={puzzlesData.initialProgressValue}\n data={puzzlesData.data.map(puzzle => ({\n card: puzzle.cardLottie,\n name: '', // We dont want to show the name of the puzzle in onboarding\n isCompleted: puzzle.solved,\n onPress: () => endJourney(puzzle, journeyId),\n }))}\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to solve a puzzle\n </Text>\n ),\n nudgePointerX: launcherDims.width * 0.6,\n nudgePointerY: launcherDims.height * 0.4,\n } as INudgeProps,\n },\n ];\n\n setJourney(journeyId, [...lessonSteps, ...gameSteps, ...puzzleSteps]);\n\n nextCoachmark(journeyId, true);\n if (isLessonAvailable && lessonRefs.current) {\n goToNextCard(lessonRefs.current, 'BLUE_4', journeyId, true);\n } else {\n goToNextCard(gameRefs.current, 'ORANGE_4', journeyId, true);\n }\n },\n [endJourney, goToNextCard, nextCoachmark, setJourney],\n );\n\n return useMemo(\n () => ({\n gameRefs,\n puzzleRefs,\n lessonRefs,\n carouselNextBtnRef,\n isJourneyInProgress,\n startJourney,\n }),\n [startJourney],\n );\n};\n"],"names":["useGameLauncherJourney","onSegmentClick","setCarouselIndex","onJourneyComplete","carouselNextBtnRef","useRef","gameRefs","puzzleRefs","lessonRefs","isJourneyInProgress","playButtonSound","useCircleSounds","nextCoachmark","setJourney","useJourney","goToNextCard","useCallback","refOfNextSlide","color","journeyId","isFirstSlide","prev","GO_TO_NEXT_SLIDE_AFTER_MS","animateLabelTimer","SHOW_LABEL_HIGHLIGHT_AFTER_MS","showNudgeTimer","SHOW_NUDGE_AFTER_MS","endJourney","puzzlesData","ProjectType","startJourney","isLessonAvailable","_a","_b","_c","_d","lessonLabelDims","_g","_f","_e","gameLabelDims","_j","_i","_h","puzzleLabelDims","_m","_l","_k","launcherDims","_p","_o","_n","lessonSteps","IndicatorType","jsx","Fragment","FlexView","Text","_q","IconButton","NextIcon","gameSteps","puzzleSteps","SegmentedGameCard","puzzle","useMemo"],"mappings":";;;;;;;;;;;;AA8BO,MAAMA,KAAyB,CAAC;AAAA,EACrC,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AACF,MAAoC;AAC5B,QAAAC,IAAqBC,EAAsB,IAAI,GAC/CC,IAAWD,EAA+B,IAAI,GAC9CE,IAAaF,EAA+B,IAAI,GAChDG,IAAaH,EAA+B,IAAI,GAEhDI,IAAsBJ,EAAO,EAAK,GAElC,EAAE,iBAAAK,MAAoBC,MACtB,EAAE,eAAAC,GAAe,YAAAC,EAAW,IAAIC,EAAW,GAE3CC,IAAeC;AAAA,IACnB,CACEC,GACAC,GACAC,GACAC,IAAwB,OACrB;AACH,MAAKA,MACaV,KACCR,EAAA,CAACmB,MAAiBA,IAAO,CAAC,GAC7BT,EAAAO,GAAW,IAAOG,EAAyB;AAGrD,YAAAC,IAAoB,WAAW,MAAM;AACzC,qBAAaA,CAAiB,GAC9BN,EAAe,oBAAoBC,CAAK;AAAA,SACvCM,EAA6B,GAE1BC,IAAiB,WAAW,MAAM;AACtC,qBAAaA,CAAc,GAC3Bb,EAAcO,GAAW,EAAI;AAAA,SAC5BO,EAAmB;AAAA,IACxB;AAAA,IACA,CAACd,GAAeF,GAAiBR,CAAgB;AAAA,EAAA,GAG7CyB,IAAaX;AAAA,I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AAW,EAAI;AAAA,IAE9D;AAAA,IACA,CAACQ,GAAYZ,GAAcH,GAAeC,CAAU;AAAA,EAAA;AAG/C,SAAAoD;AAAA,IACL,OAAO;AAAA,MACL,UAAA3D;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,MACA,oBAAAJ;AAAA,MACA,qBAAAK;AAAA,MACA,cAAAqB;AAAA,IAAA;AAAA,IAEF,CAACA,CAAY;AAAA,EAAA;AAEjB;"}
1
+ {"version":3,"file":"use-game-launcher-journey.js","sources":["../../../../../src/features/circle-games/game-launcher/use-game-launcher-journey/use-game-launcher-journey.tsx"],"sourcesContent":["import type { TJourneyId } from '../../../journey/journey-id/journey-id-types';\nimport type { ICoachmarkProps } from '../../../journey/use-journey/journey-context-types';\nimport type { IArrowTooltipProps } from '../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport type { INudgeProps } from '../../../ui/nudge/nudge-types';\nimport type { TColorNames } from '../../../ui/types';\nimport type { ICarouselRefs } from '../comps/carousel/carousel-types';\nimport type { ISegmentedGameCardRefs } from '../comps/segmented-game-card/segmented-game-card-types';\nimport type {\n IProject,\n Puzzle,\n} from '../dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IUseGameLauncherJourneyProps } from './use-game-launcher-journey-types';\n\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport NextIcon from '../../../../assets/line-icons/icons/next';\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 FlexView from '../../../ui/layout/flex-view';\nimport Text from '../../../ui/text/text';\nimport { ProjectType } from '../../games/web-view/enums';\nimport { useCircleSounds } from '../../hooks/use-circle-sounds/use-circle-sounds';\nimport { SegmentedGameCard } from '../comps/segmented-game-card/segmented-game-card';\nimport {\n GO_TO_NEXT_SLIDE_AFTER_MS,\n SHOW_LABEL_HIGHLIGHT_AFTER_MS,\n SHOW_NUDGE_AFTER_MS,\n} from './constants';\n\nexport const useGameLauncherJourney = ({\n onSegmentClick,\n setCarouselIndex,\n onJourneyComplete,\n}: IUseGameLauncherJourneyProps) => {\n const carouselNextBtnRef = useRef<ICarouselRefs>(null);\n const gameRefs = useRef<ISegmentedGameCardRefs>(null);\n const puzzleRefs = useRef<ISegmentedGameCardRefs>(null);\n const lessonRefs = useRef<ISegmentedGameCardRefs>(null);\n\n const isJourneyInProgress = useRef(false);\n\n const { playButtonSound } = useCircleSounds();\n const { nextCoachmark, setJourney } = useJourney();\n\n const goToNextCard = useCallback(\n (\n refOfNextSlide: ISegmentedGameCardRefs,\n color: TColorNames,\n journeyId: TJourneyId,\n isFirstSlide: boolean = false,\n ) => {\n if (!isFirstSlide) {\n playButtonSound();\n setCarouselIndex((prev: number) => prev + 1);\n nextCoachmark(journeyId, false, GO_TO_NEXT_SLIDE_AFTER_MS);\n }\n\n const animateLabelTimer = setTimeout(() => {\n clearTimeout(animateLabelTimer);\n refOfNextSlide.startLabelAnimation(color);\n }, SHOW_LABEL_HIGHLIGHT_AFTER_MS);\n\n const showNudgeTimer = setTimeout(() => {\n clearTimeout(showNudgeTimer);\n nextCoachmark(journeyId, true);\n }, SHOW_NUDGE_AFTER_MS);\n },\n [nextCoachmark, playButtonSound, setCarouselIndex],\n );\n\n const endJourney = useCallback(\n (puzzlesData: Puzzle, journeyId: TJourneyId) => {\n onSegmentClick(puzzlesData, ProjectType.PUZZLE);\n nextCoachmark(journeyId);\n onJourneyComplete(journeyId);\n },\n [nextCoachmark, onJourneyComplete, onSegmentClick],\n );\n\n const startJourney = useCallback(\n (puzzlesData: IProject<Puzzle>, isLessonAvailable: boolean, journeyId: TJourneyId) => {\n if (isJourneyInProgress.current) {\n return;\n }\n\n // If element refs are not available return, this is just for type safety\n if (\n !carouselNextBtnRef?.current?.nextBtnRef.current ||\n !puzzleRefs?.current?.segmentedCardWrapperRef.current ||\n !gameRefs?.current?.labelRef.current ||\n !puzzleRefs?.current?.labelRef.current ||\n !puzzlesData\n ) {\n return;\n }\n\n isJourneyInProgress.current = true;\n const lessonLabelDims = lessonRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const gameLabelDims = gameRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const puzzleLabelDims = puzzleRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n const launcherDims =\n puzzleRefs.current?.segmentedCardWrapperRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n let lessonSteps: ICoachmarkProps[] = [];\n\n if (isLessonAvailable && lessonRefs.current) {\n lessonSteps = [\n {\n originalElementToHighlightRef: lessonRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'BLUE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Get faster & stay ahead in school. Practice 3 new skills everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: lessonLabelDims.width,\n tooltipYCoOrdinates: lessonLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current?.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(gameRefs.current as ISegmentedGameCardRefs, 'ORANGE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\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 },\n ];\n }\n\n const gameSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: gameRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'ORANGE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Train to think deeper & plan ahead. Play 3 new games everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: gameLabelDims.width,\n tooltipYCoOrdinates: gameLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(puzzleRefs.current as ISegmentedGameCardRefs, 'PURPLE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\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 },\n ];\n\n const puzzleSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: puzzleRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'PURPLE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Think in new ways & stay sharp. Solve 3 new puzzles everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: puzzleLabelDims.width,\n tooltipYCoOrdinates: puzzleLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: puzzleRefs.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <SegmentedGameCard\n label={''} // This is intentionally left blank to avoid showing the label\n value={puzzlesData.data.filter(puzzle => puzzle.solved).length}\n maxValue={puzzlesData.data.length}\n initialValue={puzzlesData.initialProgressValue}\n data={puzzlesData.data.map(puzzle => ({\n card: puzzle.cardLottie,\n name: '', // We dont want to show the name of the puzzle in onboarding\n isCompleted: puzzle.solved,\n onPress: () => endJourney(puzzle, journeyId),\n }))}\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to solve a puzzle\n </Text>\n ),\n nudgePointerX: launcherDims.width * 0.6,\n nudgePointerY: launcherDims.height * 0.4,\n } as INudgeProps,\n },\n ];\n\n setJourney(journeyId, [...lessonSteps, ...gameSteps, ...puzzleSteps]);\n\n nextCoachmark(journeyId, true);\n if (isLessonAvailable && lessonRefs.current) {\n goToNextCard(lessonRefs.current, 'BLUE_4', journeyId, true);\n } else {\n goToNextCard(gameRefs.current, 'ORANGE_4', journeyId, true);\n }\n },\n [endJourney, goToNextCard, nextCoachmark, setJourney],\n );\n\n return useMemo(\n () => ({\n gameRefs,\n puzzleRefs,\n lessonRefs,\n carouselNextBtnRef,\n isJourneyInProgress,\n startJourney,\n }),\n [startJourney],\n );\n};\n"],"names":["useGameLauncherJourney","onSegmentClick","setCarouselIndex","onJourneyComplete","carouselNextBtnRef","useRef","gameRefs","puzzleRefs","lessonRefs","isJourneyInProgress","playButtonSound","useCircleSounds","nextCoachmark","setJourney","useJourney","goToNextCard","useCallback","refOfNextSlide","color","journeyId","isFirstSlide","prev","GO_TO_NEXT_SLIDE_AFTER_MS","animateLabelTimer","SHOW_LABEL_HIGHLIGHT_AFTER_MS","showNudgeTimer","SHOW_NUDGE_AFTER_MS","endJourney","puzzlesData","ProjectType","startJourney","isLessonAvailable","_a","_b","_c","_d","lessonLabelDims","_g","_f","_e","gameLabelDims","_j","_i","_h","puzzleLabelDims","_m","_l","_k","launcherDims","_p","_o","_n","lessonSteps","IndicatorType","jsx","Fragment","FlexView","Text","_q","IconButton","NextIcon","gameSteps","puzzleSteps","SegmentedGameCard","puzzle","useMemo"],"mappings":";;;;;;;;;;;;AA8BO,MAAMA,KAAyB,CAAC;AAAA,EACrC,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,m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AnC,EAAAM,GAAW,CAAC,GAAGiC,GAAa,GAAGS,GAAW,GAAGC,CAAW,CAAC,GAEpElD,EAAcO,GAAW,EAAI,GACzBY,KAAqBvB,EAAW,UAClCO,EAAaP,EAAW,SAAS,UAAUW,GAAW,EAAI,IAE1DJ,EAAaT,EAAS,SAAS,YAAYa,GAAW,EAAI;AAAA,IAE9D;AAAA,IACA,CAACQ,GAAYZ,GAAcH,GAAeC,CAAU;AAAA,EAAA;AAG/C,SAAAoD;AAAA,IACL,OAAO;AAAA,MACL,UAAA3D;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,MACA,oBAAAJ;AAAA,MACA,qBAAAK;AAAA,MACA,cAAAqB;AAAA,IAAA;AAAA,IAEF,CAACA,CAAY;AAAA,EAAA;AAEjB;"}
@@ -1,59 +1,62 @@
1
- import { jsxs as w, jsx as d } from "react/jsx-runtime";
2
- import { createContext as x, useState as v, useRef as J, useCallback as m, useMemo as $ } from "react";
3
- import { Coachmark as p } from "../comps/coachmark/coachmark.js";
4
- import { BlurOverlay as g } from "./journey-styled.js";
5
- const A = x(null), N = ({ children: f }) => {
6
- const [o, c] = v([]), a = J(-1), r = J(), l = m(
1
+ import { jsxs as v, jsx as J } from "react/jsx-runtime";
2
+ import { createContext as x, useState as $, useRef as f, useCallback as i, useMemo as p } from "react";
3
+ import { Coachmark as g } from "../comps/coachmark/coachmark.js";
4
+ import { BlurOverlay as A } from "./journey-styled.js";
5
+ const R = x(null), j = ({ children: C }) => {
6
+ const [o, u] = $([]), c = f(-1), r = f(), l = i(
7
7
  (e, t) => {
8
8
  if (o.length > 0)
9
9
  throw new Error(
10
10
  `setJourney: Other Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
11
11
  );
12
- r.current = e, a.current = -1, c([...t]);
12
+ r.current = e, c.current = -1, u([...t]);
13
13
  },
14
14
  [o.length]
15
- ), h = m((e, t) => {
15
+ ), h = i(() => {
16
+ r.current = void 0, c.current = -1, u([]);
17
+ }, []), y = i((e, t) => {
16
18
  if (!r.current || e !== r.current)
17
19
  throw new Error(
18
20
  r.current ? "addCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
19
21
  );
20
- c((s) => [...s, t]);
21
- }, []), y = m(
22
+ u((s) => [...s, t]);
23
+ }, []), d = i(
22
24
  (e, t = !1, s = 0) => {
23
25
  if (!r.current || e !== r.current)
24
26
  throw new Error(
25
27
  r.current ? "nextCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
26
28
  );
27
- s !== 0 && c((n) => n.map((u) => ({ ...u, isActive: !1 })));
28
- const k = setTimeout(() => {
29
- clearTimeout(k);
30
- const n = a.current + 1;
31
- c((u) => {
32
- if (n >= u.length || u.length === 0)
33
- return r.current = void 0, a.current = -1, [];
34
- a.current = n;
35
- const i = [...u];
36
- return i[n].isActive = !0, n > 0 && (i[n - 1].isActive = t), i;
29
+ s !== 0 && u((n) => n.map((a) => ({ ...a, isActive: !1 })));
30
+ const w = setTimeout(() => {
31
+ clearTimeout(w);
32
+ const n = c.current + 1;
33
+ u((a) => {
34
+ if (n >= a.length || a.length === 0)
35
+ return r.current = void 0, c.current = -1, [];
36
+ c.current = n;
37
+ const m = [...a];
38
+ return m[n].isActive = !0, n > 0 && (m[n - 1].isActive = t), m;
37
39
  });
38
40
  }, s);
39
41
  },
40
42
  []
41
- ), C = $(
43
+ ), k = p(
42
44
  () => ({
43
- nextCoachmark: y,
45
+ nextCoachmark: d,
44
46
  setJourney: l,
45
- addCoachmark: h,
47
+ addCoachmark: y,
48
+ clearJourney: h,
46
49
  coachmarks: o
47
50
  }),
48
- [y, l, h, o]
51
+ [d, l, y, h, o]
49
52
  );
50
- return /* @__PURE__ */ w(A.Provider, { value: C, children: [
51
- o.length > 0 && /* @__PURE__ */ d(g, { children: o.map((e, t) => /* @__PURE__ */ d(p, { coachmark: e }, `coachmark-${t}`)) }),
52
- f
53
+ return /* @__PURE__ */ v(R.Provider, { value: k, children: [
54
+ o.length > 0 && /* @__PURE__ */ J(A, { children: o.map((e, t) => /* @__PURE__ */ J(g, { coachmark: e }, `coachmark-${t}`)) }),
55
+ C
53
56
  ] });
54
57
  };
55
58
  export {
56
- A as JourneyContext,
57
- N as JourneyProvider
59
+ R as JourneyContext,
60
+ j as JourneyProvider
58
61
  };
59
62
  //# sourceMappingURL=journey-context-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["import type { TJourneyId } from '../journey-id/journey-id-types';\nimport type { ICoachmarkProps, IJourneyContext } from './journey-context-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { createContext, useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<{ children: ReactNode }> = ({ children }) => {\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const currentIndex = useRef(-1);\n const currentJourneyIdStudent = useRef<TJourneyId | undefined>();\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n throw new Error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n currentJourneyIdStudent.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `addCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\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 currentJourneyIdStudent.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 [],\n );\n\n const memoizedContextValue = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n coachmarks: coachmarkList,\n }),\n [nextCoachmark, setJourney, addCoachmark, coachmarkList],\n );\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {coachmarkList.length > 0 && (\n <S.BlurOverlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.BlurOverlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","coachmarkList","setCoachmarkList","useState","currentIndex","useRef","currentJourneyIdStudent","setJourney","useCallback","id","coachmarks","addCoachmark","coachmark","prev","nextCoachmark","keepPrevActive","delayInMs","prevList","item","timer","currIndex","updatedCoachmarkList","memoizedContextValue","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;AAEzC,QAAAF,EAAiB,CAAYe,MAAA;AAE3B,cAAIG,KAAaH,EAAS,UAAUA,EAAS,WAAW;AACtD,mBAAAX,EAAwB,UAAU,QAClCF,EAAa,UAAU,IAEhB;AAGT,UAAAA,EAAa,UAAUgB;AACjB,gBAAAC,IAAuB,CAAC,GAAGJ,CAAQ;AAExC,iBAAAI,EAAqBD,CAAS,EAAsB,WAAW,IAE5DA,IAAY,MACbC,EAAqBD,IAAY,CAAC,EAAsB,WAAWL,IAG/DM;AAAA,QAAA,CACR;AAAA,SACAL,CAAS;AAAA,IACd;AAAA,IACA,CAAC;AAAA,EAAA,GAGGM,IAAuBC;AAAA,IAC3B,OAAO;AAAA,MACL,eAAAT;AAAA,MACA,YAAAP;AAAA,MACA,cAAAI;AAAA,MACA,YAAYV;AAAA,IAAA;AAAA,IAEd,CAACa,GAAeP,GAAYI,GAAcV,CAAa;AAAA,EAAA;AAGzD,SACG,gBAAAuB,EAAA3B,EAAe,UAAf,EAAwB,OAAOyB,GAC7B,UAAA;AAAA,IAAArB,EAAc,SAAS,KACtB,gBAAAwB,EAACC,GAAA,EACE,YAAc,IAAI,CAACd,GAAWe,wBAC5BC,GAAqC,EAAA,WAAAhB,EAAA,GAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED3B;AAAA,EACH,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["import type { TJourneyId } from '../journey-id/journey-id-types';\nimport type { ICoachmarkProps, IJourneyContext } from './journey-context-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { createContext, useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<{ children: ReactNode }> = ({ children }) => {\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const currentIndex = useRef(-1);\n const currentJourneyIdStudent = useRef<TJourneyId | undefined>();\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n throw new Error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n currentJourneyIdStudent.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n }, []);\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `addCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\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 currentJourneyIdStudent.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 [],\n );\n\n const memoizedContextValue = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n coachmarks: coachmarkList,\n }),\n [nextCoachmark, setJourney, addCoachmark, clearJourney, coachmarkList],\n );\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {coachmarkList.length > 0 && (\n <S.BlurOverlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.BlurOverlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","coachmarkList","setCoachmarkList","useState","currentIndex","useRef","currentJourneyIdStudent","setJourney","useCallback","id","coachmarks","clearJourney","addCoachmark","coachmark","prev","nextCoachmark","keepPrevActive","delayInMs","prevList","item","timer","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","jsxs","jsx","S.BlurOverlay","index","Coachmark"],"mappings":";;;;AASa,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA+C,CAAC,EAAE,UAAAC,QAAe;AAC5E,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA4B,CAAE,CAAA,GAClEC,IAAeC,EAAO,EAAE,GACxBC,IAA0BD,KAE1BE,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAT,EAAc,SAAS;AACzB,cAAM,IAAI;AAAA,UACR,iEAAiEK,EAAwB,OAAO,0BAA0BG,CAAE;AAAA,QAAA;AAGhI,MAAAH,EAAwB,UAAUG,GAClCL,EAAa,UAAU,IACNF,EAAA,CAAC,GAAGQ,CAAU,CAAC;AAAA,IAClC;AAAA,IACA,CAACT,EAAc,MAAM;AAAA,EAAA,GAGjBU,IAAeH,EAAY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,IAC3B,OAAO;AAAA,MACL,eAAAT;AAAA,MACA,YAAAR;AAAA,MACA,cAAAK;AAAA,MACA,cAAAD;AAAA,MACA,YAAYV;AAAA,IAAA;AAAA,IAEd,CAACc,GAAeR,GAAYK,GAAcD,GAAcV,CAAa;AAAA,EAAA;AAGvE,SACG,gBAAAwB,EAAA5B,EAAe,UAAf,EAAwB,OAAO0B,GAC7B,UAAA;AAAA,IAAAtB,EAAc,SAAS,KACtB,gBAAAyB,EAACC,GAAA,EACE,YAAc,IAAI,CAACd,GAAWe,wBAC5BC,GAAqC,EAAA,WAAAhB,EAAA,GAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED5B;AAAA,EACH,EAAA,CAAA;AAEJ;"}
package/dist/index.d.ts CHANGED
@@ -1279,6 +1279,17 @@ export declare interface IJourneyContext {
1279
1279
  * @param coachmark - The array of coachmarks to be used in this journey.
1280
1280
  */
1281
1281
  setJourney: (id: TJourneyId, coachmark: ICoachmarkProps[]) => void;
1282
+ /**
1283
+ * Clears the current journey, removing all coachmarks.
1284
+ * Should be called inside useEffect to ensure cleanup.
1285
+ * @example
1286
+ * useEffect(() => {
1287
+ * return () => {
1288
+ * clearJourney();
1289
+ * }
1290
+ * }, []);
1291
+ */
1292
+ clearJourney: () => void;
1282
1293
  /**
1283
1294
  * Adds a single coachmark to an existing journey.
1284
1295
  * @param id - The journey identifier.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuemath/leap",
3
- "version": "2.8.21-rj-5",
3
+ "version": "2.8.21-rj-7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"