import tld from 'utils/tld' import state, { useSelector } from 'state' import { IconButton, ButtonsRow, breakpoints } from 'components/shared' import { memo } from 'react' import { MoveType, ShapeType } from 'types' import { Trash2 } from 'react-feather' import Tooltip from 'components/tooltip' import { ArrowDownIcon, ArrowUpIcon, AspectRatioIcon, CopyIcon, GroupIcon, LockClosedIcon, LockOpen1Icon, PinBottomIcon, PinTopIcon, RotateCounterClockwiseIcon, } from '@radix-ui/react-icons' function handleRotateCcw() { state.send('ROTATED_CCW') } function handleDuplicate() { state.send('DUPLICATED') } function handleGroup() { state.send('GROUPED') } function handleUngroup() { state.send('UNGROUPED') } function handleLock() { state.send('TOGGLED_SHAPE_LOCK') } function handleAspectLock() { state.send('TOGGLED_SHAPE_ASPECT_LOCK') } function handleMoveToBack() { state.send('MOVED', { type: MoveType.ToBack }) } function handleMoveBackward() { state.send('MOVED', { type: MoveType.Backward }) } function handleMoveForward() { state.send('MOVED', { type: MoveType.Forward }) } function handleMoveToFront() { state.send('MOVED', { type: MoveType.ToFront }) } function handleDelete() { state.send('DELETED') } function ShapesFunctions() { const isAllLocked = useSelector((s) => { const page = tld.getPage(s.data) return s.values.selectedIds.every((id) => page.shapes[id].isLocked) }) const isAllAspectLocked = useSelector((s) => { const page = tld.getPage(s.data) return s.values.selectedIds.every( (id) => page.shapes[id].isAspectRatioLocked ) }) const isAllGrouped = useSelector((s) => { const selectedShapes = tld.getSelectedShapes(s.data) return selectedShapes.every( (shape) => shape.type === ShapeType.Group || (shape.parentId === selectedShapes[0].parentId && selectedShapes[0].parentId !== s.data.currentPageId) ) }) const hasSelection = useSelector((s) => { return tld.getSelectedIds(s.data).size > 0 }) const hasMultipleSelection = useSelector((s) => { return tld.getSelectedIds(s.data).size > 1 }) return ( <> {isAllLocked ? : } ) } export default memo(ShapesFunctions)