@cfx-dev/ui-components 5.0.26 → 5.0.27
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
package/dist/assets/all_css.css
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.cfxui__Lightbox__lightboxOverlay__dc0eb{position:fixed;top:0;right:0;bottom:0;left:0;display:flex;background:rgba(var(--color-bg),.9);align-items:center;justify-content:center;z-index:2;cursor:pointer}.cfxui__Lightbox__lightboxContainer__26f04{position:relative;width:100%;height:100%;max-width:calc(var(--quant) * 160);max-height:calc(var(--quant) * 100);cursor:default}.cfxui__Lightbox__lightboxImageContainer__eea35{position:relative;width:100%;height:100%;padding:calc(var(--quant) * 7) 0;display:flex;align-items:center;justify-content:center;overflow:hidden}.cfxui__Lightbox__lightboxImage__0f73c{object-fit:contain;width:100%;height:100%;max-width:100%;max-height:100%;position:absolute;left:0;top:0;opacity:1}.cfxui__Lightbox__lightboxVideo__cffdb{width:100%;height:calc(100% - 2 * var(--spacer-large));object-fit:contain;border:none;max-width:100%;max-height:100%;position:absolute;left:0;top:var(--spacer-large)}.cfxui__Lightbox__lightboxControlBtn__41c50{display:flex;align-items:center;justify-content:center;z-index:9000;width:calc(var(--quant) * 6);height:calc(var(--quant) * 6);border-radius:var(--border-radius-pill)}.cfxui__Lightbox__lightboxControlBtn__41c50:not(:disabled):hover{background-color:rgba(var(--color-secondary),.2)}.cfxui__Lightbox__lightboxClose__b2b96{position:absolute;top:calc(var(--quant) * .5);right:calc(var(--quant) * .5)}.cfxui__Lightbox__lightboxNav__60d29{position:absolute}.cfxui__Lightbox__lightboxPrev__35acc{left:calc(var(--quant) * .5);bottom:calc(var(--quant) * .5)}.cfxui__Lightbox__lightboxNext__09f51{right:calc(var(--quant) * .5);bottom:calc(var(--quant) * .5)}.cfxui__Lightbox__lightboxCounter__8824a{position:absolute;left:50%;bottom:calc(var(--quant) * 2);transform:translate(-50%);padding:calc(var(--quant) * .5) var(--quant);white-space:nowrap}.cfxui__Lightbox__lightboxEmbla__546be{overflow:hidden;width:100%;height:100%}.cfxui__Lightbox__lightboxEmblaContainer__3b54b{height:100%}.cfxui__Lightbox__lightboxEmblaSlide__64f0b{flex:0 0 calc(100% - calc(var(--quant) * 4));min-width:calc(100% - calc(var(--quant) * 4));height:100%;position:relative;overflow:hidden;margin:0 calc(var(--quant) * 4 / 2)}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LightboxImageComponentProps, LightboxProps, VideoComponentProps } from './types';
|
|
3
|
+
|
|
4
|
+
interface LightboxComponentProps extends LightboxProps {
|
|
5
|
+
LightboxImageComponent: React.ComponentType<LightboxImageComponentProps>;
|
|
6
|
+
VideoComponent: React.ComponentType<VideoComponentProps>;
|
|
7
|
+
}
|
|
8
|
+
declare function Lightbox({ LightboxImageComponent, VideoComponent, ...props }: LightboxComponentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export default Lightbox;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { jsx as t, jsxs as b, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import l from "react";
|
|
3
|
+
import d from "../Flex/Flex.js";
|
|
4
|
+
import { clsx as x } from "../../utils/clsx.js";
|
|
5
|
+
import m from "../IconButton/IconButton.js";
|
|
6
|
+
import { Text as S } from "../Text/Text.js";
|
|
7
|
+
import "../../utils/ui/ui.js";
|
|
8
|
+
import "../../utils/hooks/useGlobalKeyboardEvent.js";
|
|
9
|
+
import { useKeyboardClose as K } from "../../utils/hooks/useKeyboardClose.js";
|
|
10
|
+
import "../../index-CUyjBl1Y.js";
|
|
11
|
+
import { useKeyboardArrows as M } from "../../utils/hooks/useKeyboardArrows.js";
|
|
12
|
+
import { useLightbox as z } from "../../utils/hooks/useLightbox.js";
|
|
13
|
+
const V = "cfxui__Lightbox__lightboxOverlay__dc0eb", A = "cfxui__Lightbox__lightboxContainer__26f04", F = "cfxui__Lightbox__lightboxImageContainer__eea35", $ = "cfxui__Lightbox__lightboxImage__0f73c", j = "cfxui__Lightbox__lightboxVideo__cffdb", T = "cfxui__Lightbox__lightboxControlBtn__41c50", q = "cfxui__Lightbox__lightboxClose__b2b96", G = "cfxui__Lightbox__lightboxNav__60d29", H = "cfxui__Lightbox__lightboxPrev__35acc", J = "cfxui__Lightbox__lightboxNext__09f51", Q = "cfxui__Lightbox__lightboxCounter__8824a", W = "cfxui__Lightbox__lightboxEmbla__546be", X = "cfxui__Lightbox__lightboxEmblaContainer__3b54b", Y = "cfxui__Lightbox__lightboxEmblaSlide__64f0b", o = {
|
|
14
|
+
lightboxOverlay: V,
|
|
15
|
+
lightboxContainer: A,
|
|
16
|
+
lightboxImageContainer: F,
|
|
17
|
+
lightboxImage: $,
|
|
18
|
+
lightboxVideo: j,
|
|
19
|
+
lightboxControlBtn: T,
|
|
20
|
+
lightboxClose: q,
|
|
21
|
+
lightboxNav: G,
|
|
22
|
+
lightboxPrev: H,
|
|
23
|
+
lightboxNext: J,
|
|
24
|
+
lightboxCounter: Q,
|
|
25
|
+
lightboxEmbla: W,
|
|
26
|
+
lightboxEmblaContainer: X,
|
|
27
|
+
lightboxEmblaSlide: Y
|
|
28
|
+
};
|
|
29
|
+
function he({
|
|
30
|
+
LightboxImageComponent: v,
|
|
31
|
+
VideoComponent: p,
|
|
32
|
+
...N
|
|
33
|
+
}) {
|
|
34
|
+
const {
|
|
35
|
+
lightboxItems: i,
|
|
36
|
+
currentIndex: a,
|
|
37
|
+
isOpen: r,
|
|
38
|
+
onClose: c,
|
|
39
|
+
onIndexChange: y,
|
|
40
|
+
className: L,
|
|
41
|
+
showNavigation: I = !0,
|
|
42
|
+
showCounter: w = !0,
|
|
43
|
+
showCloseButton: E = !0
|
|
44
|
+
} = N, n = l.useRef(null), h = l.useRef(null), g = l.useRef(!1), {
|
|
45
|
+
emblaRef: R,
|
|
46
|
+
getSelectedIndex: O,
|
|
47
|
+
handlePrevious: s,
|
|
48
|
+
handleNext: _,
|
|
49
|
+
handleOverlayClick: f,
|
|
50
|
+
handleOverlayKeyDown: D
|
|
51
|
+
} = z({
|
|
52
|
+
currentIndex: a,
|
|
53
|
+
isOpen: r,
|
|
54
|
+
onClose: c,
|
|
55
|
+
onIndexChange: y,
|
|
56
|
+
initialIndex: n.current ?? a
|
|
57
|
+
}), C = O(), k = l.useCallback((e) => {
|
|
58
|
+
e.target === h.current && (g.current = !0);
|
|
59
|
+
}, []), B = l.useCallback((e) => {
|
|
60
|
+
e.target === h.current && g.current && f(e), g.current = !1;
|
|
61
|
+
}, [f]), U = l.useCallback((e) => {
|
|
62
|
+
e === "left" ? s() : e === "right" && _();
|
|
63
|
+
}, [s, _]);
|
|
64
|
+
return M(U), K(c), l.useEffect(() => {
|
|
65
|
+
r && n.current === null && (n.current = a), r || (n.current = null);
|
|
66
|
+
}, [r, a]), !r || !i.length ? null : /* @__PURE__ */ t(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
className: x(o.lightboxOverlay, L),
|
|
70
|
+
onMouseDown: k,
|
|
71
|
+
onMouseUp: B,
|
|
72
|
+
onKeyDown: D,
|
|
73
|
+
role: "button",
|
|
74
|
+
"aria-label": "Close lightbox",
|
|
75
|
+
tabIndex: 0,
|
|
76
|
+
ref: h,
|
|
77
|
+
children: /* @__PURE__ */ b("div", { className: o.lightboxContainer, children: [
|
|
78
|
+
" ",
|
|
79
|
+
E && /* @__PURE__ */ t(
|
|
80
|
+
m,
|
|
81
|
+
{
|
|
82
|
+
name: "Close",
|
|
83
|
+
className: x(o.lightboxClose, o.lightboxControlBtn),
|
|
84
|
+
onClick: c,
|
|
85
|
+
"aria-label": "Close lightbox",
|
|
86
|
+
size: "medium"
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ t("div", { className: o.lightboxImageContainer, children: /* @__PURE__ */ t(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: o.lightboxEmbla,
|
|
93
|
+
ref: R,
|
|
94
|
+
children: /* @__PURE__ */ t(d, { className: o.lightboxEmblaContainer, children: i.map((e, u) => /* @__PURE__ */ b(
|
|
95
|
+
d,
|
|
96
|
+
{
|
|
97
|
+
centered: !0,
|
|
98
|
+
className: o.lightboxEmblaSlide,
|
|
99
|
+
children: [
|
|
100
|
+
e.type === "video" && e.videoUrl && /* @__PURE__ */ t(
|
|
101
|
+
p,
|
|
102
|
+
{
|
|
103
|
+
src: e.videoUrl,
|
|
104
|
+
title: e.videoTitle,
|
|
105
|
+
className: o.lightboxVideo,
|
|
106
|
+
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
|
107
|
+
allowFullScreen: !0,
|
|
108
|
+
isActive: u === C
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
e.type === "image" && e.src && /* @__PURE__ */ t(
|
|
112
|
+
v,
|
|
113
|
+
{
|
|
114
|
+
src: e.src,
|
|
115
|
+
alt: e.alt ?? `Image ${u + 1} of ${i.length}`,
|
|
116
|
+
placeholder: e.blurDataURL ? "blur" : "empty",
|
|
117
|
+
blurDataURL: e.blurDataURL,
|
|
118
|
+
fill: !0,
|
|
119
|
+
className: o.lightboxImage
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
e.id ?? u
|
|
125
|
+
)) })
|
|
126
|
+
},
|
|
127
|
+
r && n.current !== null ? `open-${n.current}` : "closed"
|
|
128
|
+
) }),
|
|
129
|
+
" ",
|
|
130
|
+
I && i.length > 1 && /* @__PURE__ */ b(P, { children: [
|
|
131
|
+
/* @__PURE__ */ t(
|
|
132
|
+
m,
|
|
133
|
+
{
|
|
134
|
+
name: "LeftChevron",
|
|
135
|
+
className: x(o.lightboxNav, o.lightboxPrev, o.lightboxControlBtn),
|
|
136
|
+
onClick: s,
|
|
137
|
+
"aria-label": "Previous image",
|
|
138
|
+
size: "large"
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ t(
|
|
142
|
+
m,
|
|
143
|
+
{
|
|
144
|
+
name: "RightChevron",
|
|
145
|
+
className: x(o.lightboxNav, o.lightboxNext, o.lightboxControlBtn),
|
|
146
|
+
onClick: _,
|
|
147
|
+
"aria-label": "Next image",
|
|
148
|
+
size: "large"
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] }),
|
|
152
|
+
w && i.length > 1 && /* @__PURE__ */ b(
|
|
153
|
+
S,
|
|
154
|
+
{
|
|
155
|
+
color: "primary",
|
|
156
|
+
size: "xsmall",
|
|
157
|
+
className: o.lightboxCounter,
|
|
158
|
+
children: [
|
|
159
|
+
C + 1,
|
|
160
|
+
" ",
|
|
161
|
+
"/",
|
|
162
|
+
i.length
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] })
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
export {
|
|
171
|
+
he as default
|
|
172
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import c from "react";
|
|
3
|
+
import s from "../Flex/Flex.js";
|
|
4
|
+
import { Interactive as m } from "../Interactive/Interactive.js";
|
|
5
|
+
import h from "./Lightbox.js";
|
|
6
|
+
const a = [
|
|
7
|
+
{
|
|
8
|
+
id: "1",
|
|
9
|
+
type: "image",
|
|
10
|
+
src: "https://picsum.photos/1200/800?1",
|
|
11
|
+
alt: "Image 1"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: "2",
|
|
15
|
+
type: "image",
|
|
16
|
+
src: "https://picsum.photos/1200/800?2",
|
|
17
|
+
alt: "Image 2"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "3",
|
|
21
|
+
type: "image",
|
|
22
|
+
src: "https://picsum.photos/1200/800?3",
|
|
23
|
+
alt: "Image 3"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "4",
|
|
27
|
+
type: "video",
|
|
28
|
+
videoUrl: "https://www.youtube.com/embed/dQw4w9WgXcQ",
|
|
29
|
+
videoTitle: "YouTube Demo Video"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
function p({
|
|
33
|
+
src: r,
|
|
34
|
+
alt: o,
|
|
35
|
+
width: n,
|
|
36
|
+
height: i,
|
|
37
|
+
className: t
|
|
38
|
+
}) {
|
|
39
|
+
return /* @__PURE__ */ e(
|
|
40
|
+
"img",
|
|
41
|
+
{
|
|
42
|
+
src: r,
|
|
43
|
+
alt: o,
|
|
44
|
+
width: n,
|
|
45
|
+
height: i,
|
|
46
|
+
className: t,
|
|
47
|
+
style: {
|
|
48
|
+
objectFit: "cover",
|
|
49
|
+
width: "100%",
|
|
50
|
+
height: "100%"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function u({
|
|
56
|
+
src: r,
|
|
57
|
+
className: o,
|
|
58
|
+
title: n,
|
|
59
|
+
allow: i,
|
|
60
|
+
allowFullScreen: t
|
|
61
|
+
}) {
|
|
62
|
+
return /* @__PURE__ */ e(
|
|
63
|
+
"iframe",
|
|
64
|
+
{
|
|
65
|
+
src: r,
|
|
66
|
+
title: n,
|
|
67
|
+
className: o,
|
|
68
|
+
allow: i,
|
|
69
|
+
allowFullScreen: t,
|
|
70
|
+
style: {
|
|
71
|
+
width: "100%",
|
|
72
|
+
height: "100%",
|
|
73
|
+
border: 0
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
function I() {
|
|
79
|
+
const [r, o] = c.useState(!1), [n, i] = c.useState(0);
|
|
80
|
+
return /* @__PURE__ */ e(s, { direction: "column", gap: "large", children: /* @__PURE__ */ d(s, { direction: "column", gap: "small", children: [
|
|
81
|
+
/* @__PURE__ */ e("h4", { children: "Default" }),
|
|
82
|
+
/* @__PURE__ */ e(s, { gap: "small", children: a.map((t, l) => /* @__PURE__ */ e(
|
|
83
|
+
m,
|
|
84
|
+
{
|
|
85
|
+
onClick: () => {
|
|
86
|
+
i(l), o(!0);
|
|
87
|
+
},
|
|
88
|
+
children: t.type === "image" ? /* @__PURE__ */ e(
|
|
89
|
+
"img",
|
|
90
|
+
{
|
|
91
|
+
src: t.src,
|
|
92
|
+
alt: t.alt,
|
|
93
|
+
width: 150,
|
|
94
|
+
height: 100,
|
|
95
|
+
style: {
|
|
96
|
+
cursor: "pointer",
|
|
97
|
+
objectFit: "cover"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
) : /* @__PURE__ */ e(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
style: {
|
|
104
|
+
width: 150,
|
|
105
|
+
height: 100,
|
|
106
|
+
background: "#000",
|
|
107
|
+
color: "#fff",
|
|
108
|
+
display: "flex",
|
|
109
|
+
alignItems: "center",
|
|
110
|
+
justifyContent: "center",
|
|
111
|
+
fontSize: 14,
|
|
112
|
+
cursor: "pointer"
|
|
113
|
+
},
|
|
114
|
+
children: "YouTube Video"
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
},
|
|
118
|
+
t.id
|
|
119
|
+
)) }),
|
|
120
|
+
/* @__PURE__ */ e(
|
|
121
|
+
h,
|
|
122
|
+
{
|
|
123
|
+
lightboxItems: a,
|
|
124
|
+
currentIndex: n,
|
|
125
|
+
isOpen: r,
|
|
126
|
+
onClose: () => o(!1),
|
|
127
|
+
onIndexChange: i,
|
|
128
|
+
LightboxImageComponent: p,
|
|
129
|
+
VideoComponent: u
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] }) });
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
I as default,
|
|
136
|
+
a as items
|
|
137
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type LightboxImageItem = {
|
|
2
|
+
type: 'image';
|
|
3
|
+
src: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
id?: string | number;
|
|
6
|
+
blurDataURL?: string;
|
|
7
|
+
};
|
|
8
|
+
export type LightboxVideoItem = {
|
|
9
|
+
type: 'video';
|
|
10
|
+
videoUrl: string;
|
|
11
|
+
videoTitle?: string;
|
|
12
|
+
id?: string | number;
|
|
13
|
+
};
|
|
14
|
+
export type MediaItem = LightboxImageItem | LightboxVideoItem;
|
|
15
|
+
export interface UseLightboxOptions {
|
|
16
|
+
lightboxItems: MediaItem[];
|
|
17
|
+
currentIndex: number;
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
onIndexChange: (idx: number) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface LightboxProps {
|
|
23
|
+
lightboxItems: MediaItem[];
|
|
24
|
+
currentIndex: number;
|
|
25
|
+
isOpen: boolean;
|
|
26
|
+
onClose: () => void;
|
|
27
|
+
onIndexChange: (index: number) => void;
|
|
28
|
+
className?: string;
|
|
29
|
+
showNavigation?: boolean;
|
|
30
|
+
showCounter?: boolean;
|
|
31
|
+
showCloseButton?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type SwipeDirection = 'left' | 'right';
|
|
34
|
+
export interface LightboxImageComponentProps {
|
|
35
|
+
src: string;
|
|
36
|
+
alt?: string;
|
|
37
|
+
width?: number;
|
|
38
|
+
height?: number;
|
|
39
|
+
className?: string;
|
|
40
|
+
placeholder?: 'blur' | 'empty';
|
|
41
|
+
blurDataURL?: string;
|
|
42
|
+
fill?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface VideoComponentProps {
|
|
45
|
+
src: string;
|
|
46
|
+
title?: string;
|
|
47
|
+
className?: string;
|
|
48
|
+
allow: string;
|
|
49
|
+
allowFullScreen?: boolean;
|
|
50
|
+
isActive?: boolean;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|