feat(ui): add docking, viewport controls and composed settings

Add shared dock layouts, navigation cube, range bands, progress actions and comparison surfaces. Extend toolbar menus and loading composition, and align tokens, registry entries, documentation and the living catalog.
This commit is contained in:
Codex
2026-10-29 09:38:25 +03:00
parent a6e6c8f2d9
commit cb534dbe39
51 changed files with 2273 additions and 336 deletions
+33
View File
@@ -0,0 +1,33 @@
import {useEffect,useRef} from "react";
import {movingToMenu,type MenuPoint} from "@nodedc/ui-core";
import type {DropdownTriggerApi} from "./Dropdown.js";
export function useToolbarMenus() {
const apis=useRef<Record<string,DropdownTriggerApi>>({});
const active=useRef<string|null>(null);
useEffect(()=>{
let previous:MenuPoint|null=null, origin:MenuPoint|null=null, pending:string|null=null, timer:number|undefined;
const clear=()=>{window.clearTimeout(timer);timer=undefined;pending=null;};
const open=(key:string)=>{clear();apis.current[key]?.show();};
const move=(event:PointerEvent)=>{
const current={x:event.clientX,y:event.clientY}, old=previous;previous=current;
const key=active.current;if(!key){clear();origin=null;return;}
const api=apis.current[key], surface=document.getElementById(api?.surfaceId);
const target=event.target instanceof Element?event.target:null;
if(surface?.contains(target)){clear();origin=current;return;}
const button=target?.closest<HTMLButtonElement>('[data-toolbar-menu]');
const next=button?.dataset.toolbarMenu;
if(next===key){clear();origin=current;return;}
if(!next||!apis.current[next]||button?.disabled){clear();return;}
if(!origin)origin=old??current;
const delay=surface&&old&&movingToMenu(origin,old,current,surface.getBoundingClientRect());
if(!delay){open(next);origin=current;return;}
if(pending===next)return;
clear();pending=next;
// Bounded grace: pausing on a sibling still switches, crossing diagonally into the menu does not.
timer=window.setTimeout(()=>open(next),300);
};
document.addEventListener("pointermove",move,{passive:true});
return()=>{clear();document.removeEventListener("pointermove",move);};
},[]);
return {apis,active};
}