react-focus-on 3.5.4 → 3.6.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/CHANGELOG.md ADDED
@@ -0,0 +1,240 @@
1
+ # [3.6.0](https://github.com/theKashey/react-focus-on/compare/v3.5.4...v3.6.0) (2022-05-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update underlaying packages; brings React 18 and Shadow DOM support ([5bd7b5c](https://github.com/theKashey/react-focus-on/commit/5bd7b5c))
7
+
8
+
9
+
10
+ ## [3.5.4](https://github.com/theKashey/react-focus-on/compare/v3.5.3...v3.5.4) (2021-11-09)
11
+
12
+
13
+
14
+ ## [3.5.3](https://github.com/theKashey/react-focus-on/compare/v3.5.2...v3.5.3) (2021-11-09)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * add tslib as dependency, fixes [#54](https://github.com/theKashey/react-focus-on/issues/54) ([ce204cd](https://github.com/theKashey/react-focus-on/commit/ce204cd))
20
+
21
+
22
+
23
+ ## [3.5.2](https://github.com/theKashey/react-focus-on/compare/v3.5.1...v3.5.2) (2021-03-28)
24
+
25
+
26
+
27
+ ## [3.5.1](https://github.com/theKashey/react-focus-on/compare/v3.5.0...v3.5.1) (2020-11-27)
28
+
29
+
30
+
31
+ # [3.5.0](https://github.com/theKashey/react-focus-on/compare/v3.4.1...v3.5.0) (2020-08-13)
32
+
33
+
34
+ ### Features
35
+
36
+ * add 'as' and 'style' props ([d1a79e4](https://github.com/theKashey/react-focus-on/commit/d1a79e4))
37
+ * expose whitelist prop ([fa5fe87](https://github.com/theKashey/react-focus-on/commit/fa5fe87))
38
+
39
+
40
+
41
+ ## [3.4.1](https://github.com/theKashey/react-focus-on/compare/v3.4.0...v3.4.1) (2020-04-17)
42
+
43
+
44
+ ### Bug Fixes
45
+
46
+ * update focus-lock, fixes [#35](https://github.com/theKashey/react-focus-on/issues/35) ([280d4a5](https://github.com/theKashey/react-focus-on/commit/280d4a5))
47
+
48
+
49
+
50
+ # [3.4.0](https://github.com/theKashey/react-focus-on/compare/v3.3.0...v3.4.0) (2020-04-16)
51
+
52
+
53
+ ### Features
54
+
55
+ * support CSP ([67739a4](https://github.com/theKashey/react-focus-on/commit/67739a4))
56
+
57
+
58
+
59
+ # [3.3.0](https://github.com/theKashey/react-focus-on/compare/v3.2.0...v3.3.0) (2019-10-17)
60
+
61
+
62
+ ### Features
63
+
64
+ * add allowPinchZoom ([ad396d7](https://github.com/theKashey/react-focus-on/commit/ad396d7))
65
+
66
+
67
+
68
+ # [3.2.0](https://github.com/theKashey/react-focus-on/compare/v3.1.5...v3.2.0) (2019-10-13)
69
+
70
+
71
+ ### Features
72
+
73
+ * allow ref forwarding ([d379b3c](https://github.com/theKashey/react-focus-on/commit/d379b3c))
74
+
75
+
76
+
77
+ ## [3.1.5](https://github.com/theKashey/react-focus-on/compare/v3.1.4...v3.1.5) (2019-10-06)
78
+
79
+
80
+
81
+ ## [3.1.4](https://github.com/theKashey/react-focus-on/compare/v3.1.3...v3.1.4) (2019-10-05)
82
+
83
+
84
+
85
+ ## [3.1.3](https://github.com/theKashey/react-focus-on/compare/v3.1.2...v3.1.3) (2019-10-01)
86
+
87
+
88
+ ### Bug Fixes
89
+
90
+ * deactivation sequence, fixes [#24](https://github.com/theKashey/react-focus-on/issues/24) ([32ed7d7](https://github.com/theKashey/react-focus-on/commit/32ed7d7))
91
+
92
+
93
+
94
+ ## [3.1.2](https://github.com/theKashey/react-focus-on/compare/v3.1.1...v3.1.2) (2019-09-28)
95
+
96
+
97
+
98
+ ## [3.1.1](https://github.com/theKashey/react-focus-on/compare/v3.1.0...v3.1.1) (2019-09-21)
99
+
100
+
101
+ ### Bug Fixes
102
+
103
+ * update hooks when users changes callbacks, fixes [#17](https://github.com/theKashey/react-focus-on/issues/17) ([127a303](https://github.com/theKashey/react-focus-on/commit/127a303))
104
+
105
+
106
+
107
+ # [3.1.0](https://github.com/theKashey/react-focus-on/compare/v3.0.7...v3.1.0) (2019-09-13)
108
+
109
+
110
+ ### Features
111
+
112
+ * support returnOption=preventScroll FocusLock option ([ff2dad3](https://github.com/theKashey/react-focus-on/commit/ff2dad3))
113
+
114
+
115
+
116
+ ## [3.0.7](https://github.com/theKashey/react-focus-on/compare/v3.0.6...v3.0.7) (2019-09-11)
117
+
118
+
119
+
120
+ ## [3.0.6](https://github.com/theKashey/react-focus-on/compare/v3.0.5...v3.0.6) (2019-08-15)
121
+
122
+
123
+ ### Bug Fixes
124
+
125
+ * fixes onClickOutside on iOS devices. fixes [#13](https://github.com/theKashey/react-focus-on/issues/13) ([96d0756](https://github.com/theKashey/react-focus-on/commit/96d0756))
126
+
127
+
128
+
129
+ ## [3.0.5](https://github.com/theKashey/react-focus-on/compare/v3.0.4...v3.0.5) (2019-07-16)
130
+
131
+
132
+ ### Bug Fixes
133
+
134
+ * handle Esc in IE compatible way, fixes [#10](https://github.com/theKashey/react-focus-on/issues/10) ([f897bea](https://github.com/theKashey/react-focus-on/commit/f897bea))
135
+
136
+
137
+
138
+ ## [3.0.4](https://github.com/theKashey/react-focus-on/compare/v3.0.3...v3.0.4) (2019-07-16)
139
+
140
+
141
+ ### Bug Fixes
142
+
143
+ * expose returnFocus prop, fixes [#11](https://github.com/theKashey/react-focus-on/issues/11) ([b25b5b5](https://github.com/theKashey/react-focus-on/commit/b25b5b5))
144
+
145
+
146
+
147
+ ## [3.0.3](https://github.com/theKashey/react-focus-on/compare/v3.0.1...v3.0.3) (2019-07-03)
148
+
149
+
150
+
151
+ ## [3.0.1](https://github.com/theKashey/react-focus-on/compare/v3.0.0...v3.0.1) (2019-07-02)
152
+
153
+
154
+ ### Bug Fixes
155
+
156
+ * aria-hidden broken in v3, fixes [#8](https://github.com/theKashey/react-focus-on/issues/8) ([f7570e5](https://github.com/theKashey/react-focus-on/commit/f7570e5))
157
+
158
+
159
+
160
+ # [3.0.0](https://github.com/theKashey/react-focus-on/compare/v2.0.2...v3.0.0) (2019-06-29)
161
+
162
+
163
+ ### Features
164
+
165
+ * introduce sidecar ([0588039](https://github.com/theKashey/react-focus-on/commit/0588039))
166
+
167
+
168
+
169
+ ## [2.0.2](https://github.com/theKashey/react-focus-on/compare/v2.0.1...v2.0.2) (2019-05-05)
170
+
171
+
172
+
173
+ ## [2.0.1](https://github.com/theKashey/react-focus-on/compare/v2.0.0...v2.0.1) (2019-04-10)
174
+
175
+
176
+ ### Bug Fixes
177
+
178
+ * dont prevent internal clicks, fixes [#3](https://github.com/theKashey/react-focus-on/issues/3) ([229eaad](https://github.com/theKashey/react-focus-on/commit/229eaad))
179
+
180
+
181
+
182
+ # [2.0.0](https://github.com/theKashey/react-focus-on/compare/v1.3.2...v2.0.0) (2019-03-11)
183
+
184
+
185
+ ### Features
186
+
187
+ * shards and remove-scroll ([dbd4d5f](https://github.com/theKashey/react-focus-on/commit/dbd4d5f))
188
+ * shards and remove-scroll ([0f5d421](https://github.com/theKashey/react-focus-on/commit/0f5d421))
189
+
190
+
191
+
192
+ ## [1.3.2](https://github.com/theKashey/react-focus-on/compare/v1.3.1...v1.3.2) (2019-01-21)
193
+
194
+
195
+ ### Bug Fixes
196
+
197
+ * return focus by default ([a525b4c](https://github.com/theKashey/react-focus-on/commit/a525b4c))
198
+
199
+
200
+
201
+ ## [1.3.1](https://github.com/theKashey/react-focus-on/compare/v1.3.0...v1.3.1) (2018-12-31)
202
+
203
+
204
+ ### Bug Fixes
205
+
206
+ * Escape on body ([e551925](https://github.com/theKashey/react-focus-on/commit/e551925))
207
+
208
+
209
+
210
+ # [1.3.0](https://github.com/theKashey/react-focus-on/compare/v1.2.1...v1.3.0) (2018-11-13)
211
+
212
+
213
+ ### Features
214
+
215
+ * expose gapMode ([0298cc8](https://github.com/theKashey/react-focus-on/commit/0298cc8))
216
+
217
+
218
+
219
+ ## [1.2.1](https://github.com/theKashey/react-focus-on/compare/v1.2.0...v1.2.1) (2018-11-13)
220
+
221
+
222
+
223
+ # [1.2.0](https://github.com/theKashey/react-focus-on/compare/v1.1.0...v1.2.0) (2018-11-12)
224
+
225
+
226
+ ### Features
227
+
228
+ * onEscapeKey ([7fb17d7](https://github.com/theKashey/react-focus-on/commit/7fb17d7))
229
+
230
+
231
+
232
+ # [1.1.0](https://github.com/theKashey/react-focus-on/compare/ed4d62b...v1.1.0) (2018-11-07)
233
+
234
+
235
+ ### Features
236
+
237
+ * onClickOutside event ([ed4d62b](https://github.com/theKashey/react-focus-on/commit/ed4d62b))
238
+
239
+
240
+
@@ -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, style = props.style, as = props.as, rest = __rest(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "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, 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,90 @@ 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
73
  /**
74
74
  * [focus-lock] allows "ignoring" focus on some elements
75
75
  * @see {@link https://github.com/theKashey/react-focus-lock#api}
76
76
  */
77
- shouldIgnore?: (candidate: HTMLElement) => boolean;
77
+ shouldIgnore?: ((candidate: HTMLElement) => boolean) | undefined;
78
78
  /**
79
79
  * allows replacement of the host node
80
80
  * @default div
81
81
  */
82
- as?: string | React.ElementType;
83
- style?: React.CSSProperties;
84
- className?: string;
82
+ as?: string | React.ElementType | undefined;
83
+ style?: React.CSSProperties | undefined;
84
+ className?: string | undefined;
85
85
  children: React.ReactNode;
86
86
  }
87
87
  export interface ReactFocusOnSideProps extends ReactFocusOnProps {
88
- sideCar: React.SFC<any>;
88
+ sideCar: React.FC<any>;
89
89
  }
90
90
  export interface EffectProps extends CommonProps {
91
91
  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");
@@ -10,13 +11,14 @@ exports.FocusOn = React.forwardRef(function (props, parentRef) {
10
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, 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
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, 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,90 @@ 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
73
  /**
74
74
  * [focus-lock] allows "ignoring" focus on some elements
75
75
  * @see {@link https://github.com/theKashey/react-focus-lock#api}
76
76
  */
77
- shouldIgnore?: (candidate: HTMLElement) => boolean;
77
+ shouldIgnore?: ((candidate: HTMLElement) => boolean) | undefined;
78
78
  /**
79
79
  * allows replacement of the host node
80
80
  * @default div
81
81
  */
82
- as?: string | React.ElementType;
83
- style?: React.CSSProperties;
84
- className?: string;
82
+ as?: string | React.ElementType | undefined;
83
+ style?: React.CSSProperties | undefined;
84
+ className?: string | undefined;
85
85
  children: React.ReactNode;
86
86
  }
87
87
  export interface ReactFocusOnSideProps extends ReactFocusOnProps {
88
- sideCar: React.SFC<any>;
88
+ sideCar: React.FC<any>;
89
89
  }
90
90
  export interface EffectProps extends CommonProps {
91
91
  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.6.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",
@@ -45,12 +45,12 @@
45
45
  },
46
46
  "dependencies": {
47
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",
48
+ "react-focus-lock": "^2.9.0",
49
+ "react-remove-scroll": "^2.5.2",
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;
@@ -1,2 +0,0 @@
1
- import { ReactFocusOnSideProps } from "./types";
2
- export declare function ReactFocusOn(props: ReactFocusOnSideProps): JSX.Element;
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
- import { RemoveScroll } from 'react-remove-scroll/UI';
3
- import ReactFocusLock from 'react-focus-lock/UI';
4
- var extractRef = function (ref) { return (('current' in ref) ? ref.current : ref); };
5
- export function ReactFocusOn(props) {
6
- var _a = React.useState(null), lockProps = _a[0], setLockProps = _a[1];
7
- var _b = this.props, children = _b.children, autoFocus = _b.autoFocus, shards = _b.shards, _c = _b.enabled, enabled = _c === void 0 ? true : _c, _d = _b.scrollLock, scrollLock = _d === void 0 ? true : _d, _e = _b.focusLock, focusLock = _e === void 0 ? true : _e, sideCar = _b.sideCar;
8
- return (React.createElement(React.Fragment, null,
9
- React.createElement(RemoveScroll, { sideCar: enabled && sideCar, enabled: enabled && scrollLock, shards: shards },
10
- enabled && React.createElement(Effect, null),
11
- React.createElement(ReactFocusLock, { sideCar: enabled && sideCar, disabled: !(this.state.lockProps && enabled && focusLock), returnFocus: true, autoFocus: autoFocus, onActivation: this.onActivation, onDeactivation: this.onDeactivation, shards: shards, lockProps: lockProps }, children))));
12
- }
@@ -1,2 +0,0 @@
1
- import { ReactFocusOnSideProps } from "./types";
2
- export declare function ReactFocusOn(props: ReactFocusOnSideProps): JSX.Element;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var React = require("react");
4
- var UI_1 = require("react-remove-scroll/UI");
5
- var UI_2 = require("react-focus-lock/UI");
6
- var InteractivityDisabler_1 = require("./InteractivityDisabler");
7
- var extractRef = function (ref) { return (('current' in ref) ? ref.current : ref); };
8
- function ReactFocusOn(props) {
9
- var _a = React.useState(null), lockProps = _a[0], setLockProps = _a[1];
10
- var _b = this.props, children = _b.children, autoFocus = _b.autoFocus, shards = _b.shards, _c = _b.enabled, enabled = _c === void 0 ? true : _c, _d = _b.scrollLock, scrollLock = _d === void 0 ? true : _d, _e = _b.focusLock, focusLock = _e === void 0 ? true : _e, sideCar = _b.sideCar;
11
- return (React.createElement(React.Fragment, null,
12
- React.createElement(UI_1.RemoveScroll, { sideCar: enabled && sideCar, enabled: enabled && scrollLock, shards: shards },
13
- enabled && React.createElement(InteractivityDisabler_1.InteractivityDisabler, null),
14
- React.createElement(UI_2.default, { sideCar: enabled && sideCar, disabled: !(this.state.lockProps && enabled && focusLock), returnFocus: true, autoFocus: autoFocus, onActivation: this.onActivation, onDeactivation: this.onDeactivation, shards: shards, lockProps: lockProps }, children))));
15
- }
16
- exports.ReactFocusOn = ReactFocusOn;