@cuemath/leap 3.3.24-as2 → 3.3.24-as3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-class-time-logic.js","sources":["../../../../../src/features/ui/timers/class-time/use-class-time-logic.ts"],"sourcesContent":["import type { TColorNames } from '../../types';\nimport type { IClassTimeProps } from './class-time-types';\n\nimport { useState, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { ANIMATION_TIME, getClockColor, LAST_FIVE, START_TIMER } from './constants';\n\nexport const useClassTimeLogic = (props: IClassTimeProps, isTabActive: boolean) => {\n const {\n classDuration,\n classStartedTime,\n extendedTime,\n ongoing,\n onComplete,\n onExtendClass,\n onExtendedTimeStart,\n showExtendIcon = false,\n } = props;\n\n // Core calculations\n const elapsedTime = (+new Date() - +classStartedTime) / 1000;\n const remainingTime = Math.floor(classDuration - elapsedTime);\n // Extended time logic\n const hasExtendedTimeStarted = useMemo(() => {\n if (!extendedTime) return false;\n\n const orgRemainingTime = Math.floor(classDuration - elapsedTime);\n\n return orgRemainingTime <= extendedTime * 60;\n }, [classDuration, extendedTime, elapsedTime]);\n const [extendedTimeStarted, setExtendedTimeStarted] = useState(hasExtendedTimeStarted);\n\n const endTime = useMemo(\n () => classDuration + +classStartedTime / 1000,\n [classDuration, classStartedTime],\n );\n\n const handleStartExtendedTime = useCallback(() => {\n setExtendedTimeStarted(true);\n onExtendedTimeStart?.();\n }, [onExtendedTimeStart]);\n\n // Timer/Clock switching logic\n const canStartTimer = useMemo(() => {\n return !!(elapsedTime >= classDuration - START_TIMER || extendedTimeStarted || extendedTime);\n }, [elapsedTime, classDuration, extendedTimeStarted, extendedTime]);\n\n const [startTimer, setStartTimer] = useState(canStartTimer);\n\n // Animation state\n const [animateClock, setAnimateClock] = useState(false);\n\n const handleStartAnimation = useCallback(() => {\n setAnimateClock(true);\n }, []);\n\n // Reminders logic\n const animationReminders = useMemo(\n () => [\n {\n at: ANIMATION_TIME.LAST_TEN,\n callback: handleStartAnimation,\n id: 'rem-10min',\n },\n {\n at: ANIMATION_TIME.LAST_FIVE,\n callback: handleStartAnimation,\n id: 'rem-5min',\n },\n ],\n [handleStartAnimation],\n );\n\n const firedReminders = useRef<Set<string>>(new Set());\n const nextReminder = useMemo(\n () =>\n animationReminders\n .filter(r => {\n const key = r.id || `multi-reminder-${r.at}`;\n const alreadyFired = firedReminders.current.has(key);\n\n return !alreadyFired && remainingTime >= r.at;\n })\n .sort((a, b) => b.at - a.at)[0],\n [animationReminders, remainingTime],\n );\n\n const handleMultiReminder = useCallback(() => {\n if (!nextReminder) return;\n\n const key = nextReminder.id || `multi-reminder-${nextReminder.at}`;\n\n firedReminders.current.add(key);\n\n if (typeof nextReminder.callback === 'function') {\n nextReminder.callback();\n }\n }, [nextReminder]);\n\n // Timer completion logic\n const handleTimerComplete = useCallback(() => {\n if (extendedTime && !extendedTimeStarted) {\n handleStartExtendedTime();\n\n return;\n }\n onComplete?.();\n }, [extendedTime, extendedTimeStarted, onComplete, handleStartExtendedTime]);\n\n // Effects\n useEffect(() => {\n const isClassCompleted =\n +new Date() / 1000 >= +classStartedTime / 1000 + classDuration && classDuration;\n\n if (isTabActive && isClassCompleted) {\n onComplete?.();\n }\n }, [classDuration, classStartedTime, isTabActive, onComplete]);\n\n useEffect(() => {\n if (isTabActive && hasExtendedTimeStarted && !extendedTimeStarted) {\n handleStartExtendedTime();\n }\n }, [isTabActive, handleStartExtendedTime, extendedTimeStarted, hasExtendedTimeStarted]);\n\n useEffect(() => {\n if (classDuration && classStartedTime && isTabActive) {\n setStartTimer(canStartTimer);\n }\n }, [classStartedTime, classDuration, canStartTimer, isTabActive]);\n\n const timerProps = {\n endTime: endTime,\n onComplete: handleTimerComplete,\n reminder: nextReminder?.at,\n onReminder: handleMultiReminder,\n };\n\n const clockProps = {\n completionTime: classDuration - ANIMATION_TIME.LAST_TEN,\n onComplete: handleStartAnimation,\n startedOn: new Date(classStartedTime),\n };\n\n const animationProps = {\n showRipple: !animateClock && startTimer,\n rippleColor: (remainingTime <= LAST_FIVE ? 'ORANGE_3' : 'YELLOW_3') as TColorNames,\n showExtendOverlay:\n Math.floor(classDuration - (+new Date() - +classStartedTime) / 1000) <=\n ANIMATION_TIME.LAST_FIVE && animateClock,\n warningProps: {\n animateClock,\n classStartedTime: +classStartedTime,\n duration: classDuration,\n onExtendClass,\n setStartTimer,\n setAnimateClock,\n showExtendIcon: !extendedTimeStarted && showExtendIcon,\n },\n };\n\n return {\n shouldRender: !!(ongoing && !(elapsedTime >= 0 && remainingTime <= 0)),\n startTimer,\n clockColor: getClockColor({\n remainingTime,\n extendedTime: extendedTime || 0,\n extendedTimeStarted,\n }),\n timerProps,\n clockProps,\n animationProps,\n };\n};\n"],"names":["useClassTimeLogic","props","isTabActive","classDuration","classStartedTime","extendedTime","ongoing","onComplete","onExtendClass","onExtendedTimeStart","showExtendIcon","elapsedTime","remainingTime","hasExtendedTimeStarted","useMemo","extendedTimeStarted","setExtendedTimeStarted","useState","endTime","handleStartExtendedTime","useCallback","canStartTimer","START_TIMER","startTimer","setStartTimer","animateClock","setAnimateClock","handleStartAnimation","animationReminders","ANIMATION_TIME","firedReminders","useRef","nextReminder","r","key","a","b","handleMultiReminder","handleTimerComplete","useEffect","isClassCompleted","timerProps","clockProps","animationProps","LAST_FIVE","getClockColor"],"mappings":";;AAOa,MAAAA,IAAoB,CAACC,GAAwBC,MAAyB;AAC3E,QAAA;AAAA,IACJ,eAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,IACA,YAAAC;AAAA,IACA,eAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,EACf,IAAAT,GAGEU,KAAe,CAAC,oBAAI,KAAK,IAAI,CAACP,KAAoB,KAClDQ,IAAgB,KAAK,MAAMT,IAAgBQ,CAAW,GAEtDE,IAAyBC,EAAQ,MAChCT,IAEoB,KAAK,MAAMF,IAAgBQ,CAAW,KAEpCN,IAAe,KAJhB,IAKzB,CAACF,GAAeE,GAAcM,CAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"use-class-time-logic.js","sources":["../../../../../src/features/ui/timers/class-time/use-class-time-logic.ts"],"sourcesContent":["import type { TColorNames } from '../../types';\nimport type { IClassTimeProps } from './class-time-types';\n\nimport { useState, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { ANIMATION_TIME, getClockColor, LAST_FIVE, START_TIMER } from './constants';\n\nexport const useClassTimeLogic = (props: IClassTimeProps, isTabActive: boolean) => {\n const {\n classDuration,\n classStartedTime,\n extendedTime,\n ongoing,\n onComplete,\n onExtendClass,\n onExtendedTimeStart,\n showExtendIcon = false,\n } = props;\n\n // Core calculations\n const elapsedTime = (+new Date() - +classStartedTime) / 1000;\n const remainingTime = Math.floor(classDuration - elapsedTime);\n // Extended time logic\n const hasExtendedTimeStarted = useMemo(() => {\n if (!extendedTime) return false;\n\n const orgRemainingTime = Math.floor(classDuration - elapsedTime);\n\n return orgRemainingTime <= extendedTime * 60;\n }, [classDuration, extendedTime, elapsedTime]);\n\n const [extendedTimeStarted, setExtendedTimeStarted] = useState(hasExtendedTimeStarted);\n\n const endTime = useMemo(\n () => classDuration + +classStartedTime / 1000,\n [classDuration, classStartedTime],\n );\n\n const handleStartExtendedTime = useCallback(() => {\n setExtendedTimeStarted(true);\n onExtendedTimeStart?.();\n }, [onExtendedTimeStart]);\n\n // Timer/Clock switching logic\n const canStartTimer = useMemo(() => {\n return !!(elapsedTime >= classDuration - START_TIMER || extendedTimeStarted || extendedTime);\n }, [elapsedTime, classDuration, extendedTimeStarted, extendedTime]);\n\n const [startTimer, setStartTimer] = useState(canStartTimer);\n\n // Animation state\n const [animateClock, setAnimateClock] = useState(false);\n\n const handleStartAnimation = useCallback(() => {\n setAnimateClock(true);\n }, []);\n\n // Reminders logic\n const animationReminders = useMemo(\n () => [\n {\n at: ANIMATION_TIME.LAST_TEN,\n callback: handleStartAnimation,\n id: 'rem-10min',\n },\n {\n at: ANIMATION_TIME.LAST_FIVE,\n callback: handleStartAnimation,\n id: 'rem-5min',\n },\n ],\n [handleStartAnimation],\n );\n\n const firedReminders = useRef<Set<string>>(new Set());\n const nextReminder = useMemo(\n () =>\n animationReminders\n .filter(r => {\n const key = r.id || `multi-reminder-${r.at}`;\n const alreadyFired = firedReminders.current.has(key);\n\n return !alreadyFired && remainingTime >= r.at;\n })\n .sort((a, b) => b.at - a.at)[0],\n [animationReminders, remainingTime],\n );\n\n const handleMultiReminder = useCallback(() => {\n if (!nextReminder) return;\n\n const key = nextReminder.id || `multi-reminder-${nextReminder.at}`;\n\n firedReminders.current.add(key);\n\n if (typeof nextReminder.callback === 'function') {\n nextReminder.callback();\n }\n }, [nextReminder]);\n\n // Timer completion logic\n const handleTimerComplete = useCallback(() => {\n if (extendedTime && !extendedTimeStarted) {\n handleStartExtendedTime();\n\n return;\n }\n onComplete?.();\n }, [extendedTime, extendedTimeStarted, onComplete, handleStartExtendedTime]);\n\n // Effects\n useEffect(() => {\n const isClassCompleted =\n +new Date() / 1000 >= +classStartedTime / 1000 + classDuration && classDuration;\n\n if (isTabActive && isClassCompleted) {\n onComplete?.();\n }\n }, [classDuration, classStartedTime, isTabActive, onComplete]);\n\n useEffect(() => {\n if (isTabActive && hasExtendedTimeStarted && !extendedTimeStarted) {\n handleStartExtendedTime();\n }\n }, [isTabActive, handleStartExtendedTime, extendedTimeStarted, hasExtendedTimeStarted]);\n\n useEffect(() => {\n if (classDuration && classStartedTime && isTabActive) {\n setStartTimer(canStartTimer);\n }\n }, [classStartedTime, classDuration, canStartTimer, isTabActive]);\n\n const timerProps = {\n endTime: endTime,\n onComplete: handleTimerComplete,\n reminder: nextReminder?.at,\n onReminder: handleMultiReminder,\n };\n\n const clockProps = {\n completionTime: classDuration - ANIMATION_TIME.LAST_TEN,\n onComplete: handleStartAnimation,\n startedOn: new Date(classStartedTime),\n };\n\n const animationProps = {\n showRipple: !animateClock && startTimer,\n rippleColor: (remainingTime <= LAST_FIVE ? 'ORANGE_3' : 'YELLOW_3') as TColorNames,\n showExtendOverlay:\n Math.floor(classDuration - (+new Date() - +classStartedTime) / 1000) <=\n ANIMATION_TIME.LAST_FIVE && animateClock,\n warningProps: {\n animateClock,\n classStartedTime: +classStartedTime,\n duration: classDuration,\n onExtendClass,\n setStartTimer,\n setAnimateClock,\n showExtendIcon: !extendedTimeStarted && showExtendIcon,\n },\n };\n\n return {\n shouldRender: !!(ongoing && !(elapsedTime >= 0 && remainingTime <= 0)),\n startTimer,\n clockColor: getClockColor({\n remainingTime,\n extendedTime: extendedTime || 0,\n extendedTimeStarted,\n }),\n timerProps,\n clockProps,\n animationProps,\n };\n};\n"],"names":["useClassTimeLogic","props","isTabActive","classDuration","classStartedTime","extendedTime","ongoing","onComplete","onExtendClass","onExtendedTimeStart","showExtendIcon","elapsedTime","remainingTime","hasExtendedTimeStarted","useMemo","extendedTimeStarted","setExtendedTimeStarted","useState","endTime","handleStartExtendedTime","useCallback","canStartTimer","START_TIMER","startTimer","setStartTimer","animateClock","setAnimateClock","handleStartAnimation","animationReminders","ANIMATION_TIME","firedReminders","useRef","nextReminder","r","key","a","b","handleMultiReminder","handleTimerComplete","useEffect","isClassCompleted","timerProps","clockProps","animationProps","LAST_FIVE","getClockColor"],"mappings":";;AAOa,MAAAA,IAAoB,CAACC,GAAwBC,MAAyB;AAC3E,QAAA;AAAA,IACJ,eAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,IACA,YAAAC;AAAA,IACA,eAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,EACf,IAAAT,GAGEU,KAAe,CAAC,oBAAI,KAAK,IAAI,CAACP,KAAoB,KAClDQ,IAAgB,KAAK,MAAMT,IAAgBQ,CAAW,GAEtDE,IAAyBC,EAAQ,MAChCT,IAEoB,KAAK,MAAMF,IAAgBQ,CAA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AiB,CAAC,oBAAI,SAAS,CAACC,KAAoB,GAAI,KACjEyB,EAAe,aAAaJ;AAAA,IAChC,cAAc;AAAA,MACZ,cAAAA;AAAA,MACA,kBAAkB,CAACrB;AAAA,MACnB,UAAUD;AAAA,MACV,eAAAK;AAAA,MACA,eAAAgB;AAAA,MACA,iBAAAE;AAAA,MACA,gBAAgB,CAACX,KAAuBL;AAAA,IAC1C;AAAA,EAAA;AAGK,SAAA;AAAA,IACL,cAAc,CAAC,EAAEJ,KAAW,EAAEK,KAAe,KAAKC,KAAiB;AAAA,IACnE,YAAAW;AAAA,IACA,YAAYsB,EAAc;AAAA,MACxB,eAAAjC;AAAA,MACA,cAAcP,KAAgB;AAAA,MAC9B,qBAAAU;AAAA,IAAA,CACD;AAAA,IACD,YAAA0B;AAAA,IACA,YAAAC;AAAA,IACA,gBAAAC;AAAA,EAAA;AAEJ;"}
|
|
@@ -6,18 +6,18 @@ const i = 250, f = (r) => r ? Math.floor(((/* @__PURE__ */ new Date()).getTime()
|
|
|
6
6
|
completionTime: r = null,
|
|
7
7
|
onComplete: o = () => {
|
|
8
8
|
},
|
|
9
|
-
startedOn:
|
|
10
|
-
textVariant: a = "
|
|
9
|
+
startedOn: c,
|
|
10
|
+
textVariant: a = "ac3-black",
|
|
11
11
|
textColor: T
|
|
12
12
|
}) => {
|
|
13
|
-
const [t, p] = g(f(
|
|
14
|
-
performance.now() - (n.current || 0) >= 1e3 && (p(f(
|
|
15
|
-
}, [
|
|
13
|
+
const [t, p] = g(f(c)), e = m(null), l = k(t), n = m(null), u = h(() => {
|
|
14
|
+
performance.now() - (n.current || 0) >= 1e3 && (p(f(c)), n.current = performance.now()), e.current = setTimeout(u, i);
|
|
15
|
+
}, [c]);
|
|
16
16
|
return s(() => {
|
|
17
17
|
r && t >= r && t <= r + 5 && (e.current && (clearTimeout(e.current), e.current = null), o());
|
|
18
|
-
}, [r, t, o]), s(() => (e.current && (clearTimeout(e.current), e.current = null), n.current === null && (n.current = performance.now()), e.current = setTimeout(
|
|
18
|
+
}, [r, t, o]), s(() => (e.current && (clearTimeout(e.current), e.current = null), n.current === null && (n.current = performance.now()), e.current = setTimeout(u, i), () => {
|
|
19
19
|
e.current && clearTimeout(e.current);
|
|
20
|
-
}), [
|
|
20
|
+
}), [u]), t < 0 ? null : /* @__PURE__ */ d(E, { $width: l.length > 5 ? 66 : 46, $renderAs: a, $color: T, children: l });
|
|
21
21
|
}, A = w(M);
|
|
22
22
|
export {
|
|
23
23
|
A as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.js","sources":["../../../../../src/features/ui/timers/clock/clock.tsx"],"sourcesContent":["import type { IClockProps } from './clock-types';\n\nimport { useState, useEffect, useCallback, useRef, memo } from 'react';\n\nimport { formatTimeInHHMMSS } from '../../../utils/utils';\nimport Text from '../../text/text';\n\nconst TIMEOUT_INTERVAL = 250;\n\nconst getTime = (startedOn?: Date): number => {\n if (!startedOn) return 0;\n\n return Math.floor((new Date().getTime() - startedOn.getTime()) / 1000);\n};\n\nconst Clock = ({\n completionTime = null,\n onComplete = () => {},\n startedOn,\n textVariant = '
|
|
1
|
+
{"version":3,"file":"clock.js","sources":["../../../../../src/features/ui/timers/clock/clock.tsx"],"sourcesContent":["import type { IClockProps } from './clock-types';\n\nimport { useState, useEffect, useCallback, useRef, memo } from 'react';\n\nimport { formatTimeInHHMMSS } from '../../../utils/utils';\nimport Text from '../../text/text';\n\nconst TIMEOUT_INTERVAL = 250;\n\nconst getTime = (startedOn?: Date): number => {\n if (!startedOn) return 0;\n\n return Math.floor((new Date().getTime() - startedOn.getTime()) / 1000);\n};\n\nconst Clock = ({\n completionTime = null,\n onComplete = () => {},\n startedOn,\n textVariant = 'ac3-black',\n textColor,\n}: IClockProps) => {\n const [elapsedTime, setElapsedTime] = useState(getTime(startedOn));\n const timerRef = useRef<NodeJS.Timeout | null>(null);\n const formattedTime = formatTimeInHHMMSS(elapsedTime);\n const start = useRef<number | null>(null);\n const timer = useCallback(() => {\n const timestamp = performance.now();\n\n const elapsed = timestamp - (start.current || 0);\n\n if (elapsed >= 1000) {\n setElapsedTime(getTime(startedOn));\n\n start.current = performance.now();\n }\n\n timerRef.current = setTimeout(timer, TIMEOUT_INTERVAL);\n }, [startedOn]);\n\n useEffect(() => {\n if (completionTime && elapsedTime >= completionTime && elapsedTime <= completionTime + 5) {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n\n onComplete();\n }\n }, [completionTime, elapsedTime, onComplete]);\n\n useEffect(() => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n\n if (start.current === null) {\n start.current = performance.now();\n }\n\n timerRef.current = setTimeout(timer, TIMEOUT_INTERVAL);\n\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, [timer]);\n\n if (elapsedTime < 0) return null;\n\n return (\n <Text $width={formattedTime.length > 5 ? 66 : 46} $renderAs={textVariant} $color={textColor}>\n {formattedTime}\n </Text>\n );\n};\n\nexport default memo(Clock);\n"],"names":["TIMEOUT_INTERVAL","getTime","startedOn","Clock","completionTime","onComplete","textVariant","textColor","elapsedTime","setElapsedTime","useState","timerRef","useRef","formattedTime","formatTimeInHHMMSS","start","timer","useCallback","useEffect","jsx","Text","Clock$1","memo"],"mappings":";;;;AAOA,MAAMA,IAAmB,KAEnBC,IAAU,CAACC,MACVA,IAEE,KAAK,QAAO,oBAAI,KAAK,GAAE,YAAYA,EAAU,QAAQ,KAAK,GAAI,IAF9C,GAKnBC,IAAQ,CAAC;AAAA,EACb,gBAAAC,IAAiB;AAAA,EACjB,YAAAC,IAAa,MAAM;AAAA,EAAC;AAAA,EACpB,WAAAH;AAAA,EACA,aAAAI,IAAc;AAAA,EACd,WAAAC;AACF,MAAmB;AACjB,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAST,EAAQC,CAAS,CAAC,GAC3DS,IAAWC,EAA8B,IAAI,GAC7CC,IAAgBC,EAAmBN,CAAW,GA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