react-pic-gallery 2.0.2 → 2.1.0
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/README.md +71 -15
- package/dist/Carousel.d.ts +19 -0
- package/dist/Gallery.d.ts +1 -1
- package/dist/Image.d.ts +5 -2
- package/dist/Lightbox.d.ts +1 -1
- package/dist/PicGallery.d.ts +1 -1
- package/dist/imageSources.d.ts +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/react-pic-gallery.js +546 -325
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/useAdjacentImagePreload.d.ts +4 -0
- package/dist/useCarouselNavigation.d.ts +21 -0
- package/dist/utils.d.ts +11 -0
- package/package.json +5 -1
|
@@ -2,40 +2,62 @@ import { memo as e, useCallback as t, useEffect as n, useId as r, useLayoutEffec
|
|
|
2
2
|
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
3
|
import { createPortal as u } from "react-dom";
|
|
4
4
|
//#region src/lib/Image.tsx
|
|
5
|
-
function d({ src: e,
|
|
6
|
-
let
|
|
5
|
+
function d({ src: e, srcSet: t, sizes: r, alt: i, className: s = "", imageClassName: u = "", style: d, imageStyle: f, onAnimationEnd: p, onClick: m, eager: h = !1, objectFit: g = "cover", width: _, height: v }) {
|
|
6
|
+
let y = a(null), b = JSON.stringify([
|
|
7
|
+
e,
|
|
8
|
+
t ?? null,
|
|
9
|
+
r ?? null
|
|
10
|
+
]), [x, S] = o({
|
|
11
|
+
sourceKey: b,
|
|
12
|
+
status: "loading"
|
|
13
|
+
}), C = x.sourceKey === b ? x.status : "loading";
|
|
7
14
|
return n(() => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
S({
|
|
16
|
+
sourceKey: b,
|
|
17
|
+
status: "loading"
|
|
18
|
+
});
|
|
19
|
+
let e = y.current;
|
|
20
|
+
e?.complete && S({
|
|
21
|
+
sourceKey: b,
|
|
22
|
+
status: e.naturalWidth > 0 ? "loaded" : "error"
|
|
23
|
+
});
|
|
24
|
+
}, [b]), /* @__PURE__ */ l("span", {
|
|
25
|
+
className: `react-pic-gallery__image ${s}`.trim(),
|
|
26
|
+
style: d,
|
|
27
|
+
"aria-busy": C === "loading",
|
|
28
|
+
onAnimationEnd: p,
|
|
29
|
+
onClick: m,
|
|
16
30
|
children: [
|
|
17
31
|
/* @__PURE__ */ c("img", {
|
|
18
|
-
ref:
|
|
32
|
+
ref: y,
|
|
33
|
+
sizes: r,
|
|
34
|
+
srcSet: t,
|
|
19
35
|
src: e,
|
|
20
|
-
alt:
|
|
21
|
-
className: `react-pic-gallery__image-element ${
|
|
36
|
+
alt: i,
|
|
37
|
+
className: `react-pic-gallery__image-element ${u}`.trim(),
|
|
22
38
|
style: {
|
|
23
|
-
objectFit:
|
|
24
|
-
...
|
|
39
|
+
objectFit: g,
|
|
40
|
+
...f
|
|
25
41
|
},
|
|
26
|
-
loading:
|
|
42
|
+
loading: h ? "eager" : "lazy",
|
|
27
43
|
decoding: "async",
|
|
28
|
-
width:
|
|
29
|
-
height:
|
|
30
|
-
onLoad: () =>
|
|
31
|
-
|
|
44
|
+
width: _,
|
|
45
|
+
height: v,
|
|
46
|
+
onLoad: () => S({
|
|
47
|
+
sourceKey: b,
|
|
48
|
+
status: "loaded"
|
|
49
|
+
}),
|
|
50
|
+
onError: () => S({
|
|
51
|
+
sourceKey: b,
|
|
52
|
+
status: "error"
|
|
53
|
+
})
|
|
32
54
|
}),
|
|
33
|
-
|
|
55
|
+
C === "loading" && /* @__PURE__ */ c("span", {
|
|
34
56
|
className: "react-pic-gallery__image-loader",
|
|
35
57
|
role: "progressbar",
|
|
36
58
|
"aria-label": "Loading image"
|
|
37
59
|
}),
|
|
38
|
-
|
|
60
|
+
C === "error" && /* @__PURE__ */ c("span", {
|
|
39
61
|
className: "react-pic-gallery__image-error",
|
|
40
62
|
role: "status",
|
|
41
63
|
children: "Unable to load image"
|
|
@@ -43,15 +65,235 @@ function d({ src: e, alt: t, className: r = "", imageClassName: i = "", style: s
|
|
|
43
65
|
]
|
|
44
66
|
});
|
|
45
67
|
}
|
|
68
|
+
function f(e) {
|
|
69
|
+
return e instanceof Element && e.closest("a[href], button, input, select, textarea, [role=\"combobox\"], [role=\"menu\"], [role=\"slider\"], [role=\"spinbutton\"], [role=\"tab\"]") !== null;
|
|
70
|
+
}
|
|
71
|
+
function p(e, t) {
|
|
72
|
+
if (!t || window.matchMedia?.("(max-width: 600px), (pointer: coarse)")?.matches !== !0) return null;
|
|
73
|
+
let n = t.getBoundingClientRect();
|
|
74
|
+
if (n.width <= 0) return null;
|
|
75
|
+
let r = (e - n.left) / n.width;
|
|
76
|
+
return r < .3 ? "previous" : r > .7 ? "next" : null;
|
|
77
|
+
}
|
|
78
|
+
function m() {
|
|
79
|
+
return /* @__PURE__ */ c("svg", {
|
|
80
|
+
viewBox: "0 0 24 24",
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
focusable: "false",
|
|
83
|
+
children: /* @__PURE__ */ c("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function h({ direction: e }) {
|
|
87
|
+
return /* @__PURE__ */ c("svg", {
|
|
88
|
+
viewBox: "0 0 24 24",
|
|
89
|
+
"aria-hidden": "true",
|
|
90
|
+
focusable: "false",
|
|
91
|
+
children: /* @__PURE__ */ c("path", { d: e === "left" ? "M14.5 5l-7 7 7 7" : "M9.5 5l7 7-7 7" })
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function g(...e) {
|
|
95
|
+
return e.filter(Boolean).join(" ");
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/lib/imageSources.ts
|
|
99
|
+
function _(e) {
|
|
100
|
+
return {
|
|
101
|
+
src: e.src,
|
|
102
|
+
srcSet: e.srcSet,
|
|
103
|
+
sizes: e.sizes
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function v(e) {
|
|
107
|
+
return e.thumbnailSrc === void 0 && e.thumbnailSrcSet === void 0 ? _(e) : {
|
|
108
|
+
src: e.thumbnailSrc ?? e.src,
|
|
109
|
+
srcSet: e.thumbnailSrcSet,
|
|
110
|
+
sizes: e.thumbnailSizes
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function y(e) {
|
|
114
|
+
return JSON.stringify([
|
|
115
|
+
e.src,
|
|
116
|
+
e.srcSet ?? null,
|
|
117
|
+
e.sizes ?? null
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/lib/useAdjacentImagePreload.ts
|
|
122
|
+
var b = 32, x = /* @__PURE__ */ new Map();
|
|
123
|
+
function S(e) {
|
|
124
|
+
e.image &&= (e.image.removeEventListener("load", e.onLoad), e.image.removeEventListener("error", e.onError), null);
|
|
125
|
+
}
|
|
126
|
+
function C(e) {
|
|
127
|
+
S(e), x.get(e.key) === e && x.delete(e.key);
|
|
128
|
+
}
|
|
129
|
+
function w() {
|
|
130
|
+
for (; x.size >= b;) {
|
|
131
|
+
let e = [...x.values()].find((e) => e.owners.size === 0);
|
|
132
|
+
if (!e) return !1;
|
|
133
|
+
C(e);
|
|
134
|
+
}
|
|
135
|
+
return !0;
|
|
136
|
+
}
|
|
137
|
+
function T(e) {
|
|
138
|
+
x.delete(e.key), x.set(e.key, e);
|
|
139
|
+
}
|
|
140
|
+
function E(e, t) {
|
|
141
|
+
if (!e.src.trim()) return null;
|
|
142
|
+
let n = y(e), r = x.get(n);
|
|
143
|
+
if (r) return r.owners.add(t), T(r), r;
|
|
144
|
+
if (typeof Image > "u" || !w()) return null;
|
|
145
|
+
let i = new Image(), a = {
|
|
146
|
+
key: n,
|
|
147
|
+
status: "pending",
|
|
148
|
+
image: i,
|
|
149
|
+
owners: /* @__PURE__ */ new Set([t]),
|
|
150
|
+
onLoad: () => {},
|
|
151
|
+
onError: () => {}
|
|
152
|
+
};
|
|
153
|
+
a.onLoad = () => {
|
|
154
|
+
x.get(n) === a && (a.status = "loaded", S(a));
|
|
155
|
+
}, a.onError = () => {
|
|
156
|
+
x.get(n) === a && C(a);
|
|
157
|
+
}, x.set(n, a), i.addEventListener("load", a.onLoad), i.addEventListener("error", a.onError), i.fetchPriority = "low";
|
|
158
|
+
try {
|
|
159
|
+
e.sizes !== void 0 && (i.sizes = e.sizes), e.srcSet !== void 0 && (i.srcset = e.srcSet), i.src = e.src;
|
|
160
|
+
} catch {
|
|
161
|
+
C(a);
|
|
162
|
+
}
|
|
163
|
+
return a;
|
|
164
|
+
}
|
|
165
|
+
function D(e, t) {
|
|
166
|
+
e.owners.delete(t), e.status === "pending" && e.owners.size === 0 && C(e);
|
|
167
|
+
}
|
|
168
|
+
function O(e, t, r) {
|
|
169
|
+
n(() => {
|
|
170
|
+
if (!r || e.length < 2 || t < 0 || t >= e.length) return;
|
|
171
|
+
let n = Symbol("adjacent-image-preload"), i = /* @__PURE__ */ new Map();
|
|
172
|
+
for (let n of [t - 1, t + 1]) {
|
|
173
|
+
if (n < 0 || n >= e.length) continue;
|
|
174
|
+
let t = _(e[n]);
|
|
175
|
+
i.set(y(t), t);
|
|
176
|
+
}
|
|
177
|
+
let a = [...i.values()].map((e) => E(e, n)).filter((e) => e !== null);
|
|
178
|
+
return () => {
|
|
179
|
+
a.forEach((e) => D(e, n));
|
|
180
|
+
};
|
|
181
|
+
}, [
|
|
182
|
+
r,
|
|
183
|
+
e,
|
|
184
|
+
t
|
|
185
|
+
]);
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/lib/Carousel.tsx
|
|
189
|
+
function k(e) {
|
|
190
|
+
let { images: t, index: n, navigation: r, renderActions: i, renderCaption: a, renderControls: o, showCounter: u = !0, showNavigation: f = !0, preloadAdjacent: v = !0, close: y, onEmptyAreaClick: b, onImageClick: x, className: S } = e, C = t[n];
|
|
191
|
+
O(t, n, v);
|
|
192
|
+
let w = C ? _(C) : void 0, T = {
|
|
193
|
+
image: C,
|
|
194
|
+
index: n,
|
|
195
|
+
count: t.length,
|
|
196
|
+
close: y ?? (() => {}),
|
|
197
|
+
next: r.next,
|
|
198
|
+
previous: r.previous,
|
|
199
|
+
canGoNext: n < t.length - 1,
|
|
200
|
+
canGoPrevious: n > 0
|
|
201
|
+
}, E = f && t.length > 1, D = f && T.canGoPrevious, k = f && T.canGoNext;
|
|
202
|
+
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l("p", {
|
|
203
|
+
className: "react-pic-gallery__sr-only",
|
|
204
|
+
"aria-live": "polite",
|
|
205
|
+
children: [
|
|
206
|
+
C.alt,
|
|
207
|
+
", image ",
|
|
208
|
+
n + 1,
|
|
209
|
+
" of ",
|
|
210
|
+
t.length
|
|
211
|
+
]
|
|
212
|
+
}), /* @__PURE__ */ l("div", {
|
|
213
|
+
className: g("react-pic-gallery__lightbox-content", S),
|
|
214
|
+
children: [
|
|
215
|
+
o ? /* @__PURE__ */ c("div", {
|
|
216
|
+
className: "react-pic-gallery__custom-controls",
|
|
217
|
+
children: o(T)
|
|
218
|
+
}) : /* @__PURE__ */ l("div", {
|
|
219
|
+
className: "react-pic-gallery__toolbar",
|
|
220
|
+
children: [/* @__PURE__ */ l("div", {
|
|
221
|
+
className: "react-pic-gallery__toolbar-actions",
|
|
222
|
+
children: [u && /* @__PURE__ */ l("span", {
|
|
223
|
+
"aria-live": "polite",
|
|
224
|
+
children: [
|
|
225
|
+
n + 1,
|
|
226
|
+
" / ",
|
|
227
|
+
t.length
|
|
228
|
+
]
|
|
229
|
+
}), i?.(T)]
|
|
230
|
+
}), y && /* @__PURE__ */ c("button", {
|
|
231
|
+
className: "react-pic-gallery__control",
|
|
232
|
+
type: "button",
|
|
233
|
+
onClick: y,
|
|
234
|
+
"aria-label": "Close image viewer",
|
|
235
|
+
children: /* @__PURE__ */ c(m, {})
|
|
236
|
+
})]
|
|
237
|
+
}),
|
|
238
|
+
/* @__PURE__ */ l("div", {
|
|
239
|
+
className: g("react-pic-gallery__viewport", E ? "react-pic-gallery__viewport--has-navigation" : void 0),
|
|
240
|
+
onMouseDown: (e) => {
|
|
241
|
+
e.target === e.currentTarget && b?.();
|
|
242
|
+
},
|
|
243
|
+
onClick: r.handleViewportClick,
|
|
244
|
+
onTouchCancel: r.handleTouchCancel,
|
|
245
|
+
onTouchEnd: r.handleTouchEnd,
|
|
246
|
+
onTouchStart: r.handleTouchStart,
|
|
247
|
+
children: [
|
|
248
|
+
D && /* @__PURE__ */ c("button", {
|
|
249
|
+
className: "react-pic-gallery__control react-pic-gallery__control--previous",
|
|
250
|
+
type: "button",
|
|
251
|
+
onClick: r.previous,
|
|
252
|
+
"aria-label": "Previous image",
|
|
253
|
+
children: /* @__PURE__ */ c(h, { direction: "left" })
|
|
254
|
+
}),
|
|
255
|
+
/* @__PURE__ */ c(d, {
|
|
256
|
+
sizes: w?.sizes,
|
|
257
|
+
srcSet: w?.srcSet,
|
|
258
|
+
src: w?.src ?? "",
|
|
259
|
+
alt: C.alt,
|
|
260
|
+
eager: !0,
|
|
261
|
+
objectFit: "contain",
|
|
262
|
+
className: g("react-pic-gallery__lightbox-image", r.swipeDirection ? `react-pic-gallery__lightbox-image--swipe-${r.swipeDirection}` : void 0),
|
|
263
|
+
onAnimationEnd: r.handleImageAnimationEnd,
|
|
264
|
+
onClick: x ? (e) => {
|
|
265
|
+
f && t.length > 1 && p(e.clientX, e.currentTarget.parentElement) !== null || x();
|
|
266
|
+
} : void 0
|
|
267
|
+
}, w ? JSON.stringify([
|
|
268
|
+
w.src,
|
|
269
|
+
w.srcSet,
|
|
270
|
+
w.sizes
|
|
271
|
+
]) : n),
|
|
272
|
+
k && /* @__PURE__ */ c("button", {
|
|
273
|
+
className: "react-pic-gallery__control react-pic-gallery__control--next",
|
|
274
|
+
type: "button",
|
|
275
|
+
onClick: r.next,
|
|
276
|
+
"aria-label": "Next image",
|
|
277
|
+
children: /* @__PURE__ */ c(h, { direction: "right" })
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
}),
|
|
281
|
+
(a || C.caption) && /* @__PURE__ */ c("div", {
|
|
282
|
+
className: "react-pic-gallery__caption",
|
|
283
|
+
children: a ? a(T) : C.caption
|
|
284
|
+
})
|
|
285
|
+
]
|
|
286
|
+
})] });
|
|
287
|
+
}
|
|
46
288
|
//#endregion
|
|
47
289
|
//#region src/lib/layout.ts
|
|
48
|
-
var
|
|
49
|
-
function
|
|
50
|
-
return Number.isFinite(e.width) && Number.isFinite(e.height) && e.width !== void 0 && e.height !== void 0 && e.width > 0 && e.height > 0 ? e.width / e.height :
|
|
290
|
+
var A = 3 / 2;
|
|
291
|
+
function j(e) {
|
|
292
|
+
return Number.isFinite(e.width) && Number.isFinite(e.height) && e.width !== void 0 && e.height !== void 0 && e.width > 0 && e.height > 0 ? e.width / e.height : A;
|
|
51
293
|
}
|
|
52
|
-
function
|
|
294
|
+
function M(e, t, n, r) {
|
|
53
295
|
if (e.length === 0) return [];
|
|
54
|
-
let i = Math.max(1, t), a = Math.max(1, n), o = Math.max(0, r), s = e.map(
|
|
296
|
+
let i = Math.max(1, t), a = Math.max(1, n), o = Math.max(0, r), s = e.map(j), c = [], l = 0;
|
|
55
297
|
for (; l < e.length;) {
|
|
56
298
|
let t = l + 1, n = i / s[l], r = Math.abs(n - a), u = s[l];
|
|
57
299
|
for (let c = l + 1; c < e.length; c += 1) {
|
|
@@ -70,29 +312,121 @@ function m(e, t, n, r) {
|
|
|
70
312
|
return c;
|
|
71
313
|
}
|
|
72
314
|
//#endregion
|
|
315
|
+
//#region src/lib/useCarouselNavigation.ts
|
|
316
|
+
function N(e) {
|
|
317
|
+
let { images: n, index: r, onIndexChange: i, disabled: s = !1, showNavigation: c = !0 } = e, l = a(n), u = a(r), d = a(i), m = a(s), h = a(c), g = a(null), [_, v] = o(null);
|
|
318
|
+
l.current = n, u.current = r, d.current = i, m.current = s, h.current = c;
|
|
319
|
+
let y = t(() => {
|
|
320
|
+
let e = u.current;
|
|
321
|
+
!m.current && e !== null && e > 0 && d.current(e - 1);
|
|
322
|
+
}, []), b = t(() => {
|
|
323
|
+
let e = u.current;
|
|
324
|
+
!m.current && e !== null && e < l.current.length - 1 && d.current(e + 1);
|
|
325
|
+
}, []), x = t(() => {
|
|
326
|
+
let e = u.current;
|
|
327
|
+
m.current || e === null || e === 0 || (v("previous"), d.current(e - 1));
|
|
328
|
+
}, []), S = t(() => {
|
|
329
|
+
let e = u.current;
|
|
330
|
+
m.current || e === null || e >= l.current.length - 1 || (v("next"), d.current(e + 1));
|
|
331
|
+
}, []);
|
|
332
|
+
return {
|
|
333
|
+
previous: y,
|
|
334
|
+
next: b,
|
|
335
|
+
swipeDirection: _,
|
|
336
|
+
handleKeyDown: t((e) => {
|
|
337
|
+
if (e.defaultPrevented) return;
|
|
338
|
+
let t = e.target;
|
|
339
|
+
t instanceof HTMLElement && (t.isContentEditable || t.closest("input, select, textarea, [role=\"combobox\"], [role=\"menu\"], [role=\"slider\"], [role=\"spinbutton\"], [role=\"tab\"]")) || (e.key === "ArrowLeft" ? (e.preventDefault(), y()) : e.key === "ArrowRight" && (e.preventDefault(), b()));
|
|
340
|
+
}, [b, y]),
|
|
341
|
+
handleTouchStart: t((e) => {
|
|
342
|
+
if (e.touches.length !== 1 || f(e.target)) {
|
|
343
|
+
g.current = null;
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
let t = e.touches[0];
|
|
347
|
+
g.current = {
|
|
348
|
+
x: t.clientX,
|
|
349
|
+
y: t.clientY
|
|
350
|
+
};
|
|
351
|
+
}, []),
|
|
352
|
+
handleTouchEnd: t((e) => {
|
|
353
|
+
let t = g.current;
|
|
354
|
+
if (g.current = null, m.current || !t || e.changedTouches.length === 0) return;
|
|
355
|
+
let n = e.changedTouches[0], r = n.clientX - t.x, i = n.clientY - t.y, a = Math.abs(r);
|
|
356
|
+
a < 48 || a <= Math.abs(i) || (r < 0 ? S() : x());
|
|
357
|
+
}, [S, x]),
|
|
358
|
+
handleTouchCancel: t(() => {
|
|
359
|
+
g.current = null;
|
|
360
|
+
}, []),
|
|
361
|
+
handleImageAnimationEnd: t((e) => {
|
|
362
|
+
e.target === e.currentTarget && v(null);
|
|
363
|
+
}, []),
|
|
364
|
+
handleViewportClick: t((e) => {
|
|
365
|
+
if (!h.current || l.current.length <= 1 || m.current || !(e.target instanceof Element) || e.target.closest("button")) return;
|
|
366
|
+
let t = p(e.clientX, e.currentTarget);
|
|
367
|
+
t === "previous" ? y() : t === "next" && b();
|
|
368
|
+
}, [b, y])
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
//#endregion
|
|
73
372
|
//#region src/lib/Gallery.tsx
|
|
74
|
-
var
|
|
75
|
-
function
|
|
76
|
-
let
|
|
373
|
+
var P = 3, F = 192, I = 12, L = typeof window > "u" ? n : i;
|
|
374
|
+
function R(e) {
|
|
375
|
+
let t = Number.parseFloat(e);
|
|
376
|
+
return Number.isFinite(t) && t >= 0 ? t : null;
|
|
377
|
+
}
|
|
378
|
+
function z(e) {
|
|
379
|
+
return Number.isFinite(e) && e > 0;
|
|
380
|
+
}
|
|
381
|
+
function B({ images: e, onImageClick: t, renderCaption: n, showCounter: r, showNavigation: i, preloadAdjacent: a }) {
|
|
382
|
+
let [s, l] = o(0), u = Math.max(0, Math.min(s, e.length - 1)), d = N({
|
|
383
|
+
images: e,
|
|
384
|
+
index: e.length > 0 ? u : null,
|
|
385
|
+
onIndexChange: (e) => {
|
|
386
|
+
e !== null && l(e);
|
|
387
|
+
},
|
|
388
|
+
showNavigation: i
|
|
389
|
+
});
|
|
390
|
+
return e.length === 0 ? null : /* @__PURE__ */ c("div", {
|
|
391
|
+
className: "react-pic-gallery__carousel",
|
|
392
|
+
role: "region",
|
|
393
|
+
"aria-roledescription": "carousel",
|
|
394
|
+
"aria-label": "Image carousel",
|
|
395
|
+
tabIndex: 0,
|
|
396
|
+
onKeyDown: d.handleKeyDown,
|
|
397
|
+
children: /* @__PURE__ */ c(k, {
|
|
398
|
+
images: e,
|
|
399
|
+
index: u,
|
|
400
|
+
navigation: d,
|
|
401
|
+
renderCaption: n,
|
|
402
|
+
showCounter: r,
|
|
403
|
+
showNavigation: i,
|
|
404
|
+
preloadAdjacent: a,
|
|
405
|
+
onImageClick: () => t?.(u)
|
|
406
|
+
})
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
function V({ images: e, onImageClick: n, layout: r = "grid", appearance: i = "framed", columns: u, rowHeight: f, className: p = "", style: m, renderCaption: h, showCounter: g, showNavigation: _, preloadAdjacent: y = !0 }) {
|
|
410
|
+
let b = a([]), x = a(null), S = a(null), [C, w] = o(0), [T, E] = o({
|
|
77
411
|
width: 1024,
|
|
78
|
-
rowHeight:
|
|
79
|
-
gap:
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
82
|
-
...r === "grid" &&
|
|
83
|
-
...
|
|
412
|
+
rowHeight: F,
|
|
413
|
+
gap: I
|
|
414
|
+
}), D = u !== void 0 && Number.isFinite(u) && u >= 1 ? Math.floor(u) : P, O = e.length - 1, k = Math.min(C, Math.max(O, 0)), A = typeof f == "number" ? `${f}px` : f, j = {
|
|
415
|
+
...m,
|
|
416
|
+
...r === "grid" && u !== void 0 && Number.isFinite(u) && u >= 1 ? { gridTemplateColumns: `repeat(${D}, minmax(0, 1fr))` } : {},
|
|
417
|
+
...A ? { "--gallery-row-height": A } : {}
|
|
84
418
|
};
|
|
85
|
-
|
|
419
|
+
L(() => {
|
|
86
420
|
if (r !== "justified") return;
|
|
87
|
-
let e =
|
|
421
|
+
let e = x.current, t = S.current;
|
|
88
422
|
if (!e || !t) return;
|
|
89
423
|
let n = () => {
|
|
90
|
-
let n = e.getBoundingClientRect().width
|
|
91
|
-
|
|
424
|
+
let n = e.getBoundingClientRect(), r = window.getComputedStyle(e), i = (R(r.paddingLeft) ?? 0) + (R(r.paddingRight) ?? 0), a = (R(r.borderLeftWidth) ?? 0) + (R(r.borderRightWidth) ?? 0), o = [n.width - i - a, e.clientWidth - i].find(z) ?? (z(window.innerWidth) ? window.innerWidth : 1024), s = t.getBoundingClientRect(), c = Number.parseFloat(window.getComputedStyle(t).width), l = typeof f == "number" ? f : typeof f == "string" && /^\s*\d+(?:\.\d+)?px\s*$/.test(f) ? Number.parseFloat(f) : null, u = l !== null && z(l) ? l : F, d = z(s.height) ? s.height : u, p = [c, s.width].find((e) => Number.isFinite(e) && e >= 0) ?? I;
|
|
425
|
+
E((e) => {
|
|
92
426
|
let t = {
|
|
93
|
-
width:
|
|
94
|
-
rowHeight:
|
|
95
|
-
gap:
|
|
427
|
+
width: o,
|
|
428
|
+
rowHeight: d,
|
|
429
|
+
gap: p
|
|
96
430
|
};
|
|
97
431
|
return e.width === t.width && e.rowHeight === t.rowHeight && e.gap === t.gap ? e : t;
|
|
98
432
|
});
|
|
@@ -103,19 +437,20 @@ function y({ images: e, onImageClick: n, layout: r = "grid", columns: i, rowHeig
|
|
|
103
437
|
i?.disconnect(), window.removeEventListener("resize", n);
|
|
104
438
|
};
|
|
105
439
|
}, [
|
|
440
|
+
i,
|
|
106
441
|
r,
|
|
107
|
-
|
|
108
|
-
|
|
442
|
+
f,
|
|
443
|
+
A
|
|
109
444
|
]);
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
}, []),
|
|
113
|
-
let i =
|
|
445
|
+
let N = t((e) => {
|
|
446
|
+
w(e), b.current[e]?.focus();
|
|
447
|
+
}, []), V = t((t, n) => {
|
|
448
|
+
let i = b.current[t];
|
|
114
449
|
if (!i) return null;
|
|
115
450
|
let a = i.getBoundingClientRect();
|
|
116
451
|
if (r === "mosaic" && i.classList.contains("react-pic-gallery__tile--mosaic-featured")) {
|
|
117
452
|
let r = i.closest(".react-pic-gallery__mosaic-group"), o = a.left + a.width / 2, s = a.top + a.height / 2, c = null, l = Infinity;
|
|
118
|
-
if (
|
|
453
|
+
if (b.current.slice(0, e.length).forEach((e, i) => {
|
|
119
454
|
if (!e || i === t || !r?.contains(e)) return;
|
|
120
455
|
let a = e.getBoundingClientRect(), u = a.left + a.width / 2, d = a.top + a.height / 2, f = n === "up" ? s - d : d - s;
|
|
121
456
|
if (f <= 0) return;
|
|
@@ -124,82 +459,95 @@ function y({ images: e, onImageClick: n, layout: r = "grid", columns: i, rowHeig
|
|
|
124
459
|
}), c !== null) return c;
|
|
125
460
|
}
|
|
126
461
|
let o = null, s = Infinity;
|
|
127
|
-
return
|
|
462
|
+
return b.current.slice(0, e.length).forEach((e, r) => {
|
|
128
463
|
if (!e || r === t) return;
|
|
129
464
|
let i = e.getBoundingClientRect(), c = n === "up" ? a.top - i.bottom : i.top - a.bottom;
|
|
130
465
|
if (c < 0) return;
|
|
131
466
|
let l = c + (i.right < a.left ? a.left - i.right : a.right < i.left ? i.left - a.right : 0);
|
|
132
467
|
l < s && (s = l, o = r);
|
|
133
468
|
}), o;
|
|
134
|
-
}, [e.length, r]),
|
|
469
|
+
}, [e.length, r]), H = t((e, t) => {
|
|
135
470
|
let n = null;
|
|
136
471
|
if (e.key === "Home") n = 0;
|
|
137
|
-
else if (e.key === "End") n =
|
|
472
|
+
else if (e.key === "End") n = O;
|
|
138
473
|
else if (r === "grid") {
|
|
139
474
|
let r = {
|
|
140
475
|
ArrowRight: 1,
|
|
141
476
|
ArrowLeft: -1,
|
|
142
|
-
ArrowDown:
|
|
143
|
-
ArrowUp: -
|
|
477
|
+
ArrowDown: D,
|
|
478
|
+
ArrowUp: -D
|
|
144
479
|
}[e.key];
|
|
145
480
|
if (r !== void 0) {
|
|
146
481
|
let e = t + r;
|
|
147
|
-
e >= 0 && e <=
|
|
482
|
+
e >= 0 && e <= O && (n = e);
|
|
148
483
|
}
|
|
149
|
-
} else if (e.key === "ArrowRight" && t <
|
|
484
|
+
} else if (e.key === "ArrowRight" && t < O) n = t + 1;
|
|
150
485
|
else if (e.key === "ArrowLeft" && t > 0) n = t - 1;
|
|
151
|
-
else if (e.key === "ArrowDown") n =
|
|
152
|
-
else if (e.key === "ArrowUp") n =
|
|
486
|
+
else if (e.key === "ArrowDown") n = V(t, "down");
|
|
487
|
+
else if (e.key === "ArrowUp") n = V(t, "up");
|
|
153
488
|
else return;
|
|
154
|
-
n !== null && n !== t && (e.preventDefault(),
|
|
489
|
+
n !== null && n !== t && (e.preventDefault(), N(n));
|
|
155
490
|
}, [
|
|
156
|
-
E,
|
|
157
|
-
M,
|
|
158
491
|
D,
|
|
492
|
+
V,
|
|
493
|
+
O,
|
|
159
494
|
r,
|
|
160
|
-
|
|
161
|
-
]),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
495
|
+
N
|
|
496
|
+
]), U = (e, t, r = {}) => {
|
|
497
|
+
let i = v(e);
|
|
498
|
+
return /* @__PURE__ */ c("button", {
|
|
499
|
+
className: `react-pic-gallery__tile ${r.className ?? ""}`.trim(),
|
|
500
|
+
type: "button",
|
|
501
|
+
disabled: !n,
|
|
502
|
+
tabIndex: t === k ? 0 : -1,
|
|
503
|
+
ref: (e) => {
|
|
504
|
+
b.current[t] = e;
|
|
505
|
+
},
|
|
506
|
+
style: r.style,
|
|
507
|
+
onKeyDown: (e) => H(e, t),
|
|
508
|
+
onClick: () => {
|
|
509
|
+
w(t), n?.(t);
|
|
510
|
+
},
|
|
511
|
+
"aria-label": `Open ${e.alt}`,
|
|
512
|
+
children: /* @__PURE__ */ c(d, {
|
|
513
|
+
sizes: i.sizes,
|
|
514
|
+
srcSet: i.srcSet,
|
|
515
|
+
src: i.src,
|
|
516
|
+
alt: e.alt,
|
|
517
|
+
objectFit: "cover",
|
|
518
|
+
width: e.width,
|
|
519
|
+
height: e.height
|
|
520
|
+
})
|
|
521
|
+
}, e.id ?? `${e.src}-${t}`);
|
|
522
|
+
}, W = r === "justified" ? M(e, T.width, T.rowHeight, T.gap) : [], G = Array(e.length);
|
|
523
|
+
return W.forEach((e) => {
|
|
184
524
|
e.indices.forEach((t, n) => {
|
|
185
|
-
|
|
525
|
+
G[t] = {
|
|
186
526
|
width: `${e.widths[n]}px`,
|
|
187
527
|
height: `${e.height}px`
|
|
188
528
|
};
|
|
189
529
|
});
|
|
190
530
|
}), /* @__PURE__ */ l("div", {
|
|
191
|
-
ref:
|
|
192
|
-
className: `react-pic-gallery__gallery react-pic-gallery__gallery--${r} ${r === "grid" ? "react-pic-gallery__grid" : ""} ${
|
|
193
|
-
style:
|
|
531
|
+
ref: x,
|
|
532
|
+
className: `react-pic-gallery__gallery react-pic-gallery__gallery--${r} react-pic-gallery__gallery--${i} ${r === "grid" ? "react-pic-gallery__grid" : ""} ${p}`.trim(),
|
|
533
|
+
style: j,
|
|
194
534
|
"data-testid": r === "grid" ? "react-pic-gallery-grid" : void 0,
|
|
195
535
|
"data-layout": r,
|
|
196
536
|
children: [
|
|
197
|
-
r === "grid" && e.map((e, t) =>
|
|
198
|
-
r === "
|
|
537
|
+
r === "grid" && e.map((e, t) => U(e, t)),
|
|
538
|
+
r === "carousel" && /* @__PURE__ */ c(B, {
|
|
539
|
+
images: e,
|
|
540
|
+
onImageClick: n,
|
|
541
|
+
renderCaption: h,
|
|
542
|
+
showCounter: g,
|
|
543
|
+
showNavigation: _,
|
|
544
|
+
preloadAdjacent: y
|
|
545
|
+
}),
|
|
546
|
+
r === "justified" && /* @__PURE__ */ l(s, { children: [e.map((e, t) => U(e, t, {
|
|
199
547
|
className: "react-pic-gallery__tile--justified",
|
|
200
|
-
style:
|
|
548
|
+
style: G[t]
|
|
201
549
|
})), /* @__PURE__ */ c("span", {
|
|
202
|
-
ref:
|
|
550
|
+
ref: S,
|
|
203
551
|
className: "react-pic-gallery__row-height-probe",
|
|
204
552
|
"aria-hidden": "true"
|
|
205
553
|
})] }),
|
|
@@ -209,278 +557,151 @@ function y({ images: e, onImageClick: n, layout: r = "grid", columns: i, rowHeig
|
|
|
209
557
|
className: `react-pic-gallery__mosaic-group react-pic-gallery__mosaic-group--${a} react-pic-gallery__mosaic-group--count-${i.length}`,
|
|
210
558
|
children: i.map((e, t) => {
|
|
211
559
|
let n = r + t, a = i.length === 3 ? t === 0 ? "featured" : "supporting" : "simple";
|
|
212
|
-
return
|
|
560
|
+
return U(e, n, { className: `react-pic-gallery__tile--mosaic react-pic-gallery__tile--mosaic-${a}` });
|
|
213
561
|
})
|
|
214
562
|
}, `mosaic-${r}`);
|
|
215
563
|
})
|
|
216
564
|
]
|
|
217
565
|
});
|
|
218
566
|
}
|
|
219
|
-
var
|
|
220
|
-
function
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
function O(e) {
|
|
224
|
-
if (!x.has(e)) {
|
|
225
|
-
if (x.size === 0) {
|
|
567
|
+
var H = e(V), U = /* @__PURE__ */ new Set(), W = null;
|
|
568
|
+
function G(e) {
|
|
569
|
+
if (!U.has(e)) {
|
|
570
|
+
if (U.size === 0) {
|
|
226
571
|
let e = document.body, t = window.innerWidth - document.documentElement.clientWidth, n = Number.parseFloat(window.getComputedStyle(e).paddingRight) || 0;
|
|
227
|
-
|
|
572
|
+
W = {
|
|
228
573
|
overflow: e.style.overflow,
|
|
229
574
|
paddingRight: e.style.paddingRight
|
|
230
575
|
}, e.style.overflow = "hidden", t > 0 && (e.style.paddingRight = `${n + t}px`);
|
|
231
576
|
}
|
|
232
|
-
|
|
577
|
+
U.add(e);
|
|
233
578
|
}
|
|
234
579
|
}
|
|
235
|
-
function
|
|
236
|
-
return
|
|
580
|
+
function K(e) {
|
|
581
|
+
return U.delete(e), U.size > 0 || !W ? !1 : (document.body.style.overflow = W.overflow, document.body.style.paddingRight = W.paddingRight, W = null, !0);
|
|
237
582
|
}
|
|
238
|
-
function
|
|
583
|
+
function q(e) {
|
|
239
584
|
let t = e.trim();
|
|
240
585
|
return t.endsWith("ms") ? Number.parseFloat(t) : t.endsWith("s") ? Number.parseFloat(t) * 1e3 : 0;
|
|
241
586
|
}
|
|
242
|
-
function
|
|
587
|
+
function J(e) {
|
|
243
588
|
let t = window.getComputedStyle(e), n = t.animationDuration.split(","), r = t.animationDelay.split(",");
|
|
244
|
-
return Math.max(...n.map((e, t) =>
|
|
245
|
-
}
|
|
246
|
-
function M() {
|
|
247
|
-
return /* @__PURE__ */ c("svg", {
|
|
248
|
-
viewBox: "0 0 24 24",
|
|
249
|
-
"aria-hidden": "true",
|
|
250
|
-
focusable: "false",
|
|
251
|
-
children: /* @__PURE__ */ c("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
function N({ direction: e }) {
|
|
255
|
-
return /* @__PURE__ */ c("svg", {
|
|
256
|
-
viewBox: "0 0 24 24",
|
|
257
|
-
"aria-hidden": "true",
|
|
258
|
-
focusable: "false",
|
|
259
|
-
children: /* @__PURE__ */ c("path", { d: e === "left" ? "M14.5 5l-7 7 7 7" : "M9.5 5l7 7-7 7" })
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
function P(...e) {
|
|
263
|
-
return e.filter(Boolean).join(" ");
|
|
589
|
+
return Math.max(...n.map((e, t) => q(e) + q(r[t % r.length] ?? "0s")), 0);
|
|
264
590
|
}
|
|
265
|
-
function
|
|
266
|
-
let
|
|
267
|
-
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
591
|
+
function Y({ images: e, index: i, onIndexChange: s, renderActions: d, renderCaption: f, renderControls: p, showCounter: m = !0, showNavigation: h = !0, preloadAdjacent: _ = !0, className: v }) {
|
|
592
|
+
let y = a(null), b = a(s), x = a(null), S = a(null), C = a(null), w = a(!1), T = a({}), E = r(), [D, O] = o(!1), A = i !== null && i >= 0 && i < e.length ? i : null, j = A === null ? void 0 : e[A];
|
|
593
|
+
b.current = s, C.current = A;
|
|
594
|
+
let M = N({
|
|
595
|
+
images: e,
|
|
596
|
+
index: A,
|
|
597
|
+
onIndexChange: s,
|
|
598
|
+
disabled: D,
|
|
599
|
+
showNavigation: h && !p
|
|
600
|
+
}), P = t(() => {
|
|
601
|
+
x.current !== null && (window.clearTimeout(x.current), x.current = null), S.current = null;
|
|
602
|
+
}, []), F = t(() => {
|
|
603
|
+
let e = C.current;
|
|
604
|
+
if (e !== null && S.current === null) {
|
|
273
605
|
if (typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
|
|
274
|
-
|
|
606
|
+
b.current(null);
|
|
275
607
|
return;
|
|
276
608
|
}
|
|
277
|
-
|
|
609
|
+
S.current = { index: e }, O(!0);
|
|
278
610
|
}
|
|
279
|
-
}, []),
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}, []), J = t(() => {
|
|
283
|
-
let e = S.current;
|
|
284
|
-
!C.current && e !== null && e < I.current.length - 1 && y.current(e + 1);
|
|
285
|
-
}, []), Y = t(() => {
|
|
611
|
+
}, []), I = t((e) => {
|
|
612
|
+
e.preventDefault(), F();
|
|
613
|
+
}, [F]), L = t(() => {
|
|
286
614
|
let e = S.current;
|
|
287
|
-
C.current || e === null || e === 0 || (H("previous"), y.current(e - 1));
|
|
288
|
-
}, []), X = t(() => {
|
|
289
|
-
let e = S.current;
|
|
290
|
-
C.current || e === null || e >= I.current.length - 1 || (H("next"), y.current(e + 1));
|
|
291
|
-
}, []), ee = t((e) => {
|
|
292
|
-
e.preventDefault(), K();
|
|
293
|
-
}, [K]), Z = t(() => {
|
|
294
|
-
let e = x.current;
|
|
295
615
|
if (e) {
|
|
296
|
-
if (
|
|
297
|
-
|
|
616
|
+
if (C.current !== e.index) {
|
|
617
|
+
P(), O(!1);
|
|
298
618
|
return;
|
|
299
619
|
}
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
}, [G]), te = t((e) => {
|
|
303
|
-
if (e.defaultPrevented) return;
|
|
304
|
-
let t = e.target;
|
|
305
|
-
t instanceof HTMLElement && (t.isContentEditable || t.closest(w)) || (e.key === "ArrowLeft" ? (e.preventDefault(), q()) : e.key === "ArrowRight" && (e.preventDefault(), J()));
|
|
306
|
-
}, [J, q]), ne = t((e) => {
|
|
307
|
-
if (e.touches.length !== 1 || D(e.target)) {
|
|
308
|
-
L.current = null;
|
|
309
|
-
return;
|
|
620
|
+
P(), O(!1), b.current(null);
|
|
310
621
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
let
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
e.target === e.currentTarget && H(null);
|
|
325
|
-
}, []), oe = t((e) => {
|
|
326
|
-
e.target === e.currentTarget && e.animationName === "react-pic-gallery-fade-out" && Z();
|
|
327
|
-
}, [Z]), se = t(() => {
|
|
328
|
-
A.current || (G(), C.current = !1, B(!1), S.current !== null && y.current(null));
|
|
329
|
-
}, [G]);
|
|
330
|
-
if (n(() => {
|
|
331
|
-
let e = x.current;
|
|
332
|
-
e && U !== e.index && (G(), C.current = !1, B(!1));
|
|
333
|
-
}, [U, G]), n(() => {
|
|
334
|
-
if (!z || !x.current || !v.current) return;
|
|
335
|
-
let e = j(v.current);
|
|
336
|
-
return b.current = window.setTimeout(Z, e), () => {
|
|
337
|
-
b.current !== null && (window.clearTimeout(b.current), b.current = null);
|
|
622
|
+
}, [P]), R = t((e) => {
|
|
623
|
+
e.target === e.currentTarget && e.animationName === "react-pic-gallery-fade-out" && L();
|
|
624
|
+
}, [L]), z = t(() => {
|
|
625
|
+
w.current || (P(), O(!1), C.current !== null && b.current(null));
|
|
626
|
+
}, [P]);
|
|
627
|
+
return n(() => {
|
|
628
|
+
let e = S.current;
|
|
629
|
+
e && A !== e.index && (P(), O(!1));
|
|
630
|
+
}, [A, P]), n(() => {
|
|
631
|
+
if (!D || !S.current || !y.current) return;
|
|
632
|
+
let e = J(y.current);
|
|
633
|
+
return x.current = window.setTimeout(L, e), () => {
|
|
634
|
+
x.current !== null && (window.clearTimeout(x.current), x.current = null);
|
|
338
635
|
};
|
|
339
|
-
}, [
|
|
340
|
-
if (
|
|
341
|
-
let e =
|
|
636
|
+
}, [L, D]), n(() => {
|
|
637
|
+
if (A === null) return;
|
|
638
|
+
let e = y.current;
|
|
342
639
|
if (!e) return;
|
|
343
640
|
let t = document.activeElement;
|
|
344
|
-
return
|
|
345
|
-
|
|
641
|
+
return G(T.current), e.open || e.showModal(), () => {
|
|
642
|
+
P(), w.current = !0, e.open && e.close(), w.current = !1, K(T.current) && t?.isConnected && t.focus();
|
|
346
643
|
};
|
|
347
|
-
}, [
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
/* @__PURE__ */ l("p", {
|
|
376
|
-
className: "react-pic-gallery__sr-only",
|
|
377
|
-
"aria-live": "polite",
|
|
378
|
-
children: [
|
|
379
|
-
W.alt,
|
|
380
|
-
", image ",
|
|
381
|
-
U + 1,
|
|
382
|
-
" of ",
|
|
383
|
-
e.length
|
|
384
|
-
]
|
|
385
|
-
}),
|
|
386
|
-
/* @__PURE__ */ l("div", {
|
|
387
|
-
className: "react-pic-gallery__lightbox-content",
|
|
388
|
-
children: [
|
|
389
|
-
m ? /* @__PURE__ */ c("div", {
|
|
390
|
-
className: "react-pic-gallery__custom-controls",
|
|
391
|
-
children: m(Q)
|
|
392
|
-
}) : /* @__PURE__ */ l("div", {
|
|
393
|
-
className: "react-pic-gallery__toolbar",
|
|
394
|
-
children: [/* @__PURE__ */ l("div", {
|
|
395
|
-
className: "react-pic-gallery__toolbar-actions",
|
|
396
|
-
children: [h && /* @__PURE__ */ l("span", {
|
|
397
|
-
"aria-live": "polite",
|
|
398
|
-
children: [
|
|
399
|
-
U + 1,
|
|
400
|
-
" / ",
|
|
401
|
-
e.length
|
|
402
|
-
]
|
|
403
|
-
}), f?.(Q)]
|
|
404
|
-
}), /* @__PURE__ */ c("button", {
|
|
405
|
-
className: "react-pic-gallery__control",
|
|
406
|
-
type: "button",
|
|
407
|
-
onClick: K,
|
|
408
|
-
"aria-label": "Close image viewer",
|
|
409
|
-
children: /* @__PURE__ */ c(M, {})
|
|
410
|
-
})]
|
|
411
|
-
}),
|
|
412
|
-
/* @__PURE__ */ l("div", {
|
|
413
|
-
className: P("react-pic-gallery__viewport", $ ? "react-pic-gallery__viewport--has-navigation" : void 0),
|
|
414
|
-
onMouseDown: ue,
|
|
415
|
-
onClick: (e) => {
|
|
416
|
-
if (!$ || C.current || !(e.target instanceof Element) || e.target.closest("button") || window.matchMedia?.(T)?.matches !== !0) return;
|
|
417
|
-
let t = e.currentTarget.getBoundingClientRect();
|
|
418
|
-
if (t.width <= 0) return;
|
|
419
|
-
let n = (e.clientX - t.left) / t.width;
|
|
420
|
-
n < E ? q() : n > .7 && J();
|
|
421
|
-
},
|
|
422
|
-
onTouchCancel: ie,
|
|
423
|
-
onTouchEnd: re,
|
|
424
|
-
onTouchStart: ne,
|
|
425
|
-
children: [
|
|
426
|
-
ce && /* @__PURE__ */ c("button", {
|
|
427
|
-
className: "react-pic-gallery__control react-pic-gallery__control--previous",
|
|
428
|
-
type: "button",
|
|
429
|
-
onClick: q,
|
|
430
|
-
"aria-label": "Previous image",
|
|
431
|
-
children: /* @__PURE__ */ c(N, { direction: "left" })
|
|
432
|
-
}),
|
|
433
|
-
/* @__PURE__ */ c(d, {
|
|
434
|
-
src: W.src,
|
|
435
|
-
alt: W.alt,
|
|
436
|
-
eager: !0,
|
|
437
|
-
objectFit: "contain",
|
|
438
|
-
className: P("react-pic-gallery__lightbox-image", V ? `react-pic-gallery__lightbox-image--swipe-${V}` : void 0),
|
|
439
|
-
onAnimationEnd: ae
|
|
440
|
-
}, W.src),
|
|
441
|
-
le && /* @__PURE__ */ c("button", {
|
|
442
|
-
className: "react-pic-gallery__control react-pic-gallery__control--next",
|
|
443
|
-
type: "button",
|
|
444
|
-
onClick: J,
|
|
445
|
-
"aria-label": "Next image",
|
|
446
|
-
children: /* @__PURE__ */ c(N, { direction: "right" })
|
|
447
|
-
})
|
|
448
|
-
]
|
|
449
|
-
}),
|
|
450
|
-
(p || W.caption) && /* @__PURE__ */ c("div", {
|
|
451
|
-
className: "react-pic-gallery__caption",
|
|
452
|
-
children: p ? p(Q) : W.caption
|
|
453
|
-
})
|
|
454
|
-
]
|
|
455
|
-
})
|
|
456
|
-
]
|
|
644
|
+
}, [A !== null, P]), A === null || !j || typeof document > "u" ? null : u(/* @__PURE__ */ l("dialog", {
|
|
645
|
+
ref: y,
|
|
646
|
+
className: g("react-pic-gallery__lightbox", D ? "react-pic-gallery__lightbox--closing" : void 0, v),
|
|
647
|
+
"aria-labelledby": E,
|
|
648
|
+
onAnimationEnd: R,
|
|
649
|
+
onClose: z,
|
|
650
|
+
onMouseDown: (e) => {
|
|
651
|
+
e.target === e.currentTarget && F();
|
|
652
|
+
},
|
|
653
|
+
onCancel: I,
|
|
654
|
+
onKeyDown: M.handleKeyDown,
|
|
655
|
+
children: [/* @__PURE__ */ c("h2", {
|
|
656
|
+
className: "react-pic-gallery__sr-only",
|
|
657
|
+
id: E,
|
|
658
|
+
children: "Image viewer"
|
|
659
|
+
}), /* @__PURE__ */ c(k, {
|
|
660
|
+
images: e,
|
|
661
|
+
index: A,
|
|
662
|
+
navigation: M,
|
|
663
|
+
renderActions: d,
|
|
664
|
+
renderCaption: f,
|
|
665
|
+
renderControls: p,
|
|
666
|
+
showCounter: m,
|
|
667
|
+
showNavigation: h && !p,
|
|
668
|
+
preloadAdjacent: _,
|
|
669
|
+
close: F,
|
|
670
|
+
onEmptyAreaClick: F
|
|
671
|
+
})]
|
|
457
672
|
}), document.body);
|
|
458
673
|
}
|
|
459
674
|
//#endregion
|
|
460
675
|
//#region src/lib/PicGallery.tsx
|
|
461
|
-
function
|
|
462
|
-
let [
|
|
676
|
+
function X({ images: e, layout: t, appearance: n, columns: r, rowHeight: i, className: a, galleryClassName: s, style: u, renderActions: d, renderCaption: f, renderControls: p, showCounter: m, showNavigation: h, preloadAdjacent: g }) {
|
|
677
|
+
let [_, v] = o(null);
|
|
463
678
|
return /* @__PURE__ */ l("div", {
|
|
464
|
-
className: `react-pic-gallery ${
|
|
465
|
-
style:
|
|
466
|
-
children: [/* @__PURE__ */ c(
|
|
679
|
+
className: `react-pic-gallery ${a ?? ""}`.trim(),
|
|
680
|
+
style: u,
|
|
681
|
+
children: [/* @__PURE__ */ c(H, {
|
|
467
682
|
images: e,
|
|
468
683
|
layout: t,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
684
|
+
appearance: n,
|
|
685
|
+
columns: r,
|
|
686
|
+
rowHeight: i,
|
|
687
|
+
className: s,
|
|
688
|
+
onImageClick: v,
|
|
689
|
+
renderCaption: f,
|
|
690
|
+
showCounter: m,
|
|
691
|
+
showNavigation: h,
|
|
692
|
+
preloadAdjacent: g
|
|
693
|
+
}), /* @__PURE__ */ c(Y, {
|
|
474
694
|
images: e,
|
|
475
|
-
index:
|
|
476
|
-
onIndexChange:
|
|
477
|
-
renderActions:
|
|
478
|
-
renderCaption:
|
|
479
|
-
renderControls:
|
|
480
|
-
showCounter:
|
|
481
|
-
showNavigation:
|
|
695
|
+
index: _,
|
|
696
|
+
onIndexChange: v,
|
|
697
|
+
renderActions: d,
|
|
698
|
+
renderCaption: f,
|
|
699
|
+
renderControls: p,
|
|
700
|
+
showCounter: m,
|
|
701
|
+
showNavigation: h,
|
|
702
|
+
preloadAdjacent: g
|
|
482
703
|
})]
|
|
483
704
|
});
|
|
484
705
|
}
|
|
485
706
|
//#endregion
|
|
486
|
-
export {
|
|
707
|
+
export { H as Gallery, Y as Lightbox, X as PicGallery, X as default };
|