feat(ui): remember expanded media geometry independently

This commit is contained in:
Codex
2026-11-17 21:24:09 +03:00
parent 13309f3209
commit bcc121e7b2
6 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
"dependencies": { "dependencies": {
"@nodedc/page-patterns": "0.1.0", "@nodedc/page-patterns": "0.1.0",
"@nodedc/ui-core": "0.7.4", "@nodedc/ui-core": "0.7.4",
"@nodedc/ui-react": "0.7.9", "@nodedc/ui-react": "0.7.10",
"cesium": "1.147.0", "cesium": "1.147.0",
"react": "^19.1.0", "react": "^19.1.0",
"react-dom": "^19.1.0" "react-dom": "^19.1.0"
+1 -1
View File
@@ -627,4 +627,4 @@ keeps the shared drag handle and activation threshold. The default stays vertica
Для ручки поверх фотографии используйте `DragHandle surface="control"` или `SortableList handleSurface="control"`: видимый круг с общим стеклом внутри `nodedc-viewport-controls`. Bare-ручка остаётся вариантом по умолчанию для обычных строк. Для ручки поверх фотографии используйте `DragHandle surface="control"` или `SortableList handleSurface="control"`: видимый круг с общим стеклом внутри `nodedc-viewport-controls`. Bare-ручка остаётся вариантом по умолчанию для обычных строк.
Window `headerLayout="adaptive"` keeps contextual actions on one trailing row. The complete title moves below actions before clipping. The measured action width sets the minimum for all resize edges, keyboard resizing and restored layout; only an undersized device viewport allows horizontal action scrolling. `expanded` temporarily fits the window to the available viewport while retaining modal/floating presentation. Users can resize the expanded window; restoration returns the previous geometry without persisting the temporary rectangle. Window `headerLayout="adaptive"` keeps contextual actions on one trailing row. The complete title moves below actions before clipping. The measured action width sets the minimum for all resize edges, keyboard resizing and restored layout; only an undersized device viewport allows horizontal action scrolling. `expanded` temporarily opens media at a moderate viewport-fitted size while retaining modal/floating presentation. Users can resize the expanded window; restoration returns the previous geometry without changing the regular rectangle. `expandedRect` / `onExpandedRectCommit` persist the user’s separate expanded position and dimensions; first expansion uses a moderate 960×800 ceiling within 80%/82% of the viewport.
+2 -2
View File
@@ -29,7 +29,7 @@
"dependencies": { "dependencies": {
"@nodedc/page-patterns": "0.1.0", "@nodedc/page-patterns": "0.1.0",
"@nodedc/ui-core": "0.7.4", "@nodedc/ui-core": "0.7.4",
"@nodedc/ui-react": "0.7.9", "@nodedc/ui-react": "0.7.10",
"cesium": "1.147.0", "cesium": "1.147.0",
"react": "^19.1.0", "react": "^19.1.0",
"react-dom": "^19.1.0" "react-dom": "^19.1.0"
@@ -2530,7 +2530,7 @@
}, },
"packages/ui-react": { "packages/ui-react": {
"name": "@nodedc/ui-react", "name": "@nodedc/ui-react",
"version": "0.7.9", "version": "0.7.10",
"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 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@nodedc/ui-react", "name": "@nodedc/ui-react",
"version": "0.7.9", "version": "0.7.10",
"type": "module", "type": "module",
"files": [ "files": [
"dist" "dist"
+11 -4
View File
@@ -44,6 +44,9 @@ export interface WindowProps extends Omit<HTMLAttributes<HTMLDivElement>, "title
headerLayout?: "inline" | "adaptive"; headerLayout?: "inline" | "adaptive";
/** Temporarily enlarge within the viewport; restoring retains prior geometry and presentation. */ /** Temporarily enlarge within the viewport; restoring retains prior geometry and presentation. */
expanded?: boolean; expanded?: boolean;
/** Separate durable layout for expanded media, committed only after a user gesture. */
expandedRect?: WindowRect;
onExpandedRectCommit?: (rect: WindowRect) => void;
/** Keep contextual actions immediately before close when requested. */ /** Keep contextual actions immediately before close when requested. */
headerActionsPlacement?: "before-move" | "before-close"; headerActionsPlacement?: "before-move" | "before-close";
size?: WindowSize; size?: WindowSize;
@@ -78,6 +81,8 @@ export function Window({
headerActions, headerActions,
headerLayout = "inline", headerLayout = "inline",
expanded = false, expanded = false,
expandedRect,
onExpandedRectCommit,
headerActionsPlacement = "before-move", headerActionsPlacement = "before-move",
size = "md", size = "md",
placement = "center", placement = "center",
@@ -119,7 +124,7 @@ export function Window({
const expansionRestoreRef = useRef<WindowRect | null>(null); const expansionRestoreRef = useRef<WindowRect | null>(null);
const commitRef = useRef(onRectCommit); const commitRef = useRef(onRectCommit);
// Temporary media expansion never replaces the application-owned window layout. // Temporary media expansion never replaces the application-owned window layout.
commitRef.current = expanded ? undefined : onRectCommit; commitRef.current = expanded ? onExpandedRectCommit : onRectCommit;
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);
@@ -226,7 +231,9 @@ export function Window({
const bounds=dialogRef.current?.getBoundingClientRect(); const bounds=dialogRef.current?.getBoundingClientRect();
if(bounds){ if(bounds){
expansionRestoreRef.current=rectRef.current??{left:bounds.left,top:bounds.top,width:bounds.width,height:bounds.height}; expansionRestoreRef.current=rectRef.current??{left:bounds.left,top:bounds.top,width:bounds.width,height:bounds.height};
changeRect(fitWindow({left:16,top:16,width:viewport.width-32,height:viewport.height-32},viewport,minimumRef.current)); const width=Math.min(960,viewport.width*0.8),height=Math.min(800,viewport.height*0.82);
const prior=expansionRestoreRef.current;
changeRect(fitWindow(expandedRect??{left:prior.left+(prior.width-width)/2,top:prior.top+(prior.height-height)/2,width,height},viewport,minimumRef.current));
} }
} }
return; return;
@@ -292,10 +299,10 @@ export function Window({
useEffect(() => { useEffect(() => {
if (!freeGeometry || !open) return; if (!freeGeometry || !open) return;
const fit = () => { if(rectRef.current) changeRect(fitWindow((expanded ? null : rect) ?? rectRef.current, { width: window.innerWidth, height: window.innerHeight },minimumRef.current)); }; const fit = () => { if(rectRef.current) changeRect(fitWindow((expanded ? expandedRect : rect) ?? rectRef.current, { width: window.innerWidth, height: window.innerHeight },minimumRef.current)); };
window.addEventListener("resize", fit); window.addEventListener("resize", fit);
return () => window.removeEventListener("resize", fit); return () => window.removeEventListener("resize", fit);
}, [freeGeometry, open, rect, expanded]); }, [freeGeometry, open, rect, expanded, expandedRect]);
if (!open || typeof document === "undefined") return null; if (!open || typeof document === "undefined") return null;
+1 -1
View File
@@ -474,7 +474,7 @@
"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.", "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.",
"Adaptive headers keep actions on one row, place the full title below before clipping, and derive the resize minimum from actual actions. Expanded media fits the viewport temporarily, remains resizable and restores the previous rectangle without overwriting durable geometry." "Adaptive headers keep actions on one row, place the full title below before clipping, and derive the resize minimum from actual actions. Expanded media opens at a moderate size and remains resizable. Separate expandedRect/onExpandedRectCommit preferences restore its user-chosen position and dimensions; returning restores regular geometry."
] ]
}, },
{ {