@cuemath/leap 3.4.9-m → 3.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/journey/use-journey/constants.js +7 -5
- package/dist/features/journey/use-journey/constants.js.map +1 -1
- package/dist/features/journey/use-journey/journey-context-provider.js +84 -72
- package/dist/features/journey/use-journey/journey-context-provider.js.map +1 -1
- package/dist/features/stickers/hooks/use-handle-sticker-send.js +44 -0
- package/dist/features/stickers/hooks/use-handle-sticker-send.js.map +1 -0
- package/dist/features/stickers/hooks/use-stickers-error-logger.js +17 -0
- package/dist/features/stickers/hooks/use-stickers-error-logger.js.map +1 -0
- package/dist/features/stickers/{sticker-selector/hooks → hooks}/use-stickers-journey/use-stickers-journey.js +7 -7
- package/dist/features/stickers/hooks/use-stickers-journey/use-stickers-journey.js.map +1 -0
- package/dist/features/stickers/sticker-selector/comps/sticker/sticker.js +27 -26
- package/dist/features/stickers/sticker-selector/comps/sticker/sticker.js.map +1 -1
- package/dist/features/stickers/sticker-selector/sticker-selector.js +67 -66
- package/dist/features/stickers/sticker-selector/sticker-selector.js.map +1 -1
- package/dist/features/stickers/stickers-analytics-events.js +8 -0
- package/dist/features/stickers/stickers-analytics-events.js.map +1 -0
- package/dist/features/worksheet/worksheet/worksheet-sidebar/question-guide.js +52 -119
- package/dist/features/worksheet/worksheet/worksheet-sidebar/question-guide.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-sidebar/sidebar.js +17 -21
- package/dist/features/worksheet/worksheet/worksheet-sidebar/sidebar.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-sidebar/worksheet-sidebar-styled.js +27 -33
- package/dist/features/worksheet/worksheet/worksheet-sidebar/worksheet-sidebar-styled.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-types.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet.js +247 -251
- package/dist/features/worksheet/worksheet/worksheet.js.map +1 -1
- package/dist/index.d.ts +15 -15
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/features/stickers/sticker-selector/hooks/use-handle-sticker-send.js +0 -33
- package/dist/features/stickers/sticker-selector/hooks/use-handle-sticker-send.js.map +0 -1
- package/dist/features/stickers/sticker-selector/hooks/use-stickers-journey/use-stickers-journey.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
1
|
+
var r = /* @__PURE__ */ ((e) => (e.TOOLTIP = "tooltip", e.NUDGE = "nudge", e))(r || {});
|
|
2
|
+
const o = {
|
|
3
3
|
nextCoachmark: () => {
|
|
4
4
|
},
|
|
5
5
|
setJourney: () => {
|
|
@@ -12,10 +12,12 @@ const r = {
|
|
|
12
12
|
},
|
|
13
13
|
coachmarks: [],
|
|
14
14
|
userCompletedJourneyIds: [],
|
|
15
|
-
isJourneyActive: !1
|
|
15
|
+
isJourneyActive: !1,
|
|
16
|
+
trackView: () => {
|
|
17
|
+
}
|
|
16
18
|
};
|
|
17
19
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
r as IndicatorType,
|
|
21
|
+
o as baseJourneyContext
|
|
20
22
|
};
|
|
21
23
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/features/journey/use-journey/constants.ts"],"sourcesContent":["import type { IJourneyContext } from './journey-context-types';\n\nexport enum IndicatorType {\n TOOLTIP = 'tooltip',\n NUDGE = 'nudge',\n}\n\nexport const baseJourneyContext: IJourneyContext = {\n nextCoachmark: () => {},\n setJourney: () => {},\n addCoachmark: () => {},\n clearJourney: () => {},\n endJourney: () => {},\n coachmarks: [],\n userCompletedJourneyIds: [],\n isJourneyActive: false,\n};\n"],"names":["IndicatorType","baseJourneyContext"],"mappings":"AAEY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,QAAQ,SAFEA,IAAAA,KAAA,CAAA,CAAA;AAKL,MAAMC,IAAsC;AAAA,EACjD,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,YAAY,MAAM;AAAA,EAAC;AAAA,EACnB,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,YAAY,MAAM;AAAA,EAAC;AAAA,EACnB,YAAY,CAAC;AAAA,EACb,yBAAyB,CAAC;AAAA,EAC1B,iBAAiB;
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/features/journey/use-journey/constants.ts"],"sourcesContent":["import type { IJourneyContext } from './journey-context-types';\n\nexport enum IndicatorType {\n TOOLTIP = 'tooltip',\n NUDGE = 'nudge',\n}\n\nexport const baseJourneyContext: IJourneyContext = {\n nextCoachmark: () => {},\n setJourney: () => {},\n addCoachmark: () => {},\n clearJourney: () => {},\n endJourney: () => {},\n coachmarks: [],\n userCompletedJourneyIds: [],\n isJourneyActive: false,\n trackView: () => {},\n};\n"],"names":["IndicatorType","baseJourneyContext"],"mappings":"AAEY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,QAAQ,SAFEA,IAAAA,KAAA,CAAA,CAAA;AAKL,MAAMC,IAAsC;AAAA,EACjD,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,YAAY,MAAM;AAAA,EAAC;AAAA,EACnB,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,YAAY,MAAM;AAAA,EAAC;AAAA,EACnB,YAAY,CAAC;AAAA,EACb,yBAAyB,CAAC;AAAA,EAC1B,iBAAiB;AAAA,EACjB,WAAW,MAAM;AAAA,EAAC;AACpB;"}
|
|
@@ -1,55 +1,60 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { Coachmark as
|
|
4
|
-
import { usePostUserJourney as
|
|
5
|
-
import { Overlay as
|
|
6
|
-
const
|
|
7
|
-
const [
|
|
1
|
+
import { jsxs as W, jsx as T } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as M, useState as s, useRef as v, useCallback as c, useMemo as G, useEffect as b } from "react";
|
|
3
|
+
import { Coachmark as F } from "../comps/coachmark/coachmark.js";
|
|
4
|
+
import { usePostUserJourney as I, useGetUserJourney as K } from "../user-journey-api/user-journey-api.js";
|
|
5
|
+
import { Overlay as Q } from "./journey-styled.js";
|
|
6
|
+
const X = M(null), ne = ({ children: U, appId: l, userId: i }) => {
|
|
7
|
+
const [q, z] = s(!0), [D, H] = s(!1), [p, x] = s(null), [y, d] = s([]), [f, A] = s(!1), m = v(-1), t = v(void 0), w = v([]), [L, N] = s(!1), [$, R] = s({
|
|
8
8
|
height: window.innerHeight,
|
|
9
9
|
width: window.innerWidth
|
|
10
|
-
}), { post:
|
|
10
|
+
}), { post: _ } = I(), { data: g = null, get: P } = K(), J = c(
|
|
11
|
+
(e) => {
|
|
12
|
+
_({
|
|
13
|
+
app_id: l,
|
|
14
|
+
user_id: i,
|
|
15
|
+
journey_id: e,
|
|
16
|
+
journey_status: "COMPLETED"
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
[l, _, i]
|
|
20
|
+
), B = c(
|
|
11
21
|
(e, r, o, C = !0) => {
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
22
|
+
var h, n;
|
|
23
|
+
if (y.length > 0) {
|
|
14
24
|
console.error(
|
|
15
25
|
`setJourney: Other Journey is already active, Current Journey: ${t.current}, New Journey Request: ${e}`
|
|
16
26
|
);
|
|
17
27
|
return;
|
|
18
28
|
}
|
|
19
|
-
|
|
29
|
+
A(!0), z(C), t.current = e, m.current = -1, d(
|
|
20
30
|
r.map((u) => ({
|
|
21
31
|
...u,
|
|
22
32
|
isActive: !1
|
|
23
33
|
// New coachmarks are inactive by default
|
|
24
34
|
}))
|
|
25
|
-
), o && (
|
|
26
|
-
height: ((
|
|
35
|
+
), o && (R({
|
|
36
|
+
height: ((h = o.current) == null ? void 0 : h.clientHeight) || window.innerHeight,
|
|
27
37
|
width: ((n = o.current) == null ? void 0 : n.clientWidth) || window.innerWidth
|
|
28
|
-
}),
|
|
38
|
+
}), N(!0));
|
|
29
39
|
},
|
|
30
|
-
[
|
|
31
|
-
),
|
|
32
|
-
|
|
40
|
+
[y.length]
|
|
41
|
+
), a = c(() => {
|
|
42
|
+
w.current.forEach((e) => {
|
|
33
43
|
clearTimeout(e);
|
|
34
|
-
}),
|
|
35
|
-
}, []), E =
|
|
44
|
+
}), w.current = [], t.current = void 0, m.current = -1, d([]), A(!1);
|
|
45
|
+
}, []), E = c(
|
|
36
46
|
(e) => {
|
|
37
|
-
|
|
38
|
-
app_id: a,
|
|
39
|
-
user_id: c,
|
|
40
|
-
journey_id: e,
|
|
41
|
-
journey_status: "COMPLETED"
|
|
42
|
-
});
|
|
47
|
+
a(), x((r) => r && !r.includes(e) ? [...r, e] : r), J(e);
|
|
43
48
|
},
|
|
44
|
-
[a,
|
|
45
|
-
),
|
|
49
|
+
[a, J]
|
|
50
|
+
), S = c((e, r) => {
|
|
46
51
|
if (!t.current || e !== t.current) {
|
|
47
52
|
console.error(
|
|
48
53
|
t.current ? `A Journey is already active, Current Journey: ${t.current}, New Journey Request: ${e}` : "addCoachmark was called before setJourney and Journey ID is undefined"
|
|
49
54
|
);
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
|
-
|
|
57
|
+
d((o) => [
|
|
53
58
|
...o,
|
|
54
59
|
{
|
|
55
60
|
...r,
|
|
@@ -57,7 +62,7 @@ const K = W(null), re = ({ children: T, appId: a, userId: c }) => {
|
|
|
57
62
|
// New coachmarks are inactive by default
|
|
58
63
|
}
|
|
59
64
|
]);
|
|
60
|
-
}, []),
|
|
65
|
+
}, []), j = c(
|
|
61
66
|
(e, r = !1, o = 0, C = !1) => {
|
|
62
67
|
if (!t.current || e !== t.current) {
|
|
63
68
|
console.error(
|
|
@@ -65,79 +70,86 @@ const K = W(null), re = ({ children: T, appId: a, userId: c }) => {
|
|
|
65
70
|
);
|
|
66
71
|
return;
|
|
67
72
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
clearTimeout(
|
|
73
|
+
H(C), o !== 0 && d((n) => n.map((u) => ({ ...u, isActive: !1 })));
|
|
74
|
+
const h = setTimeout(() => {
|
|
75
|
+
clearTimeout(h);
|
|
71
76
|
const n = m.current + 1;
|
|
72
|
-
|
|
77
|
+
d((u) => {
|
|
73
78
|
if (n >= u.length || u.length === 0)
|
|
74
|
-
return
|
|
79
|
+
return a(), [];
|
|
75
80
|
m.current = n;
|
|
76
|
-
const
|
|
77
|
-
return
|
|
81
|
+
const k = [...u];
|
|
82
|
+
return k[n].isActive = !0, n > 0 && (k[n - 1].isActive = r), k;
|
|
78
83
|
});
|
|
79
84
|
}, o);
|
|
80
|
-
|
|
85
|
+
w.current.push(h);
|
|
86
|
+
},
|
|
87
|
+
[a]
|
|
88
|
+
), O = c(
|
|
89
|
+
(e) => {
|
|
90
|
+
J(e);
|
|
81
91
|
},
|
|
82
|
-
[
|
|
83
|
-
),
|
|
92
|
+
[J]
|
|
93
|
+
), V = G(
|
|
84
94
|
() => ({
|
|
85
|
-
nextCoachmark:
|
|
95
|
+
nextCoachmark: j,
|
|
86
96
|
setJourney: B,
|
|
87
|
-
addCoachmark:
|
|
88
|
-
clearJourney:
|
|
97
|
+
addCoachmark: S,
|
|
98
|
+
clearJourney: a,
|
|
89
99
|
endJourney: E,
|
|
90
|
-
coachmarks:
|
|
91
|
-
userCompletedJourneyIds:
|
|
92
|
-
isJourneyActive:
|
|
100
|
+
coachmarks: y,
|
|
101
|
+
userCompletedJourneyIds: p,
|
|
102
|
+
isJourneyActive: f,
|
|
103
|
+
trackView: O
|
|
93
104
|
}),
|
|
94
105
|
[
|
|
95
|
-
|
|
106
|
+
j,
|
|
96
107
|
B,
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
S,
|
|
109
|
+
a,
|
|
99
110
|
E,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
y,
|
|
112
|
+
p,
|
|
113
|
+
f,
|
|
114
|
+
O
|
|
103
115
|
]
|
|
104
116
|
);
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
app_id:
|
|
108
|
-
user_id:
|
|
117
|
+
return b(() => {
|
|
118
|
+
l && i && P(i, {
|
|
119
|
+
app_id: l,
|
|
120
|
+
user_id: i,
|
|
109
121
|
journey_status: "COMPLETED"
|
|
110
122
|
});
|
|
111
|
-
}, [
|
|
112
|
-
if (
|
|
113
|
-
const e =
|
|
114
|
-
|
|
123
|
+
}, [l, P, i]), b(() => {
|
|
124
|
+
if (g) {
|
|
125
|
+
const e = g.map((r) => r.journey_id);
|
|
126
|
+
x(e);
|
|
115
127
|
}
|
|
116
|
-
}, [
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
}, [g]), /* @__PURE__ */ W(X.Provider, { value: V, children: [
|
|
129
|
+
f && /* @__PURE__ */ T(
|
|
130
|
+
Q,
|
|
119
131
|
{
|
|
120
132
|
about: "journey-overlay",
|
|
121
|
-
height:
|
|
122
|
-
width:
|
|
123
|
-
$isJourneyBlurred:
|
|
124
|
-
$isBlockingJourney:
|
|
133
|
+
height: $.height,
|
|
134
|
+
width: $.width,
|
|
135
|
+
$isJourneyBlurred: D,
|
|
136
|
+
$isBlockingJourney: q,
|
|
125
137
|
"data-testid": t.current,
|
|
126
|
-
children:
|
|
127
|
-
|
|
138
|
+
children: y.map((e, r) => /* @__PURE__ */ T(
|
|
139
|
+
F,
|
|
128
140
|
{
|
|
129
141
|
coachmark: e,
|
|
130
|
-
isInsideScrollView:
|
|
142
|
+
isInsideScrollView: L
|
|
131
143
|
},
|
|
132
144
|
`coachmark-${r}`
|
|
133
145
|
))
|
|
134
146
|
}
|
|
135
147
|
),
|
|
136
|
-
|
|
148
|
+
U
|
|
137
149
|
] });
|
|
138
150
|
};
|
|
139
151
|
export {
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
X as JourneyContext,
|
|
153
|
+
ne as JourneyProvider
|
|
142
154
|
};
|
|
143
155
|
//# 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 { FC, RefObject } from 'react';\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n TCoachmarkJourneyProps,\n} from './journey-context-types';\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 [isBlockingJourney, setIsBlockingJourney] = useState<boolean>(true);\n const [isJourneyBlurred, setIsJourneyBlurred] = useState<boolean>(false);\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[] | null>(null);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>(undefined);\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const [isScrollableJourney, setIsScrollableJourney] = useState<boolean>(false);\n const [overlaySize, setOverlaySize] = useState({\n height: window.innerHeight,\n width: window.innerWidth,\n });\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const { data: userCompletedJourneys = null, get: getJourneyProgress } = useGetUserJourney();\n\n const setJourney = useCallback(\n (\n id: TJourneyId,\n coachmarks: TCoachmarkJourneyProps[],\n scrollableContRef?: RefObject<HTMLDivElement | null>,\n isBlocking: boolean = true,\n ) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n setIsJourneyActive(true);\n setIsBlockingJourney(isBlocking);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList(\n coachmarks.map((item: TCoachmarkJourneyProps) => {\n return {\n ...item,\n isActive: false, // New coachmarks are inactive by default\n } as ICoachmarkProps;\n }),\n );\n if (scrollableContRef) {\n setOverlaySize({\n height: scrollableContRef.current?.clientHeight || window.innerHeight,\n width: scrollableContRef.current?.clientWidth || window.innerWidth,\n });\n setIsScrollableJourney(true);\n }\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n clearJourney();\n setUserCompletedJourneyIds(prev => {\n if (prev && !prev.includes(journeyId)) {\n return [...prev, journeyId];\n }\n\n return prev;\n });\n // fire the API (doesn’t block the UI)\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: TCoachmarkJourneyProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [\n ...prev,\n {\n ...coachmark,\n isActive: false, // New coachmarks are inactive by default\n } as ICoachmarkProps,\n ]);\n }, []);\n\n const nextCoachmark = useCallback(\n (\n id: TJourneyId,\n keepPrevActive: boolean = false,\n delayInMs: number = 0,\n shouldBlurNextJourney: boolean = false,\n ) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n\n setIsJourneyBlurred(shouldBlurNextJourney);\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: TCoachmarkJourneyProps) => {\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 clearJourney();\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 [clearJourney],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {isJourneyActive && (\n <S.Overlay\n about=\"journey-overlay\"\n height={overlaySize.height}\n width={overlaySize.width}\n $isJourneyBlurred={isJourneyBlurred}\n $isBlockingJourney={isBlockingJourney}\n data-testid={currentJourneyId.current}\n >\n {coachmarkList.map((coachmark, index) => (\n <Coachmark\n key={`coachmark-${index}`}\n coachmark={coachmark}\n isInsideScrollView={isScrollableJourney}\n />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","isBlockingJourney","setIsBlockingJourney","useState","isJourneyBlurred","setIsJourneyBlurred","userCompletedJourneyIds","setUserCompletedJourneyIds","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","isScrollableJourney","setIsScrollableJourney","overlaySize","setOverlaySize","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","useGetUserJourney","setJourney","useCallback","id","coachmarks","scrollableContRef","isBlocking","item","_a","_b","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","shouldBlurNextJourney","prevList","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","jsx","S.Overlay","index","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,KAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAmBC,CAAoB,IAAIC,EAAkB,EAAI,GAClE,CAACC,GAAkBC,CAAmB,IAAIF,EAAkB,EAAK,GACjE,CAACG,GAAyBC,CAA0B,IAAIJ,EAA8B,IAAI,GAC1F,CAACK,GAAeC,CAAgB,IAAIN,EAA4B,CAAE,CAAA,GAClE,CAACO,GAAiBC,CAAkB,IAAIR,EAAS,EAAK,GACtDS,IAAeC,EAAO,EAAE,GACxBC,IAAmBD,EAA+B,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QACpB,OAAOA,EAAY;AAAA,QACnB,mBAAmBd;AAAA,QACnB,oBAAoBH;AAAA,QACpB,eAAaa,EAAiB;AAAA,QAE7B,UAAcN,EAAA,IAAI,CAACgC,GAAWgB,MAC7B,gBAAAF;AAAA,UAACG;AAAA,UAAA;AAAA,YAEC,WAAAjB;AAAA,YACA,oBAAoBxB;AAAA,UAAA;AAAA,UAFf,aAAawC,CAAK;AAAA,QAAA,CAI1B;AAAA,MAAA;AAAA,IACH;AAAA,IAED1D;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 { FC, RefObject } from 'react';\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type { TTrackingId } from '../tracking-id/tracking-id-types';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n TCoachmarkJourneyProps,\n} from './journey-context-types';\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 [isBlockingJourney, setIsBlockingJourney] = useState<boolean>(true);\n const [isJourneyBlurred, setIsJourneyBlurred] = useState<boolean>(false);\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[] | null>(null);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>(undefined);\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const [isScrollableJourney, setIsScrollableJourney] = useState<boolean>(false);\n const [overlaySize, setOverlaySize] = useState({\n height: window.innerHeight,\n width: window.innerWidth,\n });\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const { data: userCompletedJourneys = null, get: getJourneyProgress } = useGetUserJourney();\n\n const saveProgress = useCallback(\n (journeyId: TJourneyId | TTrackingId) => {\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n },\n [appId, postJourneyCompletion, userId],\n );\n\n const setJourney = useCallback(\n (\n id: TJourneyId,\n coachmarks: TCoachmarkJourneyProps[],\n scrollableContRef?: RefObject<HTMLDivElement | null>,\n isBlocking: boolean = true,\n ) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n setIsJourneyActive(true);\n setIsBlockingJourney(isBlocking);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList(\n coachmarks.map((item: TCoachmarkJourneyProps) => {\n return {\n ...item,\n isActive: false, // New coachmarks are inactive by default\n } as ICoachmarkProps;\n }),\n );\n if (scrollableContRef) {\n setOverlaySize({\n height: scrollableContRef.current?.clientHeight || window.innerHeight,\n width: scrollableContRef.current?.clientWidth || window.innerWidth,\n });\n setIsScrollableJourney(true);\n }\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n clearJourney();\n setUserCompletedJourneyIds(prev => {\n if (prev && !prev.includes(journeyId)) {\n return [...prev, journeyId];\n }\n\n return prev;\n });\n saveProgress(journeyId);\n },\n [clearJourney, saveProgress],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: TCoachmarkJourneyProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [\n ...prev,\n {\n ...coachmark,\n isActive: false, // New coachmarks are inactive by default\n } as ICoachmarkProps,\n ]);\n }, []);\n\n const nextCoachmark = useCallback(\n (\n id: TJourneyId,\n keepPrevActive: boolean = false,\n delayInMs: number = 0,\n shouldBlurNextJourney: boolean = false,\n ) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n\n setIsJourneyBlurred(shouldBlurNextJourney);\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: TCoachmarkJourneyProps) => {\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 clearJourney();\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 [clearJourney],\n );\n\n const trackView = useCallback(\n (viewId: TTrackingId) => {\n saveProgress(viewId);\n },\n [saveProgress],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n trackView,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n trackView,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {isJourneyActive && (\n <S.Overlay\n about=\"journey-overlay\"\n height={overlaySize.height}\n width={overlaySize.width}\n $isJourneyBlurred={isJourneyBlurred}\n $isBlockingJourney={isBlockingJourney}\n data-testid={currentJourneyId.current}\n >\n {coachmarkList.map((coachmark, index) => (\n <Coachmark\n key={`coachmark-${index}`}\n coachmark={coachmark}\n isInsideScrollView={isScrollableJourney}\n />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","isBlockingJourney","setIsBlockingJourney","useState","isJourneyBlurred","setIsJourneyBlurred","userCompletedJourneyIds","setUserCompletedJourneyIds","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","isScrollableJourney","setIsScrollableJourney","overlaySize","setOverlaySize","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","useGetUserJourney","saveProgress","useCallback","journeyId","setJourney","id","coachmarks","scrollableContRef","isBlocking","item","_a","_b","clearJourney","timer","endJourney","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","shouldBlurNextJourney","prevList","currIndex","updatedCoachmarkList","trackView","viewId","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","jsx","S.Overlay","index","Coachmark"],"mappings":";;;;;AAgBa,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,KAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAmBC,CAAoB,IAAIC,EAAkB,EAAI,GAClE,CAACC,GAAkBC,CAAmB,IAAIF,EAAkB,EAAK,GACjE,CAACG,GAAyBC,CAA0B,IAAIJ,EAA8B,IAAI,GAC1F,CAACK,GAAeC,CAAgB,IAAIN,EAA4B,CAAE,CAAA,GAClE,CAACO,GAAiBC,CAAkB,IAAIR,EAAS,EAAK,GACtDS,IAAeC,EAAO,EAAE,GACxBC,IAAmBD,EAA+B,MAAS,GAC3DE,IAAYF,EAAwC,CAAA,CAAE,GAEtD,CAACG,GAAqBC,CAAsB,IAAId,EAAkB,EAAK,GACvE,CAACe,GAAaC,CAAc,IAAIhB,EAAS;AAAA,IAC7C,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO;AAAA,EAAA,CACf,GAEK,EAAE,MAAMiB,EAAsB,IAAIC,EAAmB,GACrD,EAAE,MAAMC,IAAwB,MAAM,KAAKC,EAAA,IAAuBC,KAElEC,IAAeC;AAAA,IACnB,CAACC,MAAwC;AACjB,MAAAP,EAAA;AAAA,QACpB,QAAQrB;AAAA,QACR,SAASC;AAAA,QACT,YAAY2B;AAAA,QACZ,gBAAgB;AAAA,MAAA,CACjB;AAAA,IACH;AAAA,IACA,CAAC5B,GAAOqB,GAAuBpB,CAAM;AAAA,EAAA,GAGjC4B,IAAaF;AAAA,IACjB,CACEG,GACAC,GACAC,GACAC,IAAsB,OACnB;;AACC,UAAAxB,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEM,EAAiB,OAAO,0BAA0Be,CAAE;AAAA,QAAA;AAGvH;AAAA,MACF;AACA,MAAAlB,EAAmB,EAAI,GACvBT,EAAqB8B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AA,MACA,iBAAAI;AAAA,MACA,WAAAuC;AAAA,IAAA;AAAA,IAEF;AAAA,MACEP;AAAA,MACAd;AAAA,MACAY;AAAA,MACAJ;AAAA,MACAE;AAAA,MACA9B;AAAA,MACAF;AAAA,MACAI;AAAA,MACAuC;AAAA,IACF;AAAA,EAAA;AAIF,SAAAI,EAAU,MAAM;AACd,IAAItD,KAASC,KACXuB,EAAmBvB,GAAQ;AAAA,MACzB,QAAQD;AAAA,MACR,SAASC;AAAA,MACT,gBAAgB;AAAA,IAAA,CACjB;AAAA,EAEF,GAAA,CAACD,GAAOwB,GAAoBvB,CAAM,CAAC,GAGtCqD,EAAU,MAAM;AACd,QAAI/B,GAAuB;AACzB,YAAMgC,IAA2BhC,EAAsB,IAAI,CAAAiC,MAAWA,EAAQ,UAAU;AAExF,MAAAhD,EAA2B+C,CAAwB;AAAA,IACrD;AAAA,EAAA,GACC,CAAChC,CAAqB,CAAC,GAGvB,gBAAAkC,EAAA7D,EAAe,UAAf,EAAwB,OAAOwD,GAC7B,UAAA;AAAA,IACCzC,KAAA,gBAAA+C;AAAA,MAACC;AAAAA,MAAA;AAAA,QACC,OAAM;AAAA,QACN,QAAQxC,EAAY;AAAA,QACpB,OAAOA,EAAY;AAAA,QACnB,mBAAmBd;AAAA,QACnB,oBAAoBH;AAAA,QACpB,eAAaa,EAAiB;AAAA,QAE7B,UAAcN,EAAA,IAAI,CAACiC,GAAWkB,MAC7B,gBAAAF;AAAA,UAACG;AAAA,UAAA;AAAA,YAEC,WAAAnB;AAAA,YACA,oBAAoBzB;AAAA,UAAA;AAAA,UAFf,aAAa2C,CAAK;AAAA,QAAA,CAI1B;AAAA,MAAA;AAAA,IACH;AAAA,IAED7D;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useCallback as i } from "react";
|
|
2
|
+
import m from "../../communication/hooks/use-inclass-message-broker/use-inclass-message-broker.js";
|
|
3
|
+
import { useUIContext as E } from "../../ui/context/context.js";
|
|
4
|
+
import { STICKERS_ANALYTICS_EVENT as d } from "../stickers-analytics-events.js";
|
|
5
|
+
import { useStickers as k } from "../stickers-effects/hooks/use-stickers.js";
|
|
6
|
+
import { useStickersErrorLogger as f } from "./use-stickers-error-logger.js";
|
|
7
|
+
const u = (t) => {
|
|
8
|
+
const { publish: e } = m({
|
|
9
|
+
studentClassroomId: t
|
|
10
|
+
}), { onEvent: c } = E(), n = f(), { showSticker: s } = k();
|
|
11
|
+
return i(
|
|
12
|
+
(o, S) => {
|
|
13
|
+
const a = {
|
|
14
|
+
classroom_id: t,
|
|
15
|
+
sticker: o.id
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
const r = {
|
|
19
|
+
message: {
|
|
20
|
+
data: {
|
|
21
|
+
selectedSticker: {
|
|
22
|
+
id: o.id,
|
|
23
|
+
name: o.name
|
|
24
|
+
},
|
|
25
|
+
effectId: S
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
type: "STICKERS"
|
|
29
|
+
};
|
|
30
|
+
s(r), e == null || e({
|
|
31
|
+
eventName: "STICKERS",
|
|
32
|
+
eventPayload: r
|
|
33
|
+
}), c(d.STICKER_SENT, a);
|
|
34
|
+
} catch (r) {
|
|
35
|
+
n(r, { baseEventData: a });
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
[n, e, s, t, c]
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
u as useHandleStickerSend
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=use-handle-sticker-send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-handle-sticker-send.js","sources":["../../../../src/features/stickers/hooks/use-handle-sticker-send.tsx"],"sourcesContent":["import { useCallback } from 'react';\n\nimport useInClassMessageBroker from '../../communication/hooks/use-inclass-message-broker/use-inclass-message-broker';\nimport { useUIContext } from '../../ui/context/context';\nimport { STICKERS_ANALYTICS_EVENT } from '../stickers-analytics-events';\nimport { useStickers } from '../stickers-effects/hooks/use-stickers';\nimport type { IStickerData, TStickerAnimationEffects, TStickersPayload } from '../stickers-types';\nimport { useStickersErrorLogger } from './use-stickers-error-logger';\n\nexport const useHandleStickerSend = (studentClassroomId?: string) => {\n const { publish } = useInClassMessageBroker({\n studentClassroomId,\n });\n\n const { onEvent: trackEvent } = useUIContext();\n const logError = useStickersErrorLogger();\n\n const { showSticker } = useStickers();\n\n const sendSticker = useCallback(\n (sticker: IStickerData, effect: TStickerAnimationEffects) => {\n const baseEventData = {\n classroom_id: studentClassroomId,\n sticker: sticker.id,\n };\n\n try {\n const payload: TStickersPayload = {\n message: {\n data: {\n selectedSticker: {\n id: sticker.id,\n name: sticker.name,\n },\n effectId: effect,\n },\n },\n type: 'STICKERS',\n };\n\n showSticker(payload);\n\n publish?.({\n eventName: 'STICKERS',\n eventPayload: payload,\n });\n\n trackEvent(STICKERS_ANALYTICS_EVENT.STICKER_SENT, baseEventData);\n } catch (error) {\n logError(error, { baseEventData });\n }\n },\n [logError, publish, showSticker, studentClassroomId, trackEvent],\n );\n\n return sendSticker;\n};\n"],"names":["useHandleStickerSend","studentClassroomId","publish","useInClassMessageBroker","trackEvent","useUIContext","logError","useStickersErrorLogger","showSticker","useStickers","useCallback","sticker","effect","baseEventData","payload","STICKERS_ANALYTICS_EVENT","error"],"mappings":";;;;;;AASa,MAAAA,IAAuB,CAACC,MAAgC;AAC7D,QAAA,EAAE,SAAAC,EAAQ,IAAIC,EAAwB;AAAA,IAC1C,oBAAAF;AAAA,EAAA,CACD,GAEK,EAAE,SAASG,EAAW,IAAIC,EAAa,GACvCC,IAAWC,KAEX,EAAE,aAAAC,MAAgBC;AAsCjB,SApCaC;AAAA,IAClB,CAACC,GAAuBC,MAAqC;AAC3D,YAAMC,IAAgB;AAAA,QACpB,cAAcZ;AAAA,QACd,SAASU,EAAQ;AAAA,MAAA;AAGf,UAAA;AACF,cAAMG,IAA4B;AAAA,UAChC,SAAS;AAAA,YACP,MAAM;AAAA,cACJ,iBAAiB;AAAA,gBACf,IAAIH,EAAQ;AAAA,gBACZ,MAAMA,EAAQ;AAAA,cAChB;AAAA,cACA,UAAUC;AAAA,YACZ;AAAA,UACF;AAAA,UACA,MAAM;AAAA,QAAA;AAGR,QAAAJ,EAAYM,CAAO,GAETZ,KAAA,QAAAA,EAAA;AAAA,UACR,WAAW;AAAA,UACX,cAAcY;AAAA,QAAA,IAGLV,EAAAW,EAAyB,cAAcF,CAAa;AAAA,eACxDG,GAAO;AACL,QAAAV,EAAAU,GAAO,EAAE,eAAAH,EAAA,CAAe;AAAA,MACnC;AAAA,IACF;AAAA,IACA,CAACP,GAAUJ,GAASM,GAAaP,GAAoBG,CAAU;AAAA,EAAA;AAInE;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useUIContext as E } from "../../ui/context/context.js";
|
|
2
|
+
import { STICKERS_ANALYTICS_EVENT as i } from "../stickers-analytics-events.js";
|
|
3
|
+
function f() {
|
|
4
|
+
const { onEvent: s } = E();
|
|
5
|
+
return (t, o) => {
|
|
6
|
+
let e = "Unknown error", n;
|
|
7
|
+
t instanceof Error ? (e = t.message, n = t.stack) : typeof t == "string" && (e = t), s(i.STICKER_LOG_ERROR, {
|
|
8
|
+
message: e,
|
|
9
|
+
stack: n,
|
|
10
|
+
...o
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
f as useStickersErrorLogger
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=use-stickers-error-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-stickers-error-logger.js","sources":["../../../../src/features/stickers/hooks/use-stickers-error-logger.ts"],"sourcesContent":["import { useUIContext } from '../../ui/context/context';\nimport { STICKERS_ANALYTICS_EVENT } from '../stickers-analytics-events';\n\nexport function useStickersErrorLogger() {\n const { onEvent: trackEvent } = useUIContext();\n\n return (error: unknown, context?: Record<string, unknown>) => {\n let message = 'Unknown error';\n let stack: string | undefined;\n\n if (error instanceof Error) {\n message = error.message;\n stack = error.stack;\n } else if (typeof error === 'string') {\n message = error;\n }\n\n trackEvent(STICKERS_ANALYTICS_EVENT.STICKER_LOG_ERROR, {\n message,\n stack,\n ...context,\n });\n };\n}\n"],"names":["useStickersErrorLogger","trackEvent","useUIContext","error","context","message","stack","STICKERS_ANALYTICS_EVENT"],"mappings":";;AAGO,SAASA,IAAyB;AACvC,QAAM,EAAE,SAASC,EAAW,IAAIC,EAAa;AAEtC,SAAA,CAACC,GAAgBC,MAAsC;AAC5D,QAAIC,IAAU,iBACVC;AAEJ,IAAIH,aAAiB,SACnBE,IAAUF,EAAM,SAChBG,IAAQH,EAAM,SACL,OAAOA,KAAU,aAChBE,IAAAF,IAGZF,EAAWM,EAAyB,mBAAmB;AAAA,MACrD,SAAAF;AAAA,MACA,OAAAC;AAAA,MACA,GAAGF;AAAA,IAAA,CACJ;AAAA,EAAA;AAEL;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback as m, useMemo as h } from "react";
|
|
3
|
-
import { JOURNEY_ID_TEACHER as t } from "
|
|
4
|
-
import { IndicatorType as C } from "
|
|
5
|
-
import { useJourney as T } from "
|
|
6
|
-
import y from "
|
|
7
|
-
import O from "
|
|
8
|
-
import S from "
|
|
9
|
-
import u from "
|
|
3
|
+
import { JOURNEY_ID_TEACHER as t } from "../../../journey/journey-id/journey-id-teacher.js";
|
|
4
|
+
import { IndicatorType as C } from "../../../journey/use-journey/constants.js";
|
|
5
|
+
import { useJourney as T } from "../../../journey/use-journey/use-journey.js";
|
|
6
|
+
import y from "../../../ui/buttons/button/button.js";
|
|
7
|
+
import O from "../../../ui/layout/flex-view.js";
|
|
8
|
+
import S from "../../../ui/separator/separator.js";
|
|
9
|
+
import u from "../../../ui/text/text.js";
|
|
10
10
|
const x = ({
|
|
11
11
|
triggerRef: o,
|
|
12
12
|
triggerElement: n,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-stickers-journey.js","sources":["../../../../../src/features/stickers/hooks/use-stickers-journey/use-stickers-journey.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react';\n\nimport { JOURNEY_ID_TEACHER } from '../../../journey/journey-id/journey-id-teacher';\nimport { IndicatorType } from '../../../journey/use-journey/constants';\nimport { useJourney } from '../../../journey/use-journey/use-journey';\nimport type { IArrowTooltipProps } from '../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport Button from '../../../ui/buttons/button/button';\nimport FlexView from '../../../ui/layout/flex-view';\nimport Separator from '../../../ui/separator/separator';\nimport Text from '../../../ui/text/text';\nimport type { IUseTeacherStickersJourneyProps } from './use-stickers-journey-types';\n\nexport const useStickersJourney = ({\n triggerRef,\n triggerElement,\n tooltipConfig,\n}: IUseTeacherStickersJourneyProps) => {\n const { setJourney, nextCoachmark, endJourney } = useJourney();\n\n const endTeacherStickersOnboarding = useCallback(() => {\n endJourney(JOURNEY_ID_TEACHER.STICKERS_INTRO_JOURNEY);\n }, [endJourney]);\n\n const startTeacherStickersJourney = useCallback(() => {\n if (!triggerRef.current) return;\n\n const indicatorPayload = {\n position: tooltipConfig.position,\n tooltipXCoOrdinates: tooltipConfig.tooltipXCoOrdinates,\n tooltipYCoOrdinates: tooltipConfig.tooltipYCoOrdinates,\n arrowXCoOrdinates: tooltipConfig.arrowXCoOrdinates,\n arrowYCoOrdinates: tooltipConfig.arrowYCoOrdinates,\n borderColor: 'BLACK',\n arrowColor: 'BLACK',\n backgroundColor: 'PURPLE_4',\n tooltipItem: (\n <FlexView>\n <FlexView>\n <Text\n $renderOnMobileAs=\"ab3\"\n $renderAs=\"ab3\"\n as=\"span\"\n $inline={true}\n $whiteSpace=\"normal\"\n >\n <Text $renderAs=\"ab3-bold\" as=\"span\" $inline={true}>\n New Stickers\n </Text>{' '}\n - Use them to celebrate little moments of joy!\n </Text>\n </FlexView>\n <Separator height={10} />\n <Button\n renderAs=\"secondary\"\n label=\"Got It\"\n size=\"xsmall\"\n width=\"50%\"\n onClick={endTeacherStickersOnboarding}\n />\n </FlexView>\n ),\n } as IArrowTooltipProps;\n\n setJourney(\n JOURNEY_ID_TEACHER.STICKERS_INTRO_JOURNEY,\n [\n {\n originalElementToHighlightRef: triggerRef,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: triggerElement,\n indicator: indicatorPayload,\n },\n ],\n undefined,\n false,\n );\n\n nextCoachmark(JOURNEY_ID_TEACHER.STICKERS_INTRO_JOURNEY);\n }, [\n triggerRef,\n triggerElement,\n tooltipConfig.position,\n tooltipConfig.tooltipXCoOrdinates,\n tooltipConfig.tooltipYCoOrdinates,\n tooltipConfig.arrowXCoOrdinates,\n tooltipConfig.arrowYCoOrdinates,\n endTeacherStickersOnboarding,\n setJourney,\n nextCoachmark,\n ]);\n\n const stickerJourney = useMemo(\n () => ({\n startTeacherStickersJourney,\n }),\n [startTeacherStickersJourney],\n );\n\n return stickerJourney;\n};\n"],"names":["useStickersJourney","triggerRef","triggerElement","tooltipConfig","setJourney","nextCoachmark","endJourney","useJourney","endTeacherStickersOnboarding","useCallback","JOURNEY_ID_TEACHER","startTeacherStickersJourney","indicatorPayload","FlexView","jsx","jsxs","Text","Separator","Button","IndicatorType","useMemo"],"mappings":";;;;;;;;;AAYO,MAAMA,IAAqB,CAAC;AAAA,EACjC,YAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,eAAAC;AACF,MAAuC;AACrC,QAAM,EAAE,YAAAC,GAAY,eAAAC,GAAe,YAAAC,MAAeC,EAAW,GAEvDC,IAA+BC,EAAY,MAAM;AACrD,IAAAH,EAAWI,EAAmB,sBAAsB;AAAA,EAAA,GACnD,CAACJ,CAAU,CAAC,GAETK,IAA8BF,EAAY,MAAM;AAChD,QAAA,CAACR,EAAW,QAAS;AAEzB,UAAMW,IAAmB;AAAA,MACvB,UAAUT,EAAc;AAAA,MACxB,qBAA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AAAA,IAAA;AAAA,IAEF,CAACA,CAA2B;AAAA,EAAA;AAIhC;"}
|
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { memo as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { jsxs as L, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { memo as $, useState as f, useRef as k, useCallback as r } from "react";
|
|
3
|
+
import j from "../../../../ui/lottie-animation/lottie-animation.js";
|
|
4
|
+
import { useStickersErrorLogger as C } from "../../../hooks/use-stickers-error-logger.js";
|
|
5
|
+
import { StickerContainer as R, StaticEmoji as x, LottieContainer as y } from "./sticker-styled.js";
|
|
6
|
+
const A = {
|
|
6
7
|
renderer: "canvas"
|
|
7
|
-
},
|
|
8
|
-
const [c,
|
|
8
|
+
}, H = ({ emoji: h, lottieUrl: a, size: n = 48, onClick: S, disabled: t = !1 }) => {
|
|
9
|
+
const [c, l] = f(!1), [i, d] = f("idle"), o = k(null), m = C(), v = r(() => {
|
|
9
10
|
var e;
|
|
10
|
-
|
|
11
|
-
}, []), S = r(() => {
|
|
12
|
-
l("error");
|
|
11
|
+
d("loaded"), (e = o.current) == null || e.play();
|
|
13
12
|
}, []), p = r(() => {
|
|
13
|
+
d("error"), m("Error in loading the lottie");
|
|
14
|
+
}, [m]), E = r(() => {
|
|
14
15
|
var e;
|
|
15
|
-
|
|
16
|
-
}, [i]),
|
|
16
|
+
l(!0), i === "loaded" && ((e = o.current) == null || e.play());
|
|
17
|
+
}, [i]), g = r(() => {
|
|
17
18
|
var e;
|
|
18
|
-
|
|
19
|
-
}, []),
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
-
|
|
19
|
+
l(!1), (e = o.current) == null || e.goToAndStop(0, !0);
|
|
20
|
+
}, []), u = c && i === "loaded";
|
|
21
|
+
return /* @__PURE__ */ L(
|
|
22
|
+
R,
|
|
22
23
|
{
|
|
23
24
|
$size: n,
|
|
24
25
|
$disabled: t,
|
|
25
|
-
onPointerEnter: t ? void 0 :
|
|
26
|
-
onPointerLeave: t ? void 0 :
|
|
27
|
-
onClick: t ? void 0 :
|
|
26
|
+
onPointerEnter: t ? void 0 : E,
|
|
27
|
+
onPointerLeave: t ? void 0 : g,
|
|
28
|
+
onClick: t ? void 0 : S,
|
|
28
29
|
children: [
|
|
29
|
-
/* @__PURE__ */ s(
|
|
30
|
-
/* @__PURE__ */ s(
|
|
31
|
-
|
|
30
|
+
/* @__PURE__ */ s(x, { $size: n, $visible: !u, children: h }),
|
|
31
|
+
/* @__PURE__ */ s(y, { $size: n, $visible: u, children: c && a && /* @__PURE__ */ s(
|
|
32
|
+
j,
|
|
32
33
|
{
|
|
33
34
|
ref: o,
|
|
34
35
|
src: a,
|
|
35
36
|
width: "100%",
|
|
36
37
|
height: "100%",
|
|
37
|
-
settings:
|
|
38
|
+
settings: A,
|
|
38
39
|
onRender: v,
|
|
39
|
-
onError:
|
|
40
|
+
onError: p
|
|
40
41
|
}
|
|
41
42
|
) })
|
|
42
43
|
]
|
|
43
44
|
}
|
|
44
45
|
);
|
|
45
|
-
},
|
|
46
|
+
}, I = $(H);
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
+
I as default
|
|
48
49
|
};
|
|
49
50
|
//# sourceMappingURL=sticker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sticker.js","sources":["../../../../../../src/features/stickers/sticker-selector/comps/sticker/sticker.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { memo, useCallback, useRef, useState } from 'react';\n\nimport LottieAnimation from '../../../../ui/lottie-animation/lottie-animation';\nimport type { ILottieAnimationRef } from '../../../../ui/lottie-animation/types';\nimport * as Styled from './sticker-styled';\nimport type { IStickerProps } from './sticker-types';\n\nconst renderSettings = {\n renderer: 'canvas' as const,\n};\n\nconst Sticker: FC<IStickerProps> = ({ emoji, lottieUrl, size = 48, onClick, disabled = false }) => {\n const [isHovered, setIsHovered] = useState(false);\n const [lottieState, setLottieState] = useState<'idle' | 'loaded' | 'error'>('idle');\n const lottieRef = useRef<ILottieAnimationRef>(null);\n\n const handleLottieReady = useCallback(() => {\n setLottieState('loaded');\n lottieRef.current?.play();\n }, []);\n\n const handleLottieError = useCallback(() => {\n setLottieState('error');\n }, []);\n\n const handleMouseEnter = useCallback(() => {\n setIsHovered(true);\n\n if (lottieState === 'loaded') {\n lottieRef.current?.play();\n }\n }, [lottieState]);\n\n const handleMouseLeave = useCallback(() => {\n setIsHovered(false);\n lottieRef.current?.goToAndStop(0, true);\n }, []);\n\n const hideStaticEmoji = isHovered && lottieState === 'loaded';\n\n return (\n <Styled.StickerContainer\n $size={size}\n $disabled={disabled}\n onPointerEnter={disabled ? undefined : handleMouseEnter}\n onPointerLeave={disabled ? undefined : handleMouseLeave}\n onClick={disabled ? undefined : onClick}\n >\n <Styled.StaticEmoji $size={size} $visible={!hideStaticEmoji}>\n {emoji}\n </Styled.StaticEmoji>\n\n <Styled.LottieContainer $size={size} $visible={hideStaticEmoji}>\n {isHovered && lottieUrl && (\n <LottieAnimation\n ref={lottieRef}\n src={lottieUrl}\n width=\"100%\"\n height=\"100%\"\n settings={renderSettings}\n onRender={handleLottieReady}\n onError={handleLottieError}\n />\n )}\n </Styled.LottieContainer>\n </Styled.StickerContainer>\n );\n};\n\nexport default memo(Sticker);\n"],"names":["renderSettings","Sticker","emoji","lottieUrl","size","onClick","disabled","isHovered","setIsHovered","useState","lottieState","setLottieState","lottieRef","useRef","handleLottieReady","useCallback","_a","handleLottieError","handleMouseEnter","handleMouseLeave","hideStaticEmoji","jsxs","Styled.StickerContainer","jsx","Styled.StaticEmoji","Styled.LottieContainer","LottieAnimation","Sticker$1","memo"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sticker.js","sources":["../../../../../../src/features/stickers/sticker-selector/comps/sticker/sticker.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { memo, useCallback, useRef, useState } from 'react';\n\nimport LottieAnimation from '../../../../ui/lottie-animation/lottie-animation';\nimport type { ILottieAnimationRef } from '../../../../ui/lottie-animation/types';\nimport { useStickersErrorLogger } from '../../../hooks/use-stickers-error-logger';\nimport * as Styled from './sticker-styled';\nimport type { IStickerProps } from './sticker-types';\n\nconst renderSettings = {\n renderer: 'canvas' as const,\n};\n\nconst Sticker: FC<IStickerProps> = ({ emoji, lottieUrl, size = 48, onClick, disabled = false }) => {\n const [isHovered, setIsHovered] = useState(false);\n const [lottieState, setLottieState] = useState<'idle' | 'loaded' | 'error'>('idle');\n const lottieRef = useRef<ILottieAnimationRef>(null);\n\n const logError = useStickersErrorLogger();\n\n const handleLottieReady = useCallback(() => {\n setLottieState('loaded');\n lottieRef.current?.play();\n }, []);\n\n const handleLottieError = useCallback(() => {\n setLottieState('error');\n logError('Error in loading the lottie');\n }, [logError]);\n\n const handleMouseEnter = useCallback(() => {\n setIsHovered(true);\n\n if (lottieState === 'loaded') {\n lottieRef.current?.play();\n }\n }, [lottieState]);\n\n const handleMouseLeave = useCallback(() => {\n setIsHovered(false);\n lottieRef.current?.goToAndStop(0, true);\n }, []);\n\n const hideStaticEmoji = isHovered && lottieState === 'loaded';\n\n return (\n <Styled.StickerContainer\n $size={size}\n $disabled={disabled}\n onPointerEnter={disabled ? undefined : handleMouseEnter}\n onPointerLeave={disabled ? undefined : handleMouseLeave}\n onClick={disabled ? undefined : onClick}\n >\n <Styled.StaticEmoji $size={size} $visible={!hideStaticEmoji}>\n {emoji}\n </Styled.StaticEmoji>\n\n <Styled.LottieContainer $size={size} $visible={hideStaticEmoji}>\n {isHovered && lottieUrl && (\n <LottieAnimation\n ref={lottieRef}\n src={lottieUrl}\n width=\"100%\"\n height=\"100%\"\n settings={renderSettings}\n onRender={handleLottieReady}\n onError={handleLottieError}\n />\n )}\n </Styled.LottieContainer>\n </Styled.StickerContainer>\n );\n};\n\nexport default memo(Sticker);\n"],"names":["renderSettings","Sticker","emoji","lottieUrl","size","onClick","disabled","isHovered","setIsHovered","useState","lottieState","setLottieState","lottieRef","useRef","logError","useStickersErrorLogger","handleLottieReady","useCallback","_a","handleLottieError","handleMouseEnter","handleMouseLeave","hideStaticEmoji","jsxs","Styled.StickerContainer","jsx","Styled.StaticEmoji","Styled.LottieContainer","LottieAnimation","Sticker$1","memo"],"mappings":";;;;;AASA,MAAMA,IAAiB;AAAA,EACrB,UAAU;AACZ,GAEMC,IAA6B,CAAC,EAAE,OAAAC,GAAO,WAAAC,GAAW,MAAAC,IAAO,IAAI,SAAAC,GAAS,UAAAC,IAAW,SAAY;AACjG,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1C,CAACC,GAAaC,CAAc,IAAIF,EAAsC,MAAM,GAC5EG,IAAYC,EAA4B,IAAI,GAE5CC,IAAWC,KAEXC,IAAoBC,EAAY,MAAM;;AAC1C,IAAAN,EAAe,QAAQ,IACvBO,IAAAN,EAAU,YAAV,QAAAM,EAAmB;AAAA,EACrB,GAAG,CAAE,CAAA,GAECC,IAAoBF,EAAY,MAAM;AAC1C,IAAAN,EAAe,OAAO,GACtBG,EAAS,6BAA6B;AAAA,EAAA,GACrC,CAACA,CAAQ,CAAC,GAEPM,IAAmBH,EAAY,MAAM;;AACzC,IAAAT,EAAa,EAAI,GAEbE,MAAgB,cAClBQ,IAAAN,EAAU,YAAV,QAAAM,EAAmB;AAAA,EACrB,GACC,CAACR,CAAW,CAAC,GAEVW,IAAmBJ,EAAY,MAAM;;AACzC,IAAAT,EAAa,EAAK,IACRU,IAAAN,EAAA,YAAA,QAAAM,EAAS,YAAY,GAAG;AAAA,EACpC,GAAG,CAAE,CAAA,GAECI,IAAkBf,KAAaG,MAAgB;AAGnD,SAAA,gBAAAa;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,OAAOpB;AAAA,MACP,WAAWE;AAAA,MACX,gBAAgBA,IAAW,SAAYc;AAAA,MACvC,gBAAgBd,IAAW,SAAYe;AAAA,MACvC,SAASf,IAAW,SAAYD;AAAA,MAEhC,UAAA;AAAA,QAAC,gBAAAo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