yet-another-react-lightbox 3.5.3 → 3.6.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.
Files changed (203) hide show
  1. package/dist/index.d.ts +240 -4
  2. package/dist/index.js +1317 -4
  3. package/dist/plugins/captions/captions.css +1 -33
  4. package/dist/plugins/captions/captions.css.d.ts +2 -0
  5. package/dist/plugins/captions/index.d.ts +8 -4
  6. package/dist/plugins/captions/index.js +104 -3
  7. package/dist/plugins/counter/counter.css +1 -16
  8. package/dist/plugins/counter/counter.css.d.ts +2 -0
  9. package/dist/plugins/counter/index.d.ts +8 -3
  10. package/dist/plugins/counter/index.js +18 -2
  11. package/dist/plugins/download/index.d.ts +6 -3
  12. package/dist/plugins/download/index.js +90 -3
  13. package/dist/plugins/fullscreen/index.d.ts +8 -4
  14. package/dist/plugins/fullscreen/index.js +128 -3
  15. package/dist/plugins/index.d.ts +9 -9
  16. package/dist/plugins/index.js +9 -9
  17. package/dist/plugins/inline/index.d.ts +8 -3
  18. package/dist/plugins/inline/index.js +26 -2
  19. package/dist/plugins/slideshow/index.d.ts +8 -4
  20. package/dist/plugins/slideshow/index.js +113 -3
  21. package/dist/plugins/thumbnails/index.d.ts +7 -4
  22. package/dist/plugins/thumbnails/index.js +262 -3
  23. package/dist/plugins/thumbnails/thumbnails.css +1 -139
  24. package/dist/plugins/thumbnails/thumbnails.css.d.ts +2 -0
  25. package/dist/plugins/video/index.d.ts +7 -2
  26. package/dist/plugins/video/index.js +109 -2
  27. package/dist/plugins/zoom/index.d.ts +7 -4
  28. package/dist/plugins/zoom/index.js +499 -3
  29. package/dist/styles.css +1 -281
  30. package/dist/styles.css.d.ts +2 -0
  31. package/dist/types.d.ts +123 -47
  32. package/dist/types.js +51 -1
  33. package/package.json +34 -10
  34. package/dist/Lightbox.d.ts +0 -4
  35. package/dist/Lightbox.js +0 -46
  36. package/dist/core/components/IconButton.d.ts +0 -7
  37. package/dist/core/components/IconButton.js +0 -8
  38. package/dist/core/components/Icons.d.ts +0 -29
  39. package/dist/core/components/Icons.js +0 -27
  40. package/dist/core/components/ImageSlide.d.ts +0 -13
  41. package/dist/core/components/ImageSlide.js +0 -68
  42. package/dist/core/components/index.d.ts +0 -3
  43. package/dist/core/components/index.js +0 -3
  44. package/dist/core/config.d.ts +0 -7
  45. package/dist/core/config.js +0 -93
  46. package/dist/core/consts.d.ts +0 -50
  47. package/dist/core/consts.js +0 -49
  48. package/dist/core/contexts/Events.d.ts +0 -17
  49. package/dist/core/contexts/Events.js +0 -29
  50. package/dist/core/contexts/LightboxProps.d.ts +0 -6
  51. package/dist/core/contexts/LightboxProps.js +0 -7
  52. package/dist/core/contexts/LightboxState.d.ts +0 -27
  53. package/dist/core/contexts/LightboxState.js +0 -49
  54. package/dist/core/contexts/Timeouts.d.ts +0 -8
  55. package/dist/core/contexts/Timeouts.js +0 -32
  56. package/dist/core/contexts/index.d.ts +0 -4
  57. package/dist/core/contexts/index.js +0 -4
  58. package/dist/core/hooks/index.d.ts +0 -11
  59. package/dist/core/hooks/index.js +0 -11
  60. package/dist/core/hooks/useAnimation.d.ts +0 -15
  61. package/dist/core/hooks/useAnimation.js +0 -57
  62. package/dist/core/hooks/useContainerRect.d.ts +0 -7
  63. package/dist/core/hooks/useContainerRect.js +0 -36
  64. package/dist/core/hooks/useDelay.d.ts +0 -1
  65. package/dist/core/hooks/useDelay.js +0 -10
  66. package/dist/core/hooks/useEventCallback.d.ts +0 -1
  67. package/dist/core/hooks/useEventCallback.js +0 -9
  68. package/dist/core/hooks/useForkRef.d.ts +0 -3
  69. package/dist/core/hooks/useForkRef.js +0 -17
  70. package/dist/core/hooks/useLayoutEffect.d.ts +0 -2
  71. package/dist/core/hooks/useLayoutEffect.js +0 -3
  72. package/dist/core/hooks/useLoseFocus.d.ts +0 -4
  73. package/dist/core/hooks/useLoseFocus.js +0 -19
  74. package/dist/core/hooks/useMotionPreference.d.ts +0 -1
  75. package/dist/core/hooks/useMotionPreference.js +0 -13
  76. package/dist/core/hooks/useRTL.d.ts +0 -1
  77. package/dist/core/hooks/useRTL.js +0 -9
  78. package/dist/core/hooks/useSensors.d.ts +0 -14
  79. package/dist/core/hooks/useSensors.js +0 -38
  80. package/dist/core/hooks/useThrottle.d.ts +0 -1
  81. package/dist/core/hooks/useThrottle.js +0 -16
  82. package/dist/core/index.d.ts +0 -7
  83. package/dist/core/index.js +0 -7
  84. package/dist/core/modules/Carousel.d.ts +0 -4
  85. package/dist/core/modules/Carousel.js +0 -72
  86. package/dist/core/modules/Controller.d.ts +0 -31
  87. package/dist/core/modules/Controller.js +0 -215
  88. package/dist/core/modules/Navigation.d.ts +0 -13
  89. package/dist/core/modules/Navigation.js +0 -35
  90. package/dist/core/modules/NoScroll.d.ts +0 -4
  91. package/dist/core/modules/NoScroll.js +0 -52
  92. package/dist/core/modules/Portal.d.ts +0 -4
  93. package/dist/core/modules/Portal.js +0 -92
  94. package/dist/core/modules/Root.d.ts +0 -4
  95. package/dist/core/modules/Root.js +0 -7
  96. package/dist/core/modules/Toolbar.d.ts +0 -4
  97. package/dist/core/modules/Toolbar.js +0 -25
  98. package/dist/core/modules/controller/index.d.ts +0 -8
  99. package/dist/core/modules/controller/index.js +0 -9
  100. package/dist/core/modules/controller/usePointerSwipe.d.ts +0 -2
  101. package/dist/core/modules/controller/usePointerSwipe.js +0 -72
  102. package/dist/core/modules/controller/usePreventSwipeNavigation.d.ts +0 -3
  103. package/dist/core/modules/controller/usePreventSwipeNavigation.js +0 -20
  104. package/dist/core/modules/controller/useWheelSwipe.d.ts +0 -3
  105. package/dist/core/modules/controller/useWheelSwipe.js +0 -92
  106. package/dist/core/modules/index.d.ts +0 -7
  107. package/dist/core/modules/index.js +0 -7
  108. package/dist/core/utils.d.ts +0 -31
  109. package/dist/core/utils.js +0 -64
  110. package/dist/plugins/captions/Captions.d.ts +0 -3
  111. package/dist/plugins/captions/Captions.js +0 -25
  112. package/dist/plugins/captions/CaptionsButton.d.ts +0 -2
  113. package/dist/plugins/captions/CaptionsButton.js +0 -16
  114. package/dist/plugins/captions/CaptionsContext.d.ts +0 -5
  115. package/dist/plugins/captions/CaptionsContext.js +0 -16
  116. package/dist/plugins/captions/Description.d.ts +0 -4
  117. package/dist/plugins/captions/Description.js +0 -27
  118. package/dist/plugins/captions/Title.d.ts +0 -4
  119. package/dist/plugins/captions/Title.js +0 -16
  120. package/dist/plugins/captions/props.d.ts +0 -19
  121. package/dist/plugins/captions/props.js +0 -14
  122. package/dist/plugins/captions/utils.d.ts +0 -1
  123. package/dist/plugins/captions/utils.js +0 -2
  124. package/dist/plugins/counter/Counter.d.ts +0 -5
  125. package/dist/plugins/counter/Counter.js +0 -14
  126. package/dist/plugins/download/Download.d.ts +0 -2
  127. package/dist/plugins/download/Download.js +0 -9
  128. package/dist/plugins/download/DownloadButton.d.ts +0 -2
  129. package/dist/plugins/download/DownloadButton.js +0 -19
  130. package/dist/plugins/download/FileSaver.d.ts +0 -1
  131. package/dist/plugins/download/FileSaver.js +0 -60
  132. package/dist/plugins/fullscreen/Fullscreen.d.ts +0 -3
  133. package/dist/plugins/fullscreen/Fullscreen.js +0 -13
  134. package/dist/plugins/fullscreen/FullscreenButton.d.ts +0 -3
  135. package/dist/plugins/fullscreen/FullscreenButton.js +0 -16
  136. package/dist/plugins/fullscreen/FullscreenContext.d.ts +0 -5
  137. package/dist/plugins/fullscreen/FullscreenContext.js +0 -93
  138. package/dist/plugins/fullscreen/props.d.ts +0 -10
  139. package/dist/plugins/fullscreen/props.js +0 -8
  140. package/dist/plugins/inline/Inline.d.ts +0 -3
  141. package/dist/plugins/inline/Inline.js +0 -18
  142. package/dist/plugins/inline/InlineContainer.d.ts +0 -4
  143. package/dist/plugins/inline/InlineContainer.js +0 -5
  144. package/dist/plugins/slideshow/Slideshow.d.ts +0 -3
  145. package/dist/plugins/slideshow/Slideshow.js +0 -13
  146. package/dist/plugins/slideshow/SlideshowButton.d.ts +0 -2
  147. package/dist/plugins/slideshow/SlideshowButton.js +0 -14
  148. package/dist/plugins/slideshow/SlideshowContext.d.ts +0 -5
  149. package/dist/plugins/slideshow/SlideshowContext.js +0 -79
  150. package/dist/plugins/slideshow/props.d.ts +0 -12
  151. package/dist/plugins/slideshow/props.js +0 -9
  152. package/dist/plugins/thumbnails/Thumbnail.d.ts +0 -15
  153. package/dist/plugins/thumbnails/Thumbnail.js +0 -51
  154. package/dist/plugins/thumbnails/Thumbnails.d.ts +0 -3
  155. package/dist/plugins/thumbnails/Thumbnails.js +0 -22
  156. package/dist/plugins/thumbnails/ThumbnailsButton.d.ts +0 -2
  157. package/dist/plugins/thumbnails/ThumbnailsButton.js +0 -16
  158. package/dist/plugins/thumbnails/ThumbnailsContext.d.ts +0 -6
  159. package/dist/plugins/thumbnails/ThumbnailsContext.js +0 -24
  160. package/dist/plugins/thumbnails/ThumbnailsTrack.d.ts +0 -5
  161. package/dist/plugins/thumbnails/ThumbnailsTrack.js +0 -141
  162. package/dist/plugins/thumbnails/props.d.ts +0 -40
  163. package/dist/plugins/thumbnails/props.js +0 -21
  164. package/dist/plugins/thumbnails/utils.d.ts +0 -2
  165. package/dist/plugins/thumbnails/utils.js +0 -4
  166. package/dist/plugins/video/Video.d.ts +0 -3
  167. package/dist/plugins/video/Video.js +0 -21
  168. package/dist/plugins/video/VideoSlide.d.ts +0 -8
  169. package/dist/plugins/video/VideoSlide.js +0 -74
  170. package/dist/plugins/video/props.d.ts +0 -29
  171. package/dist/plugins/video/props.js +0 -13
  172. package/dist/plugins/zoom/ResponsiveImage.d.ts +0 -11
  173. package/dist/plugins/zoom/ResponsiveImage.js +0 -58
  174. package/dist/plugins/zoom/Zoom.d.ts +0 -3
  175. package/dist/plugins/zoom/Zoom.js +0 -18
  176. package/dist/plugins/zoom/ZoomButton.d.ts +0 -8
  177. package/dist/plugins/zoom/ZoomButton.js +0 -27
  178. package/dist/plugins/zoom/ZoomButtonsGroup.d.ts +0 -2
  179. package/dist/plugins/zoom/ZoomButtonsGroup.js +0 -22
  180. package/dist/plugins/zoom/ZoomController.d.ts +0 -12
  181. package/dist/plugins/zoom/ZoomController.js +0 -17
  182. package/dist/plugins/zoom/ZoomToolbarControl.d.ts +0 -2
  183. package/dist/plugins/zoom/ZoomToolbarControl.js +0 -12
  184. package/dist/plugins/zoom/ZoomWrapper.d.ts +0 -5
  185. package/dist/plugins/zoom/ZoomWrapper.js +0 -36
  186. package/dist/plugins/zoom/hooks/index.d.ts +0 -6
  187. package/dist/plugins/zoom/hooks/index.js +0 -6
  188. package/dist/plugins/zoom/hooks/useZoomAnimation.d.ts +0 -2
  189. package/dist/plugins/zoom/hooks/useZoomAnimation.js +0 -39
  190. package/dist/plugins/zoom/hooks/useZoomCallback.d.ts +0 -1
  191. package/dist/plugins/zoom/hooks/useZoomCallback.js +0 -12
  192. package/dist/plugins/zoom/hooks/useZoomImageRect.d.ts +0 -5
  193. package/dist/plugins/zoom/hooks/useZoomImageRect.js +0 -41
  194. package/dist/plugins/zoom/hooks/useZoomProps.d.ts +0 -13
  195. package/dist/plugins/zoom/hooks/useZoomProps.js +0 -6
  196. package/dist/plugins/zoom/hooks/useZoomSensors.d.ts +0 -3
  197. package/dist/plugins/zoom/hooks/useZoomSensors.js +0 -154
  198. package/dist/plugins/zoom/hooks/useZoomState.d.ts +0 -12
  199. package/dist/plugins/zoom/hooks/useZoomState.js +0 -63
  200. package/dist/plugins/zoom/props.d.ts +0 -25
  201. package/dist/plugins/zoom/props.js +0 -15
  202. package/dist/props.d.ts +0 -2
  203. package/dist/props.js +0 -38
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "3.5.3",
3
+ "version": "3.6.0",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
- "main": "dist/index.js",
8
+ "module": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
@@ -13,23 +13,33 @@
13
13
  "default": "./dist/index.js"
