@mantine/lightbox 9.5.2

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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/cjs/Lightbox.cjs +56 -0
  4. package/cjs/Lightbox.cjs.map +1 -0
  5. package/cjs/Lightbox.module.cjs +30 -0
  6. package/cjs/Lightbox.module.cjs.map +1 -0
  7. package/cjs/LightboxCaption/LightboxCaption.cjs +30 -0
  8. package/cjs/LightboxCaption/LightboxCaption.cjs.map +1 -0
  9. package/cjs/LightboxCloseButton/LightboxCloseButton.cjs +32 -0
  10. package/cjs/LightboxCloseButton/LightboxCloseButton.cjs.map +1 -0
  11. package/cjs/LightboxNavigation/LightboxNavigation.cjs +105 -0
  12. package/cjs/LightboxNavigation/LightboxNavigation.cjs.map +1 -0
  13. package/cjs/LightboxProvider/LightboxProvider.cjs +29 -0
  14. package/cjs/LightboxProvider/LightboxProvider.cjs.map +1 -0
  15. package/cjs/LightboxRoot/LightboxRoot.cjs +407 -0
  16. package/cjs/LightboxRoot/LightboxRoot.cjs.map +1 -0
  17. package/cjs/LightboxSlide/ImageSlide.cjs +27 -0
  18. package/cjs/LightboxSlide/ImageSlide.cjs.map +1 -0
  19. package/cjs/LightboxSlide/LightboxSlide.cjs +55 -0
  20. package/cjs/LightboxSlide/LightboxSlide.cjs.map +1 -0
  21. package/cjs/LightboxSlide/VideoSlide.cjs +42 -0
  22. package/cjs/LightboxSlide/VideoSlide.cjs.map +1 -0
  23. package/cjs/LightboxSlides/LightboxSlides.cjs +56 -0
  24. package/cjs/LightboxSlides/LightboxSlides.cjs.map +1 -0
  25. package/cjs/LightboxThumbnails/LightboxThumbnails.cjs +74 -0
  26. package/cjs/LightboxThumbnails/LightboxThumbnails.cjs.map +1 -0
  27. package/cjs/LightboxToolbar/LightboxToolbar.cjs +80 -0
  28. package/cjs/LightboxToolbar/LightboxToolbar.cjs.map +1 -0
  29. package/cjs/LightboxToolbar/toolbar-items.cjs +156 -0
  30. package/cjs/LightboxToolbar/toolbar-items.cjs.map +1 -0
  31. package/cjs/_virtual/_rolldown/runtime.cjs +24 -0
  32. package/cjs/default-labels.cjs +20 -0
  33. package/cjs/default-labels.cjs.map +1 -0
  34. package/cjs/hooks/use-lightbox-keyboard.cjs +107 -0
  35. package/cjs/hooks/use-lightbox-keyboard.cjs.map +1 -0
  36. package/cjs/hooks/use-lightbox-lock-scroll.cjs +30 -0
  37. package/cjs/hooks/use-lightbox-lock-scroll.cjs.map +1 -0
  38. package/cjs/hooks/use-lightbox-swipe-close.cjs +38 -0
  39. package/cjs/hooks/use-lightbox-swipe-close.cjs.map +1 -0
  40. package/cjs/hooks/use-lightbox-zoom.cjs +257 -0
  41. package/cjs/hooks/use-lightbox-zoom.cjs.map +1 -0
  42. package/cjs/index.cjs +34 -0
  43. package/cjs/lightbox.context.cjs +8 -0
  44. package/cjs/lightbox.context.cjs.map +1 -0
  45. package/cjs/lightbox.store.cjs +90 -0
  46. package/cjs/lightbox.store.cjs.map +1 -0
  47. package/esm/Lightbox.mjs +56 -0
  48. package/esm/Lightbox.mjs.map +1 -0
  49. package/esm/Lightbox.module.mjs +30 -0
  50. package/esm/Lightbox.module.mjs.map +1 -0
  51. package/esm/LightboxCaption/LightboxCaption.mjs +30 -0
  52. package/esm/LightboxCaption/LightboxCaption.mjs.map +1 -0
  53. package/esm/LightboxCloseButton/LightboxCloseButton.mjs +32 -0
  54. package/esm/LightboxCloseButton/LightboxCloseButton.mjs.map +1 -0
  55. package/esm/LightboxNavigation/LightboxNavigation.mjs +105 -0
  56. package/esm/LightboxNavigation/LightboxNavigation.mjs.map +1 -0
  57. package/esm/LightboxProvider/LightboxProvider.mjs +29 -0
  58. package/esm/LightboxProvider/LightboxProvider.mjs.map +1 -0
  59. package/esm/LightboxRoot/LightboxRoot.mjs +404 -0
  60. package/esm/LightboxRoot/LightboxRoot.mjs.map +1 -0
  61. package/esm/LightboxSlide/ImageSlide.mjs +27 -0
  62. package/esm/LightboxSlide/ImageSlide.mjs.map +1 -0
  63. package/esm/LightboxSlide/LightboxSlide.mjs +55 -0
  64. package/esm/LightboxSlide/LightboxSlide.mjs.map +1 -0
  65. package/esm/LightboxSlide/VideoSlide.mjs +42 -0
  66. package/esm/LightboxSlide/VideoSlide.mjs.map +1 -0
  67. package/esm/LightboxSlides/LightboxSlides.mjs +56 -0
  68. package/esm/LightboxSlides/LightboxSlides.mjs.map +1 -0
  69. package/esm/LightboxThumbnails/LightboxThumbnails.mjs +72 -0
  70. package/esm/LightboxThumbnails/LightboxThumbnails.mjs.map +1 -0
  71. package/esm/LightboxToolbar/LightboxToolbar.mjs +80 -0
  72. package/esm/LightboxToolbar/LightboxToolbar.mjs.map +1 -0
  73. package/esm/LightboxToolbar/toolbar-items.mjs +153 -0
  74. package/esm/LightboxToolbar/toolbar-items.mjs.map +1 -0
  75. package/esm/default-labels.mjs +20 -0
  76. package/esm/default-labels.mjs.map +1 -0
  77. package/esm/hooks/use-lightbox-keyboard.mjs +107 -0
  78. package/esm/hooks/use-lightbox-keyboard.mjs.map +1 -0
  79. package/esm/hooks/use-lightbox-lock-scroll.mjs +30 -0
  80. package/esm/hooks/use-lightbox-lock-scroll.mjs.map +1 -0
  81. package/esm/hooks/use-lightbox-swipe-close.mjs +38 -0
  82. package/esm/hooks/use-lightbox-swipe-close.mjs.map +1 -0
  83. package/esm/hooks/use-lightbox-zoom.mjs +257 -0
  84. package/esm/hooks/use-lightbox-zoom.mjs.map +1 -0
  85. package/esm/index.mjs +14 -0
  86. package/esm/lightbox.context.mjs +8 -0
  87. package/esm/lightbox.context.mjs.map +1 -0
  88. package/esm/lightbox.store.mjs +79 -0
  89. package/esm/lightbox.store.mjs.map +1 -0
  90. package/lib/Lightbox.d.ts +63 -0
  91. package/lib/LightboxCaption/LightboxCaption.d.ts +18 -0
  92. package/lib/LightboxCloseButton/LightboxCloseButton.d.ts +16 -0
  93. package/lib/LightboxNavigation/LightboxNavigation.d.ts +16 -0
  94. package/lib/LightboxProvider/LightboxProvider.d.ts +19 -0
  95. package/lib/LightboxRoot/LightboxRoot.d.ts +88 -0
  96. package/lib/LightboxSlide/ImageSlide.d.ts +12 -0
  97. package/lib/LightboxSlide/LightboxSlide.d.ts +25 -0
  98. package/lib/LightboxSlide/VideoSlide.d.ts +12 -0
  99. package/lib/LightboxSlides/LightboxSlides.d.ts +20 -0
  100. package/lib/LightboxThumbnails/LightboxThumbnails.d.ts +16 -0
  101. package/lib/LightboxToolbar/LightboxToolbar.d.ts +19 -0
  102. package/lib/LightboxToolbar/toolbar-items.d.ts +5 -0
  103. package/lib/default-labels.d.ts +2 -0
  104. package/lib/hooks/use-lightbox-keyboard.d.ts +15 -0
  105. package/lib/hooks/use-lightbox-lock-scroll.d.ts +7 -0
  106. package/lib/hooks/use-lightbox-swipe-close.d.ts +10 -0
  107. package/lib/hooks/use-lightbox-zoom.d.ts +33 -0
  108. package/lib/index.d.mts +67 -0
  109. package/lib/index.d.ts +67 -0
  110. package/lib/lightbox.context.d.ts +36 -0
  111. package/lib/lightbox.store.d.ts +66 -0
  112. package/lib/lightbox.types.d.ts +131 -0
  113. package/lib/test-utils.d.ts +7 -0
  114. package/package.json +63 -0
  115. package/styles.css +262 -0
  116. package/styles.layer.css +263 -0
