@wordpress/components
Version:
UI components for WordPress.
1 lines • 1.96 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","names":["useContext","ToolbarContext","DropdownMenu","ToolbarItem","forwardRef"],"sources":["../../../src/toolbar/toolbar-dropdown-menu/index.tsx"],"sourcesContent":["import { forwardRef, useContext } from '@wordpress/element';\nimport type { ForwardedRef } from 'react';\nimport ToolbarItem from '../toolbar-item';\nimport ToolbarContext from '../toolbar-context';\nimport DropdownMenu from '../../dropdown-menu';\nimport type { DropdownMenuProps } from '../../dropdown-menu/types';\n\nfunction UnforwardedToolbarDropdownMenu(\n\tprops: DropdownMenuProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ! accessibleToolbarState ) {\n\t\treturn <DropdownMenu { ...props } />;\n\t}\n\n\t// ToolbarItem will pass all props to the render prop child, which will pass\n\t// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu\n\t// has the same API as DropdownMenu.\n\treturn (\n\t\t<ToolbarItem ref={ ref } { ...props.toggleProps }>\n\t\t\t{ ( toolbarItemProps ) => (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t...props.popoverProps,\n\t\t\t\t\t} }\n\t\t\t\t\ttoggleProps={ toolbarItemProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ToolbarItem>\n\t);\n}\n\nexport const ToolbarDropdownMenu = forwardRef( UnforwardedToolbarDropdownMenu );\nToolbarDropdownMenu.displayName = 'ToolbarDropdownMenu';\nexport default ToolbarDropdownMenu;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,+BACR,OACA,KACC;CAGD,IAAK,EAAA,GAF0BA,mBAAAA,WAAAA,CAAYC,4BAAAA,OAEf,GAC3B,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,SAAD,EAAc,GAAK,MAAS,CAAA;CAMpC,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,SAAD;EAAmB;EAAM,GAAK,MAAM;EAC/B,WAAA,qBACH,iBAAA,GAAA,kBAAA,IAAA,CAACD,8BAAAA,SAAD;GACC,GAAK;GACL,cAAe,EACd,GAAG,MAAM,aACV;GACA,aAAc;EACd,CAAA;CAEU,CAAA;AAEf;AAEA,MAAa,uBAAA,GAAsBE,mBAAAA,WAAAA,CAAY,8BAA+B;AAC9E,oBAAoB,cAAc"}