/* eslint-disable @typescript-eslint/no-explicit-any */ import { SVGContainer, TLComponentProps } from '@tldraw/react' import { TLBoxShape, TLBoxShapeProps } from '@tldraw/core' import { observer } from 'mobx-react-lite' import { CustomStyleProps, withClampedStyles } from './style-props' import { BindingIndicator } from './BindingIndicator' export interface BoxShapeProps extends TLBoxShapeProps, CustomStyleProps { borderRadius: number type: 'box' } export class BoxShape extends TLBoxShape { static id = 'box' static defaultProps: BoxShapeProps = { id: 'box', parentId: 'page', type: 'box', point: [0, 0], size: [100, 100], borderRadius: 2, stroke: '#000000', fill: '', noFill: false, strokeType: 'line', strokeWidth: 2, opacity: 1, } ReactComponent = observer(({ events, isErasing, isBinding, isSelected }: TLComponentProps) => { const { props: { size: [w, h], stroke, fill, noFill, strokeWidth, strokeType, borderRadius, opacity, }, } = this return ( {isBinding && } ) }) ReactIndicator = observer(() => { const { props: { size: [w, h], borderRadius, }, } = this return }) validateProps = (props: Partial) => { if (props.size !== undefined) { props.size[0] = Math.max(props.size[0], 1) props.size[1] = Math.max(props.size[1], 1) } if (props.borderRadius !== undefined) props.borderRadius = Math.max(0, props.borderRadius) return withClampedStyles(this, props) } }