@@ -0,0 +1,407 @@
1
+ "use client";
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_default_labels = require("../default-labels.cjs");
4
+ const require_lightbox_context = require("../lightbox.context.cjs");
5
+ const require_Lightbox_module = require("../Lightbox.module.cjs");
6
+ const require_use_lightbox_keyboard = require("../hooks/use-lightbox-keyboard.cjs");
7
+ const require_use_lightbox_lock_scroll = require("../hooks/use-lightbox-lock-scroll.cjs");
8
+ const require_use_lightbox_zoom = require("../hooks/use-lightbox-zoom.cjs");
9
+ let _mantine_core = require("@mantine/core");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+ let react = require("react");
12
+ let embla_carousel_react = require("embla-carousel-react");
13
+ embla_carousel_react = require_runtime.__toESM(embla_carousel_react);
14
+ let _mantine_hooks = require("@mantine/hooks");
15
+ //#region packages/@mantine/lightbox/src/LightboxRoot/LightboxRoot.tsx
16
+ const lightboxRootDefaultProps = {
17
+ withZoom: false,
18
+ withThumbnails: false,
19
+ withFullscreen: false,
20
+ withDownload: false,
21
+ loop: false,
22
+ closeOnClickOutside: false,
23
+ closeOnSwipeDown: true,
24
+ withKeyboardEvents: true,
25
+ returnFocus: true,
26
+ withInitialFocusPlaceholder: true,
27
+ withinPortal: true,
28
+ transitionDuration: 200,
29
+ zoomMaxScale: 3,
30
+ withSlideTransition: false
31
+ };
32
+ function createBreakpointWatchDrag(query, zoomIsActive, watchDragRef) {
33
+ return (emblaApi, event) => {
34
+ if (zoomIsActive.current) return false;
35
+ const option = watchDragRef.current[query];
36
+ if (typeof option === "function") return option(emblaApi, event);
37
+ return option ?? true;
38
+ };
39
+ }
40
+ const defaultContentTransition = {
41
+ common: { transformOrigin: "center center" },
42
+ in: {
43
+ opacity: 1,
44
+ transform: "scale(1)"
45
+ },
46
+ out: {
47
+ opacity: 0,
48
+ transform: "scale(0.95)"
49
+ },
50
+ transitionProperty: "transform, opacity"
51
+ };
52
+ function exitDocumentFullscreen() {
53
+ const _document = document;
54
+ const exit = _document.exitFullscreen || _document.msExitFullscreen || _document.webkitExitFullscreen || _document.mozCancelFullScreen;
55
+ if (typeof exit === "function") Promise.resolve(exit.call(_document)).catch(() => {});
56
+ }
57
+ const varsResolver = (0, _mantine_core.createVarsResolver)((_, { transitionDuration, zIndex }) => ({ root: {
58
+ "--lightbox-transition-duration": `${transitionDuration}ms`,
59
+ "--lightbox-overlay-color": void 0,
60
+ "--lightbox-z-index": zIndex !== void 0 ? `${zIndex}` : void 0,
61
+ "--lightbox-toolbar-height": void 0,
62
+ "--lightbox-thumbnails-height": void 0
63
+ } }));
64
+ const LightboxRoot = (0, _mantine_core.factory)((_props) => {
65
+ const props = (0, _mantine_core.useProps)("LightboxRoot", lightboxRootDefaultProps, _props);
66
+ const { classNames, className, style, styles, unstyled, vars, opened, onClose, children, slides, currentIndex, onIndexChange, labels, withZoom, withThumbnails, withFullscreen, withDownload, loop, closeOnClickOutside, closeOnSwipeDown, withKeyboardEvents, returnFocus, withInitialFocusPlaceholder, withinPortal, zIndex, transitionDuration, transitionProps, emblaOptions, zoomMaxScale, withSlideTransition, attributes, mod, onClick, ref, ...others } = props;
67
+ const getStyles = (0, _mantine_core.useStyles)({
68
+ name: "Lightbox",
69
+ classes: require_Lightbox_module.default,
70
+ props,
71
+ classNames,
72
+ styles,
73
+ unstyled,
74
+ attributes,
75
+ vars,
76
+ varsResolver
77
+ });
78
+ const _labels = (0, react.useMemo)(() => ({
79
+ ...require_default_labels.DEFAULT_LABELS,
80
+ ...labels
81
+ }), [labels]);
82
+ const getStylesRef = (0, react.useRef)(getStyles);
83
+ getStylesRef.current = getStyles;
84
+ const stableGetStyles = (0, react.useCallback)((...args) => getStylesRef.current(...args), []);
85
+ const [_currentIndex, setCurrentIndex] = (0, _mantine_hooks.useUncontrolled)({
86
+ value: currentIndex,
87
+ defaultValue: 0,
88
+ finalValue: 0,
89
+ onChange: onIndexChange
90
+ });
91
+ const zoomIsActive = (0, react.useRef)(false);
92
+ const currentIndexRef = (0, react.useRef)(_currentIndex);
93
+ const setCurrentIndexRef = (0, react.useRef)(setCurrentIndex);
94
+ const suppressSelectRef = (0, react.useRef)(null);
95
+ const fullscreenRequestedRef = (0, react.useRef)(false);
96
+ const ownsFullscreenRef = (0, react.useRef)(false);
97
+ const pendingFullscreenRef = (0, react.useRef)(null);
98
+ const exitOnSettleRef = (0, react.useRef)(false);
99
+ const emblaOptionsRef = (0, react.useRef)(emblaOptions);
100
+ const [startIndex, setStartIndex] = (0, react.useState)(_currentIndex);
101
+ const [prevOpened, setPrevOpened] = (0, react.useState)(opened);
102
+ if (opened !== prevOpened) {
103
+ setPrevOpened(opened);
104
+ if (opened) setStartIndex(_currentIndex);
105
+ }
106
+ const { dir } = (0, _mantine_core.useDirection)();
107
+ const breakpointWatchDragRef = (0, react.useRef)({});
108
+ const resolvedEmblaOptions = (0, react.useMemo)(() => {
109
+ if (!emblaOptions?.breakpoints) {
110
+ breakpointWatchDragRef.current = {};
111
+ return emblaOptions;
112
+ }
113
+ const watchDragOptions = {};
114
+ const breakpoints = Object.fromEntries(Object.entries(emblaOptions.breakpoints).map(([query, value]) => {
115
+ const { loop: _loop, startIndex: _startIndex, watchDrag, ...rest } = value ?? {};
116
+ watchDragOptions[query] = watchDrag;
117
+ return [query, watchDrag === void 0 ? rest : {
118
+ ...rest,
119
+ watchDrag: createBreakpointWatchDrag(query, zoomIsActive, breakpointWatchDragRef)
120
+ }];
121
+ }));
122
+ breakpointWatchDragRef.current = watchDragOptions;
123
+ return {
124
+ ...emblaOptions,
125
+ breakpoints
126
+ };
127
+ }, [emblaOptions]);
128
+ const [emblaRef, embla] = (0, embla_carousel_react.default)({
129
+ direction: dir,
130
+ ...resolvedEmblaOptions,
131
+ loop,
132
+ startIndex,
133
+ watchDrag: (emblaApi, event) => {
134
+ if (zoomIsActive.current) return false;
135
+ const userWatchDrag = emblaOptionsRef.current?.watchDrag;
136
+ if (typeof userWatchDrag === "function") return userWatchDrag(emblaApi, event);
137
+ return userWatchDrag ?? true;
138
+ }
139
+ });
140
+ const [thumbnailsVisible, setThumbnailsVisible] = (0, react.useState)(!!withThumbnails);
141
+ const [prevWithThumbnails, setPrevWithThumbnails] = (0, react.useState)(withThumbnails);
142
+ if (withThumbnails !== prevWithThumbnails) {
143
+ setPrevWithThumbnails(withThumbnails);
144
+ setThumbnailsVisible(!!withThumbnails);
145
+ }
146
+ const { toggle: toggleFullscreenFn, fullscreen: isFullscreen } = (0, _mantine_hooks.useFullscreenDocument)();
147
+ const toggleThumbnails = (0, react.useCallback)(() => {
148
+ setThumbnailsVisible((prev) => !prev);
149
+ }, []);
150
+ const toggleFullscreen = (0, react.useCallback)(() => {
151
+ fullscreenRequestedRef.current = !isFullscreen;
152
+ if (isFullscreen) ownsFullscreenRef.current = false;
153
+ const request = toggleFullscreenFn().then(() => {
154
+ if (pendingFullscreenRef.current === request && exitOnSettleRef.current) {
155
+ exitOnSettleRef.current = false;
156
+ exitDocumentFullscreen();
157
+ }
158
+ }).catch(() => {
159
+ fullscreenRequestedRef.current = false;
160
+ exitOnSettleRef.current = false;
161
+ }).finally(() => {
162
+ if (pendingFullscreenRef.current === request) pendingFullscreenRef.current = null;
163
+ });
164
+ pendingFullscreenRef.current = request;
165
+ }, [toggleFullscreenFn, isFullscreen]);
166
+ (0, react.useEffect)(() => {
167
+ if (!isFullscreen) {
168
+ fullscreenRequestedRef.current = false;
169
+ ownsFullscreenRef.current = false;
170
+ } else if (fullscreenRequestedRef.current) {
171
+ fullscreenRequestedRef.current = false;
172
+ ownsFullscreenRef.current = true;
173
+ }
174
+ }, [isFullscreen]);
175
+ const exitOwnedFullscreen = (0, react.useCallback)(() => {
176
+ if (!ownsFullscreenRef.current && !fullscreenRequestedRef.current) return;
177
+ if (pendingFullscreenRef.current !== null && fullscreenRequestedRef.current) exitOnSettleRef.current = true;
178
+ fullscreenRequestedRef.current = false;
179
+ ownsFullscreenRef.current = false;
180
+ exitDocumentFullscreen();
181
+ }, []);
182
+ const zoom = require_use_lightbox_zoom.useLightboxZoom({
183
+ enabled: !!withZoom,
184
+ maxScale: zoomMaxScale,
185
+ currentIndex: _currentIndex
186
+ });
187
+ (0, react.useEffect)(() => {
188
+ currentIndexRef.current = _currentIndex;
189
+ setCurrentIndexRef.current = setCurrentIndex;
190
+ zoomIsActive.current = zoom.zoomState.isZoomed;
191
+ emblaOptionsRef.current = emblaOptions;
192
+ });
193
+ const { resetZoom } = zoom;
194
+ (0, react.useEffect)(() => {
195
+ if (!opened) {
196
+ resetZoom();
197
+ setThumbnailsVisible(!!withThumbnails);
198
+ exitOwnedFullscreen();
199
+ }
200
+ }, [
201
+ opened,
202
+ resetZoom,
203
+ withThumbnails,
204
+ exitOwnedFullscreen
205
+ ]);
206
+ (0, react.useEffect)(() => exitOwnedFullscreen, [exitOwnedFullscreen]);
207
+ const theme = (0, _mantine_core.useMantineTheme)();
208
+ const shouldReduceMotion = (0, _mantine_hooks.useReducedMotion)();
209
+ const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
210
+ const animateSlides = !!withSlideTransition && !reduceMotion;
211
+ const handleNext = (0, react.useCallback)(() => {
212
+ embla?.scrollNext(!animateSlides);
213
+ }, [embla, animateSlides]);
214
+ const handlePrev = (0, react.useCallback)(() => {
215
+ embla?.scrollPrev(!animateSlides);
216
+ }, [embla, animateSlides]);
217
+ require_use_lightbox_keyboard.useLightboxKeyboard({
218
+ opened,
219
+ enabled: withKeyboardEvents,
220
+ dir,
221
+ onClose,
222
+ onNext: handleNext,
223
+ onPrev: handlePrev,
224
+ onToggleFullscreen: withFullscreen ? toggleFullscreen : void 0,
225
+ onToggleThumbnails: withThumbnails ? toggleThumbnails : void 0,
226
+ onToggleZoom: withZoom ? zoom.toggleZoom : void 0,
227
+ onZoomPan: withZoom ? zoom.panZoom : void 0
228
+ });
229
+ (0, react.useEffect)(() => {
230
+ if (!embla) return;
231
+ const onSelect = () => {
232
+ const selected = embla.selectedScrollSnap();
233
+ if (selected !== suppressSelectRef.current) setCurrentIndexRef.current(selected);
234
+ };
235
+ const onReInit = () => {
236
+ if (embla.selectedScrollSnap() !== currentIndexRef.current) {
237
+ suppressSelectRef.current = currentIndexRef.current;
238
+ embla.scrollTo(currentIndexRef.current, true);
239
+ suppressSelectRef.current = null;
240
+ }
241
+ };
242
+ embla.on("select", onSelect);
243
+ embla.on("reInit", onReInit);
244
+ return () => {
245
+ embla.off("select", onSelect);
246
+ embla.off("reInit", onReInit);
247
+ };
248
+ }, [embla]);
249
+ (0, react.useEffect)(() => {
250
+ if (embla && opened && embla.selectedScrollSnap() !== _currentIndex) {
251
+ suppressSelectRef.current = _currentIndex;
252
+ embla.scrollTo(_currentIndex, !animateSlides);
253
+ suppressSelectRef.current = null;
254
+ }
255
+ }, [
256
+ _currentIndex,
257
+ embla,
258
+ opened,
259
+ animateSlides
260
+ ]);
261
+ (0, react.useEffect)(() => {
262
+ if (slides.length > 0 && _currentIndex > slides.length - 1) setCurrentIndexRef.current(slides.length - 1);
263
+ }, [slides.length, _currentIndex]);
264
+ (0, _mantine_hooks.useFocusReturn)({
265
+ opened,
266
+ shouldReturnFocus: returnFocus
267
+ });
268
+ const shouldLockScroll = require_use_lightbox_lock_scroll.useLightboxLockScroll({
269
+ opened,
270
+ exitDuration: typeof transitionProps?.exitDuration === "number" ? transitionProps.exitDuration : typeof transitionProps?.duration === "number" ? transitionProps.duration : transitionDuration,
271
+ exitDelay: typeof transitionProps?.exitDelay === "number" ? transitionProps.exitDelay : 0
272
+ });
273
+ const transition = {
274
+ transition: defaultContentTransition,
275
+ duration: transitionDuration,
276
+ timingFunction: "ease",
277
+ ...transitionProps
278
+ };
279
+ const overlayTransition = {
280
+ transition: "fade",
281
+ duration: transition.duration,
282
+ exitDuration: transition.exitDuration,
283
+ timingFunction: transition.timingFunction,
284
+ enterDelay: transition.enterDelay,
285
+ exitDelay: transition.exitDelay,
286
+ keepMounted: transition.keepMounted
287
+ };
288
+ const setIndex = (0, react.useCallback)((index) => {
289
+ setCurrentIndexRef.current(index);
290
+ suppressSelectRef.current = index;
291
+ embla?.scrollTo(index, !animateSlides);
292
+ suppressSelectRef.current = null;
293
+ }, [embla, animateSlides]);
294
+ const currentSlide = slides[_currentIndex];
295
+ const currentSlideLabel = currentSlide?.type === "video" ? currentSlide.label : currentSlide?.type === "custom" ? void 0 : currentSlide?.alt;
296
+ const contextValue = (0, react.useMemo)(() => ({
297
+ getStyles: stableGetStyles,
298
+ labels: _labels,
299
+ opened,
300
+ slides,
301
+ currentIndex: _currentIndex,
302
+ setIndex,
303
+ next: handleNext,
304
+ prev: handlePrev,
305
+ embla: embla ?? null,
306
+ emblaRef,
307
+ withZoom: !!withZoom,
308
+ withThumbnails: !!withThumbnails,
309
+ withFullscreen: !!withFullscreen,
310
+ withDownload: !!withDownload,
311
+ thumbnailsVisible,
312
+ toggleThumbnails,
313
+ isFullscreen,
314
+ toggleFullscreen,
315
+ zoomState: zoom.zoomState,
316
+ toggleZoom: zoom.toggleZoom,
317
+ getImageZoomProps: zoom.getImageProps,
318
+ onClose,
319
+ loop: !!loop,
320
+ closeOnClickOutside: !!closeOnClickOutside,
321
+ closeOnSwipeDown: !!closeOnSwipeDown,
322
+ transitionDuration
323
+ }), [
324
+ stableGetStyles,
325
+ _labels,
326
+ opened,
327
+ slides,
328
+ _currentIndex,
329
+ setIndex,
330
+ handleNext,
331
+ handlePrev,
332
+ embla,
333
+ emblaRef,
334
+ withZoom,
335
+ withThumbnails,
336
+ withFullscreen,
337
+ withDownload,
338
+ thumbnailsVisible,
339
+ toggleThumbnails,
340
+ isFullscreen,
341
+ toggleFullscreen,
342
+ zoom,
343
+ onClose,
344
+ loop,
345
+ closeOnClickOutside,
346
+ closeOnSwipeDown,
347
+ transitionDuration
348
+ ]);
349
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.OptionalPortal, {
350
+ withinPortal,
351
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_lightbox_context.LightboxContextProvider, {
352
+ value: contextValue,
353
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.RemoveScroll, {
354
+ enabled: shouldLockScroll,
355
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mantine_core.Box, {
356
+ ...getStyles("root"),
357
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Transition, {
358
+ mounted: opened,
359
+ ...overlayTransition,
360
+ children: (overlayStyles) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Box, { ...getStyles("overlay", { style: overlayStyles }) })
361
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Transition, {
362
+ mounted: opened,
363
+ ...transition,
364
+ children: (contentStyles) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.FocusTrap, {
365
+ active: opened,
366
+ innerRef: ref,
367
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mantine_core.Box, {
368
+ ...getStyles("content", {
369
+ className,
370
+ style: style ? [style, contentStyles] : contentStyles
371
+ }),
372
+ role: "dialog",
373
+ "aria-modal": "true",
374
+ "aria-label": _labels.lightboxLabel,
375
+ tabIndex: -1,
376
+ ...others,
377
+ mod,
378
+ onClick: (event) => {
379
+ onClick?.(event);
380
+ if (closeOnClickOutside && event.target === event.currentTarget) onClose();
381
+ },
382
+ children: [
383
+ withInitialFocusPlaceholder && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.FocusTrap.InitialFocus, {}),
384
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.VisuallyHidden, {
385
+ role: "status",
386
+ "aria-live": "polite",
387
+ "aria-atomic": "true",
388
+ children: slides.length > 0 ? `${_labels.slideLabel(_currentIndex + 1, slides.length)}${currentSlideLabel ? `: ${currentSlideLabel}` : ""}` : null
389
+ }),
390
+ children
391
+ ]
392
+ })
393
+ })
394
+ })]
395
+ })
396
+ })
397
+ })
398
+ });
399
+ });
400
+ LightboxRoot.classes = require_Lightbox_module.default;
401
+ LightboxRoot.varsResolver = varsResolver;
402
+ LightboxRoot.displayName = "@mantine/lightbox/LightboxRoot";
403
+ //#endregion
404
+ exports.LightboxRoot = LightboxRoot;
405
+ exports.lightboxRootDefaultProps = lightboxRootDefaultProps;
406
+
407
+ //# sourceMappingURL=LightboxRoot.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LightboxRoot.cjs","names":["createVarsResolver","factory","useProps","useStyles","useMemo","DEFAULT_LABELS","useRef","useCallback","useUncontrolled","useState","useDirection","useEmblaCarousel","useFullscreenDocument","useLightboxZoom","useMantineTheme","useReducedMotion","useLightboxLockScroll","OptionalPortal","LightboxContextProvider","RemoveScroll","Box","Transition","FocusTrap","VisuallyHidden","classes"],"sources":["../../src/LightboxRoot/LightboxRoot.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { EmblaOptionsType } from 'embla-carousel';\nimport useEmblaCarousel from 'embla-carousel-react';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n FocusTrap,\n MantineTransition,\n OptionalPortal,\n RemoveScroll,\n StylesApiProps,\n Transition,\n TransitionOverride,\n useDirection,\n useMantineTheme,\n useProps,\n useStyles,\n VisuallyHidden,\n} from '@mantine/core';\nimport {\n useFocusReturn,\n useFullscreenDocument,\n useReducedMotion,\n useUncontrolled,\n} from '@mantine/hooks';\nimport { DEFAULT_LABELS } from '../default-labels';\nimport { useLightboxKeyboard } from '../hooks/use-lightbox-keyboard';\nimport { useLightboxLockScroll } from '../hooks/use-lightbox-lock-scroll';\nimport { useLightboxZoom } from '../hooks/use-lightbox-zoom';\nimport { LightboxContextProvider } from '../lightbox.context';\nimport type { LightboxLabels, LightboxSlideData } from '../lightbox.types';\nimport classes from '../Lightbox.module.css';\n\nexport type LightboxRootStylesNames =\n | 'root'\n | 'overlay'\n | 'content'\n | 'toolbar'\n | 'toolbarGroup'\n | 'toolbarButton'\n | 'counter'\n | 'slides'\n | 'slidesViewport'\n | 'slidesContainer'\n | 'slide'\n | 'slideImage'\n | 'slideVideo'\n | 'thumbnails'\n | 'thumbnailsViewport'\n | 'thumbnailsContainer'\n | 'thumbnail'\n | 'thumbnailImage'\n | 'navigation'\n | 'navigationButton'\n | 'caption'\n | 'closeButton';\n\nexport type LightboxCssVariables = {\n root:\n | '--lightbox-transition-duration'\n | '--lightbox-overlay-color'\n | '--lightbox-z-index'\n | '--lightbox-toolbar-height'\n | '--lightbox-thumbnails-height';\n};\n\nexport interface LightboxRootProps\n extends BoxProps, StylesApiProps<LightboxRootFactory>, ElementProps<'div', 'children'> {\n /** Controls whether the lightbox is opened */\n opened: boolean;\n\n /** Called when the lightbox is closed */\n onClose: () => void;\n\n /** Lightbox content (compound components) */\n children: React.ReactNode;\n\n /** Array of slide data objects */\n slides: LightboxSlideData[];\n\n /** Controlled current slide index */\n currentIndex?: number;\n\n /** Called when the current slide index changes */\n onIndexChange?: (index: number) => void;\n\n /** Labels used in the component, used for accessibility and localization */\n labels?: Partial<LightboxLabels>;\n\n /** Enables image zoom on click/pinch @default false */\n withZoom?: boolean;\n\n /** Shows bottom thumbnail strip @default false */\n withThumbnails?: boolean;\n\n /** Adds fullscreen toggle to toolbar @default false */\n withFullscreen?: boolean;\n\n /** Adds download button to toolbar @default false */\n withDownload?: boolean;\n\n /** Enables infinite loop navigation @default false */\n loop?: boolean;\n\n /** Closes lightbox when the empty space around the slide content is clicked @default false */\n closeOnClickOutside?: boolean;\n\n /** Closes lightbox when swiping down on mobile @default true */\n closeOnSwipeDown?: boolean;\n\n /** Determines whether keyboard shortcuts (arrows, `F`/`T`/`Z`) are active, `Escape` always closes the lightbox @default true */\n withKeyboardEvents?: boolean;\n\n /** Determines whether focus should be returned to the last active element when the lightbox is closed @default true */\n returnFocus?: boolean;\n\n /** Adds a hidden focusable element at the start of the lightbox content – prevents the first toolbar button from receiving visible focus when the lightbox is opened with a pointer. Set to `false` if you need custom focus management. @default true */\n withInitialFocusPlaceholder?: boolean;\n\n /** Determines whether the lightbox should be rendered inside `Portal` @default true */\n withinPortal?: boolean;\n\n /** `z-index` of the overlay and content elements, `400` by default */\n zIndex?: string | number;\n\n /** Transition duration in milliseconds @default 200 */\n transitionDuration?: number;\n\n /** Props passed down to the `Transition` component that animates the content, the overlay always fades. By default, the content is scaled from 95% to 100% while fading in. */\n transitionProps?: TransitionOverride;\n\n /** Additional Embla carousel options. `loop` and `startIndex` are controlled by the\n * `loop` and `currentIndex` props and cannot be set here, at the top level or in\n * `breakpoints`; a `watchDrag` option is still honored at both levels, but dragging is\n * always disabled while the image is zoomed. */\n emblaOptions?: EmblaOptionsType;\n\n /** Maximum zoom scale @default 3 */\n zoomMaxScale?: number;\n\n /** Enables animated slide transitions for programmatic navigation @default false */\n withSlideTransition?: boolean;\n}\n\nexport type LightboxRootFactory = Factory<{\n props: LightboxRootProps;\n ref: HTMLDivElement;\n stylesNames: LightboxRootStylesNames;\n vars: LightboxCssVariables;\n}>;\n\nexport const lightboxRootDefaultProps = {\n withZoom: false,\n withThumbnails: false,\n withFullscreen: false,\n withDownload: false,\n loop: false,\n closeOnClickOutside: false,\n closeOnSwipeDown: true,\n withKeyboardEvents: true,\n returnFocus: true,\n withInitialFocusPlaceholder: true,\n withinPortal: true,\n transitionDuration: 200,\n zoomMaxScale: 3,\n withSlideTransition: false,\n} satisfies Partial<LightboxRootProps>;\n\ntype WatchDragOption = EmblaOptionsType['watchDrag'];\n\nfunction createBreakpointWatchDrag(\n query: string,\n zoomIsActive: React.RefObject<boolean>,\n watchDragRef: React.RefObject<Record<string, WatchDragOption>>\n): WatchDragOption {\n return (emblaApi, event) => {\n if (zoomIsActive.current) {\n return false;\n }\n\n const option = watchDragRef.current[query];\n\n if (typeof option === 'function') {\n return option(emblaApi, event);\n }\n\n return option ?? true;\n };\n}\n\nconst defaultContentTransition: MantineTransition = {\n common: { transformOrigin: 'center center' },\n in: { opacity: 1, transform: 'scale(1)' },\n out: { opacity: 0, transform: 'scale(0.95)' },\n transitionProperty: 'transform, opacity',\n};\n\nfunction exitDocumentFullscreen() {\n const _document = document as any;\n const exit =\n _document.exitFullscreen ||\n _document.msExitFullscreen ||\n _document.webkitExitFullscreen ||\n _document.mozCancelFullScreen;\n\n if (typeof exit === 'function') {\n Promise.resolve(exit.call(_document)).catch(() => {});\n }\n}\n\nconst varsResolver = createVarsResolver<LightboxRootFactory>(\n (_, { transitionDuration, zIndex }) => ({\n root: {\n '--lightbox-transition-duration': `${transitionDuration}ms`,\n '--lightbox-overlay-color': undefined,\n '--lightbox-z-index': zIndex !== undefined ? `${zIndex}` : undefined,\n '--lightbox-toolbar-height': undefined,\n '--lightbox-thumbnails-height': undefined,\n },\n })\n);\n\nexport const LightboxRoot = factory<LightboxRootFactory>((_props) => {\n const props = useProps('LightboxRoot', lightboxRootDefaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n opened,\n onClose,\n children,\n slides,\n currentIndex,\n onIndexChange,\n labels,\n withZoom,\n withThumbnails,\n withFullscreen,\n withDownload,\n loop,\n closeOnClickOutside,\n closeOnSwipeDown,\n withKeyboardEvents,\n returnFocus,\n withInitialFocusPlaceholder,\n withinPortal,\n zIndex,\n transitionDuration,\n transitionProps,\n emblaOptions,\n zoomMaxScale,\n withSlideTransition,\n attributes,\n mod,\n onClick,\n ref,\n ...others\n } = props;\n\n const getStyles = useStyles<LightboxRootFactory>({\n name: 'Lightbox',\n classes,\n props,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const _labels = useMemo(() => ({ ...DEFAULT_LABELS, ...labels }), [labels]);\n\n const getStylesRef = useRef(getStyles);\n getStylesRef.current = getStyles;\n\n const stableGetStyles = useCallback<typeof getStyles>(\n (...args) => getStylesRef.current(...args),\n []\n );\n\n const [_currentIndex, setCurrentIndex] = useUncontrolled({\n value: currentIndex,\n defaultValue: 0,\n finalValue: 0,\n onChange: onIndexChange,\n });\n\n const zoomIsActive = useRef(false);\n const currentIndexRef = useRef(_currentIndex);\n const setCurrentIndexRef = useRef(setCurrentIndex);\n\n // Embla emits `select` synchronously from `scrollTo`. When the scroll was requested for\n // an index the consumer already knows about, that echo is suppressed for the duration\n // of the call so `onIndexChange` is not reported twice for one navigation.\n const suppressSelectRef = useRef<number | null>(null);\n const fullscreenRequestedRef = useRef(false);\n const ownsFullscreenRef = useRef(false);\n\n // A `requestFullscreen` that is still in flight, and whether it should be undone as soon\n // as it settles because the lightbox closed in the meantime.\n const pendingFullscreenRef = useRef<Promise<void> | null>(null);\n const exitOnSettleRef = useRef(false);\n\n // Embla compares options by function source, so the `watchDrag` closure above must stay\n // textually stable – the current user options are read through this ref instead.\n const emblaOptionsRef = useRef(emblaOptions);\n\n const [startIndex, setStartIndex] = useState(_currentIndex);\n const [prevOpened, setPrevOpened] = useState(opened);\n\n if (opened !== prevOpened) {\n setPrevOpened(opened);\n if (opened) {\n setStartIndex(_currentIndex);\n }\n }\n\n const { dir } = useDirection();\n\n const breakpointWatchDragRef = useRef<Record<string, WatchDragOption>>({});\n\n const resolvedEmblaOptions = useMemo(() => {\n if (!emblaOptions?.breakpoints) {\n breakpointWatchDragRef.current = {};\n return emblaOptions;\n }\n\n const watchDragOptions: Record<string, WatchDragOption> = {};\n\n const breakpoints = Object.fromEntries(\n Object.entries(emblaOptions.breakpoints).map(([query, value]) => {\n const { loop: _loop, startIndex: _startIndex, watchDrag, ...rest } = value ?? {};\n watchDragOptions[query] = watchDrag;\n\n return [\n query,\n watchDrag === undefined\n ? rest\n : {\n ...rest,\n watchDrag: createBreakpointWatchDrag(query, zoomIsActive, breakpointWatchDragRef),\n },\n ];\n })\n );\n\n breakpointWatchDragRef.current = watchDragOptions;\n return { ...emblaOptions, breakpoints };\n }, [emblaOptions]);\n\n const [emblaRef, embla] = useEmblaCarousel({\n // Placed before the user options so `emblaOptions.direction` can still override it,\n // the same way `@mantine/carousel` wires direction up.\n direction: dir,\n ...resolvedEmblaOptions,\n loop,\n startIndex,\n watchDrag: (emblaApi, event) => {\n // The zoom gesture lock always wins – dragging a zoomed image pans it\n // instead of changing the slide.\n if (zoomIsActive.current) {\n return false;\n }\n\n const userWatchDrag = emblaOptionsRef.current?.watchDrag;\n if (typeof userWatchDrag === 'function') {\n return userWatchDrag(emblaApi, event);\n }\n\n return userWatchDrag ?? true;\n },\n });\n\n const [thumbnailsVisible, setThumbnailsVisible] = useState(!!withThumbnails);\n const [prevWithThumbnails, setPrevWithThumbnails] = useState(withThumbnails);\n\n // Toggling the feature while the lightbox is open used to leave the strip expanded with\n // no way to collapse it – the toolbar button that toggles it is only rendered while\n // `withThumbnails` is set.\n if (withThumbnails !== prevWithThumbnails) {\n setPrevWithThumbnails(withThumbnails);\n setThumbnailsVisible(!!withThumbnails);\n }\n\n const { toggle: toggleFullscreenFn, fullscreen: isFullscreen } = useFullscreenDocument();\n\n const toggleThumbnails = useCallback(() => {\n setThumbnailsVisible((prev) => !prev);\n }, []);\n\n const toggleFullscreen = useCallback(() => {\n fullscreenRequestedRef.current = !isFullscreen;\n if (isFullscreen) {\n ownsFullscreenRef.current = false;\n }\n\n const request = toggleFullscreenFn()\n .then(() => {\n // Closing while `requestFullscreen` is still pending cannot exit anything yet – the\n // browser has not entered fullscreen. The exit has to be retried once the request\n // settles, or the page is left fullscreen with no lightbox on top of it.\n if (pendingFullscreenRef.current === request && exitOnSettleRef.current) {\n exitOnSettleRef.current = false;\n exitDocumentFullscreen();\n }\n })\n .catch(() => {\n fullscreenRequestedRef.current = false;\n exitOnSettleRef.current = false;\n })\n .finally(() => {\n if (pendingFullscreenRef.current === request) {\n pendingFullscreenRef.current = null;\n }\n });\n\n pendingFullscreenRef.current = request;\n }, [toggleFullscreenFn, isFullscreen]);\n\n useEffect(() => {\n if (!isFullscreen) {\n fullscreenRequestedRef.current = false;\n ownsFullscreenRef.current = false;\n } else if (fullscreenRequestedRef.current) {\n fullscreenRequestedRef.current = false;\n ownsFullscreenRef.current = true;\n }\n }, [isFullscreen]);\n\n const exitOwnedFullscreen = useCallback(() => {\n if (!ownsFullscreenRef.current && !fullscreenRequestedRef.current) {\n return;\n }\n\n // A request that has not settled yet cannot be exited now – it is exited when it does.\n if (pendingFullscreenRef.current !== null && fullscreenRequestedRef.current) {\n exitOnSettleRef.current = true;\n }\n\n fullscreenRequestedRef.current = false;\n ownsFullscreenRef.current = false;\n exitDocumentFullscreen();\n }, []);\n\n const zoom = useLightboxZoom({\n enabled: !!withZoom,\n maxScale: zoomMaxScale!,\n currentIndex: _currentIndex,\n });\n\n useEffect(() => {\n currentIndexRef.current = _currentIndex;\n setCurrentIndexRef.current = setCurrentIndex;\n zoomIsActive.current = zoom.zoomState.isZoomed;\n emblaOptionsRef.current = emblaOptions;\n });\n\n const { resetZoom } = zoom;\n\n useEffect(() => {\n if (!opened) {\n resetZoom();\n setThumbnailsVisible(!!withThumbnails);\n exitOwnedFullscreen();\n }\n }, [opened, resetZoom, withThumbnails, exitOwnedFullscreen]);\n\n useEffect(() => exitOwnedFullscreen, [exitOwnedFullscreen]);\n\n const theme = useMantineTheme();\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const animateSlides = !!withSlideTransition && !reduceMotion;\n\n const handleNext = useCallback(() => {\n embla?.scrollNext(!animateSlides);\n }, [embla, animateSlides]);\n\n const handlePrev = useCallback(() => {\n embla?.scrollPrev(!animateSlides);\n }, [embla, animateSlides]);\n\n useLightboxKeyboard({\n opened,\n enabled: withKeyboardEvents!,\n dir,\n onClose,\n onNext: handleNext,\n onPrev: handlePrev,\n onToggleFullscreen: withFullscreen ? toggleFullscreen : undefined,\n onToggleThumbnails: withThumbnails ? toggleThumbnails : undefined,\n onToggleZoom: withZoom ? zoom.toggleZoom : undefined,\n onZoomPan: withZoom ? zoom.panZoom : undefined,\n });\n\n useEffect(() => {\n if (!embla) {\n return undefined;\n }\n\n const onSelect = () => {\n const selected = embla.selectedScrollSnap();\n\n if (selected !== suppressSelectRef.current) {\n setCurrentIndexRef.current(selected);\n }\n };\n\n const onReInit = () => {\n if (embla.selectedScrollSnap() !== currentIndexRef.current) {\n suppressSelectRef.current = currentIndexRef.current;\n embla.scrollTo(currentIndexRef.current, true);\n suppressSelectRef.current = null;\n }\n };\n\n embla.on('select', onSelect);\n embla.on('reInit', onReInit);\n return () => {\n embla.off('select', onSelect);\n embla.off('reInit', onReInit);\n };\n }, [embla]);\n\n useEffect(() => {\n if (embla && opened && embla.selectedScrollSnap() !== _currentIndex) {\n // `_currentIndex` is already what the consumer asked for – do not echo it back\n suppressSelectRef.current = _currentIndex;\n embla.scrollTo(_currentIndex, !animateSlides);\n suppressSelectRef.current = null;\n }\n }, [_currentIndex, embla, opened, animateSlides]);\n\n // Slides can be replaced or shortened while the lightbox is open – without this the\n // index can point past the end, leaving no active slide and a counter like \"3 / 2\".\n useEffect(() => {\n if (slides.length > 0 && _currentIndex > slides.length - 1) {\n setCurrentIndexRef.current(slides.length - 1);\n }\n }, [slides.length, _currentIndex]);\n\n useFocusReturn({ opened, shouldReturnFocus: returnFocus });\n\n const shouldLockScroll = useLightboxLockScroll({\n opened,\n exitDuration:\n typeof transitionProps?.exitDuration === 'number'\n ? transitionProps.exitDuration\n : typeof transitionProps?.duration === 'number'\n ? transitionProps.duration\n : transitionDuration,\n exitDelay: typeof transitionProps?.exitDelay === 'number' ? transitionProps.exitDelay : 0,\n });\n\n const transition: TransitionOverride = {\n transition: defaultContentTransition,\n duration: transitionDuration,\n timingFunction: 'ease',\n ...transitionProps,\n };\n\n const overlayTransition: TransitionOverride = {\n transition: 'fade',\n duration: transition.duration,\n exitDuration: transition.exitDuration,\n timingFunction: transition.timingFunction,\n enterDelay: transition.enterDelay,\n exitDelay: transition.exitDelay,\n keepMounted: transition.keepMounted,\n };\n\n const setIndex = useCallback(\n (index: number) => {\n setCurrentIndexRef.current(index);\n suppressSelectRef.current = index;\n embla?.scrollTo(index, !animateSlides);\n suppressSelectRef.current = null;\n },\n [embla, animateSlides]\n );\n\n const currentSlide = slides[_currentIndex];\n const currentSlideLabel =\n currentSlide?.type === 'video'\n ? currentSlide.label\n : currentSlide?.type === 'custom'\n ? undefined\n : currentSlide?.alt;\n\n const contextValue = useMemo(\n () => ({\n getStyles: stableGetStyles,\n labels: _labels,\n opened,\n slides,\n currentIndex: _currentIndex,\n setIndex,\n next: handleNext,\n prev: handlePrev,\n embla: embla ?? null,\n emblaRef,\n withZoom: !!withZoom,\n withThumbnails: !!withThumbnails,\n withFullscreen: !!withFullscreen,\n withDownload: !!withDownload,\n thumbnailsVisible,\n toggleThumbnails,\n isFullscreen,\n toggleFullscreen,\n zoomState: zoom.zoomState,\n toggleZoom: zoom.toggleZoom,\n getImageZoomProps: zoom.getImageProps,\n onClose,\n loop: !!loop,\n closeOnClickOutside: !!closeOnClickOutside,\n closeOnSwipeDown: !!closeOnSwipeDown,\n transitionDuration: transitionDuration!,\n }),\n [\n stableGetStyles,\n _labels,\n opened,\n slides,\n _currentIndex,\n setIndex,\n handleNext,\n handlePrev,\n embla,\n emblaRef,\n withZoom,\n withThumbnails,\n withFullscreen,\n withDownload,\n thumbnailsVisible,\n toggleThumbnails,\n isFullscreen,\n toggleFullscreen,\n zoom,\n onClose,\n loop,\n closeOnClickOutside,\n closeOnSwipeDown,\n transitionDuration,\n ]\n );\n\n return (\n <OptionalPortal withinPortal={withinPortal}>\n <LightboxContextProvider value={contextValue}>\n <RemoveScroll enabled={shouldLockScroll}>\n <Box {...getStyles('root')}>\n <Transition mounted={opened} {...overlayTransition}>\n {(overlayStyles) => <Box {...getStyles('overlay', { style: overlayStyles })} />}\n </Transition>\n\n <Transition mounted={opened} {...transition}>\n {(contentStyles) => (\n <FocusTrap active={opened} innerRef={ref}>\n <Box\n {...getStyles('content', {\n className,\n style: style ? [style, contentStyles] : contentStyles,\n })}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={_labels.lightboxLabel}\n tabIndex={-1}\n {...others}\n mod={mod}\n onClick={(event) => {\n onClick?.(event);\n if (closeOnClickOutside && event.target === event.currentTarget) {\n onClose();\n }\n }}\n >\n {withInitialFocusPlaceholder && <FocusTrap.InitialFocus />}\n\n <VisuallyHidden role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {slides.length > 0\n ? `${_labels.slideLabel(_currentIndex + 1, slides.length)}${currentSlideLabel ? `: ${currentSlideLabel}` : ''}`\n : null}\n </VisuallyHidden>\n {children}\n </Box>\n </FocusTrap>\n )}\n </Transition>\n </Box>\n </RemoveScroll>\n </LightboxContextProvider>\n </OptionalPortal>\n );\n});\n\nLightboxRoot.classes = classes;\nLightboxRoot.varsResolver = varsResolver;\nLightboxRoot.displayName = '@mantine/lightbox/LightboxRoot';\n"],"mappings":";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AA,kBAAA,IAAA,CAACC,cAAAA,YAAD;MAAY,SAAS;MAAQ,GAAI;MAC7B,WAAA,kBAAkB,iBAAA,GAAA,kBAAA,IAAA,CAACD,cAAAA,KAAD,EAAK,GAAI,UAAU,WAAW,EAAE,OAAO,cAAc,CAAC,EAAI,CAAA;KACpE,CAAA,GAEZ,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,YAAD;MAAY,SAAS;MAAQ,GAAI;MAC7B,WAAA,kBACA,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,WAAD;OAAW,QAAQ;OAAQ,UAAU;OACnC,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAACF,cAAAA,KAAD;QACE,GAAI,UAAU,WAAW;SACvB;SACA,OAAO,QAAQ,CAAC,OAAO,aAAa,IAAI;QAC1C,CAAC;QACD,MAAK;QACL,cAAW;QACX,cAAY,QAAQ;QACpB,UAAU;QACV,GAAI;QACC;QACL,UAAU,UAAU;SAClB,UAAU,KAAK;SACf,IAAI,uBAAuB,MAAM,WAAW,MAAM,eAChD,QAAQ;QAEZ;QAhBF,UAAA;SAkBG,+BAA+B,iBAAA,GAAA,kBAAA,IAAA,CAACE,cAAAA,UAAU,cAAX,CAAyB,CAAA;SAEzD,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,gBAAD;UAAgB,MAAK;UAAS,aAAU;UAAS,eAAY;UAC1D,UAAA,OAAO,SAAS,IACb,GAAG,QAAQ,WAAW,gBAAgB,GAAG,OAAO,MAAM,IAAI,oBAAoB,KAAK,sBAAsB,OACzG;SACU,CAAA;SACf;QACE;;MACI,CAAA;KAEH,CAAA,CACT;;GACO,CAAA;EACS,CAAA;CACX,CAAA;AAEpB,CAAC;AAED,aAAa,UAAUC,wBAAAA;AACvB,aAAa,eAAe;AAC5B,aAAa,cAAc"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ const require_lightbox_context = require("../lightbox.context.cjs");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ //#region packages/@mantine/lightbox/src/LightboxSlide/ImageSlide.tsx
5
+ function ImageSlide({ slide, active, stylesApiProps }) {
6
+ const ctx = require_lightbox_context.useLightboxContext();
7
+ const { style: zoomStyle, ...zoomProps } = active && ctx.withZoom ? ctx.getImageZoomProps() : { style: void 0 };
8
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
9
+ ...ctx.getStyles("slideImage", {
10
+ ...stylesApiProps,
11
+ style: zoomStyle
12
+ }),
13
+ src: slide.src,
14
+ alt: slide.alt ?? "",
15
+ srcSet: slide.srcSet,
16
+ sizes: slide.sizes,
17
+ loading: slide.loading ?? (active ? "eager" : "lazy"),
18
+ draggable: false,
19
+ "data-reduce-motion": "true",
20
+ ...zoomProps
21
+ });
22
+ }
23
+ ImageSlide.displayName = "@mantine/lightbox/ImageSlide";
24
+ //#endregion
25
+ exports.ImageSlide = ImageSlide;
26
+
27
+ //# sourceMappingURL=ImageSlide.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageSlide.cjs","names":["useLightboxContext"],"sources":["../../src/LightboxSlide/ImageSlide.tsx"],"sourcesContent":["import { useLightboxContext } from '../lightbox.context';\nimport type { LightboxImageSlide } from '../lightbox.types';\nimport type { LightboxSlideStylesApiProps } from './LightboxSlide';\n\ninterface ImageSlideProps {\n slide: LightboxImageSlide;\n active: boolean;\n stylesApiProps?: LightboxSlideStylesApiProps;\n}\n\nexport function ImageSlide({ slide, active, stylesApiProps }: ImageSlideProps) {\n const ctx = useLightboxContext();\n const { style: zoomStyle, ...zoomProps } =\n active && ctx.withZoom ? ctx.getImageZoomProps() : { style: undefined };\n\n return (\n <img\n {...ctx.getStyles('slideImage', { ...stylesApiProps, style: zoomStyle })}\n src={slide.src}\n alt={slide.alt ?? ''}\n srcSet={slide.srcSet}\n sizes={slide.sizes}\n loading={slide.loading ?? (active ? 'eager' : 'lazy')}\n draggable={false}\n data-reduce-motion=\"true\"\n {...zoomProps}\n />\n );\n}\n\nImageSlide.displayName = '@mantine/lightbox/ImageSlide';\n"],"mappings":";;;;AAUA,SAAgB,WAAW,EAAE,OAAO,QAAQ,kBAAmC;CAC7E,MAAM,MAAMA,yBAAAA,mBAAmB;CAC/B,MAAM,EAAE,OAAO,WAAW,GAAG,cAC3B,UAAU,IAAI,WAAW,IAAI,kBAAkB,IAAI,EAAE,OAAO,KAAA,EAAU;CAExE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI,IAAI,UAAU,cAAc;GAAE,GAAG;GAAgB,OAAO;EAAU,CAAC;EACvE,KAAK,MAAM;EACX,KAAK,MAAM,OAAO;EAClB,QAAQ,MAAM;EACd,OAAO,MAAM;EACb,SAAS,MAAM,YAAY,SAAS,UAAU;EAC9C,WAAW;EACX,sBAAmB;EACnB,GAAI;CACL,CAAA;AAEL;AAEA,WAAW,cAAc"}
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ const require_lightbox_context = require("../lightbox.context.cjs");
3
+ const require_Lightbox_module = require("../Lightbox.module.cjs");
4
+ const require_ImageSlide = require("./ImageSlide.cjs");
5
+ const require_VideoSlide = require("./VideoSlide.cjs");
6
+ let _mantine_core = require("@mantine/core");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+ //#region packages/@mantine/lightbox/src/LightboxSlide/LightboxSlide.tsx
9
+ const LightboxSlide = (0, _mantine_core.factory)((props) => {
10
+ const { classNames, className, style, styles, vars, slide, index, onClick, ...others } = (0, _mantine_core.useProps)("LightboxSlide", null, props);
11
+ const ctx = require_lightbox_context.useLightboxContext();
12
+ const active = ctx.currentIndex === index;
13
+ const stylesApiProps = {
14
+ classNames,
15
+ styles
16
+ };
17
+ const renderContent = () => {
18
+ if (slide.type === "video") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_VideoSlide.VideoSlide, {
19
+ slide,
20
+ active,
21
+ stylesApiProps
22
+ });
23
+ if (slide.type === "custom") return slide.render({ active });
24
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ImageSlide.ImageSlide, {
25
+ slide,
26
+ active,
27
+ stylesApiProps
28
+ });
29
+ };
30
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Box, {
31
+ ...ctx.getStyles("slide", {
32
+ className,
33
+ style,
34
+ classNames,
35
+ styles
36
+ }),
37
+ role: "group",
38
+ "aria-roledescription": "slide",
39
+ "data-lightbox-slide": true,
40
+ "aria-label": ctx.labels.slideLabel(index + 1, ctx.slides.length),
41
+ inert: !active,
42
+ ...others,
43
+ onClick: (event) => {
44
+ onClick?.(event);
45
+ if (ctx.closeOnClickOutside && !event.defaultPrevented && event.target === event.currentTarget) ctx.onClose();
46
+ },
47
+ children: renderContent()
48
+ });
49
+ });
50
+ LightboxSlide.classes = require_Lightbox_module.default;
51
+ LightboxSlide.displayName = "@mantine/lightbox/LightboxSlide";
52
+ //#endregion
53
+ exports.LightboxSlide = LightboxSlide;
54
+
55
+ //# sourceMappingURL=LightboxSlide.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LightboxSlide.cjs","names":["factory","useProps","useLightboxContext","VideoSlide","ImageSlide","Box","classes"],"sources":["../../src/LightboxSlide/LightboxSlide.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n CompoundStylesApiProps,\n ElementProps,\n factory,\n Factory,\n useProps,\n} from '@mantine/core';\nimport { useLightboxContext } from '../lightbox.context';\nimport type { LightboxSlideData } from '../lightbox.types';\nimport { ImageSlide } from './ImageSlide';\nimport { VideoSlide } from './VideoSlide';\nimport classes from '../Lightbox.module.css';\n\nexport type LightboxSlideStylesNames = 'slide' | 'slideImage' | 'slideVideo';\n\nexport interface LightboxSlideStylesApiProps {\n classNames?: CompoundStylesApiProps<LightboxSlideFactory>['classNames'];\n styles?: CompoundStylesApiProps<LightboxSlideFactory>['styles'];\n}\n\nexport interface LightboxSlideProps\n extends BoxProps, CompoundStylesApiProps<LightboxSlideFactory>, ElementProps<'div'> {\n /** Slide data object */\n slide: LightboxSlideData;\n\n /** Index of the slide in the slides array */\n index: number;\n}\n\nexport type LightboxSlideFactory = Factory<{\n props: LightboxSlideProps;\n ref: HTMLDivElement;\n stylesNames: LightboxSlideStylesNames;\n compound: true;\n}>;\n\nexport const LightboxSlide = factory<LightboxSlideFactory>((props) => {\n const { classNames, className, style, styles, vars, slide, index, onClick, ...others } = useProps(\n 'LightboxSlide',\n null,\n props\n );\n\n const ctx = useLightboxContext();\n const active = ctx.currentIndex === index;\n\n const stylesApiProps = { classNames, styles };\n\n const renderContent = () => {\n if (slide.type === 'video') {\n return <VideoSlide slide={slide} active={active} stylesApiProps={stylesApiProps} />;\n }\n\n if (slide.type === 'custom') {\n return slide.render({ active });\n }\n\n return <ImageSlide slide={slide} active={active} stylesApiProps={stylesApiProps} />;\n };\n\n return (\n <Box\n {...ctx.getStyles('slide', { className, style, classNames, styles })}\n role=\"group\"\n aria-roledescription=\"slide\"\n data-lightbox-slide\n aria-label={ctx.labels.slideLabel(index + 1, ctx.slides.length)}\n inert={!active}\n {...others}\n onClick={(event) => {\n onClick?.(event);\n if (\n ctx.closeOnClickOutside &&\n !event.defaultPrevented &&\n event.target === event.currentTarget\n ) {\n ctx.onClose();\n }\n }}\n >\n {renderContent()}\n </Box>\n );\n});\n\nLightboxSlide.classes = classes;\nLightboxSlide.displayName = '@mantine/lightbox/LightboxSlide';\n"],"mappings":";;;;;;;;AAsCA,MAAa,iBAAA,GAAgBA,cAAAA,QAAAA,EAA+B,UAAU;CACpE,MAAM,EAAE,YAAY,WAAW,OAAO,QAAQ,MAAM,OAAO,OAAO,SAAS,GAAG,YAAA,GAAWC,cAAAA,SAAAA,CACvF,iBACA,MACA,KACF;CAEA,MAAM,MAAMC,yBAAAA,mBAAmB;CAC/B,MAAM,SAAS,IAAI,iBAAiB;CAEpC,MAAM,iBAAiB;EAAE;EAAY;CAAO;CAE5C,MAAM,sBAAsB;EAC1B,IAAI,MAAM,SAAS,SACjB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,YAAD;GAAmB;GAAe;GAAwB;EAAiB,CAAA;EAGpF,IAAI,MAAM,SAAS,UACjB,OAAO,MAAM,OAAO,EAAE,OAAO,CAAC;EAGhC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,YAAD;GAAmB;GAAe;GAAwB;EAAiB,CAAA;CACpF;CAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,KAAD;EACE,GAAI,IAAI,UAAU,SAAS;GAAE;GAAW;GAAO;GAAY;EAAO,CAAC;EACnE,MAAK;EACL,wBAAqB;EACrB,uBAAA;EACA,cAAY,IAAI,OAAO,WAAW,QAAQ,GAAG,IAAI,OAAO,MAAM;EAC9D,OAAO,CAAC;EACR,GAAI;EACJ,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IACE,IAAI,uBACJ,CAAC,MAAM,oBACP,MAAM,WAAW,MAAM,eAEvB,IAAI,QAAQ;EAEhB;EAEC,UAAA,cAAc;CACZ,CAAA;AAET,CAAC;AAED,cAAc,UAAUC,wBAAAA;AACxB,cAAc,cAAc"}
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ const require_lightbox_context = require("../lightbox.context.cjs");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ let react = require("react");
5
+ //#region packages/@mantine/lightbox/src/LightboxSlide/VideoSlide.tsx
6
+ function VideoSlide({ slide, active, stylesApiProps }) {
7
+ const ctx = require_lightbox_context.useLightboxContext();
8
+ const videoRef = (0, react.useRef)(null);
9
+ const playing = active && ctx.opened;
10
+ (0, react.useEffect)(() => {
11
+ const video = videoRef.current;
12
+ if (!video) return;
13
+ if (!playing) {
14
+ video.pause();
15
+ return;
16
+ }
17
+ if (slide.autoPlay) video.play().catch(() => {});
18
+ }, [playing, slide.autoPlay]);
19
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("video", {
20
+ ref: videoRef,
21
+ ...ctx.getStyles("slideVideo", stylesApiProps),
22
+ src: slide.src,
23
+ poster: slide.poster,
24
+ "aria-label": slide.label,
25
+ autoPlay: playing && slide.autoPlay,
26
+ "data-active": active || void 0,
27
+ controls: true,
28
+ playsInline: true,
29
+ children: slide.tracks?.map((track, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("track", {
30
+ src: track.src,
31
+ kind: track.kind ?? "subtitles",
32
+ srcLang: track.srcLang,
33
+ label: track.label,
34
+ default: track.default
35
+ }, index))
36
+ });
37
+ }
38
+ VideoSlide.displayName = "@mantine/lightbox/VideoSlide";
39
+ //#endregion
40
+ exports.VideoSlide = VideoSlide;
41
+
42
+ //# sourceMappingURL=VideoSlide.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VideoSlide.cjs","names":["useLightboxContext","useRef"],"sources":["../../src/LightboxSlide/VideoSlide.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useLightboxContext } from '../lightbox.context';\nimport type { LightboxVideoSlide } from '../lightbox.types';\nimport type { LightboxSlideStylesApiProps } from './LightboxSlide';\n\ninterface VideoSlideProps {\n slide: LightboxVideoSlide;\n active: boolean;\n stylesApiProps?: LightboxSlideStylesApiProps;\n}\n\nexport function VideoSlide({ slide, active, stylesApiProps }: VideoSlideProps) {\n const ctx = useLightboxContext();\n const videoRef = useRef<HTMLVideoElement>(null);\n\n // With `transitionProps.keepMounted` the slides stay mounted while the lightbox is\n // closed, so playback has to follow `opened` as well – otherwise a hidden autoplay video\n // starts on its own and keeps playing after the lightbox is dismissed.\n const playing = active && ctx.opened;\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (!video) {\n return;\n }\n\n if (!playing) {\n video.pause();\n return;\n }\n\n // All slides are mounted up front, so the `autoPlay` attribute only ever fires for the\n // slide that happens to be active on mount – playback has to be started explicitly\n // when an already mounted video becomes the current slide.\n if (slide.autoPlay) {\n video.play().catch(() => {});\n }\n }, [playing, slide.autoPlay]);\n\n return (\n /* eslint-disable jsx-a11y/media-has-caption */\n <video\n ref={videoRef}\n {...ctx.getStyles('slideVideo', stylesApiProps)}\n src={slide.src}\n poster={slide.poster}\n aria-label={slide.label}\n autoPlay={playing && slide.autoPlay}\n data-active={active || undefined}\n controls\n playsInline\n >\n {slide.tracks?.map((track, index) => (\n <track\n key={index}\n src={track.src}\n kind={track.kind ?? 'subtitles'}\n srcLang={track.srcLang}\n label={track.label}\n default={track.default}\n />\n ))}\n </video>\n /* eslint-enable jsx-a11y/media-has-caption */\n );\n}\n\nVideoSlide.displayName = '@mantine/lightbox/VideoSlide';\n"],"mappings":";;;;;AAWA,SAAgB,WAAW,EAAE,OAAO,QAAQ,kBAAmC;CAC7E,MAAM,MAAMA,yBAAAA,mBAAmB;CAC/B,MAAM,YAAA,GAAWC,MAAAA,OAAAA,CAAyB,IAAI;CAK9C,MAAM,UAAU,UAAU,IAAI;CAE9B,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,QAAQ,SAAS;EAEvB,IAAI,CAAC,OACH;EAGF,IAAI,CAAC,SAAS;GACZ,MAAM,MAAM;GACZ;EACF;EAKA,IAAI,MAAM,UACR,MAAM,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC;CAE/B,GAAG,CAAC,SAAS,MAAM,QAAQ,CAAC;CAE5B,OAEE,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;EACE,KAAK;EACL,GAAI,IAAI,UAAU,cAAc,cAAc;EAC9C,KAAK,MAAM;EACX,QAAQ,MAAM;EACd,cAAY,MAAM;EAClB,UAAU,WAAW,MAAM;EAC3B,eAAa,UAAU,KAAA;EACvB,UAAA;EACA,aAAA;EAEC,UAAA,MAAM,QAAQ,KAAK,OAAO,UACzB,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;GAEE,KAAK,MAAM;GACX,MAAM,MAAM,QAAQ;GACpB,SAAS,MAAM;GACf,OAAO,MAAM;GACb,SAAS,MAAM;EAChB,GANM,KAMN,CACF;CACI,CAAA;AAGX;AAEA,WAAW,cAAc"}