react-focus-on 3.5.4 → 3.7.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
@@ -61,6 +61,7 @@ import {FocusOn} from 'react-focus-on';
61
61
  - `[noIsolation]` - disables aria-hidden isolation
62
62
  - `[inert]` - enables pointer-events isolation (☠️ dangerous, use to disable "parent scrollbars", refer to [react-remove-scroll](https://github.com/theKashey/react-remove-scroll) documentation)
63
63
  - `[allowPinchZoom]` - enables "pinch-n-zoom" behavior. By default it might be prevented, refer to [react-remove-scroll](https://github.com/theKashey/react-remove-scroll) documentation
64
+ - `[preventScrollOnFocus]` - prevents a [side effect of a programatic page scroll](https://github.com/theKashey/react-focus-on/issues/62) caused by focusing elements. Especially useful to address modal animations.
64
65
  ---
65
66
  - `[onActivation]` - on activation callback
66
67
  - `[onDeactivation]` - on deactivation callback
@@ -1,8 +1,8 @@
1
- import * as tslib_1 from "tslib";
1
+ import { __assign } from "tslib";
2
2
  import * as React from 'react';
3
3
  import { FocusOn as ReactFocusOn } from './UI';
4
4
  import SideCar from './sidecar';
5
5
  var RequireSideCar = function (props) {
6
- return React.createElement(SideCar, tslib_1.__assign({}, props));
6
+ return React.createElement(SideCar, __assign({}, props));
7
7
  };
8
- export var FocusOn = React.forwardRef(function (props, ref) { return React.createElement(ReactFocusOn, tslib_1.__assign({}, props, { ref: ref, sideCar: RequireSideCar })); });
8
+ export var FocusOn = React.forwardRef(function (props, ref) { return React.createElement(ReactFocusOn, __assign({}, props, { ref: ref, sideCar: RequireSideCar })); });
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { EffectProps } from './types';
3
2
  export declare function Effect({ setLockProps, onEscapeKey, onClickOutside, shards, onActivation, onDeactivation, noIsolation }: EffectProps): JSX.Element;
@@ -1,3 +1,4 @@
1
+ import { __spreadArrays } from "tslib";
1
2
  import * as React from 'react';
2
3
  import { hideOthers } from 'aria-hidden';
3
4
  import { InteractivityDisabler } from './InteractivityDisabler';
@@ -77,7 +78,9 @@ export function Effect(_a) {
77
78
  var _undo = function () { return null; };
78
79
  var unmounted = false;
79
80
  var onNodeActivation = function (node) {
80
- _undo = hideOthers([node].concat((shards || []).map(extractRef)), document.body, noIsolation ? undefined : focusHiddenMarker);
81
+ if (!noIsolation) {
82
+ _undo = hideOthers(__spreadArrays([node], (shards || []).map(extractRef)), document.body, focusHiddenMarker);
83
+ }
81
84
  setActiveNode(function () { return node; });
82
85
  };
83
86
  var onNodeDeactivation = function () {
@@ -1,2 +1,2 @@
1
1
  import * as React from 'react';
2
- export declare const InteractivityDisabler: React.SFC;
2
+ export declare const InteractivityDisabler: React.FC;
package/dist/es2015/UI.js CHANGED
@@ -1,20 +1,21 @@
1
- import * as tslib_1 from "tslib";
1
+ import { __assign, __rest } from "tslib";
2
2
  import * as React from 'react';
3
3
  import { RemoveScroll } from 'react-remove-scroll/UI';
4
4
  import ReactFocusLock from 'react-focus-lock/UI';
5
5
  import { effectCar } from './medium';
6
6
  export var FocusOn = React.forwardRef(function (props, parentRef) {
7
7
  var _a = React.useState(false), lockProps = _a[0], setLockProps = _a[1];
8
- var children = props.children, autoFocus = props.autoFocus, shards = props.shards, _b = props.enabled, enabled = _b === void 0 ? true : _b, _c = props.scrollLock, scrollLock = _c === void 0 ? true : _c, _d = props.focusLock, focusLock = _d === void 0 ? true : _d, _e = props.returnFocus, returnFocus = _e === void 0 ? true : _e, inert = props.inert, allowPinchZoom = props.allowPinchZoom, sideCar = props.sideCar, className = props.className, shouldIgnore = props.shouldIgnore, style = props.style, as = props.as, rest = tslib_1.__rest(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "style", "as"]);
8
+ var children = props.children, autoFocus = props.autoFocus, shards = props.shards, _b = props.enabled, enabled = _b === void 0 ? true : _b, _c = props.scrollLock, scrollLock = _c === void 0 ? true : _c, _d = props.focusLock, focusLock = _d === void 0 ? true : _d, _e = props.returnFocus, returnFocus = _e === void 0 ? true : _e, inert = props.inert, allowPinchZoom = props.allowPinchZoom, sideCar = props.sideCar, className = props.className, shouldIgnore = props.shouldIgnore, preventScrollOnFocus = props.preventScrollOnFocus, style = props.style, as = props.as, rest = __rest(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as"]);
9
9
  var SideCar = sideCar;
10
- var onActivation = lockProps.onActivation, onDeactivation = lockProps.onDeactivation, restProps = tslib_1.__rest(lockProps, ["onActivation", "onDeactivation"]);
10
+ var onActivation = lockProps.onActivation, onDeactivation = lockProps.onDeactivation, restProps = __rest(lockProps, ["onActivation", "onDeactivation"]);
11
+ var appliedLockProps = __assign(__assign({}, restProps), { sideCar: sideCar,
12
+ shards: shards,
13
+ allowPinchZoom: allowPinchZoom,
14
+ as: as,
15
+ inert: inert,
16
+ style: style, enabled: enabled && scrollLock });
11
17
  return (React.createElement(React.Fragment, null,
12
- React.createElement(ReactFocusLock, { ref: parentRef, sideCar: sideCar, disabled: !(lockProps && enabled && focusLock), returnFocus: returnFocus, autoFocus: autoFocus, shards: shards, onActivation: onActivation, onDeactivation: onDeactivation, className: className, as: RemoveScroll, whiteList: shouldIgnore, lockProps: tslib_1.__assign({}, restProps, { sideCar: sideCar,
13
- shards: shards,
14
- allowPinchZoom: allowPinchZoom,
15
- as: as,
16
- inert: inert,
17
- style: style, enabled: enabled && scrollLock }) }, children),
18
- enabled && (React.createElement(SideCar, tslib_1.__assign({}, rest, { sideCar: effectCar, setLockProps: setLockProps, shards: shards })))));
18
+ React.createElement(ReactFocusLock, { ref: parentRef, sideCar: sideCar, disabled: !(lockProps && enabled && focusLock), returnFocus: returnFocus, autoFocus: autoFocus, shards: shards, onActivation: onActivation, onDeactivation: onDeactivation, className: className, whiteList: shouldIgnore, lockProps: appliedLockProps, focusOptions: preventScrollOnFocus ? { preventScroll: true } : undefined, as: RemoveScroll }, children),
19
+ enabled && (React.createElement(SideCar, __assign({}, rest, { sideCar: effectCar, setLockProps: setLockProps, shards: shards })))));
19
20
  });
20
21
  export * from './reExports';
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- export declare const effectCar: Readonly<import("use-sidecar/dist/es5/types").SideMedium<import("react").ComponentType<{}>>>;
1
+ import { EffectProps } from "./types";
2
+ export declare const effectCar: Readonly<import("use-sidecar/dist/es5/types").SideCarMedium<EffectProps>>;
3
3
  export declare const focusHiddenMarker = "data-focus-on-hidden";
@@ -1,4 +1,4 @@
1
- import * as tslib_1 from "tslib";
1
+ import { __assign } from "tslib";
2
2
  import { RemoveScroll } from 'react-remove-scroll/UI';
3
3
  export { AutoFocusInside, MoveFocusInside, InFocusGuard } from 'react-focus-lock/UI';
4
- export var classNames = tslib_1.__assign({}, RemoveScroll.classNames);
4
+ export var classNames = __assign({}, RemoveScroll.classNames);
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  import 'react-focus-lock/sidecar';
3
2
  import 'react-remove-scroll/sidecar';
4
- declare const _default: import("react").FunctionComponent<import("./types").EffectProps & import("use-sidecar/dist/es5/types").SideCarHOC>;
3
+ declare const _default: import("use-sidecar").SideCarComponent<import("./types").EffectProps>;
5
4
  export default _default;
@@ -2,90 +2,95 @@ import * as React from 'react';
2
2
  import ReactFocusLock from 'react-focus-lock/UI';
3
3
  import { ComponentProps } from "react";
4
4
  export interface LockProps {
5
- onMouseDown?(e: React.MouseEvent): void;
6
- onTouchStart?(e: React.TouchEvent): void;
7
- onActivation?(node: HTMLElement): void;
8
- onDeactivation?(): void;
5
+ onMouseDown?: ((e: React.MouseEvent) => void) | undefined;
6
+ onTouchStart?: ((e: React.TouchEvent) => void) | undefined;
7
+ onActivation?: ((node: HTMLElement) => void) | undefined;
8
+ onDeactivation?: (() => void) | undefined;
9
9
  }
10
10
  export interface CommonProps {
11
11
  /**
12
12
  * action to perform on Esc key press
13
13
  */
14
- onEscapeKey?: (event: Event) => void;
14
+ onEscapeKey?: ((event: Event) => void) | undefined;
15
15
  /**
16
16
  * action to perform on click outside
17
17
  */
18
- onClickOutside?: (event: MouseEvent | TouchEvent) => void;
18
+ onClickOutside?: ((event: MouseEvent | TouchEvent) => void) | undefined;
19
19
  /**
20
20
  * callback on lock activation
21
21
  * @param node the main node
22
22
  */
23
- onActivation?: (node: HTMLElement) => void;
23
+ onActivation?: ((node: HTMLElement) => void) | undefined;
24
24
  /**
25
25
  * callback on lock deactivation
26
26
  */
27
- onDeactivation?: () => void;
27
+ onDeactivation?: (() => void) | undefined;
28
28
  /**
29
29
  * [scroll-lock] control isolation
30
30
  * @see {@link https://github.com/theKashey/react-remove-scroll#usage}
31
31
  */
32
- noIsolation?: boolean;
32
+ noIsolation?: boolean | undefined;
33
33
  /**
34
34
  * [scroll-lock] full page inert (event suppression)
35
35
  * @default false
36
36
  * @see {@link https://github.com/theKashey/react-remove-scroll#usage}
37
37
  */
38
- inert?: boolean;
38
+ inert?: boolean | undefined;
39
39
  /**
40
40
  * [scroll-lock] allows scroll based zoom
41
41
  * @default false
42
42
  * @see https://github.com/theKashey/react-remove-scroll#usage
43
43
  */
44
- allowPinchZoom?: boolean;
44
+ allowPinchZoom?: boolean | undefined;
45
45
  /**
46
46
  * a list of elements which should be considered as a part of the lock
47
47
  */
48
- shards?: Array<React.RefObject<any> | HTMLElement>;
48
+ shards?: (Array<React.RefObject<any> | HTMLElement>) | undefined;
49
49
  }
50
50
  export interface ReactFocusOnProps extends CommonProps {
51
51
  /**
52
52
  * The main switch
53
53
  */
54
- enabled?: boolean;
54
+ enabled?: boolean | undefined;
55
55
  /**
56
56
  * Controls scroll lock behavior
57
57
  */
58
- scrollLock?: boolean;
58
+ scrollLock?: boolean | undefined;
59
59
  /**
60
60
  * Controls focus lock behavior
61
61
  */
62
- focusLock?: boolean;
62
+ focusLock?: boolean | undefined;
63
63
  /**
64
64
  * [focus-lock] control autofocus
65
65
  * @default true
66
66
  */
67
- autoFocus?: boolean;
67
+ autoFocus?: boolean | undefined;
68
68
  /**
69
69
  * [focus-lock] control returnFocus
70
70
  * @default true
71
71
  */
72
- returnFocus?: ComponentProps<typeof ReactFocusLock>['returnFocus'];
72
+ returnFocus?: ComponentProps<typeof ReactFocusLock>['returnFocus'] | undefined;
73
+ /**
74
+ * [focus-lock] prevents scroll on focus via focusOptions
75
+ * @default false
76
+ */
77
+ preventScrollOnFocus?: boolean | undefined;
73
78
  /**
74
79
  * [focus-lock] allows "ignoring" focus on some elements
75
80
  * @see {@link https://github.com/theKashey/react-focus-lock#api}
76
81
  */
77
- shouldIgnore?: (candidate: HTMLElement) => boolean;
82
+ shouldIgnore?: ((candidate: HTMLElement) => boolean) | undefined;
78
83
  /**
79
84
  * allows replacement of the host node
80
85
  * @default div
81
86
  */
82
- as?: string | React.ElementType;
83
- style?: React.CSSProperties;
84
- className?: string;
87
+ as?: string | React.ElementType | undefined;
88
+ style?: React.CSSProperties | undefined;
89
+ className?: string | undefined;
85
90
  children: React.ReactNode;
86
91
  }
87
92
  export interface ReactFocusOnSideProps extends ReactFocusOnProps {
88
- sideCar: React.SFC<any>;
93
+ sideCar: React.FC<any>;
89
94
  }
90
95
  export interface EffectProps extends CommonProps {
91
96
  setLockProps(settings: LockProps): void;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FocusOn = void 0;
3
4
  var tslib_1 = require("tslib");
4
5
  var React = require("react");
5
6
  var UI_1 = require("./UI");
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { EffectProps } from './types';
3
2
  export declare function Effect({ setLockProps, onEscapeKey, onClickOutside, shards, onActivation, onDeactivation, noIsolation }: EffectProps): JSX.Element;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Effect = void 0;
4
+ var tslib_1 = require("tslib");
3
5
  var React = require("react");
4
6
  var aria_hidden_1 = require("aria-hidden");
5
7
  var InteractivityDisabler_1 = require("./InteractivityDisabler");
@@ -79,7 +81,9 @@ function Effect(_a) {
79
81
  var _undo = function () { return null; };
80
82
  var unmounted = false;
81
83
  var onNodeActivation = function (node) {
82
- _undo = aria_hidden_1.hideOthers([node].concat((shards || []).map(extractRef)), document.body, noIsolation ? undefined : medium_1.focusHiddenMarker);
84
+ if (!noIsolation) {
85
+ _undo = aria_hidden_1.hideOthers(tslib_1.__spreadArrays([node], (shards || []).map(extractRef)), document.body, medium_1.focusHiddenMarker);
86
+ }
83
87
  setActiveNode(function () { return node; });
84
88
  };
85
89
  var onNodeDeactivation = function () {
@@ -1,2 +1,2 @@
1
1
  import * as React from 'react';
2
- export declare const InteractivityDisabler: React.SFC;
2
+ export declare const InteractivityDisabler: React.FC;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InteractivityDisabler = void 0;
3
4
  var React = require("react");
4
5
  var react_style_singleton_1 = require("react-style-singleton");
5
6
  var medium_1 = require("./medium");
package/dist/es5/UI.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FocusOn = void 0;
3
4
  var tslib_1 = require("tslib");
4
5
  var React = require("react");
5
6
  var UI_1 = require("react-remove-scroll/UI");
@@ -7,16 +8,17 @@ var UI_2 = require("react-focus-lock/UI");
7
8
  var medium_1 = require("./medium");
8
9
  exports.FocusOn = React.forwardRef(function (props, parentRef) {
9
10
  var _a = React.useState(false), lockProps = _a[0], setLockProps = _a[1];
10
- var children = props.children, autoFocus = props.autoFocus, shards = props.shards, _b = props.enabled, enabled = _b === void 0 ? true : _b, _c = props.scrollLock, scrollLock = _c === void 0 ? true : _c, _d = props.focusLock, focusLock = _d === void 0 ? true : _d, _e = props.returnFocus, returnFocus = _e === void 0 ? true : _e, inert = props.inert, allowPinchZoom = props.allowPinchZoom, sideCar = props.sideCar, className = props.className, shouldIgnore = props.shouldIgnore, style = props.style, as = props.as, rest = tslib_1.__rest(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "style", "as"]);
11
+ var children = props.children, autoFocus = props.autoFocus, shards = props.shards, _b = props.enabled, enabled = _b === void 0 ? true : _b, _c = props.scrollLock, scrollLock = _c === void 0 ? true : _c, _d = props.focusLock, focusLock = _d === void 0 ? true : _d, _e = props.returnFocus, returnFocus = _e === void 0 ? true : _e, inert = props.inert, allowPinchZoom = props.allowPinchZoom, sideCar = props.sideCar, className = props.className, shouldIgnore = props.shouldIgnore, preventScrollOnFocus = props.preventScrollOnFocus, style = props.style, as = props.as, rest = tslib_1.__rest(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as"]);
11
12
  var SideCar = sideCar;
12
13
  var onActivation = lockProps.onActivation, onDeactivation = lockProps.onDeactivation, restProps = tslib_1.__rest(lockProps, ["onActivation", "onDeactivation"]);
14
+ var appliedLockProps = tslib_1.__assign(tslib_1.__assign({}, restProps), { sideCar: sideCar,
15
+ shards: shards,
16
+ allowPinchZoom: allowPinchZoom,
17
+ as: as,
18
+ inert: inert,
19
+ style: style, enabled: enabled && scrollLock });
13
20
  return (React.createElement(React.Fragment, null,
14
- React.createElement(UI_2.default, { ref: parentRef, sideCar: sideCar, disabled: !(lockProps && enabled && focusLock), returnFocus: returnFocus, autoFocus: autoFocus, shards: shards, onActivation: onActivation, onDeactivation: onDeactivation, className: className, as: UI_1.RemoveScroll, whiteList: shouldIgnore, lockProps: tslib_1.__assign({}, restProps, { sideCar: sideCar,
15
- shards: shards,
16
- allowPinchZoom: allowPinchZoom,
17
- as: as,
18
- inert: inert,
19
- style: style, enabled: enabled && scrollLock }) }, children),
21
+ React.createElement(UI_2.default, { ref: parentRef, sideCar: sideCar, disabled: !(lockProps && enabled && focusLock), returnFocus: returnFocus, autoFocus: autoFocus, shards: shards, onActivation: onActivation, onDeactivation: onDeactivation, className: className, whiteList: shouldIgnore, lockProps: appliedLockProps, focusOptions: preventScrollOnFocus ? { preventScroll: true } : undefined, as: UI_1.RemoveScroll }, children),
20
22
  enabled && (React.createElement(SideCar, tslib_1.__assign({}, rest, { sideCar: medium_1.effectCar, setLockProps: setLockProps, shards: shards })))));
21
23
  });
22
24
  tslib_1.__exportStar(require("./reExports"), exports);
package/dist/es5/index.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
4
  var Combination_1 = require("./Combination");
5
- exports.FocusOn = Combination_1.FocusOn;
5
+ Object.defineProperty(exports, "FocusOn", { enumerable: true, get: function () { return Combination_1.FocusOn; } });
6
6
  tslib_1.__exportStar(require("./reExports"), exports);
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- export declare const effectCar: Readonly<import("use-sidecar/dist/es5/types").SideMedium<import("react").ComponentType<{}>>>;
1
+ import { EffectProps } from "./types";
2
+ export declare const effectCar: Readonly<import("use-sidecar/dist/es5/types").SideCarMedium<EffectProps>>;
3
3
  export declare const focusHiddenMarker = "data-focus-on-hidden";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.focusHiddenMarker = exports.effectCar = void 0;
3
4
  var use_sidecar_1 = require("use-sidecar");
4
5
  exports.effectCar = use_sidecar_1.createSidecarMedium();
5
6
  exports.focusHiddenMarker = 'data-focus-on-hidden';
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classNames = void 0;
3
4
  var tslib_1 = require("tslib");
4
5
  var UI_1 = require("react-remove-scroll/UI");
5
6
  var UI_2 = require("react-focus-lock/UI");
6
- exports.AutoFocusInside = UI_2.AutoFocusInside;
7
- exports.MoveFocusInside = UI_2.MoveFocusInside;
8
- exports.InFocusGuard = UI_2.InFocusGuard;
7
+ Object.defineProperty(exports, "AutoFocusInside", { enumerable: true, get: function () { return UI_2.AutoFocusInside; } });
8
+ Object.defineProperty(exports, "MoveFocusInside", { enumerable: true, get: function () { return UI_2.MoveFocusInside; } });
9
+ Object.defineProperty(exports, "InFocusGuard", { enumerable: true, get: function () { return UI_2.InFocusGuard; } });
9
10
  exports.classNames = tslib_1.__assign({}, UI_1.RemoveScroll.classNames);
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  import 'react-focus-lock/sidecar';
3
2
  import 'react-remove-scroll/sidecar';
4
- declare const _default: import("react").FunctionComponent<import("./types").EffectProps & import("use-sidecar/dist/es5/types").SideCarHOC>;
3
+ declare const _default: import("use-sidecar").SideCarComponent<import("./types").EffectProps>;
5
4
  export default _default;
@@ -2,90 +2,95 @@ import * as React from 'react';
2
2
  import ReactFocusLock from 'react-focus-lock/UI';
3
3
  import { ComponentProps } from "react";
4
4
  export interface LockProps {
5
- onMouseDown?(e: React.MouseEvent): void;
6
- onTouchStart?(e: React.TouchEvent): void;
7
- onActivation?(node: HTMLElement): void;
8
- onDeactivation?(): void;
5
+ onMouseDown?: ((e: React.MouseEvent) => void) | undefined;
6
+ onTouchStart?: ((e: React.TouchEvent) => void) | undefined;
7
+ onActivation?: ((node: HTMLElement) => void) | undefined;
8
+ onDeactivation?: (() => void) | undefined;
9
9
  }
10
10
  export interface CommonProps {
11
11
  /**
12
12
  * action to perform on Esc key press
13
13
  */
14
- onEscapeKey?: (event: Event) => void;
14
+ onEscapeKey?: ((event: Event) => void) | undefined;
15
15
  /**
16
16
  * action to perform on click outside
17
17
  */
18
- onClickOutside?: (event: MouseEvent | TouchEvent) => void;
18
+ onClickOutside?: ((event: MouseEvent | TouchEvent) => void) | undefined;
19
19
  /**
20
20
  * callback on lock activation
21
21
  * @param node the main node
22
22
  */
23
- onActivation?: (node: HTMLElement) => void;
23
+ onActivation?: ((node: HTMLElement) => void) | undefined;
24
24
  /**
25
25
  * callback on lock deactivation
26
26
  */
27
- onDeactivation?: () => void;
27
+ onDeactivation?: (() => void) | undefined;
28
28
  /**
29
29
  * [scroll-lock] control isolation
30
30
  * @see {@link https://github.com/theKashey/react-remove-scroll#usage}
31
31
  */
32
- noIsolation?: boolean;
32
+ noIsolation?: boolean | undefined;
33
33
  /**
34
34
  * [scroll-lock] full page inert (event suppression)
35
35
  * @default false
36
36
  * @see {@link https://github.com/theKashey/react-remove-scroll#usage}
37
37
  */
38
- inert?: boolean;
38
+ inert?: boolean | undefined;
39
39
  /**
40
40
  * [scroll-lock] allows scroll based zoom
41
41
  * @default false
42
42
  * @see https://github.com/theKashey/react-remove-scroll#usage
43
43
  */
44
- allowPinchZoom?: boolean;
44
+ allowPinchZoom?: boolean | undefined;
45
45
  /**
46
46
  * a list of elements which should be considered as a part of the lock
47
47
  */
48
- shards?: Array<React.RefObject<any> | HTMLElement>;
48
+ shards?: (Array<React.RefObject<any> | HTMLElement>) | undefined;
49
49
  }
50
50
  export interface ReactFocusOnProps extends CommonProps {
51
51
  /**
52
52
  * The main switch
53
53
  */
54
- enabled?: boolean;
54
+ enabled?: boolean | undefined;
55
55
  /**
56
56
  * Controls scroll lock behavior
57
57
  */
58
- scrollLock?: boolean;
58
+ scrollLock?: boolean | undefined;
59
59
  /**
60
60
  * Controls focus lock behavior
61
61
  */
62
- focusLock?: boolean;
62
+ focusLock?: boolean | undefined;
63
63
  /**
64
64
  * [focus-lock] control autofocus
65
65
  * @default true
66
66
  */
67
- autoFocus?: boolean;
67
+ autoFocus?: boolean | undefined;
68
68
  /**
69
69
  * [focus-lock] control returnFocus
70
70
  * @default true
71
71
  */
72
- returnFocus?: ComponentProps<typeof ReactFocusLock>['returnFocus'];
72
+ returnFocus?: ComponentProps<typeof ReactFocusLock>['returnFocus'] | undefined;
73
+ /**
74
+ * [focus-lock] prevents scroll on focus via focusOptions
75
+ * @default false
76
+ */
77
+ preventScrollOnFocus?: boolean | undefined;
73
78
  /**
74
79
  * [focus-lock] allows "ignoring" focus on some elements
75
80
  * @see {@link https://github.com/theKashey/react-focus-lock#api}
76
81
  */
77
- shouldIgnore?: (candidate: HTMLElement) => boolean;
82
+ shouldIgnore?: ((candidate: HTMLElement) => boolean) | undefined;
78
83
  /**
79
84
  * allows replacement of the host node
80
85
  * @default div
81
86
  */
82
- as?: string | React.ElementType;
83
- style?: React.CSSProperties;
84
- className?: string;
87
+ as?: string | React.ElementType | undefined;
88
+ style?: React.CSSProperties | undefined;
89
+ className?: string | undefined;
85
90
  children: React.ReactNode;
86
91
  }
87
92
  export interface ReactFocusOnSideProps extends ReactFocusOnProps {
88
- sideCar: React.SFC<any>;
93
+ sideCar: React.FC<any>;
89
94
  }
90
95
  export interface EffectProps extends CommonProps {
91
96
  setLockProps(settings: LockProps): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-focus-on",
3
- "version": "3.5.4",
3
+ "version": "3.7.0",
4
4
  "description": "The final solution for WAI ARIA compatible modal dialogs or full-screen tasks.",
5
5
  "main": "dist/es5/index.js",
6
6
  "scripts": {
@@ -34,7 +34,7 @@
34
34
  "author": "Anton Korzunov <thekashey@gmail.com>",
35
35
  "license": "MIT",
36
36
  "devDependencies": {
37
- "@types/react": "^16.8.19",
37
+ "@types/react": "^18.0.8",
38
38
  "conventional-changelog-cli": "^2.0.12",
39
39
  "enzyme": "^3.10.0",
40
40
  "enzyme-adapter-react-16": "^1.14.0",
@@ -44,13 +44,13 @@
44
44
  "ts-react-toolbox": "^0.2.10"
45
45
  },
46
46
  "dependencies": {
47
- "aria-hidden": "^1.1.3",
48
- "react-focus-lock": "^2.6.0",
49
- "react-remove-scroll": "^2.4.1",
50
- "react-style-singleton": "^2.1.1",
47
+ "aria-hidden": "^1.2.2",
48
+ "react-focus-lock": "^2.9.2",
49
+ "react-remove-scroll": "^2.5.5",
50
+ "react-style-singleton": "^2.2.0",
51
51
  "tslib": "^2.3.1",
52
- "use-callback-ref": "^1.2.5",
53
- "use-sidecar": "^1.0.5"
52
+ "use-callback-ref": "^1.3.0",
53
+ "use-sidecar": "^1.1.2"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=8.5.0"
@@ -80,7 +80,7 @@
80
80
  "isolation"
81
81
  ],
82
82
  "resolutions": {
83
- "typescript": "^3.0.0"
83
+ "typescript": "^3.8.0"
84
84
  },
85
85
  "homepage": "https://github.com/theKashey/react-focus-on#readme"
86
86
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
2
 
3
- declare var sidecar: React.SFC;
3
+ declare var sidecar: React.FC;
4
4
 
5
5
  export default sidecar;