@wordpress/components
Version:
UI components for WordPress.
1 lines • 1.44 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/higher-order/with-constrained-tabbing/index.tsx"],"sourcesContent":["import {\n\tcreateHigherOrderComponent,\n\tuseConstrainedTabbing,\n} from '@wordpress/compose';\n\n/**\n * `withConstrainedTabbing` is a React [higher-order component](https://facebook.github.io/react/docs/higher-order-components.html)\n * adding the ability to constrain keyboard navigation with the Tab key within a component.\n * For accessibility reasons, some UI components need to constrain Tab navigation, for example\n * modal dialogs or similar UI. Use of this component is recommended only in cases where a way to\n * navigate away from the wrapped component is implemented by other means, usually by pressing\n * the Escape key or using a specific UI control, e.g. a \"Close\" button.\n */\nconst withConstrainedTabbing = createHigherOrderComponent(\n\t( WrappedComponent ) =>\n\t\tfunction ComponentWithConstrainedTabbing( props ) {\n\t\t\tconst ref = useConstrainedTabbing();\n\t\t\treturn (\n\t\t\t\t<div ref={ ref } tabIndex={ -1 }>\n\t\t\t\t\t<WrappedComponent { ...props } />\n\t\t\t\t</div>\n\t\t\t);\n\t\t},\n\t'withConstrainedTabbing'\n);\n\nexport default withConstrainedTabbing;\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,yBAAyB,4BAC5B,qBACD,SAAS,gCAAiC,OAAQ;CACjD,MAAM,MAAM,sBAAsB;CAClC,OACC,oBAAC,OAAD;EAAW;EAAM,UAAW;EAC3B,UAAA,oBAAC,kBAAD,EAAkB,GAAK,MAAS,CAAA;CAC5B,CAAA;AAEP,GACD,wBACD"}