diff --git a/apps/catalog/src/CatalogApp.tsx b/apps/catalog/src/CatalogApp.tsx index 0792f1e..e1583fb 100644 --- a/apps/catalog/src/CatalogApp.tsx +++ b/apps/catalog/src/CatalogApp.tsx @@ -4,8 +4,12 @@ import { createTemplateFeatures, getPageTemplate, pageTemplates, type PageTempla import { ActivityIndicator, LoadingRegion, + Description, + ComparisonTable, StatusBadge, ProgressBar, + ProgressButton, + LayerStackIndicator, AdminNavigationPanel, AppHeader, ApplicationPanel, @@ -19,6 +23,7 @@ import { ControlRow, Dropdown, DragDropRoot, + DockLayout, DockHandle, balancedDockTree, type DockTree, DraggableItem, DropZone, FieldFrame, @@ -37,6 +42,8 @@ import { ResourceRow, ResourceList, SegmentedControl, + SegmentedGroup, + SegmentedButton, Select, ShareAccessModal, ShareLinkModal, @@ -50,6 +57,7 @@ import { ToastCard, ToastStack, Toolbar, + NavigationCube, UserProfileMenu, useApplicationWorkspace, Window, @@ -213,7 +221,7 @@ const iconGroups: Array<{ title: string; note: string; icons: IconName[] }> = [ { title: "Редактирование", note: "Launcher / SEO", - icons: ["save", "edit", "trash", "copy", "upload", "download", "external"], + icons: ["save", "edit", "trash", "copy", "upload", "download", "external", "rotate-clockwise", "add-point", "orthographic", "perspective", "select", "pen", "rectangle", "curve", "undo", "redo"], }, { title: "Состояние и доступ", @@ -233,6 +241,7 @@ const iconGroups: Array<{ title: string; note: string; icons: IconName[] }> = [ ]; const iconLabels: Record = { + "add-point":"Добавить точку",orthographic:"Ортографическая проекция",perspective:"Перспективная проекция",select:"Выделение",pen:"Перо",rectangle:"Прямоугольник",curve:"Кривая",undo:"Отменить",redo:"Повторить", activity: "Активность", alert: "Предупреждение", apps: "Приложения", @@ -275,6 +284,7 @@ const iconLabels: Record = { plus: "Добавить", profile: "Профиль", refresh: "Обновить", + "rotate-clockwise": "Повернуть по часовой стрелке", save: "Сохранить", search: "Поиск", settings: "Настройки", @@ -348,6 +358,7 @@ export function CatalogApp() { const [createModuleDescription, setCreateModuleDescription] = useState(""); const [deleteModuleOpen, setDeleteModuleOpen] = useState(false); const [pageRemovalId, setPageRemovalId] = useState(null); + const [previewLayers, setPreviewLayers] = useState(["source"]); const [applicationMode, setApplicationMode] = useState<"edit" | "preview">("edit"); const [designProfileSaveOpen, setDesignProfileSaveOpen] = useState(false); const [designProfileSaveMode, setDesignProfileSaveMode] = useState<"save" | "save-as">("save"); @@ -365,6 +376,7 @@ export function CatalogApp() { const activePageTemplateId = pageTemplateIdFromView(activeView); const [selectedStatus, setSelectedStatus] = useState<(typeof selectOptions)[number]["value"]>("active"); const [brightness, setBrightness] = useState(49); + const [sliceBand, setSliceBand] = useState<[number, number]>([-1.2, 51.5]); const [glowDistance, setGlowDistance] = useState(105); const [usePortColors, setUsePortColors] = useState(false); const [connectionType, setConnectionType] = useState("spline"); @@ -379,6 +391,7 @@ export function CatalogApp() { const [workspaceWindowDemoOpen, setWorkspaceWindowDemoOpen] = useState(true); const [workspaceWindowDemoMaximized, setWorkspaceWindowDemoMaximized] = useState(false); const [workspaceWindowDemoRect, setWorkspaceWindowDemoRect] = useState({ x: 24, y: 24, width: 340, height: 230 }); + const [dockDemoTree, setDockDemoTree] = useState(() => balancedDockTree(["camera", "depth", "map", "scene"])); const [splitPaneInvisible, setSplitPaneInvisible] = useState(false); const [splitPaneDemoSize, setSplitPaneDemoSize] = useState(50); const [sidePanelDemoOpen, setSidePanelDemoOpen] = useState(true); @@ -424,6 +437,9 @@ export function CatalogApp() { icon512: "/favicon/icon-512.png", }); const pendingFaviconIcoRef = useRef(null); + const [cubeSize,setCubeSize]=useState(66); + const [cubeEdgeOpacity,setCubeEdgeOpacity]=useState(1); + const [cubeDirection,setCubeDirection]=useState([0,0,1]); const [toolbarPlacement, setToolbarPlacement] = useState("bottom"); const [toolbarBg, setToolbarBg] = useState("#111115"); const [toolbarBorder, setToolbarBorder] = useState("#111117"); @@ -432,6 +448,8 @@ export function CatalogApp() { const [toolbarMaxSize, setToolbarMaxSize] = useState(87); const [toolbarLensCount, setToolbarLensCount] = useState(5); const [toolbarAutoHide, setToolbarAutoHide] = useState(false); + const [toolbarHideDelay,setToolbarHideDelay]=useState(5000); + const [toolbarGap,setToolbarGap]=useState(10); const [shareEmail, setShareEmail] = useState(""); const [shareRole, setShareRole] = useState("editor"); const [shareMessage, setShareMessage] = useState(""); @@ -495,6 +513,8 @@ export function CatalogApp() { if (typeof stored.toolbar?.minSize === "number") setToolbarMinSize(stored.toolbar.minSize); if (typeof stored.toolbar?.maxSize === "number") setToolbarMaxSize(stored.toolbar.maxSize); if (typeof stored.toolbar?.lensCount === "number") setToolbarLensCount(stored.toolbar.lensCount); + if (typeof stored.toolbar?.hideDelay === "number") setToolbarHideDelay(stored.toolbar.hideDelay); + if (typeof stored.toolbar?.gap === "number") setToolbarGap(stored.toolbar.gap); if (typeof stored.toolbar?.autoHide === "boolean") setToolbarAutoHide(stored.toolbar.autoHide); }, []); @@ -596,13 +616,15 @@ export function CatalogApp() { } const toolbar = stored.toolbar; if (toolbar) { - if (toolbar.placement === "left" || toolbar.placement === "right" || toolbar.placement === "bottom") setToolbarPlacement(toolbar.placement); + if (toolbar.placement === "left" || toolbar.placement === "right" || toolbar.placement === "bottom" || toolbar.placement === "top") setToolbarPlacement(toolbar.placement); if (toolbar.background) setToolbarBg(toolbar.background); if (toolbar.border) setToolbarBorder(toolbar.border); if (toolbar.outline) setToolbarOutline(toolbar.outline); if (typeof toolbar.minSize === "number") setToolbarMinSize(toolbar.minSize); if (typeof toolbar.maxSize === "number") setToolbarMaxSize(toolbar.maxSize); if (typeof toolbar.lensCount === "number") setToolbarLensCount(toolbar.lensCount); + if (typeof toolbar.hideDelay === "number") setToolbarHideDelay(toolbar.hideDelay); + if (typeof toolbar.gap === "number") setToolbarGap(toolbar.gap); if (typeof toolbar.autoHide === "boolean") setToolbarAutoHide(toolbar.autoHide); } setLayoutSaveState("saved"); @@ -1071,6 +1093,7 @@ export function CatalogApp() { maxSize: toolbarMaxSize, lensCount: toolbarLensCount, autoHide: toolbarAutoHide, + hideDelay:toolbarHideDelay,gap:toolbarGap, }, }; const response = await fetch("/api/layout", { @@ -1279,6 +1302,7 @@ export function CatalogApp() { { value: "left", label: "Слева" }, { value: "right", label: "Справа" }, { value: "bottom", label: "Снизу" }, + { value: "top", label: "Сверху" }, ]} onChange={(value) => setToolbarPlacement(value as ToolbarPlacement)} /> @@ -1293,6 +1317,8 @@ export function CatalogApp() { `${value}px`} onChange={(value) => setToolbarMaxSize(Math.max(toolbarMinSize, Math.round(value)))} /> `${value} иконок`} onChange={(value) => setToolbarLensCount(Math.round(value) % 2 === 0 ? Math.round(value) + 1 : Math.round(value))} /> + `${v/1000} с`} onChange={setToolbarHideDelay}/> + `${v} px`} onChange={setToolbarGap}/> ), }, @@ -1304,8 +1330,8 @@ export function CatalogApp() { <> `${value}%`} onChange={setBrightness} /> -
`${value.toFixed(1).replace('.', ',')} м`} formatLimit={(value) => value.toFixed(1).replace('.', ',')} onChange={(value) => setBrightness((value + 1.2) / 52.7 * 100)} />
-
`${value.toFixed(1).replace('.', ',')} м`} formatLimit={(value) => value.toFixed(1).replace('.', ',')} onChange={(value) => setBrightness((value + 1.2) / 52.7 * 100)} />
+
`${value.toFixed(1).replace('.', ',')} м`} formatLimit={(value) => value.toFixed(1).replace('.', ',')} onChange={setSliceBand} />
+
`${value.toFixed(1).replace('.', ',')} м`} formatLimit={(value) => value.toFixed(1).replace('.', ',')} onChange={setSliceBand} />
`${value}%`} onChange={setGlowDistance} /> ), @@ -1352,9 +1378,10 @@ export function CatalogApp() { case "controls": return (
+ `${v} px`}/>setCubeEdgeOpacity(1-v)} formatValue={v=>`${Math.round(v*100)}%`}/>

{cubeDirection.join(" · ")}

- + @@ -1439,6 +1467,27 @@ export function CatalogApp() { Требуется внимание + +
+ } /> + } progress={{label:"Анализ поверхности · 29 / 96",value:29/96}} /> + } progress={{label:"Подготовка данных"}} /> + } /> +
+
+ + + setPreviewLayers(current=>current.includes("gaussian")?current.filter(v=>v!=="gaussian"):[...current,"gaussian"])}>Gaussian + Недоступный слой + Память}> +

Накопленные проезды этой локации.

