import { Button } from "@wordpress/components"; import Responsive from "../responsive/responsive"; import { useDeviceType } from "../../controls/controls"; import { ResetIcon } from "../../icons/icons"; export const BoxSpacing = ({ label, customClass, attributes, attributesKey, setAttributes, boxUnits, units, labelItem, handleReset, onChange = false, }) => { const deviceType = useDeviceType(); const haveDevice = typeof attributes?.device !== "undefined" ? true : false; const attrValue = haveDevice ? attributes?.device?.[deviceType] : attributes?.value; const setSpacingData = (newValue, side) => { const updateValue = haveDevice ? { ...attributes, device: { ...attributes.device, [deviceType]: { ...attributes.device?.[deviceType], [side]: parseInt(newValue), }, }, } : { ...attributes, value: { ...attributes["value"], [side]: parseInt(newValue), }, }; if (onChange) { onChange(attributesKey, updateValue); } else { setAttributes({ [attributesKey]: updateValue, }); } }; const setUnit = (value) => { const updateUnit = haveDevice ? { ...attributes.unit, [deviceType]: value } : value; if (onChange) { onChange(attributesKey, { ...attributes, unit: updateUnit }); } else { setAttributes({ [attributesKey]: { ...attributes, unit: updateUnit, }, }); } }; return (