feat(ui): support storage settings, pinned copies and contextual window actions
This commit is contained in:
@@ -236,7 +236,7 @@ const iconGroups: Array<{ title: string; note: string; icons: IconName[] }> = [
|
||||
{
|
||||
title: "Сущности",
|
||||
note: "Общий словарь",
|
||||
icons: ["profile", "users", "building", "globe", "target", "database", "network", "inbox", "mail"],
|
||||
icons: ["profile", "users", "building", "globe", "target", "database", "pin", "network", "inbox", "mail"],
|
||||
},
|
||||
{
|
||||
title: "Контент",
|
||||
@@ -264,6 +264,7 @@ const iconLabels: Record<IconName, string> = {
|
||||
close: "Закрыть",
|
||||
copy: "Копировать",
|
||||
database: "База данных",
|
||||
pin: "Закрепить",
|
||||
download: "Скачать",
|
||||
edit: "Редактировать",
|
||||
eye: "Показать",
|
||||
@@ -2365,6 +2366,8 @@ export function CatalogApp() {
|
||||
<Window
|
||||
open={createModuleOpen}
|
||||
title="Создать модуль"
|
||||
headerActionsPlacement="before-close"
|
||||
headerActions={<IconButton label="Очистить форму" onClick={() => {setCreateModuleName("");setCreateModuleSlug("");}}><Icon name="trash"/></IconButton>}
|
||||
subtitle="Свободное окно · шапка: перемещение · края: размер"
|
||||
size="sm"
|
||||
onClose={() => setCreateModuleOpen(false)}
|
||||
|
||||
@@ -22,6 +22,7 @@ export function EnvironmentCatalogDemo() {
|
||||
</div>
|
||||
<div className="catalog-environment-stage"><LandingStage page={settings.pages.home} /></div>
|
||||
<EnvironmentSettingsWindow open={open} onClose={() => setOpen(false)} productName="Продукт"
|
||||
additionalSections={[{ id: "storage", label: "Хранилище", icon: "database", content: <p>Настройки хранения продукта используют общий каркас окна.</p> }]}
|
||||
surfaces={[{ id: "home", home: true, description: "Главная страница продукта", actions: [] }]}
|
||||
settings={settings} state="ready" error={null}
|
||||
onSave={async draft => { const next = { ...draft, revision: draft.revision + 1 }; setSettings(next); return next; }}
|
||||
|
||||
@@ -524,3 +524,8 @@ Exact `RangeControl` editors synchronize external controlled-value changes while
|
||||
Window: `rect` / `onRectCommit` — восстановление и фиксация геометрии инструментов; см. WINDOWS_AND_LAYERS.md. Иконка `minus` дополняет `plus` для управления масштабом содержимого.
|
||||
|
||||
`EditorDockLayout` / `EditorWorkspace`: переносимый редактор с закреплённым основным видом, четырьмя зонами стыковки, разделителями и отрываемыми панелями. Управляемый `EditorDockState` хранится в документе приложения. Шапка редактора не участвует в стыковке; возврат восстанавливает исходный вид. Контракт, keyboard и минимумы — в WINDOWS_AND_LAYERS.md.
|
||||
|
||||
Размер поясняющего текста `Description` можно задать через
|
||||
`--nodedc-description-font-size`; по умолчанию используется `--nodedc-font-size-sm`.
|
||||
|
||||
Window header actions default to before the move toggle. `headerActionsPlacement="before-close"` places supplied canonical IconButtons between move and close, preserving DOM/Tab order. Deletion confirmation remains application-owned content in the same mounted Window.
|
||||
|
||||
@@ -17,3 +17,16 @@ The application validates URLs/media bytes, persists uploads and document revisi
|
||||
Mission Core passes all existing page definitions and its current operator-environment API. Mission Core Node passes home only and authenticated local presentation storage. Device control never depends on this document. The catalog EnvironmentCatalogDemo exercises the same exported components with an explicitly in-memory save/upload adapter; it is not a persistence service.
|
||||
|
||||
Validate the source migration, TypeScript builds, playlist functions, neutral enabled/disabled DOM contract, dark/light and multiple accents, modal Escape, media order/timing and both consumer persistence adapters. Long-running or physical device acceptance remains application-owned.
|
||||
|
||||
## Product sections (2026-11-08)
|
||||
|
||||
`additionalSections` accepts `{ id, label, icon, group?, content, footer? }`.
|
||||
Use unique IDs other than `environment`. Content and footer are product-owned;
|
||||
the shared shell retains navigation, focus, dragging, Escape and geometry.
|
||||
Environment drafts remain intact when switching sections. Each section owns its
|
||||
loading/error/saving states. No product API is called by the shared library.
|
||||
Mission Core uses this extension for the owner-requested Storage section.
|
||||
|
||||
The canonical `pin` icon is the Lucide Pin glyph. Pair it with IconButton and
|
||||
`aria-pressed` for pinned state; use a busy/disabled state during preparation.
|
||||
An absent local copy and an unpinned copy are separate states.
|
||||
|
||||
@@ -13,3 +13,6 @@ aria-valuenow отсутствует. `label` обязателен; `valueText`
|
||||
ResourceRow.progress занимает свободное место между текстом и actions, скрывает
|
||||
status, на узком экране переносится ниже текста. Готовность не вычисляется
|
||||
компонентом. Каталог содержит завершённый, определённый и неизвестный прогресс.
|
||||
|
||||
Размер полосы задаётся опциональным `--nodedc-progress-height`; по умолчанию
|
||||
используется `--nodedc-space-2`. Плотность не меняет поведение и ARIA-состояния.
|
||||
|
||||
@@ -693,7 +693,7 @@ textarea.nodedc-field__control {
|
||||
font-family: inherit;
|
||||
font-weight: 400;
|
||||
color: var(--nodedc-text-muted);
|
||||
font-size: var(--nodedc-font-size-sm);
|
||||
font-size: var(--nodedc-description-font-size, var(--nodedc-font-size-sm));
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
@@ -4006,7 +4006,7 @@ textarea.nodedc-field__control {
|
||||
[data-nodedc-theme="light"] :is(.nodedc-header__brand, .nodedc-header__workspace)[data-monochrome="true"] img { filter: brightness(0); }
|
||||
|
||||
/* Owner-admitted linear progress in the shared resource row. */
|
||||
.nodedc-progress-bar { min-width: 3rem; height: var(--nodedc-space-2); overflow: hidden; border-radius: var(--nodedc-radius-circle); background: var(--nodedc-glass-control-bg); }
|
||||
.nodedc-progress-bar { min-width: 3rem; height: var(--nodedc-progress-height, var(--nodedc-space-2)); overflow: hidden; border-radius: var(--nodedc-radius-circle); background: var(--nodedc-glass-control-bg); }
|
||||
.nodedc-progress-bar__fill { display: block; width: 100%; height: 100%; background: var(--nodedc-text-secondary); border-radius: inherit; transform: scaleX(var(--nodedc-progress-fraction)); transform-origin: left; transition: transform var(--nodedc-duration-normal) var(--nodedc-ease-standard); }
|
||||
.nodedc-progress-bar[data-indeterminate] > .nodedc-progress-bar__fill { width: 35%; animation: nodedc-progress-travel 1.5s ease-in-out infinite alternate; }
|
||||
@keyframes nodedc-progress-travel { from { transform: translateX(-100%); } to { transform: translateX(285%); } }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
||||
import {
|
||||
Button,
|
||||
FeatureSettingsWindow,
|
||||
@@ -18,9 +18,12 @@ import {
|
||||
type EnvironmentSurface,
|
||||
type UploadedEnvironmentMedia,
|
||||
} from "@nodedc/ui-core";
|
||||
import type { FeatureSettingsSection } from "./FeatureSettingsWindow.js";
|
||||
import { EnvironmentMediaPlaylistEditor } from "./EnvironmentMediaPlaylistEditor.js";
|
||||
|
||||
export interface EnvironmentSettingsWindowProps {
|
||||
/** Product-owned sections reuse this shell; each owns its content and save lifecycle. */
|
||||
additionalSections?: readonly (FeatureSettingsSection & { content: ReactNode; footer?: ReactNode })[];
|
||||
productName: string;
|
||||
surfaces: readonly EnvironmentSurface[];
|
||||
initialSurfaceId?: string;
|
||||
@@ -70,6 +73,7 @@ function patchBackground(
|
||||
|
||||
export function EnvironmentSettingsWindow({
|
||||
productName,
|
||||
additionalSections = [],
|
||||
surfaces,
|
||||
initialSurfaceId,
|
||||
open,
|
||||
@@ -80,6 +84,8 @@ export function EnvironmentSettingsWindow({
|
||||
onSave,
|
||||
onUpload,
|
||||
}: EnvironmentSettingsWindowProps) {
|
||||
const [activeSection, setActiveSection] = useState("environment");
|
||||
const extension = additionalSections.find(section => section.id === activeSection);
|
||||
const [draft, setDraft] = useState(() => cloneEnvironmentSettings(settings));
|
||||
const [surfaceId, setSurfaceId] = useState(initialSurfaceId ?? surfaces[0]?.id ?? "home");
|
||||
const [uploading, setUploading] = useState(false);
|
||||
@@ -196,11 +202,12 @@ export function EnvironmentSettingsWindow({
|
||||
group: productName.toUpperCase(),
|
||||
icon: "settings",
|
||||
},
|
||||
...additionalSections,
|
||||
]}
|
||||
activeSection="environment"
|
||||
onSectionChange={() => undefined}
|
||||
activeSection={extension ? activeSection : "environment"}
|
||||
onSectionChange={setActiveSection}
|
||||
onClose={onClose}
|
||||
footer={(
|
||||
footer={extension ? extension.footer : (
|
||||
<WindowFooterActions>
|
||||
<Button
|
||||
variant="secondary"
|
||||
@@ -223,7 +230,7 @@ export function EnvironmentSettingsWindow({
|
||||
</WindowFooterActions>
|
||||
)}
|
||||
>
|
||||
<div className="nodedc-environment-settings">
|
||||
{extension ? extension.content : <div className="nodedc-environment-settings">
|
||||
<SettingsCard
|
||||
eyebrow="ОКРУЖЕНИЕ"
|
||||
title="Основные элементы управления"
|
||||
@@ -349,7 +356,7 @@ export function EnvironmentSettingsWindow({
|
||||
/>
|
||||
</div>
|
||||
</SettingsCard>
|
||||
</div>
|
||||
</div>}
|
||||
</FeatureSettingsWindow>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import {
|
||||
PanelTop,
|
||||
Pencil,
|
||||
Play,
|
||||
Pin,
|
||||
Power,
|
||||
Plus,
|
||||
Minus,
|
||||
@@ -95,6 +96,7 @@ const icons = {
|
||||
close: X,
|
||||
copy: Copy,
|
||||
database: Database,
|
||||
pin: Pin,
|
||||
download: Download,
|
||||
edit: Pencil,
|
||||
eye: Eye,
|
||||
|
||||
@@ -39,6 +39,8 @@ export interface WindowProps extends Omit<HTMLAttributes<HTMLDivElement>, "title
|
||||
footer?: ReactNode;
|
||||
/** Context actions beside close, using canonical IconButton controls. */
|
||||
headerActions?: ReactNode;
|
||||
/** Keep contextual actions immediately before close when requested. */
|
||||
headerActionsPlacement?: "before-move" | "before-close";
|
||||
size?: WindowSize;
|
||||
placement?: WindowPlacement;
|
||||
closeLabel?: string;
|
||||
@@ -66,6 +68,7 @@ export function Window({
|
||||
children,
|
||||
footer,
|
||||
headerActions,
|
||||
headerActionsPlacement = "before-move",
|
||||
size = "md",
|
||||
placement = "center",
|
||||
closeLabel = "Закрыть",
|
||||
@@ -286,7 +289,7 @@ export function Window({
|
||||
{subtitle ? <p id={descriptionId} className="nodedc-window__subtitle">{subtitle}</p> : null}
|
||||
</div>
|
||||
<div className="nodedc-window__actions">
|
||||
{headerActions}
|
||||
{headerActionsPlacement === "before-move" && headerActions}
|
||||
{allowFloating && placement === "center" && <IconButton label={isFloating ? "Вернуть модальный режим" : "Свободное окно"} aria-pressed={isFloating} onClick={() => {
|
||||
dragRef.current = null; resizeRef.current = null;
|
||||
if (!isFloating) {
|
||||
@@ -295,6 +298,7 @@ export function Window({
|
||||
}
|
||||
setFloating(!isFloating);
|
||||
}}><Icon name="move" /></IconButton>}
|
||||
{headerActionsPlacement === "before-close" && headerActions}
|
||||
<button type="button" className="nodedc-window__close" aria-label={closeLabel} onClick={onClose}>
|
||||
<Icon name="close" size={16} strokeWidth={1.6} />
|
||||
</button>
|
||||
|
||||
@@ -416,6 +416,7 @@
|
||||
"Escape and Tab belong to the focused or topmost visible modal; parent windows do not dismiss behind nested settings."
|
||||
],
|
||||
"rules": [
|
||||
"headerActionsPlacement=before-close places context actions between the move toggle and close in both visual and keyboard order; the default preserves existing consumers.",
|
||||
"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.",
|
||||
"Open state belongs to the application; focus/layer behavior belongs to the component.",
|
||||
@@ -1112,14 +1113,15 @@
|
||||
"nodedc-environment-settings",
|
||||
"nodedc-environment-media-playlist"
|
||||
],
|
||||
"summary": "Shared avatar Settings → Environment composition for product/home copy, quick actions and image/video playlists.",
|
||||
"summary": "Shared avatar Settings composition with Environment editing and optional consumer-owned settings sections.",
|
||||
"behavior": [
|
||||
"product-configured page list",
|
||||
"draft/reset/save",
|
||||
"upload adapter",
|
||||
"ordered media playlist",
|
||||
"image timing",
|
||||
"parent save/upload disabled state"
|
||||
"parent save/upload disabled state",
|
||||
"additionalSections extends shared navigation with consumer-owned content and footer while preserving the Environment draft"
|
||||
],
|
||||
"rules": [
|
||||
"Reuse FeatureSettingsWindow and existing form primitives; never fork an application-specific settings form.",
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
"building",
|
||||
"globe",
|
||||
"database",
|
||||
"pin",
|
||||
"network",
|
||||
"inbox",
|
||||
"mail"
|
||||
|
||||
@@ -31,7 +31,7 @@ test('legacy card paragraphs and live descriptions share small muted typography,
|
||||
assert.ok(copy);
|
||||
assert.match(copy.selectors,/\.nodedc-settings-card__titles p/);
|
||||
assert.match(copy.selectors,/\.nodedc-settings-card__body :where\(p:not\(\[class\]\)\)/);
|
||||
for(const declaration of ['font-family: inherit','font-weight: 400','color: var(--nodedc-text-muted)','font-size: var(--nodedc-font-size-sm)','line-height: 1.4'])assert.ok(copy.body.includes(declaration),declaration);
|
||||
for(const declaration of ['font-family: inherit','font-weight: 400','color: var(--nodedc-text-muted)','font-size: var(--nodedc-description-font-size, var(--nodedc-font-size-sm))','line-height: 1.4'])assert.ok(copy.body.includes(declaration),declaration);
|
||||
assert.doesNotMatch(copy.selectors,/h[1-6]|button|input|select/);
|
||||
const markup=renderToStaticMarkup(h(Description,{role:'status','aria-live':'polite'},'Waiting for device'));
|
||||
assert.match(markup,/role="status"/);assert.match(markup,/aria-live="polite"/);assert.match(markup,/class="nodedc-description"/);
|
||||
|
||||
Reference in New Issue
Block a user