feat(ui): add plain editable copy and visible media drag grips
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nodedc/page-patterns": "0.1.0",
|
||||
"@nodedc/ui-core": "0.7.2",
|
||||
"@nodedc/ui-react": "0.7.5",
|
||||
"@nodedc/ui-core": "0.7.3",
|
||||
"@nodedc/ui-react": "0.7.8",
|
||||
"cesium": "1.147.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0"
|
||||
|
||||
@@ -1472,6 +1472,7 @@ export function CatalogApp() {
|
||||
<div className="catalog-form">
|
||||
<TextField label="Название проекта" hint="обязательно" value={projectName} onChange={(event) => setProjectName(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>
|
||||
</Preview>
|
||||
<Preview title="Действия" note="общая геометрия" className="catalog-preview--compact">
|
||||
@@ -1553,7 +1554,7 @@ export function CatalogApp() {
|
||||
</ResourceList>
|
||||
<Button onClick={()=>setTreeDemoOpen(true)}>Дерево объектов · изменяемый размер</Button>
|
||||
<DragDropRoot onDragEnd={()=>{}}><DraggableItem id="whole-material-tile">{({activator})=><Button {...activator.attributes} {...activator.listeners}>Перенос за всю плитку</Button>}</DraggableItem></DragDropRoot>
|
||||
<SortableList layout="grid" className="catalog-sortable-grid" items={gridOrder} getId={item=>item} onReorder={setGridOrder}>{(item,{handle})=><GlassSurface padding="sm">{handle}<Icon name="image"/><Description>{item}</Description></GlassSurface>}</SortableList>
|
||||
<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 align="center" role="status" title="Настройки применены" description="Проверьте подключение устройства." />
|
||||
</Preview>
|
||||
|
||||
+3
-1
@@ -46,7 +46,7 @@ Icon-only action по умолчанию круглый. Квадратная к
|
||||
|
||||
## 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 будут расширением этого контракта, а не локальным классом приложения.
|
||||
|
||||
@@ -624,3 +624,5 @@ EditorDockLayout: every floating or actively detached tool uses context="scene"
|
||||
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-ручка остаётся вариантом по умолчанию для обычных строк.
|
||||
|
||||
Generated
+6
-6
@@ -28,8 +28,8 @@
|
||||
"version": "0.7.0",
|
||||
"dependencies": {
|
||||
"@nodedc/page-patterns": "0.1.0",
|
||||
"@nodedc/ui-core": "0.7.2",
|
||||
"@nodedc/ui-react": "0.7.5",
|
||||
"@nodedc/ui-core": "0.7.3",
|
||||
"@nodedc/ui-react": "0.7.8",
|
||||
"cesium": "1.147.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0"
|
||||
@@ -2516,7 +2516,7 @@
|
||||
},
|
||||
"packages/ui-core": {
|
||||
"name": "@nodedc/ui-core",
|
||||
"version": "0.7.2",
|
||||
"version": "0.7.3",
|
||||
"dependencies": {
|
||||
"@nodedc/tokens": "0.6.0"
|
||||
}
|
||||
@@ -2525,17 +2525,17 @@
|
||||
"name": "@nodedc/ui-dom",
|
||||
"version": "0.7.0",
|
||||
"dependencies": {
|
||||
"@nodedc/ui-core": "0.7.2"
|
||||
"@nodedc/ui-core": "0.7.3"
|
||||
}
|
||||
},
|
||||
"packages/ui-react": {
|
||||
"name": "@nodedc/ui-react",
|
||||
"version": "0.7.7",
|
||||
"version": "0.7.8",
|
||||
"dependencies": {
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@nodedc/ui-core": "0.7.2",
|
||||
"@nodedc/ui-core": "0.7.3",
|
||||
"lucide-react": "^0.468.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nodedc/ui-core",
|
||||
"version": "0.7.2",
|
||||
"version": "0.7.3",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -4885,3 +4885,20 @@ textarea.nodedc-field__control {
|
||||
background: transparent;
|
||||
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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nodedc/ui-core": "0.7.2"
|
||||
"@nodedc/ui-core": "0.7.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nodedc/ui-react",
|
||||
"version": "0.7.7",
|
||||
"version": "0.7.8",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
@@ -21,7 +21,7 @@
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@nodedc/ui-core": "0.7.2",
|
||||
"@nodedc/ui-core": "0.7.3",
|
||||
"lucide-react": "^0.468.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -52,8 +52,9 @@ const copyRect = (rect: DragRect | null | undefined): DragRect | undefined => re
|
||||
height: rect.height,
|
||||
}) : undefined;
|
||||
|
||||
export function DragHandle({ label = "Перетащить", listeners, attributes, className }: {
|
||||
export function DragHandle({ label = "Перетащить", listeners, attributes, className, surface="none" }: {
|
||||
label?: string;
|
||||
surface?: "none" | "control";
|
||||
listeners?: ReturnType<typeof useDraggable>["listeners"];
|
||||
attributes?: ReturnType<typeof useDraggable>["attributes"];
|
||||
className?: string;
|
||||
@@ -62,6 +63,7 @@ export function DragHandle({ label = "Перетащить", listeners, attribut
|
||||
<button
|
||||
type="button"
|
||||
className={cn("nodedc-drag-handle", className)}
|
||||
data-surface={surface}
|
||||
aria-label={label}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
@@ -126,8 +128,9 @@ export function SortableScope({ ids, children, layout="list" }: { ids: string[];
|
||||
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;
|
||||
handleSurface?: "none" | "control";
|
||||
data?: NodedcDragData;
|
||||
className?: string;
|
||||
children: (state: { handle: ReactNode; isDragging: boolean }) => ReactNode;
|
||||
@@ -141,13 +144,14 @@ export function SortableItem({ id, data, className, children }: {
|
||||
className={cn(className, isDragging && "is-dragging")}
|
||||
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>
|
||||
);
|
||||
}
|
||||
|
||||
export function SortableList<T>({ items, getId, className, onReorder, children, layout="list" }: {
|
||||
export function SortableList<T>({ items, getId, className, onReorder, children, layout="list", handleSurface="none" }: {
|
||||
items: T[];
|
||||
handleSurface?: "none" | "control";
|
||||
layout?: "list" | "grid";
|
||||
getId: (item: T) => string;
|
||||
className?: string;
|
||||
@@ -165,7 +169,7 @@ export function SortableList<T>({ items, getId, className, onReorder, children,
|
||||
<SortableScope ids={ids} layout={layout}>
|
||||
<div className={className}>
|
||||
{items.map((item) => (
|
||||
<SortableItem key={getId(item)} id={getId(item)}>
|
||||
<SortableItem key={getId(item)} id={getId(item)} handleSurface={handleSurface}>
|
||||
{(state) => children(item, state)}
|
||||
</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";
|
||||
|
||||
export interface FieldFrameProps {
|
||||
@@ -29,6 +29,8 @@ export interface TextFieldProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||
hint?: string;
|
||||
description?: string;
|
||||
fieldClassName?: string;
|
||||
/** Plain text appearance for directly editable detail content. Keep an accessible name. */
|
||||
appearance?: "default" | "plain";
|
||||
}
|
||||
|
||||
export function TextField({
|
||||
@@ -36,6 +38,7 @@ export function TextField({
|
||||
hint,
|
||||
description,
|
||||
fieldClassName,
|
||||
appearance = "default",
|
||||
className,
|
||||
id,
|
||||
...props
|
||||
@@ -43,7 +46,7 @@ export function TextField({
|
||||
const generatedId = useId();
|
||||
const controlId = id ?? generatedId;
|
||||
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} />
|
||||
</FieldFrame>
|
||||
);
|
||||
@@ -54,6 +57,8 @@ export interface TextAreaFieldProps extends TextareaHTMLAttributes<HTMLTextAreaE
|
||||
hint?: string;
|
||||
description?: string;
|
||||
fieldClassName?: string;
|
||||
/** Plain text appearance for directly editable detail content. Keep an accessible name. */
|
||||
appearance?: "default" | "plain";
|
||||
}
|
||||
|
||||
export function TextAreaField({
|
||||
@@ -61,15 +66,29 @@ export function TextAreaField({
|
||||
hint,
|
||||
description,
|
||||
fieldClassName,
|
||||
appearance = "default",
|
||||
className,
|
||||
id,
|
||||
...props
|
||||
}: TextAreaFieldProps) {
|
||||
const generatedId = useId();
|
||||
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 (
|
||||
<FieldFrame label={label} hint={hint} description={description} htmlFor={controlId} className={fieldClassName}>
|
||||
<textarea id={controlId} className={cn("nodedc-field__control", className)} {...props} />
|
||||
<FieldFrame label={label} hint={hint} description={description} htmlFor={controlId} className={cn(fieldClassName, appearance === "plain" && "nodedc-field--plain", !label && "nodedc-field--unlabelled")}>
|
||||
<textarea ref={area} id={controlId} className={cn("nodedc-field__control", className)} {...props} />
|
||||
</FieldFrame>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -257,7 +257,8 @@
|
||||
"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.",
|
||||
"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."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1128,7 +1129,8 @@
|
||||
"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.",
|
||||
"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."
|
||||
"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