import React, { Fragment } from 'react' import { useTransformHelper, useCursor, usePrefix } from '../../hooks' import { observer } from '@formily/reactive-react' import { CursorStatus } from '@nokecy/designable-core' import { ILineSegment, calcRectOfAxisLineSegment, } from '@nokecy/designable-shared' export const SpaceBlock = observer(() => { const cursor = useCursor() const transformHelper = useTransformHelper() const prefix = usePrefix('aux-space-block') if (cursor.status !== CursorStatus.Dragging) return null const renderRulerBox = (distance: number, type?: string) => { if (type === 'top' || type === 'bottom') { return (
{distance?.toFixed(0)}
) } else if (type === 'left' || type === 'right') { return (
{distance?.toFixed(0)}
) } } const renderDashedLine = (line?: ILineSegment) => { if (!line) return null const rect = calcRectOfAxisLineSegment(line) if (!rect) return null const width = rect.width || 2 const height = rect.height || 2 return ( ) } return ( <> {transformHelper.measurerSpaceBlocks.map( ({ type, crossDragNodesRect, distance, extendsLine }, key) => { return ( {renderDashedLine(extendsLine)}
{renderRulerBox(distance, type)}
) } )} {transformHelper.thresholdSpaceBlocks.map(({ rect }, key) => { return (
) })} ) }) SpaceBlock.displayName = 'SpaceBlock'