@wordpress/components
Version:
UI components for WordPress.
27 lines (26 loc) • 1.4 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_compose = require("@wordpress/compose");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/components/src/higher-order/with-constrained-tabbing/index.tsx
/**
* `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, _wordpress_compose.createHigherOrderComponent)((WrappedComponent) => function ComponentWithConstrainedTabbing(props) {
const ref = (0, _wordpress_compose.useConstrainedTabbing)();
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
ref,
tabIndex: -1,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrappedComponent, { ...props })
});
}, "withConstrainedTabbing");
exports.default = withConstrainedTabbing;
//# sourceMappingURL=index.cjs.map