UNPKG

@wordpress/components

Version:
31 lines (29 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _compose = require("@wordpress/compose"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * `withConstrainedTabbing` is a React [higher-order component](https://facebook.github.io/react/docs/higher-order-components.html) * adding the ability to constrain keyboard navigation with the Tab key within a component. * For accessibility reasons, some UI components need to constrain Tab navigation, for example * modal dialogs or similar UI. Use of this component is recommended only in cases where a way to * navigate away from the wrapped component is implemented by other means, usually by pressing * the Escape key or using a specific UI control, e.g. a "Close" button. */const withConstrainedTabbing = (0, _compose.createHigherOrderComponent)(WrappedComponent => function ComponentWithConstrainedTabbing(props) { const ref = (0, _compose.useConstrainedTabbing)(); return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { ref: ref, tabIndex: -1, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, { ...props }) }); }, 'withConstrainedTabbing'); var _default = exports.default = withConstrainedTabbing; //# sourceMappingURL=index.js.map