yet-another-react-lightbox 2.2.2 → 2.2.3

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.
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- export declare type IconButtonProps = Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "type" | "aria-label"> & {
2
+ export type IconButtonProps = Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "type" | "aria-label"> & {
3
3
  label: string;
4
4
  icon: React.ElementType;
5
5
  renderIcon?: () => React.ReactNode;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { ImageFit, Render, SlideImage } from "../../types.js";
3
3
  import { ContainerRect } from "../hooks/index.js";
4
- export declare type ImageSlideProps = {
4
+ export type ImageSlideProps = {
5
5
  slide: SlideImage;
6
6
  offset?: number;
7
7
  render?: Render;
@@ -16,7 +16,7 @@ export declare const SLIDE_STATUS_PLAYING = "playing";
16
16
  export declare const SLIDE_STATUS_ERROR = "error";
17
17
  export declare const SLIDE_STATUS_COMPLETE = "complete";
18
18
  export declare const SLIDE_STATUS_PLACEHOLDER = "placeholder";
19
- export declare type SlideStatus = typeof SLIDE_STATUS_LOADING | typeof SLIDE_STATUS_PLAYING | typeof SLIDE_STATUS_ERROR | typeof SLIDE_STATUS_COMPLETE;
19
+ export type SlideStatus = typeof SLIDE_STATUS_LOADING | typeof SLIDE_STATUS_PLAYING | typeof SLIDE_STATUS_ERROR | typeof SLIDE_STATUS_COMPLETE;
20
20
  export declare const activeSlideStatus: (status: SlideStatus) => string;
21
21
  export declare const ACTIVE_SLIDE_LOADING: string;
22
22
  export declare const ACTIVE_SLIDE_PLAYING: string;
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
- export declare type Callback = (event?: unknown) => void;
3
- export declare type Subscribe = (topic: string, callback: Callback) => () => void;
4
- export declare type Unsubscribe = (topic: string, callback: Callback) => void;
5
- export declare type Publish = (topic: string, event?: unknown) => void;
6
- export declare type EventsContextType = {
2
+ export type Callback = (event?: unknown) => void;
3
+ export type Subscribe = (topic: string, callback: Callback) => () => void;
4
+ export type Unsubscribe = (topic: string, callback: Callback) => void;
5
+ export type Publish = (topic: string, event?: unknown) => void;
6
+ export type EventsContextType = {
7
7
  subscribe: Subscribe;
8
8
  unsubscribe: Unsubscribe;
9
9
  publish: Publish;
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
- export declare type LightboxState = {
2
+ export type LightboxState = {
3
3
  currentIndex: number;
4
4
  globalIndex: number;
5
5
  animationDuration: number;
6
6
  };
7
- declare type LightboxStateAction = {
7
+ type LightboxStateAction = {
8
8
  increment?: number;
9
9
  animationDuration: number;
10
10
  };
@@ -12,7 +12,7 @@ export declare const useLightboxState: () => {
12
12
  state: LightboxState;
13
13
  dispatch: React.Dispatch<LightboxStateAction>;
14
14
  };
15
- declare type LightboxStateProviderProps = React.PropsWithChildren<{
15
+ type LightboxStateProviderProps = React.PropsWithChildren<{
16
16
  slidesCount: number;
17
17
  initialIndex: number;
18
18
  }>;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- export declare type TimeoutsContextType = {
2
+ export type TimeoutsContextType = {
3
3
  setTimeout: (fn: () => void, delay?: number) => number;
4
4
  clearTimeout: (id?: number) => void;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- export declare type ContainerRect = {
2
+ export type ContainerRect = {
3
3
  width: number;
4
4
  height: number;
5
5
  };
@@ -1,13 +1,13 @@
1
1
  import * as React from "react";
2
- export declare type PointerEventType = "onPointerDown" | "onPointerMove" | "onPointerUp" | "onPointerLeave" | "onPointerCancel";
3
- export declare type KeyboardEventType = "onKeyDown" | "onKeyUp";
4
- export declare type WheelEventType = "onWheel";
5
- export declare type SupportedEventType = PointerEventType | KeyboardEventType | WheelEventType;
6
- export declare type ReactEventType<T, K> = K extends KeyboardEventType ? React.KeyboardEvent<T> : K extends WheelEventType ? React.WheelEvent<T> : K extends PointerEventType ? React.PointerEvent<T> : never;
7
- export declare type EventCallback<T, P extends React.PointerEvent<T> | React.KeyboardEvent<T> | React.WheelEvent<T>> = (event: P) => void;
8
- export declare type SubscribeSensors<T> = <ET extends SupportedEventType>(type: ET, callback: EventCallback<T, ReactEventType<T, ET>>) => () => void;
9
- export declare type RegisterSensors<T> = Required<Pick<React.HTMLAttributes<T>, PointerEventType>> & Required<Pick<React.HTMLAttributes<T>, KeyboardEventType>> & Required<Pick<React.HTMLAttributes<T>, WheelEventType>>;
10
- export declare type UseSensors<T> = {
2
+ export type PointerEventType = "onPointerDown" | "onPointerMove" | "onPointerUp" | "onPointerLeave" | "onPointerCancel";
3
+ export type KeyboardEventType = "onKeyDown" | "onKeyUp";
4
+ export type WheelEventType = "onWheel";
5
+ export type SupportedEventType = PointerEventType | KeyboardEventType | WheelEventType;
6
+ export type ReactEventType<T, K> = K extends KeyboardEventType ? React.KeyboardEvent<T> : K extends WheelEventType ? React.WheelEvent<T> : K extends PointerEventType ? React.PointerEvent<T> : never;
7
+ export type EventCallback<T, P extends React.PointerEvent<T> | React.KeyboardEvent<T> | React.WheelEvent<T>> = (event: P) => void;
8
+ export type SubscribeSensors<T> = <ET extends SupportedEventType>(type: ET, callback: EventCallback<T, ReactEventType<T, ET>>) => () => void;
9
+ export type RegisterSensors<T> = Required<Pick<React.HTMLAttributes<T>, PointerEventType>> & Required<Pick<React.HTMLAttributes<T>, KeyboardEventType>> & Required<Pick<React.HTMLAttributes<T>, WheelEventType>>;
10
+ export type UseSensors<T> = {
11
11
  registerSensors: RegisterSensors<T>;
12
12
  subscribeSensors: SubscribeSensors<T>;
13
13
  };
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { Component, ComponentProps } from "../../types.js";
3
3
  import { ContainerRect, SubscribeSensors } from "../hooks/index.js";
4
- export declare type ControllerContextType = {
4
+ export type ControllerContextType = {
5
5
  getLightboxProps: () => ComponentProps;
6
6
  subscribeSensors: SubscribeSensors<HTMLDivElement>;
7
7
  transferFocus: () => void;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { Component, Labels } from "../../types.js";
3
3
  import { Publish } from "../contexts/index.js";
4
- export declare type NavigationButtonProps = {
4
+ export type NavigationButtonProps = {
5
5
  publish: Publish;
6
6
  labels?: Labels;
7
7
  label: string;
@@ -16,6 +16,7 @@ export const usePointerSwipe = (subscribeSensors, isSwipeValid, containerWidth,
16
16
  }, []);
17
17
  const addPointer = React.useCallback((event) => {
18
18
  clearPointer(event);
19
+ event.persist();
19
20
  pointers.current.push(event);
20
21
  }, [clearPointer]);
21
22
  const onPointerDown = useEventCallback((event) => {
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- declare type CaptionsContextType = {
2
+ type CaptionsContextType = {
3
3
  toolbarWidth?: number;
4
4
  };
5
5
  export declare const useCaptions: () => CaptionsContextType;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
2
  import { LightboxProps, Slide } from "../../types.js";
3
- declare type DescriptionProps = Pick<LightboxProps, "styles"> & Required<Pick<Slide, "description">> & Required<LightboxProps["captions"]>;
3
+ type DescriptionProps = Pick<LightboxProps, "styles"> & Required<Pick<Slide, "description">> & Required<LightboxProps["captions"]>;
4
4
  export declare const Description: React.FC<DescriptionProps>;
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
2
  import { LightboxProps, Slide } from "../../types.js";
3
- declare type TitleProps = Pick<LightboxProps, "styles"> & Pick<Slide, "title">;
3
+ type TitleProps = Pick<LightboxProps, "styles"> & Pick<Slide, "title">;
4
4
  export declare const Title: React.FC<TitleProps>;
5
5
  export {};
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Captions } from "./Captions.js";
3
- declare type TextAlignment = "start" | "end" | "center";
3
+ type TextAlignment = "start" | "end" | "center";
4
4
  declare module "../../types" {
5
5
  interface GenericSlide {
6
6
  /** slide title */
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { LightboxProps } from "../../types.js";
3
3
  /** Fullscreen button props */
4
- export declare type FullscreenButtonProps = Pick<LightboxProps, "labels" | "render"> & {
4
+ export type FullscreenButtonProps = Pick<LightboxProps, "labels" | "render"> & {
5
5
  auto: boolean;
6
6
  };
7
7
  /** Fullscreen button */
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- declare type FullscreenContextType = React.RefObject<HTMLDivElement>;
2
+ type FullscreenContextType = React.RefObject<HTMLDivElement>;
3
3
  export declare const useFullscreen: () => FullscreenContextType;
4
4
  export declare const FullscreenContextProvider: React.FC<React.PropsWithChildren>;
5
5
  export {};
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { ImageFit, LightboxProps, Slide } from "../../types.js";
3
3
  import { ContainerRect } from "../../core/index.js";
4
- declare type FadeSettings = {
4
+ type FadeSettings = {
5
5
  duration: number;
6
6
  delay: number;
7
7
  };
8
- declare type ThumbnailProps = {
8
+ type ThumbnailProps = {
9
9
  rect: ContainerRect;
10
10
  slide: Slide | null;
11
11
  onClick: () => void;
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { ContainerRect } from "../../core/index.js";
3
3
  import { DeepNonNullable, LightboxProps } from "../../types.js";
4
- declare type ThumbnailsInternal = DeepNonNullable<LightboxProps["thumbnails"]>;
5
- declare type ThumbnailsTrackProps = Pick<LightboxProps, "slides" | "carousel" | "animation" | "render" | "styles"> & {
4
+ type ThumbnailsInternal = DeepNonNullable<LightboxProps["thumbnails"]>;
5
+ type ThumbnailsTrackProps = Pick<LightboxProps, "slides" | "carousel" | "animation" | "render" | "styles"> & {
6
6
  container: React.RefObject<HTMLDivElement>;
7
7
  thumbnails: ThumbnailsInternal;
8
8
  startingIndex: number;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { ContainerRect } from "../../core/index.js";
3
3
  import { Thumbnails } from "./Thumbnails.js";
4
- declare type Position = "top" | "bottom" | "start" | "end";
4
+ type Position = "top" | "bottom" | "start" | "end";
5
5
  declare module "../../types" {
6
6
  interface LightboxProps {
7
7
  /** Thumbnails plugin settings */
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { SlideVideo } from "./index.js";
3
- declare type VideoSlideProps = {
3
+ type VideoSlideProps = {
4
4
  slide: SlideVideo;
5
5
  offset: number;
6
6
  };
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { ImageSlideProps } from "../../core/index.js";
3
3
  import { ImageSource, SlideImage } from "../../types.js";
4
- declare type ResponsiveImageSlide = Omit<SlideImage, "srcSet"> & {
4
+ type ResponsiveImageSlide = Omit<SlideImage, "srcSet"> & {
5
5
  srcSet: [ImageSource, ...ImageSource[]];
6
6
  };
7
7
  export declare const isResponsiveImageSlide: (slide: SlideImage) => slide is ResponsiveImageSlide;
8
- declare type ResponsiveImageProps = Omit<ImageSlideProps, "slide" | "rect"> & Required<Pick<ImageSlideProps, "rect">> & {
8
+ type ResponsiveImageProps = Omit<ImageSlideProps, "slide" | "rect"> & Required<Pick<ImageSlideProps, "rect">> & {
9
9
  slide: ResponsiveImageSlide;
10
10
  };
11
11
  export declare const ResponsiveImage: React.FC<ResponsiveImageProps>;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
2
  import { LightboxProps } from "../../types.js";
3
- declare type ZoomButtonsGroupProps = Pick<LightboxProps, "labels" | "render">;
3
+ type ZoomButtonsGroupProps = Pick<LightboxProps, "labels" | "render">;
4
4
  export declare const ZoomButtonsGroup: React.FC<ZoomButtonsGroupProps>;
5
5
  export {};
@@ -210,6 +210,7 @@ export const ZoomContainer = ({ slide, offset, rect, render, carousel, animation
210
210
  }, []);
211
211
  const replacePointer = React.useCallback((event) => {
212
212
  clearPointer(event);
213
+ event.persist();
213
214
  activePointers.current.push(event);
214
215
  }, [clearPointer]);
215
216
  const onPointerDown = useEventCallback((event) => {
@@ -1,5 +1,5 @@
1
1
  import { Component } from "../../types.js";
2
- declare type ZoomContextType = {
2
+ type ZoomContextType = {
3
3
  isMinZoom: boolean;
4
4
  isMaxZoom: boolean;
5
5
  isZoomSupported: boolean;
@@ -4,7 +4,7 @@ import { Zoom } from "./Zoom.js";
4
4
  export declare const ACTION_ZOOM_IN = "zoom-in";
5
5
  export declare const ACTION_ZOOM_OUT = "zoom-out";
6
6
  /** Custom zoom button render function */
7
- declare type RenderZoomButton = ({ ref, labels, disabled, onClick, onFocus, onBlur, }: Pick<LightboxProps, "labels"> & {
7
+ type RenderZoomButton = ({ ref, labels, disabled, onClick, onFocus, onBlur, }: Pick<LightboxProps, "labels"> & {
8
8
  ref: React.ForwardedRef<HTMLButtonElement>;
9
9
  disabled: boolean;
10
10
  onClick: () => void;
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { ContainerRect } from "./core/hooks/useContainerRect.js";
3
3
  /** Image fit setting */
4
- export declare type ImageFit = "contain" | "cover";
4
+ export type ImageFit = "contain" | "cover";
5
5
  /** Image source */
6
6
  export interface ImageSource {
7
7
  /** image URL */
@@ -37,7 +37,7 @@ export interface SlideTypes {
37
37
  SlideImage: SlideImage;
38
38
  }
39
39
  /** Slide */
40
- export declare type Slide = SlideTypes[keyof SlideTypes];
40
+ export type Slide = SlideTypes[keyof SlideTypes];
41
41
  /** Supported customization slots */
42
42
  export interface SlotType {
43
43
  /** lightbox root customization slot */
@@ -50,13 +50,13 @@ export interface SlotType {
50
50
  icon: "icon";
51
51
  }
52
52
  /** Customization slots */
53
- export declare type Slot = SlotType[keyof SlotType];
53
+ export type Slot = SlotType[keyof SlotType];
54
54
  /** Customization slot CSS properties */
55
55
  interface SlotCSSProperties extends React.CSSProperties {
56
56
  [key: `--yarl__${string}`]: string | number;
57
57
  }
58
58
  /** Customization slots styles */
59
- export declare type SlotStyles = {
59
+ export type SlotStyles = {
60
60
  [key in Slot]?: SlotCSSProperties;
61
61
  };
62
62
  /** Carousel settings */
@@ -173,7 +173,7 @@ export interface LightboxProps {
173
173
  className: string;
174
174
  }
175
175
  /** Custom UI labels */
176
- export declare type Labels = {
176
+ export type Labels = {
177
177
  [key: string]: string;
178
178
  };
179
179
  /** Toolbar settings */
@@ -182,27 +182,27 @@ export interface ToolbarSettings {
182
182
  buttons: ("close" | React.ReactNode)[];
183
183
  }
184
184
  /** Lightbox component properties */
185
- export declare type ComponentProps = Omit<LightboxProps, "plugins">;
185
+ export type ComponentProps = Omit<LightboxProps, "plugins">;
186
186
  /** Lightbox component */
187
- export declare type Component = React.ComponentType<React.PropsWithChildren<ComponentProps>>;
187
+ export type Component = React.ComponentType<React.PropsWithChildren<ComponentProps>>;
188
188
  /** Lightbox module */
189
- export declare type Module = {
189
+ export type Module = {
190
190
  /** module name */
191
191
  name: string;
192
192
  /** module component */
193
193
  component: Component;
194
194
  };
195
195
  /** Lightbox component tree node */
196
- export declare type Node = {
196
+ export type Node = {
197
197
  /** module */
198
198
  module: Module;
199
199
  /** module child nodes */
200
200
  children?: Node[];
201
201
  };
202
202
  /** Lightbox props augmentation */
203
- export declare type Augmentation = (props: LightboxProps) => LightboxProps;
203
+ export type Augmentation = (props: LightboxProps) => LightboxProps;
204
204
  /** Plugin methods */
205
- export declare type PluginMethods = {
205
+ export type PluginMethods = {
206
206
  /** test if a target module is present */
207
207
  contains: (target: string) => boolean;
208
208
  /** add module as a parent */
@@ -221,15 +221,15 @@ export declare type PluginMethods = {
221
221
  augment: (augmentation: Augmentation) => void;
222
222
  };
223
223
  /** Lightbox plugin */
224
- export declare type Plugin = ({ addParent, addChild, addSibling, replace, remove, append, augment }: PluginMethods) => void;
224
+ export type Plugin = ({ addParent, addChild, addSibling, replace, remove, append, augment }: PluginMethods) => void;
225
225
  /** Deep partial utility type */
226
- export declare type DeepPartial<T, K extends keyof T> = Omit<T, K> & {
226
+ export type DeepPartial<T, K extends keyof T> = Omit<T, K> & {
227
227
  [P in keyof Pick<T, K>]?: Partial<Pick<T, K>[P]>;
228
228
  };
229
229
  /** Deep non-nullable utility type */
230
- export declare type DeepNonNullable<T> = T extends {} ? {
230
+ export type DeepNonNullable<T> = T extends {} ? {
231
231
  [K in keyof T]-?: NonNullable<T[K]>;
232
232
  } : never;
233
233
  /** Lightbox external props */
234
- export declare type LightboxExternalProps = DeepPartial<Partial<LightboxProps>, "carousel" | "animation" | "controller" | "toolbar">;
234
+ export type LightboxExternalProps = DeepPartial<Partial<LightboxProps>, "carousel" | "animation" | "controller" | "toolbar">;
235
235
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",
@@ -90,42 +90,42 @@
90
90
  "react-dom": ">=16.8.0"
91
91
  },
92
92
  "devDependencies": {
93
- "@commitlint/cli": "^17.2.0",
94
- "@commitlint/config-conventional": "^17.2.0",
95
- "@semantic-release/changelog": "^6.0.1",
96
- "@semantic-release/github": "^8.0.6",
93
+ "@commitlint/cli": "^17.3.0",
94
+ "@commitlint/config-conventional": "^17.3.0",
95
+ "@semantic-release/changelog": "^6.0.2",
96
+ "@semantic-release/github": "^8.0.7",
97
97
  "@testing-library/jest-dom": "^5.16.5",
98
98
  "@testing-library/react": "^13.4.0",
99
99
  "@testing-library/user-event": "^14.4.3",
100
- "@types/jest": "^29.2.2",
101
- "@types/react": "^18.0.25",
102
- "@types/react-dom": "^18.0.8",
103
- "@typescript-eslint/eslint-plugin": "^5.42.0",
104
- "@typescript-eslint/parser": "^5.42.0",
100
+ "@types/jest": "^29.2.4",
101
+ "@types/react": "^18.0.26",
102
+ "@types/react-dom": "^18.0.9",
103
+ "@typescript-eslint/eslint-plugin": "^5.45.1",
104
+ "@typescript-eslint/parser": "^5.45.1",
105
105
  "autoprefixer": "^10.4.13",
106
- "eslint": "^8.27.0",
106
+ "eslint": "^8.29.0",
107
107
  "eslint-config-airbnb": "^19.0.4",
108
108
  "eslint-config-airbnb-typescript": "^17.0.0",
109
109
  "eslint-config-prettier": "^8.5.0",
110
110
  "eslint-plugin-import": "^2.26.0",
111
111
  "eslint-plugin-jsx-a11y": "^6.6.1",
112
112
  "eslint-plugin-prettier": "^4.2.1",
113
- "eslint-plugin-react": "^7.31.10",
113
+ "eslint-plugin-react": "^7.31.11",
114
114
  "eslint-plugin-react-hooks": "^4.6.0",
115
- "husky": "^8.0.1",
116
- "jest": "^29.2.2",
117
- "jest-environment-jsdom": "^29.2.2",
118
- "lint-staged": "^13.0.3",
115
+ "husky": "^8.0.2",
116
+ "jest": "^29.3.1",
117
+ "jest-environment-jsdom": "^29.3.1",
118
+ "lint-staged": "^13.1.0",
119
119
  "npm-run-all": "^4.1.5",
120
- "postcss": "^8.4.18",
121
- "postcss-cli": "^10.0.0",
122
- "prettier": "^2.7.1",
120
+ "postcss": "^8.4.19",
121
+ "postcss-cli": "^10.1.0",
122
+ "prettier": "^2.8.1",
123
123
  "react": "^18.2.0",
124
124
  "react-dom": "^18.2.0",
125
125
  "rimraf": "^3.0.2",
126
- "sass": "^1.56.0",
126
+ "sass": "^1.56.1",
127
127
  "ts-jest": "^29.0.3",
128
- "typescript": "^4.8.4"
128
+ "typescript": "^4.9.3"
129
129
  },
130
130
  "keywords": [
131
131
  "react",