14
14
  },
15
15
  "./core": {
16
- "types": "./dist/core/index.d.ts",
17
- "default": "./dist/core/index.js"
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./styles.css": {
20
+ "types": "./dist/styles.css.d.ts",
21
+ "default": "./dist/styles.css"
18
22
  },
19
23
  "./plugins": {
20
24
  "types": "./dist/plugins/index.d.ts",
21
25
  "default": "./dist/plugins/index.js"
22
26
  },
23
- "./plugins/captions.css": "./dist/plugins/captions/captions.css",
24
27
  "./plugins/captions": {
25
28
  "types": "./dist/plugins/captions/index.d.ts",
26
29
  "default": "./dist/plugins/captions/index.js"
27
30
  },
28
- "./plugins/counter.css": "./dist/plugins/counter/counter.css",
31
+ "./plugins/captions.css": {
32
+ "types": "./dist/plugins/captions/captions.css.d.ts",
33
+ "default": "./dist/plugins/captions/captions.css"
34
+ },
29
35
  "./plugins/counter": {
30
36
  "types": "./dist/plugins/counter/index.d.ts",
31
37
  "default": "./dist/plugins/counter/index.js"
32
38
  },
39
+ "./plugins/counter.css": {
40
+ "types": "./dist/plugins/counter/counter.css.d.ts",
41
+ "default": "./dist/plugins/counter/counter.css"
42
+ },
33
43
  "./plugins/download": {
34
44
  "types": "./dist/plugins/download/index.d.ts",
35
45
  "default": "./dist/plugins/download/index.js"
@@ -46,11 +56,14 @@
46
56
  "types": "./dist/plugins/slideshow/index.d.ts",
47
57
  "default": "./dist/plugins/slideshow/index.js"
48
58
  },
