yet-another-react-lightbox-lite 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -192,7 +192,7 @@ A callback to update current slide index state. This prop is required.
192
192
 
193
193
  ### labels
194
194
 
195
- Type: `{ [key: string]: string }`
195
+ Type: `keyof Labels`
196
196
 
197
197
  Custom UI labels / translations.
198
198
 
@@ -569,22 +569,22 @@ defines the fixed position without visual styles.
569
569
  ## Text Selection
570
570
 
571
571
  The lightbox is rendered with the `user-select: none` CSS style. If you'd like
572
- to make some of your custom elements user-selectable, use the `yarll_selectable`
573
- CSS class. This class sets the `user-select: text` style and turns off
574
- click-and-drag slide navigation, likely interfering with text selection UX.
572
+ to make some of your custom elements user-selectable, use the
573
+ `yarll__selectable` CSS class. This class sets the `user-select: text` style and
574
+ turns off click-and-drag slide navigation, likely interfering with text
575
+ selection UX.
575
576
 
576
- ## Hooks (experimental)
577
+ ## Hooks
577
578
 
578
- The library exports the following experimental hooks that you may find helpful
579
- in customizing lightbox functionality. All experimental hooks are currently
580
- exported with the `unstable_` prefix.
579
+ The library exports the following hooks that you may find helpful in customizing
580
+ lightbox functionality.
581
581
 
582
582
  ### useZoom
583
583
 
584
584
  You can use the `useZoom` hook to build your custom zoom controls.
585
585
 
586
586
  ```tsx
587
- import { unstable_useZoom as useZoom } from "yet-another-react-lightbox-lite";
587
+ import { useZoom } from "yet-another-react-lightbox-lite";
588
588
  ```
589
589
 
590
590
  The hook provides an object with the following props:
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Dispatch, SetStateAction, Key, ReactNode, ComponentProps, CSSProperties, MouseEvent } from 'react';
1
+ import { Key, Dispatch, SetStateAction, ReactNode, ComponentProps, CSSProperties, MouseEvent } from 'react';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
 
4
4
  /** Lightbox props */
