@cfx-dev/ui-components 5.0.26 → 5.0.28
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/assets/all_css.css +1 -0
- package/dist/assets/css/Lightbox.css +1 -0
- package/dist/components/Lightbox/Lightbox.d.ts +9 -0
- package/dist/components/Lightbox/Lightbox.js +172 -0
- package/dist/components/Lightbox/LightboxShowcase.d.ts +6 -0
- package/dist/components/Lightbox/LightboxShowcase.js +137 -0
- package/dist/components/Lightbox/index.d.ts +2 -0
- package/dist/components/Lightbox/index.js +4 -0
- package/dist/components/Lightbox/types.d.ts +51 -0
- package/dist/components/Lightbox/types.js +1 -0
- package/dist/embla-carousel-react.esm-BE464U1q.js +1252 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +225 -224
- package/dist/utils/contexts/AnalyticsContext/AnalyticsContext.d.ts +15 -2
- package/dist/utils/contexts/AnalyticsContext/AnalyticsContext.js +9 -3
- package/dist/utils/contexts/AnalyticsContext/index.d.ts +2 -2
- package/dist/utils/contexts/AnalyticsContext/index.js +8 -7
- package/dist/utils/contexts/AnalyticsContext/useSiteLinkClick.js +12 -12
- package/dist/utils/hooks/useBodyScrollLock.d.ts +1 -0
- package/dist/utils/hooks/useBodyScrollLock.js +9 -0
- package/dist/utils/hooks/useCarousel.js +17 -1264
- package/dist/utils/hooks/useKeyboardArrows.d.ts +5 -0
- package/dist/utils/hooks/useKeyboardArrows.js +13 -0
- package/dist/utils/hooks/useLightbox.d.ts +21 -0
- package/dist/utils/hooks/useLightbox.js +80 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useDynamicRef as t } from "./useDynamicRef.js";
|
|
2
|
+
import { useGlobalKeyboardEvent as f } from "./useGlobalKeyboardEvent.js";
|
|
3
|
+
function o(r) {
|
|
4
|
+
const e = t((i) => {
|
|
5
|
+
o.isArrowLeft(i) && r("left"), o.isArrowRight(i) && r("right");
|
|
6
|
+
});
|
|
7
|
+
f(e);
|
|
8
|
+
}
|
|
9
|
+
o.isArrowLeft = (r) => r.key === "ArrowLeft";
|
|
10
|
+
o.isArrowRight = (r) => r.key === "ArrowRight";
|
|
11
|
+
export {
|
|
12
|
+
o as useKeyboardArrows
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { MediaItem, UseLightboxOptions } from '../../components/Lightbox/types';
|
|
3
|
+
|
|
4
|
+
export declare function useLightboxOpener(initialIndex?: number): {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
openLightbox: (idx: number) => void;
|
|
7
|
+
closeLightbox: () => void;
|
|
8
|
+
currentIndex: number;
|
|
9
|
+
handleIndexChange: (idx: number) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function useLightbox({ currentIndex, isOpen, onClose, onIndexChange, initialIndex, }: UseLightboxOptions & {
|
|
12
|
+
initialIndex?: number;
|
|
13
|
+
}): {
|
|
14
|
+
emblaRef: import('embla-carousel-react').EmblaViewportRefType;
|
|
15
|
+
getSelectedIndex: () => number;
|
|
16
|
+
handlePrevious: () => void;
|
|
17
|
+
handleNext: () => void;
|
|
18
|
+
handleOverlayClick: (e: React.MouseEvent) => void;
|
|
19
|
+
handleOverlayKeyDown: (e: React.KeyboardEvent) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare const usePreloadMedia: (items: MediaItem[], open: boolean) => void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { u as b } from "../../embla-carousel-react.esm-BE464U1q.js";
|
|
2
|
+
import { useCallback as c, useEffect as i, useState as g } from "react";
|
|
3
|
+
import { useBodyScrollLock as y } from "./useBodyScrollLock.js";
|
|
4
|
+
function L(o = 0) {
|
|
5
|
+
const [s, t] = g(!1), [l, n] = g(o), f = c((a) => {
|
|
6
|
+
n(a), t(!0);
|
|
7
|
+
}, []), e = c(() => {
|
|
8
|
+
t(!1);
|
|
9
|
+
}, []), u = c((a) => {
|
|
10
|
+
n(a);
|
|
11
|
+
}, []);
|
|
12
|
+
return {
|
|
13
|
+
isOpen: s,
|
|
14
|
+
openLightbox: f,
|
|
15
|
+
closeLightbox: e,
|
|
16
|
+
currentIndex: l,
|
|
17
|
+
handleIndexChange: u
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function v({
|
|
21
|
+
currentIndex: o,
|
|
22
|
+
isOpen: s,
|
|
23
|
+
onClose: t,
|
|
24
|
+
onIndexChange: l,
|
|
25
|
+
initialIndex: n
|
|
26
|
+
}) {
|
|
27
|
+
const [f, e] = b({
|
|
28
|
+
loop: !1,
|
|
29
|
+
startIndex: typeof n == "number" ? n : o
|
|
30
|
+
}), u = c(() => {
|
|
31
|
+
e && e.scrollPrev();
|
|
32
|
+
}, [e]), a = c(() => {
|
|
33
|
+
e && e.scrollNext();
|
|
34
|
+
}, [e]), d = c(
|
|
35
|
+
(r) => {
|
|
36
|
+
r.target === r.currentTarget && t();
|
|
37
|
+
},
|
|
38
|
+
[t]
|
|
39
|
+
), p = c(
|
|
40
|
+
(r) => {
|
|
41
|
+
(r.key === "Enter" || r.key === " ") && r.target === r.currentTarget && t();
|
|
42
|
+
},
|
|
43
|
+
[t]
|
|
44
|
+
), h = c(() => e ? e.selectedScrollSnap() : o, [e, o]);
|
|
45
|
+
return i(() => {
|
|
46
|
+
e && s && e.scrollTo(o);
|
|
47
|
+
}, [e, o, s]), i(() => {
|
|
48
|
+
if (!e)
|
|
49
|
+
return;
|
|
50
|
+
const r = () => {
|
|
51
|
+
const m = e.selectedScrollSnap();
|
|
52
|
+
l(m);
|
|
53
|
+
};
|
|
54
|
+
return e.on("select", r), () => {
|
|
55
|
+
e.off("select", r);
|
|
56
|
+
};
|
|
57
|
+
}, [e, l]), y(s), {
|
|
58
|
+
emblaRef: f,
|
|
59
|
+
getSelectedIndex: h,
|
|
60
|
+
handlePrevious: u,
|
|
61
|
+
handleNext: a,
|
|
62
|
+
handleOverlayClick: d,
|
|
63
|
+
handleOverlayKeyDown: p
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const w = (o, s) => {
|
|
67
|
+
i(() => {
|
|
68
|
+
s && o.forEach((t) => {
|
|
69
|
+
if (t.type === "image" && t.src) {
|
|
70
|
+
const l = new window.Image();
|
|
71
|
+
l.src = t.src;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}, [s, o]);
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
v as useLightbox,
|
|
78
|
+
L as useLightboxOpener,
|
|
79
|
+
w as usePreloadMedia
|
|
80
|
+
};
|