49
- "./plugins/thumbnails.css": "./dist/plugins/thumbnails/thumbnails.css",
50
59
  "./plugins/thumbnails": {
51
60
  "types": "./dist/plugins/thumbnails/index.d.ts",
52
61
  "default": "./dist/plugins/thumbnails/index.js"
53
62
  },
63
+ "./plugins/thumbnails.css": {
64
+ "types": "./dist/plugins/thumbnails/thumbnails.css.d.ts",
65
+ "default": "./dist/plugins/thumbnails/thumbnails.css"
66
+ },
54
67
  "./plugins/video": {
55
68
  "types": "./dist/plugins/video/index.d.ts",
56
69
  "default": "./dist/plugins/video/index.js"
@@ -58,8 +71,7 @@
58
71
  "./plugins/zoom": {
59
72
  "types": "./dist/plugins/zoom/index.d.ts",
60
73
  "default": "./dist/plugins/zoom/index.js"
61
- },
62
- "./styles.css": "./dist/styles.css"
74
+ }
63
75
  },
64
76
  "typesVersions": {
65
77
  "*": {
@@ -67,7 +79,10 @@
67
79
  "dist/index.d.ts"
68
80
  ],
69
81
  "core": [
70
- "dist/core/index.d.ts"
82
+ "dist/index.d.ts"
83
+ ],
84
+ "styles.css": [
85
+ "dist/styles.css.d.ts"
71
86
  ],
72
87
  "plugins": [
73
88
  "dist/plugins/index.d.ts"
@@ -75,9 +90,15 @@
75
90
  "plugins/captions": [
76
91
  "dist/plugins/captions/index.d.ts"
77
92
  ],
93
+ "plugins/captions.css": [
94
+ "dist/plugins/captions/captions.css.d.ts"
95
+ ],
78
96
  "plugins/counter": [
79
97
  "dist/plugins/counter/index.d.ts"
80
98
  ],
99
+ "plugins/counter.css": [
100
+ "dist/plugins/counter/counter.css.d.ts"
101
+ ],
81
102
  "plugins/download": [
82
103
  "dist/plugins/download/index.d.ts"
83
104
  ],
@@ -93,6 +114,9 @@
93
114
  "plugins/thumbnails": [
94
115
  "dist/plugins/thumbnails/index.d.ts"
95
116
  ],
117
+ "plugins/thumbnails.css": [
118
+ "dist/plugins/thumbnails/thumbnails.css.d.ts"
119
+ ],
96
120
  "plugins/video": [
97
121
  "dist/plugins/video/index.d.ts"
98
122
  ],
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { LightboxExternalProps } from "./types.js";
3
- /** Lightbox component */
4
- export declare function Lightbox({ carousel, animation, render, toolbar, controller, on, plugins, slides, index, ...restProps }: LightboxExternalProps): JSX.Element | null;
package/dist/Lightbox.js DELETED
@@ -1,46 +0,0 @@
1
- import * as React from "react";
2
- import { LightboxDefaultProps } from "./props.js";
3
- import { CarouselModule, ControllerModule, createNode, EventsProvider, LightboxPropsProvider, LightboxStateProvider, NavigationModule, NoScrollModule, PortalModule, RootModule, TimeoutsProvider, ToolbarModule, withPlugins, } from "./core/index.js";
4
- function renderNode(node, props) {
5
- var _a;
6
- return React.createElement(node.module.component, { key: node.module.name, ...props }, (_a = node.children) === null || _a === void 0 ? void 0 : _a.map((child) => renderNode(child, props)));
7
- }
8
- function mergeAnimation(defaultAnimation, animation = {}) {
9
- const { easing: defaultAnimationEasing, ...restDefaultAnimation } = defaultAnimation;
10
- const { easing, ...restAnimation } = animation;
11
- return {
12
- easing: { ...defaultAnimationEasing, ...easing },
13
- ...restDefaultAnimation,
14
- ...restAnimation,
15
- };
16
- }
17
- export function Lightbox({ carousel, animation, render, toolbar, controller, on, plugins, slides, index, ...restProps }) {
18
- const { animation: defaultAnimation, carousel: defaultCarousel, render: defaultRender, toolbar: defaultToolbar, controller: defaultController, on: defaultOn, slides: defaultSlides, index: defaultIndex, plugins: defaultPlugins, ...restDefaultProps } = LightboxDefaultProps;
19
- const { config, augmentation } = withPlugins([
20
- createNode(PortalModule, [
21
- createNode(NoScrollModule, [
22
- createNode(ControllerModule, [
23
- createNode(CarouselModule),
24
- createNode(ToolbarModule),
25
- createNode(NavigationModule),
26
- ]),
27
- ]),
28
- ]),
29
- ], plugins || defaultPlugins);
30
- const props = augmentation({
31
- animation: mergeAnimation(defaultAnimation, animation),
32
- carousel: { ...defaultCarousel, ...carousel },
33
- render: { ...defaultRender, ...render },
34
- toolbar: { ...defaultToolbar, ...toolbar },
35
- controller: { ...defaultController, ...controller },
36
- on: { ...defaultOn, ...on },
37
- ...restDefaultProps,
38
- ...restProps,
39
- });
40
- if (!props.open)
41
- return null;
42
- return (React.createElement(LightboxPropsProvider, { ...props },
43
- React.createElement(LightboxStateProvider, { slides: slides || defaultSlides, index: index || defaultIndex },
44
- React.createElement(TimeoutsProvider, null,
45
- React.createElement(EventsProvider, null, renderNode(createNode(RootModule, config), props))))));
46
- }
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- export type IconButtonProps = Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "type" | "aria-label"> & {
3
- label: string;
4
- icon: React.ElementType;
5
- renderIcon?: () => React.ReactNode;
6
- };
7
- export declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
@@ -1,8 +0,0 @@
1
- import * as React from "react";
2
- import { clsx, cssClass, label as translateLabel } from "../utils.js";
3
- import { useLightboxProps } from "../contexts/index.js";
4
- import { ELEMENT_BUTTON, ELEMENT_ICON } from "../consts.js";
5
- export const IconButton = React.forwardRef(function IconButton({ label, className, icon: Icon, renderIcon, onClick, style, ...rest }, ref) {
6
- const { styles, labels } = useLightboxProps();
7
- return (React.createElement("button", { ref: ref, type: "button", "aria-label": translateLabel(labels, label), className: clsx(cssClass(ELEMENT_BUTTON), className), onClick: onClick, style: { ...style, ...styles.button }, ...rest }, renderIcon ? renderIcon() : React.createElement(Icon, { className: cssClass(ELEMENT_ICON), style: styles.icon })));
8
- });
@@ -1,29 +0,0 @@
1
- import * as React from "react";
2
- export declare function createIcon(name: string, glyph: React.ReactNode): {
3
- (props: React.SVGProps<SVGSVGElement>): JSX.Element;
4
- displayName: string;
5
- };
6
- export declare function createIconDisabled(name: string, glyph: React.ReactNode): {
7
- (props: React.SVGProps<SVGSVGElement>): JSX.Element;
8
- displayName: string;
9
- };
10
- export declare const CloseIcon: {
11
- (props: React.SVGProps<SVGSVGElement>): JSX.Element;
12
- displayName: string;
13
- };
14
- export declare const PreviousIcon: {
15
- (props: React.SVGProps<SVGSVGElement>): JSX.Element;
16
- displayName: string;
17
- };
18
- export declare const NextIcon: {
19
- (props: React.SVGProps<SVGSVGElement>): JSX.Element;
20
- displayName: string;
21
- };
22
- export declare const LoadingIcon: {
23
- (props: React.SVGProps<SVGSVGElement>): JSX.Element;
24
- displayName: string;
25
- };
26
- export declare const ErrorIcon: {
27
- (props: React.SVGProps<SVGSVGElement>): JSX.Element;
28
- displayName: string;
29
- };
@@ -1,27 +0,0 @@
1
- import * as React from "react";
2
- function svgIcon(name, children) {
3
- const icon = (props) => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", "aria-hidden": "true", focusable: "false", ...props }, children));
4
- icon.displayName = name;
5
- return icon;
6
- }
7
- export function createIcon(name, glyph) {
8
- return svgIcon(name, React.createElement("g", { fill: "currentColor" },
9
- React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" }),
10
- glyph));
11
- }
12
- export function createIconDisabled(name, glyph) {
13
- return svgIcon(name, React.createElement(React.Fragment, null,
14
- React.createElement("defs", null,
15
- React.createElement("mask", { id: "strike" },
16
- React.createElement("path", { d: "M0 0h24v24H0z", fill: "white" }),
17
- React.createElement("path", { d: "M0 0L24 24", stroke: "black", strokeWidth: 4 }))),
18
- React.createElement("path", { d: "M0.70707 2.121320L21.878680 23.292883", stroke: "currentColor", strokeWidth: 2 }),
19
- React.createElement("g", { fill: "currentColor", mask: "url(#strike)" },
20
- React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" }),
21
- glyph)));
22
- }
23
- export const CloseIcon = createIcon("Close", React.createElement("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }));
24
- export const PreviousIcon = createIcon("Previous", React.createElement("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }));
25
- export const NextIcon = createIcon("Next", React.createElement("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }));
26
- export const LoadingIcon = createIcon("Loading", React.createElement(React.Fragment, null, Array.from({ length: 8 }).map((_, index, array) => (React.createElement("line", { key: index, x1: "12", y1: "6.5", x2: "12", y2: "1.8", strokeLinecap: "round", strokeWidth: "2.6", stroke: "currentColor", strokeOpacity: (1 / array.length) * (index + 1), transform: `rotate(${(360 / array.length) * index}, 12, 12)` })))));
27
- export const ErrorIcon = createIcon("Error", React.createElement("path", { d: "M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z" }));
@@ -1,13 +0,0 @@
1
- import * as React from "react";
2
- import { ContainerRect, ImageFit, Render, SlideImage } from "../../types.js";
3
- export type ImageSlideProps = {
4
- slide: SlideImage;
5
- offset?: number;
6
- render?: Render;
7
- rect?: ContainerRect;
8
- imageFit?: ImageFit;
9
- onClick?: () => void;
10
- onLoad?: (image: HTMLImageElement) => void;
11
- style?: React.CSSProperties;
12
- };
13
- export declare function ImageSlide({ slide: image, offset, render, rect, imageFit, onClick, onLoad, style }: ImageSlideProps): JSX.Element;
@@ -1,68 +0,0 @@
1
- import * as React from "react";
2
- import { clsx, cssClass, hasWindow, isImageFitCover, makeComposePrefix } from "../utils.js";
3
- import { useEventCallback } from "../hooks/index.js";
4
- import { useEvents, useTimeouts } from "../contexts/index.js";
5
- import { ErrorIcon, LoadingIcon } from "./Icons.js";
6
- import { activeSlideStatus, ELEMENT_ICON, SLIDE_STATUS_COMPLETE, SLIDE_STATUS_ERROR, SLIDE_STATUS_LOADING, SLIDE_STATUS_PLACEHOLDER, } from "../consts.js";
7
- const slidePrefix = makeComposePrefix("slide");
8
- const slideImagePrefix = makeComposePrefix("slide_image");
9
- export function ImageSlide({ slide: image, offset, render, rect, imageFit, onClick, onLoad, style }) {
10
- var _a, _b, _c, _d, _e, _f, _g;
11
- const [status, setStatus] = React.useState(SLIDE_STATUS_LOADING);
12
- const { publish } = useEvents();
13
- const { setTimeout } = useTimeouts();
14
- const imageRef = React.useRef(null);
15
- React.useEffect(() => {
16
- if (offset === 0) {
17
- publish(activeSlideStatus(status));
18
- }
19
- }, [offset, status, publish]);
20
- const handleLoading = useEventCallback((img) => {
21
- ("decode" in img ? img.decode() : Promise.resolve())
22
- .catch(() => { })
23
- .then(() => {
24
- if (!img.parentNode) {
25
- return;
26
- }
27
- setStatus(SLIDE_STATUS_COMPLETE);
28
- setTimeout(() => {
29
- onLoad === null || onLoad === void 0 ? void 0 : onLoad(img);
30
- }, 0);
31
- });
32
- });
33
- const setImageRef = React.useCallback((img) => {
34
- imageRef.current = img;
35
- if (img === null || img === void 0 ? void 0 : img.complete) {
36
- handleLoading(img);
37
- }
38
- }, [handleLoading]);
39
- const handleOnLoad = React.useCallback((event) => {
40
- handleLoading(event.currentTarget);
41
- }, [handleLoading]);
42
- const onError = React.useCallback(() => {
43
- setStatus(SLIDE_STATUS_ERROR);
44
- }, []);
45
- const cover = isImageFitCover(image, imageFit);
46
- const nonInfinite = (value, fallback) => (Number.isFinite(value) ? value : fallback);
47
- const maxWidth = nonInfinite(Math.max(...((_b = (_a = image.srcSet) === null || _a === void 0 ? void 0 : _a.map((x) => x.width)) !== null && _b !== void 0 ? _b : []).concat(image.width ? [image.width] : [])), ((_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalWidth) || 0);
48
- const maxHeight = nonInfinite(Math.max(...((_e = (_d = image.srcSet) === null || _d === void 0 ? void 0 : _d.map((x) => x.height)) !== null && _e !== void 0 ? _e : []).concat(image.height ? [image.height] : [])), ((_f = imageRef.current) === null || _f === void 0 ? void 0 : _f.naturalHeight) || 0);
49
- const defaultStyle = maxWidth && maxHeight
50
- ? {
51
- maxWidth: `min(${maxWidth}px, 100%)`,
52
- maxHeight: `min(${maxHeight}px, 100%)`,
53
- }
54
- : {
55
- maxWidth: "100%",
56
- maxHeight: "100%",
57
- };
58
- const srcSet = (_g = image.srcSet) === null || _g === void 0 ? void 0 : _g.sort((a, b) => a.width - b.width).map((item) => `${item.src} ${item.width}w`).join(", ");
59
- const estimateActualWidth = () => rect && !cover && image.width && image.height ? (rect.height / image.height) * image.width : Number.MAX_VALUE;
60
- const sizes = srcSet && rect && hasWindow() ? `${Math.round(Math.min(estimateActualWidth(), rect.width))}px` : undefined;
61
- return (React.createElement(React.Fragment, null,
62
- React.createElement("img", { ref: setImageRef, onLoad: handleOnLoad, onError: onError, onClick: onClick, className: clsx(cssClass(slideImagePrefix()), cover && cssClass(slideImagePrefix("cover")), status !== SLIDE_STATUS_COMPLETE && cssClass(slideImagePrefix("loading"))), draggable: false, alt: image.alt, style: { ...defaultStyle, ...style }, sizes: sizes, srcSet: srcSet, src: image.src }),
63
- status !== SLIDE_STATUS_COMPLETE && (React.createElement("div", { className: cssClass(slidePrefix(SLIDE_STATUS_PLACEHOLDER)) },
64
- status === SLIDE_STATUS_LOADING &&
65
- ((render === null || render === void 0 ? void 0 : render.iconLoading) ? (render.iconLoading()) : (React.createElement(LoadingIcon, { className: clsx(cssClass(ELEMENT_ICON), cssClass(slidePrefix(SLIDE_STATUS_LOADING))) }))),
66
- status === SLIDE_STATUS_ERROR &&
67
- ((render === null || render === void 0 ? void 0 : render.iconError) ? (render.iconError()) : (React.createElement(ErrorIcon, { className: clsx(cssClass(ELEMENT_ICON), cssClass(slidePrefix(SLIDE_STATUS_ERROR))) })))))));
68
- }
@@ -1,3 +0,0 @@
1
- export * from "./IconButton.js";
2
- export * from "./Icons.js";
3
- export * from "./ImageSlide.js";
@@ -1,3 +0,0 @@
1
- export * from "./IconButton.js";
2
- export * from "./Icons.js";
3
- export * from "./ImageSlide.js";
@@ -1,7 +0,0 @@
1
- import { Augmentation, Component, Module, Node, Plugin } from "../types.js";
2
- export declare function createModule(name: string, component: Component): Module;
3
- export declare function createNode(module: Module, children?: Node[]): Node;
4
- export declare function withPlugins(root: Node[], plugins?: Plugin[], augmentations?: Augmentation[]): {
5
- config: Node[];
6
- augmentation: Augmentation;
7
- };
@@ -1,93 +0,0 @@
1
- import { MODULE_CONTROLLER } from "./consts.js";
2
- export function createModule(name, component) {
3
- return { name, component };
4
- }
5
- export function createNode(module, children) {
6
- return { module, children };
7
- }
8
- function traverseNode(node, target, apply) {
9
- if (node.module.name === target) {
10
- return apply(node);
11
- }
12
- if (node.children) {
13
- return [
14
- createNode(node.module, node.children.flatMap((n) => { var _a; return (_a = traverseNode(n, target, apply)) !== null && _a !== void 0 ? _a : []; })),
15
- ];
16
- }
17
- return [node];
18
- }
19
- function traverse(nodes, target, apply) {
20
- return nodes.flatMap((node) => { var _a; return (_a = traverseNode(node, target, apply)) !== null && _a !== void 0 ? _a : []; });
21
- }
22
- export function withPlugins(root, plugins = [], augmentations = []) {
23
- let config = root;
24
- const contains = (target) => {
25
- const nodes = [...config];
26
- while (nodes.length > 0) {
27
- const node = nodes.pop();
28
- if ((node === null || node === void 0 ? void 0 : node.module.name) === target)
29
- return true;
30
- if (node === null || node === void 0 ? void 0 : node.children)
31
- nodes.push(...node.children);
32
- }
33
- return false;
34
- };
35
- const addParent = (target, module) => {
36
- if (target === "") {
37
- config = [createNode(module, config)];
38
- return;
39
- }
40
- config = traverse(config, target, (node) => [createNode(module, [node])]);
41
- };
42
- const append = (target, module) => {
43
- config = traverse(config, target, (node) => [createNode(node.module, [createNode(module, node.children)])]);
44
- };
45
- const addChild = (target, module, precede) => {
46
- config = traverse(config, target, (node) => {
47
- var _a;
48
- return [
49
- createNode(node.module, [
50
- ...(precede ? [createNode(module)] : []),
51
- ...((_a = node.children) !== null && _a !== void 0 ? _a : []),
52
- ...(!precede ? [createNode(module)] : []),
53
- ]),
54
- ];
55
- });
56
- };
57
- const addSibling = (target, module, precede) => {
58
- config = traverse(config, target, (node) => [
59
- ...(precede ? [createNode(module)] : []),
60
- node,
61
- ...(!precede ? [createNode(module)] : []),
62
- ]);
63
- };
64
- const addModule = (module) => {
65
- append(MODULE_CONTROLLER, module);
66
- };
67
- const replace = (target, module) => {
68
- config = traverse(config, target, (node) => [createNode(module, node.children)]);
69
- };
70
- const remove = (target) => {
71
- config = traverse(config, target, (node) => node.children);
72
- };
73
- const augment = (augmentation) => {
74
- augmentations.push(augmentation);
75
- };
76
- plugins.forEach((plugin) => {
77
- plugin({
78
- contains,
79
- addParent,
80
- append,
81
- addChild,
82
- addSibling,
83
- addModule,
84
- replace,
85
- remove,
86
- augment,
87
- });
88
- });
89
- return {
90
- config,
91
- augmentation: (props) => augmentations.reduce((acc, augmentation) => augmentation(acc), props),
92
- };
93
- }
@@ -1,50 +0,0 @@
1
- export declare const MODULE_CAROUSEL = "carousel";
2
- export declare const MODULE_CONTROLLER = "controller";
3
- export declare const MODULE_NAVIGATION = "navigation";
4
- export declare const MODULE_NO_SCROLL = "no-scroll";
5
- export declare const MODULE_PORTAL = "portal";
6
- export declare const MODULE_ROOT = "root";
7
- export declare const MODULE_TOOLBAR = "toolbar";
8
- export declare const PLUGIN_CAPTIONS = "captions";
9
- export declare const PLUGIN_COUNTER = "counter";
10
- export declare const PLUGIN_DOWNLOAD = "download";
11
- export declare const PLUGIN_FULLSCREEN = "fullscreen";
12
- export declare const PLUGIN_INLINE = "inline";
13
- export declare const PLUGIN_SLIDESHOW = "slideshow";
14
- export declare const PLUGIN_THUMBNAILS = "thumbnails";
15
- export declare const PLUGIN_ZOOM = "zoom";
16
- export declare const SLIDE_STATUS_LOADING = "loading";
17
- export declare const SLIDE_STATUS_PLAYING = "playing";
18
- export declare const SLIDE_STATUS_ERROR = "error";
19
- export declare const SLIDE_STATUS_COMPLETE = "complete";
20
- export declare const SLIDE_STATUS_PLACEHOLDER = "placeholder";
21
- export type SlideStatus = typeof SLIDE_STATUS_LOADING | typeof SLIDE_STATUS_PLAYING | typeof SLIDE_STATUS_ERROR | typeof SLIDE_STATUS_COMPLETE;
22
- export declare const activeSlideStatus: (status: SlideStatus) => `active-slide-${SlideStatus}`;
23
- export declare const ACTIVE_SLIDE_LOADING: "active-slide-loading";
24
- export declare const ACTIVE_SLIDE_PLAYING: "active-slide-playing";
25
- export declare const ACTIVE_SLIDE_ERROR: "active-slide-error";
26
- export declare const ACTIVE_SLIDE_COMPLETE: "active-slide-complete";
27
- export declare const CLASS_FULLSIZE = "fullsize";
28
- export declare const CLASS_FLEX_CENTER = "flex_center";
29
- export declare const CLASS_NO_SCROLL = "no_scroll";
30
- export declare const CLASS_NO_SCROLL_PADDING = "no_scroll_padding";
31
- export declare const ACTION_PREV = "prev";
32
- export declare const ACTION_NEXT = "next";
33
- export declare const ACTION_SWIPE = "swipe";
34
- export declare const ACTION_CLOSE = "close";
35
- export declare const EVENT_ON_POINTER_DOWN = "onPointerDown";
36
- export declare const EVENT_ON_POINTER_MOVE = "onPointerMove";
37
- export declare const EVENT_ON_POINTER_UP = "onPointerUp";
38
- export declare const EVENT_ON_POINTER_LEAVE = "onPointerLeave";
39
- export declare const EVENT_ON_POINTER_CANCEL = "onPointerCancel";
40
- export declare const EVENT_ON_KEY_DOWN = "onKeyDown";
41
- export declare const EVENT_ON_KEY_UP = "onKeyUp";
42
- export declare const EVENT_ON_WHEEL = "onWheel";
43
- export declare const VK_ESCAPE = "Escape";
44
- export declare const VK_ARROW_LEFT = "ArrowLeft";
45
- export declare const VK_ARROW_RIGHT = "ArrowRight";
46
- export declare const ELEMENT_BUTTON = "button";
47
- export declare const ELEMENT_ICON = "icon";
48
- export declare const IMAGE_FIT_CONTAIN = "contain";
49
- export declare const IMAGE_FIT_COVER = "cover";
50
- export declare const UNKNOWN_ACTION_TYPE = "Unknown action type";
@@ -1,49 +0,0 @@
1
- export const MODULE_CAROUSEL = "carousel";
2
- export const MODULE_CONTROLLER = "controller";
3
- export const MODULE_NAVIGATION = "navigation";
4
- export const MODULE_NO_SCROLL = "no-scroll";
5
- export const MODULE_PORTAL = "portal";
6
- export const MODULE_ROOT = "root";
7
- export const MODULE_TOOLBAR = "toolbar";
8
- export const PLUGIN_CAPTIONS = "captions";
9
- export const PLUGIN_COUNTER = "counter";
10
- export const PLUGIN_DOWNLOAD = "download";
11
- export const PLUGIN_FULLSCREEN = "fullscreen";
12
- export const PLUGIN_INLINE = "inline";
13
- export const PLUGIN_SLIDESHOW = "slideshow";
14
- export const PLUGIN_THUMBNAILS = "thumbnails";
15
- export const PLUGIN_ZOOM = "zoom";
16
- export const SLIDE_STATUS_LOADING = "loading";
17
- export const SLIDE_STATUS_PLAYING = "playing";
18
- export const SLIDE_STATUS_ERROR = "error";
19
- export const SLIDE_STATUS_COMPLETE = "complete";
20
- export const SLIDE_STATUS_PLACEHOLDER = "placeholder";
21
- export const activeSlideStatus = (status) => `active-slide-${status}`;
22
- export const ACTIVE_SLIDE_LOADING = activeSlideStatus(SLIDE_STATUS_LOADING);
23
- export const ACTIVE_SLIDE_PLAYING = activeSlideStatus(SLIDE_STATUS_PLAYING);
24
- export const ACTIVE_SLIDE_ERROR = activeSlideStatus(SLIDE_STATUS_ERROR);
25
- export const ACTIVE_SLIDE_COMPLETE = activeSlideStatus(SLIDE_STATUS_COMPLETE);
26
- export const CLASS_FULLSIZE = "fullsize";
27
- export const CLASS_FLEX_CENTER = "flex_center";
28
- export const CLASS_NO_SCROLL = "no_scroll";
29
- export const CLASS_NO_SCROLL_PADDING = "no_scroll_padding";
30
- export const ACTION_PREV = "prev";
31
- export const ACTION_NEXT = "next";
32
- export const ACTION_SWIPE = "swipe";
33
- export const ACTION_CLOSE = "close";
34
- export const EVENT_ON_POINTER_DOWN = "onPointerDown";
35
- export const EVENT_ON_POINTER_MOVE = "onPointerMove";
36
- export const EVENT_ON_POINTER_UP = "onPointerUp";
37
- export const EVENT_ON_POINTER_LEAVE = "onPointerLeave";
38
- export const EVENT_ON_POINTER_CANCEL = "onPointerCancel";
39
- export const EVENT_ON_KEY_DOWN = "onKeyDown";
40
- export const EVENT_ON_KEY_UP = "onKeyUp";
41
- export const EVENT_ON_WHEEL = "onWheel";
42
- export const VK_ESCAPE = "Escape";
43
- export const VK_ARROW_LEFT = "ArrowLeft";
44
- export const VK_ARROW_RIGHT = "ArrowRight";
45
- export const ELEMENT_BUTTON = "button";
46
- export const ELEMENT_ICON = "icon";
47
- export const IMAGE_FIT_CONTAIN = "contain";
48
- export const IMAGE_FIT_COVER = "cover";
49
- export const UNKNOWN_ACTION_TYPE = "Unknown action type";
@@ -1,17 +0,0 @@
1
- import * as React from "react";
2
- export interface EventTypes {
3
- }
4
- export type Topic = keyof EventTypes;
5
- export type Event<T extends Topic> = EventTypes[T];
6
- export type Callback<T extends Topic> = (...args: Event<T> extends void ? [] : [event: Event<T>]) => void;
7
- export type Subscribe = <T extends Topic>(topic: T, callback: Callback<T>) => () => void;
8
- export type Unsubscribe = <T extends Topic>(topic: T, callback: Callback<T>) => void;
9
- export type Publish = <T extends Topic>(...args: Event<T> extends void ? [topic: T] : [topic: T, event: Event<T>]) => void;
10
- export type EventsContextType = {
11
- subscribe: Subscribe;
12
- unsubscribe: Unsubscribe;
13
- publish: Publish;
14
- };
15
- export declare const EventsContext: React.Context<EventsContextType | null>;
16
- export declare const useEvents: () => EventsContextType;
17
- export declare function EventsProvider({ children }: React.PropsWithChildren): JSX.Element;
@@ -1,29 +0,0 @@
1
- import * as React from "react";
2
- import { makeUseContext } from "../utils.js";
3
- export const EventsContext = React.createContext(null);
4
- export const useEvents = makeUseContext("useEvents", "EventsContext", EventsContext);
5
- export function EventsProvider({ children }) {
6
- const [subscriptions] = React.useState({});
7
- React.useEffect(() => () => {
8
- Object.keys(subscriptions).forEach((topic) => delete subscriptions[topic]);
9
- }, [subscriptions]);
10
- const context = React.useMemo(() => {
11
- const unsubscribe = (topic, callback) => {
12
- var _a;
13
- (_a = subscriptions[topic]) === null || _a === void 0 ? void 0 : _a.splice(0, subscriptions[topic].length, ...subscriptions[topic].filter((cb) => cb !== callback));
14
- };
15
- const subscribe = (topic, callback) => {
16
- if (!subscriptions[topic]) {
17
- subscriptions[topic] = [];
18
- }
19
- subscriptions[topic].push(callback);
20
- return () => unsubscribe(topic, callback);
21
- };
22
- const publish = (...[topic, event]) => {
23
- var _a;
24
- (_a = subscriptions[topic]) === null || _a === void 0 ? void 0 : _a.forEach((callback) => callback(event));
25
- };
26
- return { publish, subscribe, unsubscribe };
27
- }, [subscriptions]);
28
- return React.createElement(EventsContext.Provider, { value: context }, children);
29
- }
@@ -1,6 +0,0 @@
1
- import * as React from "react";
2
- import { ComponentProps } from "../../types.js";
3
- export type LightboxPropsContextType = Omit<ComponentProps, "children">;
4
- export declare const LightboxPropsContext: React.Context<LightboxPropsContextType | null>;
5
- export declare const useLightboxProps: () => LightboxPropsContextType;
6
- export declare function LightboxPropsProvider({ children, ...props }: ComponentProps): JSX.Element;
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { makeUseContext } from "../utils.js";
3
- export const LightboxPropsContext = React.createContext(null);
4
- export const useLightboxProps = makeUseContext("useLightboxProps", "LightboxPropsContext", LightboxPropsContext);
5
- export function LightboxPropsProvider({ children, ...props }) {
6
- return React.createElement(LightboxPropsContext.Provider, { value: props }, children);
7
- }
@@ -1,27 +0,0 @@
1
- import * as React from "react";
2
- import { LightboxProps, LightboxState, Slide } from "../../types.js";
3
- export type LightboxStateSwipeAction = {
4
- type: "swipe";
5
- increment: number;
6
- duration?: number;
7
- easing?: string;
8
- };
9
- export type LightboxStateUpdateAction = {
10
- type: "update";
11
- slides: Slide[];
12
- index: number;
13
- };
14
- export type LightboxStateAction = LightboxStateSwipeAction | LightboxStateUpdateAction;
15
- export type LightboxStateContextType = LightboxState & {
16
- /** @deprecated - use `useLightboxState` props directly */
17
- state: LightboxState;
18
- /** @deprecated - use `useLightboxDispatch` instead */
19
- dispatch: React.Dispatch<LightboxStateAction>;
20
- };
21
- export declare const LightboxStateContext: React.Context<LightboxStateContextType | null>;
22
- export declare const useLightboxState: () => NonNullable<LightboxStateContextType>;
23
- export type LightboxDispatchContextType = React.Dispatch<LightboxStateAction>;
24
- export declare const LightboxDispatchContext: React.Context<LightboxDispatchContextType | null>;
25
- export declare const useLightboxDispatch: () => LightboxDispatchContextType;
26
- export type LightboxStateProviderProps = React.PropsWithChildren<Pick<LightboxProps, "slides" | "index">>;
27
- export declare function LightboxStateProvider({ slides, index, children }: LightboxStateProviderProps): JSX.Element;