yet-another-react-lightbox 1.3.1 → 1.3.2

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/Lightbox.js CHANGED
@@ -25,7 +25,7 @@ const LightboxComponent = (props) => {
25
25
  };
26
26
  LightboxComponent.propTypes = LightboxPropTypes;
27
27
  export const Lightbox = (props) => {
28
- const { carousel, animation, render, toolbar, on, ...restProps } = props;
29
- const { carousel: defaultCarousel, animation: defaultAnimation, render: defaultRender, toolbar: defaultToolbar, on: defaultOn, ...restDefaultProps } = LightboxDefaultProps;
30
- return (React.createElement(LightboxComponent, { carousel: { ...defaultCarousel, ...carousel }, animation: { ...defaultAnimation, ...animation }, render: { ...defaultRender, ...render }, toolbar: { ...defaultToolbar, ...toolbar }, on: { ...defaultOn, ...on }, ...restDefaultProps, ...restProps }));
28
+ const { carousel, animation, render, toolbar, controller, on, ...restProps } = props;
29
+ const { carousel: defaultCarousel, animation: defaultAnimation, render: defaultRender, toolbar: defaultToolbar, controller: defaultController, on: defaultOn, ...restDefaultProps } = LightboxDefaultProps;
30
+ return (React.createElement(LightboxComponent, { carousel: { ...defaultCarousel, ...carousel }, animation: { ...defaultAnimation, ...animation }, render: { ...defaultRender, ...render }, toolbar: { ...defaultToolbar, ...toolbar }, controller: { ...defaultController, ...controller }, on: { ...defaultOn, ...on }, ...restDefaultProps, ...restProps }));
31
31
  };
@@ -42,8 +42,10 @@ export const Controller = ({ children, ...props }) => {
42
42
  }, [containerRef]);
43
43
  React.useEffect(() => {
44
44
  var _a;
45
- (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
46
- }, [containerRef]);
45
+ if (refs.current.props.controller.focus) {
46
+ (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
47
+ }
48
+ }, [containerRef, refs]);
47
49
  React.useEffect(() => {
48
50
  var _a, _b;
49
51
  (_b = (_a = refs.current.props.on).view) === null || _b === void 0 ? void 0 : _b.call(_a, state.currentIndex);
@@ -3,7 +3,7 @@ import { createModule } from "../core/index.js";
3
3
  const InlineContainer = ({ inline, children }) => React.createElement("div", { ...inline }, children);
4
4
  const InlineModule = createModule("inline", InlineContainer);
5
5
  const Inline = ({ augment, replace, remove }) => {
6
- augment(({ toolbar: { buttons, ...restToolbar }, open, close, ...restProps }) => ({
6
+ augment(({ toolbar: { buttons, ...restToolbar }, open, close, controller: { focus, ...restController }, ...restProps }) => ({
7
7
  open: true,
8
8
  close: () => { },
9
9
  toolbar: {
@@ -11,6 +11,7 @@ const Inline = ({ augment, replace, remove }) => {
11
11
  ...restToolbar,
12
12
  },
13
13
  inline: { style: { width: "100%", height: "100%" } },
14
+ controller: { focus: false, ...restController },
14
15
  ...restProps,
15
16
  }));
16
17
  remove("no-scroll");
package/dist/types.d.ts CHANGED
@@ -13,16 +13,19 @@ export interface SlideTypes {
13
13
  SlideImage: SlideImage;
14
14
  }
15
15
  export declare type Slide = SlideTypes[keyof SlideTypes];
16
- export interface Carousel {
16
+ export interface CarouselSettings {
17
17
  finite: boolean;
18
18
  preload: number;
19
19
  padding: string | number;
20
20
  spacing: string | number;
21
21
  }
22
- export interface Animation {
22
+ export interface AnimationSettings {
23
23
  fade: number;
24
24
  swipe: number;
25
25
  }
26
+ export interface ControllerSettings {
27
+ focus: boolean;
28
+ }
26
29
  export interface Render {
27
30
  slide?: (slide: Slide) => React.ReactNode;
28
31
  iconPrev?: () => React.ReactNode;
@@ -49,9 +52,10 @@ export interface LightboxProps {
49
52
  render: Render;
50
53
  labels: Labels;
51
54
  plugins: Plugin[];
52
- toolbar: Toolbar;
53
- carousel: Carousel;
54
- animation: Animation;
55
+ toolbar: ToolbarSettings;
56
+ carousel: CarouselSettings;
57
+ animation: AnimationSettings;
58
+ controller: ControllerSettings;
55
59
  on: Callbacks;
56
60
  }
57
61
  export declare const SlideTypesPropTypes: PropTypes.Validator<any>[];
@@ -86,6 +90,9 @@ export declare const LightboxPropTypes: {
86
90
  fade: PropTypes.Validator<number>;
87
91
  swipe: PropTypes.Validator<number>;
88
92
  }>>;
93
+ controller: PropTypes.Validator<PropTypes.InferProps<{
94
+ focus: PropTypes.Validator<boolean>;
95
+ }>>;
89
96
  on: PropTypes.Validator<PropTypes.InferProps<{
90
97
  view: PropTypes.Requireable<(...args: any[]) => any>;
91
98
  entering: PropTypes.Requireable<(...args: any[]) => any>;
@@ -101,16 +108,17 @@ export declare const LightboxDefaultProps: {
101
108
  slides: Slide[];
102
109
  render: Render;
103
110
  plugins: Plugin[];
104
- toolbar: Toolbar;
111
+ toolbar: ToolbarSettings;
105
112
  labels: Labels;
106
- animation: Animation;
107
- carousel: Carousel;
113
+ animation: AnimationSettings;
114
+ carousel: CarouselSettings;
115
+ controller: ControllerSettings;
108
116
  on: Callbacks;
109
117
  };
110
118
  export declare type Labels = {
111
119
  [key: string]: string;
112
120
  };
113
- export interface Toolbar {
121
+ export interface ToolbarSettings {
114
122
  buttons: ("close" | React.ReactNode)[];
115
123
  }
116
124
  export declare type ComponentProps = Omit<LightboxProps, "plugins">;
package/dist/types.js CHANGED
@@ -44,6 +44,9 @@ export const LightboxPropTypes = {
44
44
  fade: PropTypes.number.isRequired,
45
45
  swipe: PropTypes.number.isRequired,
46
46
  }).isRequired,
47
+ controller: PropTypes.shape({
48
+ focus: PropTypes.bool.isRequired,
49
+ }).isRequired,
47
50
  on: PropTypes.shape({
48
51
  view: PropTypes.func,
49
52
  entering: PropTypes.func,
@@ -71,5 +74,8 @@ export const LightboxDefaultProps = {
71
74
  padding: "16px",
72
75
  spacing: "30%",
73
76
  },
77
+ controller: {
78
+ focus: true,
79
+ },
74
80
  on: {},
75
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",