diff --git a/apps/catalog/src/CatalogApp.tsx b/apps/catalog/src/CatalogApp.tsx index 4d565cb..e52ec67 100644 --- a/apps/catalog/src/CatalogApp.tsx +++ b/apps/catalog/src/CatalogApp.tsx @@ -57,6 +57,7 @@ import { ShareLinkModal, SplitPane, SortableItem, + SortableList, SortableScope, SettingsCard, Switch, @@ -406,6 +407,9 @@ export function CatalogApp() { const [strokeColor, setStrokeColor] = useState("#2b2b36"); const [strokeOpacity, setStrokeOpacity] = useState(100); const [treeDemoOpen,setTreeDemoOpen]=useState(false); + const [gridOrder,setGridOrder]=useState(["Первое изображение","Второе изображение","Третье изображение"]); + const [detailFloating,setDetailFloating]=useState(false); + const [detailRect,setDetailRect]=useState(); const [treeDemoRect,setTreeDemoRect]=useState({left:32,top:96,width:380,height:480}); const [treeSelected,setTreeSelected]=useState('cells'); const [treeVisible,setTreeVisible]=useState(true); @@ -1549,6 +1553,7 @@ export function CatalogApp() { {}}>{({activator})=>} + item} onReorder={setGridOrder}>{(item,{handle})=>{handle}{item}} @@ -2401,6 +2406,8 @@ export function CatalogApp() { {setCreateModuleName("");setCreateModuleSlug("");}}>} diff --git a/apps/catalog/src/styles.css b/apps/catalog/src/styles.css index 78fd1a5..8a544a3 100644 --- a/apps/catalog/src/styles.css +++ b/apps/catalog/src/styles.css @@ -2307,3 +2307,5 @@ textarea { .catalog-theme-fields { display: grid; gap: var(--nodedc-space-4); } .catalog-viewport-actions {position:absolute;top:var(--nodedc-space-3);right:var(--nodedc-space-3);display:flex;gap:var(--nodedc-space-2);padding:var(--nodedc-space-2);} + +.catalog-sortable-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--nodedc-space-3,12px)} diff --git a/docs/COMPONENTS.md b/docs/COMPONENTS.md index 22d3c41..a2a4a74 100644 --- a/docs/COMPONENTS.md +++ b/docs/COMPONENTS.md @@ -617,3 +617,10 @@ ColorField screen sampling (owner direction, 2026-11-14): the shared palette inc Floating EditorDockLayout tools honor minimumSize on restore, all eight resize edges and keyboard resize. If the available viewport is smaller, they fit that viewport; Inspector fields stack below a 330px content width instead of clipping. Tool footer is separate from the scrolling body; a Button width="full" is the canonical adaptive bottom action. The catalog's scene editor example demonstrates minimum size, a ColorField and fixed reset footer. EditorDockLayout: every floating or actively detached tool uses context="scene" Glass V4 (shared scene tint/blur); docking removes that context and retains tiled surface/corner rules. Applies to hierarchy, layers, settings and any other editor tool. No application tint/blur overrides. + +### Remembered detail windows and sortable image grids + +`Window.floating/onFloatingChange` lets the host persist modal/floating mode by +window kind alongside `rect/onRectCommit`. See WINDOWS_AND_LAYERS.md. +`SortableList` and `SortableScope` accept `layout="grid"`; rectangular sorting +keeps the shared drag handle and activation threshold. The default stays vertical. diff --git a/docs/WINDOWS_AND_LAYERS.md b/docs/WINDOWS_AND_LAYERS.md index 9ae2f69..9861eb2 100644 --- a/docs/WINDOWS_AND_LAYERS.md +++ b/docs/WINDOWS_AND_LAYERS.md @@ -175,3 +175,13 @@ ColorField spectrum has no decorative perimeter stroke; retain its visible sampl ## Focus of movable headers Window, WorkspaceWindow and EditorDockLayout share the same drag-header focus contract. A pointer grab never inherits a keyboard focus ring or filled header from the previously focused input. Headers have no perimeter outline in any theme; keyboard focus uses the canonical contrasting surface. Pointer capture, focus ownership, Arrow/Shift+Arrow movement/resizing, Enter/Space docking and Escape cancellation remain unchanged. Check both direct grabbing and input → Tab → grabbing, in docked/floating and fullscreen contexts. + +## Remembered presentation + +Entity/detail windows persist presentation **by window kind**, not title or entity ID. +The application stores `floating` and `rect` in its durable user preferences; +`Window` consumes `floating`/`onFloatingChange` and `rect`/`onRectCommit`. +Opening the next entity restores the same mode, position and size. Return to modal +keeps the last floating rectangle for the next detachment. Viewport fitting does +not overwrite saved geometry. Switching view/edit keeps the same mounted Window. +Confirmation dialogs remain modal (`allowFloating=false`) and never inherit it. diff --git a/package-lock.json b/package-lock.json index fe48f8f..3a2d0e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2530,7 +2530,7 @@ }, "packages/ui-react": { "name": "@nodedc/ui-react", - "version": "0.7.6", + "version": "0.7.7", "dependencies": { "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", diff --git a/packages/ui-react/package.json b/packages/ui-react/package.json index cd8237f..5b193ac 100644 --- a/packages/ui-react/package.json +++ b/packages/ui-react/package.json @@ -1,6 +1,6 @@ { "name": "@nodedc/ui-react", - "version": "0.7.6", + "version": "0.7.7", "type": "module", "files": [ "dist" diff --git a/packages/ui-react/src/DragDrop.tsx b/packages/ui-react/src/DragDrop.tsx index 220b444..54cd4f1 100644 --- a/packages/ui-react/src/DragDrop.tsx +++ b/packages/ui-react/src/DragDrop.tsx @@ -16,6 +16,7 @@ import { arrayMove, useSortable, verticalListSortingStrategy, + rectSortingStrategy, } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; import { cn } from "./cn.js"; @@ -120,8 +121,9 @@ export function DropZone({ id, data, className, children }: { id: string; data?: return
{children}
; } -export function SortableScope({ ids, children }: { ids: string[]; children: ReactNode }) { - return {children}; +const SortableLayoutContext=createContext<"list"|"grid">("list"); +export function SortableScope({ ids, children, layout="list" }: { ids: string[]; children: ReactNode; layout?:"list"|"grid" }) { + return {children}; } export function SortableItem({ id, data, className, children }: { @@ -131,7 +133,8 @@ export function SortableItem({ id, data, className, children }: { children: (state: { handle: ReactNode; isDragging: boolean }) => ReactNode; }) { const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id, data }); - const verticalTransform = transform ? { ...transform, x: 0 } : null; + const layout=useContext(SortableLayoutContext); + const verticalTransform = transform && layout!=="grid" ? { ...transform, x: 0 } : transform; return (
({ items, getId, className, onReorder, children }: { +export function SortableList({ items, getId, className, onReorder, children, layout="list" }: { items: T[]; + layout?: "list" | "grid"; getId: (item: T) => string; className?: string; onReorder: (items: T[]) => void; @@ -158,7 +162,7 @@ export function SortableList({ items, getId, className, onReorder, children } const to = ids.indexOf(overId); if (from >= 0 && to >= 0) onReorder(arrayMove(items, from, to)); }}> - +
{items.map((item) => ( diff --git a/packages/ui-react/src/Window.tsx b/packages/ui-react/src/Window.tsx index 25c5aa6..bcebe37 100644 --- a/packages/ui-react/src/Window.tsx +++ b/packages/ui-react/src/Window.tsx @@ -59,6 +59,9 @@ export interface WindowProps extends Omit, "title onRectCommit?: (rect: WindowRect) => void; /** Centered windows can become modeless without remounting their contents. */ allowFloating?: boolean; + /** App-owned presentation, persisted by window kind alongside rect. */ + floating?: boolean; + onFloatingChange?: (floating: boolean) => void; onClose: () => void; } @@ -83,6 +86,8 @@ export function Window({ rect, onRectCommit, allowFloating = true, + floating: controlledFloating, + onFloatingChange, onClose, className, style, @@ -107,7 +112,7 @@ export function Window({ const changeRect = (next: WindowRect | null) => { rectRef.current = next; setFloatingRect(next); }; const gestureChanged = useRef(false); const resizeRef = useRef<{ pointerId: number; x: number; y: number; rect: WindowRect; edge: ResizeEdge } | null>(null); - const isFloating = floating && allowFloating && placement === "center"; + const isFloating = (controlledFloating ?? floating) && allowFloating && placement === "center"; const freeGeometry = isFloating || (resizable && placement === "end"); const canDrag = draggable || freeGeometry; const shouldLockBodyScroll = !suspended && !isFloating && (lockBodyScroll ?? placement === "center"); @@ -310,7 +315,9 @@ export function Window({ const rect = dialogRef.current?.getBoundingClientRect(); if (rect) changeRect(fitWindow(rectRef.current ?? { left: rect.left, top: rect.top, width: rect.width, height: rect.height }, { width: window.innerWidth, height: window.innerHeight })); } + if (rectRef.current) commitRef.current?.({...rectRef.current}); setFloating(!isFloating); + onFloatingChange?.(!isFloating); }}>} {headerActionsPlacement === "before-close" && headerActions}