feat(ui): remember detail window presentation and sort image grids
This commit is contained in:
@@ -57,6 +57,7 @@ import {
|
|||||||
ShareLinkModal,
|
ShareLinkModal,
|
||||||
SplitPane,
|
SplitPane,
|
||||||
SortableItem,
|
SortableItem,
|
||||||
|
SortableList,
|
||||||
SortableScope,
|
SortableScope,
|
||||||
SettingsCard,
|
SettingsCard,
|
||||||
Switch,
|
Switch,
|
||||||
@@ -406,6 +407,9 @@ export function CatalogApp() {
|
|||||||
const [strokeColor, setStrokeColor] = useState("#2b2b36");
|
const [strokeColor, setStrokeColor] = useState("#2b2b36");
|
||||||
const [strokeOpacity, setStrokeOpacity] = useState(100);
|
const [strokeOpacity, setStrokeOpacity] = useState(100);
|
||||||
const [treeDemoOpen,setTreeDemoOpen]=useState(false);
|
const [treeDemoOpen,setTreeDemoOpen]=useState(false);
|
||||||
|
const [gridOrder,setGridOrder]=useState(["Первое изображение","Второе изображение","Третье изображение"]);
|
||||||
|
const [detailFloating,setDetailFloating]=useState(false);
|
||||||
|
const [detailRect,setDetailRect]=useState<import("@nodedc/ui-react").WindowRect>();
|
||||||
const [treeDemoRect,setTreeDemoRect]=useState({left:32,top:96,width:380,height:480});
|
const [treeDemoRect,setTreeDemoRect]=useState({left:32,top:96,width:380,height:480});
|
||||||
const [treeSelected,setTreeSelected]=useState<string|null>('cells');
|
const [treeSelected,setTreeSelected]=useState<string|null>('cells');
|
||||||
const [treeVisible,setTreeVisible]=useState(true);
|
const [treeVisible,setTreeVisible]=useState(true);
|
||||||
@@ -1549,6 +1553,7 @@ export function CatalogApp() {
|
|||||||
</ResourceList>
|
</ResourceList>
|
||||||
<Button onClick={()=>setTreeDemoOpen(true)}>Дерево объектов · изменяемый размер</Button>
|
<Button onClick={()=>setTreeDemoOpen(true)}>Дерево объектов · изменяемый размер</Button>
|
||||||
<DragDropRoot onDragEnd={()=>{}}><DraggableItem id="whole-material-tile">{({activator})=><Button {...activator.attributes} {...activator.listeners}>Перенос за всю плитку</Button>}</DraggableItem></DragDropRoot>
|
<DragDropRoot onDragEnd={()=>{}}><DraggableItem id="whole-material-tile">{({activator})=><Button {...activator.attributes} {...activator.listeners}>Перенос за всю плитку</Button>}</DraggableItem></DragDropRoot>
|
||||||
|
<SortableList layout="grid" className="catalog-sortable-grid" items={gridOrder} getId={item=>item} onReorder={setGridOrder}>{(item,{handle})=><GlassSurface padding="sm">{handle}<Icon name="image"/><Description>{item}</Description></GlassSurface>}</SortableList>
|
||||||
<SettingsCard title="Устройства не обнаружены" description="Подключите устройство, чтобы оно появилось в списке." />
|
<SettingsCard title="Устройства не обнаружены" description="Подключите устройство, чтобы оно появилось в списке." />
|
||||||
<SettingsCard align="center" role="status" title="Настройки применены" description="Проверьте подключение устройства." />
|
<SettingsCard align="center" role="status" title="Настройки применены" description="Проверьте подключение устройства." />
|
||||||
</Preview>
|
</Preview>
|
||||||
@@ -2401,6 +2406,8 @@ export function CatalogApp() {
|
|||||||
|
|
||||||
<Window
|
<Window
|
||||||
open={createModuleOpen}
|
open={createModuleOpen}
|
||||||
|
floating={detailFloating} onFloatingChange={setDetailFloating}
|
||||||
|
rect={detailRect} onRectCommit={setDetailRect}
|
||||||
title="Создать модуль"
|
title="Создать модуль"
|
||||||
headerActionsPlacement="before-close"
|
headerActionsPlacement="before-close"
|
||||||
headerActions={<IconButton label="Очистить форму" onClick={() => {setCreateModuleName("");setCreateModuleSlug("");}}><Icon name="trash"/></IconButton>}
|
headerActions={<IconButton label="Очистить форму" onClick={() => {setCreateModuleName("");setCreateModuleSlug("");}}><Icon name="trash"/></IconButton>}
|
||||||
|
|||||||
@@ -2307,3 +2307,5 @@ textarea {
|
|||||||
.catalog-theme-fields { display: grid; gap: var(--nodedc-space-4); }
|
.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-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)}
|
||||||
|
|||||||
@@ -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.
|
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.
|
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.
|
||||||
|
|||||||
@@ -175,3 +175,13 @@ ColorField spectrum has no decorative perimeter stroke; retain its visible sampl
|
|||||||
## Focus of movable headers
|
## 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.
|
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.
|
||||||
|
|||||||
Generated
+1
-1
@@ -2530,7 +2530,7 @@
|
|||||||
},
|
},
|
||||||
"packages/ui-react": {
|
"packages/ui-react": {
|
||||||
"name": "@nodedc/ui-react",
|
"name": "@nodedc/ui-react",
|
||||||
"version": "0.7.6",
|
"version": "0.7.7",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nodedc/ui-react",
|
"name": "@nodedc/ui-react",
|
||||||
"version": "0.7.6",
|
"version": "0.7.7",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
arrayMove,
|
arrayMove,
|
||||||
useSortable,
|
useSortable,
|
||||||
verticalListSortingStrategy,
|
verticalListSortingStrategy,
|
||||||
|
rectSortingStrategy,
|
||||||
} from "@dnd-kit/sortable";
|
} from "@dnd-kit/sortable";
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
import { cn } from "./cn.js";
|
import { cn } from "./cn.js";
|
||||||
@@ -120,8 +121,9 @@ export function DropZone({ id, data, className, children }: { id: string; data?:
|
|||||||
return <div ref={setNodeRef} className={cn(className, isOver && "is-drag-over")}>{children}</div>;
|
return <div ref={setNodeRef} className={cn(className, isOver && "is-drag-over")}>{children}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SortableScope({ ids, children }: { ids: string[]; children: ReactNode }) {
|
const SortableLayoutContext=createContext<"list"|"grid">("list");
|
||||||
return <SortableContext items={ids} strategy={verticalListSortingStrategy}>{children}</SortableContext>;
|
export function SortableScope({ ids, children, layout="list" }: { ids: string[]; children: ReactNode; layout?:"list"|"grid" }) {
|
||||||
|
return <SortableLayoutContext.Provider value={layout}><SortableContext items={ids} strategy={layout==="grid"?rectSortingStrategy:verticalListSortingStrategy}>{children}</SortableContext></SortableLayoutContext.Provider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SortableItem({ id, data, className, 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;
|
children: (state: { handle: ReactNode; isDragging: boolean }) => ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id, data });
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={setNodeRef}
|
ref={setNodeRef}
|
||||||
@@ -143,8 +146,9 @@ export function SortableItem({ id, data, className, children }: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SortableList<T>({ items, getId, className, onReorder, children }: {
|
export function SortableList<T>({ items, getId, className, onReorder, children, layout="list" }: {
|
||||||
items: T[];
|
items: T[];
|
||||||
|
layout?: "list" | "grid";
|
||||||
getId: (item: T) => string;
|
getId: (item: T) => string;
|
||||||
className?: string;
|
className?: string;
|
||||||
onReorder: (items: T[]) => void;
|
onReorder: (items: T[]) => void;
|
||||||
@@ -158,7 +162,7 @@ export function SortableList<T>({ items, getId, className, onReorder, children }
|
|||||||
const to = ids.indexOf(overId);
|
const to = ids.indexOf(overId);
|
||||||
if (from >= 0 && to >= 0) onReorder(arrayMove(items, from, to));
|
if (from >= 0 && to >= 0) onReorder(arrayMove(items, from, to));
|
||||||
}}>
|
}}>
|
||||||
<SortableScope ids={ids}>
|
<SortableScope ids={ids} layout={layout}>
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<SortableItem key={getId(item)} id={getId(item)}>
|
<SortableItem key={getId(item)} id={getId(item)}>
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ export interface WindowProps extends Omit<HTMLAttributes<HTMLDivElement>, "title
|
|||||||
onRectCommit?: (rect: WindowRect) => void;
|
onRectCommit?: (rect: WindowRect) => void;
|
||||||
/** Centered windows can become modeless without remounting their contents. */
|
/** Centered windows can become modeless without remounting their contents. */
|
||||||
allowFloating?: boolean;
|
allowFloating?: boolean;
|
||||||
|
/** App-owned presentation, persisted by window kind alongside rect. */
|
||||||
|
floating?: boolean;
|
||||||
|
onFloatingChange?: (floating: boolean) => void;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +86,8 @@ export function Window({
|
|||||||
rect,
|
rect,
|
||||||
onRectCommit,
|
onRectCommit,
|
||||||
allowFloating = true,
|
allowFloating = true,
|
||||||
|
floating: controlledFloating,
|
||||||
|
onFloatingChange,
|
||||||
onClose,
|
onClose,
|
||||||
className,
|
className,
|
||||||
style,
|
style,
|
||||||
@@ -107,7 +112,7 @@ export function Window({
|
|||||||
const changeRect = (next: WindowRect | null) => { rectRef.current = next; setFloatingRect(next); };
|
const changeRect = (next: WindowRect | null) => { rectRef.current = next; setFloatingRect(next); };
|
||||||
const gestureChanged = useRef(false);
|
const gestureChanged = useRef(false);
|
||||||
const resizeRef = useRef<{ pointerId: number; x: number; y: number; rect: WindowRect; edge: ResizeEdge } | null>(null);
|
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 freeGeometry = isFloating || (resizable && placement === "end");
|
||||||
const canDrag = draggable || freeGeometry;
|
const canDrag = draggable || freeGeometry;
|
||||||
const shouldLockBodyScroll = !suspended && !isFloating && (lockBodyScroll ?? placement === "center");
|
const shouldLockBodyScroll = !suspended && !isFloating && (lockBodyScroll ?? placement === "center");
|
||||||
@@ -310,7 +315,9 @@ export function Window({
|
|||||||
const rect = dialogRef.current?.getBoundingClientRect();
|
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 (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);
|
setFloating(!isFloating);
|
||||||
|
onFloatingChange?.(!isFloating);
|
||||||
}}><Icon name="move" /></IconButton>}
|
}}><Icon name="move" /></IconButton>}
|
||||||
{headerActionsPlacement === "before-close" && headerActions}
|
{headerActionsPlacement === "before-close" && headerActions}
|
||||||
<button type="button" className="nodedc-window__close" aria-label={closeLabel} onClick={onClose}>
|
<button type="button" className="nodedc-window__close" aria-label={closeLabel} onClick={onClose}>
|
||||||
|
|||||||
@@ -464,14 +464,15 @@
|
|||||||
"A draggable inspector moves by its header and remains clamped to the viewport.",
|
"A draggable inspector moves by its header and remains clamped to the viewport.",
|
||||||
"Closing a modeless inspector is never gated by autosave; preserve the draft, close immediately and report persistence failure through ToastStack.",
|
"Closing a modeless inspector is never gated by autosave; preserve the draft, close immediately and report persistence failure through ToastStack.",
|
||||||
"Operational copy inside Window uses component typography tokens; browser-default paragraph or heading sizes are forbidden.",
|
"Operational copy inside Window uses component typography tokens; browser-default paragraph or heading sizes are forbidden.",
|
||||||
"Centered windows expose the move toggle by default; allowFloating opts a workflow out. Returning to modal restores canonical centered geometry; closing clears floating geometry.",
|
"Centered windows expose the move toggle by default; allowFloating opts a workflow out. Returning to modal restores canonical centered geometry; uncontrolled windows clear floating geometry on close.",
|
||||||
"Floating header supports arrow-key movement and Shift+arrow resizing. Bounds stay inside the viewport. Resize affordances have no hover decoration.",
|
"Floating header supports arrow-key movement and Shift+arrow resizing. Bounds stay inside the viewport. Resize affordances have no hover decoration.",
|
||||||
"Inspectors inside a Window use its full available content width.",
|
"Inspectors inside a Window use its full available content width.",
|
||||||
"End inspectors opt into resizable with an optional initialRect; existing eight edge geometry and keyboard resize are shared with floating windows.",
|
"End inspectors opt into resizable with an optional initialRect; existing eight edge geometry and keyboard resize are shared with floating windows.",
|
||||||
"Application-owned rect restores modeless window geometry on reopen and external undo/import. onRectCommit reports one completed drag/resize or keyboard step; viewport fitting never overwrites saved geometry.",
|
"Application-owned rect restores modeless window geometry on reopen and external undo/import. onRectCommit reports one completed drag/resize or keyboard step; viewport fitting never overwrites saved geometry.",
|
||||||
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions.",
|
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions.",
|
||||||
"Drag headers never draw perimeter outlines or inherit keyboard-focus fill on pointer grab. Keyboard focus remains visible through the canonical surface; arrows, Shift+arrows and docking shortcuts remain available.",
|
"Drag headers never draw perimeter outlines or inherit keyboard-focus fill on pointer grab. Keyboard focus remains visible through the canonical surface; arrows, Shift+arrows and docking shortcuts remain available.",
|
||||||
"Detached center windows automatically use scene Glass V4; fixed confirmations opt out of detachment with allowFloating=false. Unsaved profile confirmation is owned by the application."
|
"Detached center windows automatically use scene Glass V4; fixed confirmations opt out of detachment with allowFloating=false. Unsaved profile confirmation is owned by the application.",
|
||||||
|
"floating/onFloatingChange and rect/onRectCommit allow durable application-owned presentation by window kind, independent of the currently displayed entity. Reopening restores mode and fitted geometry. Fixed confirmations do not inherit this state."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1126,7 +1127,8 @@
|
|||||||
"A reordered application page array is the single source of truth for both composition and navigation order.",
|
"A reordered application page array is the single source of truth for both composition and navigation order.",
|
||||||
"Optional renderOverlay portals the drag preview above scroll clipping without moving source layout; cancellation clears it.",
|
"Optional renderOverlay portals the drag preview above scroll clipping without moving source layout; cancellation clears it.",
|
||||||
"Pointer drops report client coordinates for consumer-owned canvas hit testing; dropping on empty space never implies an object target.",
|
"Pointer drops report client coordinates for consumer-owned canvas hit testing; dropping on empty space never implies an object target.",
|
||||||
"DraggableItem exposes activator attributes/listeners for whole-tile dragging without a separate handle; the same activation threshold distinguishes clicks from drags."
|
"DraggableItem exposes activator attributes/listeners for whole-tile dragging without a separate handle; the same activation threshold distinguishes clicks from drags.",
|
||||||
|
"SortableList/SortableScope layout=grid uses rectangular sorting and two-axis movement with the same handle-only interaction; list remains vertical by default."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user