UNPKG

@gechiui/block-editor

Version:
52 lines (46 loc) 1.43 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@gechiui/element"; /** * GeChiUI dependencies */ import { __experimentalUnitControl as UnitControl } from '@gechiui/components'; import { __ } from '@gechiui/i18n'; const CORNERS = { topLeft: __('左上方'), topRight: __('右上方'), bottomLeft: __('左下方'), bottomRight: __('右下方') }; export default function BoxInputControls(_ref) { let { onChange, values: valuesProp, ...props } = _ref; const createHandleOnChange = corner => next => { if (!onChange) { return; } onChange({ ...values, [corner]: next ? next : undefined }); }; // For shorthand style & backwards compatibility, handle flat string value. const values = typeof valuesProp !== 'string' ? valuesProp : { topLeft: valuesProp, topRight: valuesProp, bottomLeft: valuesProp, bottomRight: valuesProp }; // Controls are wrapped in tooltips as visible labels aren't desired here. return createElement("div", { className: "components-border-radius-control__input-controls-wrapper" }, Object.entries(CORNERS).map(_ref2 => { let [key, label] = _ref2; return createElement(UnitControl, _extends({}, props, { key: key, "aria-label": label, value: values[key], onChange: createHandleOnChange(key) })); })); } //# sourceMappingURL=input-controls.js.map