UNPKG

@wordpress/block-library

Version:
77 lines (75 loc) 1.77 kB
/** * External dependencies */ import clsx from 'clsx'; /** * WordPress dependencies */ import { useState } from '@wordpress/element'; import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; /** * Internal dependencies */ import { unlock } from '../../lock-unlock'; import { jsx as _jsx } from "react/jsx-runtime"; const RESIZABLE_BOX_ENABLE_OPTION = { top: false, right: false, bottom: true, left: false, topRight: false, bottomRight: false, bottomLeft: false, topLeft: false }; const { ResizableBoxPopover } = unlock(blockEditorPrivateApis); export default function ResizableCoverPopover({ className, height, minHeight, onResize, onResizeStart, onResizeStop, showHandle, size, width, ...props }) { const [isResizing, setIsResizing] = useState(false); const resizableBoxProps = { className: clsx(className, { 'is-resizing': isResizing }), enable: RESIZABLE_BOX_ENABLE_OPTION, onResizeStart: (_event, _direction, elt) => { onResizeStart(elt.clientHeight); onResize(elt.clientHeight); }, onResize: (_event, _direction, elt) => { onResize(elt.clientHeight); if (!isResizing) { setIsResizing(true); } }, onResizeStop: (_event, _direction, elt) => { onResizeStop(elt.clientHeight); setIsResizing(false); }, showHandle, size, __experimentalShowTooltip: true, __experimentalTooltipProps: { axis: 'y', position: 'bottom', isVisible: isResizing } }; return /*#__PURE__*/_jsx(ResizableBoxPopover, { className: "block-library-cover__resizable-box-popover", resizableBoxProps: resizableBoxProps, ...props }); } //# sourceMappingURL=resizable-cover-popover.js.map