Fix build
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useRef, useState, useMemo, useEffect } from 'react';
|
import React, { useRef, useState, useMemo } from 'react';
|
||||||
import { AppConfig, LayoutSplits, Partition } from '../types';
|
import { AppConfig, LayoutSplits, Partition } from '../types';
|
||||||
import { Grid, MousePointer2, Trash2, RotateCcw, X, Move, Settings2 } from 'lucide-react';
|
import { Grid, MousePointer2, Trash2, RotateCcw, X, Move, Settings2 } from 'lucide-react';
|
||||||
|
|
||||||
@@ -18,7 +18,6 @@ type DragTarget =
|
|||||||
|
|
||||||
export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||||
const svgRef = useRef<SVGSVGElement>(null);
|
const svgRef = useRef<SVGSVGElement>(null);
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
const [mode, setMode] = useState<EditMode>('lines');
|
const [mode, setMode] = useState<EditMode>('lines');
|
||||||
|
|
||||||
@@ -148,9 +147,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
|||||||
// --- HOVER LOGIC: MAIN LINES ---
|
// --- HOVER LOGIC: MAIN LINES ---
|
||||||
if (mode === 'lines') {
|
if (mode === 'lines') {
|
||||||
setHoveredMainSplit(null);
|
setHoveredMainSplit(null);
|
||||||
const SNAP = 0.015; // Чувствительность
|
const SNAP = 0.015;
|
||||||
// Check hover existing
|
|
||||||
// (Logic handled in individual line elements via onMouseMove to simplify global handler)
|
|
||||||
|
|
||||||
// Phantom Line
|
// Phantom Line
|
||||||
if (nx > SNAP && nx < 1-SNAP && ny > SNAP && ny < 1-SNAP) {
|
if (nx > SNAP && nx < 1-SNAP && ny > SNAP && ny < 1-SNAP) {
|
||||||
@@ -210,9 +207,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
|||||||
if (foundPart) {
|
if (foundPart) {
|
||||||
setHoveredPartition({ id: foundPart.id, cellKey: key });
|
setHoveredPartition({ id: foundPart.id, cellKey: key });
|
||||||
} else {
|
} else {
|
||||||
// Show Phantom Partition based on movement direction logic
|
// Show Phantom Partition
|
||||||
// If moving more horizontally -> vertical split. Moving vertically -> horizontal split.
|
|
||||||
// Simplified: Distance to edges
|
|
||||||
const distLeft = lx; const distRight = 1 - lx;
|
const distLeft = lx; const distRight = 1 - lx;
|
||||||
const distTop = ly; const distBottom = 1 - ly;
|
const distTop = ly; const distBottom = 1 - ly;
|
||||||
const minX = Math.min(distLeft, distRight);
|
const minX = Math.min(distLeft, distRight);
|
||||||
@@ -266,6 +261,13 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleMainSplitHover = (e: React.MouseEvent, axis: Axis, index: number) => {
|
||||||
|
if (mode !== 'lines' || dragging) return;
|
||||||
|
e.stopPropagation();
|
||||||
|
setHoveredMainSplit({ axis, index });
|
||||||
|
setPhantomMainAxis(null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-slate-900 p-4 rounded-xl shadow-lg border border-slate-800 h-full flex flex-col relative overflow-hidden">
|
<div className="bg-slate-900 p-4 rounded-xl shadow-lg border border-slate-800 h-full flex flex-col relative overflow-hidden">
|
||||||
|
|
||||||
@@ -297,13 +299,13 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
|||||||
{mode === 'lines' ? (
|
{mode === 'lines' ? (
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<span><b className="text-blue-400">ЛКМ:</b> Создать/Тянуть линию</span>
|
<span><b className="text-blue-400">ЛКМ:</b> Создать/Тянуть линию</span>
|
||||||
<span><b className="text-red-400">2xЛКМ / ПКМ:</b> Удалить</span>
|
<span><b className="text-red-400">ПКМ:</b> Удалить</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<span><b className="text-green-400">ЛКМ в ячейке:</b> Создать перегородку</span>
|
<span><b className="text-green-400">ЛКМ в ячейке:</b> Создать перегородку</span>
|
||||||
<span><b className="text-purple-400">Драг:</b> Двигать</span>
|
<span><b className="text-purple-400">Драг:</b> Двигать</span>
|
||||||
<span><b className="text-red-400">2xЛКМ:</b> Удалить</span>
|
<span><b className="text-red-400">ПКМ:</b> Удалить</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -312,7 +314,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
|||||||
<div className="flex-1 bg-slate-800/30 rounded-lg flex flex-col items-center justify-center relative overflow-hidden border border-slate-700/50 min-h-0 w-full">
|
<div className="flex-1 bg-slate-800/30 rounded-lg flex flex-col items-center justify-center relative overflow-hidden border border-slate-700/50 min-h-0 w-full">
|
||||||
|
|
||||||
{/* SVG Container - FILLS SPACE BUT KEEPS ASPECT RATIO */}
|
{/* SVG Container - FILLS SPACE BUT KEEPS ASPECT RATIO */}
|
||||||
<div ref={containerRef} className="relative w-full h-full flex items-center justify-center p-4">
|
<div className="relative w-full h-full flex items-center justify-center p-4">
|
||||||
<div
|
<div
|
||||||
className="relative shadow-2xl bg-[#1e293b] border border-slate-600 rounded-sm overflow-hidden"
|
className="relative shadow-2xl bg-[#1e293b] border border-slate-600 rounded-sm overflow-hidden"
|
||||||
style={{
|
style={{
|
||||||
@@ -330,8 +332,8 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
|||||||
ref={svgRef}
|
ref={svgRef}
|
||||||
viewBox={`0 0 ${viewBoxW} ${viewBoxH}`}
|
viewBox={`0 0 ${viewBoxW} ${viewBoxH}`}
|
||||||
className="w-full h-full touch-none block"
|
className="w-full h-full touch-none block"
|
||||||
preserveAspectRatio="none" // Важно: растягиваем SVG на весь div
|
preserveAspectRatio="none"
|
||||||
onMouseMove={handleGlobalMouseMove}
|
onMouseMove={handleMouseMove}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
onMouseUp={() => setDragging(null)}
|
onMouseUp={() => setDragging(null)}
|
||||||
onMouseLeave={() => setDragging(null)}
|
onMouseLeave={() => setDragging(null)}
|
||||||
@@ -399,7 +401,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{/* Фантомная перегородка (только если наведена мышь на ячейку и нет перегородки под курсором) */}
|
{/* Фантомная перегородка */}
|
||||||
{isHovered && phantomPartition && !hoveredPartition && !dragging && (
|
{isHovered && phantomPartition && !hoveredPartition && !dragging && (
|
||||||
<g className="pointer-events-none opacity-60">
|
<g className="pointer-events-none opacity-60">
|
||||||
{phantomPartition.axis === 'x' ? (
|
{phantomPartition.axis === 'x' ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user