react-focus-on 3.9.4 → 3.10.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.
@@ -50,15 +50,15 @@ export function Effect(_a) {
50
50
  mouseTouches.current = event.touches.length;
51
51
  };
52
52
  if (activeNode) {
53
- document.addEventListener('keydown', onKeyDown);
54
- document.addEventListener('mousedown', onMouseDown);
55
- document.addEventListener('touchstart', onTouchStart);
56
- document.addEventListener('touchend', onTouchEnd);
53
+ activeNode.ownerDocument.addEventListener('keydown', onKeyDown);
54
+ activeNode.ownerDocument.addEventListener('mousedown', onMouseDown);
55
+ activeNode.ownerDocument.addEventListener('touchstart', onTouchStart);
56
+ activeNode.ownerDocument.addEventListener('touchend', onTouchEnd);
57
57
  return function () {
58
- document.removeEventListener('keydown', onKeyDown);
59
- document.removeEventListener('mousedown', onMouseDown);
60
- document.removeEventListener('touchstart', onTouchStart);
61
- document.removeEventListener('touchend', onTouchEnd);
58
+ activeNode.ownerDocument.removeEventListener('keydown', onKeyDown);
59
+ activeNode.ownerDocument.removeEventListener('mousedown', onMouseDown);
60
+ activeNode.ownerDocument.removeEventListener('touchstart', onTouchStart);
61
+ activeNode.ownerDocument.removeEventListener('touchend', onTouchEnd);
62
62
  };
63
63
  }
64
64
  }, [activeNode, onClickOutside, onEscapeKey]);
@@ -79,7 +79,7 @@ export function Effect(_a) {
79
79
  var unmounted = false;
80
80
  var onNodeActivation = function (node) {
81
81
  if (!noIsolation) {
82
- _undo = hideOthers(__spreadArrays([node], (shards || []).map(extractRef)), document.body, focusHiddenMarker);
82
+ _undo = hideOthers(__spreadArrays([node], (shards || []).map(extractRef)), node.ownerDocument.body, focusHiddenMarker);
83
83
  }
84
84
  setActiveNode(function () { return node; });
85
85
  };
@@ -53,15 +53,15 @@ function Effect(_a) {
53
53
  mouseTouches.current = event.touches.length;
54
54
  };
55
55
  if (activeNode) {
56
- document.addEventListener('keydown', onKeyDown);
57
- document.addEventListener('mousedown', onMouseDown);
58
- document.addEventListener('touchstart', onTouchStart);
59
- document.addEventListener('touchend', onTouchEnd);
56
+ activeNode.ownerDocument.addEventListener('keydown', onKeyDown);
57
+ activeNode.ownerDocument.addEventListener('mousedown', onMouseDown);
58
+ activeNode.ownerDocument.addEventListener('touchstart', onTouchStart);
59
+ activeNode.ownerDocument.addEventListener('touchend', onTouchEnd);
60
60
  return function () {
61
- document.removeEventListener('keydown', onKeyDown);
62
- document.removeEventListener('mousedown', onMouseDown);
63
- document.removeEventListener('touchstart', onTouchStart);
64
- document.removeEventListener('touchend', onTouchEnd);
61
+ activeNode.ownerDocument.removeEventListener('keydown', onKeyDown);
62
+ activeNode.ownerDocument.removeEventListener('mousedown', onMouseDown);
63
+ activeNode.ownerDocument.removeEventListener('touchstart', onTouchStart);
64
+ activeNode.ownerDocument.removeEventListener('touchend', onTouchEnd);
65
65
  };
66
66
  }
67
67
  }, [activeNode, onClickOutside, onEscapeKey]);
@@ -82,7 +82,7 @@ function Effect(_a) {
82
82
  var unmounted = false;
83
83
  var onNodeActivation = function (node) {
84
84
  if (!noIsolation) {
85
- _undo = aria_hidden_1.hideOthers(tslib_1.__spreadArrays([node], (shards || []).map(extractRef)), document.body, medium_1.focusHiddenMarker);
85
+ _undo = aria_hidden_1.hideOthers(tslib_1.__spreadArrays([node], (shards || []).map(extractRef)), node.ownerDocument.body, medium_1.focusHiddenMarker);
86
86
  }
87
87
  setActiveNode(function () { return node; });
88
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-focus-on",
3
- "version": "3.9.4",
3
+ "version": "3.10.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": {
@@ -44,19 +44,19 @@
44
44
  "ts-react-toolbox": "^0.2.10"
45
45
  },
46
46
  "dependencies": {
47
- "aria-hidden": "^1.2.2",
48
- "react-focus-lock": "^2.11.3",
49
- "react-remove-scroll": "^2.6.0",
50
- "react-style-singleton": "^2.2.1",
47
+ "aria-hidden": "^1.2.5",
48
+ "react-focus-lock": "^2.13.6",
49
+ "react-remove-scroll": "^2.6.3",
50
+ "react-style-singleton": "^2.2.3",
51
51
  "tslib": "^2.3.1",
52
- "use-sidecar": "^1.1.2"
52
+ "use-sidecar": "^1.1.3"
53
53
  },
54
54
  "engines": {
55
55
  "node": ">=8.5.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0",
59
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
58
+ "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
59
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@types/react": {
@@ -81,5 +81,6 @@
81
81
  "resolutions": {
82
82
  "typescript": "^3.8.0"
83
83
  },
84
- "homepage": "https://github.com/theKashey/react-focus-on#readme"
84
+ "homepage": "https://github.com/theKashey/react-focus-on#readme",
85
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
85
86
  }
@@ -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;