@wordpress/block-editor
Version:
51 lines (49 loc) • 1.46 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = SingleInputControl;
var _spacingInputControl = _interopRequireDefault(require("./spacing-input-control"));
var _utils = require("../utils");
var _jsxRuntime = require("react/jsx-runtime");
/**
* Internal dependencies
*/
function SingleInputControl({
minimumCustomValue,
onChange,
onMouseOut,
onMouseOver,
showSideInLabel,
side,
spacingSizes,
type,
values
}) {
const createHandleOnChange = currentSide => next => {
// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
const nextValues = {
...Object.keys(values).reduce((acc, key) => {
acc[key] = (0, _utils.getPresetValueFromCustomValue)(values[key], spacingSizes);
return acc;
}, {})
};
nextValues[currentSide] = next;
onChange(nextValues);
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_spacingInputControl.default, {
label: _utils.LABELS[side],
minimumCustomValue: minimumCustomValue,
onChange: createHandleOnChange(side),
onMouseOut: onMouseOut,
onMouseOver: onMouseOver,
showSideInLabel: showSideInLabel,
side: side,
spacingSizes: spacingSizes,
type: type,
value: values[side],
withInputField: false
});
}
//# sourceMappingURL=single.js.map