react-focus-lock
Advanced tools
Comparing version 2.13.2 to 2.13.3
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,8 +9,6 @@ value: true | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var constants = _interopRequireWildcard(require("focus-lock/constants")); | ||
var _constants = require("focus-lock/constants"); | ||
var _util = require("./util"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } | ||
var AutoFocusInside = function AutoFocusInside(_ref) { | ||
@@ -23,3 +20,3 @@ var _ref$disabled = _ref.disabled, | ||
className = _ref$className === void 0 ? undefined : _ref$className; | ||
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _util.inlineProp)(constants.FOCUS_AUTO, !disabled), { | ||
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _util.inlineProp)(_constants.FOCUS_AUTO, !disabled), { | ||
className: className | ||
@@ -26,0 +23,0 @@ }), children); |
@@ -8,3 +8,3 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
@@ -36,7 +36,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } | ||
var SideEffect = function SideEffect(props) { | ||
var lastProps = React.useRef(props); | ||
React.useEffect(function () { | ||
var lastProps = (0, _react.useRef)(props); | ||
(0, _react.useEffect)(function () { | ||
lastProps.current = props; | ||
}); | ||
React.useEffect(function () { | ||
(0, _react.useEffect)(function () { | ||
console.log('ins added'); | ||
@@ -50,3 +50,3 @@ mountedInstances.push(lastProps); | ||
}, []); | ||
return /*#__PURE__*/React.createElement(WrappedComponent, props); | ||
return /*#__PURE__*/_react["default"].createElement(WrappedComponent, props); | ||
}; | ||
@@ -53,0 +53,0 @@ return SideEffect; |
@@ -11,3 +11,3 @@ "use strict"; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _Lock = _interopRequireDefault(require("./Lock")); | ||
@@ -17,4 +17,4 @@ var _Trap = _interopRequireDefault(require("./Trap")); | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } | ||
var FocusLockCombination = /*#__PURE__*/React.forwardRef(function FocusLockUICombination(props, ref) { | ||
return /*#__PURE__*/React.createElement(_Lock["default"], (0, _extends2["default"])({ | ||
var FocusLockCombination = /*#__PURE__*/(0, _react.forwardRef)(function FocusLockUICombination(props, ref) { | ||
return /*#__PURE__*/_react["default"].createElement(_Lock["default"], (0, _extends2["default"])({ | ||
sideCar: _Trap["default"], | ||
@@ -21,0 +21,0 @@ ref: ref |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.hiddenGuard = exports["default"] = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
@@ -26,3 +26,3 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
children = _ref$children === void 0 ? null : _ref$children; | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { | ||
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("div", { | ||
key: "guard-first", | ||
@@ -32,3 +32,3 @@ "data-focus-guard": true, | ||
style: hiddenGuard | ||
}), children, children && /*#__PURE__*/React.createElement("div", { | ||
}), children, children && /*#__PURE__*/_react["default"].createElement("div", { | ||
key: "guard-last", | ||
@@ -35,0 +35,0 @@ "data-focus-guard": true, |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,12 +9,10 @@ value: true | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var constants = _interopRequireWildcard(require("focus-lock/constants")); | ||
var _constants = require("focus-lock/constants"); | ||
var _util = require("./util"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } | ||
var FreeFocusInside = function FreeFocusInside(_ref) { | ||
var children = _ref.children, | ||
className = _ref.className; | ||
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _util.inlineProp)(constants.FOCUS_ALLOW, true), { | ||
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _util.inlineProp)(_constants.FOCUS_ALLOW, true), { | ||
className: className | ||
@@ -22,0 +19,0 @@ }), children); |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import { FC, Component, RefObject, FocusEventHandler } from 'react'; | ||
import {ReactFocusLockProps, AutoFocusProps, FreeFocusProps, InFocusGuardProps} from "./interfaces.js"; | ||
@@ -8,3 +8,3 @@ | ||
*/ | ||
declare const ReactFocusLock: React.FC<ReactFocusLockProps>; | ||
declare const ReactFocusLock: FC<ReactFocusLockProps>; | ||
@@ -16,3 +16,3 @@ export default ReactFocusLock; | ||
*/ | ||
export class AutoFocusInside extends React.Component<AutoFocusProps> { | ||
export class AutoFocusInside extends Component<AutoFocusProps> { | ||
} | ||
@@ -23,3 +23,3 @@ | ||
*/ | ||
export class MoveFocusInside extends React.Component<AutoFocusProps> { | ||
export class MoveFocusInside extends Component<AutoFocusProps> { | ||
} | ||
@@ -30,3 +30,3 @@ | ||
*/ | ||
export class FreeFocusInside extends React.Component<FreeFocusProps> { | ||
export class FreeFocusInside extends Component<FreeFocusProps> { | ||
} | ||
@@ -37,3 +37,3 @@ | ||
*/ | ||
export class InFocusGuard extends React.Component<InFocusGuardProps> { | ||
export class InFocusGuard extends Component<InFocusGuardProps> { | ||
} | ||
@@ -44,3 +44,3 @@ | ||
*/ | ||
export function useFocusInside(node: React.RefObject<HTMLElement>): void; | ||
export function useFocusInside(node: RefObject<HTMLElement>): void; | ||
@@ -122,3 +122,3 @@ export type FocusOptions = { | ||
*/ | ||
onFocus: React.FocusEventHandler<T>; | ||
onFocus: FocusEventHandler<T>; | ||
/** | ||
@@ -128,3 +128,3 @@ * reference to the node | ||
*/ | ||
ref: React.RefObject<T>; | ||
} | ||
ref: RefObject<T>; | ||
} |
@@ -1,5 +0,4 @@ | ||
import * as React from 'react'; | ||
import {Ref} from "react"; | ||
import { Ref, ReactNode, ElementType, RefObject } from "react"; | ||
export interface ReactFocusLockProps<ChildrenType = React.ReactNode, LockProps = Record<string, any>> { | ||
export interface ReactFocusLockProps<ChildrenType = ReactNode, LockProps = Record<string, any>> { | ||
disabled?: boolean; | ||
@@ -93,3 +92,3 @@ | ||
*/ | ||
as?: string | React.ElementType<LockProps & { children: ChildrenType }>, | ||
as?: string | ElementType<LockProps & { children: ChildrenType }>, | ||
lockProps?: LockProps, | ||
@@ -109,3 +108,3 @@ | ||
*/ | ||
shards?: Array<React.RefObject<any> | HTMLElement>; | ||
shards?: Array<RefObject<any> | HTMLElement>; | ||
@@ -116,3 +115,3 @@ children?: ChildrenType; | ||
export interface AutoFocusProps { | ||
children: React.ReactNode; | ||
children: ReactNode; | ||
disabled?: boolean; | ||
@@ -123,3 +122,3 @@ className?: string; | ||
export interface FreeFocusProps { | ||
children: React.ReactNode; | ||
children: ReactNode; | ||
className?: string; | ||
@@ -129,3 +128,3 @@ } | ||
export interface InFocusGuardProps { | ||
children?: React.ReactNode; | ||
children?: ReactNode; | ||
} |
@@ -13,5 +13,5 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = require("prop-types"); | ||
var constants = _interopRequireWildcard(require("focus-lock/constants")); | ||
var _constants = require("focus-lock/constants"); | ||
var _useCallbackRef = require("use-callback-ref"); | ||
@@ -26,13 +26,13 @@ var _FocusGuard = require("./FocusGuard"); | ||
var emptyArray = []; | ||
var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parentRef) { | ||
var _React$useState = React.useState(), | ||
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2), | ||
realObserved = _React$useState2[0], | ||
setObserved = _React$useState2[1]; | ||
var observed = React.useRef(); | ||
var isActive = React.useRef(false); | ||
var originalFocusedElement = React.useRef(null); | ||
var _React$useState3 = React.useState({}), | ||
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2), | ||
update = _React$useState4[1]; | ||
var FocusLock = /*#__PURE__*/(0, _react.forwardRef)(function FocusLockUI(props, parentRef) { | ||
var _useState = (0, _react.useState)(), | ||
_useState2 = (0, _slicedToArray2["default"])(_useState, 2), | ||
realObserved = _useState2[0], | ||
setObserved = _useState2[1]; | ||
var observed = (0, _react.useRef)(); | ||
var isActive = (0, _react.useRef)(false); | ||
var originalFocusedElement = (0, _react.useRef)(null); | ||
var _useState3 = (0, _react.useState)({}), | ||
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2), | ||
update = _useState4[1]; | ||
var children = props.children, | ||
@@ -66,6 +66,6 @@ _props$disabled = props.disabled, | ||
onDeactivationCallback = props.onDeactivation; | ||
var _React$useState5 = React.useState({}), | ||
_React$useState6 = (0, _slicedToArray2["default"])(_React$useState5, 1), | ||
id = _React$useState6[0]; | ||
var onActivation = React.useCallback(function (_ref) { | ||
var _useState5 = (0, _react.useState)({}), | ||
_useState6 = (0, _slicedToArray2["default"])(_useState5, 1), | ||
id = _useState6[0]; | ||
var onActivation = (0, _react.useCallback)(function (_ref) { | ||
var captureFocusRestore = _ref.captureFocusRestore; | ||
@@ -86,3 +86,3 @@ if (!originalFocusedElement.current) { | ||
}, [onActivationCallback]); | ||
var onDeactivation = React.useCallback(function () { | ||
var onDeactivation = (0, _react.useCallback)(function () { | ||
isActive.current = false; | ||
@@ -94,3 +94,3 @@ if (onDeactivationCallback) { | ||
}, [onDeactivationCallback]); | ||
var returnFocus = React.useCallback(function (allowDefer) { | ||
var returnFocus = (0, _react.useCallback)(function (allowDefer) { | ||
var focusRestore = originalFocusedElement.current; | ||
@@ -113,3 +113,3 @@ if (focusRestore) { | ||
}, [shouldReturnFocus]); | ||
var onFocus = React.useCallback(function (event) { | ||
var onFocus = (0, _react.useCallback)(function (event) { | ||
if (isActive.current) { | ||
@@ -120,3 +120,3 @@ _medium.mediumFocus.useMedium(event); | ||
var onBlur = _medium.mediumBlur.useMedium; | ||
var setObserveNode = React.useCallback(function (newObserved) { | ||
var setObserveNode = (0, _react.useCallback)(function (newObserved) { | ||
if (observed.current !== newObserved) { | ||
@@ -131,3 +131,3 @@ observed.current = newObserved; | ||
} | ||
React.useEffect(function () { | ||
(0, _react.useEffect)(function () { | ||
if (!observed.current && typeof Container !== 'string') { | ||
@@ -138,7 +138,7 @@ console.error('FocusLock: could not obtain ref to internal node'); | ||
} | ||
var lockProps = _objectSpread((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, constants.FOCUS_DISABLED, disabled && 'disabled'), constants.FOCUS_GROUP, group), containerProps); | ||
var lockProps = _objectSpread((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, _constants.FOCUS_DISABLED, disabled && 'disabled'), _constants.FOCUS_GROUP, group), containerProps); | ||
var hasLeadingGuards = noFocusGuards !== true; | ||
var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail'; | ||
var mergedRef = (0, _useCallbackRef.useMergeRefs)([parentRef, setObserveNode]); | ||
var focusScopeValue = React.useMemo(function () { | ||
var focusScopeValue = (0, _react.useMemo)(function () { | ||
return { | ||
@@ -151,5 +151,5 @@ observed: observed, | ||
}, [disabled, isActive.current, shards, realObserved]); | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeadingGuards && [ | ||
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, hasLeadingGuards && [ | ||
/*#__PURE__*/ | ||
React.createElement("div", { | ||
_react["default"].createElement("div", { | ||
key: "guard-first", | ||
@@ -159,3 +159,3 @@ "data-focus-guard": true, | ||
style: _FocusGuard.hiddenGuard | ||
}), hasPositiveIndices ? /*#__PURE__*/React.createElement("div", { | ||
}), hasPositiveIndices ? /*#__PURE__*/_react["default"].createElement("div", { | ||
key: "guard-nearest", | ||
@@ -165,3 +165,3 @@ "data-focus-guard": true, | ||
style: _FocusGuard.hiddenGuard | ||
}) : null], !disabled && /*#__PURE__*/React.createElement(SideCar, { | ||
}) : null], !disabled && /*#__PURE__*/_react["default"].createElement(SideCar, { | ||
id: id, | ||
@@ -181,3 +181,3 @@ sideCar: _medium.mediumSidecar, | ||
noFocusGuards: noFocusGuards | ||
}), /*#__PURE__*/React.createElement(Container, (0, _extends2["default"])({ | ||
}), /*#__PURE__*/_react["default"].createElement(Container, (0, _extends2["default"])({ | ||
ref: mergedRef | ||
@@ -188,5 +188,5 @@ }, lockProps, { | ||
onFocus: onFocus | ||
}), /*#__PURE__*/React.createElement(_scope.focusScope.Provider, { | ||
}), /*#__PURE__*/_react["default"].createElement(_scope.focusScope.Provider, { | ||
value: focusScopeValue | ||
}, children)), hasTailingGuards && /*#__PURE__*/React.createElement("div", { | ||
}, children)), hasTailingGuards && /*#__PURE__*/_react["default"].createElement("div", { | ||
"data-focus-guard": true, | ||
@@ -193,0 +193,0 @@ tabIndex: disabled ? -1 : 0, |
@@ -10,5 +10,5 @@ "use strict"; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var constants = _interopRequireWildcard(require("focus-lock/constants")); | ||
var _constants = require("focus-lock/constants"); | ||
var _util = require("./util"); | ||
@@ -19,3 +19,3 @@ var _medium = require("./medium"); | ||
var useFocusInside = exports.useFocusInside = function useFocusInside(observedRef) { | ||
React.useEffect(function () { | ||
(0, _react.useEffect)(function () { | ||
var enabled = true; | ||
@@ -40,5 +40,5 @@ _medium.mediumEffect.useMedium(function (car) { | ||
children = _ref.children; | ||
var ref = React.useRef(null); | ||
var ref = (0, _react.useRef)(null); | ||
useFocusInside(isDisabled ? undefined : ref); | ||
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _util.inlineProp)(constants.FOCUS_AUTO, !isDisabled), { | ||
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _util.inlineProp)(_constants.FOCUS_AUTO, !isDisabled), { | ||
ref: ref, | ||
@@ -45,0 +45,0 @@ className: className |
@@ -1,5 +0,5 @@ | ||
import * as React from "react"; | ||
import { FC } from 'react'; | ||
declare var sidecar: React.FC; | ||
declare var sidecar: FC; | ||
export default sidecar; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,3 +9,3 @@ value: true | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
@@ -17,4 +16,2 @@ var _reactClientsideEffect = _interopRequireDefault(require("react-clientside-effect")); | ||
var _medium = require("./medium"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } | ||
var focusOnBody = function focusOnBody() { | ||
@@ -193,3 +190,3 @@ return document && document.activeElement === document.body; | ||
var children = _ref5.children; | ||
return /*#__PURE__*/React.createElement("div", { | ||
return /*#__PURE__*/_react["default"].createElement("div", { | ||
onBlur: onBlur, | ||
@@ -196,0 +193,0 @@ onFocus: onFocus |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import { FC, Component, RefObject, FocusEventHandler } from 'react'; | ||
import {ReactFocusLockProps, AutoFocusProps, FreeFocusProps, InFocusGuardProps} from "./interfaces.js"; | ||
@@ -7,3 +7,3 @@ | ||
*/ | ||
declare const ReactFocusLock: React.FC<ReactFocusLockProps & { sideCar: React.FC<any> }>; | ||
declare const ReactFocusLock: FC<ReactFocusLockProps & { sideCar: FC<any> }>; | ||
@@ -15,3 +15,3 @@ export default ReactFocusLock; | ||
*/ | ||
export class AutoFocusInside extends React.Component<AutoFocusProps> { | ||
export class AutoFocusInside extends Component<AutoFocusProps> { | ||
} | ||
@@ -22,3 +22,3 @@ | ||
*/ | ||
export class MoveFocusInside extends React.Component<AutoFocusProps> { | ||
export class MoveFocusInside extends Component<AutoFocusProps> { | ||
} | ||
@@ -29,3 +29,3 @@ | ||
*/ | ||
export class FreeFocusInside extends React.Component<FreeFocusProps> { | ||
export class FreeFocusInside extends Component<FreeFocusProps> { | ||
} | ||
@@ -36,3 +36,3 @@ | ||
*/ | ||
export class InFocusGuard extends React.Component<InFocusGuardProps> { | ||
export class InFocusGuard extends Component<InFocusGuardProps> { | ||
} | ||
@@ -43,3 +43,3 @@ | ||
*/ | ||
export function useFocusInside(node: React.RefObject<HTMLElement>): void; | ||
export function useFocusInside(node: RefObject<HTMLElement>): void; | ||
@@ -121,3 +121,3 @@ export type FocusOptions = { | ||
*/ | ||
onFocus: React.FocusEventHandler<T>; | ||
onFocus: FocusEventHandler<T>; | ||
/** | ||
@@ -127,3 +127,3 @@ * reference to the node | ||
*/ | ||
ref: React.RefObject<T>; | ||
} | ||
ref: RefObject<T>; | ||
} |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import * as constants from 'focus-lock/constants'; | ||
import { FOCUS_AUTO } from 'focus-lock/constants'; | ||
import { inlineProp } from './util'; | ||
@@ -12,3 +12,3 @@ var AutoFocusInside = function AutoFocusInside(_ref) { | ||
className = _ref$className === void 0 ? undefined : _ref$className; | ||
return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(constants.FOCUS_AUTO, !disabled), { | ||
return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(FOCUS_AUTO, !disabled), { | ||
className: className | ||
@@ -15,0 +15,0 @@ }), children); |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import React, { useEffect, useRef } from 'react'; | ||
function withSideEffect(reducePropsToState, handleStateChangeOnClient) { | ||
@@ -26,7 +26,7 @@ if (process.env.NODE_ENV !== 'production') { | ||
var SideEffect = function SideEffect(props) { | ||
var lastProps = React.useRef(props); | ||
React.useEffect(function () { | ||
var lastProps = useRef(props); | ||
useEffect(function () { | ||
lastProps.current = props; | ||
}); | ||
React.useEffect(function () { | ||
useEffect(function () { | ||
console.log('ins added'); | ||
@@ -33,0 +33,0 @@ mountedInstances.push(lastProps); |
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import * as React from 'react'; | ||
import React, { forwardRef } from 'react'; | ||
import FocusLockUI from './Lock'; | ||
import FocusTrap from './Trap'; | ||
var FocusLockCombination = /*#__PURE__*/React.forwardRef(function FocusLockUICombination(props, ref) { | ||
var FocusLockCombination = /*#__PURE__*/forwardRef(function FocusLockUICombination(props, ref) { | ||
return /*#__PURE__*/React.createElement(FocusLockUI, _extends({ | ||
@@ -8,0 +8,0 @@ sideCar: FocusTrap, |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import React, { Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
@@ -15,3 +15,3 @@ export var hiddenGuard = { | ||
children = _ref$children === void 0 ? null : _ref$children; | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { | ||
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", { | ||
key: "guard-first", | ||
@@ -18,0 +18,0 @@ "data-focus-guard": true, |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import * as constants from 'focus-lock/constants'; | ||
import { FOCUS_ALLOW } from 'focus-lock/constants'; | ||
import { inlineProp } from './util'; | ||
@@ -9,3 +9,3 @@ var FreeFocusInside = function FreeFocusInside(_ref) { | ||
className = _ref.className; | ||
return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(constants.FOCUS_ALLOW, true), { | ||
return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(FOCUS_ALLOW, true), { | ||
className: className | ||
@@ -12,0 +12,0 @@ }), children); |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import * as React from 'react'; | ||
import React, { forwardRef, useRef, useState, useCallback, useEffect, useMemo, Fragment } from 'react'; | ||
import { node, bool, string, any, arrayOf, oneOfType, object, func } from 'prop-types'; | ||
import * as constants from 'focus-lock/constants'; | ||
import { FOCUS_DISABLED, FOCUS_GROUP } from 'focus-lock/constants'; | ||
import { useMergeRefs } from 'use-callback-ref'; | ||
@@ -10,12 +10,12 @@ import { hiddenGuard } from './FocusGuard'; | ||
var emptyArray = []; | ||
var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parentRef) { | ||
var FocusLock = /*#__PURE__*/forwardRef(function FocusLockUI(props, parentRef) { | ||
var _extends2; | ||
var _React$useState = React.useState(), | ||
realObserved = _React$useState[0], | ||
setObserved = _React$useState[1]; | ||
var observed = React.useRef(); | ||
var isActive = React.useRef(false); | ||
var originalFocusedElement = React.useRef(null); | ||
var _React$useState2 = React.useState({}), | ||
update = _React$useState2[1]; | ||
var _useState = useState(), | ||
realObserved = _useState[0], | ||
setObserved = _useState[1]; | ||
var observed = useRef(); | ||
var isActive = useRef(false); | ||
var originalFocusedElement = useRef(null); | ||
var _useState2 = useState({}), | ||
update = _useState2[1]; | ||
var children = props.children, | ||
@@ -49,5 +49,5 @@ _props$disabled = props.disabled, | ||
onDeactivationCallback = props.onDeactivation; | ||
var _React$useState3 = React.useState({}), | ||
id = _React$useState3[0]; | ||
var onActivation = React.useCallback(function (_ref) { | ||
var _useState3 = useState({}), | ||
id = _useState3[0]; | ||
var onActivation = useCallback(function (_ref) { | ||
var captureFocusRestore = _ref.captureFocusRestore; | ||
@@ -68,3 +68,3 @@ if (!originalFocusedElement.current) { | ||
}, [onActivationCallback]); | ||
var onDeactivation = React.useCallback(function () { | ||
var onDeactivation = useCallback(function () { | ||
isActive.current = false; | ||
@@ -76,3 +76,3 @@ if (onDeactivationCallback) { | ||
}, [onDeactivationCallback]); | ||
var returnFocus = React.useCallback(function (allowDefer) { | ||
var returnFocus = useCallback(function (allowDefer) { | ||
var focusRestore = originalFocusedElement.current; | ||
@@ -95,3 +95,3 @@ if (focusRestore) { | ||
}, [shouldReturnFocus]); | ||
var onFocus = React.useCallback(function (event) { | ||
var onFocus = useCallback(function (event) { | ||
if (isActive.current) { | ||
@@ -102,3 +102,3 @@ mediumFocus.useMedium(event); | ||
var onBlur = mediumBlur.useMedium; | ||
var setObserveNode = React.useCallback(function (newObserved) { | ||
var setObserveNode = useCallback(function (newObserved) { | ||
if (observed.current !== newObserved) { | ||
@@ -113,3 +113,3 @@ observed.current = newObserved; | ||
} | ||
React.useEffect(function () { | ||
useEffect(function () { | ||
if (!observed.current && typeof Container !== 'string') { | ||
@@ -120,7 +120,7 @@ console.error('FocusLock: could not obtain ref to internal node'); | ||
} | ||
var lockProps = _extends((_extends2 = {}, _extends2[constants.FOCUS_DISABLED] = disabled && 'disabled', _extends2[constants.FOCUS_GROUP] = group, _extends2), containerProps); | ||
var lockProps = _extends((_extends2 = {}, _extends2[FOCUS_DISABLED] = disabled && 'disabled', _extends2[FOCUS_GROUP] = group, _extends2), containerProps); | ||
var hasLeadingGuards = noFocusGuards !== true; | ||
var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail'; | ||
var mergedRef = useMergeRefs([parentRef, setObserveNode]); | ||
var focusScopeValue = React.useMemo(function () { | ||
var focusScopeValue = useMemo(function () { | ||
return { | ||
@@ -133,3 +133,3 @@ observed: observed, | ||
}, [disabled, isActive.current, shards, realObserved]); | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeadingGuards && [ | ||
return /*#__PURE__*/React.createElement(Fragment, null, hasLeadingGuards && [ | ||
/*#__PURE__*/ | ||
@@ -136,0 +136,0 @@ React.createElement("div", { |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import * as React from 'react'; | ||
import React, { useEffect, useRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import * as constants from 'focus-lock/constants'; | ||
import { FOCUS_AUTO } from 'focus-lock/constants'; | ||
import { inlineProp } from './util'; | ||
import { mediumEffect } from './medium'; | ||
export var useFocusInside = function useFocusInside(observedRef) { | ||
React.useEffect(function () { | ||
useEffect(function () { | ||
var enabled = true; | ||
@@ -28,5 +28,5 @@ mediumEffect.useMedium(function (car) { | ||
children = _ref.children; | ||
var ref = React.useRef(null); | ||
var ref = useRef(null); | ||
useFocusInside(isDisabled ? undefined : ref); | ||
return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(constants.FOCUS_AUTO, !isDisabled), { | ||
return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(FOCUS_AUTO, !isDisabled), { | ||
ref: ref, | ||
@@ -33,0 +33,0 @@ className: className |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
@@ -3,0 +3,0 @@ import withSideEffect from 'react-clientside-effect'; |
{ | ||
"name": "react-focus-lock", | ||
"version": "2.13.2", | ||
"version": "2.13.3", | ||
"description": "It is a trap! (for a focus)", | ||
@@ -18,5 +18,5 @@ "main": "dist/cjs/index.js", | ||
"build": "rm -Rf ./dist && yarn build:es5 && yarn build:cjs && yarn build:dts", | ||
"test": "npm run test:pick -- '_tests/**/*spec.js'", | ||
"test": "yarn test:pick -- '_tests/**/*spec.js'", | ||
"test:pick": "NODE_ENV=cjs mocha --require @babel/register --require global-jsdom/register --require _tests/spinup/scaffolding --exit", | ||
"prepublish": "npm run lint:fix && npm run build && npm run changelog", | ||
"prepublish": "yarn lint:fix && yarn build && yarn changelog", | ||
"lint": "eslint src", | ||
@@ -23,0 +23,0 @@ "lint:fix": "eslint src --fix", |
@@ -425,3 +425,3 @@ <div align="left"> | ||
- manage a focus. Use this library | ||
- block document scroll. Use [react-scroll-locky](https://github.com/theKashey/react-scroll-locky). | ||
- block document scroll. Use [react-remove-scroll](https://github.com/theKashey/react-remove-scroll). | ||
- hide everything else from screen readers. Use [aria-hidden](https://github.com/theKashey/aria-hidden) | ||
@@ -428,0 +428,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110652
2289