UNPKG

@onesy/ui-react

Version:
857 lines (853 loc) 33.2 kB
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; const _excluded = ["ref", "tonal", "color", "version", "render", "updates", "actions", "exclude", "downloadName", "downloadType", "downloadQuality", "viewBox", "strokeColor", "strokeWidth", "svgRef", "valueDefault", "value", "onChange", "onMouseDown", "onClear", "onDownload", "IconClear", "IconDownload", "IconSize", "IconStrokeColor", "IconProps", "SizeProps", "AppendProps", "ToolbarProps", "ToolbarUpdatesProps", "ToolbarActionsProps", "ToggleButtonProps", "ToggleButtonsProps", "DividerProps", "SelectProps", "ListItemProps", "TooltipProps", "PaletteProps", "IconButtonProps", "ColorTextFieldProps", "Component", "className"], _excluded2 = ["ref", "open", "label", "children"], _excluded3 = ["open", "element", "anchorElement", "onClose", "children"], _excluded4 = ["color"], _excluded5 = ["ref", "version", "onUpdate", "onClose"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import React from 'react'; import { elementToCanvas, is, isEnvironment } from '@onesy/utils'; import { classNames, colors, style as styleMethod, useOnesyTheme } from '@onesy/style-react'; import IconMaterialDeleteSweep from '@onesy/icons-material-rounded-react/IconMaterialDeleteSweepW100'; import IconMaterialDownload from '@onesy/icons-material-rounded-react/IconMaterialDownloadW100'; import IconMaterialCropLandscape from '@onesy/icons-material-rounded-react/IconMaterialCropLandscapeW100'; import IconMaterialPalette from '@onesy/icons-material-rounded-react/IconMaterialPaletteW100'; import ListItemElement from '../ListItem'; import SurfaceElement from '../Surface'; import TooltipElement from '../Tooltip'; import TypeElement from '../Type'; import ButtonElement from '../Button'; import LineElement from '../Line'; import SelectElement from '../Select'; import NumericTextFieldElement from '../NumericTextField'; import ToggleButtonsElement from '../ToggleButtons'; import DividerElement from '../Divider'; import ToggleButtonElement from '../ToggleButton'; import ColorTextFieldElement from '../ColorTextField'; import AppendElement from '../Append'; import FadeElement from '../Fade'; import ClickListenerElement from '../ClickListener'; import { staticClassName } from '../utils'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const useStyle = styleMethod(theme => ({ root: { position: 'relative' }, methods: { position: 'absolute', right: '8px', bottom: '8px', padding: `${theme.methods.space.value(0.5, 'px')} ${theme.methods.space.value(1.5, 'px')}` }, svg: { display: 'block', margin: '12px', cursor: 'none', touchAction: 'none', boxShadow: theme.shadows.values.default[1], background: theme.palette.color.neutral[100] }, toolbars: { width: '100%' }, toolbar: { width: '100%', overflowX: 'auto', padding: theme.methods.space.value(1, 'px') }, modal: { padding: theme.methods.space.value(1.5, 'px'), borderRadius: theme.methods.shape.radius.value(1, 'px'), boxShadow: theme.shadows.values.default[2] }, palette: { padding: theme.methods.space.value(1.5, 'px'), borderRadius: theme.methods.shape.radius.value(1, 'px'), boxShadow: theme.shadows.values.default[2] }, paletteItem: { position: 'relative', width: '17px', height: '17px', cursor: 'pointer', borderRadius: theme.methods.shape.radius.value(40, 'px'), boxShadow: theme.shadows.values.default[1], transition: theme.methods.transitions.make('box-shadow'), '&:hover': { boxShadow: theme.shadows.values.default[2] } }, textFieldColor: { flex: '1 1 auto' }, inputColor: { border: 'none', borderRadius: theme.methods.shape.radius.value(40, 'px'), overflow: 'hidden', width: '17px', height: '17px', cursor: 'pointer', boxShadow: theme.shadows.values.default[1], '&::-webkit-color-swatch-wrapper': { padding: '0px' }, '&::-webkit-color-swatch': { border: 'none' } }, divider: { '&.onesy-Divider-root': { margin: '0' } }, divider_middle: { '&.onesy-Divider-root': { opacity: theme.palette.light ? '0.07' : '0.24' } }, divider_end: { '&.onesy-Divider-root': { opacity: theme.palette.light ? '0.14' : '0.4' } } }), { name: 'onesy-Drawing' }); const Drawing = props__ => { const theme = useOnesyTheme(); const l = theme.l; const props = _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyDrawing?.props?.default), props__); const Line = theme?.elements?.Line || LineElement; const ListItem = theme?.elements?.ListItem || ListItemElement; const Surface = theme?.elements?.Surface || SurfaceElement; const Tooltip = theme?.elements?.Tooltip || TooltipElement; const Type = theme?.elements?.Type || TypeElement; const Button = theme?.elements?.Button || ButtonElement; const Select = theme?.elements?.Select || SelectElement; const NumericTextField = theme?.elements?.NumericTextField || NumericTextFieldElement; const ToggleButton = theme?.elements?.ToggleButton || ToggleButtonElement; const ToggleButtons = theme?.elements?.ToggleButtons || ToggleButtonsElement; const Divider = theme?.elements?.Divider || DividerElement; const ColorTextField = theme?.elements?.ColorTextField || ColorTextFieldElement; const Append = theme?.elements?.Append || AppendElement; const Fade = theme?.elements?.Fade || FadeElement; const ClickListener = theme?.elements?.ClickListener || ClickListenerElement; const { ref, tonal = true, color = 'default', version = 'filled', render, updates = true, actions = true, exclude, downloadName = `onesy-drawing.png`, downloadType = 'image/png', downloadQuality = 1, viewBox = '0 0 340 140', strokeColor = '#000000', strokeWidth = 1, svgRef, valueDefault, value: value_, onChange, onMouseDown: onMouseDown_, onClear: onClear_, onDownload: onDownload_, IconClear = IconMaterialDeleteSweep, IconDownload = IconMaterialDownload, IconSize = IconMaterialCropLandscape, IconStrokeColor = IconMaterialPalette, IconProps: IconProps_, SizeProps, AppendProps: AppendProps_, ToolbarProps, ToolbarUpdatesProps, ToolbarActionsProps, ToggleButtonProps: ToggleButtonProps_, ToggleButtonsProps: ToggleButtonsProps_, DividerProps: DividerProps_, SelectProps: SelectProps_, ListItemProps: ListItemProps_, TooltipProps: TooltipProps_, PaletteProps, IconButtonProps, ColorTextFieldProps, Component = 'div', className } = props, other = _objectWithoutProperties(props, _excluded); const { classes } = useStyle(); const [value, setValue] = React.useState((valueDefault !== undefined ? valueDefault : value_) || []); const [mouseDown, setMouseDown] = React.useState(false); const [move, setMove] = React.useState({}); const [loading, setLoading] = React.useState(false); const [inputValues, setInputValues] = React.useState({ viewBox: '0 0 340 140', width: 340, widthInput: 340, height: 140, heightInput: 140, strokeWidth: 1, strokeColor: '#000000' }); const [open, setOpen] = React.useState({}); const refs = { root: React.useRef(undefined), inputValues: React.useRef(undefined), svg: React.useRef(undefined), value: React.useRef(undefined), mouseDown: React.useRef(undefined), props: React.useRef(undefined), move: React.useRef(undefined), download: React.useRef(undefined), open: React.useRef(undefined), elements: { size: React.useRef(undefined), strokeColor: React.useRef(undefined) } }; refs.value.current = value; refs.open.current = open; refs.props.current = props; refs.inputValues.current = inputValues; refs.download.current = { name: downloadName, type: downloadType, quality: downloadQuality }; refs.mouseDown.current = mouseDown; refs.move.current = move; const updateValue = valueNew => { if (!props.hasOwnProperty('value')) setValue(valueNew); if (is('function', onChange)) onChange(valueNew); }; const updateInputValues = (property, itemValue) => { setInputValues(values => _objectSpread(_objectSpread({}, values), {}, { [property]: itemValue })); }; const updateOpen = (property_0, itemValue_0) => { setOpen(values_0 => _objectSpread(_objectSpread({}, values_0), {}, { [property_0]: itemValue_0 })); }; React.useEffect(() => { const onMouseUp = () => { if (refs.mouseDown.current) setMouseDown(false); }; const onMouseMove = event => { const x = event.clientX; const y = event.clientY; const rect = refs.svg.current?.getBoundingClientRect(); if (!rect) return; const { x: xRoot, y: yRoot } = rect; const valueMove = { x: x - xRoot, y: y - yRoot }; update(valueMove); }; const onTouchMove = event_0 => { const x_0 = event_0.touches[0].clientX; const y_0 = event_0.touches[0].clientY; const rect_0 = refs.svg.current?.getBoundingClientRect(); if (!rect_0) return; const { x: xRoot_0, y: yRoot_0 } = rect_0; const valueMove_0 = { x: x_0 - xRoot_0, y: y_0 - yRoot_0 }; update(valueMove_0); }; const update = valueNew_0 => { if (refs.mouseDown.current) { // Update // relative value from the previous one how much x and y moved const x_1 = valueNew_0?.x; const y_1 = valueNew_0?.y; const previous = refs.value.current?.[refs.value.current?.length - 1]; if (previous) { if (!(x_1 === 0 && y_1 === 0)) { previous.d += ` ${x_1},${y_1}`; updateValue([...refs.value.current]); } } } setMove(valueNew_0); }; const rootDocument = isEnvironment('browser') ? refs.root.current?.ownerDocument || window.document : undefined; rootDocument.addEventListener('mouseup', onMouseUp); rootDocument.addEventListener('mousemove', onMouseMove); rootDocument.addEventListener('touchend', onMouseUp, { passive: true }); rootDocument.addEventListener('touchmove', onTouchMove); return () => { rootDocument.removeEventListener('mouseup', onMouseUp); rootDocument.removeEventListener('touchend', onMouseUp); rootDocument.removeEventListener('mousemove', onMouseMove); rootDocument.removeEventListener('touchmove', onTouchMove); }; }, []); React.useEffect(() => { if (value_ !== refs.value.current) setValue(value_); }, [value_]); React.useEffect(() => { if (strokeColor !== undefined && strokeColor !== refs.inputValues.current.strokeColor) updateInputValues('strokeColor', strokeColor); if (strokeWidth !== undefined && strokeWidth !== refs.inputValues.current.strokeWidth) updateInputValues('strokeWidth', strokeWidth); }, [strokeColor, strokeWidth]); React.useEffect(() => { if (viewBox !== undefined && viewBox !== refs.inputValues.current.viewBox) { updateInputValues('viewBox', viewBox); updateInputValues('width', viewBox.split(' ')[2]); updateInputValues('height', viewBox.split(' ')[3]); } }, [viewBox]); const onMouseDown = event_1 => { setMouseDown(true); let x_2 = event_1.touches ? event_1.touches[0].clientX : event_1.clientX; let y_2 = event_1.touches ? event_1.touches[0].clientY : event_1.clientY; const rect_1 = refs.svg.current.getBoundingClientRect(); x_2 -= rect_1.x; y_2 -= rect_1.y; setMove({ x: x_2, y: y_2 }); // Create new value path updateValue([...(refs.value.current || []), { d: `M ${x_2},${y_2} L ${x_2} ${y_2}`, stroke: refs.inputValues.current.strokeColor, strokeWidth: refs.inputValues.current.strokeWidth }]); if (is('function', onMouseDown_)) onMouseDown_(event_1); }; const onClear = () => { updateValue([]); if (is('function', onClear_)) onClear_(); }; const onDownload = async () => { const svg = refs.svg.current; const rect_2 = svg.getBoundingClientRect(); // Clean up const clone = svg.cloneNode(true); clone.style.margin = '0px'; clone.style.boxShadow = 'none'; if (refs.download.current.type?.includes('png')) { clone.style.background = 'transparent'; } try { setLoading(true); await elementToCanvas(clone, { response: 'download', filter: ['.onesy-Drawing-pointer'], download: refs.download.current, width: rect_2.width, height: rect_2.height }); } catch (error) {} setLoading(false); if (is('function', onDownload_)) onDownload_(); }; const includes = (...args) => !is('array', exclude) || args.some(item => !exclude.includes(item)); // updates toolbar const updateOptions = ['stroke-color', 'stroke-width', 'size']; const updates_ = updates && (!is('array', exclude) || includes(...updateOptions)); // action toolbar const actions_ = actions && (!is('array', exclude) || includes('clear', 'download')); const AppendProps = _objectSpread({ padding: [14, 14] }, AppendProps_); const DividerProps = _objectSpread({ color: 'inherit' }, DividerProps_); const TooltipProps = _objectSpread({ position: 'bottom', interactive: false }, TooltipProps_); const ToggleButtonsProps = _objectSpread({ tonal, color, version: 'text', border: false }, ToggleButtonsProps_); const ToggleButtonProps = _objectSpread({ size: 'small' }, ToggleButtonProps_); const SelectProps = _objectSpread({ tonal, color: refs.props.current.color !== undefined ? refs.props.current.color : 'themed', version: 'outlined', size: 'small', ListProps: { tonal, color: refs.props.current.color !== undefined ? refs.props.current.color : 'themed' }, MenuProps: { portal: true } }, SelectProps_); const ListItemProps = _objectSpread({ size: 'small', PrimaryProps: { style: { fontFamily: 'inherit' } } }, ListItemProps_); const IconProps = _objectSpread({ size: 'small' }, IconProps_); const WrapperToggleButton = props_ => { const { ref: ref_, open: open_, label, children } = props_, other_ = _objectWithoutProperties(props_, _excluded2); return /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({ ref: ref_, open: open_ !== undefined ? open_ : undefined, name: label }, TooltipProps), {}, { children: /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, other_), children.props)) })); }; const WrapperAppend = props__0 => { const { open: open__0, element, anchorElement, onClose, children: children_0 } = props__0, other__0 = _objectWithoutProperties(props__0, _excluded3); return /*#__PURE__*/_jsx(Append, _objectSpread(_objectSpread({ open: open__0, element: /*#__PURE__*/_jsx("div", { children: /*#__PURE__*/_jsx(Fade, { in: open__0, add: true, children: /*#__PURE__*/React.cloneElement(element) }) }), anchorElement: anchorElement, portal: true, alignment: "center", position: "bottom" }, AppendProps), {}, { children: /*#__PURE__*/React.cloneElement(children_0, _objectSpread(_objectSpread({}, other__0), children_0.props)) })); }; const PaletteItem = props__1 => { const { color: color_ } = props__1, other__1 = _objectWithoutProperties(props__1, _excluded4); return /*#__PURE__*/_jsx("span", _objectSpread({ className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-palette-item'], classes.paletteItem]), style: { background: color_ } }, other__1)); }; const Palette = props__2 => { const { ref: ref__0, version: version_, onUpdate, onClose: onClose_0 } = props__2, other__2 = _objectWithoutProperties(props__2, _excluded5); return /*#__PURE__*/_jsxs(Line, _objectSpread(_objectSpread({ ref: ref__0, gap: 1, direction: "column", tonal: tonal, color: refs.props.current.color !== undefined ? refs.props.current.color : 'themed', Component: Surface, className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-palette'], classes.palette]) }, other__2), {}, { children: [/*#__PURE__*/_jsxs(Line, { gap: 0.5, children: [/*#__PURE__*/_jsxs(Line, { gap: 0.5, direction: "row", style: { width: '100%' }, children: [/*#__PURE__*/_jsx(PaletteItem, { color: "#000000", onClick: () => { onUpdate('#000000'); onClose_0(); } }), /*#__PURE__*/_jsx(PaletteItem, { color: "#ffffff", onClick: () => { onUpdate('#ffffff'); onClose_0(); } })] }), Object.keys(colors).filter(item_0 => !['black', 'white'].includes(item_0)).map((item_1, index) => /*#__PURE__*/_jsx(Line, { gap: 0.5, direction: "row", style: { width: '100%' }, children: Object.keys(colors[item_1]).map((item_, index_) => /*#__PURE__*/_jsx(PaletteItem, { color: colors[item_1][item_], onClick: () => { onUpdate(colors[item_1][item_]); onClose_0(); } }, index_)) }, index))] }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsxs(Line, { gap: 0.5, direction: "row", align: "center", style: { width: '100%' }, children: [/*#__PURE__*/_jsx(ColorTextField, _objectSpread(_objectSpread({ tonal: tonal, color: color, name: l('Custom color'), version: "outlined", size: "small", value: refs.inputValues.current[version_], onChange: valueNew_1 => updateInputValues(version_, valueNew_1) }, ColorTextFieldProps), {}, { className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-text-field-color'], ColorTextFieldProps?.className, classes.textFieldColor]) })), /*#__PURE__*/_jsx(Button, { tonal: tonal, color: "inherit", version: "text", size: "small", onClick: () => { onUpdate(refs.inputValues.current[version_]); onClose_0(); }, children: l('Apply') })] })] })); }; const valueNew_ = (is('array', value) ? value : [value]).filter(Boolean); const valueNewActive = mouseDown && valueNew_[valueNew_.length - 1]; const circleStrokeWidth = +(valueNewActive ? valueNewActive.strokeWidth : refs.inputValues.current.strokeWidth); const stroke_width = [{ label: /*#__PURE__*/_jsxs(Line, { direction: "row", align: "center", children: [/*#__PURE__*/_jsx("div", { style: { width: 14, height: 1, background: theme.palette.text.default.primary } }), /*#__PURE__*/_jsx(Type, { version: "b2", children: "1" })] }), value: 1 }, { label: /*#__PURE__*/_jsxs(Line, { direction: "row", align: "center", children: [/*#__PURE__*/_jsx("div", { style: { width: 14, height: 2, background: theme.palette.text.default.primary } }), /*#__PURE__*/_jsx(Type, { version: "b2", children: "2" })] }), value: 2 }, { label: /*#__PURE__*/_jsxs(Line, { direction: "row", align: "center", children: [/*#__PURE__*/_jsx("div", { style: { width: 14, height: 4, background: theme.palette.text.default.primary } }), /*#__PURE__*/_jsx(Type, { version: "b2", children: "4" })] }), value: 4 }, { label: /*#__PURE__*/_jsxs(Line, { direction: "row", align: "center", children: [/*#__PURE__*/_jsx("div", { style: { width: 14, height: 8, background: theme.palette.text.default.primary } }), /*#__PURE__*/_jsx(Type, { version: "b2", children: "8" })] }), value: 8 }]; return /*#__PURE__*/_jsxs(Surface, _objectSpread(_objectSpread({ ref: item_2 => { if (ref) { if (is('function', ref)) ref(item_2);else ref.current = item_2; } refs.root.current = item_2; }, tonal: tonal, color: color, version: version, Component: Component, className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-root', updates && `onesy-Drawing-updates`, actions && `onesy-Drawing-actions`], className, classes.root]) }, other), {}, { children: [(updates || actions_) && /*#__PURE__*/_jsxs(Line, _objectSpread(_objectSpread({ tonal: tonal, color: color, version: version, gap: 0, direction: "column", align: "unset", justify: "unset", Component: Surface }, ToolbarProps), {}, { className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-toolbars'], ToolbarProps?.className, classes.toolbars]), children: [updates_ && /*#__PURE__*/_jsxs(Line, _objectSpread(_objectSpread({ gap: 2, direction: "row", align: "center", justify: "flex-start" }, ToolbarUpdatesProps), {}, { className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-toolbar'], ToolbarUpdatesProps?.className, classes.toolbar, classes.toolbar_updates]), children: [includes('stroke-width') && /*#__PURE__*/_jsx(Line, { gap: 1, direction: "row", align: "center", justify: "flex-start", children: includes('stroke-width') && /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({ name: l('Stroke Width'), valueDefault: stroke_width.find(item_3 => String(item_3.value).includes('1')).value, value: inputValues['strokeWidth'], onChange: valueNew_2 => updateInputValues('strokeWidth', valueNew_2) }, SelectProps), {}, { className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-select'], SelectProps?.className, classes.select]), style: { minWidth: '90px' }, children: stroke_width.map(item_4 => /*#__PURE__*/_jsx(ListItem, _objectSpread({ primary: item_4.label, value: item_4.value, button: true }, ListItemProps), item_4.value)) })) }), includes('stroke-color') && /*#__PURE__*/_jsx(ToggleButtons, _objectSpread(_objectSpread({}, ToggleButtonsProps), {}, { children: includes('stroke-color') && /*#__PURE__*/_jsx(WrapperAppend, { open: refs.open.current.strokeColor, anchorElement: refs.elements.strokeColor.current, element: /*#__PURE__*/_jsx(ClickListener, { onClickOutside: () => updateOpen('strokeColor', false), include: [refs.elements.strokeColor, refs.elements.strokeColor.current], children: /*#__PURE__*/_jsx(Palette, _objectSpread({ onClose: () => updateOpen('strokeColor', false), onUpdate: valueNew_3 => updateInputValues('strokeColor', valueNew_3) }, PaletteProps)) }), children: /*#__PURE__*/_jsx(WrapperToggleButton, { name: l('Stroke Color'), open: refs.open.current.strokeColor ? false : undefined, children: is('function', render) ? render('stroke-color', ToggleButtonProps, refs.value.current) : /*#__PURE__*/_jsx(ToggleButton, _objectSpread(_objectSpread({ ref: refs.elements.strokeColor }, ToggleButtonProps), {}, { selected: refs.open.current.strokeColor, onClick: () => updateOpen('strokeColor', !refs.open.current.strokeColor), children: /*#__PURE__*/_jsx(IconStrokeColor, _objectSpread({}, IconProps)) })) }) }) })), includes('size') && /*#__PURE__*/_jsx(ToggleButtons, _objectSpread(_objectSpread({}, ToggleButtonsProps), {}, { children: includes('size') && /*#__PURE__*/_jsx(WrapperAppend, { open: refs.open.current.size, anchorElement: refs.elements.size.current, element: /*#__PURE__*/_jsx(ClickListener, { onClickOutside: () => updateOpen('size', false), include: [refs.elements.size], children: /*#__PURE__*/_jsxs(Line, _objectSpread(_objectSpread({ gap: 1, tonal: tonal, color: refs.props.current.color !== undefined ? refs.props.current.color : 'themed', Component: Surface, className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-modal'], classes.modal]) }, SizeProps), {}, { children: [/*#__PURE__*/_jsxs(Line, { gap: 1, direction: "row", align: "center", justify: "center", children: [/*#__PURE__*/_jsx(NumericTextField, { name: l('Width'), tonal: tonal, color: color, size: "small", version: "outlined", min: 1, increment: false, decrement: false, value: refs.inputValues.current.widthInput, onChange: valueNew_4 => updateInputValues('widthInput', !valueNew_4 ? 1 : valueNew_4) }), "\xD7", /*#__PURE__*/_jsx(NumericTextField, { name: l('Height'), tonal: tonal, color: color, size: "small", version: "outlined", min: 1, increment: false, decrement: false, value: refs.inputValues.current.heightInput, onChange: valueNew_5 => updateInputValues('heightInput', !valueNew_5 ? 1 : valueNew_5) })] }), /*#__PURE__*/_jsx(Line, { gap: 1, direction: "row", align: "center", justify: "flex-end", style: { width: '100%' }, children: /*#__PURE__*/_jsx(Button, { tonal: tonal, color: "inherit", version: "text", size: "small", onClick: () => { const viewBox_ = refs.inputValues.current.viewBox?.split(' '); if (viewBox_) { viewBox_[2] = refs.inputValues.current.widthInput; viewBox_[3] = refs.inputValues.current.heightInput; } updateInputValues('viewBox', viewBox_.join(' ')); updateInputValues('width', refs.inputValues.current.widthInput); updateInputValues('height', refs.inputValues.current.heightInput); updateOpen('size', false); }, children: "Update" }) })] })) }), children: /*#__PURE__*/_jsx(WrapperToggleButton, { name: l('Size'), open: refs.open.current.size ? false : undefined, children: is('function', render) ? render('size', ToggleButtonProps, refs.value.current) : /*#__PURE__*/_jsx(ToggleButton, _objectSpread(_objectSpread({ ref: refs.elements.size }, ToggleButtonProps), {}, { selected: refs.open.current.size, onClick: () => updateOpen('size', !refs.open.current.size), children: /*#__PURE__*/_jsx(IconSize, _objectSpread({}, IconProps)) })) }) }) }))] })), updates_ && actions_ && /*#__PURE__*/_jsx(Divider, _objectSpread(_objectSpread({}, DividerProps), {}, { className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-divider'], DividerProps?.className, classes.divider, classes.divider_middle]) })), actions_ && /*#__PURE__*/_jsx(Line, _objectSpread(_objectSpread({ gap: 2, direction: "row", align: "center", justify: "flex-start" }, ToolbarActionsProps), {}, { className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-toolbar'], ToolbarActionsProps?.className, classes.toolbar, classes.toolbar_actions]), children: /*#__PURE__*/_jsxs(Line, { direction: "row", align: "center", justify: "space-between", style: { width: '100%' }, children: [/*#__PURE__*/_jsx(Line, { gap: 2, direction: "row", align: "center", justify: "flex-start", children: includes('clear') && /*#__PURE__*/_jsx(ToggleButtons, _objectSpread(_objectSpread({}, ToggleButtonsProps), {}, { children: includes('clear') && /*#__PURE__*/_jsx(WrapperToggleButton, { name: l('Clear'), children: is('function', render) ? render('clear', ToggleButtonProps, refs.value.current) : /*#__PURE__*/_jsx(ToggleButton, _objectSpread(_objectSpread({}, ToggleButtonProps), {}, { onClick: onClear, children: /*#__PURE__*/_jsx(IconClear, _objectSpread({}, IconProps)) })) }) })) }), /*#__PURE__*/_jsx(Line, { gap: 2, direction: "row", align: "center", justify: "flex-start", children: includes('download') && /*#__PURE__*/_jsx(ToggleButtons, _objectSpread(_objectSpread({}, ToggleButtonsProps), {}, { children: includes('download') && /*#__PURE__*/_jsx(WrapperToggleButton, { name: l('Download'), children: is('function', render) ? render('download', ToggleButtonProps, refs.value.current) : /*#__PURE__*/_jsx(ToggleButton, _objectSpread(_objectSpread({}, ToggleButtonProps), {}, { loading: loading, onClick: onDownload, children: /*#__PURE__*/_jsx(IconDownload, _objectSpread({}, IconProps)) })) }) })) })] }) })), /*#__PURE__*/_jsx(Divider, _objectSpread(_objectSpread({}, DividerProps), {}, { className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-divider'], DividerProps?.className, classes.divider, classes.divider_end]) }))] })), /*#__PURE__*/_jsxs("svg", { ref: item_5 => { if (svgRef) svgRef.current = item_5; refs.svg.current = item_5; }, viewBox: refs.inputValues.current.viewBox, onMouseDown: onMouseDown, onTouchStart: onMouseDown, className: classNames([staticClassName('Drawing', theme) && ['onesy-Drawing-svg'], classes.svg]), style: { width: refs.inputValues.current.width, height: refs.inputValues.current.height }, children: [valueNew_.map((item_6, index_0) => /*#__PURE__*/_jsx("path", _objectSpread({ fill: "none" }, item_6), index_0)), /*#__PURE__*/_jsx("circle", { className: "onesy-Drawing-pointer", cx: move?.x, cy: move?.y, r: circleStrokeWidth + 1, fill: refs.inputValues.current.strokeColor })] })] })); }; Drawing.displayName = 'onesy-Drawing'; export default Drawing;