@hgdc/ui 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/account-menu.d.ts +7 -1
- package/dist/account-menu.js +6 -3
- package/dist/app-shell.d.ts +1 -1
- package/dist/app-shell.js +3 -2
- package/dist/shell-placement.d.ts +7 -0
- package/dist/shell-placement.js +9 -0
- package/dist/uptime-bar.d.ts +25 -2
- package/dist/uptime-bar.js +35 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ Sur ordinateur, la coque ouvre sur la barre des produits (ADR 0011) : organisati
|
|
|
94
94
|
| `stat` | `<StatGrid><StatTile label="Erreurs" value="12" delta={{ value: "8 %", direction: "up", good: "down" }} /></StatGrid>` |
|
|
95
95
|
| `time-chart` | `<TimeChart label="Envois par jour" timestamps={days} series={[{ key: "sent", label: "Envoyés", values }]} kind="bar" lastIncomplete />` (dernier point en pointillés : la journée n'est pas finie) |
|
|
96
96
|
| `status` | `<StatusBadge status="degraded" />` (Opérationnel, Dégradé, Panne, Maintenance, Inconnu) ; hors services, `<StatusBadge tone="success" label="Remis" />` (`neutral`, `success`, `warning`, `danger`, `info`, `pending`) |
|
|
97
|
-
| `uptime-bar` | `<UptimeBar days={[{ date, status: "operational", uptime: "100 %" }]} summary="99,95 % sur 90 jours" />`
|
|
97
|
+
| `uptime-bar` | `<UptimeBar days={[{ date, status: "operational", uptime: "100 %", detail: { levels, incidents } }]} summary="99,95 % sur 90 jours" />` |
|
|
98
98
|
| `timeline` | `<Timeline entries={[{ id, title: "Résolu", time, status: "operational" }]} />` |
|
|
99
99
|
| `relative-time` | `<RelativeTime date={deployment._creationTime} />` (« il y a 3 min », date exacte au survol) |
|
|
100
100
|
| `copy-button` | `<Snippet value="bun add @hgdc/ui" prompt />`, `<CopyButton value={url} />`, `<CopyButton value={all} label="Tout copier" showLabel />` |
|
package/dist/account-menu.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export type AccountUser = {
|
|
|
30
30
|
* (`productMenuEntries`, `@hgdc/ui/products`), avec `product` coché. `products` remplace cette
|
|
31
31
|
* liste ; `products={[]}` la retire.
|
|
32
32
|
*/
|
|
33
|
-
export declare function AccountMenu({ user, onProfile, onSecurity, onShortcuts, onSignOut, products: productsProp, product: currentProduct, accountHref, children, variant, }: {
|
|
33
|
+
export declare function AccountMenu({ user, onProfile, onSecurity, onShortcuts, onSignOut, products: productsProp, product: currentProduct, accountHref, statusPage, children, variant, }: {
|
|
34
34
|
user: AccountUser;
|
|
35
35
|
onProfile?: () => void;
|
|
36
36
|
onSecurity?: () => void;
|
|
@@ -43,6 +43,12 @@ export declare function AccountMenu({ user, onProfile, onSecurity, onShortcuts,
|
|
|
43
43
|
product?: string;
|
|
44
44
|
/** Adresse d'Account dans la liste par défaut (un Account local en développement). */
|
|
45
45
|
accountHref?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Page de statut du produit, entrée « État du service » : celle d'`AppShell` par défaut (son
|
|
48
|
+
* `statusPage`, sinon `https://status.hgdc.ch/<produit>`), `false` pour la retirer. Hors de la
|
|
49
|
+
* coque, sans adresse donnée, pas d'entrée.
|
|
50
|
+
*/
|
|
51
|
+
statusPage?: string | false;
|
|
46
52
|
/** Entrées propres au produit (« Administration »), après le profil. */
|
|
47
53
|
children?: ReactNode;
|
|
48
54
|
variant?: "row" | "avatar";
|
package/dist/account-menu.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Activity01Icon from "@hugeicons/core-free-icons/Activity01Icon";
|
|
2
3
|
import DashboardSquare01Icon from "@hugeicons/core-free-icons/DashboardSquare01Icon";
|
|
3
4
|
import KeyboardIcon from "@hugeicons/core-free-icons/KeyboardIcon";
|
|
4
5
|
import Logout01Icon from "@hugeicons/core-free-icons/Logout01Icon";
|
|
@@ -13,7 +14,7 @@ import { initials } from "./initials.js";
|
|
|
13
14
|
import { MENU_LINK_ITEM } from "./org-switcher.js";
|
|
14
15
|
import { ProductBadge } from "./product-badge.js";
|
|
15
16
|
import { productMenuEntries } from "./products.js";
|
|
16
|
-
import { useLeaveOnClick, useProductRailShown } from "./shell-placement.js";
|
|
17
|
+
import { useLeaveOnClick, useProductRailShown, useStatusPage } from "./shell-placement.js";
|
|
17
18
|
import { ThemeSwitch } from "./theme-switch.js";
|
|
18
19
|
/**
|
|
19
20
|
* Le menu du compte, en bas de la barre latérale : profil, sécurité, choix du thème en trois icônes, raccourcis, autres
|
|
@@ -26,11 +27,13 @@ import { ThemeSwitch } from "./theme-switch.js";
|
|
|
26
27
|
* (`productMenuEntries`, `@hgdc/ui/products`), avec `product` coché. `products` remplace cette
|
|
27
28
|
* liste ; `products={[]}` la retire.
|
|
28
29
|
*/
|
|
29
|
-
export function AccountMenu({ user, onProfile, onSecurity, onShortcuts, onSignOut, products: productsProp, product: currentProduct, accountHref, children, variant = "row", }) {
|
|
30
|
+
export function AccountMenu({ user, onProfile, onSecurity, onShortcuts, onSignOut, products: productsProp, product: currentProduct, accountHref, statusPage, children, variant = "row", }) {
|
|
30
31
|
const products = productsProp ?? productMenuEntries({ current: currentProduct, accountHref });
|
|
31
32
|
const railShown = useProductRailShown();
|
|
33
|
+
const shellStatusPage = useStatusPage();
|
|
34
|
+
const statusPageUrl = statusPage === false ? null : (statusPage ?? shellStatusPage);
|
|
32
35
|
const leaveOnClick = useLeaveOnClick();
|
|
33
|
-
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: variant === "row" ? (_jsx("button", { type: "button", "aria-label": `Compte de ${user.name}`, className: "flex w-full min-w-0 items-center gap-2.5 rounded-xl p-1.5 text-left outline-none transition-colors duration-(--duration-fast) ease-out hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50 aria-expanded:bg-muted lg:hover:bg-shell-hover lg:aria-expanded:bg-shell-hover lg:rail:justify-center" })) : (_jsx("button", { type: "button", "aria-label": `Compte de ${user.name}`, className: "touch-target grid size-9 place-items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring/50" })), children: [_jsxs(Avatar, { children: [user.image ? _jsx(AvatarImage, { src: user.image, alt: "" }) : null, _jsx(AvatarFallback, { className: "text-xs font-semibold uppercase", children: initials(user.name, user.email) })] }), variant === "row" ? (_jsxs("span", { className: "min-w-0 flex-1 lg:rail:hidden", children: [_jsx("span", { className: "block truncate text-sm font-medium", children: user.name }), _jsx("span", { className: "block truncate text-xs text-muted-foreground lg:text-shell-muted", children: user.email })] })) : null] }), _jsxs(DropdownMenuContent, { align: variant === "row" ? "start" : "end", side: variant === "row" ? "top" : "bottom", className: "w-64", children: [_jsx(DropdownMenuGroup, { children: _jsxs(DropdownMenuLabel, { children: [_jsx("span", { className: "block truncate text-foreground", children: user.name }), _jsx("span", { className: "block truncate", children: user.email })] }) }), _jsx(DropdownMenuSeparator, {}), onProfile ? (_jsxs(DropdownMenuItem, { onClick: onProfile, children: [_jsx(HugeiconsIcon, { icon: UserIcon, "aria-hidden": true }), "Profil"] })) : null, onSecurity ? (_jsxs(DropdownMenuItem, { onClick: onSecurity, children: [_jsx(HugeiconsIcon, { icon: SecurityLockIcon, "aria-hidden": true }), "S\u00E9curit\u00E9"] })) : null, children, _jsx(ThemeSwitch, {}), onShortcuts ? (_jsxs(DropdownMenuItem, { onClick: onShortcuts, children: [_jsx(HugeiconsIcon, { icon: KeyboardIcon, "aria-hidden": true }), "Raccourcis clavier", _jsx(DropdownMenuShortcut, { children: "?" })] })) : null, products.length ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, { className: railShown ? "lg:hidden" : undefined }), _jsxs(DropdownMenuGroup, { className: railShown ? "lg:hidden" : undefined, children: [_jsx(DropdownMenuLabel, { children: "Produits" }), products.map((product) => product.current ? (_jsxs(DropdownMenuItem, { disabled: true, className: "data-disabled:opacity-100", children: [_jsx(ProductMenuIcon, { product: product }), _jsx("span", { className: "flex-1", children: product.name }), _jsx(HugeiconsIcon, { icon: Tick02Icon, "aria-label": "Produit ouvert" })] }, product.name)) : (_jsxs(MenuPrimitive.LinkItem, { href: product.href, onClick: leaveOnClick, className: MENU_LINK_ITEM, children: [_jsx(ProductMenuIcon, { product: product }), _jsx("span", { className: "flex-1", children: product.name }), product.hint ? (_jsx("span", { className: "text-xs font-normal text-muted-foreground", children: product.hint })) : null] }, product.name)))] })] })) : null, _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: onSignOut, children: [_jsx(HugeiconsIcon, { icon: Logout01Icon, "aria-hidden": true }), "Se d\u00E9connecter"] })] })] }));
|
|
36
|
+
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: variant === "row" ? (_jsx("button", { type: "button", "aria-label": `Compte de ${user.name}`, className: "flex w-full min-w-0 items-center gap-2.5 rounded-xl p-1.5 text-left outline-none transition-colors duration-(--duration-fast) ease-out hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50 aria-expanded:bg-muted lg:hover:bg-shell-hover lg:aria-expanded:bg-shell-hover lg:rail:justify-center" })) : (_jsx("button", { type: "button", "aria-label": `Compte de ${user.name}`, className: "touch-target grid size-9 place-items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring/50" })), children: [_jsxs(Avatar, { children: [user.image ? _jsx(AvatarImage, { src: user.image, alt: "" }) : null, _jsx(AvatarFallback, { className: "text-xs font-semibold uppercase", children: initials(user.name, user.email) })] }), variant === "row" ? (_jsxs("span", { className: "min-w-0 flex-1 lg:rail:hidden", children: [_jsx("span", { className: "block truncate text-sm font-medium", children: user.name }), _jsx("span", { className: "block truncate text-xs text-muted-foreground lg:text-shell-muted", children: user.email })] })) : null] }), _jsxs(DropdownMenuContent, { align: variant === "row" ? "start" : "end", side: variant === "row" ? "top" : "bottom", className: "w-64", children: [_jsx(DropdownMenuGroup, { children: _jsxs(DropdownMenuLabel, { children: [_jsx("span", { className: "block truncate text-foreground", children: user.name }), _jsx("span", { className: "block truncate", children: user.email })] }) }), _jsx(DropdownMenuSeparator, {}), onProfile ? (_jsxs(DropdownMenuItem, { onClick: onProfile, children: [_jsx(HugeiconsIcon, { icon: UserIcon, "aria-hidden": true }), "Profil"] })) : null, onSecurity ? (_jsxs(DropdownMenuItem, { onClick: onSecurity, children: [_jsx(HugeiconsIcon, { icon: SecurityLockIcon, "aria-hidden": true }), "S\u00E9curit\u00E9"] })) : null, children, _jsx(ThemeSwitch, {}), onShortcuts ? (_jsxs(DropdownMenuItem, { onClick: onShortcuts, children: [_jsx(HugeiconsIcon, { icon: KeyboardIcon, "aria-hidden": true }), "Raccourcis clavier", _jsx(DropdownMenuShortcut, { children: "?" })] })) : null, statusPageUrl ? (_jsxs(MenuPrimitive.LinkItem, { href: statusPageUrl, className: MENU_LINK_ITEM, children: [_jsx(HugeiconsIcon, { icon: Activity01Icon, "aria-hidden": true }), "\u00C9tat du service"] })) : null, products.length ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, { className: railShown ? "lg:hidden" : undefined }), _jsxs(DropdownMenuGroup, { className: railShown ? "lg:hidden" : undefined, children: [_jsx(DropdownMenuLabel, { children: "Produits" }), products.map((product) => product.current ? (_jsxs(DropdownMenuItem, { disabled: true, className: "data-disabled:opacity-100", children: [_jsx(ProductMenuIcon, { product: product }), _jsx("span", { className: "flex-1", children: product.name }), _jsx(HugeiconsIcon, { icon: Tick02Icon, "aria-label": "Produit ouvert" })] }, product.name)) : (_jsxs(MenuPrimitive.LinkItem, { href: product.href, onClick: leaveOnClick, className: MENU_LINK_ITEM, children: [_jsx(ProductMenuIcon, { product: product }), _jsx("span", { className: "flex-1", children: product.name }), product.hint ? (_jsx("span", { className: "text-xs font-normal text-muted-foreground", children: product.hint })) : null] }, product.name)))] })] })) : null, _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: onSignOut, children: [_jsx(HugeiconsIcon, { icon: Logout01Icon, "aria-hidden": true }), "Se d\u00E9connecter"] })] })] }));
|
|
34
37
|
}
|
|
35
38
|
function ProductMenuIcon({ product }) {
|
|
36
39
|
if (product.badge)
|
package/dist/app-shell.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export declare function AppShell({ product, organization, productRail, accountHr
|
|
|
84
84
|
/**
|
|
85
85
|
* Page de statut du produit, dont le bandeau d'état se pose en tête du contenu (ADR 0018) :
|
|
86
86
|
* `https://status.hgdc.ch/<produit>` par défaut, une autre adresse (prévisualisation sur une page
|
|
87
|
-
* de test), ou `false` pour ne rien lire.
|
|
87
|
+
* de test), ou `false` pour ne rien lire. Le menu du compte en tire son entrée « État du service ».
|
|
88
88
|
*/
|
|
89
89
|
statusPage?: string | false | undefined;
|
|
90
90
|
}): React.JSX.Element;
|
package/dist/app-shell.js
CHANGED
|
@@ -14,7 +14,7 @@ import { ProductBadge } from "./product-badge.js";
|
|
|
14
14
|
import { ProductRail } from "./product-rail.js";
|
|
15
15
|
import { useProductSwitch } from "./product-switch.js";
|
|
16
16
|
import { HGDC_ACCOUNT, HGDC_PRODUCTS } from "./products.js";
|
|
17
|
-
import { ProductRailShownContext, ShellLeaveContext } from "./shell-placement.js";
|
|
17
|
+
import { ProductRailShownContext, ShellLeaveContext, StatusPageContext } from "./shell-placement.js";
|
|
18
18
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
19
19
|
import { cn } from "./cn.js";
|
|
20
20
|
import { ServiceStatus, statusPageUrlFor } from "./service-status.js";
|
|
@@ -201,6 +201,7 @@ export function AppShell({ product, organization, productRail = true, accountHre
|
|
|
201
201
|
window.addEventListener("pageshow", onPageShow);
|
|
202
202
|
return () => window.removeEventListener("pageshow", onPageShow);
|
|
203
203
|
}, []);
|
|
204
|
+
const statusPageUrl = statusPage === false ? null : (statusPage ?? statusPageUrlFor(product));
|
|
204
205
|
const loading = useContentLoading({ navigating, pending: pagePending > 0 || leaving });
|
|
205
206
|
// Avant l'hydratation, le CSS montre le calque et le H dès qu'une page attend (`:has`) ; ensuite
|
|
206
207
|
// `data-loading` prend le relais dans la même image.
|
|
@@ -212,5 +213,5 @@ export function AppShell({ product, organization, productRail = true, accountHre
|
|
|
212
213
|
if (loading && contentRef.current)
|
|
213
214
|
contentRef.current.scrollTop = 0;
|
|
214
215
|
}, [loading]);
|
|
215
|
-
return (_jsx(ShellContext.Provider, { value: { closeMobileNav: () => setMenuOpen(false) }, children: _jsx(ProductRailShownContext, { value: productRail, children: _jsx(ShellLeaveContext, { value: leave, children: _jsxs("div", { "data-slot": "app-shell", "data-rail-peek": railPeek ? "" : undefined, "data-product-rail": productRail ? "" : undefined, "data-loading": loading ? "" : undefined, "data-hydrated": hydrated ? "" : undefined, className: cn("min-h-dvh lg:grid lg:h-dvh lg:bg-shell", productRail ? "lg:grid-cols-[auto_auto_minmax(0,1fr)]" : "lg:grid-cols-[auto_minmax(0,1fr)]"), children: [_jsx("a", { href: "#contenu", className: "sr-only z-50 rounded-xl bg-background px-4 py-2 text-sm font-medium focus:not-sr-only focus:fixed focus:top-3 focus:left-3 focus:ring-2 focus:ring-ring", children: "Aller au contenu" }), productRail ? (_jsx(ProductRail, { current: product, organization: organization, accountHref: accountHref, onExpandedChange: setRailPeek })) : null, _jsxs("aside", { "aria-label": "Barre lat\u00E9rale", className: "group/sidebar hidden overflow-hidden text-shell-foreground transition-[width] duration-(--duration-base) ease-ios motion-reduce:transition-none lg:flex lg:w-64 lg:flex-col lg:rail:w-16", children: [_jsx(SidebarHead, { product: product }), !productRail && organization ? _jsx("div", { className: "shrink-0 px-3 pb-1", children: organization }) : null, nav, sidebarFooter ? _jsx("div", { className: "grid gap-0.5 px-3 pt-1 pb-3", children: sidebarFooter }) : null] }), _jsx("div", { className: "flex min-h-dvh flex-col lg:min-h-0 lg:p-2 lg:pl-0", children: _jsxs("div", { ref: contentRef, className: "relative flex flex-1 flex-col lg:min-h-0 lg:overflow-y-auto lg:rounded-xl lg:bg-background lg:[scrollbar-gutter:stable]", children: [_jsxs("header", { className: "sticky top-[env(safe-area-inset-top,0px)] z-30 flex min-h-14 shrink-0 flex-wrap items-center gap-x-1 gap-y-1 border-b border-foreground/5 bg-background px-2 py-1.5 sm:px-4 lg:top-0", children: [_jsx("button", { type: "button", onClick: () => setMenuOpen(true), "aria-label": "Ouvrir le menu", className: "touch-target grid size-10 shrink-0 place-items-center rounded-xl text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 lg:hidden", children: _jsx(HugeiconsIcon, { icon: Menu01Icon, "aria-hidden": true, className: "size-5" }) }), _jsxs("div", { "data-slot": "app-shell-brand", className: "flex shrink-0 items-center gap-2 pr-1 lg:hidden", children: [_jsx(ProductBadge, { product: product, className: "size-6" }), _jsx("span", { className: "font-heading text-[0.9375rem] font-semibold", children: productName(product) })] }), _jsx("div", { className: cn("flex min-w-0 items-center gap-2", header ? "flex-[1_1_7rem]" : "flex-1"), children: header }), onSearch ? (_jsx(CommandMenuButton, { onClick: onSearch, compact: "mobile", className: "shrink-0 lg:w-96 lg:max-w-none", ...(searchLabel !== undefined ? { label: searchLabel } : {}) })) : null] }), _jsx("div", { "data-slot": "app-shell-loading", "aria-hidden": !loading, className: CONTENT_LOADING_LAYER, children: loading ? (_jsx("span", { role: "status", className: "sr-only", children: "Chargement\u2026" })) : null }), _jsxs("main", { id: "contenu", tabIndex: -1, "aria-busy": loading ? true : undefined, inert: loading || undefined, className: cn("mx-auto w-full max-w-6xl flex-1 px-4 pt-6 pb-16 outline-none sm:px-6 lg:px-10 lg:pt-8", mainClassName), children: [_jsx(ServiceStatus, { pageUrl:
|
|
216
|
+
return (_jsx(ShellContext.Provider, { value: { closeMobileNav: () => setMenuOpen(false) }, children: _jsx(ProductRailShownContext, { value: productRail, children: _jsx(ShellLeaveContext, { value: leave, children: _jsx(StatusPageContext, { value: statusPageUrl, children: _jsxs("div", { "data-slot": "app-shell", "data-rail-peek": railPeek ? "" : undefined, "data-product-rail": productRail ? "" : undefined, "data-loading": loading ? "" : undefined, "data-hydrated": hydrated ? "" : undefined, className: cn("min-h-dvh lg:grid lg:h-dvh lg:bg-shell", productRail ? "lg:grid-cols-[auto_auto_minmax(0,1fr)]" : "lg:grid-cols-[auto_minmax(0,1fr)]"), children: [_jsx("a", { href: "#contenu", className: "sr-only z-50 rounded-xl bg-background px-4 py-2 text-sm font-medium focus:not-sr-only focus:fixed focus:top-3 focus:left-3 focus:ring-2 focus:ring-ring", children: "Aller au contenu" }), productRail ? (_jsx(ProductRail, { current: product, organization: organization, accountHref: accountHref, onExpandedChange: setRailPeek })) : null, _jsxs("aside", { "aria-label": "Barre lat\u00E9rale", className: "group/sidebar hidden overflow-hidden text-shell-foreground transition-[width] duration-(--duration-base) ease-ios motion-reduce:transition-none lg:flex lg:w-64 lg:flex-col lg:rail:w-16", children: [_jsx(SidebarHead, { product: product }), !productRail && organization ? _jsx("div", { className: "shrink-0 px-3 pb-1", children: organization }) : null, nav, sidebarFooter ? _jsx("div", { className: "grid gap-0.5 px-3 pt-1 pb-3", children: sidebarFooter }) : null] }), _jsx("div", { className: "flex min-h-dvh flex-col lg:min-h-0 lg:p-2 lg:pl-0", children: _jsxs("div", { ref: contentRef, className: "relative flex flex-1 flex-col lg:min-h-0 lg:overflow-y-auto lg:rounded-xl lg:bg-background lg:[scrollbar-gutter:stable]", children: [_jsxs("header", { className: "sticky top-[env(safe-area-inset-top,0px)] z-30 flex min-h-14 shrink-0 flex-wrap items-center gap-x-1 gap-y-1 border-b border-foreground/5 bg-background px-2 py-1.5 sm:px-4 lg:top-0", children: [_jsx("button", { type: "button", onClick: () => setMenuOpen(true), "aria-label": "Ouvrir le menu", className: "touch-target grid size-10 shrink-0 place-items-center rounded-xl text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 lg:hidden", children: _jsx(HugeiconsIcon, { icon: Menu01Icon, "aria-hidden": true, className: "size-5" }) }), _jsxs("div", { "data-slot": "app-shell-brand", className: "flex shrink-0 items-center gap-2 pr-1 lg:hidden", children: [_jsx(ProductBadge, { product: product, className: "size-6" }), _jsx("span", { className: "font-heading text-[0.9375rem] font-semibold", children: productName(product) })] }), _jsx("div", { className: cn("flex min-w-0 items-center gap-2", header ? "flex-[1_1_7rem]" : "flex-1"), children: header }), onSearch ? (_jsx(CommandMenuButton, { onClick: onSearch, compact: "mobile", className: "shrink-0 lg:w-96 lg:max-w-none", ...(searchLabel !== undefined ? { label: searchLabel } : {}) })) : null] }), _jsx("div", { "data-slot": "app-shell-loading", "aria-hidden": !loading, className: CONTENT_LOADING_LAYER, children: loading ? (_jsx("span", { role: "status", className: "sr-only", children: "Chargement\u2026" })) : null }), _jsxs("main", { id: "contenu", tabIndex: -1, "aria-busy": loading ? true : undefined, inert: loading || undefined, className: cn("mx-auto w-full max-w-6xl flex-1 px-4 pt-6 pb-16 outline-none sm:px-6 lg:px-10 lg:pt-8", mainClassName), children: [_jsx(ServiceStatus, { pageUrl: statusPageUrl, className: "mb-6" }), _jsx(ContentLoadingContext, { value: registerPagePending, children: contentKey === undefined ? (children) : (_jsx(Suspense, { fallback: _jsx(PagePending, {}), children: children }, contentKey)) })] })] }) }), hasRoot ? null : _jsx(FamilyLoaderHost, {}), _jsx(Drawer, { side: "bottom", open: menuOpen, onOpenChange: setMenuOpen, children: _jsxs(DrawerContent, { className: "lg:hidden", children: [_jsx(DrawerTitle, { className: "sr-only", children: "Menu" }), organization ? _jsx("div", { className: "px-3 pt-1", children: organization }) : null, nav, sidebarFooter ? (_jsx("div", { className: "grid gap-0.5 border-t border-foreground/5 px-3 pt-2 pb-[max(env(safe-area-inset-bottom),0.75rem)]", children: sidebarFooter })) : null] }) })] }) }) }) }) }));
|
|
216
217
|
}
|
|
@@ -19,3 +19,10 @@ export declare function useProductRailShown(): boolean;
|
|
|
19
19
|
export declare const ShellLeaveContext: React.Context<() => void>;
|
|
20
20
|
/** `onClick` d'un lien vers un autre produit : clic simple seulement (pas Ctrl, Cmd, Maj, molette). */
|
|
21
21
|
export declare function useLeaveOnClick(): (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Page de statut du produit affiché, posée par `AppShell` (son `statusPage`, sinon
|
|
24
|
+
* `https://status.hgdc.ch/<produit>`) : le menu du compte en tire son entrée « État du service ».
|
|
25
|
+
* `null` hors de la coque ou quand la coque ne lit aucune page.
|
|
26
|
+
*/
|
|
27
|
+
export declare const StatusPageContext: React.Context<string | null>;
|
|
28
|
+
export declare function useStatusPage(): string | null;
|
package/dist/shell-placement.js
CHANGED
|
@@ -31,3 +31,12 @@ export function useLeaveOnClick() {
|
|
|
31
31
|
leave();
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Page de statut du produit affiché, posée par `AppShell` (son `statusPage`, sinon
|
|
36
|
+
* `https://status.hgdc.ch/<produit>`) : le menu du compte en tire son entrée « État du service ».
|
|
37
|
+
* `null` hors de la coque ou quand la coque ne lit aucune page.
|
|
38
|
+
*/
|
|
39
|
+
export const StatusPageContext = createContext(null);
|
|
40
|
+
export function useStatusPage() {
|
|
41
|
+
return useContext(StatusPageContext);
|
|
42
|
+
}
|
package/dist/uptime-bar.d.ts
CHANGED
|
@@ -6,15 +6,38 @@ export type UptimeDay = {
|
|
|
6
6
|
status: ServiceStatus;
|
|
7
7
|
/** Disponibilité du jour, déjà formatée : « 99,98 % ». */
|
|
8
8
|
uptime?: string;
|
|
9
|
-
/** Ce qui s'est passé : « Panne de 12 min, base de données ». */
|
|
9
|
+
/** Ce qui s'est passé : « Panne de 12 min, base de données ». Ignoré quand `detail` est là. */
|
|
10
10
|
note?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Détail du jour, comme chez Statuspage : durée par niveau et incidents en liens. Le jour ouvre
|
|
13
|
+
* alors une bulle (survol, toucher, Entrée) dont les liens se suivent au clavier, au lieu de
|
|
14
|
+
* l'infobulle en texte.
|
|
15
|
+
*/
|
|
16
|
+
detail?: UptimeDayDetail;
|
|
17
|
+
};
|
|
18
|
+
export type UptimeDayDetail = {
|
|
19
|
+
/** Temps passé à chaque niveau, du plus grave au moins grave : « Panne majeure », « 12 min ». */
|
|
20
|
+
levels: Array<{
|
|
21
|
+
status: ServiceStatus;
|
|
22
|
+
label: string;
|
|
23
|
+
duration: string;
|
|
24
|
+
}>;
|
|
25
|
+
/** Incidents du jour, vers leur page. */
|
|
26
|
+
incidents: Array<{
|
|
27
|
+
title: string;
|
|
28
|
+
href: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** Phrase quand `levels` est vide : « Aucune panne ce jour-là » par défaut. */
|
|
31
|
+
empty?: string;
|
|
11
32
|
};
|
|
12
33
|
/** Le jour à atteindre pour une touche, ou `null` si la touche ne déplace pas. */
|
|
13
34
|
export declare function nextDay(key: string, current: number, count: number): number | null;
|
|
14
35
|
/**
|
|
15
36
|
* Une barre par jour, du plus ancien au plus récent, comme les pages de statut de référence.
|
|
16
37
|
* Chaque barre a sa couleur et, au survol, une infobulle en texte (jour, statut, disponibilité,
|
|
17
|
-
* note).
|
|
38
|
+
* note). Un jour qui porte un `detail` ouvre à la place une bulle (survol, toucher, Entrée) : durée
|
|
39
|
+
* par niveau et incidents du jour en liens. Les lecteurs d'écran lisent la liste des jours, dont
|
|
40
|
+
* chacun dit son statut en mots.
|
|
18
41
|
*
|
|
19
42
|
* Au clavier, la barre est un seul arrêt de tabulation (le dernier jour visité, aujourd'hui au
|
|
20
43
|
* départ) ; les flèches, Début et Fin passent d'un jour à l'autre et ouvrent son infobulle.
|
package/dist/uptime-bar.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from "./popover.js";
|
|
4
|
+
import { SERVICE_STATUS_LABEL, StatusDot } from "./status.js";
|
|
4
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
5
6
|
import { cn } from "./cn.js";
|
|
7
|
+
const NO_DOWNTIME = "Aucune panne ce jour-là";
|
|
6
8
|
const BAR = {
|
|
7
9
|
operational: "bg-status-operational",
|
|
8
10
|
degraded: "bg-status-degraded",
|
|
@@ -10,11 +12,20 @@ const BAR = {
|
|
|
10
12
|
maintenance: "bg-status-maintenance",
|
|
11
13
|
unknown: "bg-foreground/10",
|
|
12
14
|
};
|
|
15
|
+
const DAY = "block w-full rounded-[3px] outline-none transition-opacity duration-(--duration-fast) ease-out hover:opacity-70 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-popup-open:opacity-70";
|
|
13
16
|
const day = new Intl.DateTimeFormat("fr-CH", { weekday: "short", day: "numeric", month: "short" });
|
|
17
|
+
const longDay = new Intl.DateTimeFormat("fr-CH", { weekday: "long", day: "numeric", month: "long", year: "numeric" });
|
|
14
18
|
function describe(entry) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const detail = entry.detail;
|
|
20
|
+
const note = detail
|
|
21
|
+
? [
|
|
22
|
+
...detail.levels.map((level) => `${level.label} ${level.duration}`),
|
|
23
|
+
...detail.incidents.map((incident) => incident.title),
|
|
24
|
+
].join(" · ") ||
|
|
25
|
+
detail.empty ||
|
|
26
|
+
NO_DOWNTIME
|
|
27
|
+
: entry.note;
|
|
28
|
+
return [day.format(entry.date), SERVICE_STATUS_LABEL[entry.status], entry.uptime, note].filter(Boolean).join(" · ");
|
|
18
29
|
}
|
|
19
30
|
/** Le jour à atteindre pour une touche, ou `null` si la touche ne déplace pas. */
|
|
20
31
|
export function nextDay(key, current, count) {
|
|
@@ -33,10 +44,16 @@ export function nextDay(key, current, count) {
|
|
|
33
44
|
return null;
|
|
34
45
|
}
|
|
35
46
|
}
|
|
47
|
+
/** Bulle d'un jour : date, disponibilité, durée par niveau (point et mots), incidents en liens. */
|
|
48
|
+
function DayDetail({ entry, detail }) {
|
|
49
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { children: [_jsx(PopoverTitle, { className: "first-letter:uppercase", children: longDay.format(entry.date) }), entry.uptime ? _jsx("p", { className: "text-xs text-muted-foreground tabular-nums", children: entry.uptime }) : null] }), detail.levels.length ? (_jsx("ul", { className: "grid gap-1", children: detail.levels.map((level) => (_jsxs("li", { className: "flex items-center gap-2", children: [_jsx(StatusDot, { status: level.status }), _jsx("span", { className: "min-w-0 flex-1", children: level.label }), _jsx("span", { className: "shrink-0 text-muted-foreground tabular-nums", children: level.duration })] }, level.label))) })) : (_jsx("p", { className: "text-muted-foreground", children: detail.empty ?? NO_DOWNTIME })), detail.incidents.length ? (_jsx("ul", { "aria-label": "Incidents du jour", className: "grid gap-1.5 border-t border-border pt-2", children: detail.incidents.map((incident) => (_jsx("li", { children: _jsx("a", { href: incident.href, className: "rounded-sm font-medium text-pretty underline decoration-muted-foreground/50 underline-offset-4 outline-none hover:decoration-foreground focus-visible:ring-2 focus-visible:ring-ring", children: incident.title }) }, incident.href))) })) : null] }));
|
|
50
|
+
}
|
|
36
51
|
/**
|
|
37
52
|
* Une barre par jour, du plus ancien au plus récent, comme les pages de statut de référence.
|
|
38
53
|
* Chaque barre a sa couleur et, au survol, une infobulle en texte (jour, statut, disponibilité,
|
|
39
|
-
* note).
|
|
54
|
+
* note). Un jour qui porte un `detail` ouvre à la place une bulle (survol, toucher, Entrée) : durée
|
|
55
|
+
* par niveau et incidents du jour en liens. Les lecteurs d'écran lisent la liste des jours, dont
|
|
56
|
+
* chacun dit son statut en mots.
|
|
40
57
|
*
|
|
41
58
|
* Au clavier, la barre est un seul arrêt de tabulation (le dernier jour visité, aujourd'hui au
|
|
42
59
|
* départ) ; les flèches, Début et Fin passent d'un jour à l'autre et ouvrent son infobulle.
|
|
@@ -53,5 +70,16 @@ export function UptimeBar({ days, label = "Disponibilité", summary, className,
|
|
|
53
70
|
setFocused(target);
|
|
54
71
|
list.current?.querySelectorAll("[data-slot=uptime-day]")[target]?.focus();
|
|
55
72
|
}
|
|
56
|
-
return (_jsxs("div", { "data-slot": "uptime-bar", className: cn("grid gap-2", className), children: [_jsx("ol", { ref: list, "aria-label": label, className: "flex h-8 items-stretch gap-[2px]", children: days.map((entry, index) =>
|
|
73
|
+
return (_jsxs("div", { "data-slot": "uptime-bar", className: cn("grid gap-2", className), children: [_jsx("ol", { ref: list, "aria-label": label, className: "flex h-8 items-stretch gap-[2px]", children: days.map((entry, index) => {
|
|
74
|
+
const trigger = {
|
|
75
|
+
render: _jsx("button", { type: "button" }),
|
|
76
|
+
"data-slot": "uptime-day",
|
|
77
|
+
tabIndex: index === current ? 0 : -1,
|
|
78
|
+
onFocus: () => setFocused(index),
|
|
79
|
+
onKeyDown,
|
|
80
|
+
className: cn(DAY, BAR[entry.status]),
|
|
81
|
+
children: _jsx("span", { className: "sr-only", children: describe(entry) }),
|
|
82
|
+
};
|
|
83
|
+
return (_jsx("li", { className: "flex min-w-0 flex-1", children: entry.detail ? (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { openOnHover: true, ...trigger }), _jsx(PopoverContent, { side: "top", className: "w-64 gap-3", "data-slot": "uptime-day-detail", children: _jsx(DayDetail, { entry: entry, detail: entry.detail }) })] })) : (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { ...trigger }), _jsx(TooltipContent, { children: describe(entry) })] })) }, new Date(entry.date).toISOString()));
|
|
84
|
+
}) }), _jsxs("div", { "aria-hidden": true, "data-slot": "uptime-legend", className: "flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-xs text-muted-foreground tabular-nums", children: [_jsx("span", { className: "shrink-0", children: days.length > 0 ? `il y a ${days.length} jours` : null }), summary ? (_jsx("span", { className: "min-w-0 text-center text-pretty break-words text-foreground", children: summary })) : null, _jsx("span", { className: "shrink-0", children: "Aujourd'hui" })] })] }));
|
|
57
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hgdc/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Interface de la H Collection : jetons de la DA, thèmes, polices et composants.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://github.com/hugogebel-boop/hgdc-kit/tree/main/packages/ui#readme",
|