@@ -198,4 +198,5 @@ type ZoomContextType = {
198
198
  /** `useZoom` hook */
199
199
  declare const useZoom: () => ZoomContextType;
200
200
 
201
- export { type Callback, type CarouselSettings, type ControllerSettings, type GenericSlide, type ImageSource, type Label, type Labels, type LightboxProps, type Rect, type Render, type RenderFunction, type RenderSlideProps, type Slide, type SlideImage, type SlideTypeKey, type SlideTypes, type Slot, type SlotStyles, type SlotType, type ToolbarSettings, type ZoomSettings, Lightbox as default, useZoom as unstable_useZoom };
201
+ export { Lightbox as default, useZoom };
202
+ export type { Callback, CarouselSettings, ControllerSettings, GenericSlide, ImageSource, Label, Labels, LightboxProps, Rect, Render, RenderFunction, RenderSlideProps, Slide, SlideImage, SlideTypeKey, SlideTypes, Slot, SlotStyles, SlotType, ToolbarSettings, ZoomSettings };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { useContext, createContext, useState, useRef, useLayoutEffect, useCallback, useMemo, useEffect, isValidElement, cloneElement } from 'react';
2
+ import { useContext, createContext, useState, useRef, useLayoutEffect, useCallback, useMemo, useEffect, cloneElement, isValidElement } from 'react';
3
3
  import { flushSync, createPortal } from 'react-dom';
4
4
 
5
5
  const cssPrefix = "yarll__";
@@ -66,7 +66,7 @@ function getImageDimensions(slide, rect) {
66
66
  }
67
67
  function ImageSlide({ slide, rect, zoom }) {
68
68
  const [scale, setScale] = useState(1);
69
- const persistScaleTimeout = useRef();
69
+ const persistScaleTimeout = useRef(undefined);
70
70
  const { carousel: { imageProps } = {}, styles } = useLightboxContext();
71
71
  if (zoom > scale) {
72
72
  clearTimeout(persistScaleTimeout.current);
@@ -93,7 +93,7 @@ function Zoom({ children }) {
93
93
  const [offsetX, setOffsetX] = useState(0);
94
94
  const [offsetY, setOffsetY] = useState(0);
95
95
  const [rect, setRect] = useState();
96
- const observer = useRef();
96
+ const observer = useRef(undefined);
97
97
  const carouselRef = useRef(null);
98
98
  const { index, slides, zoom: { supports, disabled } = {} } = useLightboxContext();
99
99
  const [prevIndex, setPrevIndex] = useState(index);
@@ -104,7 +104,9 @@ function Zoom({ children }) {
104
104
  setPrevIndex(index);
105
105
  }
106
106
  const slide = slides[index];
107
- const maxZoom = (isImageSlide(slide) && !disabled) || (supports || []).includes(slide.type) ? 8 : 1;
107
+ const maxZoom = (isImageSlide(slide) && !disabled) || (supports || []).includes(slide.type)
108
+ ? 8
109
+ : 1;
108
110
  useLayoutEffect(() => {
109
111
  const carouselHalfWidth = (rect?.width || 0) / 2;
110
112
  const carouselHalfHeight = (rect?.height || 0) / 2;
@@ -260,7 +262,7 @@ function useSensors() {
260
262
  const wheelCooldown = useRef(null);
261
263
  const wheelCooldownMomentum = useRef(null);
262
264
  const activePointers = useRef([]);
263
- const pinchZoomDistance = useRef();
265
+ const pinchZoomDistance = useRef(undefined);
264
266
  const { zoom, maxZoom, changeZoom, changeOffsets } = useZoom();
265
267
  const { carouselRef } = useZoomInternal();
266
268
  const { prev, next, close } = useController();
@@ -295,11 +297,11 @@ function useSensors() {
295
297
  if (key === "ArrowUp")
296
298
  move(0, KEYBOARD_MOVE_DISTANCE);
297
299
  if (key === "ArrowDown")
298
- move(0, -KEYBOARD_MOVE_DISTANCE);
300
+ move(0, -50);
299
301
  if (key === "ArrowLeft")
300
302
  move(KEYBOARD_MOVE_DISTANCE, 0);
301
303
  if (key === "ArrowRight")
302
- move(-KEYBOARD_MOVE_DISTANCE, 0);
304
+ move(-50, 0);
303
305
  return;
304
306
  }
305
307
  if (key === "ArrowLeft")
@@ -469,7 +471,7 @@ function Portal({ children }) {
469
471
  const cleanup = useRef([]);
470
472
  const [mounted, setMounted] = useState(false);
471
473
  const [visible, setVisible] = useState(false);
472
- const onTransitionEnd = useRef();
474
+ const onTransitionEnd = useRef(undefined);
473
475
  const restoreFocus = useRef(null);
474
476
  const sensors = useSensors();
475
477
  const { addExitHook } = useController();
@@ -548,4 +550,4 @@ function Lightbox({ slides, index, setIndex, ...rest }) {
548
550
  return (jsx(LightboxContextProvider, { slides, index, ...rest, children: jsx(Controller, { setIndex, children: jsx(Zoom, { children: jsxs(Portal, { children: [jsx(Toolbar, {}), jsx(Carousel, {}), jsx(Navigation, {})] }) }) }) }));
549
551
  }
550
552
 
551
- export { Lightbox as default, useZoom as unstable_useZoom };
553
+ export { Lightbox as default, useZoom };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox-lite",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Lightweight React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",
@@ -39,10 +39,10 @@
39
39
  "provenance": true
40
40
  },
41
41
  "peerDependencies": {
42
- "@types/react": ">=18",
43
- "@types/react-dom": ">=18",
44
- "react": ">=18",
45
- "react-dom": ">=18"
42
+ "@types/react": "^18 || ^19",
43
+ "@types/react-dom": "^18 || ^19",
44
+ "react": "^18 || ^19",
45
+ "react-dom": "^18 || ^19"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "@types/react": {