@cuemath/leap 3.5.11-ak2 → 3.5.11-ak3
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.
|
@@ -9,7 +9,7 @@ const X = M(null), ne = ({ children: U, appId: l, userId: i }) => {
|
|
|
9
9
|
width: document.documentElement.clientWidth
|
|
10
10
|
}), { post: E } = I(), { data: C = null, get: _ } = K(), J = c(
|
|
11
11
|
(e) => {
|
|
12
|
-
E({
|
|
12
|
+
x((r) => r && !r.includes(e) ? [...r, e] : r), E({
|
|
13
13
|
app_id: l,
|
|
14
14
|
user_id: i,
|
|
15
15
|
journey_id: e,
|
|
@@ -44,7 +44,7 @@ const X = M(null), ne = ({ children: U, appId: l, userId: i }) => {
|
|
|
44
44
|
}), g.current = [], t.current = void 0, h.current = -1, d([]), A(!1);
|
|
45
45
|
}, []), B = c(
|
|
46
46
|
(e) => {
|
|
47
|
-
a(),
|
|
47
|
+
a(), J(e);
|
|
48
48
|
},
|
|
49
49
|
[a, J]
|
|
50
50
|
), S = c((e, r) => {
|
|
@@ -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 {\n createContext,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type FC,\n type RefObject,\n} 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: document.documentElement.clientHeight,\n width: document.documentElement.clientWidth,\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":";;;;;AAwBa,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,SAAS,gBAAgB;AAAA,IACjC,OAAO,SAAS,gBAAgB;AAAA,EAAA,CACjC,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,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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;"}
|
|
1
|
+
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport {\n createContext,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type FC,\n type RefObject,\n} 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<\n (TJourneyId | TTrackingId)[] | null\n >(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: document.documentElement.clientHeight,\n width: document.documentElement.clientWidth,\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 setUserCompletedJourneyIds(prev => {\n if (prev && !prev.includes(journeyId)) {\n return [...prev, journeyId];\n }\n\n return prev;\n });\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 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","prev","setJourney","id","coachmarks","scrollableContRef","isBlocking","item","_a","_b","clearJourney","timer","endJourney","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","shouldBlurNextJourney","prevList","currIndex","updatedCoachmarkList","trackView","viewId","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","jsx","S.Overlay","index","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