@cuemath/leap 3.1.25-as1 → 3.1.25-as2
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.
|
@@ -8,7 +8,7 @@ const e = () => {
|
|
|
8
8
|
}
|
|
9
9
|
document.body.style.overflow = "hidden", document.body.style.touchAction = "none";
|
|
10
10
|
}, n = () => {
|
|
11
|
-
document.body.dataset.originalPadding !== void 0 && (document.body.style.paddingRight = document.body.dataset.originalPadding, delete document.body.dataset.originalPadding), document.body.dataset.originalOverflow !== void 0 ? (document.body.style.overflow = document.body.dataset.originalOverflow, delete document.body.dataset.originalOverflow) : document.body.style.overflow = "
|
|
11
|
+
document.body.dataset.originalPadding !== void 0 && (document.body.style.paddingRight = document.body.dataset.originalPadding, delete document.body.dataset.originalPadding), document.body.dataset.originalOverflow !== void 0 ? (document.body.style.overflow = document.body.dataset.originalOverflow, delete document.body.dataset.originalOverflow) : document.body.style.overflow = "", document.body.style.touchAction = "";
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
14
14
|
e as lockScroll,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-helpers.js","sources":["../../../../src/features/ui/modals/modal-helpers.ts"],"sourcesContent":["/**\n * Locks scrolling on the body element while preserving the scrollbar width to prevent layout shifts.\n * Stores original style values in data attributes for later restoration.\n */\nexport const lockScroll = (): void => {\n // Calculate if scrollbar is present\n const hasScrollbar = window.innerWidth > document.documentElement.clientWidth;\n\n // Save original overflow state regardless\n document.body.dataset.originalOverflow = document.body.style.overflow || '';\n\n if (hasScrollbar) {\n // Calculate scrollbar width\n const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n\n // Save original padding\n document.body.dataset.originalPadding = document.body.style.paddingRight || '';\n\n // Get current padding if any\n const currentPadding = parseInt(window.getComputedStyle(document.body).paddingRight, 10) || 0;\n\n // Add padding to prevent content shift when scrollbar disappears\n document.body.style.paddingRight = `${currentPadding + scrollbarWidth}px`;\n }\n\n // Lock scroll\n document.body.style.overflow = 'hidden';\n document.body.style.touchAction = 'none'; // Prevent touch scrolling on mobile\n};\n\n/**\n * Unlocks scrolling on the body element and restores original styles.\n * Uses stored data attributes from lockScroll to restore previous state.\n */\nexport const unlockScroll = (): void => {\n // Restore original padding if it was set\n if (document.body.dataset.originalPadding !== undefined) {\n document.body.style.paddingRight = document.body.dataset.originalPadding;\n delete document.body.dataset.originalPadding;\n }\n\n // Restore original overflow\n if (document.body.dataset.originalOverflow !== undefined) {\n document.body.style.overflow = document.body.dataset.originalOverflow;\n delete document.body.dataset.originalOverflow;\n } else {\n document.body.style.overflow = '
|
|
1
|
+
{"version":3,"file":"modal-helpers.js","sources":["../../../../src/features/ui/modals/modal-helpers.ts"],"sourcesContent":["/**\n * Locks scrolling on the body element while preserving the scrollbar width to prevent layout shifts.\n * Stores original style values in data attributes for later restoration.\n */\nexport const lockScroll = (): void => {\n // Calculate if scrollbar is present\n const hasScrollbar = window.innerWidth > document.documentElement.clientWidth;\n\n // Save original overflow state regardless\n document.body.dataset.originalOverflow = document.body.style.overflow || '';\n\n if (hasScrollbar) {\n // Calculate scrollbar width\n const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n\n // Save original padding\n document.body.dataset.originalPadding = document.body.style.paddingRight || '';\n\n // Get current padding if any\n const currentPadding = parseInt(window.getComputedStyle(document.body).paddingRight, 10) || 0;\n\n // Add padding to prevent content shift when scrollbar disappears\n document.body.style.paddingRight = `${currentPadding + scrollbarWidth}px`;\n }\n\n // Lock scroll\n document.body.style.overflow = 'hidden';\n document.body.style.touchAction = 'none'; // Prevent touch scrolling on mobile\n};\n\n/**\n * Unlocks scrolling on the body element and restores original styles.\n * Uses stored data attributes from lockScroll to restore previous state.\n */\nexport const unlockScroll = (): void => {\n // Restore original padding if it was set\n if (document.body.dataset.originalPadding !== undefined) {\n document.body.style.paddingRight = document.body.dataset.originalPadding;\n delete document.body.dataset.originalPadding;\n }\n\n // Restore original overflow\n if (document.body.dataset.originalOverflow !== undefined) {\n document.body.style.overflow = document.body.dataset.originalOverflow;\n delete document.body.dataset.originalOverflow;\n } else {\n document.body.style.overflow = '';\n }\n\n document.body.style.touchAction = '';\n};\n"],"names":["lockScroll","hasScrollbar","scrollbarWidth","currentPadding","unlockScroll"],"mappings":"AAIO,MAAMA,IAAa,MAAY;AAEpC,QAAMC,IAAe,OAAO,aAAa,SAAS,gBAAgB;AAKlE,MAFA,SAAS,KAAK,QAAQ,mBAAmB,SAAS,KAAK,MAAM,YAAY,IAErEA,GAAc;AAEhB,UAAMC,IAAiB,OAAO,aAAa,SAAS,gBAAgB;AAGpE,aAAS,KAAK,QAAQ,kBAAkB,SAAS,KAAK,MAAM,gBAAgB;AAGtE,UAAAC,IAAiB,SAAS,OAAO,iBAAiB,SAAS,IAAI,EAAE,cAAc,EAAE,KAAK;AAG5F,aAAS,KAAK,MAAM,eAAe,GAAGA,IAAiBD,CAAc;AAAA,EACvE;AAGS,WAAA,KAAK,MAAM,WAAW,UACtB,SAAA,KAAK,MAAM,cAAc;AACpC,GAMaE,IAAe,MAAY;AAEtC,EAAI,SAAS,KAAK,QAAQ,oBAAoB,WAC5C,SAAS,KAAK,MAAM,eAAe,SAAS,KAAK,QAAQ,iBAClD,OAAA,SAAS,KAAK,QAAQ,kBAI3B,SAAS,KAAK,QAAQ,qBAAqB,UAC7C,SAAS,KAAK,MAAM,WAAW,SAAS,KAAK,QAAQ,kBAC9C,OAAA,SAAS,KAAK,QAAQ,oBAEpB,SAAA,KAAK,MAAM,WAAW,IAGxB,SAAA,KAAK,MAAM,cAAc;AACpC;"}
|
|
@@ -1,51 +1,57 @@
|
|
|
1
1
|
import { jsxs as x, jsx as y } from "react/jsx-runtime";
|
|
2
|
-
import { memo as D, useState as
|
|
2
|
+
import { memo as D, useState as u, useRef as C, useCallback as s, useMemo as I, useEffect as P } from "react";
|
|
3
3
|
import b from "./modal.js";
|
|
4
|
-
import
|
|
5
|
-
import { lockScroll as R, unlockScroll as
|
|
6
|
-
const
|
|
7
|
-
const [o,
|
|
8
|
-
(
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import L from "./modal-context.js";
|
|
5
|
+
import { lockScroll as R, unlockScroll as $ } from "./modal-helpers.js";
|
|
6
|
+
const j = 500, O = D(({ children: S, modals: M, isUserAuthenticated: l }) => {
|
|
7
|
+
const [o, m] = u(null), [v, E] = u(void 0), [t, a] = u(!1), i = C(void 0), c = C(!1), w = s(() => {
|
|
8
|
+
c.current || (R(), c.current = !0);
|
|
9
|
+
}, []), k = s(() => {
|
|
10
|
+
$(), c.current = !1;
|
|
11
|
+
}, []), p = s(
|
|
12
|
+
(e, n, T) => {
|
|
13
|
+
if (c.current)
|
|
14
|
+
return;
|
|
15
|
+
const f = M.find((g) => g.name === e);
|
|
16
|
+
if (!f)
|
|
11
17
|
throw new Error(`Modal with name "${e}" not found`);
|
|
12
|
-
if (
|
|
18
|
+
if (f.isPrivate && !l)
|
|
13
19
|
throw new Error(
|
|
14
20
|
`Access violation: Modal "${e}" is private and user is not authenticated`
|
|
15
21
|
);
|
|
16
|
-
|
|
22
|
+
i.current = T, a(!1), m(f), E(n), w();
|
|
17
23
|
},
|
|
18
|
-
[
|
|
19
|
-
),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
}, []),
|
|
24
|
+
[l, w, M]
|
|
25
|
+
), r = s(() => {
|
|
26
|
+
a(!0), k(), setTimeout(() => {
|
|
27
|
+
m(null), a(!1);
|
|
28
|
+
}, j);
|
|
29
|
+
}, [k]), h = I(
|
|
24
30
|
() => ({
|
|
25
31
|
modal: o,
|
|
26
|
-
modalParams:
|
|
27
|
-
openModal:
|
|
28
|
-
closeModal:
|
|
29
|
-
isClosing:
|
|
32
|
+
modalParams: v,
|
|
33
|
+
openModal: p,
|
|
34
|
+
closeModal: r,
|
|
35
|
+
isClosing: t
|
|
30
36
|
}),
|
|
31
|
-
[o,
|
|
32
|
-
),
|
|
33
|
-
var e,
|
|
34
|
-
(o == null ? void 0 : o.isDismissable) !== !1 && !
|
|
35
|
-
}, [o,
|
|
36
|
-
return
|
|
37
|
-
!
|
|
38
|
-
}, [
|
|
39
|
-
const e = (
|
|
40
|
-
|
|
37
|
+
[o, v, p, r, t]
|
|
38
|
+
), d = s(() => {
|
|
39
|
+
var e, n;
|
|
40
|
+
(o == null ? void 0 : o.isDismissable) !== !1 && !t && (r(), i.current && ((n = (e = i.current).onCloseModal) == null || n.call(e), i.current.onCloseModal = void 0));
|
|
41
|
+
}, [o, r, t]);
|
|
42
|
+
return P(() => {
|
|
43
|
+
!l && (o != null && o.isPrivate) && r();
|
|
44
|
+
}, [l, o, r]), P(() => {
|
|
45
|
+
const e = (n) => {
|
|
46
|
+
n.key === "Escape" && d();
|
|
41
47
|
};
|
|
42
48
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
43
|
-
}, [
|
|
44
|
-
|
|
45
|
-
o && /* @__PURE__ */ y(b, { modal: o, isClosing:
|
|
49
|
+
}, [d]), /* @__PURE__ */ x(L.Provider, { value: h, children: [
|
|
50
|
+
S,
|
|
51
|
+
o && /* @__PURE__ */ y(b, { modal: o, isClosing: t, onClose: d })
|
|
46
52
|
] });
|
|
47
|
-
}),
|
|
53
|
+
}), q = O;
|
|
48
54
|
export {
|
|
49
|
-
|
|
55
|
+
q as default
|
|
50
56
|
};
|
|
51
57
|
//# sourceMappingURL=modal-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-provider.js","sources":["../../../../src/features/ui/modals/modal-provider.tsx"],"sourcesContent":["import type { IModal, IModalCallbacks, IModalContext, IModalProviderProps } from './modal-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport Modal from './modal';\nimport ModalContext from './modal-context';\nimport { lockScroll, unlockScroll } from './modal-helpers';\n\nconst ANIMATION_DURATION_MS = 500; // Match the animation duration in modal.tsx\n\n/**\n * Provider component that manages modal state and provides modal context to child components\n */\nconst ModalProvider: FC<IModalProviderProps> = memo(({ children, modals, isUserAuthenticated }) => {\n const [modal, setModal] = useState<IModal | null>(null);\n const [modalParams, setModalParams] = useState<Record<string, unknown> | undefined>(undefined);\n const [isClosing, setIsClosing] = useState(false);\n const callbacksRef = useRef<IModalCallbacks | undefined>(undefined);\n /**\n * Opens a modal by name with optional parameters\n * Handles authentication check for private modals\n */\n const openModal = useCallback<IModalContext['openModal']>(\n (modalName, newModalParams, callbacks) => {\n const newModal = modals.find(m => m.name === modalName);\n\n if (!newModal) {\n throw new Error(`Modal with name \"${modalName}\" not found`);\n }\n\n if (newModal.isPrivate && !isUserAuthenticated) {\n throw new Error(\n `Access violation: Modal \"${modalName}\" is private and user is not authenticated`,\n );\n }\n\n callbacksRef.current = callbacks;\n setIsClosing(false);\n setModal(newModal);\n setModalParams(newModalParams as unknown as Record<string, unknown> | undefined);\n
|
|
1
|
+
{"version":3,"file":"modal-provider.js","sources":["../../../../src/features/ui/modals/modal-provider.tsx"],"sourcesContent":["import type { IModal, IModalCallbacks, IModalContext, IModalProviderProps } from './modal-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport Modal from './modal';\nimport ModalContext from './modal-context';\nimport { lockScroll, unlockScroll } from './modal-helpers';\n\nconst ANIMATION_DURATION_MS = 500; // Match the animation duration in modal.tsx\n\n/**\n * Provider component that manages modal state and provides modal context to child components\n */\nconst ModalProvider: FC<IModalProviderProps> = memo(({ children, modals, isUserAuthenticated }) => {\n const [modal, setModal] = useState<IModal | null>(null);\n const [modalParams, setModalParams] = useState<Record<string, unknown> | undefined>(undefined);\n const [isClosing, setIsClosing] = useState(false);\n const callbacksRef = useRef<IModalCallbacks | undefined>(undefined);\n const isScrollLocked = useRef(false);\n\n // Enhanced lockScroll that tracks state\n const lockScrollWithTracking = useCallback(() => {\n if (isScrollLocked.current) return;\n lockScroll();\n isScrollLocked.current = true;\n }, []);\n\n // Enhanced unlockScroll that tracks state\n const unlockScrollWithTracking = useCallback(() => {\n unlockScroll();\n isScrollLocked.current = false;\n }, []);\n\n /**\n * Early return if scroll is already locked\n * Opens a modal by name with optional parameters\n * Handles authentication check for private modals\n */\n const openModal = useCallback<IModalContext['openModal']>(\n (modalName, newModalParams, callbacks) => {\n if (isScrollLocked.current) {\n return;\n }\n\n const newModal = modals.find(m => m.name === modalName);\n\n if (!newModal) {\n throw new Error(`Modal with name \"${modalName}\" not found`);\n }\n\n if (newModal.isPrivate && !isUserAuthenticated) {\n throw new Error(\n `Access violation: Modal \"${modalName}\" is private and user is not authenticated`,\n );\n }\n\n callbacksRef.current = callbacks;\n setIsClosing(false);\n setModal(newModal);\n setModalParams(newModalParams as unknown as Record<string, unknown> | undefined);\n lockScrollWithTracking();\n },\n [isUserAuthenticated, lockScrollWithTracking, modals],\n );\n\n const closeModal = useCallback(() => {\n setIsClosing(true);\n unlockScrollWithTracking();\n setTimeout(() => {\n setModal(null);\n setIsClosing(false);\n }, ANIMATION_DURATION_MS);\n }, [unlockScrollWithTracking]);\n\n const modalContent = useMemo<IModalContext>(\n () => ({\n modal,\n modalParams,\n openModal,\n closeModal,\n isClosing,\n }),\n [modal, modalParams, openModal, closeModal, isClosing],\n );\n\n const onModalDismiss = useCallback(() => {\n if (modal?.isDismissable !== false && !isClosing) {\n closeModal();\n if (callbacksRef.current) {\n callbacksRef.current.onCloseModal?.();\n callbacksRef.current.onCloseModal = undefined; // Clear callback reference\n }\n }\n }, [modal, closeModal, isClosing]);\n\n useEffect(() => {\n if (!isUserAuthenticated && modal?.isPrivate) {\n // If the modal is private and user is not authenticated, close it\n closeModal();\n }\n }, [isUserAuthenticated, modal, closeModal]);\n\n // Handle ESC key\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n onModalDismiss();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, [onModalDismiss]);\n\n return (\n <ModalContext.Provider value={modalContent}>\n {children}\n {modal && <Modal modal={modal} isClosing={isClosing} onClose={onModalDismiss} />}\n </ModalContext.Provider>\n );\n});\n\nexport default ModalProvider;\n"],"names":["ANIMATION_DURATION_MS","ModalProvider","memo","children","modals","isUserAuthenticated","modal","setModal","useState","modalParams","setModalParams","isClosing","setIsClosing","callbacksRef","useRef","isScrollLocked","lockScrollWithTracking","useCallback","lockScroll","unlockScrollWithTracking","unlockScroll","openModal","modalName","newModalParams","callbacks","newModal","m","closeModal","modalContent","useMemo","onModalDismiss","_b","_a","useEffect","handleKeyDown","e","jsxs","ModalContext","jsx","Modal","ModalProvider$1"],"mappings":";;;;;AASA,MAAMA,IAAwB,KAKxBC,IAAyCC,EAAK,CAAC,EAAE,UAAAC,GAAU,QAAAC,GAAQ,qBAAAC,QAA0B;AACjG,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAwB,IAAI,GAChD,CAACC,GAAaC,CAAc,IAAIF,EAA8C,MAAS,GACvF,CAACG,GAAWC,CAAY,IAAIJ,EAAS,EAAK,GAC1CK,IAAeC,EAAoC,MAAS,GAC5DC,IAAiBD,EAAO,EAAK,GAG7BE,IAAyBC,EAAY,MAAM;AAC/C,IAAIF,EAAe,YACRG,KACXH,EAAe,UAAU;AAAA,EAC3B,GAAG,CAAE,CAAA,GAGCI,IAA2BF,EAAY,MAAM;AACpC,IAAAG,KACbL,EAAe,UAAU;AAAA,EAC3B,GAAG,CAAE,CAAA,GAOCM,IAAYJ;AAAA,IAChB,CAACK,GAAWC,GAAgBC,MAAc;AACxC,UAAIT,EAAe;AACjB;AAGF,YAAMU,IAAWrB,EAAO,KAAK,CAAKsB,MAAAA,EAAE,SAASJ,CAAS;AAEtD,UAAI,CAACG;AACH,cAAM,IAAI,MAAM,oBAAoBH,CAAS,aAAa;AAGxD,UAAAG,EAAS,aAAa,CAACpB;AACzB,cAAM,IAAI;AAAA,UACR,4BAA4BiB,CAAS;AAAA,QAAA;AAIzC,MAAAT,EA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