+
+
+ +
@@ -1456,9 +1505,11 @@ export function CatalogApp() { - -
+ +
+ + onChange(Number(event.target.value))} /> - {label} · {displayValue} -
- {formatLimit(max)} + {formatLimit(clampRangeValue(value, min, safeMax))} {formatLimit(min)}
); diff --git a/packages/ui-react/src/SegmentedControl.tsx b/packages/ui-react/src/SegmentedControl.tsx index a76f9fe..6d8ace9 100644 --- a/packages/ui-react/src/SegmentedControl.tsx +++ b/packages/ui-react/src/SegmentedControl.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from "react"; +import { forwardRef, type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode } from "react"; import { cn } from "./cn.js"; export interface SegmentedItem { @@ -7,48 +7,46 @@ export interface SegmentedItem { icon?: ReactNode; disabled?: boolean; } - export type SegmentedControlSize = "default" | "dense"; - -export interface SegmentedControlProps { - value: T; +export type SegmentedControlProps = { items: Array>; label: string; size?: SegmentedControlSize; className?: string; - onChange: (value: T) => void; +} & ({ selectionMode?: "single"; value: T; onChange: (value: T) => void } + | { selectionMode: "multiple"; value: readonly T[]; onChange: (value: T[]) => void }); + +export function SegmentedControl(props: SegmentedControlProps) { + const { items, label, size = "default", className } = props; + const multiple = props.selectionMode === "multiple"; + return
+ {items.map(item => { + const active = props.selectionMode === "multiple" ? props.value.includes(item.value) : props.value === item.value; + return ; + })} +
; } -export function SegmentedControl({ - value, - items, - label, - size = "default", - className, - onChange, -}: SegmentedControlProps) { - return ( -
- {items.map((item) => ( - - ))} -
- ); +/** Shared capsule for independently controlled toggles and menu triggers. */ +export function SegmentedGroup({ label, size = "default", className, ...props }: + HTMLAttributes & { label: string; size?: SegmentedControlSize }) { + return
; } + +/** Caller supplies aria-pressed for toggles or aria-expanded/haspopup for menu triggers. */ +export const SegmentedButton = forwardRef & { active?: boolean } +>(function SegmentedButton({ active, className, type = "button", ...props }, ref) { + return - ); + );}; + return item.menu ? { + const button=buttonRefs.current[key], toolbar=toolbarRef.current; + if(!button||!toolbar)return null; + const b=button.getBoundingClientRect(), t=toolbar.getBoundingClientRect(); + // Reserve the largest possible icon, including while its spring is still moving. + const pad=Math.max(safeMax,...Object.values(buttonRefs.current).map(n=>n?.getBoundingClientRect().width??0)); + if(placement==="right")return {...b.toJSON(),left:t.right-pad,right:t.right,width:pad}; + if(placement==="left")return {...b.toJSON(),left:t.left,right:t.left+pad,width:pad}; + if(placement==="bottom")return {...b.toJSON(),top:t.bottom-pad,bottom:t.bottom,height:pad}; + return {...b.toJSON(),top:t.top,bottom:t.top+pad,height:pad}; + }} width={220} trigger={button} onPointerDownOutside={event=>{ + const target=event.target as Element; + // Dismiss a menu before a viewport tool can turn this same click into an edit. + if(container?.contains(target)&&!target.closest('button,input,select,textarea,a,[role="button"],[role="tab"]')){ + event.preventDefault();event.stopPropagation(); + } + }} onOpenChange={open => { + if(open){openMenusRef.current.add(key);menus.active.current=key;showDock();}else{openMenusRef.current.delete(key);if(menus.active.current===key)menus.active.current=null;scheduleHide();} + }}> + {({close}) => typeof item.menu === "function" ? item.menu(close) : item.menu} + : button(); })}
diff --git a/packages/ui-react/src/VerticalRangeBand.tsx b/packages/ui-react/src/VerticalRangeBand.tsx new file mode 100644 index 0000000..cf65820 --- /dev/null +++ b/packages/ui-react/src/VerticalRangeBand.tsx @@ -0,0 +1,67 @@ +import { useRef, type CSSProperties, type PointerEvent } from "react"; +import type { RangeControlProps } from "./RangeControl.js"; +import { cn } from "./cn.js"; +import { moveRangeBoundary, nearestRangeBoundary, normalizeRangeBand } from "./rangeBand.js"; + +export interface RangeBandControlProps extends Omit { + orientation: "vertical"; + value: readonly [number, number]; + onChange: (value: [number, number]) => void; + lowerLabel?: string; + upperLabel?: string; +} + +/** Two native keyboard targets, with one pointer track selecting its nearest boundary. */ +export function VerticalRangeBand({ label, value, min, max, step = 1, onChange, + lowerLabel = `${label}: нижняя граница`, upperLabel = `${label}: верхняя граница`, + formatValue = String, formatLimit = String, limitSide = "right", disabled = false, + className, style, orientation: _orientation, ...props }: RangeBandControlProps) { + const safeMax = max > min ? max : min + 1; + const band = normalizeRangeBand(value, min, safeMax); + const current = useRef(band); current.current = band; + const inputs = useRef<(HTMLInputElement | null)[]>([]); + const drag = useRef<{ id: number; boundary: 0 | 1 } | null>(null); + const progress = band.map(n => (n - min) / (safeMax - min) * 100); + const variables = { ...style, "--nodedc-range-lower": `${progress[0]}%`, + "--nodedc-range-upper": `${progress[1]}%` } as CSSProperties; + const change = (boundary: 0 | 1, next: number) => { + const result = moveRangeBoundary(current.current, boundary, next, min, safeMax, step); + current.current = result; onChange(result); + }; + const position = (event: PointerEvent) => { + const rect = event.currentTarget.getBoundingClientRect(); + return min + Math.max(0, Math.min(1, (rect.bottom - event.clientY) / rect.height)) * (safeMax - min); + }; + const end = (event: PointerEvent) => { + if (drag.current?.id !== event.pointerId) return; + drag.current = null; + if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId); + }; + return
+
+
{ + if (disabled || event.button !== 0 || drag.current) return; + event.preventDefault(); event.stopPropagation(); + const next = position(event), boundary = nearestRangeBoundary(current.current, next); + drag.current = { id: event.pointerId, boundary }; + inputs.current[boundary]?.focus({ preventScroll: true }); + event.currentTarget.setPointerCapture(event.pointerId); change(boundary, next); + }} + onPointerMove={event => { + if (disabled || drag.current?.id !== event.pointerId) return; + event.preventDefault(); event.stopPropagation(); change(drag.current.boundary, position(event)); + }} onPointerUp={end} onPointerCancel={end} onLostPointerCapture={() => { drag.current = null; }}> + {([0, 1] as const).map(boundary => { inputs.current[boundary] = node; }} type="range" data-boundary={boundary === 0 ? "lower" : "upper"} + min={min} max={safeMax} step={step} value={band[boundary]} disabled={disabled} + aria-label={boundary === 0 ? lowerLabel : upperLabel} aria-orientation="vertical" + aria-valuemin={boundary === 0 ? min : band[0]} aria-valuemax={boundary === 0 ? band[1] : safeMax} + aria-valuetext={formatValue(band[boundary])} + onChange={event => change(boundary, Number(event.target.value))} />)} +
+
+ {formatLimit(band[1])} + {formatLimit(band[0])} +
; +} diff --git a/packages/ui-react/src/Window.tsx b/packages/ui-react/src/Window.tsx index 8f4ec6d..0d3bf5f 100644 --- a/packages/ui-react/src/Window.tsx +++ b/packages/ui-react/src/Window.tsx @@ -9,6 +9,7 @@ import { } from "react"; import { createPortal } from "react-dom"; import { InspectorSelectPolicyContext } from "./InspectorContext.js"; +import { LoadingContext } from "./LoadingContext.js"; import { cn } from "./cn.js"; import { Icon } from "./Icon.js"; @@ -154,7 +155,7 @@ export function Window({ }; return createPortal( - +
{footer} : null}
-
, - document.body, +
, + document.fullscreenElement ?? document.body, ); } diff --git a/packages/ui-react/src/WorkspaceWindow.tsx b/packages/ui-react/src/WorkspaceWindow.tsx index 084702a..33d76ce 100644 --- a/packages/ui-react/src/WorkspaceWindow.tsx +++ b/packages/ui-react/src/WorkspaceWindow.tsx @@ -35,6 +35,7 @@ export interface WorkspaceWindowProps extends Omit Math.max(min, Math.min(max, n)); + +export function normalizeRangeBand(value: RangeBand, min: number, max: number): [number, number] { + const low = clamp(value[0], min, max); + return [low, clamp(value[1], low, max)]; +} + +export function nearestRangeBoundary([low, high]: RangeBand, value: number): 0 | 1 { + // Coincident boundaries remain separable: below pulls the lower, above the upper. + return value <= (low + high) / 2 ? 0 : 1; +} + +export function moveRangeBoundary(value: RangeBand, boundary: 0 | 1, next: number, + min: number, max: number, step: string | number = 1): [number, number] { + const band = normalizeRangeBand(value, min, max); + const increment = Number(step); + const bounded = clamp(next, min, max); + // Exact endpoints stay reachable even when the range is not step-aligned. + const aligned = bounded === min || bounded === max || !Number.isFinite(increment) || increment <= 0 + ? bounded : Number((min + Math.round((bounded - min) / increment) * increment).toPrecision(12)); + band[boundary] = boundary === 0 ? clamp(aligned, min, band[1]) : clamp(aligned, band[0], max); + return band; +} diff --git a/packages/ui-react/src/useToolbarMenus.ts b/packages/ui-react/src/useToolbarMenus.ts new file mode 100644 index 0000000..cea0094 --- /dev/null +++ b/packages/ui-react/src/useToolbarMenus.ts @@ -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>({}); + const active=useRef(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('[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}; +} diff --git a/registry/components.json b/registry/components.json index 734dad6..2ba1bfb 100644 --- a/registry/components.json +++ b/registry/components.json @@ -1,28 +1,50 @@ { "schemaVersion": "1.0.0", "components": [ -{ - "id": "progress-bar", - "status": "baseline", - "package": "@nodedc/ui-react", - "exports": [ - "ProgressBar", - "ProgressBarProps" - ], - "domContract": [ - "nodedc-progress-bar" - ], - "summary": "Accessible determinate or indeterminate linear progress, including the central ResourceRow slot.", - "variants": [ - "determinate", - "indeterminate" - ], - "rules": [ - "Consumer supplies measured progress; elapsed time must not invent completion.", - "ResourceRow progress replaces status and occupies space between copy and actions.", - "Reduced motion preserves a visible non-animated indicator." - ] -}, + { + "id": "progress-button", + "status": "baseline", + "package": "@nodedc/ui-react", + "exports": [ + "ProgressButton", + "ProgressButtonProps", + "LayerStackIndicator" + ], + "domContract": [ + "nodedc-progress-button", + "nodedc-layer-stack-indicator" + ], + "summary": "Action with an internal phase label and measured progress beneath it; optional accumulating layers animation.", + "behavior": [ + "pending disables repeat activation while keeping readable status", + "progress semantics are siblings of the button rather than flattened descendants", + "phase progress comes from the consumer", + "reduced motion keeps a static layers glyph" + ], + "documentation": "../docs/PROGRESS_BUTTON.md" + }, + { + "id": "progress-bar", + "status": "baseline", + "package": "@nodedc/ui-react", + "exports": [ + "ProgressBar", + "ProgressBarProps" + ], + "domContract": [ + "nodedc-progress-bar" + ], + "summary": "Accessible determinate or indeterminate linear progress, including the central ResourceRow slot.", + "variants": [ + "determinate", + "indeterminate" + ], + "rules": [ + "Consumer supplies measured progress; elapsed time must not invent completion.", + "ResourceRow progress replaces status and occupies space between copy and actions.", + "Reduced motion preserves a visible non-animated indicator." + ] + }, { "id": "resource-row", "status": "baseline", @@ -52,12 +74,38 @@ "id": "glass-surface", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["GlassSurface", "GlassMaterialSurface", "MapGlassSurface"], - "domContract": ["nodedc-glass", "nodedc-glass-material", "nodedc-map-glass", "nodedc-material-rim"], + "exports": [ + "GlassSurface", + "GlassMaterialSurface", + "MapGlassSurface" + ], + "domContract": [ + "nodedc-glass", + "nodedc-glass-material", + "nodedc-map-glass", + "nodedc-material-rim" + ], "summary": "Matte application surfaces, the Engine V4 modal material and the light translucent surface used over Cesium imagery.", - "anatomy": ["theme-provided surface", "modal tint", "map-only light translucency", "gradient rim", "backdrop blur/saturation/brightness", "content"], - "variants": ["default", "strong", "soft", "map"], - "radiusVariants": ["card", "panel", "modal", "pill"], + "anatomy": [ + "theme-provided surface", + "modal tint", + "map-only light translucency", + "gradient rim", + "backdrop blur/saturation/brightness", + "content" + ], + "variants": [ + "default", + "strong", + "soft", + "map" + ], + "radiusVariants": [ + "card", + "panel", + "modal", + "pill" + ], "rules": [ "Geometry is invariant across application themes.", "Opt-in appearance=mission applies the qualified Mission Core operator surfaces, avatars and dot statuses across portals without changing geometry.", @@ -78,7 +126,9 @@ ], "domContract": [ "nodedc-button", - "nodedc-icon-button" + "nodedc-icon-button", + "nodedc-scene-controls", + "nodedc-viewport-controls" ], "summary": "Text and icon actions with shared sizing, states and computed accent contrast.", "variants": [ @@ -100,22 +150,37 @@ ], "rules": [ "Icon-only actions are circular by default.", + "Groups over rendered imagery use nodedc-scene-controls: Button, IconButton, Select and SegmentedControl share the opaque field surface and interaction states; all viewport controls use the same 70-percent geometry, and rails must not inherit the translucent header background.", "Controlled toggle actions expose aria-pressed and use the canonical active surface without changing geometry.", "Filled accent actions derive foreground contrast from the actual accent.", "Destructive actions remain neutral until confirmation unless danger is the principal message.", "loading displays one centered indicator inside the initiating action, disables repeat activation and preserves dimensions and accessible name. Never place its spinner beside or below the action group.", - "Primary tone=neutral is white when enabled and gray when disabled in every theme/accent; use it for accent-independent operator actions without local CSS overrides." + "Primary tone=neutral is white when enabled and gray when disabled in every theme/accent; use it for accent-independent operator actions without local CSS overrides.", + "nodedc-viewport-controls is the shared geometry context for every viewer toolbar: 0.7 times standard controls, including icons, fonts and rims. It normalizes legacy compact/dense variants, never compounds in nested groups, and excludes portaled menus/settings and scene content." ] }, { "id": "activity-indicator", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ActivityIndicator", "ActivityIndicatorProps", "ActivityIndicatorSize"], - "domContract": ["nodedc-activity-indicator"], + "exports": [ + "ActivityIndicator", + "ActivityIndicatorProps", + "ActivityIndicatorSize" + ], + "domContract": [ + "nodedc-activity-indicator" + ], "summary": "Theme-independent indeterminate progress indicator for inline operations and pending action controls.", - "variants": ["default", "compact"], - "behavior": ["decorative by default", "optional status semantics", "static reduced-motion presentation"], + "variants": [ + "default", + "compact" + ], + "behavior": [ + "decorative by default", + "optional status semantics", + "static reduced-motion presentation" + ], "rules": [ "Use Button.loading or IconButton.loading for actions and LoadingRegion for content. Standalone ActivityIndicator is limited to an explicit inline status or resource-row slot.", "The process owner exposes aria-busy and visible pending copy; provide label only when the indicator itself is the status announcement.", @@ -127,36 +192,55 @@ "id": "loading-region", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["LoadingRegion", "LoadingRegionProps"], - "domContract": ["nodedc-loading-region", "nodedc-loading-region__status"], + "exports": [ + "LoadingRegion", + "LoadingRegionProps" + ], + "domContract": [ + "nodedc-loading-region", + "nodedc-loading-region__status" + ], "summary": "Centered pending feedback within the content region that owns the request, without unmounting content.", "rules": [ "The consumer owns loading and its terminal result; no timer or implicit network operation exists in this component.", "Keep content mounted and reserve its dimensions while pending. Center the indicator within this region in normal and expanded layouts.", "A command belongs to its initiating Button.loading; do not duplicate that command in a region spinner.", "Remove loading on first usable content, failure or timeout. A live media connection alone is not usable content.", - "Use only for blocking initial content or explicit recovery. Background refresh with usable content does not cover it." + "Use only for blocking initial content or explicit recovery. Background refresh with usable content does not cover it.", + "For a composed initial load, aggregate collects descendant LoadingRegions into one indicator. Each descendant releases its pending state on success, failure or unmount. Windows reset the scope; action spinners remain independent." ] }, { "id": "field", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["FieldFrame", "TextField", "TextAreaField"], - "domContract": ["nodedc-field", "nodedc-field__control"], + "exports": [ + "FieldFrame", + "TextField", + "TextAreaField" + ], + "domContract": [ + "nodedc-field", + "nodedc-field__control" + ], "summary": "Textual form controls with consistent labels, hints, geometry and focus surface.", "rules": [ "Labels and validation copy are part of the field contract.", "Keyboard focus changes the surface and remains visible without a browser-blue outline.", - "Browser autofill retains the canonical field material, text and caret; keyboard focus remains visible." + "Browser autofill retains the canonical field material, text and caret; keyboard focus remains visible.", + "FieldFrame labelPlacement=below is the compact muted caption variant for header selectors; above remains the default." ] }, { "id": "checker", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["Checker"], - "domContract": ["nodedc-checker"], + "exports": [ + "Checker" + ], + "domContract": [ + "nodedc-checker" + ], "summary": "Binary setting control derived from the redesigned Engine environment settings.", "rules": [ "The visual anchor is circular, not a square native checkbox.", @@ -168,15 +252,30 @@ "id": "range-control", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["RangeControl"], - "domContract": ["nodedc-range"], - "summary": "Filled pill range control with horizontal exact editing or a slim vertical scale with endpoints on the scene-inward side and a fixed centered label/value.", - "behavior": ["native range drag", "native caret and selection replacement", "automatic fill/base contrast", "unbounded finite exact editing by default", "Enter/blur commit", "Escape cancel", "independent optional exact-value bounds", "step normalization"], + "exports": [ + "RangeControl" + ], + "domContract": [ + "nodedc-range" + ], + "summary": "Filled horizontal range with exact editing; half-width vertical rail supporting an independently adjustable lower/upper band.", + "behavior": [ + "native range drag", + "native caret and selection replacement", + "automatic fill/base contrast", + "unbounded finite exact editing by default", + "Enter/blur commit", + "Escape cancel", + "independent optional exact-value bounds", + "step normalization", + "vertical two-sided band with independent native keyboard targets and nearest-boundary pointer capture" + ], "rules": [ "The accent fill follows the active application theme.", - "Vertical scales place formatLimit(min/max) on the configured scene-inward side (right by default, left with limitSide=left) in theme text, without units by default; label and formatValue(value) stay together at the center of the pill.", - "The vertical shaft is 40 percent of control height (20 percent slimmer than the original half-width variant); center and endpoint typography are 90 percent of their sm/xs tokens.", - "Central vertical text uses two identical layers clipped to the rounded fill, including partially covered glyphs. Vertical scales never have a perimeter border, outline or shadow, including focus; focus-visible underlines both central text layers with their existing contrast.", + "Vertical tuple values [lower, upper] retain the band between two non-crossing boundaries; both labels follow their boundary. Coincident boundaries remain separable. Each native input has a distinct accessible name, value and dependent bounds.", + "Scalar vertical scales show formatLimit(value) at the moving fill boundary and formatLimit(min) at the lower retained boundary, on the configured scene-inward side. There is no central label/value; the accessible name and value remain on the native input.", + "The vertical shaft is 20 percent of control height (9.2 px at 46 px), with a transparent pointer target of at least 24 px. Boundary labels remain inside the rail height and separate near the lower endpoint.", + "Vertical scales never have a perimeter border, outline or shadow. Focus-visible underlines the moving value; native arrows and Home/End remain available.", "The native range remains the accessible drag input while its chrome is visually replaced.", "The fill travels beneath the visible value; the persistent transparent native editor above the value receives exact-edit clicks without remounting.", "Exact editing stays inside the existing value area and never expands the control.", @@ -192,10 +291,21 @@ "id": "color-field", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ColorField"], - "domContract": ["nodedc-color-field"], + "exports": [ + "ColorField" + ], + "domContract": [ + "nodedc-color-field" + ], "summary": "Engine/BIM-derived swatch and HEX field with a theme-neutral portal palette.", - "behavior": ["controlled HEX value", "saturation/value plane", "hue slider", "quick colors", "portal palette", "keyboard spectrum adjustment"], + "behavior": [ + "controlled HEX value", + "saturation/value plane", + "hue slider", + "quick colors", + "portal palette", + "keyboard spectrum adjustment" + ], "rules": [ "Do not expose a browser-native color dialog as the product runtime UI.", "The palette owns choice geometry; the consumer owns color validation, persistence and domain reaction." @@ -205,12 +315,33 @@ "id": "dropdown", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["Dropdown"], + "exports": [ + "Dropdown" + ], "domPackage": "@nodedc/ui-dom", - "domExports": ["createFloatingLayer"], - "domContract": ["nodedc-dropdown-surface", "nodedc-dropdown-option"], + "domExports": [ + "createFloatingLayer" + ], + "domContract": [ + "nodedc-dropdown-surface", + "nodedc-dropdown-option" + ], "summary": "Shared portal/fixed floating layer for action and selection menus.", - "behavior": ["portal to document body", "viewport clamp", "vertical flip", "outside pointer close", "Escape close with trigger focus restore", "scroll and resize reposition", "contained menu scroll without geometry growth", "offscreen trigger close", "one open dropdown per window", "optional open-state notification"], + "behavior": [ + "portal to active fullscreen element or document body", + "viewport clamp", + "vertical flip", + "capture-phase outside pointer close before scene tool interception", + "optional outside-pointer consumer for editing viewports", + "Escape close with trigger focus restore", + "scroll and resize reposition", + "contained menu scroll without geometry growth", + "offscreen trigger close", + "one open root dropdown with nested selection menus", + "optional open-state notification", + "optional side placement and animated reserved anchor", + "side overflow shrinks width rather than covering the anchor" + ], "rules": [ "Never render a runtime dropdown as an absolute child of a card, sticky header or scroll container.", "Action menus and selection menus share floating behavior even when their row content differs.", @@ -221,12 +352,27 @@ "id": "select", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["Select"], + "exports": [ + "Select" + ], "domPackage": "@nodedc/ui-dom", - "domExports": ["createSelectController"], + "domExports": [ + "createSelectController" + ], "summary": "Theme-independent selection control using the canonical dropdown layer.", - "variants": ["integrated", "split", "inline"], - "behavior": ["controlled value", "optional search", "disabled options", "selected state", "portal menu", "optional independent row action"], + "variants": [ + "integrated", + "split", + "inline" + ], + "behavior": [ + "controlled value", + "optional search", + "disabled options", + "selected state", + "portal menu", + "optional independent row action" + ], "rules": [ "An option.action is a sibling canonical IconButton with an independent disabled state; it closes the menu without selecting the option. Action-bearing menus use dialog semantics instead of nesting interactive controls in listbox options. Confirmation and mutation remain consumer-owned.", "Select row actions match the compact Mission Core session-catalog reference: transparent 2.35rem hit column, 15px glyph, muted foreground and no round backing. An optional danger tone changes only hover/focus foreground; canonical keyboard focus remains visible.", @@ -241,12 +387,29 @@ "id": "window", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["Window", "WindowFooterActions"], + "exports": [ + "Window", + "WindowFooterActions" + ], "domPackage": "@nodedc/ui-dom", - "domExports": ["createModalController"], - "domContract": ["nodedc-overlay", "nodedc-window"], + "domExports": [ + "createModalController" + ], + "domContract": [ + "nodedc-overlay", + "nodedc-window" + ], "summary": "Canonical controlled window for modal and right-side panel presentations, with optional headerActions beside close.", - "behavior": ["portal to body", "focus entry", "modal-only focus trap", "focus restore", "Escape close", "backdrop close policy", "modal-only body scroll lock", "optional bounded dragging for modeless inspectors"], + "behavior": [ + "portal to active fullscreen element or body", + "focus entry", + "modal-only focus trap", + "focus restore", + "Escape close", + "backdrop close policy", + "modal-only body scroll lock", + "optional bounded dragging for modeless inspectors" + ], "rules": [ "WindowFooterActions aligns modal actions to the trailing edge, including a footer with only one action group; actions wrap within narrow windows.", "Centered windows at narrow widths subtract both overlay gutters from their maximum width and height.", @@ -262,14 +425,36 @@ "id": "workspace-window", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["WorkspaceWindow", "WorkspaceWindowRect", "WorkspaceWindowProps"], - "domContract": ["nodedc-workspace-window"], + "exports": [ + "WorkspaceWindow", + "WorkspaceWindowRect", + "WorkspaceWindowProps" + ], + "domContract": [ + "nodedc-workspace-window" + ], "summary": "Controlled modeless window for media, tools and synchronized views constrained to an application-owned workspace.", - "anatomy": ["controlled local rectangle", "title and optional status", "maximize and close actions", "scrollable body", "optional footer", "keyboard-accessible resize handle"], - "behavior": ["inline render without portal", "parent-bound dragging", "bottom-right resizing", "maximize within parent", "ResizeObserver reclamp", "pointer and keyboard geometry control", "application-owned activation and stacking"], + "anatomy": [ + "controlled local rectangle", + "title and optional status", + "maximize and close actions", + "scrollable body", + "optional footer", + "keyboard-accessible resize handle with optional hidden indicator" + ], + "behavior": [ + "inline render without portal", + "parent-bound dragging", + "bottom-right resizing", + "maximize within parent", + "ResizeObserver reclamp", + "pointer and keyboard geometry control", + "application-owned activation and stacking" + ], "rules": [ "The bounds element is an application-owned positioned and clipped workspace; WorkspaceWindow never escapes it or renders into document.body.", "Rectangle, maximized state, visibility, activation and z-order are controlled by the application.", + "resizeIndicator=false hides only the corner glyph; pointer hit area, cursor and keyboard resizing remain available.", "Use WorkspaceWindow for auxiliary views inside a stage; modal workflows and viewport inspectors continue to use Window.", "Dragging and resizing remain clamped when the workspace changes size, including when it becomes smaller than the requested minimum." ] @@ -278,21 +463,49 @@ "id": "confirmation-modal", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ConfirmationModal"], + "exports": [ + "ConfirmationModal" + ], "summary": "Async-safe confirmation window for destructive and consequential operations.", - "behavior": ["pending state", "double-submit protection", "disabled close policy while pending"] + "behavior": [ + "pending state", + "double-submit protection", + "disabled close policy while pending" + ] }, { "id": "split-pane", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["SplitPane", "SplitPaneProps", "SplitPaneOrientation"], - "domContract": ["nodedc-split-pane", "nodedc-split-pane__panel", "nodedc-split-pane__separator"], + "exports": [ + "SplitPane", + "SplitPaneProps", + "SplitPaneOrientation" + ], + "domContract": [ + "nodedc-split-pane", + "nodedc-split-pane__panel", + "nodedc-split-pane__separator" + ], "summary": "Controlled two-panel layout with a pointer- and keyboard-resizable accessible separator.", - "anatomy": ["primary panel", "structural separator", "secondary panel"], - "variants": ["vertical", "horizontal"], - "behavior": ["controlled percentage", "optional resizable separator", - "line or invisible separator appearance with retained keyboard focus", "pointer capture drag", "Arrow/Home/End keyboard sizing", "ARIA separator range", "ratio preservation across host resize"], + "anatomy": [ + "primary panel", + "structural separator", + "secondary panel" + ], + "variants": [ + "vertical", + "horizontal" + ], + "behavior": [ + "controlled percentage", + "optional resizable separator", + "line or invisible separator appearance with retained keyboard focus", + "pointer capture drag", + "Arrow/Home/End keyboard sizing", + "ARIA separator range", + "ratio preservation across host resize" + ], "rules": [ "The application owns the controlled primary percentage and panel content; the component owns separator interaction and accessibility.", "Minimum primary and secondary percentages clamp both pointer and keyboard changes.", @@ -304,10 +517,25 @@ "id": "share-access-modal", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ShareAccessModal"], - "domContract": ["nodedc-share-access-window", "nodedc-share-access", "nodedc-share-access__summary", "nodedc-share-access__member-list"], + "exports": [ + "ShareAccessModal" + ], + "domContract": [ + "nodedc-share-access-window", + "nodedc-share-access", + "nodedc-share-access__summary", + "nodedc-share-access__member-list" + ], "summary": "Engine-derived workflow access modal with compact member stack, role management and invite adapter slots.", - "behavior": ["controlled members", "compact expandable member stack", "role change", "member removal", "invite state", "immutable owner", "backdrop close disabled"], + "behavior": [ + "controlled members", + "compact expandable member stack", + "role change", + "member removal", + "invite state", + "immutable owner", + "backdrop close disabled" + ], "rules": [ "The component owns access-modal geometry and interaction; the consumer owns ACL requests and directory lookup.", "Owner immutability and permission checks are supplied as member and canManage data.", @@ -318,12 +546,27 @@ "id": "share-link-modal", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ShareLinkModal"], + "exports": [ + "ShareLinkModal" + ], "domPackage": "@nodedc/ui-dom", - "domExports": ["createShareLinkController", "createModalController"], - "domContract": ["nodedc-window", "nodedc-field", "nodedc-button"], + "domExports": [ + "createShareLinkController", + "createModalController" + ], + "domContract": [ + "nodedc-window", + "nodedc-field", + "nodedc-button" + ], "summary": "BIM-derived read-only resource link modal with copy progress and framework-neutral copy controller.", - "behavior": ["read-only link", "copy adapter", "copied state", "disabled empty state", "copy error adapter"], + "behavior": [ + "read-only link", + "copy adapter", + "copied state", + "disabled empty state", + "copy error adapter" + ], "rules": [ "The resource service creates the URL; the modal only presents and copies it.", "BIM DOM consumers combine the share-link controller with the canonical modal controller and core classes." @@ -333,22 +576,55 @@ "id": "segmented-control", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["SegmentedControl"], - "domContract": ["nodedc-segmented"], + "exports": [ + "SegmentedControl", + "SegmentedGroup", + "SegmentedButton" + ], + "selectionModes": [ + "single", + "multiple" + ], + "behavior": [ + "multiple uses independently pressed buttons, permits empty/all selections and preserves native Tab/Space/Enter interaction" + ], + "domContract": [ + "nodedc-segmented" + ], "summary": "Pill navigation used in the shared top header and compact mode switches.", - "sizes": ["default", "dense"], + "sizes": [ + "default", + "dense" + ], "rules": [ - "Dense is reserved for high-density in-viewer layer and mode toolbars; application headers retain default geometry." + "Dense is reserved for high-density in-viewer layer and mode toolbars; application headers retain default geometry.", + "SegmentedGroup and SegmentedButton compose mixed toggles and Dropdown triggers in one capsule; consumers supply aria-pressed or aria-expanded as appropriate and retain native keyboard interaction." ] }, { "id": "app-header", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["AppHeader", "HeaderNavigation", "HeaderProfile", "HeaderProfileButton", "HeaderWorkspace", "HeaderAvatar"], - "domContract": ["nodedc-header-shell", "nodedc-header", "nodedc-header__row"], + "exports": [ + "AppHeader", + "HeaderNavigation", + "HeaderProfile", + "HeaderProfileButton", + "HeaderWorkspace", + "HeaderAvatar" + ], + "domContract": [ + "nodedc-header-shell", + "nodedc-header", + "nodedc-header__row" + ], "summary": "Strict Launcher-preset NODE.DC header with a 68 px outer toolbar, 48 px visible row and fixed three-axis geometry.", - "anatomy": ["left brand", "optional left context", "center navigation/workspace", "right actions/profile"], + "anatomy": [ + "left brand", + "optional left context", + "center navigation/workspace", + "right actions/profile" + ], "rules": [ "The logo occupies the same visual position and geometry across applications.", "Light single-color assets may opt into brandMonochrome / monochrome for theme contrast; full-color images are unchanged by default.", @@ -361,10 +637,23 @@ "id": "user-profile-menu", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["UserProfileMenu", "UserProfileMenuAction"], - "domContract": ["nodedc-user-profile-menu", "nodedc-user-profile-card", "nodedc-user-profile-card__action"], + "exports": [ + "UserProfileMenu", + "UserProfileMenuAction" + ], + "domContract": [ + "nodedc-user-profile-menu", + "nodedc-user-profile-card", + "nodedc-user-profile-card__action" + ], "summary": "Canonical user profile dropdown for NODE.DC application headers with identity cover and application-owned actions.", - "behavior": ["portal dropdown", "profile identity card", "theme-independent cover", "action links and callbacks", "outside pointer and Escape close"], + "behavior": [ + "portal dropdown", + "profile identity card", + "theme-independent cover", + "action links and callbacks", + "outside pointer and Escape close" + ], "rules": [ "The component owns menu geometry and profile presentation; the application owns settings, profile and logout actions.", "Use the existing Dropdown engine so the menu is never clipped by the fixed application header.", @@ -375,28 +664,66 @@ "id": "feature-settings-window", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["FeatureSettingsWindow", "FeatureSettingsSection", "FeatureSettingsWindowProps"], - "domContract": ["nodedc-feature-settings-window", "nodedc-feature-settings__navigation", "nodedc-feature-settings__content"], + "exports": [ + "FeatureSettingsWindow", + "FeatureSettingsSection", + "FeatureSettingsWindowProps" + ], + "domContract": [ + "nodedc-feature-settings-window", + "nodedc-feature-settings__navigation", + "nodedc-feature-settings__content" + ], "summary": "Engine-derived large settings window with module identity, grouped feature navigation and application-owned content.", - "behavior": ["canonical modal focus behavior", "controlled active section", "grouped navigation", "responsive single-column layout"], + "behavior": [ + "canonical modal focus behavior", + "controlled active section", + "grouped navigation", + "responsive single-column layout" + ], "rules": [ "The window owns settings-shell geometry only; forms, API calls and authorization remain application-owned.", "FeatureSettingsWindow composes the canonical Window and must not create a second portal or focus trap.", "At narrow widths, keep the window within the overlay padding and size navigation to its content; the content row receives the remaining height.", - "Module colors are supplied through the active NODE.DC Design Profile rather than hard-coded product CSS." + "Module colors are supplied through the active NODE.DC Design Profile rather than hard-coded product CSS.", + "Navigation and content are independent keyboard-accessible scrollports with contained overscroll. The outer window body never scrolls." ] }, { "id": "application-shell", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ApplicationShell", "ApplicationPanel", "useApplicationWorkspace"], + "exports": [ + "ApplicationShell", + "ApplicationPanel", + "useApplicationWorkspace" + ], "domPackage": "@nodedc/ui-dom", - "domExports": ["createApplicationWorkspaceController"], - "domContract": ["nodedc-app-shell", "nodedc-application-panel"], + "domExports": [ + "createApplicationWorkspaceController" + ], + "domContract": [ + "nodedc-app-shell", + "nodedc-application-panel" + ], "summary": "Launcher-derived application template with fixed header, media stage, left navigation and a separate expandable content window.", - "anatomy": ["fixed AppHeader", "stage", "left navigation", "right content window", "persistent utility actions", "expand and close actions"], - "behavior": ["one shared navigation/content state machine", "navigation shifts stage", "content opens beside navigation", "expanded content replaces stage", "global utility actions remain in the panel header across sections", "mobile panels use the available viewport sequentially", "independent content scrolling"], + "anatomy": [ + "fixed AppHeader", + "stage", + "left navigation", + "right content window", + "persistent utility actions", + "expand and close actions" + ], + "behavior": [ + "one shared navigation/content state machine", + "navigation shifts stage", + "content opens beside navigation", + "expanded content replaces stage", + "global utility actions remain in the panel header across sections", + "mobile panels use the available viewport sequentially", + "independent content scrolling" + ], "rules": [ "The bottom Launcher service rail is product-specific and is not part of the general application template.", "Desktop page gap is 20 px and navigation width follows the Launcher 332–352 px range.", @@ -409,13 +736,40 @@ "id": "toolbar", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["Toolbar"], + "exports": [ + "Toolbar" + ], "domPackage": "@nodedc/ui-dom", - "domExports": ["createToolbarController"], - "domContract": ["nodedc-toolbar-wrap", "nodedc-toolbar", "nodedc-toolbar__button"], - "summary": "Engine/BIM-derived magnifying application toolbar with left, right and bottom placements.", - "variants": ["left", "right", "bottom"], - "behavior": ["controlled active item", "spring lens magnification without flex reflow", "axis-aware neighbor shift", "optional delayed autohide hotzone", "theme-independent geometry"], + "domExports": [ + "createToolbarController" + ], + "domContract": [ + "nodedc-toolbar-wrap", + "nodedc-toolbar", + "nodedc-toolbar__button" + ], + "summary": "Engine/BIM-derived magnifying toolbar with four placements and protected interactive menus.", + "variants": [ + "left", + "right", + "top", + "bottom" + ], + "behavior": [ + "controlled active item", + "spring lens magnification without flex reflow", + "axis-aware neighbor shift", + "optional delayed autohide hotzone", + "viewport container scope with local edge reveal", + "native tooltips with keyboard shortcut hints", + "optional canonical dropdown for toolbar item menus", + "theme-independent geometry", + "menus outside maximum magnified icon envelope", + "bounded triangle intent corridor before sibling menu activation", + "autohide suspended while menu is open or keyboard focus is inside", + "configurable gap and hide delay", + "Hold can control autoHide; cancelling pending hide timers makes pinning stable" + ], "rules": [ "Engine defaults are background #111115, border #111117, outline #1c1c1c, min 25 px, max 87 px and five lens items.", "Toolbar actions call application navigation; they do not duplicate route state.", @@ -427,10 +781,18 @@ "id": "icon", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["Icon"], - "domContract": ["svg using currentColor"], + "exports": [ + "Icon" + ], + "domContract": [ + "svg using currentColor" + ], "summary": "Audited semantic icon subset shared by NODE.DC applications instead of product-local vendor imports.", - "variants": ["14 px", "16 px", "18 px"], + "variants": [ + "14 px", + "16 px", + "18 px" + ], "rules": [ "Use semantic names from registry/icons.json.", "Use terminal for a command console or command journal entry; activity remains telemetry and health.", @@ -443,10 +805,21 @@ "id": "admin-navigation-panel", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["AdminNavigationPanel"], - "domContract": ["nodedc-admin-panel"], + "exports": [ + "AdminNavigationPanel" + ], + "domContract": [ + "nodedc-admin-panel" + ], "summary": "Hub-derived left administration panel with context selectors, route navigation, close action and footer identity.", - "anatomy": ["eyebrow and title", "close action", "workspace context", "company context", "route items", "footer identity"], + "anatomy": [ + "eyebrow and title", + "close action", + "workspace context", + "company context", + "route items", + "footer identity" + ], "rules": [ "The panel shell, full-bleed pills and icon circles are library geometry; routes and identity data remain application-owned.", "The desktop panel follows the Launcher 332–352 px width range with a 21.6 px shell radius and a 20 px page gap.", @@ -457,11 +830,28 @@ "id": "application-side-panel", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ApplicationSidePanel", "ApplicationSidePanelProps"], - "domContract": ["nodedc-application-side-panel", "nodedc-app-shell__end-panel"], + "exports": [ + "ApplicationSidePanel", + "ApplicationSidePanelProps" + ], + "domContract": [ + "nodedc-application-side-panel", + "nodedc-app-shell__end-panel" + ], "summary": "Theme-aware trailing application panel paired with AdminNavigationPanel and hosted in a separate ApplicationShell end column.", - "anatomy": ["eyebrow and title", "optional description", "close action", "scrollable body", "optional footer"], - "behavior": ["right-to-left entrance", "separate push column", "controlled visibility", "theme token inheritance"], + "anatomy": [ + "eyebrow and title", + "optional description", + "close action", + "scrollable body", + "optional footer" + ], + "behavior": [ + "right-to-left entrance", + "separate push column", + "controlled visibility", + "theme token inheritance" + ], "rules": [ "The panel uses the same 332–352 px geometry, radius, surface, shadow and circular actions as AdminNavigationPanel.", "ApplicationShell shrinks the expanded content/stage by one panel width plus the canonical page gap; the side panel never overlays the desktop work area.", @@ -506,8 +896,14 @@ "id": "settings-card", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["SettingsCard", "Switch"], - "domContract": ["nodedc-settings-card", "nodedc-switch"], + "exports": [ + "SettingsCard", + "Switch" + ], + "domContract": [ + "nodedc-settings-card", + "nodedc-switch" + ], "summary": "Neutral administration group with title metadata, actions, content and a compact binary switch.", "rules": [ "The card owns grouping geometry but not product form schemas.", @@ -521,21 +917,53 @@ "id": "status-badge", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["StatusBadge"], - "variants": ["badge", "indicator"], - "domContract": ["nodedc-status"], + "exports": [ + "StatusBadge" + ], + "variants": [ + "badge", + "indicator" + ], + "domContract": [ + "nodedc-status" + ], "summary": "Semantic status pill whose tone is independent from the application accent.", - "behavior": ["optional pulse animates only the status lamp", "pulse is static with reduced motion"] + "behavior": [ + "optional pulse animates only the status lamp", + "pulse is static with reduced motion" + ] }, { "id": "toast", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["ToastCard", "ToastStack", "ToastItem", "ToastTone"], - "domContract": ["nodedc-toast-viewport", "nodedc-toast", "nodedc-toast__icon", "nodedc-toast__copy"], + "exports": [ + "ToastCard", + "ToastStack", + "ToastItem", + "ToastTone" + ], + "domContract": [ + "nodedc-toast-viewport", + "nodedc-toast", + "nodedc-toast__icon", + "nodedc-toast__copy" + ], "summary": "Tasker-derived non-blocking status notification with a bottom-right glass stack.", - "variants": ["success", "error", "warning", "info", "loading"], - "behavior": ["controlled items", "independent 10 second default auto-dismiss per terminal item", "manual dismiss", "portal viewport", "polite live region"], + "variants": [ + "success", + "error", + "warning", + "info", + "loading" + ], + "behavior": [ + "controlled items", + "independent 10 second default auto-dismiss per terminal item", + "manual dismiss", + "portal viewport", + "polite live region" + ], "rules": [ "Applications own operation state and message copy; ToastStack owns viewport geometry and dismissal timing.", "Errors and status copy use the compact Toast typography; consumers do not substitute browser-default paragraphs or title-sized text.", @@ -544,14 +972,79 @@ "Status notifications never replace a blocking confirmation modal." ] }, + { + "id": "dock-layout", + "status": "baseline", + "package": "@nodedc/ui-react", + "exports": [ + "DockLayout", + "DockHandle", + "DockTree", + "DockMove", + "DockPosition", + "DockRect", + "DockLayoutProps", + "decodeDockTree", + "dockIds", + "balancedDockTree", + "reconcileDockTree", + "pruneDockTree", + "moveDockPanel", + "resizeDockSplit", + "dockRects", + "dockPosition" + ], + "domContract": [ + "nodedc-dock-layout", + "nodedc-dock-layout__panel", + "nodedc-dock-layout__preview" + ], + "summary": "Arbitrary nested viewport splits with stable media hosts and an exact destination contour during docking.", + "behavior": [ + "center swaps identities", + "four edges split the destination", + "empty source branches collapse", + "6 px handle activation", + "pointer-position hit testing", + "outside and self drops cancel", + "keyboard docking", + "resizable splits", + "focus preserves media hosts" + ], + "rules": [ + "Applications persist the serializable tree and own panel content.", + "Drag geometry follows the pointer, not the size or center of the source window.", + "The preview shows the final source rectangle after removing the source and splitting the target.", + "Space or Enter starts keyboard docking, Tab chooses the destination, arrows choose an edge, Home chooses swap, Enter commits and Escape cancels.", + "Only the active drag paints a destination contour; no permanent decorative panel outlines.", + "Panel minimumSize propagates through split ancestors, constrains pointer/keyboard resize and expands a scrollable canvas below the viewport limit; never clips content to satisfy a ratio.", + "preferredSize applies only to an unsaved default layout; minimumSize always constrains nested splits and scroll canvas." + ] + }, { "id": "drag-drop", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["DragHandle", "DragDropRoot", "DraggableItem", "DropZone", "SortableScope", "SortableItem", "SortableList"], - "domContract": ["nodedc-drag-handle"], + "exports": [ + "DragHandle", + "DragDropRoot", + "DraggableItem", + "DropZone", + "SortableScope", + "SortableItem", + "SortableList" + ], + "domContract": [ + "nodedc-drag-handle" + ], "summary": "Engine-derived handle-only drag, transfer and sortable primitives with the canonical six-dot grip and a 6 px activation threshold.", - "behavior": ["handle-only drag", "cross-list transfer with explicit overlap acceptance", "vertical-axis reorder", "drop-zone state", "keyboard attributes from dnd-kit"], + "behavior": [ + "handle-only drag", + "cross-list transfer with explicit overlap acceptance", + "vertical-axis reorder", + "drop-zone state", + "keyboard attributes from dnd-kit" + ], "rules": [ "The six-dot handle is the only drag initiator; clicking the row keeps its normal navigation or selection action.", "Sortable rows are visually constrained to the vertical axis and cannot pull their layout horizontally.", @@ -565,8 +1058,15 @@ "id": "inspector", "status": "baseline", "package": "@nodedc/ui-react", - "exports": ["Inspector", "ControlRow", "InspectorSelectField"], - "domContract": ["nodedc-inspector", "nodedc-control-row"], + "exports": [ + "Inspector", + "ControlRow", + "InspectorSelectField" + ], + "domContract": [ + "nodedc-inspector", + "nodedc-control-row" + ], "summary": "Accordion settings/definition inspector derived only from the redesigned Engine environment and NDC agent inspector.", "rules": [ "Legacy Engine inspectors are not reference implementations.", @@ -575,6 +1075,7 @@ "Inspector supports controlled openSections/onOpenSectionsChange state so a consumer can persist the exact accordion layout without remount defaults.", "Inspector selection fields use InspectorSelectField only: a stacked visible label and the 276/8/46 px split control; integrated pills are prohibited.", "The panel variant reuses AdminNavigationPanel pill, icon and theme tokens while retaining the same controlled accordion state and domain-owned content.", + "A section action is a sibling IconButton before the disclosure chevron, never nested in the trigger. It does not toggle the section. Panel chevrons point down when collapsed and up when expanded.", "Accent-filled section headers belong to Environment Settings; neutral headers remain available for other approved inspector contexts." ] }, @@ -654,6 +1155,62 @@ "Consumer owns command lifecycle and blur/cancel release.", "No internal toggle or global keyboard handler." ] + }, + { + "id": "description", + "status": "baseline", + "package": "@nodedc/ui-react", + "exports": [ + "Description" + ], + "domContract": [ + "nodedc-description" + ], + "summary": "Secondary explanatory copy matching SettingsCard descriptions.", + "rules": [ + "Use the same inherited family, regular 400 weight, small font token, muted text token and 1.4 line height for explanatory paragraphs. Do not restyle per feature." + ] + }, + { + "id": "comparison-table", + "status": "baseline", + "package": "@nodedc/ui-react", + "exports": [ + "ComparisonTable", + "ComparisonTableProps" + ], + "domContract": [ + "nodedc-comparison-table" + ], + "summary": "Horizontal entity comparison with one label column and bounded-width entity columns.", + "rules": [ + "Each column has a 9rem minimum. Extra entities scroll horizontally, never collapse into vertical cards.", + "Keep row/column headers semantic and missing values explicit. Domain adapters own freshness and units.", + "The scrollport is keyboard-focusable and contains overscroll. No decorative cell outlines.", + "Compact density uses 21px normal rows and adaptive 7.5rem label / 5.5rem entity minima. The containing dock must admit the full table width and height." + ] + }, + { + "id": "navigation-cube", + "status": "baseline", + "package": "@nodedc/ui-react", + "exports": [ + "NavigationCube", + "NavigationCubeProps", + "CubeDirection" + ], + "domContract": [ + "nodedc-navigation-cube" + ], + "summary": "Renderer-independent BIM-style orientation cube; six faces, twelve edges, eight corners.", + "behavior": [ + "Tracks camera quaternion; never changes projection implicitly", + "Visible regions support hover, focus, Enter/Space and disabled state", + "Consumer owns camera navigation and coordinate conversion", + "Controlled pixel size (default 66), face/text/edge/hover/hoverText colors, overall opacity and independent edgeOpacity", + "Labels rotate and foreshorten in the face plane; they never billboard" + ], + "documentation": "../docs/NAVIGATION_CUBE.md" } ] } diff --git a/registry/icons.json b/registry/icons.json index 460c671..ebe99f9 100644 --- a/registry/icons.json +++ b/registry/icons.json @@ -4,45 +4,141 @@ "package": "@nodedc/ui-react", "baseLibrary": "lucide-react", "defaultSize": 18, - "supportedSizes": [16, 18, 20], + "supportedSizes": [ + 16, + 18, + 20 + ], "strokeWidth": 1.8, - "filledNames": ["play", "stop"], + "filledNames": [ + "play", + "stop" + ], "groups": [ { "id": "window-layer", "label": "Окно и слой", - "referenceSources": ["launcher", "engine"], - "names": ["close", "plus", "expand", "minimize", "refresh", "panel", "apps", "layers"] + "referenceSources": [ + "launcher", + "engine" + ], + "names": [ + "close", + "plus", + "expand", + "minimize", + "refresh", + "panel", + "apps", + "layers" + ] }, { "id": "navigation", "label": "Навигация", - "referenceSources": ["launcher", "engine", "bim-viewer"], - "names": ["chevron-left", "chevron-right", "chevron-down", "chevron-up", "grid", "list", "sliders", "search"] + "referenceSources": [ + "launcher", + "engine", + "bim-viewer" + ], + "names": [ + "chevron-left", + "chevron-right", + "chevron-down", + "chevron-up", + "grid", + "list", + "sliders", + "search", + "orthographic", + "perspective" + ] }, { "id": "editing", "label": "Редактирование", - "referenceSources": ["launcher", "seo"], - "names": ["save", "edit", "trash", "copy", "upload", "download", "external"] + "referenceSources": [ + "launcher", + "seo" + ], + "names": [ + "save", + "edit", + "trash", + "copy", + "upload", + "download", + "external", + "rotate-clockwise", + "select", + "pen", + "rectangle", + "curve", + "undo", + "redo", + "add-point" + ] }, { "id": "state-access", "label": "Состояние и доступ", - "referenceSources": ["launcher", "seo", "task-manager"], - "names": ["check", "alert", "info", "activity", "lock", "key", "shield", "circle", "eye", "eye-off"] + "referenceSources": [ + "launcher", + "seo", + "task-manager" + ], + "names": [ + "check", + "alert", + "info", + "activity", + "lock", + "key", + "shield", + "circle", + "eye", + "eye-off" + ] }, { "id": "entities", "label": "Сущности", - "referenceSources": ["launcher", "task-manager"], - "names": ["profile", "users", "building", "globe", "database", "network", "inbox", "mail"] + "referenceSources": [ + "launcher", + "task-manager" + ], + "names": [ + "profile", + "users", + "building", + "globe", + "database", + "network", + "inbox", + "mail" + ] }, { "id": "content", "label": "Контент", - "referenceSources": ["seo", "bim-viewer", "engine"], - "names": ["camera", "plan", "play", "stop", "image", "video", "file", "folder", "clipboard", "settings", "terminal"] + "referenceSources": [ + "seo", + "bim-viewer", + "engine" + ], + "names": [ + "camera", + "plan", + "play", + "stop", + "image", + "video", + "file", + "folder", + "clipboard", + "settings", + "terminal" + ] } ], "rules": [ diff --git a/registry/schemas/design-profile-v0.1.schema.json b/registry/schemas/design-profile-v0.1.schema.json index fec68b5..0c1e20e 100644 --- a/registry/schemas/design-profile-v0.1.schema.json +++ b/registry/schemas/design-profile-v0.1.schema.json @@ -92,13 +92,15 @@ "additionalProperties": false, "required": ["placement", "background", "border", "outline", "minSize", "maxSize", "lensCount", "autoHide"], "properties": { - "placement": { "enum": ["left", "right", "bottom"] }, + "placement": { "enum": ["left", "right", "top", "bottom"] }, "background": { "$ref": "#/$defs/hex" }, "border": { "$ref": "#/$defs/hex" }, "outline": { "$ref": "#/$defs/hex" }, "minSize": { "type": "number", "minimum": 16, "maximum": 64 }, "maxSize": { "type": "number", "minimum": 32, "maximum": 160 }, - "lensCount": { "type": "integer", "minimum": 1, "maximum": 12 }, + "lensCount": { "type": "integer", "minimum": 1, "maximum": 13 }, + "hideDelay": { "type": "number", "minimum": 0, "maximum": 15000 }, + "gap": { "type": "number", "minimum": 0, "maximum": 24 }, "autoHide": { "type": "boolean" } } }, diff --git a/scripts/analysis-controls.test.mjs b/scripts/analysis-controls.test.mjs new file mode 100644 index 0000000..d30c9f8 --- /dev/null +++ b/scripts/analysis-controls.test.mjs @@ -0,0 +1,54 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { createElement } from 'react'; +import { renderToStaticMarkup } from 'react-dom/server'; +import { SegmentedControl, SegmentedGroup, SegmentedButton, ProgressButton, LayerStackIndicator } from '../packages/ui-react/dist/index.js'; + +test('multiple segments allow all/none and never drop another active layer', () => { + let value = ['gaussian']; + const items = [{value:'gaussian',label:'Gaussian'},{value:'collision',label:'Коллизии'}]; + const render = () => SegmentedControl({selectionMode:'multiple',value,items,label:'Слои',onChange:next=>{value=next;}}); + render().props.children[1].props.onClick(); + assert.deepEqual(value,['gaussian','collision']); + render().props.children[0].props.onClick(); + assert.deepEqual(value,['collision']); + render().props.children[1].props.onClick(); + assert.deepEqual(value,[]); + const html=renderToStaticMarkup(render()); + assert.match(html,/role="group"/); + assert.doesNotMatch(html,/role="tab|aria-selected/); + assert.equal((html.match(/aria-pressed="false"/g)||[]).length,2); +}); + +test('single segment consumers retain one selected tab and scalar changes', () => { + let value='3d'; + const element=SegmentedControl({value,items:[{value:'3d',label:'3D'},{value:'top',label:'Top'}],label:'View',onChange:next=>{value=next;}}); + assert.match(renderToStaticMarkup(element),/role="tablist"/); + element.props.children[1].props.onClick(); + assert.equal(value,'top'); +}); + +test('pending progress preserves action name, rejects reentry and exposes a separate measured progressbar', () => { + const html=renderToStaticMarkup(createElement(ProgressButton,{label:'Проанализировать',icon:createElement(LayerStackIndicator),progress:{label:'Анализ поверхности · 29 / 96',value:29/96}})); + assert.match(html,/]*aria-label="Проанализировать"[^>]*disabled=""/); + assert.match(html,/aria-busy="true"/); + assert.match(html,/aria-valuenow="30"/); + assert.match(html,/<\/button>[\s\S]*role="progressbar"/); + assert.match(html,/Анализ поверхности/); + const unknown=renderToStaticMarkup(createElement(ProgressButton,{label:'Анализ',progress:{label:'Подготовка'}})); + assert.doesNotMatch(unknown,/aria-valuenow/); + const idle=renderToStaticMarkup(createElement(ProgressButton,{label:'Анализ'})); + assert.doesNotMatch(idle,/disabled=""|role="progressbar"/); +}); + + +test('mixed capsule keeps toggle and menu semantics distinct', () => { + const html=renderToStaticMarkup(createElement(SegmentedGroup,{label:'Layers'}, + createElement(SegmentedButton,{active:true,'aria-pressed':true},'Gaussian'), + createElement(SegmentedButton,{'aria-expanded':false,'aria-haspopup':'dialog'},'Memory'))); + assert.match(html,/role="group" aria-label="Layers"/); + assert.match(html,/aria-pressed="true"[^>]*data-active="true"/); + assert.match(html,/aria-expanded="false" aria-haspopup="dialog"/); + assert.equal((html.match(/aria-pressed/g)||[]).length,1); + assert.doesNotMatch(html,/role="tab/); +}); diff --git a/scripts/control-density-contract.test.mjs b/scripts/control-density-contract.test.mjs index 5dd4bb5..78604e5 100644 --- a/scripts/control-density-contract.test.mjs +++ b/scripts/control-density-contract.test.mjs @@ -35,3 +35,15 @@ test("dense viewer controls remain a public Button and SegmentedControl contract assert.match(docs, /size="dense"/); assert.match(docs, /viewer/); }); + +test("viewport controls share one scale without scaling nested controls twice", async () => { + const [tokens,styles,registrySource] = await Promise.all([ + readFile(new URL("../packages/tokens/tokens.css",import.meta.url),"utf8"), + readFile(new URL("../packages/ui-core/styles.css",import.meta.url),"utf8"), + readFile(new URL("../registry/components.json",import.meta.url),"utf8"), + ]); + assert.match(tokens,/--nodedc-viewport-control-scale: 0\.7/); + assert.match(styles,/zoom: var\(--nodedc-viewport-control-scale\)/); + assert.match(styles, /\.nodedc-segmented\) :is\([^}]+zoom: 1;/); + assert.ok(JSON.parse(registrySource).components.find(c=>c.id==='button').domContract.includes('nodedc-viewport-controls')); +}); diff --git a/scripts/dock-layout.test.mjs b/scripts/dock-layout.test.mjs new file mode 100644 index 0000000..f6bddb1 --- /dev/null +++ b/scripts/dock-layout.test.mjs @@ -0,0 +1,81 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import {preferDockSizes,dockMinimum,constrainDockTree,balancedDockTree,decodeDockTree,dockIds,dockPosition,dockRects,moveDockPanel,pruneDockTree,reconcileDockTree,resizeDockSplit} from '../packages/ui-core/dist/dockTree.js'; +const bounds={left:0,top:0,width:1200,height:800}; +const initial=balancedDockTree(['a','b','c']); +const rects=tree=>dockRects(tree,bounds); + +test('three asymmetric panes: center exchanges contents without changing slots',()=>{ + const before=rects(initial),next=rects(moveDockPanel(initial,{activeId:'c',overId:'a',position:'center'})); + assert.deepEqual(next.c,before.a);assert.deepEqual(next.a,before.c);assert.deepEqual(next.b,before.b); +}); +test('left to top/bottom edge of right pane gives one left and two right',()=>{ + for(const position of ['top','bottom']){ + const next=moveDockPanel(initial,{activeId:'a',overId:'c',position}),r=rects(next); + assert.deepEqual(r.b,{left:0,top:0,width:600,height:800}); + assert.deepEqual(r.a,{left:600,top:position==='top'?0:400,width:600,height:400}); + assert.deepEqual(r.c,{left:600,top:position==='top'?400:0,width:600,height:400}); + } +}); +test('right window moves to any edge of a left pane; left/right create a middle column',()=>{ + for(const position of ['left','right','top','bottom']){ + const next=moveDockPanel(initial,{activeId:'c',overId:'a',position}),r=rects(next); + assert.deepEqual(r.b,{left:0,top:400,width:1200,height:400}); + assert.equal(position==='left'?r.c.leftr.a.left:position==='top'?r.c.topr.a.top,true); + } +}); +test('every source/destination/edge for 2..12 panes retains each identity and tiles the whole area',()=>{ + for(let n=2;n<=12;n++){ + const ids=Array.from({length:n},(_,i)=>String(i));let tree=balancedDockTree(ids); + for(const activeId of ids)for(const overId of ids)for(const position of ['center','left','right','top','bottom']){ + tree=moveDockPanel(tree,{activeId,overId,position}); + assert.deepEqual([...dockIds(tree)].sort(),[...ids].sort()); + const panels=Object.values(rects(tree)); + assert.ok(Math.abs(panels.reduce((total,r)=>total+r.width*r.height,0)-bounds.width*bounds.height)<1e-6); + for(let i=0;i{ + const r={left:400,top:100,width:800,height:600}; + assert.equal(dockPosition(r,405,400),'left');assert.equal(dockPosition(r,1195,400),'right'); + assert.equal(dockPosition(r,800,105),'top');assert.equal(dockPosition(r,800,695),'bottom'); + assert.equal(dockPosition(r,800,400),'center');assert.equal(dockPosition(r,399,400),null); + assert.equal(moveDockPanel(initial,{activeId:'a',overId:'a',position:'left'}),initial); + assert.equal(moveDockPanel(initial,{activeId:'missing',overId:'c',position:'center'}),initial); +}); +test('resize, focus, persistence and new/missing sources preserve identity',()=>{ + const changed=resizeDockSplit(initial,'0',63); + assert.equal(changed.first.ratio,63);assert.equal(initial.first.ratio,50); + assert.deepEqual(decodeDockTree(JSON.parse(JSON.stringify(changed))),changed); + assert.deepEqual(pruneDockTree(changed,['c']),{id:'c'}); + const restored=reconcileDockTree(pruneDockTree(changed,['a','c']),['a','b','c','d']); + assert.deepEqual(dockIds(restored).sort(),['a','b','c','d']); + assert.deepEqual(decodeDockTree({axis:'x',ratio:50,first:{id:'a'},second:{id:'a'}}),{id:'a'}); + assert.equal(decodeDockTree({axis:'x',ratio:Infinity}),null); +}); + +test('recursive minimums protect all columns and rows after extreme resize',()=>{ + const t={axis:'x',ratio:99,first:{id:'scene'},second:{axis:'y',ratio:1,first:{id:'telemetry'},second:{id:'camera'}}}; + for(let n=1;n<=8;n++){ + const sizes={telemetry:{width:144+88*n,height:280}},minimum=dockMinimum(t,sizes); + for(const requested of [{width:1200,height:800},{width:100,height:100}]){ + const b={left:0,top:0,width:Math.max(requested.width,minimum.width),height:Math.max(requested.height,minimum.height)}; + const c=constrainDockTree(t,b,sizes),r=dockRects(c,b); + assert.ok(r.telemetry.width+1e-8>=sizes.telemetry.width);assert.ok(r.telemetry.height+1e-8>=280); + assert.ok(r.scene.width+1e-8>=160);assert.ok(r.camera.height+1e-8>=120); + assert.deepEqual(constrainDockTree(c,b,sizes),c); + } + } +}); + +test('new compact panel uses its preferred size without changing saved ratios',()=>{ + const t={axis:'x',ratio:65,first:{id:'map'},second:{axis:'y',ratio:40,first:{id:'telemetry'},second:{id:'camera'}}}; + const sizes={telemetry:{width:320,height:280}}; + const initial=constrainDockTree(preferDockSizes(t,bounds,sizes),bounds,sizes),r=rects(initial); + assert.ok(Math.abs(r.telemetry.width-320)<1e-8);assert.ok(Math.abs(r.telemetry.height-280)<1e-8); + assert.deepEqual(preferDockSizes(t,bounds,{}),t); +}); diff --git a/scripts/navigation-cube.test.mjs b/scripts/navigation-cube.test.mjs new file mode 100644 index 0000000..4692219 --- /dev/null +++ b/scripts/navigation-cube.test.mjs @@ -0,0 +1,24 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {cubeRegions} from '../packages/ui-react/dist/NavigationCube.js'; +test('cube exposes exactly 26 unique face/edge/corner directions over all sides',()=>{ + const views=[[0,0,0,1],[0,1,0,0],[0,Math.SQRT1_2,0,Math.SQRT1_2],[0,-Math.SQRT1_2,0,Math.SQRT1_2],[Math.SQRT1_2,0,0,Math.SQRT1_2],[-Math.SQRT1_2,0,0,Math.SQRT1_2]]; + const dirs=new Set(views.flatMap(q=>cubeRegions(q).map(r=>r.direction.join(',')))); + assert.equal(dirs.size,26);assert.ok(!dirs.has('0,0,0')); + assert.deepEqual(cubeRegions([0,0,0,1]).filter(r=>r.faceLabel).map(r=>r.faceLabel),['FRONT']); + assert.deepEqual(cubeRegions([Math.SQRT1_2,0,0,Math.SQRT1_2]).filter(r=>r.faceLabel).map(r=>r.faceLabel),['BOTTOM']); + for(const q of views)for(const r of cubeRegions(q)){assert.ok(!r.polygon.includes('NaN'));assert.ok(r.label);} +}); + +test('labels are projected in each face plane with no mirrored front-facing text',()=>{ + const q=[.28,-.36,.12,.88],regions=cubeRegions(q).filter(r=>r.faceLabel); + assert.equal(regions.length,3); + for(const r of regions){ + const [a,b,c,d,e,f]=r.textMatrix;assert.ok(a*d-b*c>0);assert.ok(a*d-b*c<1); + assert.ok(r.textMatrix.every(Number.isFinite));assert.ok(Math.abs(b)+Math.abs(c)>0.05); + const points=r.polygon.split(' ').map(p=>p.split(',').map(Number)); + assert.ok(Math.abs(points.reduce((n,p)=>n+p[0],0)/4-e)<1e-9); + assert.ok(Math.abs(points.reduce((n,p)=>n+p[1],0)/4-f)<1e-9); + } + assert.deepEqual(cubeRegions([0,0,0,1]).find(r=>r.faceLabel).textMatrix.map(n=>n||0),[1,0,0,1,60,60]); +}); diff --git a/scripts/range-control-contract.test.mjs b/scripts/range-control-contract.test.mjs index eb6bfd4..d9743e4 100644 --- a/scripts/range-control-contract.test.mjs +++ b/scripts/range-control-contract.test.mjs @@ -23,47 +23,33 @@ test("RangeControl keeps native drag semantics and exposes one persistent exact- assert.doesNotMatch(markup, /nodedc-range__value-hit/); }); -test("vertical scale keeps endpoints outside and the label/value centered at every fill level", () => { +test("vertical scale exposes retained bounds without center text and follows every value", () => { for (const [value, progress] of [[-1.2, 0], [25.15, 50], [51.5, 100]]) { - const markup = renderToStaticMarkup(createElement(RangeControl, { - label: "Срез", orientation: "vertical", value, min: -1.2, max: 51.5, step: "any", - formatValue: (n) => `${n.toFixed(1).replace('.', ',')} м`, - formatLimit: (n) => n.toFixed(1).replace('.', ','), onChange: () => {}, - })); - const renderedProgress = Number(markup.match(/--nodedc-range-progress:([\d.]+)%/)?.[1]); - assert.ok(Math.abs(renderedProgress - progress) < 1e-9); - assert.match(markup, /aria-label="Срез" aria-orientation="vertical"/); - assert.match(markup, /min="-1.2" max="51.5" step="any"/); - assert.equal((markup.match(/nodedc-range-scale__limit--max">51,5<\/span>/g) ?? []).length, 1); - assert.equal((markup.match(/nodedc-range-scale__limit--min">-1,2<\/span>/g) ?? []).length, 1); - assert.match(markup, /<\/span><\/span><\/div>Срез · /g) ?? []).length, 2); - assert.match(markup, /nodedc-range__fill-text" aria-hidden="true"/); - assert.doesNotMatch(markup, /nodedc-range__value|nodedc-range__editor|formatLimit=/); + for (const limitSide of ["left", "right"]) { + const markup = renderToStaticMarkup(createElement(RangeControl, { + label: "Срез", orientation: "vertical", limitSide, value, min: -1.2, max: 51.5, step: "any", + formatValue: n => `${n.toFixed(1)} м`, formatLimit: n => n.toFixed(1), onChange: () => {}, + })); + const renderedProgress = Number(markup.match(/--nodedc-range-progress:([\d.]+)%/)?.[1]); + assert.ok(Math.abs(renderedProgress - progress) < 1e-9); + assert.ok(markup.includes(`data-limit-side="${limitSide}"`)); + assert.ok(markup.includes(`nodedc-range-scale__limit--max">${value.toFixed(1)}`)); + assert.match(markup, /nodedc-range-scale__limit--min">-1.2<\/span>/); + assert.match(markup, /aria-label="Срез" aria-orientation="vertical"/); + assert.ok(markup.includes(`aria-valuetext="${value.toFixed(1)} м"`)); + assert.match(markup, /min="-1.2" max="51.5" step="any"/); + assert.doesNotMatch(markup, /nodedc-range__label|nodedc-range__fill-text|nodedc-range__editor|formatLimit=/); + } } }); -test("vertical scale mirrors only endpoint labels for the opposite scene edge", () => { - const markup = renderToStaticMarkup(createElement(RangeControl, { - label: "Срез", orientation: "vertical", limitSide: "left", value: 25.15, min: -1.2, max: 51.5, - step: "any", formatLimit: (n) => n.toFixed(1).replace('.', ','), onChange: () => {}, - })); - assert.match(markup, /class="nodedc-range-scale" data-limit-side="left"/); - assert.match(markup, /nodedc-range-scale__limit--max">51,5<\/span>/); - assert.match(markup, /nodedc-range-scale__limit--min">-1,2<\/span>/); -}); - -test("vertical contrast clips both glyph layers and visible focus has no perimeter", async () => { +test("thin vertical rail retains a usable pointer target and boundary focus", async () => { const styles = await readFile(new URL("../packages/ui-core/styles.css", import.meta.url), "utf8"); - assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\] \.nodedc-range__fill-text \{ clip-path: inset\(calc\(100% - var\(--nodedc-range-progress\)\) 0 0 round var\(--nodedc-radius-circle\)\)/); - assert.match(styles, /\.nodedc-range-scale \{[^}]*width: calc\(var\(--nodedc-control-height\) \* 0\.4\)/); - assert.match(styles, /\.nodedc-range-scale__limit \{[^}]*left: calc\(100% \+ 0\.4rem\);[^}]*color: var\(--nodedc-text-primary\);[^}]*font-size: calc\(var\(--nodedc-font-size-xs\) \* 0\.9\)/); - assert.match(styles, /\.nodedc-range-scale\[data-limit-side="left"\] \.nodedc-range-scale__limit \{[^}]*right: calc\(100% \+ 0\.4rem\);[^}]*left: auto;[^}]*text-align: right/); - assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\] \.nodedc-range__label \{[^}]*font-size: calc\(var\(--nodedc-font-size-sm\) \* 0\.9\)/); - assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\] \{[^}]*border: 0; outline: 0; box-shadow: none;/); - assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\]:has\(input:focus-visible\) \.nodedc-range__label \{ text-decoration: underline; text-decoration-thickness: 2px;/); - assert.doesNotMatch(styles, /\.nodedc-range\[data-orientation="vertical"\]:has\(input:focus-visible\) \{/); - assert.doesNotMatch(styles, /\.nodedc-range\[data-orientation="vertical"\]:focus-within/); + assert.match(styles, /width: calc\(var\(--nodedc-control-height\) \* 0\.2\)/); + assert.match(styles, /width: max\(100%, 24px\)/); + assert.match(styles, /limit--max \{ bottom: clamp\(/); + assert.match(styles, /range-scale:has\(input:focus-visible\) \.nodedc-range-scale__limit--max \{ text-decoration: underline/); + assert.match(styles, /data-orientation="vertical"\] \{[^}]*border: 0; outline: 0; box-shadow: none;/); }); test("exact editing is a stable native caret field without remount, forced selection or a dark editor box", async () => { @@ -102,3 +88,32 @@ test("exact editing is a stable native caret field without remount, forced selec assert.match(windowComponent, /onCloseRef\.current\(\)/); assert.doesNotMatch(windowComponent, /\[closeOnEscape, onClose, open, shouldLockBodyScroll, shouldTrapFocus\]/); }); + +test("vertical band exposes two independent accessible boundaries", () => { + for (const value of [[-52, 500], [10, 35], [20, 20]]) { + const markup = renderToStaticMarkup(createElement(RangeControl, { + label: "Срез", orientation: "vertical", value, min: -52, max: 500, step: "any", + formatValue: n => `${n} м`, onChange: () => {}, + })); + assert.equal((markup.match(/type="range"/g) ?? []).length, 2); + assert.match(markup, /aria-label="Срез: нижняя граница"/); + assert.match(markup, /aria-label="Срез: верхняя граница"/); + assert.ok(markup.includes(`aria-valuemax="${value[1]}"`)); + assert.ok(markup.includes(`aria-valuemin="${value[0]}"`)); + assert.doesNotMatch(markup, /nodedc-range__label|nodedc-range__editor/); + } +}); + +test("both boundaries move, clamp independently, separate after coincidence and restore endpoints", async () => { + const {moveRangeBoundary: move, nearestRangeBoundary: nearest} = await import("../packages/ui-react/dist/rangeBand.js"); + let band = [-52, 500]; + assert.equal(nearest(band, -40), 0); assert.equal(nearest(band, 450), 1); + band = move(band, 0, 10, -52, 500, "any"); assert.deepEqual(band, [10, 500]); + band = move(band, 1, 30, -52, 500, "any"); assert.deepEqual(band, [10, 30]); + band = move(band, 0, 50, -52, 500, "any"); assert.deepEqual(band, [30, 30]); + assert.equal(nearest(band, 20), 0); assert.equal(nearest(band, 40), 1); + band = move(band, 0, -100, -52, 500, "any"); + band = move(band, 1, 600, -52, 500, "any"); assert.deepEqual(band, [-52, 500]); + assert.deepEqual(move([0, 10], 1, 7.3, 0, 10, .5), [0, 7.5]); + assert.deepEqual(move([0, 9], 1, 10.1, 0, 10.1, 3), [0, 10.1]); +}); diff --git a/scripts/settings-surfaces.test.mjs b/scripts/settings-surfaces.test.mjs new file mode 100644 index 0000000..b337987 --- /dev/null +++ b/scripts/settings-surfaces.test.mjs @@ -0,0 +1,25 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import {createElement as h} from 'react'; +import {renderToStaticMarkup} from 'react-dom/server'; +import {LoadingRegion,Description,SettingsCard,ComparisonTable} from '../packages/ui-react/dist/index.js'; +test('composed loading draws exactly one owner even with multiple pending descendants',()=>{ + const child=h(LoadingRegion,{loading:true,label:'child'},h('span',null,'retained')); + const markup=renderToStaticMarkup(h(LoadingRegion,{aggregate:true,loading:true,label:'equipment'},child,child,h(LoadingRegion,{aggregate:true,loading:true,label:'nested'},child))); + assert.equal((markup.match(/role="status"/g)||[]).length,1);assert.match(markup,/aria-label="equipment"/);assert.equal((markup.match(/retained/g)||[]).length,3); +}); +test('independent surfaces keep their loaders and resolved content has no indicator',()=>{ + const markup=renderToStaticMarkup(h('div',null,h(LoadingRegion,{loading:true,label:'a'}),h(LoadingRegion,{loading:true,label:'b'}))); + assert.equal((markup.match(/role="status"/g)||[]).length,2); + assert.doesNotMatch(renderToStaticMarkup(h(LoadingRegion,{aggregate:true,loading:false,label:'done'},h(LoadingRegion,{loading:false,label:'child'},'ready'))),/role="status"/); +}); +test('comparison has one label column, arbitrary entity columns and semantic headers',()=>{ + for(const count of [1,2,3,4,8]){ + const markup=renderToStaticMarkup(h(ComparisonTable,{label:'VESC',heading:'VESC',columns:Array.from({length:count},(_,i)=>({id:String(i),label:'id'+i})),rows:[{id:'position',label:'Расположение',cells:Array(count).fill('Левый')},{id:'current',label:'Ток',cells:[]}]})); + assert.equal((markup.match(/scope="col"/g)||[]).length,count+1);assert.equal((markup.match(/scope="row"/g)||[]).length,2);assert.equal((markup.match(//g)||[]).length,2*count);assert.match(markup,/tabindex="0"/); + } +}); +test('SettingsCard and standalone explanatory paragraphs use one typography component',()=>{ + assert.match(renderToStaticMarkup(h(Description,null,'help')),/class="nodedc-description"/); + assert.match(renderToStaticMarkup(h(SettingsCard,{title:'Settings',description:'help'})),/

help/); +}); diff --git a/scripts/toolbar-menu.test.mjs b/scripts/toolbar-menu.test.mjs new file mode 100644 index 0000000..de4ecbe --- /dev/null +++ b/scripts/toolbar-menu.test.mjs @@ -0,0 +1,23 @@ +import assert from "node:assert/strict"; +import {test} from "node:test"; +import {computeFloatingPosition,movingToMenu} from "../packages/ui-core/dist/index.js"; +test("menus stay beyond the maximum magnified edge, including narrow windows",()=>{ + for(const width of [320,640,1400])for(const size of [25,42,88]){ + const anchor={left:width-12-size,right:width-12,top:200,bottom:225,width:size,height:25}; + const p=computeFloatingPosition({anchor,surfaceWidth:220,surfaceHeight:400,placement:"left-start",flip:false,viewportWidth:width,viewportHeight:600}); + assert.ok(p.left+Math.min(220,p.maxWidth)<=anchor.left-8+1e-9); + assert.ok(p.left>=8);assert.ok(p.top+Math.min(400,p.maxHeight)<=592); + const mirror={...anchor,left:12,right:12+size}; + const q=computeFloatingPosition({anchor:mirror,surfaceWidth:220,surfaceHeight:400,placement:"right-start",flip:false,viewportWidth:width,viewportHeight:600}); + assert.ok(q.left>=mirror.right+8);assert.ok(q.left+Math.min(220,q.maxWidth)<=width-8); + } +}); +test("intent triangle protects diagonal entry but never blocks deliberate vertical or reverse motion",()=>{ + const s={left:200,right:450,top:100,bottom:500,width:250,height:400},o={x:490,y:200}; + assert.equal(movingToMenu(o,o,{x:480,y:210},s),true); + assert.equal(movingToMenu(o,o,{x:490,y:240},s),false); + assert.equal(movingToMenu(o,{x:480,y:210},{x:485,y:220},s),false); + assert.equal(movingToMenu(o,o,{x:480,y:600},s),false); + assert.equal(movingToMenu({x:150,y:200},{x:150,y:200},{x:160,y:210},s),true); + assert.equal(movingToMenu({x:300,y:550},{x:300,y:550},{x:310,y:540},s),true); +}); diff --git a/server/catalog-server.mjs b/server/catalog-server.mjs index 7a6e1da..d2b0141 100644 --- a/server/catalog-server.mjs +++ b/server/catalog-server.mjs @@ -1121,7 +1121,7 @@ function validateDesignProfileLayout(value) { if (media.logoSource !== "file" && media.logoSource !== "url") throw applicationError("invalid_design_profile_logo_source"); if (!isObject(media.faviconAssets)) throw applicationError("invalid_design_profile_favicon_assets"); if (glass.version !== 4) throw applicationError("unsupported_glass_material_version"); - if (!["left", "right", "bottom"].includes(toolbar.placement)) throw applicationError("invalid_toolbar_placement"); + if (!["left", "right", "top", "bottom"].includes(toolbar.placement)) throw applicationError("invalid_toolbar_placement"); return { theme: value.theme, accentHex: requireHex(value.accentHex, "invalid_design_profile_accent"), @@ -1176,8 +1176,10 @@ function validateDesignProfileLayout(value) { outline: requireHex(toolbar.outline, "invalid_toolbar_outline"), minSize: requireNumber(toolbar.minSize, 16, 64, "invalid_toolbar_min_size"), maxSize: requireNumber(toolbar.maxSize, 32, 160, "invalid_toolbar_max_size"), - lensCount: requireInteger(toolbar.lensCount, 1, 12, "invalid_toolbar_lens_count"), + lensCount: requireInteger(toolbar.lensCount, 1, 13, "invalid_toolbar_lens_count"), autoHide: requireBoolean(toolbar.autoHide, "invalid_toolbar_auto_hide"), + hideDelay: requireNumber(toolbar.hideDelay ?? 5000,0,15000,"invalid_toolbar_hide_delay"), + gap: requireNumber(toolbar.gap ?? 10,0,24,"invalid_toolbar_gap"), }, pageTypes: validateDesignProfilePageTypes(value.pageTypes), };