yet-another-react-lightbox 3.29.2 → 3.30.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/dist/index.d.ts +14 -4
- package/dist/index.js +21 -10
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ declare function useEventCallback<Args extends unknown[], Return>(fn: (...args:
|
|
|
87
87
|
declare function setRef<T>(ref: React.MutableRefObject<T | null> | ((instance: T | null) => void) | null | undefined, value: T | null): void;
|
|
88
88
|
declare function useForkRef<InstanceA, InstanceB>(refA: React.Ref<InstanceA> | null | undefined, refB: React.Ref<InstanceB> | null | undefined): React.Ref<InstanceA & InstanceB> | null;
|
|
89
89
|
|
|
90
|
-
declare const useLayoutEffect: typeof React.
|
|
90
|
+
declare const useLayoutEffect: typeof React.useLayoutEffect;
|
|
91
91
|
|
|
92
92
|
declare function useLoseFocus(focus: () => void, disabled?: boolean): {
|
|
93
93
|
onFocus: () => void;
|
|
@@ -173,6 +173,16 @@ declare const useLightboxDispatch: () => LightboxDispatchContextType;
|
|
|
173
173
|
type LightboxStateProviderProps = React.PropsWithChildren<Pick<LightboxProps, "slides" | "index">>;
|
|
174
174
|
declare function LightboxStateProvider({ slides, index, children }: LightboxStateProviderProps): React.JSX.Element;
|
|
175
175
|
|
|
176
|
+
type RTLContextType = {
|
|
177
|
+
isRTL: boolean;
|
|
178
|
+
};
|
|
179
|
+
declare const RTLContext: React.Context<RTLContextType | null>;
|
|
180
|
+
declare const useRTLContext: () => RTLContextType;
|
|
181
|
+
type RTLContextProviderProps = React.PropsWithChildren & {
|
|
182
|
+
isRTL: boolean;
|
|
183
|
+
};
|
|
184
|
+
declare function RTLContextProvider({ isRTL, children }: RTLContextProviderProps): React.JSX.Element;
|
|
185
|
+
|
|
176
186
|
type TimeoutsContextType = {
|
|
177
187
|
setTimeout: (fn: () => void, delay?: number) => number;
|
|
178
188
|
clearTimeout: (id?: number) => void;
|
|
@@ -291,7 +301,7 @@ declare function useNavigationState(): {
|
|
|
291
301
|
declare function NoScroll({ noScroll: { disabled }, children }: ComponentProps): React.JSX.Element;
|
|
292
302
|
declare const NoScrollModule: Module;
|
|
293
303
|
|
|
294
|
-
declare function Portal({
|
|
304
|
+
declare function Portal({ portal: { root, container: { className: containerClassName, style: containerStyle, ...containerRest } }, animation, styles, className, on, close, labels, children, }: ComponentProps): React.ReactPortal | null;
|
|
295
305
|
declare const PortalModule: Module;
|
|
296
306
|
|
|
297
307
|
declare function Root({ children }: ComponentProps): React.JSX.Element;
|
|
@@ -300,5 +310,5 @@ declare const RootModule: Module;
|
|
|
300
310
|
declare function Toolbar({ toolbar: { buttons }, render: { buttonClose, iconClose }, styles }: ComponentProps): React.JSX.Element;
|
|
301
311
|
declare const ToolbarModule: Module;
|
|
302
312
|
|
|
303
|
-
export { A11yContext, A11yContextProvider, Augmentation, Callback, Carousel, CarouselModule, CarouselSettings, CloseIcon, Component, ComponentProps, ContainerRect, Controller, ControllerContext, ControllerModule, ControllerRef, ControllerSettings, DocumentContext, DocumentContextProvider, ErrorIcon, EventTypes, EventsContext, EventsProvider, IconButton, ImageSlide, Label, Labels, LengthOrPercentage, Lightbox, LightboxDefaultProps, LightboxDispatchContext, LightboxExternalProps, LightboxProps, LightboxPropsContext, LightboxPropsProvider, LightboxRoot, LightboxState, LightboxStateContext, LightboxStateProvider, LightboxStateSwipeAction, LightboxStateUpdateAction, LoadingIcon, Module, Navigation, NavigationButton, NavigationModule, NextIcon, NoScroll, NoScrollModule, Node$1 as Node, Plugin, Portal, PortalModule, PreviousIcon, Render, RenderFunction, Root, RootModule, Slide, SlideImage, SwipeState, TimeoutsContext, TimeoutsProvider, Toolbar, ToolbarModule, ToolbarSettings, addToolbarButton, calculatePreload, cleanup, clsx, composePrefix, computeSlideRect, createIcon, createIconDisabled, createModule, createNode, cssClass, cssVar, Lightbox as default, devicePixelRatio, getSlide, getSlideIfPresent, getSlideIndex, getSlideKey, hasSlides, hasWindow, isImageFitCover, isImageSlide, label, makeComposePrefix, makeInertWhen, makeUseContext, parseInt, parseLengthPercentage, reflow, round, setRef, stopNavigationEventsPropagation, translateLabel, translateSlideCounter, useA11yContext, useAnimation, useContainerRect, useController, useDelay, useDocumentContext, useEventCallback, useEvents, useForkRef, useKeyboardNavigation, useLayoutEffect, useLightboxDispatch, useLightboxProps, useLightboxState, useLoseFocus, useMotionPreference, useNavigationState, usePointerSwipe, usePreventWheelDefaults, useRTL, useSensors, useThrottle, useTimeouts, useWheelSwipe, withPlugins };
|
|
304
|
-
export type { A11yContextType, ComputeAnimation, ControllerContextType, DocumentContextProviderProps, DocumentContextType, Event, EventCallback, EventsContextType, IconButtonProps, ImageSlideProps, KeyboardEventType, LightboxDispatchContextType, LightboxPropsContextType, LightboxStateAction, LightboxStateContextType, LightboxStateProviderProps, NavigationButtonProps, PointerEventType, Publish, ReactEventType, RegisterSensors, SensorCallback, Subscribe, SubscribeSensors, SupportedEventType, TimeoutsContextType, Topic, Unsubscribe, UseSensors, WheelEventType };
|
|
313
|
+
export { A11yContext, A11yContextProvider, Augmentation, Callback, Carousel, CarouselModule, CarouselSettings, CloseIcon, Component, ComponentProps, ContainerRect, Controller, ControllerContext, ControllerModule, ControllerRef, ControllerSettings, DocumentContext, DocumentContextProvider, ErrorIcon, EventTypes, EventsContext, EventsProvider, IconButton, ImageSlide, Label, Labels, LengthOrPercentage, Lightbox, LightboxDefaultProps, LightboxDispatchContext, LightboxExternalProps, LightboxProps, LightboxPropsContext, LightboxPropsProvider, LightboxRoot, LightboxState, LightboxStateContext, LightboxStateProvider, LightboxStateSwipeAction, LightboxStateUpdateAction, LoadingIcon, Module, Navigation, NavigationButton, NavigationModule, NextIcon, NoScroll, NoScrollModule, Node$1 as Node, Plugin, Portal, PortalModule, PreviousIcon, RTLContext, RTLContextProvider, Render, RenderFunction, Root, RootModule, Slide, SlideImage, SwipeState, TimeoutsContext, TimeoutsProvider, Toolbar, ToolbarModule, ToolbarSettings, addToolbarButton, calculatePreload, cleanup, clsx, composePrefix, computeSlideRect, createIcon, createIconDisabled, createModule, createNode, cssClass, cssVar, Lightbox as default, devicePixelRatio, getSlide, getSlideIfPresent, getSlideIndex, getSlideKey, hasSlides, hasWindow, isImageFitCover, isImageSlide, label, makeComposePrefix, makeInertWhen, makeUseContext, parseInt, parseLengthPercentage, reflow, round, setRef, stopNavigationEventsPropagation, translateLabel, translateSlideCounter, useA11yContext, useAnimation, useContainerRect, useController, useDelay, useDocumentContext, useEventCallback, useEvents, useForkRef, useKeyboardNavigation, useLayoutEffect, useLightboxDispatch, useLightboxProps, useLightboxState, useLoseFocus, useMotionPreference, useNavigationState, usePointerSwipe, usePreventWheelDefaults, useRTL, useRTLContext, useSensors, useThrottle, useTimeouts, useWheelSwipe, withPlugins };
|
|
314
|
+
export type { A11yContextType, ComputeAnimation, ControllerContextType, DocumentContextProviderProps, DocumentContextType, Event, EventCallback, EventsContextType, IconButtonProps, ImageSlideProps, KeyboardEventType, LightboxDispatchContextType, LightboxPropsContextType, LightboxStateAction, LightboxStateContextType, LightboxStateProviderProps, NavigationButtonProps, PointerEventType, Publish, RTLContextProviderProps, RTLContextType, ReactEventType, RegisterSensors, SensorCallback, Subscribe, SubscribeSensors, SupportedEventType, TimeoutsContextType, Topic, Unsubscribe, UseSensors, WheelEventType };
|
package/dist/index.js
CHANGED
|
@@ -394,6 +394,13 @@ function LightboxStateProvider({ slides, index, children }) {
|
|
|
394
394
|
React.createElement(LightboxStateContext.Provider, { value: context }, children)));
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
const RTLContext = React.createContext(null);
|
|
398
|
+
const useRTLContext = makeUseContext("useRTLContext", "RTLContext", RTLContext);
|
|
399
|
+
function RTLContextProvider({ isRTL, children }) {
|
|
400
|
+
const context = React.useMemo(() => ({ isRTL }), [isRTL]);
|
|
401
|
+
return React.createElement(RTLContext.Provider, { value: context }, children);
|
|
402
|
+
}
|
|
403
|
+
|
|
397
404
|
const TimeoutsContext = React.createContext(null);
|
|
398
405
|
const useTimeouts = makeUseContext("useTimeouts", "TimeoutsContext", TimeoutsContext);
|
|
399
406
|
function TimeoutsProvider({ children }) {
|
|
@@ -612,11 +619,7 @@ function useLoseFocus(focus, disabled = false) {
|
|
|
612
619
|
}
|
|
613
620
|
|
|
614
621
|
function useRTL() {
|
|
615
|
-
|
|
616
|
-
useLayoutEffect(() => {
|
|
617
|
-
setIsRTL(window.getComputedStyle(window.document.documentElement).direction === "rtl");
|
|
618
|
-
}, []);
|
|
619
|
-
return isRTL;
|
|
622
|
+
return useRTLContext().isRTL;
|
|
620
623
|
}
|
|
621
624
|
|
|
622
625
|
function useSensors() {
|
|
@@ -734,9 +737,16 @@ function ImageSlide({ slide: image, offset, render, rect, imageFit, imageProps,
|
|
|
734
737
|
|
|
735
738
|
const LightboxRoot = React.forwardRef(function LightboxRoot({ className, children, onFocus, onBlur, ...rest }, ref) {
|
|
736
739
|
const nodeRef = React.useRef(null);
|
|
740
|
+
const [isRTL, setIsRTL] = React.useState(false);
|
|
737
741
|
const { trackFocusWithin } = useA11yContext();
|
|
742
|
+
const detectRTL = React.useCallback((node) => {
|
|
743
|
+
if (node) {
|
|
744
|
+
setIsRTL(window.getComputedStyle(node).direction === "rtl");
|
|
745
|
+
}
|
|
746
|
+
}, []);
|
|
738
747
|
return (React.createElement(DocumentContextProvider, { nodeRef: nodeRef },
|
|
739
|
-
React.createElement(
|
|
748
|
+
React.createElement(RTLContextProvider, { isRTL: isRTL },
|
|
749
|
+
React.createElement("div", { ref: useForkRef(useForkRef(ref, nodeRef), detectRTL), className: clsx(cssClass("root"), className), ...trackFocusWithin(onFocus, onBlur), ...rest }, children))));
|
|
740
750
|
});
|
|
741
751
|
|
|
742
752
|
var SwipeState;
|
|
@@ -1451,7 +1461,7 @@ function setAttribute(element, attribute, value) {
|
|
|
1451
1461
|
}
|
|
1452
1462
|
};
|
|
1453
1463
|
}
|
|
1454
|
-
function Portal({
|
|
1464
|
+
function Portal({ portal: { root, container: { className: containerClassName, style: containerStyle, ...containerRest } = {} }, animation, styles, className, on, close, labels, children, }) {
|
|
1455
1465
|
const [mounted, setMounted] = React.useState(false);
|
|
1456
1466
|
const [visible, setVisible] = React.useState(false);
|
|
1457
1467
|
const cleanup = React.useRef([]);
|
|
@@ -1514,7 +1524,7 @@ function Portal({ children, animation, styles, className, on, portal, close, lab
|
|
|
1514
1524
|
}
|
|
1515
1525
|
}, [handleEnter, handleCleanup]);
|
|
1516
1526
|
return mounted
|
|
1517
|
-
? createPortal(React.createElement(LightboxRoot, { ref: handleRef, className: clsx(className, cssClass(cssPrefix$1()), cssClass(CLASS_NO_SCROLL_PADDING), visible && cssClass(cssPrefix$1("open"))), "aria-modal": true, role: "dialog", "aria-label": translateLabel(labels, "Lightbox"), style: {
|
|
1527
|
+
? createPortal(React.createElement(LightboxRoot, { ref: handleRef, className: clsx(className, containerClassName, cssClass(cssPrefix$1()), cssClass(CLASS_NO_SCROLL_PADDING), visible && cssClass(cssPrefix$1("open"))), "aria-modal": true, role: "dialog", "aria-label": translateLabel(labels, "Lightbox"), style: {
|
|
1518
1528
|
...(animation.fade !== LightboxDefaultProps.animation.fade
|
|
1519
1529
|
? { [cssVar("fade_animation_duration")]: `${animationDuration}ms` }
|
|
1520
1530
|
: null),
|
|
@@ -1522,11 +1532,12 @@ function Portal({ children, animation, styles, className, on, portal, close, lab
|
|
|
1522
1532
|
? { [cssVar("fade_animation_timing_function")]: animation.easing.fade }
|
|
1523
1533
|
: null),
|
|
1524
1534
|
...styles.root,
|
|
1535
|
+
...containerStyle,
|
|
1525
1536
|
}, onFocus: (event) => {
|
|
1526
1537
|
if (!restoreFocus.current) {
|
|
1527
1538
|
restoreFocus.current = event.relatedTarget;
|
|
1528
1539
|
}
|
|
1529
|
-
} }, children),
|
|
1540
|
+
}, ...containerRest }, children), root || document.body)
|
|
1530
1541
|
: null;
|
|
1531
1542
|
}
|
|
1532
1543
|
const PortalModule = createModule(MODULE_PORTAL, Portal);
|
|
@@ -1600,4 +1611,4 @@ function Lightbox({ carousel, animation, render, toolbar, controller, noScroll,
|
|
|
1600
1611
|
React.createElement(A11yContextProvider, null, renderNode(createNode(RootModule, config), props)))))));
|
|
1601
1612
|
}
|
|
1602
1613
|
|
|
1603
|
-
export { A11yContext, A11yContextProvider, ACTION_CLOSE, ACTION_NEXT, ACTION_PREV, ACTION_SWIPE, CLASS_FLEX_CENTER, CLASS_NO_SCROLL, CLASS_NO_SCROLL_PADDING, CLASS_SLIDE, CLASS_SLIDE_WRAPPER, Carousel, CarouselModule, CloseIcon, Controller, ControllerContext, ControllerModule, DocumentContext, DocumentContextProvider, ELEMENT_BUTTON, ELEMENT_ICON, EVENT_ON_KEY_DOWN, EVENT_ON_KEY_UP, EVENT_ON_POINTER_CANCEL, EVENT_ON_POINTER_DOWN, EVENT_ON_POINTER_LEAVE, EVENT_ON_POINTER_MOVE, EVENT_ON_POINTER_UP, EVENT_ON_WHEEL, ErrorIcon, EventsContext, EventsProvider, IMAGE_FIT_CONTAIN, IMAGE_FIT_COVER, IconButton, ImageSlide, Lightbox, LightboxDefaultProps, LightboxDispatchContext, LightboxPropsContext, LightboxPropsProvider, LightboxRoot, LightboxStateContext, LightboxStateProvider, LoadingIcon, MODULE_CAROUSEL, MODULE_CONTROLLER, MODULE_NAVIGATION, MODULE_NO_SCROLL, MODULE_PORTAL, MODULE_ROOT, MODULE_TOOLBAR, Navigation, NavigationButton, NavigationModule, NextIcon, NoScroll, NoScrollModule, Portal, PortalModule, PreviousIcon, Root, RootModule, SLIDE_STATUS_COMPLETE, SLIDE_STATUS_ERROR, SLIDE_STATUS_LOADING, SLIDE_STATUS_PLACEHOLDER, SwipeState, TimeoutsContext, TimeoutsProvider, Toolbar, ToolbarModule, UNKNOWN_ACTION_TYPE, VK_ARROW_LEFT, VK_ARROW_RIGHT, VK_ESCAPE, activeSlideStatus, addToolbarButton, calculatePreload, cleanup, clsx, composePrefix, computeSlideRect, createIcon, createIconDisabled, createModule, createNode, cssClass, cssVar, Lightbox as default, devicePixelRatio, getSlide, getSlideIfPresent, getSlideIndex, getSlideKey, hasSlides, hasWindow, isImageFitCover, isImageSlide, label, makeComposePrefix, makeInertWhen, makeUseContext, parseInt, parseLengthPercentage, reflow, round, setRef, stopNavigationEventsPropagation, translateLabel, translateSlideCounter, useA11yContext, useAnimation, useContainerRect, useController, useDelay, useDocumentContext, useEventCallback, useEvents, useForkRef, useKeyboardNavigation, useLayoutEffect, useLightboxDispatch, useLightboxProps, useLightboxState, useLoseFocus, useMotionPreference, useNavigationState, usePointerEvents, usePointerSwipe, usePreventWheelDefaults, useRTL, useSensors, useThrottle, useTimeouts, useWheelSwipe, withPlugins };
|
|
1614
|
+
export { A11yContext, A11yContextProvider, ACTION_CLOSE, ACTION_NEXT, ACTION_PREV, ACTION_SWIPE, CLASS_FLEX_CENTER, CLASS_NO_SCROLL, CLASS_NO_SCROLL_PADDING, CLASS_SLIDE, CLASS_SLIDE_WRAPPER, Carousel, CarouselModule, CloseIcon, Controller, ControllerContext, ControllerModule, DocumentContext, DocumentContextProvider, ELEMENT_BUTTON, ELEMENT_ICON, EVENT_ON_KEY_DOWN, EVENT_ON_KEY_UP, EVENT_ON_POINTER_CANCEL, EVENT_ON_POINTER_DOWN, EVENT_ON_POINTER_LEAVE, EVENT_ON_POINTER_MOVE, EVENT_ON_POINTER_UP, EVENT_ON_WHEEL, ErrorIcon, EventsContext, EventsProvider, IMAGE_FIT_CONTAIN, IMAGE_FIT_COVER, IconButton, ImageSlide, Lightbox, LightboxDefaultProps, LightboxDispatchContext, LightboxPropsContext, LightboxPropsProvider, LightboxRoot, LightboxStateContext, LightboxStateProvider, LoadingIcon, MODULE_CAROUSEL, MODULE_CONTROLLER, MODULE_NAVIGATION, MODULE_NO_SCROLL, MODULE_PORTAL, MODULE_ROOT, MODULE_TOOLBAR, Navigation, NavigationButton, NavigationModule, NextIcon, NoScroll, NoScrollModule, Portal, PortalModule, PreviousIcon, RTLContext, RTLContextProvider, Root, RootModule, SLIDE_STATUS_COMPLETE, SLIDE_STATUS_ERROR, SLIDE_STATUS_LOADING, SLIDE_STATUS_PLACEHOLDER, SwipeState, TimeoutsContext, TimeoutsProvider, Toolbar, ToolbarModule, UNKNOWN_ACTION_TYPE, VK_ARROW_LEFT, VK_ARROW_RIGHT, VK_ESCAPE, activeSlideStatus, addToolbarButton, calculatePreload, cleanup, clsx, composePrefix, computeSlideRect, createIcon, createIconDisabled, createModule, createNode, cssClass, cssVar, Lightbox as default, devicePixelRatio, getSlide, getSlideIfPresent, getSlideIndex, getSlideKey, hasSlides, hasWindow, isImageFitCover, isImageSlide, label, makeComposePrefix, makeInertWhen, makeUseContext, parseInt, parseLengthPercentage, reflow, round, setRef, stopNavigationEventsPropagation, translateLabel, translateSlideCounter, useA11yContext, useAnimation, useContainerRect, useController, useDelay, useDocumentContext, useEventCallback, useEvents, useForkRef, useKeyboardNavigation, useLayoutEffect, useLightboxDispatch, useLightboxProps, useLightboxState, useLoseFocus, useMotionPreference, useNavigationState, usePointerEvents, usePointerSwipe, usePreventWheelDefaults, useRTL, useRTLContext, useSensors, useThrottle, useTimeouts, useWheelSwipe, withPlugins };
|
package/dist/types.d.ts
CHANGED
|
@@ -264,6 +264,8 @@ interface ControllerRef {
|
|
|
264
264
|
interface PortalSettings {
|
|
265
265
|
/** portal mount point */
|
|
266
266
|
root?: DocumentFragment | Element | null;
|
|
267
|
+
/** HTML attributes for the portal container */
|
|
268
|
+
container?: React.HTMLAttributes<HTMLDivElement>;
|
|
267
269
|
}
|
|
268
270
|
/** NoScroll module settings */
|
|
269
271
|
interface NoScrollSettings {
|