@wordpress/components
Version:
UI components for WordPress.
1 lines • 1.3 kB
Source Map (JSON)
{"version":3,"file":"overlay-middlewares.mjs","names":[],"sources":["../../src/popover/overlay-middlewares.tsx"],"sourcesContent":["import type { MiddlewareState } from '@floating-ui/react-dom';\nimport { size } from '@floating-ui/react-dom';\n\nexport function overlayMiddlewares() {\n\treturn [\n\t\t{\n\t\t\tname: 'overlay',\n\t\t\tfn( { rects }: MiddlewareState ) {\n\t\t\t\treturn rects.reference;\n\t\t\t},\n\t\t},\n\t\tsize( {\n\t\t\tapply( { rects, elements } ) {\n\t\t\t\tconst { firstElementChild } = elements.floating ?? {};\n\n\t\t\t\t// Only HTMLElement instances have the `style` property.\n\t\t\t\tif ( ! ( firstElementChild instanceof HTMLElement ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\tObject.assign( firstElementChild.style, {\n\t\t\t\t\twidth: `${ rects.reference.width }px`,\n\t\t\t\t\theight: `${ rects.reference.height }px`,\n\t\t\t\t} );\n\t\t\t},\n\t\t} ),\n\t];\n}\n"],"mappings":";;AAGA,SAAgB,qBAAqB;CACpC,OAAO,CACN;EACC,MAAM;EACN,GAAI,EAAE,SAA2B;GAChC,OAAO,MAAM;EACd;CACD,GACA,KAAM,EACL,MAAO,EAAE,OAAO,YAAa;EAC5B,MAAM,EAAE,sBAAsB,SAAS,YAAY,CAAC;EAGpD,IAAK,EAAI,6BAA6B,cACrC;EAID,OAAO,OAAQ,kBAAkB,OAAO;GACvC,OAAO,GAAI,MAAM,UAAU,MAAO;GAClC,QAAQ,GAAI,MAAM,UAAU,OAAQ;EACrC,CAAE;CACH,EACD,CAAE,CACH;AACD"}