@cuemath/leap 2.8.57-hg3 → 2.8.57-rj-0
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/constants/api.js +6 -5
- package/dist/constants/api.js.map +1 -1
- package/dist/features/circle-games/game-launcher/comps/segmented-game-card/segmented-game-card.js +75 -62
- package/dist/features/circle-games/game-launcher/comps/segmented-game-card/segmented-game-card.js.map +1 -1
- package/dist/features/circle-games/game-launcher/comps/tables-card/tables-card.js +47 -54
- package/dist/features/circle-games/game-launcher/comps/tables-card/tables-card.js.map +1 -1
- package/dist/features/circle-games/game-launcher/game-launcher.js +66 -76
- package/dist/features/circle-games/game-launcher/game-launcher.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js +18 -19
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js +22 -23
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js.map +1 -1
- package/dist/features/journey/journey-progress-api/journey-progress-api.js +12 -0
- package/dist/features/journey/journey-progress-api/journey-progress-api.js.map +1 -0
- package/dist/features/journey/use-get-eligible-journey.js +11 -0
- package/dist/features/journey/use-get-eligible-journey.js.map +1 -0
- package/dist/features/journey/use-journey/journey-context-provider.js +76 -40
- package/dist/features/journey/use-journey/journey-context-provider.js.map +1 -1
- package/dist/features/ui/lottie-animation/lottie-animation.js +24 -39
- package/dist/features/ui/lottie-animation/lottie-animation.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +147 -145
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as r, Fragment as R } from "react/jsx-runtime";
|
2
|
-
import { useRef as A, useCallback as C, useEffect as
|
3
|
-
import
|
2
|
+
import { useRef as A, useCallback as C, useEffect as V } from "react";
|
3
|
+
import X from "../../../../../assets/line-icons/icons/carat-right.js";
|
4
4
|
import { PLATFORM_EVENTS_STUDENT as G } from "../../../../analytics-events/platform-events-student.js";
|
5
5
|
import { JOURNEY_ID_STUDENT as K } from "../../../../journey/journey-id/journey-id-student.js";
|
6
6
|
import { IndicatorType as d } from "../../../../journey/use-journey/constants.js";
|
@@ -13,22 +13,21 @@ import { CIRCLE_ONBOARDING_ANALYTICS_STEPS as v } from "../../../enum/circle-onb
|
|
13
13
|
import { useCircleSounds as z } from "../../../hooks/use-circle-sounds/use-circle-sounds.js";
|
14
14
|
import { TablesCard as M } from "../../comps/tables-card/tables-card.js";
|
15
15
|
import { GAME_LAUNCHER_ANALYTICS_EVENTS as Q } from "../../game-launcher-analytics-events.js";
|
16
|
-
import { SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS as ee, SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS as te, START_ANIMATING_CLONED_ELEM as $, TABLE_CARD_INDEX as x, GO_TO_TABLE_LAUNCHER_DURATION_MS as re, SHOW_CLICK_TABLE_NUDGE_AFTER_MS as ne, PUZZLE_CARD_INDEX as oe, SHOW_INITIAL_COACHMARK_AFTER_MS as
|
16
|
+
import { SHOW_PICK_A_LEVEL_TOOLTIP_AFTER_MS as ee, SHOW_PICK_A_LEVEL_NUDGE_AFTER_MS as te, START_ANIMATING_CLONED_ELEM as $, TABLE_CARD_INDEX as x, GO_TO_TABLE_LAUNCHER_DURATION_MS as re, SHOW_CLICK_TABLE_NUDGE_AFTER_MS as ne, PUZZLE_CARD_INDEX as oe, SHOW_INITIAL_COACHMARK_AFTER_MS as J, LESSON_CARD_INDEX as ie, SHOW_INITIAL_TOOLTIP_AFTER_MS as le } from "./constants.js";
|
17
17
|
import { Indicator as ce } from "./use-table-launcher-journey-styled.js";
|
18
18
|
const Oe = ({
|
19
19
|
carouselRefs: a,
|
20
|
-
onTableSegmentClick: S
|
21
|
-
onJourneyComplete: P
|
20
|
+
onTableSegmentClick: S
|
22
21
|
}) => {
|
23
|
-
const e = K.CIRCLE_TABLES_INTRO_JOURNEY, t = A(null),
|
22
|
+
const e = K.CIRCLE_TABLES_INTRO_JOURNEY, t = A(null), p = A(null), L = A(!1), T = A([]), { playButtonSound: P } = z(), { nextCoachmark: o, setJourney: I, addCoachmark: u, endJourney: y } = j(), { onEvent: _ } = q(), b = C(
|
24
23
|
(n) => {
|
25
24
|
var c, i;
|
26
|
-
n && S(n),
|
25
|
+
n && S(n), _(G.ONBOARDING_STEP_COMPLETED, {
|
27
26
|
step: v.TABLES
|
28
|
-
}), (c = t == null ? void 0 : t.current) == null || c.setLabelVisiblity(!0), (i = t == null ? void 0 : t.current) == null || i.stopLabelAnimation(),
|
27
|
+
}), (c = t == null ? void 0 : t.current) == null || c.setLabelVisiblity(!0), (i = t == null ? void 0 : t.current) == null || i.stopLabelAnimation(), o(e, !1), y(e);
|
29
28
|
},
|
30
|
-
[e, o,
|
31
|
-
),
|
29
|
+
[y, e, o, S, _]
|
30
|
+
), H = C(
|
32
31
|
(n, c) => {
|
33
32
|
var g, E, h;
|
34
33
|
if (!((g = t.current) != null && g.segmentedCardWrapperRef.current) || !((E = t.current) != null && E.labelRef.current))
|
@@ -41,7 +40,7 @@ const Oe = ({
|
|
41
40
|
elementToHighlight: /* @__PURE__ */ r(
|
42
41
|
M,
|
43
42
|
{
|
44
|
-
ref:
|
43
|
+
ref: p,
|
45
44
|
defaultTable: c,
|
46
45
|
label: n.label,
|
47
46
|
data: n.data,
|
@@ -71,14 +70,14 @@ const Oe = ({
|
|
71
70
|
}), o(e, !1, ee), o(e, !0, te);
|
72
71
|
const s = setTimeout(() => {
|
73
72
|
var f;
|
74
|
-
clearTimeout(s), (f =
|
73
|
+
clearTimeout(s), (f = p.current) == null || f.startLabelAnimation("YELLOW_4");
|
75
74
|
}, $);
|
76
75
|
T.current.push(s);
|
77
76
|
},
|
78
77
|
[u, b, e, o]
|
79
78
|
), O = C(() => {
|
80
79
|
var i;
|
81
|
-
|
80
|
+
P(), (i = a.current) == null || i.goToIndex(x), o(e, !1, re), _(G.ONBOARDING_STEP_VIEWED, {
|
82
81
|
step: v.TABLES
|
83
82
|
});
|
84
83
|
const n = setTimeout(() => {
|
@@ -88,10 +87,10 @@ const Oe = ({
|
|
88
87
|
T.current.push(n);
|
89
88
|
const c = setTimeout(() => {
|
90
89
|
var l;
|
91
|
-
clearTimeout(c), (l =
|
90
|
+
clearTimeout(c), (l = p.current) == null || l.startLabelAnimation("YELLOW_4");
|
92
91
|
}, $);
|
93
92
|
T.current.push(c);
|
94
|
-
}, [a, e, o,
|
93
|
+
}, [a, e, o, P, _]), w = C(
|
95
94
|
(n, c = !1) => {
|
96
95
|
var h, f, D, W, Y, k, B, U;
|
97
96
|
if (L.current)
|
@@ -136,7 +135,7 @@ const Oe = ({
|
|
136
135
|
},
|
137
136
|
elementToHighlight: /* @__PURE__ */ r(R, {})
|
138
137
|
}
|
139
|
-
]), (U = a.current) == null || U.goToIndex(ie), o(e, !1,
|
138
|
+
]), (U = a.current) == null || U.goToIndex(ie), o(e, !1, J), o(e, !0, le)) : (I(e, [
|
140
139
|
{
|
141
140
|
originalElementToHighlightRef: (k = a.current) == null ? void 0 : k.nextBtnRef,
|
142
141
|
isActive: !1,
|
@@ -151,13 +150,13 @@ const Oe = ({
|
|
151
150
|
Z,
|
152
151
|
{
|
153
152
|
renderAs: "secondary",
|
154
|
-
Icon:
|
153
|
+
Icon: X,
|
155
154
|
onClick: O,
|
156
155
|
analyticsLabel: Q.JOURNEY_NEXT_ACTIVITY
|
157
156
|
}
|
158
157
|
)
|
159
158
|
}
|
160
|
-
]), (B = a.current) == null || B.goToIndex(oe), o(e, !1,
|
159
|
+
]), (B = a.current) == null || B.goToIndex(oe), o(e, !1, J)), u(e, {
|
161
160
|
originalElementToHighlightRef: t.current.labelRef,
|
162
161
|
isActive: !1,
|
163
162
|
type: d.TOOLTIP,
|
@@ -183,12 +182,12 @@ const Oe = ({
|
|
183
182
|
elementToHighlight: /* @__PURE__ */ r(
|
184
183
|
M,
|
185
184
|
{
|
186
|
-
ref:
|
185
|
+
ref: p,
|
187
186
|
label: n.label,
|
188
187
|
data: n.data,
|
189
188
|
onPress: () => {
|
190
189
|
},
|
191
|
-
onPressTableSegment: (
|
190
|
+
onPressTableSegment: (F) => H(n, F)
|
192
191
|
}
|
193
192
|
)
|
194
193
|
});
|
@@ -197,17 +196,17 @@ const Oe = ({
|
|
197
196
|
u,
|
198
197
|
a,
|
199
198
|
O,
|
200
|
-
|
199
|
+
H,
|
201
200
|
e,
|
202
201
|
o,
|
203
202
|
I
|
204
203
|
]
|
205
204
|
);
|
206
|
-
return
|
205
|
+
return V(() => () => {
|
207
206
|
T.current.forEach((n) => clearTimeout(n)), T.current = [], L.current = !1;
|
208
207
|
}, [e]), {
|
209
208
|
tableRef: t,
|
210
|
-
startJourney:
|
209
|
+
startJourney: w
|
211
210
|
};
|
212
211
|
};
|
213
212
|
export {
|
@@ -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 onJourneyComplete,\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 } = useJourney();\n const { onEvent: trackAnalytics } = useUIContext();\n\n const endJourney = 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 onJourneyComplete(journeyId);\n nextCoachmark(journeyId, false);\n },\n [journeyId, nextCoachmark, onJourneyComplete, 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={endJourney}\n onGoBackFromTableLevel={endJourney}\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, endJourney, 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","onJourneyComplete","journeyId","JOURNEY_ID_STUDENT","originalTableRef","useRef","highlightedTableRef","isJourneyInProgress","timerRefs","playButtonSound","useCircleSounds","nextCoachmark","setJourney","addCoachmark","useJourney","trackAnalytics","useUIContext","endJourney","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","_d","labelDims","_e","S.Indicator","_h","LESSON_CARD_INDEX","SHOW_INITIAL_COACHMARK_AFTER_MS","SHOW_INITIAL_TOOLTIP_AFTER_MS","_f","IconButton","CaratRightIcon","GAME_LAUNCHER_ANALYTICS_EVENTS","_g","PUZZLE_CARD_INDEX","tableInfo","useEffect","timer"],"mappings":";;;;;;;;;;;;;;;;;AAyCO,MAAMA,KAA0B,CAAC;AAAA,EACtC,cAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,mBAAAC;AACF,MAA6B;AAC3B,QAAMC,IAAYC,EAAmB,6BAC/BC,IAAmBC,EAAsB,IAAI,GAC7CC,IAAsBD,EAAsB,IAAI,GAChDE,IAAsBF,EAAO,EAAK,GAElCG,IAAYH,EAAwC,CAAA,CAAE,GAEtD,EAAE,iBAAAI,MAAoBC,KACtB,EAAE,eAAAC,GAAe,YAAAC,GAAY,cAAAC,MAAiBC,EAAW,GACzD,EAAE,SAASC,EAAe,IAAIC,EAAa,GAE3CC,IAAaC;AAAA,IACjB,CAACC,MAAiC;;AAEhC,MAAIA,KACFnB,EAAoBmB,CAAY,GAElCJ,EAAeK,EAAwB,2BAA2B;AAAA,QAChE,MAAMC,EAAO;AAAA,MAAA,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,SAAS;AAAA,QAC1C;AAAA,MAAA,CACD,GAEDxC,EAAaX,GAAW;AAAA,QACtB,+BAA+BE,EAAiB,QAAQ;AAAA,QACxD,UAAU;AAAA,QACV,MAAM0B,EAAc;AAAA,QACpB,WAAW;AAAA,UACT,OAAO;AAAA,UACP,SACG,gBAAAC,EAAAG,GAAA,EAAK,WAAU,OAAM,QAAO,SAC1B,UACH,yBAAA;AAAA,UAEF,eAAeN,EAAc,QAAQ,IAAI;AAAA,UACzC,eAAeA,EAAc,SAAS;AAAA,QACxC;AAAA,QACA,oBACE,gBAAAG;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,KAAK1B;AAAA,YACL,OAAOyC,EAAW;AAAA,YAClB,MAAMA,EAAW;AAAA,YACjB,SAAS,MAAM;AAAA,YAAC;AAAA,YAChB,qBAAqB,CAAAmB,MAAa1C,EAAwBuB,GAAYmB,CAAS;AAAA,UAAA;AAAA,QACjF;AAAA,MAAA,CAEH;AAAA,IACH;AAAA,IACA;AAAA,MACErD;AAAA,MACAd;AAAA,MACAyC;AAAA,MACAhB;AAAA,MACAtB;AAAA,MACAS;AAAA,MACAC;AAAA,IACF;AAAA,EAAA;AAIF,SAAAuD,EAAU,MACD,MAAM;AACX,IAAA3D,EAAU,QAAQ,QAAQ,CAAS4D,MAAA,aAAaA,CAAK,CAAC,GACtD5D,EAAU,UAAU,IACpBD,EAAoB,UAAU;AAAA,EAAA,GAE/B,CAACL,CAAS,CAAC,GAEP;AAAA,IACL,UAAUE;AAAA,IACV,cAAA0C;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 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 nextCoachmark(journeyId, false);\n endJourney(journeyId);\n },\n [endJourney, journeyId, nextCoachmark, 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","_d","labelDims","_e","S.Indicator","_h","LESSON_CARD_INDEX","SHOW_INITIAL_COACHMARK_AFTER_MS","SHOW_INITIAL_TOOLTIP_AFTER_MS","_f","IconButton","CaratRightIcon","GAME_LAUNCHER_ANALYTICS_EVENTS","_g","PUZZLE_CARD_INDEX","tableInfo","useEffect","timer"],"mappings":";;;;;;;;;;;;;;;;;AAyCO,MAAMA,KAA0B,CAAC;AAAA,EACtC,cAAAC;AAAA,EACA,qBAAAC;AACF,MAA6B;AAC3B,QAAMC,IAAYC,EAAmB,6BAC/BC,IAAmBC,EAAsB,IAAI,GAC7CC,IAAsBD,EAAsB,IAAI,GAChDE,IAAsBF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AS,CAAC,GAEP;AAAA,IACL,UAAUE;AAAA,IACV,cAAA2C;AAAA,EAAA;AAEJ;"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { createGetAPI as o, createPostAPI as u } from "@cuemath/rest-api";
|
2
|
+
import { BASE_URL as e } from "../../../constants/api.js";
|
3
|
+
const { useGet: p } = o({
|
4
|
+
getURL: (n, { app_id: s, journey_status: r, user_id: t }) => `${e}/task/user-journey/?app_id=${s}&journey_status=${r}&user_id=${t}`
|
5
|
+
}), { usePost: y } = u({
|
6
|
+
getURL: () => `${e}/task/user-journey/`
|
7
|
+
});
|
8
|
+
export {
|
9
|
+
p as useGetJourneyProgress,
|
10
|
+
y as usePostJourneyProgress
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=journey-progress-api.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"journey-progress-api.js","sources":["../../../../src/features/journey/journey-progress-api/journey-progress-api.ts"],"sourcesContent":["import type {\n TGetJourneyProgressPayloadModel,\n TGetJourneyProgressResponseModel,\n TPostJourneyProgressPayloadModel,\n TPostJourneyProgressResponseModel,\n} from './journey-progress-api-types';\n\nimport { createGetAPI, createPostAPI } from '@cuemath/rest-api';\n\nimport { BASE_URL } from '../../../constants/api';\n\nconst { useGet: useGetJourneyProgress } = createGetAPI<\n TGetJourneyProgressResponseModel,\n TGetJourneyProgressPayloadModel\n>({\n getURL: (_, { app_id, journey_status, user_id }) =>\n `${BASE_URL}/task/user-journey/?app_id=${app_id}&journey_status=${journey_status}&user_id=${user_id}`,\n});\n\nconst { usePost: usePostJourneyProgress } = createPostAPI<\n TPostJourneyProgressResponseModel,\n TPostJourneyProgressPayloadModel\n>({\n getURL: () => `${BASE_URL}/task/user-journey/`,\n});\n\nexport { useGetJourneyProgress, usePostJourneyProgress };\n"],"names":["useGetJourneyProgress","createGetAPI","_","app_id","journey_status","user_id","BASE_URL","usePostJourneyProgress","createPostAPI"],"mappings":";;AAWA,MAAM,EAAE,QAAQA,EAAsB,IAAIC,EAGxC;AAAA,EACA,QAAQ,CAACC,GAAG,EAAE,QAAAC,GAAQ,gBAAAC,GAAgB,SAAAC,EAAA,MACpC,GAAGC,CAAQ,8BAA8BH,CAAM,mBAAmBC,CAAc,YAAYC,CAAO;AACvG,CAAC,GAEK,EAAE,SAASE,EAAuB,IAAIC,EAG1C;AAAA,EACA,QAAQ,MAAM,GAAGF,CAAQ;AAC3B,CAAC;"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { useJourney as t } from "./use-journey/use-journey.js";
|
2
|
+
const u = (n) => {
|
3
|
+
const { completedJourneys: r } = t(), e = n.filter(
|
4
|
+
(o) => !r.includes(o)
|
5
|
+
);
|
6
|
+
return e.length > 0 ? e[0] : null;
|
7
|
+
};
|
8
|
+
export {
|
9
|
+
u as useGetEligibleJourney
|
10
|
+
};
|
11
|
+
//# sourceMappingURL=use-get-eligible-journey.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-get-eligible-journey.js","sources":["../../../src/features/journey/use-get-eligible-journey.tsx"],"sourcesContent":["import type { TJourneyId } from './journey-id/journey-id-types';\n\nimport { useJourney } from './use-journey/use-journey';\n\nexport const useGetEligibleJourney = (allJourneyIds: TJourneyId[]) => {\n const { completedJourneys } = useJourney();\n const eligibleJourneys = allJourneyIds.filter(\n journeyId => !completedJourneys.includes(journeyId),\n );\n\n if (eligibleJourneys.length > 0) {\n return eligibleJourneys[0];\n }\n\n return null;\n};\n"],"names":["useGetEligibleJourney","allJourneyIds","completedJourneys","useJourney","eligibleJourneys","journeyId"],"mappings":";AAIa,MAAAA,IAAwB,CAACC,MAAgC;AAC9D,QAAA,EAAE,mBAAAC,MAAsBC,KACxBC,IAAmBH,EAAc;AAAA,IACrC,CAAaI,MAAA,CAACH,EAAkB,SAASG,CAAS;AAAA,EAAA;AAGhD,SAAAD,EAAiB,SAAS,IACrBA,EAAiB,CAAC,IAGpB;AACT;"}
|
@@ -1,71 +1,107 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { createContext as
|
3
|
-
import { Coachmark as
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
1
|
+
import { jsxs as O, jsx as $ } from "react/jsx-runtime";
|
2
|
+
import { createContext as R, useState as L, useRef as C, useCallback as y, useMemo as D, useEffect as T } from "react";
|
3
|
+
import { Coachmark as b } from "../comps/coachmark/coachmark.js";
|
4
|
+
import { usePostJourneyProgress as q, useGetJourneyProgress as M } from "../journey-progress-api/journey-progress-api.js";
|
5
|
+
import { BlurOverlay as N } from "./journey-styled.js";
|
6
|
+
const j = R(null), F = ({ children: w, appId: J, userId: u }) => {
|
7
|
+
const [c, p] = L([]), [s, a] = L([]), i = C(-1), r = C(), f = C([]), { post: g } = q(), { data: l = null, get: k } = M(), v = y(
|
7
8
|
(e, t) => {
|
8
|
-
if (
|
9
|
+
if (s.length > 0) {
|
9
10
|
console.error(
|
10
11
|
`setJourney: Other Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
11
12
|
);
|
12
13
|
return;
|
13
14
|
}
|
14
|
-
r.current = e,
|
15
|
+
r.current = e, i.current = -1, a([...t]);
|
15
16
|
},
|
16
|
-
[
|
17
|
-
),
|
18
|
-
|
17
|
+
[s.length]
|
18
|
+
), d = y(() => {
|
19
|
+
f.current.forEach((e) => {
|
19
20
|
clearTimeout(e);
|
20
|
-
}),
|
21
|
-
}, []),
|
21
|
+
}), f.current = [], r.current = void 0, i.current = -1, a([]);
|
22
|
+
}, []), x = y(
|
23
|
+
(e) => {
|
24
|
+
if (c.includes(e)) {
|
25
|
+
console.error(`endJourney: Journey ID ${e} is already completed.`);
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
p((t) => [...t, e]), g({
|
29
|
+
app_id: J,
|
30
|
+
user_id: u,
|
31
|
+
journey_id: e,
|
32
|
+
journey_status: "COMPLETED"
|
33
|
+
}), d();
|
34
|
+
},
|
35
|
+
[J, d, c, g, u]
|
36
|
+
), E = y((e, t) => {
|
22
37
|
if (!r.current || e !== r.current) {
|
23
38
|
console.error(
|
24
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"
|
25
40
|
);
|
26
41
|
return;
|
27
42
|
}
|
28
|
-
|
29
|
-
}, []),
|
30
|
-
(e, t = !1,
|
43
|
+
a((n) => [...n, t]);
|
44
|
+
}, []), P = y(
|
45
|
+
(e, t = !1, n = 0) => {
|
31
46
|
if (!r.current || e !== r.current) {
|
32
47
|
console.error(
|
33
48
|
r.current ? "nextCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
34
49
|
);
|
35
50
|
return;
|
36
51
|
}
|
37
|
-
|
38
|
-
const
|
39
|
-
clearTimeout(
|
40
|
-
const
|
41
|
-
|
42
|
-
if (
|
43
|
-
return r.current = void 0,
|
44
|
-
|
45
|
-
const
|
46
|
-
return
|
52
|
+
n !== 0 && a((o) => o.map((m) => ({ ...m, isActive: !1 })));
|
53
|
+
const _ = setTimeout(() => {
|
54
|
+
clearTimeout(_);
|
55
|
+
const o = i.current + 1;
|
56
|
+
a((m) => {
|
57
|
+
if (o >= m.length || m.length === 0)
|
58
|
+
return r.current = void 0, i.current = -1, [];
|
59
|
+
i.current = o;
|
60
|
+
const h = [...m];
|
61
|
+
return h[o].isActive = !0, o > 0 && (h[o - 1].isActive = t), h;
|
47
62
|
});
|
48
|
-
},
|
49
|
-
|
63
|
+
}, n);
|
64
|
+
f.current.push(_);
|
50
65
|
},
|
51
66
|
[]
|
52
|
-
),
|
67
|
+
), A = D(
|
53
68
|
() => ({
|
54
|
-
nextCoachmark:
|
55
|
-
setJourney:
|
56
|
-
addCoachmark:
|
57
|
-
clearJourney:
|
58
|
-
|
69
|
+
nextCoachmark: P,
|
70
|
+
setJourney: v,
|
71
|
+
addCoachmark: E,
|
72
|
+
clearJourney: d,
|
73
|
+
endJourney: x,
|
74
|
+
coachmarks: s,
|
75
|
+
completedJourneys: c
|
59
76
|
}),
|
60
|
-
[
|
77
|
+
[
|
78
|
+
P,
|
79
|
+
v,
|
80
|
+
E,
|
81
|
+
d,
|
82
|
+
x,
|
83
|
+
s,
|
84
|
+
c
|
85
|
+
]
|
61
86
|
);
|
62
|
-
return
|
63
|
-
|
64
|
-
|
87
|
+
return T(() => {
|
88
|
+
u && k(u, {
|
89
|
+
app_id: J,
|
90
|
+
user_id: u,
|
91
|
+
journey_status: "COMPLETED"
|
92
|
+
});
|
93
|
+
}, [J, k, u]), T(() => {
|
94
|
+
if (l && c.length === 0) {
|
95
|
+
const t = (l == null ? void 0 : l.filter((n) => n.status === "COMPLETED")).map((n) => n.journey_id);
|
96
|
+
p(t);
|
97
|
+
}
|
98
|
+
}, [c.length, l]), /* @__PURE__ */ O(j.Provider, { value: A, children: [
|
99
|
+
s.length > 0 && /* @__PURE__ */ $(N, { children: s.map((e, t) => /* @__PURE__ */ $(b, { coachmark: e }, `coachmark-${t}`)) }),
|
100
|
+
w
|
65
101
|
] });
|
66
102
|
};
|
67
103
|
export {
|
68
|
-
|
69
|
-
|
104
|
+
j as JourneyContext,
|
105
|
+
F as JourneyProvider
|
70
106
|
};
|
71
107
|
//# 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":["/* eslint-disable no-console */\nimport 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 const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\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: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n currentJourneyIdStudent.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 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 console.error(\n currentJourneyIdStudent.current\n ? `A Journey is already active, Current Journey: ${currentJourneyIdStudent.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 (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n console.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 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 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 timerRefs.current.push(timer);\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","timerRefs","setJourney","useCallback","id","coachmarks","clearJourney","timer","addCoachmark","coachmark","prev","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","jsxs","jsx","S.BlurOverlay","index","Coachmark"],"mappings":";;;;AAUa,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,KAC1BE,IAAYF,EAAwC,CAAA,CAAE,GAEtDG,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAV,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEK,EAAwB,OAAO,0BAA0BI,CAAE;AAAA,QAAA;AAG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,UAAU,QAClCF,EAAa,UAAU,IAEhB;AAGT,UAAAA,EAAa,UAAUkB;AACjB,gBAAAC,IAAuB,CAAC,GAAGH,CAAQ;AAExC,iBAAAG,EAAqBD,CAAS,EAAsB,WAAW,IAE5DA,IAAY,MACbC,EAAqBD,IAAY,CAAC,EAAsB,WAAWJ,IAG/DK;AAAA,QAAA,CACR;AAAA,SACAJ,CAAS;AAEF,MAAAZ,EAAA,QAAQ,KAAKM,CAAK;AAAA,IAC9B;AAAA,IACA,CAAC;AAAA,EAAA,GAGGW,IAAuBC;AAAA,IAC3B,OAAO;AAAA,MACL,eAAAR;AAAA,MACA,YAAAT;AAAA,MACA,cAAAM;AAAA,MACA,cAAAF;AAAA,MACA,YAAYX;AAAA,IAAA;AAAA,IAEd,CAACgB,GAAeT,GAAYM,GAAcF,GAAcX,CAAa;AAAA,EAAA;AAGvE,SACG,gBAAAyB,EAAA7B,EAAe,UAAf,EAAwB,OAAO2B,GAC7B,UAAA;AAAA,IAAAvB,EAAc,SAAS,KACtB,gBAAA0B,EAACC,GAAA,EACE,YAAc,IAAI,CAACb,GAAWc,wBAC5BC,GAAqC,EAAA,WAAAf,EAAA,GAAtB,aAAac,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED7B;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 {\n useGetJourneyProgress,\n usePostJourneyProgress,\n} from '../journey-progress-api/journey-progress-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 [completedJourneys, setCompletedJourneys] = useState<TJourneyId[]>([]);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const currentIndex = useRef(-1);\n const currentJourneyIdStudent = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostJourneyProgress();\n const { data: journeyProgressData = null, get: getJourneyProgress } = useGetJourneyProgress();\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: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n currentJourneyIdStudent.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 currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n if (completedJourneys.includes(journeyId)) {\n console.error(`endJourney: Journey ID ${journeyId} is already completed.`);\n\n return;\n }\n setCompletedJourneys(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, completedJourneys, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n console.error(\n currentJourneyIdStudent.current\n ? `A Journey is already active, Current Journey: ${currentJourneyIdStudent.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 (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n console.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 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 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 timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n completedJourneys,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n completedJourneys,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (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 (journeyProgressData && completedJourneys.length === 0) {\n const completedJourneysList = journeyProgressData?.filter(journey => {\n return journey.status === 'COMPLETED';\n });\n const completedJourneysIds = completedJourneysList.map(journey => journey.journey_id);\n\n setCompletedJourneys(completedJourneysIds);\n }\n }, [completedJourneys.length, journeyProgressData]);\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","appId","userId","completedJourneys","setCompletedJourneys","useState","coachmarkList","setCoachmarkList","currentIndex","useRef","currentJourneyIdStudent","timerRefs","postJourneyCompletion","usePostJourneyProgress","journeyProgressData","getJourneyProgress","useGetJourneyProgress","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedJourneysIds","journey","jsxs","jsx","S.BlurOverlay","index","Coachmark"],"mappings":";;;;;AAkBa,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAmBC,CAAoB,IAAIC,EAAuB,CAAE,CAAA,GACrE,CAACC,GAAeC,CAAgB,IAAIF,EAA4B,CAAE,CAAA,GAClEG,IAAeC,EAAO,EAAE,GACxBC,IAA0BD,KAC1BE,IAAYF,EAAwC,CAAA,CAAE,GAEtD,EAAE,MAAMG,EAAsB,IAAIC,EAAuB,GACzD,EAAE,MAAMC,IAAsB,MAAM,KAAKC,EAAA,IAAuBC,KAEhEC,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAd,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEI,EAAwB,OAAO,0BAA0BS,CAAE;AAAA,QAAA;AAG9H;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V,QAAAvB,KAAuBX,EAAkB,WAAW,GAAG;AAIzD,YAAMmC,KAHwBxB,KAAA,gBAAAA,EAAqB,OAAO,CAAWyB,MAC5DA,EAAQ,WAAW,cAEuB,IAAI,CAAAA,MAAWA,EAAQ,UAAU;AAEpF,MAAAnC,EAAqBkC,CAAoB;AAAA,IAC3C;AAAA,EACC,GAAA,CAACnC,EAAkB,QAAQW,CAAmB,CAAC,GAG/C,gBAAA0B,EAAA3C,EAAe,UAAf,EAAwB,OAAOsC,GAC7B,UAAA;AAAA,IAAA7B,EAAc,SAAS,KACtB,gBAAAmC,EAACC,GAAA,EACE,YAAc,IAAI,CAACf,GAAWgB,wBAC5BC,GAAqC,EAAA,WAAAjB,EAAA,GAAtB,aAAagB,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED3C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
@@ -1,52 +1,37 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import
|
3
|
-
import { memo as
|
4
|
-
import
|
5
|
-
import { fetchLottie as
|
6
|
-
const
|
7
|
-
const {
|
8
|
-
|
9
|
-
|
10
|
-
height: g = "100%",
|
11
|
-
settings: u,
|
12
|
-
eventListener: r,
|
13
|
-
onRender: i,
|
14
|
-
useVisibilityObserver: o
|
15
|
-
} = p, n = c(null), e = c(null), a = c(null);
|
16
|
-
return A(
|
17
|
-
h,
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
2
|
+
import p from "lottie-web";
|
3
|
+
import { memo as h, forwardRef as L, useRef as m, useImperativeHandle as g, useEffect as v } from "react";
|
4
|
+
import w from "../layout/flex-view.js";
|
5
|
+
import { fetchLottie as y } from "./helper.js";
|
6
|
+
const A = L((s, u) => {
|
7
|
+
const { src: i, width: l = "100%", height: f = "100%", settings: a, eventListener: t, onRender: n } = s, o = m(null), e = m(null);
|
8
|
+
return g(
|
9
|
+
u,
|
18
10
|
() => ({
|
19
|
-
playSegments: (
|
20
|
-
e.current && e.current.playSegments(
|
11
|
+
playSegments: (c, r) => {
|
12
|
+
e.current && e.current.playSegments(c, r);
|
21
13
|
}
|
22
14
|
}),
|
23
15
|
[]
|
24
|
-
),
|
16
|
+
), v(() => ((async () => {
|
25
17
|
try {
|
26
|
-
const
|
27
|
-
|
28
|
-
container:
|
29
|
-
animationData:
|
18
|
+
const r = await y(i);
|
19
|
+
o.current && (e.current = p.loadAnimation({
|
20
|
+
container: o.current,
|
21
|
+
animationData: r,
|
30
22
|
renderer: "svg",
|
31
23
|
loop: !0,
|
32
24
|
autoplay: !0,
|
33
|
-
...
|
34
|
-
}),
|
35
|
-
|
36
|
-
|
37
|
-
l && l.isIntersecting ? (f = e.current) == null || f.play() : (d = e.current) == null || d.pause();
|
38
|
-
},
|
39
|
-
{ threshold: 0 }
|
40
|
-
), n.current && a.current.observe(n.current)), i == null || i(), r && e.current.addEventListener(r.name, r.callback));
|
41
|
-
} catch (t) {
|
42
|
-
throw Error(`Error loading Lottie animation: ${t}`);
|
25
|
+
...a
|
26
|
+
}), n == null || n(), t && e.current.addEventListener(t.name, t.callback));
|
27
|
+
} catch (r) {
|
28
|
+
throw Error(`Error loading Lottie animation: ${r}`);
|
43
29
|
}
|
44
30
|
})(), () => {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}), D = w(x);
|
31
|
+
e.current && (t && e.current.removeEventListener(t.name, t.callback), e.current.destroy());
|
32
|
+
}), [i, t, n, a]), /* @__PURE__ */ d(w, { ref: o, $width: l, $height: f });
|
33
|
+
}), I = h(A);
|
49
34
|
export {
|
50
|
-
|
35
|
+
I as default
|
51
36
|
};
|
52
37
|
//# sourceMappingURL=lottie-animation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lottie-animation.js","sources":["../../../../src/features/ui/lottie-animation/lottie-animation.tsx"],"sourcesContent":["import type { ILottieAnimationProps, ILottieAnimationRef } from './types';\nimport type { AnimationItem, AnimationSegment } from 'lottie-web';\n\nimport lottie from 'lottie-web';\nimport { forwardRef, memo, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport FlexView from '../layout/flex-view';\nimport { fetchLottie } from './helper';\n\nconst LottieAnimation = forwardRef<ILottieAnimationRef, ILottieAnimationProps>((props, ref) => {\n const {
|
1
|
+
{"version":3,"file":"lottie-animation.js","sources":["../../../../src/features/ui/lottie-animation/lottie-animation.tsx"],"sourcesContent":["import type { ILottieAnimationProps, ILottieAnimationRef } from './types';\nimport type { AnimationItem, AnimationSegment } from 'lottie-web';\n\nimport lottie from 'lottie-web';\nimport { forwardRef, memo, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport FlexView from '../layout/flex-view';\nimport { fetchLottie } from './helper';\n\nconst LottieAnimation = forwardRef<ILottieAnimationRef, ILottieAnimationProps>((props, ref) => {\n const { src, width = '100%', height = '100%', settings, eventListener, onRender } = props;\n\n const container = useRef<HTMLDivElement>(null);\n const animationInstance = useRef<AnimationItem | null>(null);\n\n useImperativeHandle(\n ref,\n () => ({\n playSegments: (segments: AnimationSegment, forceFlag?: boolean) => {\n if (animationInstance.current) {\n animationInstance.current.playSegments(segments, forceFlag);\n }\n },\n }),\n [],\n );\n\n useEffect(() => {\n const loadAnimation = async () => {\n try {\n const animationData = await fetchLottie(src);\n\n if (container.current) {\n animationInstance.current = lottie.loadAnimation({\n container: container.current,\n animationData,\n renderer: 'svg',\n loop: true,\n autoplay: true,\n ...settings,\n });\n\n onRender?.();\n if (eventListener) {\n animationInstance.current.addEventListener(eventListener.name, eventListener.callback);\n }\n }\n } catch (error) {\n throw Error(`Error loading Lottie animation: ${error}`);\n }\n };\n\n loadAnimation();\n\n return () => {\n if (animationInstance.current) {\n if (eventListener) {\n animationInstance.current.removeEventListener(eventListener.name, eventListener.callback);\n }\n animationInstance.current.destroy();\n }\n };\n }, [src, eventListener, onRender, settings]);\n\n return <FlexView ref={container} $width={width} $height={height} />;\n});\n\nexport default memo(LottieAnimation);\n"],"names":["LottieAnimation","forwardRef","props","ref","src","width","height","settings","eventListener","onRender","container","useRef","animationInstance","useImperativeHandle","segments","forceFlag","useEffect","animationData","fetchLottie","lottie","error","FlexView","LottieAnimation$1","memo"],"mappings":";;;;;AASA,MAAMA,IAAkBC,EAAuD,CAACC,GAAOC,MAAQ;AACvF,QAAA,EAAE,KAAAC,GAAK,OAAAC,IAAQ,QAAQ,QAAAC,IAAS,QAAQ,UAAAC,GAAU,eAAAC,GAAe,UAAAC,EAAa,IAAAP,GAE9EQ,IAAYC,EAAuB,IAAI,GACvCC,IAAoBD,EAA6B,IAAI;AAE3D,SAAAE;AAAA,IACEV;AAAA,IACA,OAAO;AAAA,MACL,cAAc,CAACW,GAA4BC,MAAwB;AACjE,QAAIH,EAAkB,WACFA,EAAA,QAAQ,aAAaE,GAAUC,CAAS;AAAA,MAE9D;AAAA,IAAA;AAAA,IAEF,CAAC;AAAA,EAAA,GAGHC,EAAU,QACc,YAAY;AAC5B,QAAA;AACI,YAAAC,IAAgB,MAAMC,EAAYd,CAAG;AAE3C,MAAIM,EAAU,YACME,EAAA,UAAUO,EAAO,cAAc;AAAA,QAC/C,WAAWT,EAAU;AAAA,QACrB,eAAAO;AAAA,QACA,UAAU;AAAA,QACV,MAAM;AAAA,QACN,UAAU;AAAA,QACV,GAAGV;AAAA,MAAA,CACJ,GAEUE,KAAA,QAAAA,KACPD,KACFI,EAAkB,QAAQ,iBAAiBJ,EAAc,MAAMA,EAAc,QAAQ;AAAA,aAGlFY,GAAO;AACR,YAAA,MAAM,mCAAmCA,CAAK,EAAE;AAAA,IACxD;AAAA,EAAA,MAKK,MAAM;AACX,IAAIR,EAAkB,YAChBJ,KACFI,EAAkB,QAAQ,oBAAoBJ,EAAc,MAAMA,EAAc,QAAQ,GAE1FI,EAAkB,QAAQ;EAC5B,IAED,CAACR,GAAKI,GAAeC,GAAUF,CAAQ,CAAC,qBAEnCc,GAAS,EAAA,KAAKX,GAAW,QAAQL,GAAO,SAASC,EAAQ,CAAA;AACnE,CAAC,GAEcgB,IAAAC,EAAKvB,CAAe;"}
|
package/dist/index.d.ts
CHANGED
@@ -1121,7 +1121,6 @@ declare interface IGameLauncherProps {
|
|
1121
1121
|
defaultIndex?: number;
|
1122
1122
|
journeyId?: TJourneyId;
|
1123
1123
|
isTutorialOnboardingDone?: boolean;
|
1124
|
-
onJourneyComplete: (journeyId: TJourneyId) => void;
|
1125
1124
|
}
|
1126
1125
|
|
1127
1126
|
declare interface IGetArrowTooltipConfig {
|
@@ -1327,6 +1326,14 @@ export declare interface IJourneyContext {
|
|
1327
1326
|
* @param delayInMs - Optional delay (in milliseconds) before rendering the current coachmark.
|
1328
1327
|
*/
|
1329
1328
|
nextCoachmark: (id: TJourneyId, keepPrevActive?: boolean, delayInMs?: number) => void;
|
1329
|
+
endJourney: (id: TJourneyId) => void;
|
1330
|
+
completedJourneys: TJourneyId[];
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
declare interface IJourneyProviderProps {
|
1334
|
+
children: React.ReactNode;
|
1335
|
+
appId: string;
|
1336
|
+
userId: string;
|
1330
1337
|
}
|
1331
1338
|
|
1332
1339
|
export declare interface ILayout {
|
@@ -3433,9 +3440,7 @@ export declare enum JOURNEY_ID_STUDENT {
|
|
3433
3440
|
CIRCLE_STREAK_REDUCTION_JOURNEY = "CIRCLE_STREAK_REDUCTION_JOURNEY"
|
3434
3441
|
}
|
3435
3442
|
|
3436
|
-
export declare const JourneyProvider: FC<
|
3437
|
-
children: ReactNode;
|
3438
|
-
}>;
|
3443
|
+
export declare const JourneyProvider: FC<IJourneyProviderProps>;
|
3439
3444
|
|
3440
3445
|
export declare const Leaderboard: ({ leaderboardData, type, userId, onClose, isLoading, streakInfo, }: ILeaderboardProps) => JSX_2.Element;
|
3441
3446
|
|
@@ -5012,6 +5017,8 @@ export declare const useGetCircleHomeDetailsDal: (userId: string, grade: string,
|
|
5012
5017
|
invalidateCircleHomeDetails: () => void;
|
5013
5018
|
};
|
5014
5019
|
|
5020
|
+
export declare const useGetEligibleJourney: (allJourneyIds: TJourneyId[]) => JOURNEY_ID_STUDENT | null | undefined;
|
5021
|
+
|
5015
5022
|
declare const useGetLeaderboard: (initialId?: string, initialQuery?: IGetLeaderboardPayloadModel | undefined) => {
|
5016
5023
|
get: (id: string, query: IGetLeaderboardPayloadModel, meta: void) => Promise<void>;
|
5017
5024
|
resource: ResourceModel<IGetLeaderboardResponseModel> | undefined;
|