feat(ui): support notification history and selectable side-panel actions
This commit is contained in:
@@ -65,6 +65,7 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
ToastCard,
|
ToastCard,
|
||||||
ToastStack,
|
ToastStack,
|
||||||
|
ToastObserver,
|
||||||
Toolbar,
|
Toolbar,
|
||||||
NavigationCube,
|
NavigationCube,
|
||||||
UserProfileMenu,
|
UserProfileMenu,
|
||||||
@@ -362,6 +363,7 @@ export function CatalogApp() {
|
|||||||
const [applicationSaveState, setApplicationSaveState] = useState<ApplicationDraftSaveState>("idle");
|
const [applicationSaveState, setApplicationSaveState] = useState<ApplicationDraftSaveState>("idle");
|
||||||
const [applicationError, setApplicationError] = useState("");
|
const [applicationError, setApplicationError] = useState("");
|
||||||
const [toasts, setToasts] = useState<ToastItem[]>([]);
|
const [toasts, setToasts] = useState<ToastItem[]>([]);
|
||||||
|
const [observedToasts, setObservedToasts] = useState<ToastItem[]>([]);
|
||||||
const toastSequenceRef = useRef(0);
|
const toastSequenceRef = useRef(0);
|
||||||
const [sessionProfile, setSessionProfile] = useState<FoundrySessionProfile | null>(null);
|
const [sessionProfile, setSessionProfile] = useState<FoundrySessionProfile | null>(null);
|
||||||
const [foundrySettingsOpen, setFoundrySettingsOpen] = useState(false);
|
const [foundrySettingsOpen, setFoundrySettingsOpen] = useState(false);
|
||||||
@@ -1657,6 +1659,7 @@ export function CatalogApp() {
|
|||||||
eyebrow="MAP / SETTINGS"
|
eyebrow="MAP / SETTINGS"
|
||||||
title="Настройки карты"
|
title="Настройки карты"
|
||||||
description="Theme-aware application panel"
|
description="Theme-aware application panel"
|
||||||
|
headerActions={<IconButton label="Настройки панели" onClick={() => setInspectorOpen(true)}><Icon name="settings" /></IconButton>}
|
||||||
onClose={() => setSidePanelDemoOpen(false)}
|
onClose={() => setSidePanelDemoOpen(false)}
|
||||||
>
|
>
|
||||||
<Inspector variant="panel" sections={environmentSections.slice(0, 3).map(section=>({...section,action:{label:`Действие секции ${section.label}`,icon:<Icon name="edit"/>,onAction:()=>setInspectorOpen(true)}}))} defaultOpen={[environmentSections[0]?.id ?? ""]} singleOpen />
|
<Inspector variant="panel" sections={environmentSections.slice(0, 3).map(section=>({...section,action:{label:`Действие секции ${section.label}`,icon:<Icon name="edit"/>,onAction:()=>setInspectorOpen(true)}}))} defaultOpen={[environmentSections[0]?.id ?? ""]} singleOpen />
|
||||||
@@ -1801,6 +1804,7 @@ export function CatalogApp() {
|
|||||||
</div>
|
</div>
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
<SettingsCard eyebrow="LIVE STATES" title="Проверка стека" description="Кнопки используют тот же bottom-right viewport, что и реальные save/update flows.">
|
<SettingsCard eyebrow="LIVE STATES" title="Проверка стека" description="Кнопки используют тот же bottom-right viewport, что и реальные save/update flows.">
|
||||||
|
<Description>Последняя передача приложению: {observedToasts.map(item => item.title).join(', ') || 'нет уведомлений'}</Description>
|
||||||
<div className="catalog-inline catalog-inline--wrap">
|
<div className="catalog-inline catalog-inline--wrap">
|
||||||
<Button onClick={() => pushToast("success", "Изменения сохранены", "Статус автоматически исчезнет.")}>Success</Button>
|
<Button onClick={() => pushToast("success", "Изменения сохранены", "Статус автоматически исчезнет.")}>Success</Button>
|
||||||
<Button onClick={() => pushToast("info", "Профиль применён", "Application использует выбранную версию.")}>Info</Button>
|
<Button onClick={() => pushToast("info", "Профиль применён", "Application использует выбранную версию.")}>Info</Button>
|
||||||
@@ -2204,6 +2208,7 @@ export function CatalogApp() {
|
|||||||
<UserProfileMenu
|
<UserProfileMenu
|
||||||
triggerLabel="Профиль"
|
triggerLabel="Профиль"
|
||||||
triggerIcon="inbox"
|
triggerIcon="inbox"
|
||||||
|
headerAction={{label: 'Правая панель', pressed: sidePanelDemoOpen, onSelect: () => setSidePanelDemoOpen(open => !open)}}
|
||||||
displayName={sessionProfile?.user?.displayName || "Профиль"}
|
displayName={sessionProfile?.user?.displayName || "Профиль"}
|
||||||
subtitle={sessionProfile?.user?.email || "NODE.DC Foundry"}
|
subtitle={sessionProfile?.user?.email || "NODE.DC Foundry"}
|
||||||
avatarUrl={sessionProfile?.user?.avatarUrl || undefined}
|
avatarUrl={sessionProfile?.user?.avatarUrl || undefined}
|
||||||
@@ -2645,7 +2650,9 @@ export function CatalogApp() {
|
|||||||
onClose={() => setConfirmOpen(false)}
|
onClose={() => setConfirmOpen(false)}
|
||||||
onConfirm={() => setConfirmOpen(false)}
|
onConfirm={() => setConfirmOpen(false)}
|
||||||
/>
|
/>
|
||||||
<ToastStack items={toasts} onDismiss={dismissToast} />
|
<ToastObserver onPresent={setObservedToasts}>
|
||||||
|
<ToastStack items={toasts} onDismiss={dismissToast} />
|
||||||
|
</ToastObserver>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,6 +296,13 @@ setup-команды, сохранение, API и права принадлеж
|
|||||||
|
|
||||||
## SettingsCard и Switch
|
## SettingsCard и Switch
|
||||||
|
|
||||||
|
В `UserProfileMenu` необязательный `headerAction={{label, onSelect}}` отделяет
|
||||||
|
действие средней иконки от меню профиля. Аватар и текст профиля сохраняют меню.
|
||||||
|
`ToastObserver onPresent` сообщает приложению новые и изменённые завершённые
|
||||||
|
уведомления из вложенных `ToastStack`; хранение, даты и история принадлежат
|
||||||
|
приложению. `ToastStack observe={false}` исключает повторную регистрацию
|
||||||
|
сообщений, уже записанных сервером. Отображение и таймеры не изменяются.
|
||||||
|
|
||||||
`SettingsCard` фиксирует нейтральную структуру админской группы: eyebrow/title/description/actions/body. `Switch` покрывает компактное включение/видимость внутри таких групп. Данные секции, сохранение и права остаются в consumer.
|
`SettingsCard` фиксирует нейтральную структуру админской группы: eyebrow/title/description/actions/body. `Switch` покрывает компактное включение/видимость внутри таких групп. Данные секции, сохранение и права остаются в consumer.
|
||||||
|
|
||||||
Промежуточный loading-контейнер не должен обнулять вертикальный ритм тела
|
Промежуточный loading-контейнер не должен обнулять вертикальный ритм тела
|
||||||
@@ -343,6 +350,8 @@ Reduced motion отключает анимацию. На узком экране
|
|||||||
|
|
||||||
## ApplicationSidePanel
|
## ApplicationSidePanel
|
||||||
|
|
||||||
|
Перед кнопкой закрытия можно разместить действия через `headerActions`. Кнопка `UserProfileMenu.headerAction` принимает `pressed` и `controls` для связи с выдвижной панелью.
|
||||||
|
|
||||||
`ApplicationSidePanel` — правая application-level пара к `AdminNavigationPanel`.
|
`ApplicationSidePanel` — правая application-level пара к `AdminNavigationPanel`.
|
||||||
Она использует ту же ширину `332–352 px`, радиус, theme-aware surface, тень и
|
Она использует ту же ширину `332–352 px`, радиус, theme-aware surface, тень и
|
||||||
круглые действия, но появляется справа налево. `ApplicationShell` размещает её
|
круглые действия, но появляется справа налево. `ApplicationShell` размещает её
|
||||||
|
|||||||
@@ -364,7 +364,8 @@
|
|||||||
color: var(--nodedc-text-primary);
|
color: var(--nodedc-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nodedc-icon-button[aria-pressed="true"] {
|
.nodedc-icon-button[aria-pressed="true"],
|
||||||
|
.nodedc-header__profile .nodedc-icon-button[aria-pressed="true"] {
|
||||||
background: var(--nodedc-glass-control-active);
|
background: var(--nodedc-glass-control-active);
|
||||||
color: var(--nodedc-glass-control-active-text);
|
color: var(--nodedc-glass-control-active-text);
|
||||||
}
|
}
|
||||||
@@ -1632,6 +1633,8 @@ textarea.nodedc-field__control {
|
|||||||
.nodedc-app-shell__end-panel {
|
.nodedc-app-shell__end-panel {
|
||||||
right: var(--nodedc-app-page-pad);
|
right: var(--nodedc-app-page-pad);
|
||||||
width: var(--nodedc-app-nav-width);
|
width: var(--nodedc-app-nav-width);
|
||||||
|
transform: translateX(calc(100% + var(--nodedc-app-page-pad)));
|
||||||
|
transition: transform var(--nodedc-app-navigation-motion), visibility 0s linear 440ms;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
@@ -1642,6 +1645,8 @@ textarea.nodedc-field__control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nodedc-app-shell[data-end-panel-open="true"] .nodedc-app-shell__end-panel {
|
.nodedc-app-shell[data-end-panel-open="true"] .nodedc-app-shell__end-panel {
|
||||||
|
transform: translateX(0);
|
||||||
|
transition-delay: 0s;
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
@@ -4910,3 +4915,7 @@ textarea.nodedc-field__control {
|
|||||||
.nodedc-window[data-header-stacked="true"]>.nodedc-window__head>.nodedc-window__titles{grid-row:2}
|
.nodedc-window[data-header-stacked="true"]>.nodedc-window__head>.nodedc-window__titles{grid-row:2}
|
||||||
|
|
||||||
.nodedc-window[data-header-layout="adaptive"]>.nodedc-window__head>.nodedc-window__actions>*{flex-shrink:0}
|
.nodedc-window[data-header-layout="adaptive"]>.nodedc-window__head>.nodedc-window__actions>*{flex-shrink:0}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.nodedc-app-shell__end-panel { transition: none; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export interface ApplicationSidePanelProps extends Omit<HTMLAttributes<HTMLEleme
|
|||||||
title: ReactNode;
|
title: ReactNode;
|
||||||
description?: ReactNode;
|
description?: ReactNode;
|
||||||
closeLabel?: string;
|
closeLabel?: string;
|
||||||
|
headerActions?: ReactNode;
|
||||||
footer?: ReactNode;
|
footer?: ReactNode;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -23,6 +24,7 @@ export function ApplicationSidePanel({
|
|||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
closeLabel = "Закрыть панель",
|
closeLabel = "Закрыть панель",
|
||||||
|
headerActions,
|
||||||
footer,
|
footer,
|
||||||
onClose,
|
onClose,
|
||||||
children,
|
children,
|
||||||
@@ -42,6 +44,7 @@ export function ApplicationSidePanel({
|
|||||||
{description ? <span className="nodedc-application-side-panel__description">{description}</span> : null}
|
{description ? <span className="nodedc-application-side-panel__description">{description}</span> : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="nodedc-admin-panel__head-actions">
|
<div className="nodedc-admin-panel__head-actions">
|
||||||
|
{headerActions}
|
||||||
<button type="button" className="nodedc-admin-panel__close" aria-label={closeLabel} onClick={onClose}>
|
<button type="button" className="nodedc-admin-panel__close" aria-label={closeLabel} onClick={onClose}>
|
||||||
<Icon name="close" size={16} strokeWidth={1.6} />
|
<Icon name="close" size={16} strokeWidth={1.6} />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useRef, type HTMLAttributes } from "react";
|
import { createContext, useContext, useEffect, useRef, type HTMLAttributes, type ReactNode } from "react";
|
||||||
import { createPortal } from "react-dom";
|
import { createPortal } from "react-dom";
|
||||||
import { cn } from "./cn.js";
|
import { cn } from "./cn.js";
|
||||||
import { Icon, type IconName } from "./Icon.js";
|
import { Icon, type IconName } from "./Icon.js";
|
||||||
@@ -13,6 +13,13 @@ export type ToastItem = {
|
|||||||
durationMs?: number | null;
|
durationMs?: number | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ToastObservation = createContext<((items: ToastItem[]) => void) | null>(null);
|
||||||
|
|
||||||
|
/** The application owns history/storage; this only reports terminal presentations. */
|
||||||
|
export function ToastObserver({onPresent, children}: {onPresent: (items: ToastItem[]) => void; children: ReactNode}) {
|
||||||
|
return <ToastObservation.Provider value={onPresent}>{children}</ToastObservation.Provider>;
|
||||||
|
}
|
||||||
|
|
||||||
const toastIcons: Record<ToastTone, IconName> = {
|
const toastIcons: Record<ToastTone, IconName> = {
|
||||||
success: "check",
|
success: "check",
|
||||||
error: "alert",
|
error: "alert",
|
||||||
@@ -69,7 +76,21 @@ function TimedToastCard({ item, onDismiss }: { item: ToastItem; onDismiss: (id:
|
|||||||
return <ToastCard item={item} onDismiss={onDismiss} />;
|
return <ToastCard item={item} onDismiss={onDismiss} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ToastStack({ items, onDismiss }: { items: ToastItem[]; onDismiss: (id: string) => void }) {
|
export function ToastStack({ items, onDismiss, observe = true }: { items: ToastItem[]; onDismiss: (id: string) => void; observe?: boolean }) {
|
||||||
|
const observer = useContext(ToastObservation);
|
||||||
|
const presented = useRef(new Map<string, string>());
|
||||||
|
useEffect(() => {
|
||||||
|
const next = new Map<string, string>();
|
||||||
|
const fresh: ToastItem[] = [];
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.tone === 'loading') continue;
|
||||||
|
const identity = JSON.stringify([item.tone, item.title, item.description]);
|
||||||
|
next.set(item.id, identity);
|
||||||
|
if (presented.current.get(item.id) !== identity) fresh.push(item);
|
||||||
|
}
|
||||||
|
presented.current = next;
|
||||||
|
if (observe && fresh.length) observer?.(fresh);
|
||||||
|
}, [items, observer, observe]);
|
||||||
if (typeof document === "undefined" || items.length === 0) return null;
|
if (typeof document === "undefined" || items.length === 0) return null;
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<div className="nodedc-toast-viewport nodedc-ui-root" aria-live="polite" aria-relevant="additions removals">
|
<div className="nodedc-toast-viewport nodedc-ui-root" aria-live="polite" aria-relevant="additions removals">
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export interface UserProfileMenuProps {
|
|||||||
triggerLabel?: ReactNode;
|
triggerLabel?: ReactNode;
|
||||||
/** Optional status glyph between the label and avatar. */
|
/** Optional status glyph between the label and avatar. */
|
||||||
triggerIcon?: IconName;
|
triggerIcon?: IconName;
|
||||||
|
/** Independent header action; the avatar still opens the profile menu. */
|
||||||
|
headerAction?: { label: string; pressed?: boolean; controls?: string; onSelect: () => void };
|
||||||
actions: readonly UserProfileMenuAction[];
|
actions: readonly UserProfileMenuAction[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ export function UserProfileMenu({
|
|||||||
coverImageUrl,
|
coverImageUrl,
|
||||||
triggerLabel,
|
triggerLabel,
|
||||||
triggerIcon,
|
triggerIcon,
|
||||||
|
headerAction,
|
||||||
actions,
|
actions,
|
||||||
}: UserProfileMenuProps) {
|
}: UserProfileMenuProps) {
|
||||||
const label = displayName || "NODE.DC";
|
const label = displayName || "NODE.DC";
|
||||||
@@ -51,11 +54,15 @@ export function UserProfileMenu({
|
|||||||
</HeaderProfileButton>
|
</HeaderProfileButton>
|
||||||
<IconButton
|
<IconButton
|
||||||
ref={setTriggerRef}
|
ref={setTriggerRef}
|
||||||
label={`Меню пользователя ${label}`}
|
label={headerAction?.label ?? `Меню пользователя ${label}`}
|
||||||
aria-haspopup="menu"
|
aria-haspopup={headerAction ? undefined : "menu"}
|
||||||
aria-expanded={open}
|
aria-pressed={headerAction?.pressed}
|
||||||
aria-controls={surfaceId}
|
aria-expanded={headerAction ? headerAction.pressed : open}
|
||||||
onClick={(event) => { setTriggerRef(event.currentTarget); toggle(); }}
|
aria-controls={headerAction ? headerAction.controls : surfaceId}
|
||||||
|
onClick={(event) => {
|
||||||
|
if (headerAction) { if (open) toggle(); headerAction.onSelect(); }
|
||||||
|
else { setTriggerRef(event.currentTarget); toggle(); }
|
||||||
|
}}
|
||||||
><Icon name={triggerIcon ?? "inbox"} size={20} strokeWidth={1.7} /></IconButton>
|
><Icon name={triggerIcon ?? "inbox"} size={20} strokeWidth={1.7} /></IconButton>
|
||||||
<button type="button" className="nodedc-user-profile-menu__trigger" aria-label={`Профиль ${label}`} aria-haspopup="menu" aria-expanded={open} aria-controls={surfaceId}
|
<button type="button" className="nodedc-user-profile-menu__trigger" aria-label={`Профиль ${label}`} aria-haspopup="menu" aria-expanded={open} aria-controls={surfaceId}
|
||||||
onClick={(event) => { setTriggerRef(event.currentTarget); toggle(); }}>
|
onClick={(event) => { setTriggerRef(event.currentTarget); toggle(); }}>
|
||||||
|
|||||||
@@ -708,6 +708,7 @@
|
|||||||
"behavior": [
|
"behavior": [
|
||||||
"portal dropdown",
|
"portal dropdown",
|
||||||
"profile identity card",
|
"profile identity card",
|
||||||
|
"optional pressed state and controlled region on independent header action; its selected circle and glyph use the active IconButton colors, including on hover",
|
||||||
"theme-independent cover",
|
"theme-independent cover",
|
||||||
"action links and callbacks",
|
"action links and callbacks",
|
||||||
"outside pointer and Escape close",
|
"outside pointer and Escape close",
|
||||||
@@ -717,7 +718,8 @@
|
|||||||
"The component owns menu geometry and profile presentation; the application owns settings, profile and logout actions.",
|
"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.",
|
"Use the existing Dropdown engine so the menu is never clipped by the fixed application header.",
|
||||||
"Do not embed product permissions or sharing rules in the visual menu.",
|
"Do not embed product permissions or sharing rules in the visual menu.",
|
||||||
"The default header composes HeaderProfileButton, an independent menu IconButton and HeaderAvatar using the existing header geometry. Application settings belong inside this menu; do not add an adjacent settings button or another HeaderProfile wrapper."
|
"The default header composes HeaderProfileButton, an independent menu IconButton and HeaderAvatar using the existing header geometry. Application settings belong inside this menu; do not add an adjacent settings button or another HeaderProfile wrapper.",
|
||||||
|
"Optional headerAction separates the middle icon action from the avatar/profile trigger; without it legacy behavior is preserved."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -908,7 +910,7 @@
|
|||||||
"nodedc-application-side-panel",
|
"nodedc-application-side-panel",
|
||||||
"nodedc-app-shell__end-panel"
|
"nodedc-app-shell__end-panel"
|
||||||
],
|
],
|
||||||
"summary": "Theme-aware trailing application panel paired with AdminNavigationPanel and hosted in a separate ApplicationShell end column.",
|
"summary": "Theme-aware trailing application panel with optional header actions before close, hosted in a separate ApplicationShell end column.",
|
||||||
"anatomy": [
|
"anatomy": [
|
||||||
"eyebrow and title",
|
"eyebrow and title",
|
||||||
"optional description",
|
"optional description",
|
||||||
@@ -1013,7 +1015,8 @@
|
|||||||
"ToastCard",
|
"ToastCard",
|
||||||
"ToastStack",
|
"ToastStack",
|
||||||
"ToastItem",
|
"ToastItem",
|
||||||
"ToastTone"
|
"ToastTone",
|
||||||
|
"ToastObserver"
|
||||||
],
|
],
|
||||||
"domContract": [
|
"domContract": [
|
||||||
"nodedc-toast-viewport",
|
"nodedc-toast-viewport",
|
||||||
@@ -1041,7 +1044,8 @@
|
|||||||
"Errors and status copy use the compact Toast typography; consumers do not substitute browser-default paragraphs or title-sized text.",
|
"Errors and status copy use the compact Toast typography; consumers do not substitute browser-default paragraphs or title-sized text.",
|
||||||
"Adding or updating another notification never restarts the lifetime of an existing item; each item owns its timer by stable id.",
|
"Adding or updating another notification never restarts the lifetime of an existing item; each item owns its timer by stable id.",
|
||||||
"Loading notifications remain until the operation updates or dismisses them.",
|
"Loading notifications remain until the operation updates or dismisses them.",
|
||||||
"Status notifications never replace a blocking confirmation modal."
|
"Status notifications never replace a blocking confirmation modal.",
|
||||||
|
"ToastObserver reports new or changed terminal presentations to the consumer; storage and history belong to the application. Set observe=false for server-originated items already recorded in history."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user