@wordpress/components
Version:
UI components for WordPress.
1 lines • 1.69 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","names":["createHigherOrderComponent","useState","useCallback","useFocusOutside"],"sources":["../../../src/higher-order/with-focus-outside/index.tsx"],"sourcesContent":["import { useCallback, useState } from '@wordpress/element';\nimport {\n\tcreateHigherOrderComponent,\n\t__experimentalUseFocusOutside as useFocusOutside,\n} from '@wordpress/compose';\n\nexport default createHigherOrderComponent(\n\t( WrappedComponent ) =>\n\t\tfunction WithFocusOutside( props ) {\n\t\t\tconst [ handleFocusOutside, setHandleFocusOutside ] = useState<\n\t\t\t\tundefined | ( ( event: React.FocusEvent ) => void )\n\t\t\t>( undefined );\n\n\t\t\tconst bindFocusOutsideHandler = useCallback<\n\t\t\t\t( node: React.FocusEvent ) => void\n\t\t\t>(\n\t\t\t\t( node: any ) =>\n\t\t\t\t\tsetHandleFocusOutside( () =>\n\t\t\t\t\t\tnode?.handleFocusOutside\n\t\t\t\t\t\t\t? node.handleFocusOutside.bind( node )\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t),\n\t\t\t\t[]\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<div { ...useFocusOutside( handleFocusOutside ) }>\n\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\tref={ bindFocusOutsideHandler }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t},\n\t'withFocusOutside'\n);\n"],"mappings":";;;;;;;;;AAMA,IAAA,8BAAA,GAAeA,mBAAAA,2BAAAA,EACZ,qBACD,SAAS,iBAAkB,OAAQ;CAClC,MAAM,CAAE,oBAAoB,0BAAA,GAA0BC,mBAAAA,SAAAA,CAEnD,KAAA,CAAU;CAEb,MAAM,2BAAA,GAA0BC,mBAAAA,YAAAA,EAG7B,SACD,4BACC,MAAM,qBACH,KAAK,mBAAmB,KAAM,IAAK,IACnC,KAAA,CACJ,GACD,CAAC,CACF;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,IAAA,GAAKC,mBAAAA,8BAAAA,CAAiB,kBAAmB;EAC7C,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAD;GACC,KAAM;GACN,GAAK;EACL,CAAA;CACG,CAAA;AAEP,GACD,kBACD"}