UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 2.87 kB
{ "version": 3, "sources": ["../../../src/components/block-popover/drop-zone.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopoverCover from './cover';\n\nconst animateVariants = {\n\thide: { opacity: 0, scaleY: 0.75 },\n\tshow: { opacity: 1, scaleY: 1 },\n\texit: { opacity: 0, scaleY: 0.9 },\n};\n\nfunction BlockDropZonePopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { clientId } = useSelect( ( select ) => {\n\t\tconst { getBlockOrder, getBlockInsertionPoint } =\n\t\t\tselect( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tclientId: order[ insertionPoint.index ],\n\t\t};\n\t}, [] );\n\tconst reducedMotion = useReducedMotion();\n\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\tclassName=\"block-editor-block-popover__drop-zone\"\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tdata-testid=\"block-popover-drop-zone\"\n\t\t\t\tinitial={\n\t\t\t\t\treducedMotion ? animateVariants.show : animateVariants.hide\n\t\t\t\t}\n\t\t\t\tanimate={ animateVariants.show }\n\t\t\t\texit={\n\t\t\t\t\treducedMotion ? animateVariants.show : animateVariants.exit\n\t\t\t\t}\n\t\t\t\tclassName=\"block-editor-block-popover__drop-zone-foreground\"\n\t\t\t/>\n\t\t</BlockPopoverCover>\n\t);\n}\n\nexport default BlockDropZonePopover;\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAiC;AACjC,wBAA2C;AAK3C,mBAA0C;AAC1C,mBAA8B;AAmC3B;AAjCH,IAAM,kBAAkB;AAAA,EACvB,MAAM,EAAE,SAAS,GAAG,QAAQ,KAAK;AAAA,EACjC,MAAM,EAAE,SAAS,GAAG,QAAQ,EAAE;AAAA,EAC9B,MAAM,EAAE,SAAS,GAAG,QAAQ,IAAI;AACjC;AAEA,SAAS,qBAAsB;AAAA,EAC9B;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,SAAS,QAAI,uBAAW,CAAE,WAAY;AAC7C,UAAM,EAAE,eAAe,uBAAuB,IAC7C,OAAQ,aAAAA,KAAiB;AAC1B,UAAM,iBAAiB,uBAAuB;AAC9C,UAAM,QAAQ,cAAe,eAAe,YAAa;AAEzD,QAAK,CAAE,MAAM,QAAS;AACrB,aAAO,CAAC;AAAA,IACT;AAEA,WAAO;AAAA,MACN,UAAU,MAAO,eAAe,KAAM;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,oBAAgB,iCAAiB;AAEvC,SACC;AAAA,IAAC,aAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAU;AAAA,MAEV;AAAA,QAAC,kBAAAC,iBAAO;AAAA,QAAP;AAAA,UACA,eAAY;AAAA,UACZ,SACC,gBAAgB,gBAAgB,OAAO,gBAAgB;AAAA,UAExD,SAAU,gBAAgB;AAAA,UAC1B,MACC,gBAAgB,gBAAgB,OAAO,gBAAgB;AAAA,UAExD,WAAU;AAAA;AAAA,MACX;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,oBAAQ;", "names": ["blockEditorStore", "BlockPopoverCover", "motion"] }