Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d96eba824a | ||
|
|
6bf22988c5 |
@@ -11,8 +11,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/page-patterns": "0.1.0",
|
"@nodedc/page-patterns": "0.1.0",
|
||||||
"@nodedc/ui-core": "0.7.2",
|
"@nodedc/ui-core": "0.7.3",
|
||||||
"@nodedc/ui-react": "0.7.5",
|
"@nodedc/ui-react": "0.7.8",
|
||||||
"cesium": "1.147.0",
|
"cesium": "1.147.0",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0"
|
"react-dom": "^19.1.0"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import {
|
|||||||
ShareLinkModal,
|
ShareLinkModal,
|
||||||
SplitPane,
|
SplitPane,
|
||||||
SortableItem,
|
SortableItem,
|
||||||
|
SortableList,
|
||||||
SortableScope,
|
SortableScope,
|
||||||
SettingsCard,
|
SettingsCard,
|
||||||
Switch,
|
Switch,
|
||||||
@@ -406,6 +407,9 @@ export function CatalogApp() {
|
|||||||
const [strokeColor, setStrokeColor] = useState("#2b2b36");
|
const [strokeColor, setStrokeColor] = useState("#2b2b36");
|
||||||
const [strokeOpacity, setStrokeOpacity] = useState(100);
|
const [strokeOpacity, setStrokeOpacity] = useState(100);
|
||||||
const [treeDemoOpen,setTreeDemoOpen]=useState(false);
|
const [treeDemoOpen,setTreeDemoOpen]=useState(false);
|
||||||
|
const [gridOrder,setGridOrder]=useState(["Первое изображение","Второе изображение","Третье изображение"]);
|
||||||
|
const [detailFloating,setDetailFloating]=useState(false);
|
||||||
|
const [detailRect,setDetailRect]=useState<import("@nodedc/ui-react").WindowRect>();
|
||||||
const [treeDemoRect,setTreeDemoRect]=useState({left:32,top:96,width:380,height:480});
|
const [treeDemoRect,setTreeDemoRect]=useState({left:32,top:96,width:380,height:480});
|
||||||
const [treeSelected,setTreeSelected]=useState<string|null>('cells');
|
const [treeSelected,setTreeSelected]=useState<string|null>('cells');
|
||||||
const [treeVisible,setTreeVisible]=useState(true);
|
const [treeVisible,setTreeVisible]=useState(true);
|
||||||
@@ -1468,6 +1472,7 @@ export function CatalogApp() {
|
|||||||
<div className="catalog-form">
|
<div className="catalog-form">
|
||||||
<TextField label="Название проекта" hint="обязательно" value={projectName} onChange={(event) => setProjectName(event.target.value)} />
|
<TextField label="Название проекта" hint="обязательно" value={projectName} onChange={(event) => setProjectName(event.target.value)} />
|
||||||
<TextAreaField label="Описание" value={notes} onChange={(event) => setNotes(event.target.value)} />
|
<TextAreaField label="Описание" value={notes} onChange={(event) => setNotes(event.target.value)} />
|
||||||
|
<TextAreaField appearance="plain" label="" aria-label="Текст заметки" value={notes} onChange={(event) => setNotes(event.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
</Preview>
|
</Preview>
|
||||||
<Preview title="Действия" note="общая геометрия" className="catalog-preview--compact">
|
<Preview title="Действия" note="общая геометрия" className="catalog-preview--compact">
|
||||||
@@ -1549,6 +1554,7 @@ export function CatalogApp() {
|
|||||||
</ResourceList>
|
</ResourceList>
|
||||||
<Button onClick={()=>setTreeDemoOpen(true)}>Дерево объектов · изменяемый размер</Button>
|
<Button onClick={()=>setTreeDemoOpen(true)}>Дерево объектов · изменяемый размер</Button>
|
||||||
<DragDropRoot onDragEnd={()=>{}}><DraggableItem id="whole-material-tile">{({activator})=><Button {...activator.attributes} {...activator.listeners}>Перенос за всю плитку</Button>}</DraggableItem></DragDropRoot>
|
<DragDropRoot onDragEnd={()=>{}}><DraggableItem id="whole-material-tile">{({activator})=><Button {...activator.attributes} {...activator.listeners}>Перенос за всю плитку</Button>}</DraggableItem></DragDropRoot>
|
||||||
|
<SortableList handleSurface="control" layout="grid" className="catalog-sortable-grid" items={gridOrder} getId={item=>item} onReorder={setGridOrder}>{(item,{handle})=><GlassSurface padding="sm">{handle}<Icon name="image"/><Description>{item}</Description></GlassSurface>}</SortableList>
|
||||||
<SettingsCard title="Устройства не обнаружены" description="Подключите устройство, чтобы оно появилось в списке." />
|
<SettingsCard title="Устройства не обнаружены" description="Подключите устройство, чтобы оно появилось в списке." />
|
||||||
<SettingsCard align="center" role="status" title="Настройки применены" description="Проверьте подключение устройства." />
|
<SettingsCard align="center" role="status" title="Настройки применены" description="Проверьте подключение устройства." />
|
||||||
</Preview>
|
</Preview>
|
||||||
@@ -2401,6 +2407,8 @@ export function CatalogApp() {
|
|||||||
|
|
||||||
<Window
|
<Window
|
||||||
open={createModuleOpen}
|
open={createModuleOpen}
|
||||||
|
floating={detailFloating} onFloatingChange={setDetailFloating}
|
||||||
|
rect={detailRect} onRectCommit={setDetailRect}
|
||||||
title="Создать модуль"
|
title="Создать модуль"
|
||||||
headerActionsPlacement="before-close"
|
headerActionsPlacement="before-close"
|
||||||
headerActions={<IconButton label="Очистить форму" onClick={() => {setCreateModuleName("");setCreateModuleSlug("");}}><Icon name="trash"/></IconButton>}
|
headerActions={<IconButton label="Очистить форму" onClick={() => {setCreateModuleName("");setCreateModuleSlug("");}}><Icon name="trash"/></IconButton>}
|
||||||
|
|||||||
@@ -2307,3 +2307,5 @@ textarea {
|
|||||||
.catalog-theme-fields { display: grid; gap: var(--nodedc-space-4); }
|
.catalog-theme-fields { display: grid; gap: var(--nodedc-space-4); }
|
||||||
|
|
||||||
.catalog-viewport-actions {position:absolute;top:var(--nodedc-space-3);right:var(--nodedc-space-3);display:flex;gap:var(--nodedc-space-2);padding:var(--nodedc-space-2);}
|
.catalog-viewport-actions {position:absolute;top:var(--nodedc-space-3);right:var(--nodedc-space-3);display:flex;gap:var(--nodedc-space-2);padding:var(--nodedc-space-2);}
|
||||||
|
|
||||||
|
.catalog-sortable-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--nodedc-space-3,12px)}
|
||||||
|
|||||||
+10
-1
@@ -46,7 +46,7 @@ Icon-only action по умолчанию круглый. Квадратная к
|
|||||||
|
|
||||||
## Field
|
## Field
|
||||||
|
|
||||||
FieldFrame объединяет label, control, hint и description. `labelPlacement="below"` ставит компактную приглушённую подпись под контролом в заголовке; доступное имя контрола остаётся прежним. TextField/TextAreaField реализуют стандартные текстовые поля. Автозаполнение браузера сохраняет материал поля, цвет текста и каретки текущей темы; синяя системная заливка не используется. Клавиатурный фокус остаётся видимым.
|
FieldFrame объединяет label, control, hint и description. `labelPlacement="below"` ставит компактную приглушённую подпись под контролом в заголовке; доступное имя контрола остаётся прежним. TextField/TextAreaField реализуют стандартные текстовые поля. `appearance="plain"` сохраняет вид обычного текста без подложки и позволяет сразу поставить каретку; при пустой подписи нужен `aria-label`. TextAreaField в этом режиме растёт по содержимому и ширине окна, нативные выделение, вставка и undo сохраняются. Автозаполнение браузера сохраняет материал поля, цвет текста и каретки текущей темы; синяя системная заливка не используется. Клавиатурный фокус остаётся видимым.
|
||||||
|
|
||||||
Приложение не должно вручную собирать label и input, если подходит Field. Ошибка и validation state будут расширением этого контракта, а не локальным классом приложения.
|
Приложение не должно вручную собирать label и input, если подходит Field. Ошибка и validation state будут расширением этого контракта, а не локальным классом приложения.
|
||||||
|
|
||||||
@@ -617,3 +617,12 @@ ColorField screen sampling (owner direction, 2026-11-14): the shared palette inc
|
|||||||
Floating EditorDockLayout tools honor minimumSize on restore, all eight resize edges and keyboard resize. If the available viewport is smaller, they fit that viewport; Inspector fields stack below a 330px content width instead of clipping. Tool footer is separate from the scrolling body; a Button width="full" is the canonical adaptive bottom action. The catalog's scene editor example demonstrates minimum size, a ColorField and fixed reset footer.
|
Floating EditorDockLayout tools honor minimumSize on restore, all eight resize edges and keyboard resize. If the available viewport is smaller, they fit that viewport; Inspector fields stack below a 330px content width instead of clipping. Tool footer is separate from the scrolling body; a Button width="full" is the canonical adaptive bottom action. The catalog's scene editor example demonstrates minimum size, a ColorField and fixed reset footer.
|
||||||
|
|
||||||
EditorDockLayout: every floating or actively detached tool uses context="scene" Glass V4 (shared scene tint/blur); docking removes that context and retains tiled surface/corner rules. Applies to hierarchy, layers, settings and any other editor tool. No application tint/blur overrides.
|
EditorDockLayout: every floating or actively detached tool uses context="scene" Glass V4 (shared scene tint/blur); docking removes that context and retains tiled surface/corner rules. Applies to hierarchy, layers, settings and any other editor tool. No application tint/blur overrides.
|
||||||
|
|
||||||
|
### Remembered detail windows and sortable image grids
|
||||||
|
|
||||||
|
`Window.floating/onFloatingChange` lets the host persist modal/floating mode by
|
||||||
|
window kind alongside `rect/onRectCommit`. See WINDOWS_AND_LAYERS.md.
|
||||||
|
`SortableList` and `SortableScope` accept `layout="grid"`; rectangular sorting
|
||||||
|
keeps the shared drag handle and activation threshold. The default stays vertical.
|
||||||
|
|
||||||
|
Для ручки поверх фотографии используйте `DragHandle surface="control"` или `SortableList handleSurface="control"`: видимый круг с общим стеклом внутри `nodedc-viewport-controls`. Bare-ручка остаётся вариантом по умолчанию для обычных строк.
|
||||||
|
|||||||
@@ -175,3 +175,13 @@ ColorField spectrum has no decorative perimeter stroke; retain its visible sampl
|
|||||||
## Focus of movable headers
|
## Focus of movable headers
|
||||||
|
|
||||||
Window, WorkspaceWindow and EditorDockLayout share the same drag-header focus contract. A pointer grab never inherits a keyboard focus ring or filled header from the previously focused input. Headers have no perimeter outline in any theme; keyboard focus uses the canonical contrasting surface. Pointer capture, focus ownership, Arrow/Shift+Arrow movement/resizing, Enter/Space docking and Escape cancellation remain unchanged. Check both direct grabbing and input → Tab → grabbing, in docked/floating and fullscreen contexts.
|
Window, WorkspaceWindow and EditorDockLayout share the same drag-header focus contract. A pointer grab never inherits a keyboard focus ring or filled header from the previously focused input. Headers have no perimeter outline in any theme; keyboard focus uses the canonical contrasting surface. Pointer capture, focus ownership, Arrow/Shift+Arrow movement/resizing, Enter/Space docking and Escape cancellation remain unchanged. Check both direct grabbing and input → Tab → grabbing, in docked/floating and fullscreen contexts.
|
||||||
|
|
||||||
|
## Remembered presentation
|
||||||
|
|
||||||
|
Entity/detail windows persist presentation **by window kind**, not title or entity ID.
|
||||||
|
The application stores `floating` and `rect` in its durable user preferences;
|
||||||
|
`Window` consumes `floating`/`onFloatingChange` and `rect`/`onRectCommit`.
|
||||||
|
Opening the next entity restores the same mode, position and size. Return to modal
|
||||||
|
keeps the last floating rectangle for the next detachment. Viewport fitting does
|
||||||
|
not overwrite saved geometry. Switching view/edit keeps the same mounted Window.
|
||||||
|
Confirmation dialogs remain modal (`allowFloating=false`) and never inherit it.
|
||||||
|
|||||||
Generated
+6
-6
@@ -28,8 +28,8 @@
|
|||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/page-patterns": "0.1.0",
|
"@nodedc/page-patterns": "0.1.0",
|
||||||
"@nodedc/ui-core": "0.7.2",
|
"@nodedc/ui-core": "0.7.3",
|
||||||
"@nodedc/ui-react": "0.7.5",
|
"@nodedc/ui-react": "0.7.8",
|
||||||
"cesium": "1.147.0",
|
"cesium": "1.147.0",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0"
|
"react-dom": "^19.1.0"
|
||||||
@@ -2516,7 +2516,7 @@
|
|||||||
},
|
},
|
||||||
"packages/ui-core": {
|
"packages/ui-core": {
|
||||||
"name": "@nodedc/ui-core",
|
"name": "@nodedc/ui-core",
|
||||||
"version": "0.7.2",
|
"version": "0.7.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/tokens": "0.6.0"
|
"@nodedc/tokens": "0.6.0"
|
||||||
}
|
}
|
||||||
@@ -2525,17 +2525,17 @@
|
|||||||
"name": "@nodedc/ui-dom",
|
"name": "@nodedc/ui-dom",
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/ui-core": "0.7.2"
|
"@nodedc/ui-core": "0.7.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/ui-react": {
|
"packages/ui-react": {
|
||||||
"name": "@nodedc/ui-react",
|
"name": "@nodedc/ui-react",
|
||||||
"version": "0.7.6",
|
"version": "0.7.8",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@nodedc/ui-core": "0.7.2",
|
"@nodedc/ui-core": "0.7.3",
|
||||||
"lucide-react": "^0.468.0"
|
"lucide-react": "^0.468.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nodedc/ui-core",
|
"name": "@nodedc/ui-core",
|
||||||
"version": "0.7.2",
|
"version": "0.7.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -4885,3 +4885,20 @@ textarea.nodedc-field__control {
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--nodedc-text-primary);
|
color: var(--nodedc-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Directly editable detail copy: no permanent field plate. */
|
||||||
|
.nodedc-field--unlabelled > .nodedc-field__label-row {display:none;}
|
||||||
|
.nodedc-field--plain {gap:0;}
|
||||||
|
.nodedc-field--plain .nodedc-field__control {
|
||||||
|
min-height:0; padding:0; border-radius:var(--nodedc-radius-control-compact);
|
||||||
|
background:transparent; box-shadow:none; color:inherit; font:inherit; line-height:inherit;
|
||||||
|
}
|
||||||
|
.nodedc-field--plain .nodedc-field__control:focus-visible {background:var(--nodedc-focus-surface);}
|
||||||
|
.nodedc-field--plain textarea.nodedc-field__control {resize:none;overflow:hidden;}
|
||||||
|
.nodedc-drag-handle[data-surface="control"] {background:var(--nodedc-glass-control-bg);color:var(--nodedc-text-primary);}
|
||||||
|
:is(.nodedc-viewport-controls,.nodedc-scene-controls) .nodedc-drag-handle[data-surface="control"] {
|
||||||
|
background:rgb(var(--nodedc-modal-glass-tint-rgb) / var(--nodedc-scene-glass-opacity));
|
||||||
|
backdrop-filter:blur(var(--nodedc-scene-glass-blur)) saturate(var(--nodedc-modal-glass-saturation));
|
||||||
|
-webkit-backdrop-filter:blur(var(--nodedc-scene-glass-blur)) saturate(var(--nodedc-modal-glass-saturation));
|
||||||
|
}
|
||||||
|
.nodedc-drag-handle[data-surface="control"]:hover {background:var(--nodedc-glass-control-hover);}
|
||||||
|
|||||||
@@ -20,6 +20,6 @@
|
|||||||
"typecheck": "tsc -p tsconfig.json --noEmit"
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/ui-core": "0.7.2"
|
"@nodedc/ui-core": "0.7.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nodedc/ui-react",
|
"name": "@nodedc/ui-react",
|
||||||
"version": "0.7.6",
|
"version": "0.7.8",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@nodedc/ui-core": "0.7.2",
|
"@nodedc/ui-core": "0.7.3",
|
||||||
"lucide-react": "^0.468.0"
|
"lucide-react": "^0.468.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
arrayMove,
|
arrayMove,
|
||||||
useSortable,
|
useSortable,
|
||||||
verticalListSortingStrategy,
|
verticalListSortingStrategy,
|
||||||
|
rectSortingStrategy,
|
||||||
} from "@dnd-kit/sortable";
|
} from "@dnd-kit/sortable";
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
import { cn } from "./cn.js";
|
import { cn } from "./cn.js";
|
||||||
@@ -51,8 +52,9 @@ const copyRect = (rect: DragRect | null | undefined): DragRect | undefined => re
|
|||||||
height: rect.height,
|
height: rect.height,
|
||||||
}) : undefined;
|
}) : undefined;
|
||||||
|
|
||||||
export function DragHandle({ label = "Перетащить", listeners, attributes, className }: {
|
export function DragHandle({ label = "Перетащить", listeners, attributes, className, surface="none" }: {
|
||||||
label?: string;
|
label?: string;
|
||||||
|
surface?: "none" | "control";
|
||||||
listeners?: ReturnType<typeof useDraggable>["listeners"];
|
listeners?: ReturnType<typeof useDraggable>["listeners"];
|
||||||
attributes?: ReturnType<typeof useDraggable>["attributes"];
|
attributes?: ReturnType<typeof useDraggable>["attributes"];
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -61,6 +63,7 @@ export function DragHandle({ label = "Перетащить", listeners, attribut
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={cn("nodedc-drag-handle", className)}
|
className={cn("nodedc-drag-handle", className)}
|
||||||
|
data-surface={surface}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
{...attributes}
|
{...attributes}
|
||||||
{...listeners}
|
{...listeners}
|
||||||
@@ -120,31 +123,36 @@ export function DropZone({ id, data, className, children }: { id: string; data?:
|
|||||||
return <div ref={setNodeRef} className={cn(className, isOver && "is-drag-over")}>{children}</div>;
|
return <div ref={setNodeRef} className={cn(className, isOver && "is-drag-over")}>{children}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SortableScope({ ids, children }: { ids: string[]; children: ReactNode }) {
|
const SortableLayoutContext=createContext<"list"|"grid">("list");
|
||||||
return <SortableContext items={ids} strategy={verticalListSortingStrategy}>{children}</SortableContext>;
|
export function SortableScope({ ids, children, layout="list" }: { ids: string[]; children: ReactNode; layout?:"list"|"grid" }) {
|
||||||
|
return <SortableLayoutContext.Provider value={layout}><SortableContext items={ids} strategy={layout==="grid"?rectSortingStrategy:verticalListSortingStrategy}>{children}</SortableContext></SortableLayoutContext.Provider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SortableItem({ id, data, className, children }: {
|
export function SortableItem({ id, data, className, children, handleSurface="none" }: {
|
||||||
id: string;
|
id: string;
|
||||||
|
handleSurface?: "none" | "control";
|
||||||
data?: NodedcDragData;
|
data?: NodedcDragData;
|
||||||
className?: string;
|
className?: string;
|
||||||
children: (state: { handle: ReactNode; isDragging: boolean }) => ReactNode;
|
children: (state: { handle: ReactNode; isDragging: boolean }) => ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id, data });
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id, data });
|
||||||
const verticalTransform = transform ? { ...transform, x: 0 } : null;
|
const layout=useContext(SortableLayoutContext);
|
||||||
|
const verticalTransform = transform && layout!=="grid" ? { ...transform, x: 0 } : transform;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={setNodeRef}
|
ref={setNodeRef}
|
||||||
className={cn(className, isDragging && "is-dragging")}
|
className={cn(className, isDragging && "is-dragging")}
|
||||||
style={{ transform: CSS.Transform.toString(verticalTransform), transition, opacity: isDragging ? 0.65 : undefined }}
|
style={{ transform: CSS.Transform.toString(verticalTransform), transition, opacity: isDragging ? 0.65 : undefined }}
|
||||||
>
|
>
|
||||||
{children({ handle: <DragHandle listeners={listeners} attributes={attributes} />, isDragging })}
|
{children({ handle: <DragHandle surface={handleSurface} listeners={listeners} attributes={attributes} />, isDragging })}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SortableList<T>({ items, getId, className, onReorder, children }: {
|
export function SortableList<T>({ items, getId, className, onReorder, children, layout="list", handleSurface="none" }: {
|
||||||
items: T[];
|
items: T[];
|
||||||
|
handleSurface?: "none" | "control";
|
||||||
|
layout?: "list" | "grid";
|
||||||
getId: (item: T) => string;
|
getId: (item: T) => string;
|
||||||
className?: string;
|
className?: string;
|
||||||
onReorder: (items: T[]) => void;
|
onReorder: (items: T[]) => void;
|
||||||
@@ -158,10 +166,10 @@ export function SortableList<T>({ items, getId, className, onReorder, children }
|
|||||||
const to = ids.indexOf(overId);
|
const to = ids.indexOf(overId);
|
||||||
if (from >= 0 && to >= 0) onReorder(arrayMove(items, from, to));
|
if (from >= 0 && to >= 0) onReorder(arrayMove(items, from, to));
|
||||||
}}>
|
}}>
|
||||||
<SortableScope ids={ids}>
|
<SortableScope ids={ids} layout={layout}>
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<SortableItem key={getId(item)} id={getId(item)}>
|
<SortableItem key={getId(item)} id={getId(item)} handleSurface={handleSurface}>
|
||||||
{(state) => children(item, state)}
|
{(state) => children(item, state)}
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useId, type InputHTMLAttributes, type ReactNode, type TextareaHTMLAttributes } from "react";
|
import { useId, useLayoutEffect, useRef, type InputHTMLAttributes, type ReactNode, type TextareaHTMLAttributes } from "react";
|
||||||
import { cn } from "./cn.js";
|
import { cn } from "./cn.js";
|
||||||
|
|
||||||
export interface FieldFrameProps {
|
export interface FieldFrameProps {
|
||||||
@@ -29,6 +29,8 @@ export interface TextFieldProps extends InputHTMLAttributes<HTMLInputElement> {
|
|||||||
hint?: string;
|
hint?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
fieldClassName?: string;
|
fieldClassName?: string;
|
||||||
|
/** Plain text appearance for directly editable detail content. Keep an accessible name. */
|
||||||
|
appearance?: "default" | "plain";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TextField({
|
export function TextField({
|
||||||
@@ -36,6 +38,7 @@ export function TextField({
|
|||||||
hint,
|
hint,
|
||||||
description,
|
description,
|
||||||
fieldClassName,
|
fieldClassName,
|
||||||
|
appearance = "default",
|
||||||
className,
|
className,
|
||||||
id,
|
id,
|
||||||
...props
|
...props
|
||||||
@@ -43,7 +46,7 @@ export function TextField({
|
|||||||
const generatedId = useId();
|
const generatedId = useId();
|
||||||
const controlId = id ?? generatedId;
|
const controlId = id ?? generatedId;
|
||||||
return (
|
return (
|
||||||
<FieldFrame label={label} hint={hint} description={description} htmlFor={controlId} className={fieldClassName}>
|
<FieldFrame label={label} hint={hint} description={description} htmlFor={controlId} className={cn(fieldClassName, appearance === "plain" && "nodedc-field--plain", !label && "nodedc-field--unlabelled")}>
|
||||||
<input id={controlId} className={cn("nodedc-field__control", className)} {...props} />
|
<input id={controlId} className={cn("nodedc-field__control", className)} {...props} />
|
||||||
</FieldFrame>
|
</FieldFrame>
|
||||||
);
|
);
|
||||||
@@ -54,6 +57,8 @@ export interface TextAreaFieldProps extends TextareaHTMLAttributes<HTMLTextAreaE
|
|||||||
hint?: string;
|
hint?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
fieldClassName?: string;
|
fieldClassName?: string;
|
||||||
|
/** Plain text appearance for directly editable detail content. Keep an accessible name. */
|
||||||
|
appearance?: "default" | "plain";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TextAreaField({
|
export function TextAreaField({
|
||||||
@@ -61,15 +66,29 @@ export function TextAreaField({
|
|||||||
hint,
|
hint,
|
||||||
description,
|
description,
|
||||||
fieldClassName,
|
fieldClassName,
|
||||||
|
appearance = "default",
|
||||||
className,
|
className,
|
||||||
id,
|
id,
|
||||||
...props
|
...props
|
||||||
}: TextAreaFieldProps) {
|
}: TextAreaFieldProps) {
|
||||||
const generatedId = useId();
|
const generatedId = useId();
|
||||||
const controlId = id ?? generatedId;
|
const controlId = id ?? generatedId;
|
||||||
|
const area = useRef<HTMLTextAreaElement>(null);
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const el = area.current;
|
||||||
|
if (!el || appearance !== "plain") return;
|
||||||
|
const resize = () => { el.style.height = "auto"; el.style.height = el.scrollHeight + "px"; };
|
||||||
|
resize();
|
||||||
|
let width = el.clientWidth;
|
||||||
|
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
|
||||||
|
if (el.clientWidth !== width) { width = el.clientWidth; resize(); }
|
||||||
|
});
|
||||||
|
observer?.observe(el);
|
||||||
|
return () => observer?.disconnect();
|
||||||
|
}, [appearance, props.value]);
|
||||||
return (
|
return (
|
||||||
<FieldFrame label={label} hint={hint} description={description} htmlFor={controlId} className={fieldClassName}>
|
<FieldFrame label={label} hint={hint} description={description} htmlFor={controlId} className={cn(fieldClassName, appearance === "plain" && "nodedc-field--plain", !label && "nodedc-field--unlabelled")}>
|
||||||
<textarea id={controlId} className={cn("nodedc-field__control", className)} {...props} />
|
<textarea ref={area} id={controlId} className={cn("nodedc-field__control", className)} {...props} />
|
||||||
</FieldFrame>
|
</FieldFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ export interface WindowProps extends Omit<HTMLAttributes<HTMLDivElement>, "title
|
|||||||
onRectCommit?: (rect: WindowRect) => void;
|
onRectCommit?: (rect: WindowRect) => void;
|
||||||
/** Centered windows can become modeless without remounting their contents. */
|
/** Centered windows can become modeless without remounting their contents. */
|
||||||
allowFloating?: boolean;
|
allowFloating?: boolean;
|
||||||
|
/** App-owned presentation, persisted by window kind alongside rect. */
|
||||||
|
floating?: boolean;
|
||||||
|
onFloatingChange?: (floating: boolean) => void;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +86,8 @@ export function Window({
|
|||||||
rect,
|
rect,
|
||||||
onRectCommit,
|
onRectCommit,
|
||||||
allowFloating = true,
|
allowFloating = true,
|
||||||
|
floating: controlledFloating,
|
||||||
|
onFloatingChange,
|
||||||
onClose,
|
onClose,
|
||||||
className,
|
className,
|
||||||
style,
|
style,
|
||||||
@@ -107,7 +112,7 @@ export function Window({
|
|||||||
const changeRect = (next: WindowRect | null) => { rectRef.current = next; setFloatingRect(next); };
|
const changeRect = (next: WindowRect | null) => { rectRef.current = next; setFloatingRect(next); };
|
||||||
const gestureChanged = useRef(false);
|
const gestureChanged = useRef(false);
|
||||||
const resizeRef = useRef<{ pointerId: number; x: number; y: number; rect: WindowRect; edge: ResizeEdge } | null>(null);
|
const resizeRef = useRef<{ pointerId: number; x: number; y: number; rect: WindowRect; edge: ResizeEdge } | null>(null);
|
||||||
const isFloating = floating && allowFloating && placement === "center";
|
const isFloating = (controlledFloating ?? floating) && allowFloating && placement === "center";
|
||||||
const freeGeometry = isFloating || (resizable && placement === "end");
|
const freeGeometry = isFloating || (resizable && placement === "end");
|
||||||
const canDrag = draggable || freeGeometry;
|
const canDrag = draggable || freeGeometry;
|
||||||
const shouldLockBodyScroll = !suspended && !isFloating && (lockBodyScroll ?? placement === "center");
|
const shouldLockBodyScroll = !suspended && !isFloating && (lockBodyScroll ?? placement === "center");
|
||||||
@@ -310,7 +315,9 @@ export function Window({
|
|||||||
const rect = dialogRef.current?.getBoundingClientRect();
|
const rect = dialogRef.current?.getBoundingClientRect();
|
||||||
if (rect) changeRect(fitWindow(rectRef.current ?? { left: rect.left, top: rect.top, width: rect.width, height: rect.height }, { width: window.innerWidth, height: window.innerHeight }));
|
if (rect) changeRect(fitWindow(rectRef.current ?? { left: rect.left, top: rect.top, width: rect.width, height: rect.height }, { width: window.innerWidth, height: window.innerHeight }));
|
||||||
}
|
}
|
||||||
|
if (rectRef.current) commitRef.current?.({...rectRef.current});
|
||||||
setFloating(!isFloating);
|
setFloating(!isFloating);
|
||||||
|
onFloatingChange?.(!isFloating);
|
||||||
}}><Icon name="move" /></IconButton>}
|
}}><Icon name="move" /></IconButton>}
|
||||||
{headerActionsPlacement === "before-close" && headerActions}
|
{headerActionsPlacement === "before-close" && headerActions}
|
||||||
<button type="button" className="nodedc-window__close" aria-label={closeLabel} onClick={onClose}>
|
<button type="button" className="nodedc-window__close" aria-label={closeLabel} onClick={onClose}>
|
||||||
|
|||||||
@@ -257,7 +257,8 @@
|
|||||||
"Labels and validation copy are part of the field contract.",
|
"Labels and validation copy are part of the field contract.",
|
||||||
"Keyboard focus changes the surface and remains visible without a browser-blue outline.",
|
"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."
|
"FieldFrame labelPlacement=below is the compact muted caption variant for header selectors; above remains the default.",
|
||||||
|
"appearance=plain renders immediately editable detail copy without a permanent plate; empty labels require aria-label, textarea grows to content, keyboard focus remains visible."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -464,14 +465,15 @@
|
|||||||
"A draggable inspector moves by its header and remains clamped to the viewport.",
|
"A draggable inspector moves by its header and remains clamped to the viewport.",
|
||||||
"Closing a modeless inspector is never gated by autosave; preserve the draft, close immediately and report persistence failure through ToastStack.",
|
"Closing a modeless inspector is never gated by autosave; preserve the draft, close immediately and report persistence failure through ToastStack.",
|
||||||
"Operational copy inside Window uses component typography tokens; browser-default paragraph or heading sizes are forbidden.",
|
"Operational copy inside Window uses component typography tokens; browser-default paragraph or heading sizes are forbidden.",
|
||||||
"Centered windows expose the move toggle by default; allowFloating opts a workflow out. Returning to modal restores canonical centered geometry; closing clears floating geometry.",
|
"Centered windows expose the move toggle by default; allowFloating opts a workflow out. Returning to modal restores canonical centered geometry; uncontrolled windows clear floating geometry on close.",
|
||||||
"Floating header supports arrow-key movement and Shift+arrow resizing. Bounds stay inside the viewport. Resize affordances have no hover decoration.",
|
"Floating header supports arrow-key movement and Shift+arrow resizing. Bounds stay inside the viewport. Resize affordances have no hover decoration.",
|
||||||
"Inspectors inside a Window use its full available content width.",
|
"Inspectors inside a Window use its full available content width.",
|
||||||
"End inspectors opt into resizable with an optional initialRect; existing eight edge geometry and keyboard resize are shared with floating windows.",
|
"End inspectors opt into resizable with an optional initialRect; existing eight edge geometry and keyboard resize are shared with floating windows.",
|
||||||
"Application-owned rect restores modeless window geometry on reopen and external undo/import. onRectCommit reports one completed drag/resize or keyboard step; viewport fitting never overwrites saved geometry.",
|
"Application-owned rect restores modeless window geometry on reopen and external undo/import. onRectCommit reports one completed drag/resize or keyboard step; viewport fitting never overwrites saved geometry.",
|
||||||
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions.",
|
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions.",
|
||||||
"Drag headers never draw perimeter outlines or inherit keyboard-focus fill on pointer grab. Keyboard focus remains visible through the canonical surface; arrows, Shift+arrows and docking shortcuts remain available.",
|
"Drag headers never draw perimeter outlines or inherit keyboard-focus fill on pointer grab. Keyboard focus remains visible through the canonical surface; arrows, Shift+arrows and docking shortcuts remain available.",
|
||||||
"Detached center windows automatically use scene Glass V4; fixed confirmations opt out of detachment with allowFloating=false. Unsaved profile confirmation is owned by the application."
|
"Detached center windows automatically use scene Glass V4; fixed confirmations opt out of detachment with allowFloating=false. Unsaved profile confirmation is owned by the application.",
|
||||||
|
"floating/onFloatingChange and rect/onRectCommit allow durable application-owned presentation by window kind, independent of the currently displayed entity. Reopening restores mode and fitted geometry. Fixed confirmations do not inherit this state."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1126,7 +1128,9 @@
|
|||||||
"A reordered application page array is the single source of truth for both composition and navigation order.",
|
"A reordered application page array is the single source of truth for both composition and navigation order.",
|
||||||
"Optional renderOverlay portals the drag preview above scroll clipping without moving source layout; cancellation clears it.",
|
"Optional renderOverlay portals the drag preview above scroll clipping without moving source layout; cancellation clears it.",
|
||||||
"Pointer drops report client coordinates for consumer-owned canvas hit testing; dropping on empty space never implies an object target.",
|
"Pointer drops report client coordinates for consumer-owned canvas hit testing; dropping on empty space never implies an object target.",
|
||||||
"DraggableItem exposes activator attributes/listeners for whole-tile dragging without a separate handle; the same activation threshold distinguishes clicks from drags."
|
"DraggableItem exposes activator attributes/listeners for whole-tile dragging without a separate handle; the same activation threshold distinguishes clicks from drags.",
|
||||||
|
"SortableList/SortableScope layout=grid uses rectangular sorting and two-axis movement with the same handle-only interaction; list remains vertical by default.",
|
||||||
|
"DragHandle surface=control and SortableList handleSurface=control put the grip in a visible circle; viewport contexts use the shared glass material."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user