yet-another-react-lightbox 3.29.2 → 3.30.1
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 +13 -3
- package/dist/index.js +25 -10
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -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,20 @@ 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 = useEventCallback(() => {
|
|
743
|
+
if (nodeRef.current) {
|
|
744
|
+
const rtl = window.getComputedStyle(nodeRef.current).direction === "rtl";
|
|
745
|
+
if (rtl !== isRTL) {
|
|
746
|
+
setIsRTL(rtl);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
React.useEffect(detectRTL);
|
|
738
751
|
return (React.createElement(DocumentContextProvider, { nodeRef: nodeRef },
|
|
739
|
-
React.createElement(
|
|
752
|
+
React.createElement(RTLContextProvider, { isRTL: isRTL },
|
|
753
|
+
React.createElement("div", { ref: useForkRef(ref, nodeRef), className: clsx(cssClass("root"), className), ...trackFocusWithin(onFocus, onBlur), ...rest }, children))));
|
|
740
754
|
});
|
|
741
755
|
|
|
742
756
|
var SwipeState;
|
|
@@ -1451,7 +1465,7 @@ function setAttribute(element, attribute, value) {
|
|
|
1451
1465
|
}
|
|
1452
1466
|
};
|
|
1453
1467
|
}
|
|
1454
|
-
function Portal({
|
|
1468
|
+
function Portal({ portal: { root, container: { className: containerClassName, style: containerStyle, ...containerRest } = {} }, animation, styles, className, on, close, labels, children, }) {
|
|
1455
1469
|
const [mounted, setMounted] = React.useState(false);
|
|
1456
1470
|
const [visible, setVisible] = React.useState(false);
|
|
1457
1471
|
const cleanup = React.useRef([]);
|
|
@@ -1514,7 +1528,7 @@ function Portal({ children, animation, styles, className, on, portal, close, lab
|
|
|
1514
1528
|
}
|
|
1515
1529
|
}, [handleEnter, handleCleanup]);
|
|
1516
1530
|
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: {
|
|
1531
|
+
? 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
1532
|
...(animation.fade !== LightboxDefaultProps.animation.fade
|
|
1519
1533
|
? { [cssVar("fade_animation_duration")]: `${animationDuration}ms` }
|
|
1520
1534
|
: null),
|
|
@@ -1522,11 +1536,12 @@ function Portal({ children, animation, styles, className, on, portal, close, lab
|
|
|
1522
1536
|
? { [cssVar("fade_animation_timing_function")]: animation.easing.fade }
|
|
1523
1537
|
: null),
|
|
1524
1538
|
...styles.root,
|
|
1539
|
+
...containerStyle,
|
|
1525
1540
|
}, onFocus: (event) => {
|
|
1526
1541
|
if (!restoreFocus.current) {
|
|
1527
1542
|
restoreFocus.current = event.relatedTarget;
|
|
1528
1543
|
}
|
|
1529
|
-
} }, children),
|
|
1544
|
+
}, ...containerRest }, children), root || document.body)
|
|
1530
1545
|
: null;
|
|
1531
1546
|
}
|
|
1532
1547
|
const PortalModule = createModule(MODULE_PORTAL, Portal);
|
|
@@ -1600,4 +1615,4 @@ function Lightbox({ carousel, animation, render, toolbar, controller, noScroll,
|
|
|
1600
1615
|
React.createElement(A11yContextProvider, null, renderNode(createNode(RootModule, config), props)))))));
|
|
1601
1616
|
}
|
|
1602
1617
|
|
|
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 };
|
|
1618
|
+
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 {
|