@cuemath/leap 2.8.63-akm-5 → 2.9.0-aa1
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/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.js +45 -46
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.js.map +1 -1
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.js +25 -26
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.js.map +1 -1
- package/dist/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.js +50 -58
- package/dist/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-provider.js +9 -8
- package/dist/features/cue-canvas/cue-canvas-provider.js.map +1 -1
- package/dist/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.js +59 -60
- package/dist/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.js.map +1 -1
- package/dist/features/sheets/resources-list/resource-item/resource-item.js +89 -90
- package/dist/features/sheets/resources-list/resource-item/resource-item.js.map +1 -1
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/student-actions/student-actions.js +60 -61
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/student-actions/student-actions.js.map +1 -1
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/teacher-actions/teacher-actions.js +63 -64
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/teacher-actions/teacher-actions.js.map +1 -1
- package/dist/features/sheets/utils/is-v3-worksheet.js +4 -14
- package/dist/features/sheets/utils/is-v3-worksheet.js.map +1 -1
- package/dist/index.d.ts +10 -13
- package/dist/index.js +425 -425
- package/dist/index.js.map +1 -1
- package/dist/library/polypad.js +24965 -0
- package/dist/library/polypad.js.map +1 -0
- package/package.json +4 -2
@@ -1,43 +1,42 @@
|
|
1
1
|
import { jsxs as u, jsx as e, Fragment as B } from "react/jsx-runtime";
|
2
2
|
import { useMemo as f, useCallback as $ } from "react";
|
3
|
-
import { getRewardsBadgeUrl as
|
4
|
-
import
|
5
|
-
import q from "../../../../../../ui/context
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import K from "../../context-menu-helper/
|
10
|
-
import Q from "
|
11
|
-
import {
|
12
|
-
|
13
|
-
const we = ({ sheet: t, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
3
|
+
import { getRewardsBadgeUrl as G } from "../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils.js";
|
4
|
+
import Z from "../../../../../../ui/context-menu/context-menu.js";
|
5
|
+
import { useUIContext as q } from "../../../../../../ui/context/context.js";
|
6
|
+
import P from "../../../../../../ui/layout/flex-view.js";
|
7
|
+
import { checkIfPPTNodeType as H } from "../../../../utils/index.js";
|
8
|
+
import J from "../../context-menu-helper/menu-element.js";
|
9
|
+
import K from "../../context-menu-helper/target-element.js";
|
10
|
+
import { StyledButton as M, RewardImage as Q, RewardAccuracy as Y } from "../reward-n-actions-styled.js";
|
11
|
+
import { getPrimaryCtaLabel as ee } from "./student-actions-utils.js";
|
12
|
+
const ue = ({ sheet: n, isLastSheet: N, onStartOrResume: m, onReview: l }) => {
|
14
13
|
var A;
|
15
|
-
const { onEvent: w } =
|
16
|
-
permissions:
|
14
|
+
const { onEvent: w } = q(), {
|
15
|
+
permissions: O,
|
17
16
|
can_start: o,
|
18
17
|
can_resume: c,
|
19
18
|
can_review: i,
|
20
|
-
can_reattempt:
|
19
|
+
can_reattempt: S,
|
21
20
|
accuracy: y,
|
22
21
|
can_redo: j,
|
23
22
|
rewards: a,
|
24
23
|
attempt_state: _,
|
25
24
|
is_subjective: F,
|
26
|
-
is_turing:
|
25
|
+
is_turing: V,
|
27
26
|
completed_on: g,
|
28
27
|
node_type: d,
|
29
28
|
ceremony_completed_on_ts: R,
|
30
|
-
can_reattempt_block:
|
29
|
+
can_reattempt_block: W,
|
31
30
|
node_id: b,
|
32
|
-
id:
|
33
|
-
} =
|
31
|
+
id: C
|
32
|
+
} = n, { access: v } = O.can_do, t = H(d), r = V || t, h = a && G(a), U = a && ((A = a[0]) == null ? void 0 : A.performance), z = !o && !c && typeof y == "number" && !(F && _ && _ === "WAIT_FOR_REVIEW"), k = W && !g, I = o || c || j || S, L = v && I || !r && k, p = !!(i && g && !R), s = f(
|
34
33
|
() => ({
|
35
|
-
user_node_id:
|
34
|
+
user_node_id: C,
|
36
35
|
nodeId: b
|
37
36
|
}),
|
38
|
-
[b,
|
39
|
-
),
|
40
|
-
() =>
|
37
|
+
[b, C]
|
38
|
+
), T = f(
|
39
|
+
() => ee({
|
41
40
|
canStart: o,
|
42
41
|
canResume: c,
|
43
42
|
isInstructionNodeType: r,
|
@@ -48,67 +47,67 @@ const we = ({ sheet: t, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
|
48
47
|
), x = $(() => {
|
49
48
|
if (typeof m != "function")
|
50
49
|
throw new Error("onStartOrResume is not a function");
|
51
|
-
m(
|
52
|
-
}, [m,
|
50
|
+
m(n);
|
51
|
+
}, [m, n]), E = $(() => {
|
53
52
|
if (typeof l != "function")
|
54
53
|
throw new Error("onReview is not a function");
|
55
54
|
w("clicked", {
|
56
|
-
cta:
|
55
|
+
cta: t ? "View" : "Review sheet",
|
57
56
|
...s
|
58
|
-
}), l(
|
59
|
-
}, [s,
|
57
|
+
}), l(n);
|
58
|
+
}, [s, t, l, n, w]), X = r ? !!R : i, D = f(
|
60
59
|
() => [
|
61
60
|
{
|
62
61
|
key: "review-sheet",
|
63
|
-
label:
|
62
|
+
label: t ? "View" : "Review sheet",
|
64
63
|
visible: !!i,
|
65
64
|
onClick: E
|
66
65
|
}
|
67
66
|
],
|
68
|
-
[i, E,
|
67
|
+
[i, E, t]
|
69
68
|
);
|
70
|
-
return
|
71
|
-
|
72
|
-
|
69
|
+
return t ? null : /* @__PURE__ */ u(P, { $flexDirection: "row", $alignItems: "center", $flexGap: 8, children: [
|
70
|
+
v && r ? /* @__PURE__ */ e(B, { children: (I || p) && /* @__PURE__ */ e(
|
71
|
+
M,
|
73
72
|
{
|
74
73
|
renderAs: "primary",
|
75
74
|
size: "small",
|
76
75
|
widthX: 6,
|
77
76
|
onClick: x,
|
78
|
-
label:
|
77
|
+
label: T,
|
79
78
|
analyticsProps: s
|
80
79
|
}
|
81
80
|
) }) : /* @__PURE__ */ u(B, { children: [
|
82
|
-
|
83
|
-
|
84
|
-
/* @__PURE__ */ e(
|
81
|
+
z && /* @__PURE__ */ u(P, { $justifyContent: "center", $alignItems: "center", children: [
|
82
|
+
h && /* @__PURE__ */ e(Q, { src: h, alt: "Reward" }),
|
83
|
+
/* @__PURE__ */ e(Y, { $renderAs: "eyebrow2", $align: "center", children: U || `${Math.ceil(y)}%` })
|
85
84
|
] }),
|
86
|
-
|
87
|
-
|
85
|
+
L && /* @__PURE__ */ e(
|
86
|
+
M,
|
88
87
|
{
|
89
88
|
renderAs: "primary",
|
90
89
|
size: "small",
|
91
90
|
widthX: 6,
|
92
|
-
label:
|
93
|
-
disabled:
|
91
|
+
label: T,
|
92
|
+
disabled: k,
|
94
93
|
onClick: x,
|
95
94
|
analyticsProps: s
|
96
95
|
}
|
97
96
|
)
|
98
97
|
] }),
|
99
|
-
|
100
|
-
|
98
|
+
X && /* @__PURE__ */ e(
|
99
|
+
Z,
|
101
100
|
{
|
102
|
-
targetElement: /* @__PURE__ */ e(
|
103
|
-
menuElement: /* @__PURE__ */ e(
|
101
|
+
targetElement: /* @__PURE__ */ e(K, {}),
|
102
|
+
menuElement: /* @__PURE__ */ e(J, { options: D }),
|
104
103
|
menuOffset: 5,
|
105
104
|
menuZIndex: 1,
|
106
|
-
placeTop:
|
105
|
+
placeTop: N
|
107
106
|
}
|
108
107
|
)
|
109
108
|
] });
|
110
109
|
};
|
111
110
|
export {
|
112
|
-
|
111
|
+
ue as default
|
113
112
|
};
|
114
113
|
//# sourceMappingURL=student-actions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"student-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport
|
1
|
+
{"version":3,"file":"student-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport ContextMenu from '../../../../../../ui/context-menu/context-menu';\nimport { useUIContext } from '../../../../../../ui/context/context';\nimport FlexView from '../../../../../../ui/layout/flex-view';\nimport { checkIfPPTNodeType } from '../../../../utils';\nimport ContextMenuElement from '../../context-menu-helper/menu-element';\nimport ContextMenuTargetElement from '../../context-menu-helper/target-element';\nimport { RewardAccuracy, RewardImage, StyledButton } from '../reward-n-actions-styled';\nimport { getPrimaryCtaLabel } from './student-actions-utils';\n\ninterface IStudentActions extends ILPARSheetCallbacks {\n sheet: TLPARSheetData;\n isLastSheet: boolean;\n isClassOngoing: boolean;\n}\n\nconst StudentActions: FC<IStudentActions> = ({ sheet, isLastSheet, onStartOrResume, onReview }) => {\n const { onEvent: trackEvent } = useUIContext();\n\n const {\n permissions,\n can_start: canStart,\n can_resume: canResume,\n can_review: canReview,\n can_reattempt: canReattempt,\n accuracy,\n can_redo: canRedo,\n rewards,\n attempt_state: attemptState,\n is_subjective: isSubjective,\n is_turing: isTuring,\n completed_on: completedOn,\n node_type: nodeType,\n ceremony_completed_on_ts: ceremonyCompletedOnTS,\n can_reattempt_block: canReattemptBlock,\n node_id: nodeId,\n id: userNodeId,\n } = sheet;\n const { access } = permissions.can_do;\n const isPPTNodeType = checkIfPPTNodeType(nodeType);\n const isInstructionNodeType = isTuring || isPPTNodeType;\n const rewardsBadgeUrl = rewards && getRewardsBadgeUrl(rewards);\n\n const performance = rewards && rewards[0]?.performance;\n const isWaitingForReview = isSubjective && attemptState && attemptState === 'WAIT_FOR_REVIEW';\n const renderAccuracy =\n !canStart && !canResume && typeof accuracy === 'number' && !isWaitingForReview;\n const reattemptBlocked = canReattemptBlock && !completedOn;\n const canStartOrResume = canStart || canResume || canRedo || canReattempt;\n const renderAccuracyNPrimaryCta =\n (access && canStartOrResume) || (!isInstructionNodeType && reattemptBlocked);\n const reviewInstructionNodeType = Boolean(canReview && completedOn && !ceremonyCompletedOnTS);\n\n const analyticsProps = useMemo(\n () => ({\n user_node_id: userNodeId,\n nodeId: nodeId,\n }),\n [nodeId, userNodeId],\n );\n\n const primaryCtaLabel = useMemo(\n () =>\n getPrimaryCtaLabel({\n canStart,\n canResume,\n isInstructionNodeType,\n reviewInstructionNodeType,\n nodeType,\n }),\n [canResume, canStart, isInstructionNodeType, nodeType, reviewInstructionNodeType],\n );\n\n const handleOnActionClick = useCallback(() => {\n if (typeof onStartOrResume !== 'function') {\n throw new Error(`onStartOrResume is not a function`);\n }\n\n onStartOrResume(sheet);\n }, [onStartOrResume, sheet]);\n\n const handleOnReview = useCallback(() => {\n if (typeof onReview !== 'function') {\n throw new Error(`onReview is not a function`);\n }\n\n trackEvent('clicked', {\n cta: isPPTNodeType ? 'View' : 'Review sheet',\n ...analyticsProps,\n });\n\n onReview(sheet);\n }, [analyticsProps, isPPTNodeType, onReview, sheet, trackEvent]);\n\n const isMenuVisible = isInstructionNodeType ? Boolean(ceremonyCompletedOnTS) : canReview;\n const options = useMemo(\n () => [\n {\n key: 'review-sheet',\n label: isPPTNodeType ? 'View' : 'Review sheet',\n visible: Boolean(canReview),\n onClick: handleOnReview,\n },\n ],\n [canReview, handleOnReview, isPPTNodeType],\n );\n\n if (isPPTNodeType) return null;\n\n return (\n <FlexView $flexDirection=\"row\" $alignItems=\"center\" $flexGap={8}>\n {access && isInstructionNodeType ? (\n <>\n {(canStartOrResume || reviewInstructionNodeType) && (\n <StyledButton\n renderAs=\"primary\"\n size=\"small\"\n widthX={6}\n onClick={handleOnActionClick}\n label={primaryCtaLabel}\n analyticsProps={analyticsProps}\n />\n )}\n </>\n ) : (\n <>\n {renderAccuracy && (\n <FlexView $justifyContent=\"center\" $alignItems=\"center\">\n {rewardsBadgeUrl && <RewardImage src={rewardsBadgeUrl} alt=\"Reward\" />}\n <RewardAccuracy $renderAs=\"eyebrow2\" $align=\"center\">\n {performance || `${Math.ceil(accuracy)}%`}\n </RewardAccuracy>\n </FlexView>\n )}\n\n {renderAccuracyNPrimaryCta && (\n <StyledButton\n renderAs=\"primary\"\n size=\"small\"\n widthX={6}\n label={primaryCtaLabel}\n disabled={reattemptBlocked}\n onClick={handleOnActionClick}\n analyticsProps={analyticsProps}\n />\n )}\n </>\n )}\n\n {isMenuVisible && (\n <ContextMenu\n targetElement={<ContextMenuTargetElement />}\n menuElement={<ContextMenuElement options={options} />}\n menuOffset={5}\n menuZIndex={1}\n placeTop={isLastSheet}\n />\n )}\n </FlexView>\n );\n};\n\nexport default StudentActions;\n"],"names":["StudentActions","sheet","isLastSheet","onStartOrResume","onReview","trackEvent","useUIContext","permissions","canStart","canResume","canReview","canReattempt","accuracy","canRedo","rewards","attemptState","isSubjective","isTuring","completedOn","nodeType","ceremonyCompletedOnTS","canReattemptBlock","nodeId","userNodeId","access","isPPTNodeType","checkIfPPTNodeType","isInstructionNodeType","rewardsBadgeUrl","getRewardsBadgeUrl","performance","_a","renderAccuracy","reattemptBlocked","canStartOrResume","renderAccuracyNPrimaryCta","reviewInstructionNodeType","analyticsProps","useMemo","primaryCtaLabel","getPrimaryCtaLabel","handleOnActionClick","useCallback","handleOnReview","isMenuVisible","options","FlexView","jsx","Fragment","StyledButton","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;AAoBA,MAAMA,KAAsC,CAAC,EAAE,OAAAC,GAAO,aAAAC,GAAa,iBAAAC,GAAiB,UAAAC,QAAe;;AACjG,QAAM,EAAE,SAASC,EAAW,IAAIC,EAAa,GAEvC;AAAA,IACJ,aAAAC;AAAA,IACA,WAAWC;AAAA,IACX,YAAYC;AAAA,IACZ,YAAYC;AAAA,IACZ,eAAeC;AAAA,IACf,UAAAC;AAAA,IACA,UAAUC;AAAA,IACV,SAAAC;AAAA,IACA,eAAeC;AAAA,IACf,eAAeC;AAAA,IACf,WAAWC;AAAA,IACX,cAAcC;AAAA,IACd,WAAWC;AAAA,IACX,0BAA0BC;AAAA,IAC1B,qBAAqBC;AAAA,IACrB,SAASC;AAAA,IACT,IAAIC;AAAA,EACF,IAAAtB,GACE,EAAE,QAAAuB,EAAO,IAAIjB,EAAY,QACzBkB,IAAgBC,EAAmBP,CAAQ,GAC3CQ,IAAwBV,KAAYQ,GACpCG,IAAkBd,KAAWe,EAAmBf,CAAO,GAEvDgB,IAAchB,OAAWiB,IAAAjB,EAAQ,CAAC,MAAT,gBAAAiB,EAAY,cAErCC,IACJ,CAACxB,KAAY,CAACC,KAAa,OAAOG,KAAa,YAAY,EAFlCI,KAAgBD,KAAgBA,MAAiB,oBAGtEkB,IAAmBZ,KAAqB,CAACH,GACzCgB,IAAmB1B,KAAYC,KAAaI,KAAWF,GACvDwB,IACHX,KAAUU,KAAsB,CAACP,KAAyBM,GACvDG,IAA4B,GAAQ1B,KAAaQ,KAAe,CAACE,IAEjEiB,IAAiBC;AAAA,IACrB,OAAO;AAAA,MACL,cAAcf;AAAA,MACd,QAAAD;AAAA,IAAA;AAAA,IAEF,CAACA,GAAQC,CAAU;AAAA,EAAA,GAGfgB,IAAkBD;AAAA,IACtB,MACEE,GA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Aa,EAAAF,GAAA,EAAA,UAAA;AAAA,MAAAhB,KACE,gBAAAkB,EAAAJ,GAAA,EAAS,iBAAgB,UAAS,aAAY,UAC5C,UAAA;AAAA,QAAAlB,KAAoB,gBAAAmB,EAAAI,GAAA,EAAY,KAAKvB,GAAiB,KAAI,UAAS;AAAA,QACnE,gBAAAmB,EAAAK,GAAA,EAAe,WAAU,YAAW,QAAO,UACzC,UAAetB,KAAA,GAAG,KAAK,KAAKlB,CAAQ,CAAC,KACxC;AAAA,MAAA,GACF;AAAA,MAGDuB,KACC,gBAAAY;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,UAAS;AAAA,UACT,MAAK;AAAA,UACL,QAAQ;AAAA,UACR,OAAOV;AAAA,UACP,UAAUN;AAAA,UACV,SAASQ;AAAA,UACT,gBAAAJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA,GAEJ;AAAA,IAGDO,KACC,gBAAAG;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,iCAAgBC,GAAyB,EAAA;AAAA,QACzC,aAAc,gBAAAP,EAAAQ,GAAA,EAAmB,SAAAV,EAAkB,CAAA;AAAA,QACnD,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU3C;AAAA,MAAA;AAAA,IACZ;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
@@ -1,24 +1,23 @@
|
|
1
1
|
import { jsx as e, jsxs as x } from "react/jsx-runtime";
|
2
2
|
import { useMemo as E, useCallback as T } from "react";
|
3
|
-
import { NODE_TYPE as
|
3
|
+
import { NODE_TYPE as V } from "../../../../../../sheets/constants/sheet.js";
|
4
4
|
import { getRewardsBadgeUrl as G } from "../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils.js";
|
5
|
-
import { isV3Worksheet as H } from "../../../../../../sheets/utils/is-v3-worksheet.js";
|
6
5
|
import R from "../../../../../../ui/buttons/button/button.js";
|
7
|
-
import
|
8
|
-
import { useUIContext as
|
6
|
+
import H from "../../../../../../ui/context-menu/context-menu.js";
|
7
|
+
import { useUIContext as j } from "../../../../../../ui/context/context.js";
|
9
8
|
import u from "../../../../../../ui/layout/flex-view.js";
|
10
|
-
import { checkIfIsHiddenUnlocked as
|
9
|
+
import { checkIfIsHiddenUnlocked as z, checkIfPPTNodeType as L } from "../../../../utils/index.js";
|
11
10
|
import F from "../../context-menu-helper/menu-element.js";
|
12
|
-
import
|
13
|
-
import { StyledEyeIcon as $, RewardImage as
|
14
|
-
const
|
11
|
+
import W from "../../context-menu-helper/target-element.js";
|
12
|
+
import { StyledEyeIcon as $, RewardImage as Y, RewardAccuracy as Z } from "../reward-n-actions-styled.js";
|
13
|
+
const le = ({
|
15
14
|
isLastSheet: M,
|
16
15
|
isClassOngoing: N,
|
17
|
-
sheet:
|
16
|
+
sheet: n,
|
18
17
|
...v
|
19
18
|
}) => {
|
20
19
|
var h;
|
21
|
-
const { onView: s, onMenuActionAttempt: m } = v, { onEvent: r } =
|
20
|
+
const { onView: s, onMenuActionAttempt: m } = v, { onEvent: r } = j(), {
|
22
21
|
accuracy: f,
|
23
22
|
can_teacher_review: k,
|
24
23
|
id: d,
|
@@ -29,7 +28,7 @@ const se = ({
|
|
29
28
|
completed_on: y,
|
30
29
|
can_reattempt_block: _,
|
31
30
|
node_id: g
|
32
|
-
} =
|
31
|
+
} = n, { code: p } = P.can_do, I = i === V.HIDDEN_BASIC, S = c && ((h = c[0]) == null ? void 0 : h.performance), A = c && G(c), C = L(i), B = k && typeof f == "number" && !C, U = d && !I, b = C && N && p === "IN_PROGRESS", O = !!(p && z(p)), t = E(
|
33
32
|
() => ({
|
34
33
|
node_id: g,
|
35
34
|
user_node_id: d
|
@@ -39,13 +38,13 @@ const se = ({
|
|
39
38
|
(o) => {
|
40
39
|
if (r("clicked", {
|
41
40
|
cta: o,
|
42
|
-
...
|
41
|
+
...t
|
43
42
|
}), typeof m != "function")
|
44
43
|
throw new Error("onMenuActionAttempt must be a function");
|
45
|
-
m(o,
|
44
|
+
m(o, n);
|
46
45
|
},
|
47
|
-
[
|
48
|
-
),
|
46
|
+
[t, m, n, r]
|
47
|
+
), D = E(
|
49
48
|
() => [
|
50
49
|
{
|
51
50
|
key: "change-location",
|
@@ -69,11 +68,11 @@ const se = ({
|
|
69
68
|
[_, y, w, i, l]
|
70
69
|
), a = T(
|
71
70
|
(o) => {
|
72
|
-
if (o && r(o,
|
71
|
+
if (o && r(o, t), typeof s != "function")
|
73
72
|
throw new Error("onView must be a function");
|
74
|
-
s(
|
73
|
+
s(n);
|
75
74
|
},
|
76
|
-
[
|
75
|
+
[t, s, n, r]
|
77
76
|
);
|
78
77
|
return I ? /* @__PURE__ */ e(u, { $flexGap: 8, $flexDirection: "row", $alignItems: "center", children: O ? /* @__PURE__ */ e($, { onClick: () => a("clicked") }) : /* @__PURE__ */ e(
|
79
78
|
R,
|
@@ -82,12 +81,12 @@ const se = ({
|
|
82
81
|
size: "small",
|
83
82
|
label: "Start",
|
84
83
|
onClick: a,
|
85
|
-
analyticsProps:
|
84
|
+
analyticsProps: t
|
86
85
|
}
|
87
86
|
) }) : /* @__PURE__ */ x(u, { $flexGap: 8, $flexDirection: "row", $alignItems: "center", children: [
|
88
87
|
B && /* @__PURE__ */ x(u, { $justifyContent: "center", $alignItems: "center", children: [
|
89
|
-
A && /* @__PURE__ */ e(
|
90
|
-
/* @__PURE__ */ e(
|
88
|
+
A && /* @__PURE__ */ e(Y, { src: A, alt: "Reward" }),
|
89
|
+
/* @__PURE__ */ e(Z, { $renderAs: "eyebrow2", $align: "center", children: S || `${Math.ceil(f)}%` })
|
91
90
|
] }),
|
92
91
|
k && b && /* @__PURE__ */ e(
|
93
92
|
R,
|
@@ -96,15 +95,15 @@ const se = ({
|
|
96
95
|
size: "small",
|
97
96
|
label: "Resume",
|
98
97
|
onClick: a,
|
99
|
-
analyticsProps:
|
98
|
+
analyticsProps: t
|
100
99
|
}
|
101
100
|
),
|
102
101
|
!b && /* @__PURE__ */ e($, { onClick: () => a("clicked") }),
|
103
102
|
U && /* @__PURE__ */ e(
|
104
|
-
|
103
|
+
H,
|
105
104
|
{
|
106
|
-
targetElement: /* @__PURE__ */ e(
|
107
|
-
menuElement: /* @__PURE__ */ e(F, { options:
|
105
|
+
targetElement: /* @__PURE__ */ e(W, {}),
|
106
|
+
menuElement: /* @__PURE__ */ e(F, { options: D }),
|
108
107
|
menuOffset: 5,
|
109
108
|
menuZIndex: 1,
|
110
109
|
placeTop: M
|
@@ -113,6 +112,6 @@ const se = ({
|
|
113
112
|
] });
|
114
113
|
};
|
115
114
|
export {
|
116
|
-
|
115
|
+
le as default
|
117
116
|
};
|
118
117
|
//# sourceMappingURL=teacher-actions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"teacher-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { NODE_TYPE } from '../../../../../../sheets/constants/sheet';\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport
|
1
|
+
{"version":3,"file":"teacher-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { NODE_TYPE } from '../../../../../../sheets/constants/sheet';\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport Button from '../../../../../../ui/buttons/button/button';\nimport ContextMenu from '../../../../../../ui/context-menu/context-menu';\nimport { useUIContext } from '../../../../../../ui/context/context';\nimport FlexView from '../../../../../../ui/layout/flex-view';\nimport { checkIfIsHiddenUnlocked, checkIfPPTNodeType } from '../../../../utils';\nimport ContextMenuElement from '../../context-menu-helper/menu-element';\nimport ContextMenuTargetElement from '../../context-menu-helper/target-element';\nimport { RewardAccuracy, RewardImage, StyledEyeIcon } from '../reward-n-actions-styled';\n\nexport interface ITeacherActions extends ILPARSheetCallbacks {\n sheet: TLPARSheetData;\n isClassOngoing: boolean;\n isLastSheet: boolean;\n}\n\nconst TeacherActions: FC<ITeacherActions> = ({\n isLastSheet,\n isClassOngoing,\n sheet,\n ...restTeacherActionsProps\n}) => {\n const { onView, onMenuActionAttempt } = restTeacherActionsProps;\n\n const { onEvent: trackEvent } = useUIContext();\n\n const {\n accuracy,\n can_teacher_review: canTeacherReview,\n id: userNodeId,\n node_type: nodeType,\n permissions,\n rewards,\n is_turing: isTuring,\n completed_on: completedOn,\n can_reattempt_block: canReattemptBlock,\n node_id: nodeId,\n } = sheet;\n const { code } = permissions.can_do;\n const isHiddenNode = nodeType === NODE_TYPE.HIDDEN_BASIC;\n const performance = rewards && rewards[0]?.performance;\n const rewardsBadgeUrl = rewards && getRewardsBadgeUrl(rewards);\n const isPPTNodeType = checkIfPPTNodeType(nodeType);\n const renderAccuracy = canTeacherReview && typeof accuracy === 'number' && !isPPTNodeType;\n const isMenuVisible = userNodeId && !isHiddenNode;\n const pptNodeTypeSheetInProgress = isPPTNodeType && isClassOngoing && code === 'IN_PROGRESS';\n const isHiddenUnlocked = Boolean(code && checkIfIsHiddenUnlocked(code));\n\n const analyticsProps = useMemo(\n () => ({\n node_id: nodeId,\n user_node_id: userNodeId,\n }),\n [nodeId, userNodeId],\n );\n\n const handleOnMenuActionAttempt = useCallback(\n (action: string) => {\n trackEvent('clicked', {\n cta: action,\n ...analyticsProps,\n });\n\n if (typeof onMenuActionAttempt !== 'function') {\n throw new Error('onMenuActionAttempt must be a function');\n }\n\n onMenuActionAttempt(action, sheet);\n },\n [analyticsProps, onMenuActionAttempt, sheet, trackEvent],\n );\n\n const options = useMemo(\n () => [\n {\n key: 'change-location',\n label: 'Change Location',\n visible: true,\n onClick: () => handleOnMenuActionAttempt('change_attempt_location'),\n },\n {\n key: 'turing-option',\n label: completedOn && nodeType !== 'TURING_BASIC' ? 'Student Work Url' : 'Activity Link',\n visible: isTuring,\n onClick: () => handleOnMenuActionAttempt('turing_attempt'),\n },\n {\n key: 'allow-reattempt',\n label: 'Allow Reattempt',\n visible: canReattemptBlock,\n onClick: () => handleOnMenuActionAttempt('allow_reattempt'),\n },\n ],\n [canReattemptBlock, completedOn, isTuring, nodeType, handleOnMenuActionAttempt],\n );\n\n const handleOnView = useCallback(\n (action?: string) => {\n if (action) {\n trackEvent(action, analyticsProps);\n }\n\n if (typeof onView !== 'function') {\n throw new Error('onView must be a function');\n }\n\n onView(sheet);\n },\n [analyticsProps, onView, sheet, trackEvent],\n );\n\n if (isHiddenNode) {\n return (\n <FlexView $flexGap={8} $flexDirection=\"row\" $alignItems=\"center\">\n {isHiddenUnlocked ? (\n <StyledEyeIcon onClick={() => handleOnView('clicked')} />\n ) : (\n <Button\n renderAs=\"primary\"\n size=\"small\"\n label=\"Start\"\n onClick={handleOnView}\n analyticsProps={analyticsProps}\n />\n )}\n </FlexView>\n );\n }\n\n return (\n <FlexView $flexGap={8} $flexDirection=\"row\" $alignItems=\"center\">\n {renderAccuracy && (\n <FlexView $justifyContent=\"center\" $alignItems=\"center\">\n {rewardsBadgeUrl && <RewardImage src={rewardsBadgeUrl} alt=\"Reward\" />}\n <RewardAccuracy $renderAs=\"eyebrow2\" $align=\"center\">\n {performance || `${Math.ceil(accuracy)}%`}\n </RewardAccuracy>\n </FlexView>\n )}\n\n {canTeacherReview && pptNodeTypeSheetInProgress && (\n <Button\n renderAs=\"primary\"\n size=\"small\"\n label=\"Resume\"\n onClick={handleOnView}\n analyticsProps={analyticsProps}\n />\n )}\n\n {!pptNodeTypeSheetInProgress && <StyledEyeIcon onClick={() => handleOnView('clicked')} />}\n\n {isMenuVisible && (\n <ContextMenu\n targetElement={<ContextMenuTargetElement />}\n menuElement={<ContextMenuElement options={options} />}\n menuOffset={5}\n menuZIndex={1}\n placeTop={isLastSheet}\n />\n )}\n </FlexView>\n );\n};\n\nexport default TeacherActions;\n"],"names":["TeacherActions","isLastSheet","isClassOngoing","sheet","restTeacherActionsProps","onView","onMenuActionAttempt","trackEvent","useUIContext","accuracy","canTeacherReview","userNodeId","nodeType","permissions","rewards","isTuring","completedOn","canReattemptBlock","nodeId","code","isHiddenNode","NODE_TYPE","performance","_a","rewardsBadgeUrl","getRewardsBadgeUrl","isPPTNodeType","checkIfPPTNodeType","renderAccuracy","isMenuVisible","pptNodeTypeSheetInProgress","isHiddenUnlocked","checkIfIsHiddenUnlocked","analyticsProps","useMemo","handleOnMenuActionAttempt","useCallback","action","options","handleOnView","FlexView","jsx","StyledEyeIcon","Button","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;;AAqBA,MAAMA,KAAsC,CAAC;AAAA,EAC3C,aAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,MAAM;;AACE,QAAA,EAAE,QAAAC,GAAQ,qBAAAC,EAAwB,IAAAF,GAElC,EAAE,SAASG,EAAW,IAAIC,EAAa,GAEvC;AAAA,IACJ,UAAAC;AAAA,IACA,oBAAoBC;AAAA,IACpB,IAAIC;AAAA,IACJ,WAAWC;AAAA,IACX,aAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAWC;AAAA,IACX,cAAcC;AAAA,IACd,qBAAqBC;AAAA,IACrB,SAASC;AAAA,EACP,IAAAf,GACE,EAAE,MAAAgB,EAAK,IAAIN,EAAY,QACvBO,IAAeR,MAAaS,EAAU,cACtCC,IAAcR,OAAWS,IAAAT,EAAQ,CAAC,MAAT,gBAAAS,EAAY,cACrCC,IAAkBV,KAAWW,EAAmBX,CAAO,GACvDY,IAAgBC,EAAmBf,CAAQ,GAC3CgB,IAAiBlB,KAAoB,OAAOD,KAAa,YAAY,CAACiB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
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { useCallback as
|
2
|
-
import { CircleSoundKeyMapper as
|
1
|
+
import { useCallback as a } from "react";
|
2
|
+
import { CircleSoundKeyMapper as A, SWIPE_SOUND_ORDER as i } from "./constants.js";
|
3
3
|
import { CircleSoundKey as l } from "./use-circle-sounds-enums.js";
|
4
|
-
let
|
5
|
-
const
|
4
|
+
let C = 0;
|
5
|
+
const r = {
|
6
6
|
[l.BACKGROUND]: null,
|
7
7
|
[l.BACKGROUND_RUSHHOUR]: null,
|
8
8
|
[l.TUTORIAL]: null,
|
@@ -26,71 +26,63 @@ const t = {
|
|
26
26
|
[l.TIME_INTRO]: null,
|
27
27
|
[l.TIME_TARGET]: null,
|
28
28
|
[l.METER_FILL]: null
|
29
|
-
},
|
30
|
-
const
|
31
|
-
if (!
|
32
|
-
const
|
33
|
-
|
29
|
+
}, I = {}, O = () => {
|
30
|
+
const e = a((n) => {
|
31
|
+
if (!r[n]) {
|
32
|
+
const t = new Audio(A[n]);
|
33
|
+
r[n] = t;
|
34
34
|
}
|
35
|
-
}, []), p =
|
36
|
-
|
37
|
-
|
38
|
-
e
|
39
|
-
}) : document.visibilityState === "visible" && (p.current.forEach((n) => {
|
40
|
-
const e = t[n];
|
41
|
-
e == null || e.play();
|
42
|
-
}), p.current.clear());
|
43
|
-
}, []), E = r(() => {
|
44
|
-
var e;
|
45
|
-
C.forEach((u) => {
|
46
|
-
s(u);
|
35
|
+
}, []), p = a(() => {
|
36
|
+
var t;
|
37
|
+
i.forEach((o) => {
|
38
|
+
e(o);
|
47
39
|
});
|
48
|
-
const n = C
|
49
|
-
|
50
|
-
}, [
|
51
|
-
var
|
52
|
-
return
|
53
|
-
}, [
|
54
|
-
(n,
|
55
|
-
|
56
|
-
const
|
57
|
-
if (!
|
58
|
-
if (
|
59
|
-
|
60
|
-
const
|
61
|
-
|
40
|
+
const n = i[C] || l.SWIPE_01;
|
41
|
+
C < i.length - 1 ? C++ : C = 0, (t = r[n]) == null || t.play();
|
42
|
+
}, [e]), _ = a(() => {
|
43
|
+
var t;
|
44
|
+
return e(l.TOGGLE), (t = r[l.TOGGLE]) == null ? void 0 : t.play();
|
45
|
+
}, [e]), E = a(
|
46
|
+
(n, t = !0, o = !1) => {
|
47
|
+
e(n);
|
48
|
+
const u = r[n];
|
49
|
+
if (!u) return;
|
50
|
+
if (u.loop = o, t) {
|
51
|
+
u.volume = 1;
|
52
|
+
const s = u.play();
|
53
|
+
I[n] = s;
|
62
54
|
return;
|
63
55
|
}
|
64
|
-
|
65
|
-
const
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}, 100);
|
72
|
-
return o;
|
56
|
+
u.volume = 0;
|
57
|
+
const c = u.play();
|
58
|
+
return I[n] = c, setInterval(() => {
|
59
|
+
if (!u) return;
|
60
|
+
const s = 0;
|
61
|
+
u.volume = s + 0.1;
|
62
|
+
}, 100), u;
|
73
63
|
},
|
74
|
-
[
|
75
|
-
),
|
76
|
-
var
|
77
|
-
const
|
78
|
-
|
79
|
-
if (
|
80
|
-
|
64
|
+
[e]
|
65
|
+
), S = a((n, t = !0) => {
|
66
|
+
var u;
|
67
|
+
const o = r[n];
|
68
|
+
I[n] !== void 0 && ((u = I[n]) == null || u.then(() => {
|
69
|
+
if (t) {
|
70
|
+
o == null || o.pause();
|
81
71
|
return;
|
82
72
|
}
|
83
|
-
const
|
84
|
-
if (!
|
85
|
-
const
|
86
|
-
|
73
|
+
const c = setInterval(() => {
|
74
|
+
if (!o) return;
|
75
|
+
const s = o.volume || 0;
|
76
|
+
s - 0.1 <= 0 ? (o.volume = 0, o.pause(), clearInterval(c)) : o.volume = s - 0.1;
|
87
77
|
}, 100);
|
78
|
+
}).catch((c) => {
|
79
|
+
console.log("sound not playing", c);
|
88
80
|
}));
|
89
81
|
}, []);
|
90
|
-
return { playSwipSound:
|
82
|
+
return { playSwipSound: p, play: E, stop: S, playButtonSound: _ };
|
91
83
|
};
|
92
84
|
export {
|
93
|
-
|
94
|
-
|
85
|
+
r as soundMapper,
|
86
|
+
O as useCircleSounds
|
95
87
|
};
|
96
88
|
//# sourceMappingURL=use-circle-sounds.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-circle-sounds.js","sources":["../../../../../src/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.ts"],"sourcesContent":["import { useCallback
|
1
|
+
{"version":3,"file":"use-circle-sounds.js","sources":["../../../../../src/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nimport { CircleSoundKeyMapper, SWIPE_SOUND_ORDER } from './constants';\nimport { CircleSoundKey } from './use-circle-sounds-enums';\n\nlet swipeSoundIndex = 0;\n\nexport const soundMapper: Record<keyof typeof CircleSoundKeyMapper, null | HTMLAudioElement> = {\n [CircleSoundKey.BACKGROUND]: null,\n [CircleSoundKey.BACKGROUND_RUSHHOUR]: null,\n [CircleSoundKey.TUTORIAL]: null,\n [CircleSoundKey.SWIPE_01]: null,\n [CircleSoundKey.SWIPE_02]: null,\n [CircleSoundKey.SWIPE_03]: null,\n [CircleSoundKey.SWIPE_04]: null,\n [CircleSoundKey.SWIPE_DOWN]: null,\n [CircleSoundKey.TOGGLE]: null,\n [CircleSoundKey.POINTS_AWARDED]: null,\n [CircleSoundKey.POINTS_ADDED]: null,\n [CircleSoundKey.GAME_CARD_CLICK]: null,\n [CircleSoundKey.CLOCK_IN]: null,\n [CircleSoundKey.CLOCK_OUT]: null,\n [CircleSoundKey.ACCURACY_IN]: null,\n [CircleSoundKey.ACCURACY_OUT]: null,\n [CircleSoundKey.STREAK_IN]: null,\n [CircleSoundKey.STREAK_OUT]: null,\n [CircleSoundKey.ACCURACY_INTRO]: null,\n [CircleSoundKey.ACCURACY_TARGET]: null,\n [CircleSoundKey.TIME_INTRO]: null,\n [CircleSoundKey.TIME_TARGET]: null,\n [CircleSoundKey.METER_FILL]: null,\n};\n\nconst soundInstancePromise: Partial<Record<keyof typeof CircleSoundKeyMapper, Promise<void>>> = {};\n\nexport const useCircleSounds = () => {\n const loadSound = useCallback((key: CircleSoundKey) => {\n if (!soundMapper[key]) {\n const loadedSound = new Audio(CircleSoundKeyMapper[key]);\n\n soundMapper[key] = loadedSound;\n }\n }, []);\n\n const playSwipSound = useCallback(() => {\n SWIPE_SOUND_ORDER.forEach(key => {\n loadSound(key);\n });\n\n const key = SWIPE_SOUND_ORDER[swipeSoundIndex] || CircleSoundKey.SWIPE_01;\n\n if (swipeSoundIndex < SWIPE_SOUND_ORDER.length - 1) {\n swipeSoundIndex++;\n } else {\n swipeSoundIndex = 0;\n }\n soundMapper[key]?.play();\n }, [loadSound]);\n\n const playButtonSound = useCallback(() => {\n loadSound(CircleSoundKey.TOGGLE);\n const sound = soundMapper[CircleSoundKey.TOGGLE]?.play();\n\n return sound;\n }, [loadSound]);\n\n const play = useCallback(\n (key: CircleSoundKey, immediately: boolean = true, loop = false) => {\n loadSound(key);\n const soundInstance = soundMapper[key];\n\n if (!soundInstance) return;\n\n soundInstance.loop = loop;\n if (immediately) {\n soundInstance.volume = 1;\n const promise = soundInstance.play();\n\n soundInstancePromise[key] = promise;\n\n return;\n }\n\n soundInstance.volume = 0;\n const promise = soundInstance.play();\n\n soundInstancePromise[key] = promise;\n\n const intervalId = setInterval(() => {\n if (!soundInstance) return;\n\n const vol = 0;\n\n if (vol < 1) {\n soundInstance.volume = vol + 0.1;\n } else {\n clearInterval(intervalId);\n }\n }, 100);\n\n return soundInstance;\n },\n [loadSound],\n );\n\n const stop = useCallback((key: CircleSoundKey, immediately: boolean = true) => {\n const soundInstance = soundMapper[key];\n\n // check if the sound is playing as the play() return a promise\n if (soundInstancePromise[key] !== undefined) {\n soundInstancePromise[key]\n ?.then(() => {\n if (immediately) {\n soundInstance?.pause();\n\n return;\n }\n\n const intervalId = setInterval(() => {\n if (!soundInstance) return;\n\n const vol = soundInstance.volume || 0;\n\n if (vol - 0.1 <= 0) {\n soundInstance.volume = 0;\n soundInstance.pause();\n clearInterval(intervalId);\n } else {\n soundInstance.volume = vol - 0.1;\n }\n }, 100);\n })\n .catch(err => {\n // eslint-disable-next-line no-console\n console.log('sound not playing', err);\n });\n }\n }, []);\n\n return { playSwipSound, play, stop, playButtonSound };\n};\n"],"names":["swipeSoundIndex","soundMapper","CircleSoundKey","soundInstancePromise","useCircleSounds","loadSound","useCallback","key","loadedSound","CircleSoundKeyMapper","playSwipSound","SWIPE_SOUND_ORDER","_a","playButtonSound","play","immediately","loop","soundInstance","promise","vol","stop","intervalId","err"],"mappings":";;;AAKA,IAAIA,IAAkB;AAEf,MAAMC,IAAkF;AAAA,EAC7F,CAACC,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,mBAAmB,GAAG;AAAA,EACtC,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,MAAM,GAAG;AAAA,EACzB,CAACA,EAAe,cAAc,GAAG;AAAA,EACjC,CAACA,EAAe,YAAY,GAAG;AAAA,EAC/B,CAACA,EAAe,eAAe,GAAG;AAAA,EAClC,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,SAAS,GAAG;AAAA,EAC5B,CAACA,EAAe,WAAW,GAAG;AAAA,EAC9B,CAACA,EAAe,YAAY,GAAG;AAAA,EAC/B,CAACA,EAAe,SAAS,GAAG;AAAA,EAC5B,CAACA,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,cAAc,GAAG;AAAA,EACjC,CAACA,EAAe,eAAe,GAAG;AAAA,EAClC,CAACA,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,WAAW,GAAG;AAAA,EAC9B,CAACA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;AAAA,IACT;AAAA,IACA,CAACZ,CAAS;AAAA,EAAA,GAGNe,IAAOd,EAAY,CAACC,GAAqBQ,IAAuB,OAAS;;AACvE,UAAAE,IAAgBhB,EAAYM,CAAG;AAGjC,IAAAJ,EAAqBI,CAAG,MAAM,YACXK,IAAAT,EAAAI,CAAG,MAAH,QAAAK,EACjB,KAAK,MAAM;AACX,UAAIG,GAAa;AACf,QAAAE,KAAA,QAAAA,EAAe;AAEf;AAAA,MACF;AAEM,YAAAI,IAAa,YAAY,MAAM;AACnC,YAAI,CAACJ,EAAe;AAEd,cAAAE,IAAMF,EAAc,UAAU;AAEhC,QAAAE,IAAM,OAAO,KACfF,EAAc,SAAS,GACvBA,EAAc,MAAM,GACpB,cAAcI,CAAU,KAExBJ,EAAc,SAASE,IAAM;AAAA,SAE9B,GAAG;AAAA,IAAA,GAEP,MAAM,CAAOG,MAAA;AAEJ,cAAA,IAAI,qBAAqBA,CAAG;AAAA,IAAA;AAAA,EAG5C,GAAG,CAAE,CAAA;AAEL,SAAO,EAAE,eAAAZ,GAAe,MAAAI,GAAM,MAAAM,GAAM,iBAAAP,EAAgB;AACtD;"}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
2
|
-
import
|
3
|
-
import p from "
|
2
|
+
import "../../library/polypad.js";
|
3
|
+
import { memo as p, useMemo as i, useState as o } from "react";
|
4
|
+
import f from "./cue-canvas-context.js";
|
4
5
|
import { getColorsForUser as x } from "./cue-canvas-helpers.js";
|
5
|
-
const A =
|
6
|
-
({ children:
|
7
|
-
const
|
6
|
+
const A = p(
|
7
|
+
({ children: n, userType: t }) => {
|
8
|
+
const a = i(() => x(t), [t]), [e, v] = o(), [r, m] = o("pen"), [s, l] = o(), [c, C] = o(a[0]), u = i(
|
8
9
|
() => ({
|
9
10
|
activeInstance: e,
|
10
11
|
setActiveInstance: v,
|
@@ -17,10 +18,10 @@ const A = f(
|
|
17
18
|
}),
|
18
19
|
[c, e, s, r]
|
19
20
|
);
|
20
|
-
return /* @__PURE__ */ d(
|
21
|
+
return /* @__PURE__ */ d(f.Provider, { value: u, children: n });
|
21
22
|
}
|
22
|
-
),
|
23
|
+
), j = A;
|
23
24
|
export {
|
24
|
-
|
25
|
+
j as default
|
25
26
|
};
|
26
27
|
//# sourceMappingURL=cue-canvas-provider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cue-canvas-provider.js","sources":["../../../src/features/cue-canvas/cue-canvas-provider.tsx"],"sourcesContent":["import type { TUserTypes } from '../ui/types';\nimport type { CueCanvasCore } from './cue-canvas-core';\nimport type { TCueCanvasColors, TCueCanvasSidebar, TCueCanvasTool } from './types/cue-canvas';\nimport '../../library/polypad';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { useState, memo, useMemo } from 'react';\n\nimport CueCanvasContext from './cue-canvas-context';\nimport { getColorsForUser } from './cue-canvas-helpers';\n\nconst CueCanvasProvider: FC<PropsWithChildren<{ userType: TUserTypes }>> = memo(\n ({ children, userType }) => {\n const colors = useMemo(() => getColorsForUser(userType), [userType]);\n\n const [activeInstance, setActiveInstance] = useState<CueCanvasCore>();\n const [activeTool, setActiveTool] = useState<TCueCanvasTool>('pen');\n const [activeSidebar, setActiveSidebar] = useState<TCueCanvasSidebar>();\n const [activeColor, setActiveColor] = useState<TCueCanvasColors>(colors[0] as TCueCanvasColors);\n const contextValue = useMemo(\n () => ({\n activeInstance: activeInstance,\n setActiveInstance: setActiveInstance,\n activeTool: activeTool,\n setActiveTool: setActiveTool,\n activeColor,\n setActiveColor,\n activeSidebar,\n setActiveSidebar,\n }),\n [activeColor, activeInstance, activeSidebar, activeTool],\n );\n\n return <CueCanvasContext.Provider value={contextValue}>{children}</CueCanvasContext.Provider>;\n },\n);\n\nexport default CueCanvasProvider;\n"],"names":["CueCanvasProvider","memo","children","userType","colors","useMemo","getColorsForUser","activeInstance","setActiveInstance","useState","activeTool","setActiveTool","activeSidebar","setActiveSidebar","activeColor","setActiveColor","contextValue","CueCanvasContext","CueCanvasProvider$1"],"mappings":"
|
1
|
+
{"version":3,"file":"cue-canvas-provider.js","sources":["../../../src/features/cue-canvas/cue-canvas-provider.tsx"],"sourcesContent":["import type { TUserTypes } from '../ui/types';\nimport type { CueCanvasCore } from './cue-canvas-core';\nimport type { TCueCanvasColors, TCueCanvasSidebar, TCueCanvasTool } from './types/cue-canvas';\nimport '../../library/polypad';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { useState, memo, useMemo } from 'react';\n\nimport CueCanvasContext from './cue-canvas-context';\nimport { getColorsForUser } from './cue-canvas-helpers';\n\nconst CueCanvasProvider: FC<PropsWithChildren<{ userType: TUserTypes }>> = memo(\n ({ children, userType }) => {\n const colors = useMemo(() => getColorsForUser(userType), [userType]);\n\n const [activeInstance, setActiveInstance] = useState<CueCanvasCore>();\n const [activeTool, setActiveTool] = useState<TCueCanvasTool>('pen');\n const [activeSidebar, setActiveSidebar] = useState<TCueCanvasSidebar>();\n const [activeColor, setActiveColor] = useState<TCueCanvasColors>(colors[0] as TCueCanvasColors);\n const contextValue = useMemo(\n () => ({\n activeInstance: activeInstance,\n setActiveInstance: setActiveInstance,\n activeTool: activeTool,\n setActiveTool: setActiveTool,\n activeColor,\n setActiveColor,\n activeSidebar,\n setActiveSidebar,\n }),\n [activeColor, activeInstance, activeSidebar, activeTool],\n );\n\n return <CueCanvasContext.Provider value={contextValue}>{children}</CueCanvasContext.Provider>;\n },\n);\n\nexport default CueCanvasProvider;\n"],"names":["CueCanvasProvider","memo","children","userType","colors","useMemo","getColorsForUser","activeInstance","setActiveInstance","useState","activeTool","setActiveTool","activeSidebar","setActiveSidebar","activeColor","setActiveColor","contextValue","CueCanvasContext","CueCanvasProvider$1"],"mappings":";;;;;AAWA,MAAMA,IAAqEC;AAAA,EACzE,CAAC,EAAE,UAAAC,GAAU,UAAAC,QAAe;AACpB,UAAAC,IAASC,EAAQ,MAAMC,EAAiBH,CAAQ,GAAG,CAACA,CAAQ,CAAC,GAE7D,CAACI,GAAgBC,CAAiB,IAAIC,EAAwB,GAC9D,CAACC,GAAYC,CAAa,IAAIF,EAAyB,KAAK,GAC5D,CAACG,GAAeC,CAAgB,IAAIJ,EAA4B,GAChE,CAACK,GAAaC,CAAc,IAAIN,EAA2BL,EAAO,CAAC,CAAqB,GACxFY,IAAeX;AAAA,MACnB,OAAO;AAAA,QACL,gBAAAE;AAAA,QACA,mBAAAC;AAAA,QACA,YAAAE;AAAA,QACA,eAAAC;AAAA,QACA,aAAAG;AAAA,QACA,gBAAAC;AAAA,QACA,eAAAH;AAAA,QACA,kBAAAC;AAAA,MAAA;AAAA,MAEF,CAACC,GAAaP,GAAgBK,GAAeF,CAAU;AAAA,IAAA;AAGzD,6BAAQO,EAAiB,UAAjB,EAA0B,OAAOD,GAAe,UAAAd,EAAS,CAAA;AAAA,EACnE;AACF,GAEAgB,IAAelB;"}
|