UNPKG

geoiq-frontend-ui-kit

Version:

This project is a UI kit for GeoIQ's frontend. It's built with React, TypeScript, and Vite.

98 lines (97 loc) 2.3 kB
import { useCallback as c } from "react"; const L = ({ editorState: s, setEditorState: m, setCanvasElements: D, clearSelection: b, selectImage: h, selectTextBox: u, toggleTextEditing: r, saveStateToHistory: f, transformerRef: k, textBoxRefs: o }) => { const C = c( (a) => { const n = a.target.getStage(); n && (a.target === n || a.target === n.findOne("Image")) && (b(), r(!1), k.current?.nodes([])?.getLayer()?.batchDraw()); }, [b, r] ), X = c( (a, n) => { s.isDrawingMode || (n.cancelBubble = !0, h(a), r(!1)); }, [s.isDrawingMode, h, r] ), d = c( (a, n) => { s.isEditingText || s.isDrawingMode || (n.cancelBubble = !0, u(a)); }, [s.isEditingText, s.isDrawingMode, u] ), x = c( (a, n) => { s.isDrawingMode || (n.cancelBubble = !0, h(null), r(!1)); }, [s.isDrawingMode, h, r] ), e = c( (a) => { s.isEditingText || s.isDrawingMode || (u(a), r(!0)); }, [ s.isEditingText, s.isDrawingMode, u, r ] ), g = c( (a, n) => { const i = n.scaleX(), l = n.scaleY(); D((w) => ({ ...w, squares: w.squares.map( (M, y) => y === a ? { ...M, width: Math.max(30, M.width * i), height: Math.max(30, M.height * l), x: n.x(), y: n.y(), rotation: n.rotation() } : M ) })), n.scaleX(1), n.scaleY(1), f(); }, [f] ), Y = c(() => { m((a) => ({ ...a, isTransforming: !0 })); }, []), p = c( (a) => { const n = o.current[a]; n && (D((i) => ({ ...i, textBoxes: i.textBoxes.map( (l, w) => w === a ? { ...l, width: Math.max(30, l.width * n.scaleX()), rotation: n.rotation(), x: n.x(), y: n.y() } : l ) })), n.scaleX(1), m((i) => ({ ...i, isTransforming: !1 })), f()); }, [f] ); return { handleStageClick: C, handleImageClick: X, handleTextClick: d, handleLineClick: x, handleTextDblClick: e, handleImageTransform: g, handleTextTransformStart: Y, handleTextTransformEnd: p }; }; export { L as useMouseHandlers }; //# sourceMappingURL=index.es103.js.map