UNPKG

@wordpress/block-editor

Version:
58 lines (50 loc) 1.41 kB
import { createElement } from "@wordpress/element"; /** * WordPress dependencies */ import { RangeControl } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import { cleanEmptyObject } from './utils'; const MIN_BORDER_RADIUS_VALUE = 0; const MAX_BORDER_RADIUS_VALUE = 50; /** * Inspector control panel containing the border radius related configuration. * * @param {Object} props Block properties. * @return {WPElement} Border radius edit element. */ export function BorderRadiusEdit(props) { var _style$border; const { attributes: { style }, setAttributes } = props; const onChange = newRadius => { let newStyle = { ...style, border: { ...(style === null || style === void 0 ? void 0 : style.border), radius: newRadius } }; if (newRadius === undefined) { newStyle = cleanEmptyObject(newStyle); } setAttributes({ style: newStyle }); }; return createElement(RangeControl, { value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius, label: __('Border radius'), min: MIN_BORDER_RADIUS_VALUE, max: MAX_BORDER_RADIUS_VALUE, initialPosition: 0, allowReset: true, onChange: onChange }); } //# sourceMappingURL=border-radius.js.map