@etic-insa/ui 0.5.0 → 0.6.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.
@@ -0,0 +1,46 @@
1
+ import { TONS as e } from "../../lib/ton.js";
2
+ import { cn as t } from "cn";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ // src/components/etic/progress-ring.tsx
5
+ var i = 11, a = 89 / 2, o = i / 2 / (2 * Math.PI * a) * 100, s = {
6
+ cx: 50,
7
+ cy: 50,
8
+ r: a,
9
+ fill: "none",
10
+ strokeWidth: i
11
+ };
12
+ function c({ valeur: i, ton: a = "neutral", libelle: c, children: l, className: u, ...d }) {
13
+ let f = i === null || Number.isNaN(i) ? 0 : Math.min(100, Math.max(0, i)), p = f >= 100;
14
+ return /* @__PURE__ */ r("div", {
15
+ role: "img",
16
+ "aria-label": c,
17
+ "data-slot": "progress-ring",
18
+ "data-ton": a,
19
+ className: t("relative size-28 shrink-0", u),
20
+ ...d,
21
+ children: [/* @__PURE__ */ r("svg", {
22
+ "aria-hidden": !0,
23
+ viewBox: "0 0 100 100",
24
+ className: "size-full -rotate-90",
25
+ children: [/* @__PURE__ */ n("circle", {
26
+ ...s,
27
+ className: "stroke-muted"
28
+ }), f > 0 ? /* @__PURE__ */ n("circle", {
29
+ ...s,
30
+ "data-slot": "progress-ring-arc",
31
+ strokeLinecap: p ? "butt" : "round",
32
+ pathLength: 100,
33
+ strokeDasharray: `${p ? 100 : Math.max(f - 2 * o, .01)} 100`,
34
+ strokeDashoffset: p ? 0 : -o,
35
+ className: e[a].trait
36
+ }) : null]
37
+ }), l == null ? null : /* @__PURE__ */ n("span", {
38
+ "aria-hidden": !0,
39
+ className: "absolute inset-0 grid place-items-center text-xl font-semibold tracking-tight tabular-nums",
40
+ children: l
41
+ })]
42
+ });
43
+ }
44
+ export { c as ProgressRing };
45
+
46
+ //# sourceMappingURL=progress-ring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-ring.js","names":["EPAISSEUR","RAYON","BOUT","CERCLE","ProgressRing","props","part","valeur","plein","libelle","ton","cn","className","TONS","children"],"sources":["../../../src/components/etic/progress-ring.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from \"react\"\nimport { cn } from \"cn\"\n\nimport { TONS, type StatusTon } from \"@etic-ui/lib/ton\"\n\n// Dans un carré de 100 : l'anneau longe le bord du cadre, épais de 11 % de\n// son diamètre.\nconst EPAISSEUR = 11\nconst RAYON = (100 - EPAISSEUR) / 2\n// Ce que dépasse un bout arrondi, en % du tour : une demi-épaisseur. Le\n// tracé est raccourci de deux bouts et part un bout plus loin, pour que\n// l'arc, bouts compris, couvre exactement la valeur (sans quoi les bouts se\n// chevauchent à midi près du plein).\nconst BOUT = (EPAISSEUR / 2 / (2 * Math.PI * RAYON)) * 100\n// Piste et arc : le même cercle.\nconst CERCLE = {\n cx: 50,\n cy: 50,\n r: RAYON,\n fill: \"none\",\n strokeWidth: EPAISSEUR,\n} as const\n\nexport interface ProgressRingProps extends Omit<\n ComponentProps<\"div\">,\n \"children\" | \"role\" | \"aria-label\"\n> {\n /** Part remplie, de 0 à 100 (bornée) ; `null` : inconnue, anneau vide. */\n valeur: number | null\n /** Couleur de l'arc : « warning » au-delà d'un seuil d'alerte,\n * « destructive » quand c'est plein. « neutral » (par défaut) : l'accent. */\n ton?: StatusTon\n /** Ce que lit un lecteur d'écran, valeur comprise : « Mémoire : 45 % ». */\n libelle: string\n /** Au centre de l'anneau, le pourcentage en général ; caché aux lecteurs\n * d'écran, que `libelle` renseigne déjà. */\n children?: ReactNode\n}\n\n/**\n * Jauge circulaire d'une ressource qui se remplit (mémoire, disque, quota) :\n * un anneau sur piste grise, rempli dans le sens des aiguilles d'une montre\n * depuis midi, et une valeur au centre. Le pendant rond de `Progress`, pour\n * une jauge qui se lit seule ; SVG pur, sans bibliothèque de graphiques.\n * La taille vient de `className` (`size-28` par défaut) ; le texte du centre\n * se règle avec ses propres classes (`text-2xl`, couleur du ton…).\n */\nexport function ProgressRing({\n valeur,\n ton = \"neutral\",\n libelle,\n children,\n className,\n ...props\n}: ProgressRingProps) {\n const part =\n valeur === null || Number.isNaN(valeur)\n ? 0\n : Math.min(100, Math.max(0, valeur))\n // Plein : un cercle fermé, sans bouts. Sous deux bouts (~4 %), l'arc se\n // réduit à un point de l'épaisseur de l'anneau.\n const plein = part >= 100\n return (\n <div\n role=\"img\"\n aria-label={libelle}\n data-slot=\"progress-ring\"\n data-ton={ton}\n className={cn(\"relative size-28 shrink-0\", className)}\n {...props}\n >\n <svg aria-hidden viewBox=\"0 0 100 100\" className=\"size-full -rotate-90\">\n <circle {...CERCLE} className=\"stroke-muted\" />\n {/* Rien à 0 : le bout arrondi d'un arc vide dessinerait un point. */}\n {part > 0 ? (\n <circle\n {...CERCLE}\n data-slot=\"progress-ring-arc\"\n strokeLinecap={plein ? \"butt\" : \"round\"}\n pathLength={100}\n strokeDasharray={`${plein ? 100 : Math.max(part - 2 * BOUT, 0.01)} 100`}\n strokeDashoffset={plein ? 0 : -BOUT}\n className={TONS[ton].trait}\n />\n ) : null}\n </svg>\n {children != null ? (\n <span\n aria-hidden\n className=\"absolute inset-0 grid place-items-center text-xl font-semibold tracking-tight tabular-nums\"\n >\n {children}\n </span>\n ) : null}\n </div>\n )\n}\n"],"mappings":";;;;AAOA,IAAMA,IAAY,IACZC,IAAS,KAAmB,GAK5BC,IAAQF,IAAY,KAAK,IAAI,KAAK,KAAKC,KAAU,KAEjDE,IAAS;CACb,IAAI;CACJ,IAAI;CACJ,GAAGF;CACH,MAAM;CACN,aAAaD;AACf;AA0BA,SAAgBI,EAAa,EAC3B,WACA,SAAM,WACN,YACA,aACA,cACA,GAAGC,KACiB;CACpB,IAAMC,IACJC,MAAW,QAAQ,OAAO,MAAMA,CAAM,IAClC,IACA,KAAK,IAAI,KAAK,KAAK,IAAI,GAAGA,CAAM,CAAC,GAGjCC,IAAQF,KAAQ;CACtB,OACE,kBAAC,OAAD;EACE,MAAK;EACL,cAAYG;EACZ,aAAU;EACV,YAAUC;EACV,WAAWC,EAAG,6BAA6BC,CAAS;EACpD,GAAIP;EANN,UAAA,CAQE,kBAAC,OAAD;GAAK,eAAA;GAAY,SAAQ;GAAc,WAAU;GAAjD,UAAA,CACE,kBAAC,UAAD;IAAQ,GAAIF;IAAQ,WAAU;GAAgB,CAAA,GAE7CG,IAAO,IACN,kBAAC,UAAD;IACE,GAAIH;IACJ,aAAU;IACV,eAAeK,IAAQ,SAAS;IAChC,YAAY;IACZ,iBAAiB,GAAGA,IAAQ,MAAM,KAAK,IAAIF,IAAO,IAAIJ,GAAM,GAAI,EAAE;IAClE,kBAAkBM,IAAQ,IAAI,CAACN;IAC/B,WAAWW,EAAKH,EAAI,CAAC;GACtB,CAAA,IACC,IACD;EACJ,CAAA,GAAAI,KAAY,OAOT,OANF,kBAAC,QAAD;GACE,eAAA;GACA,WAAU;GAET;EACG,CAAA,CAEL;;AAET"}
@@ -0,0 +1,37 @@
1
+ import { TooltipButtonProps } from './tooltip-button';
2
+ export interface ResetButtonProps extends Omit<TooltipButtonProps, "onClick" | "children" | "infobulle" | "verrou"> {
3
+ /** La valeur rétablie, telle qu'elle s'affiche (« 6 », « 5 Mo »,
4
+ * « Hebdomadaire ») : l'infobulle dit « Rétablir la valeur par défaut :
5
+ * 6 ». Sans elle, le bouton rétablit tout un formulaire. */
6
+ valeur?: string;
7
+ onRetablir: () => void;
8
+ /** La valeur est déjà celle par défaut : le bouton est invisible mais
9
+ * garde sa place (rien ne bouge autour quand il apparaît) et sort de
10
+ * l'ordre de tabulation. */
11
+ masque?: boolean;
12
+ /** Identifiant du libellé que le nom accessible cite (« … du champ
13
+ * Cadence ») : par défaut, celui du `FormField` qui entoure le bouton.
14
+ * Pour un champ hors `FormField` (`FieldSet` et sa `FieldLegend`). */
15
+ libelleId?: string;
16
+ /**
17
+ * Élément qui reçoit le focus une fois la valeur rétablie : son
18
+ * identifiant, ou une fonction qui le renvoie. Par défaut, le contrôle du
19
+ * `FormField` qui entoure le bouton. Un groupe (boutons joints, cases)
20
+ * donne le focus à son option choisie. Le bouton se masque d'ordinaire
21
+ * avec l'écart : sans cible, le focus tomberait sur la page.
22
+ */
23
+ cible?: string | (() => HTMLElement | null | undefined);
24
+ }
25
+ /**
26
+ * Retour à la valeur par défaut d'un champ : une icône ↶, la valeur rétablie
27
+ * dans l'infobulle. Dans un `FormField`, à passer à son `action` : il se
28
+ * pose à droite du contrôle, et son nom accessible cite le libellé du champ
29
+ * (« Rétablir la valeur par défaut (6) du champ Copies conservées »), pour
30
+ * distinguer les boutons d'une même page ; ailleurs, `libelleId` et
31
+ * `cible` disent quel libellé citer et qui reçoit le focus. Toujours rendu,
32
+ * `masque` tant que la valeur est celle par défaut.
33
+ *
34
+ * Sans `valeur`, c'est le bouton général d'un formulaire (« Rétablir toutes
35
+ * les valeurs par défaut ») : voir `retablirDefauts` de `SaveBar`.
36
+ */
37
+ export declare function ResetButton({ valeur, onRetablir, masque, libelleId, cible, variant, size, className, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props }: ResetButtonProps): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { useFormField as e } from "./form-field-context.js";
2
+ import { TooltipButton as t } from "./tooltip-button.js";
3
+ import { cn as n } from "cn";
4
+ import { useEffectEvent as r, useId as i, useLayoutEffect as a, useState as o } from "react";
5
+ import { jsx as s } from "react/jsx-runtime";
6
+ import { Undo2Icon as c } from "lucide-react";
7
+ // src/components/etic/reset-button.tsx
8
+ var l = "input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])";
9
+ function u(e) {
10
+ return e.matches(l) ? e : e.querySelector("[aria-pressed=\"true\"], [aria-checked=\"true\"]") ?? e.querySelector(l) ?? e;
11
+ }
12
+ function d({ valeur: l, onRetablir: d, masque: f = !1, libelleId: p, cible: m, variant: h = "ghost", size: g = "icon-sm", className: _, id: v, "aria-label": y, "aria-labelledby": b, ...x }) {
13
+ let S = e(), C = i(), w = v ?? C, T = l === void 0 ? "Rétablir toutes les valeurs par défaut" : `Rétablir la valeur par défaut : ${l}`, E = p ?? S?.libelleId, D = l !== void 0 && E !== void 0 && y === void 0 && b === void 0, [O, k] = o(0), A = r(() => {
14
+ let e = typeof m == "function" ? m() : document.getElementById(m ?? S?.id ?? "");
15
+ e && u(e).focus();
16
+ });
17
+ a(() => {
18
+ O > 0 && A();
19
+ }, [O]);
20
+ let j = () => {
21
+ k((e) => e + 1), d();
22
+ };
23
+ return /* @__PURE__ */ s(t, {
24
+ ...x,
25
+ type: "button",
26
+ id: w,
27
+ variant: h,
28
+ size: g,
29
+ infobulle: f ? void 0 : T,
30
+ "aria-label": D ? `Rétablir la valeur par défaut (${l}) du champ` : y ?? T,
31
+ "aria-labelledby": D ? `${w} ${E}` : b,
32
+ "aria-hidden": f || void 0,
33
+ tabIndex: f ? -1 : void 0,
34
+ className: n(h === "ghost" && "text-muted-foreground", "transition-[opacity,visibility,color,background-color] duration-150 ease-out motion-reduce:transition-none", f && "invisible opacity-0", _),
35
+ onClick: j,
36
+ children: /* @__PURE__ */ s(c, {})
37
+ });
38
+ }
39
+ export { d as ResetButton };
40
+
41
+ //# sourceMappingURL=reset-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset-button.js","names":["FOCALISABLE","focalisableDans","cible","ResetButton","ariaLabel","ariaLabelledby","props","champ","useFormField","genere","useId","idBouton","id","infobulle","valeur","libelleCite","libelleId","nommeParLeChamp","clics","setClics","useState","focaliser","useEffectEvent","element","surClic","n","onRetablir","TooltipButton","masque","cn","variant","className","Undo2Icon"],"sources":["../../../src/components/etic/reset-button.tsx"],"sourcesContent":["import { useEffectEvent, useId, useLayoutEffect, useState } from \"react\"\nimport { cn } from \"cn\"\nimport { Undo2Icon } from \"lucide-react\"\n\nimport { useFormField } from \"@etic-ui/components/etic/form-field-context\"\nimport {\n TooltipButton,\n type TooltipButtonProps,\n} from \"@etic-ui/components/etic/tooltip-button\"\n\nexport interface ResetButtonProps extends Omit<\n TooltipButtonProps,\n \"onClick\" | \"children\" | \"infobulle\" | \"verrou\"\n> {\n /** La valeur rétablie, telle qu'elle s'affiche (« 6 », « 5 Mo »,\n * « Hebdomadaire ») : l'infobulle dit « Rétablir la valeur par défaut :\n * 6 ». Sans elle, le bouton rétablit tout un formulaire. */\n valeur?: string\n onRetablir: () => void\n /** La valeur est déjà celle par défaut : le bouton est invisible mais\n * garde sa place (rien ne bouge autour quand il apparaît) et sort de\n * l'ordre de tabulation. */\n masque?: boolean\n /** Identifiant du libellé que le nom accessible cite (« … du champ\n * Cadence ») : par défaut, celui du `FormField` qui entoure le bouton.\n * Pour un champ hors `FormField` (`FieldSet` et sa `FieldLegend`). */\n libelleId?: string\n /**\n * Élément qui reçoit le focus une fois la valeur rétablie : son\n * identifiant, ou une fonction qui le renvoie. Par défaut, le contrôle du\n * `FormField` qui entoure le bouton. Un groupe (boutons joints, cases)\n * donne le focus à son option choisie. Le bouton se masque d'ordinaire\n * avec l'écart : sans cible, le focus tomberait sur la page.\n */\n cible?: string | (() => HTMLElement | null | undefined)\n}\n\nconst FOCALISABLE =\n \"input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])\"\n\n/** Ce qui prend le focus dans `cible` : elle-même si elle le peut ; dans un\n * groupe, l'option choisie, sinon le premier élément focalisable. */\nfunction focalisableDans(cible: HTMLElement): HTMLElement {\n if (cible.matches(FOCALISABLE)) return cible\n return (\n cible.querySelector<HTMLElement>(\n '[aria-pressed=\"true\"], [aria-checked=\"true\"]'\n ) ??\n cible.querySelector<HTMLElement>(FOCALISABLE) ??\n cible\n )\n}\n\n/**\n * Retour à la valeur par défaut d'un champ : une icône ↶, la valeur rétablie\n * dans l'infobulle. Dans un `FormField`, à passer à son `action` : il se\n * pose à droite du contrôle, et son nom accessible cite le libellé du champ\n * (« Rétablir la valeur par défaut (6) du champ Copies conservées »), pour\n * distinguer les boutons d'une même page ; ailleurs, `libelleId` et\n * `cible` disent quel libellé citer et qui reçoit le focus. Toujours rendu,\n * `masque` tant que la valeur est celle par défaut.\n *\n * Sans `valeur`, c'est le bouton général d'un formulaire (« Rétablir toutes\n * les valeurs par défaut ») : voir `retablirDefauts` de `SaveBar`.\n */\nexport function ResetButton({\n valeur,\n onRetablir,\n masque = false,\n libelleId,\n cible,\n variant = \"ghost\",\n size = \"icon-sm\",\n className,\n id,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n}: ResetButtonProps) {\n const champ = useFormField()\n const genere = useId()\n const idBouton = id ?? genere\n const infobulle =\n valeur === undefined\n ? \"Rétablir toutes les valeurs par défaut\"\n : `Rétablir la valeur par défaut : ${valeur}`\n // Le nom cite le libellé du champ : deux « Copies conservées » sur la même\n // page ne donnent pas deux boutons indiscernables. Le bouton se cite\n // lui-même (son `aria-label`), puis le libellé : aucun texte caché.\n const libelleCite = libelleId ?? champ?.libelleId\n const nommeParLeChamp =\n valeur !== undefined &&\n libelleCite !== undefined &&\n ariaLabel === undefined &&\n ariaLabelledby === undefined\n\n // Le focus part une fois la valeur rétablie à l'écran (l'option choisie\n // d'un groupe est alors celle du défaut), avant que le navigateur ne\n // peigne le bouton masqué. Le bouton reste monté : l'effet suit chaque clic.\n const [clics, setClics] = useState(0)\n const focaliser = useEffectEvent(() => {\n const element =\n typeof cible === \"function\"\n ? cible()\n : document.getElementById(cible ?? champ?.id ?? \"\")\n if (element) focalisableDans(element).focus()\n })\n useLayoutEffect(() => {\n if (clics > 0) focaliser()\n }, [clics])\n\n const surClic = () => {\n setClics((n) => n + 1)\n onRetablir()\n }\n\n return (\n <TooltipButton\n // D'abord : les attributs calculés ci-dessous (masque, nom, clic)\n // l'emportent sur ceux de l'appelant.\n {...props}\n type=\"button\"\n id={idBouton}\n variant={variant}\n size={size}\n infobulle={masque ? undefined : infobulle}\n aria-label={\n nommeParLeChamp\n ? `Rétablir la valeur par défaut (${valeur}) du champ`\n : (ariaLabel ?? infobulle)\n }\n aria-labelledby={\n nommeParLeChamp ? `${idBouton} ${libelleCite}` : ariaLabelledby\n }\n // `invisible` : ni survol, ni focus, ni lecteur d'écran, mais la\n // place reste. Il apparaît (et s'efface) en un fondu bref : surgi à la\n // première frappe, il attirait l'œil plus que le champ. `visibility`\n // suit l'opacité (transition discrète), sans fondu si l'utilisateur\n // réduit les animations.\n aria-hidden={masque || undefined}\n tabIndex={masque ? -1 : undefined}\n className={cn(\n variant === \"ghost\" && \"text-muted-foreground\",\n \"transition-[opacity,visibility,color,background-color] duration-150 ease-out motion-reduce:transition-none\",\n masque && \"invisible opacity-0\",\n className\n )}\n onClick={surClic}\n >\n <Undo2Icon />\n </TooltipButton>\n )\n}\n"],"mappings":";;;;;;;AAqCA,IAAMA,IACJ;AAIF,SAASC,EAAgB,GAAiC;CAExD,OADIC,EAAM,QAAQF,CAAW,IAAUE,IAErCA,EAAM,cACJ,kDACF,KACAA,EAAM,cAA2BF,CAAW,KAC5CE;AAEJ;AAcA,SAAgBC,EAAY,EAC1B,WACA,eACA,YAAS,IACT,cACA,UACA,aAAU,SACV,UAAO,WACP,cACA,OACA,cAAcC,GACd,mBAAmBC,GACnB,GAAGC,KACgB;CACnB,IAAMC,IAAQC,EAAa,GACrBC,IAASC,EAAM,GACfC,IAAWC,KAAMH,GACjBI,IACJC,MAAW,KAAA,IACP,2CACA,mCAAmCA,KAInCC,IAAcC,KAAaT,GAAO,WAClCU,IACJH,MAAW,KAAA,KACXC,MAAgB,KAAA,KAChBX,MAAc,KAAA,KACdC,MAAmB,KAAA,GAKf,CAACa,GAAOC,KAAYC,EAAS,CAAC,GAC9BC,IAAYC,QAAqB;EACrC,IAAMC,IACJ,OAAOrB,KAAU,aACbA,EAAM,IACN,SAAS,eAAeA,KAASK,GAAO,MAAM,EAAE;EACtD,AAAIgB,KAAStB,EAAgBsB,CAAO,CAAC,CAAC,MAAM;CAC9C,CAAC;CACD,QAAsB;EACpB,AAAIL,IAAQ,KAAGG,EAAU;CAC3B,GAAG,CAACH,CAAK,CAAC;CAEV,IAAMM,UAAgB;EAEpB,AADAL,GAAU,MAAMM,IAAI,CAAC,GACrBC,EAAW;CACb;CAEA,OACE,kBAACC,GAAD;EAGE,GAAIrB;EACJ,MAAK;EACL,IAAIK;EACK;EACH;EACN,WAAWiB,IAAS,KAAA,IAAYf;EAChC,cACEI,IACI,kCAAkCH,EAAO,cACxCV,KAAaS;EAEpB,mBACEI,IAAkB,GAAGN,EAAS,GAAGI,MAAgBV;EAOnD,eAAauB,KAAU,KAAA;EACvB,UAAUA,IAAS,KAAK,KAAA;EACxB,WAAWC,EACTC,MAAY,WAAW,yBACvB,8GACAF,KAAU,uBACVG,CACF;EACA,SAASP;EAET,UAAA,kBAACQ,GAAD,CAAY,CAAA;CACC,CAAA;AAEnB"}
@@ -26,13 +26,28 @@ export interface SaveBarProps {
26
26
  /** Sans gestionnaire, « Enregistrer » soumet le formulaire qui l'entoure. */
27
27
  onEnregistrer?: () => void;
28
28
  /** Revenir à ce qui est enregistré : affiche « Annuler ». À ne passer que
29
- * s'il y a des modifications (`onAnnuler={modifie ? annuler : undefined}`). */
29
+ * s'il y a des modifications (`onAnnuler={modifie ? annuler : undefined}`).
30
+ * Au clic, le focus passe à « Enregistrer » : « Annuler » disparaît.
31
+ * Avec `masqueeAuRepos`, toute la barre disparaît : c'est à l'application
32
+ * de rendre le focus (au formulaire). */
30
33
  onAnnuler?: () => void;
34
+ /**
35
+ * Formulaire dont les champs ont une valeur par défaut : le bouton
36
+ * général ↶ (`ResetButton`), devant « Annuler », qui remet tous les
37
+ * champs à leur défaut sans rien enregistrer. `masque` quand aucun champ
38
+ * ne s'en écarte (il garde sa place). Au clic, le focus passe à
39
+ * « Enregistrer », l'étape suivante.
40
+ */
41
+ retablirDefauts?: {
42
+ onRetablir: () => void;
43
+ masque?: boolean;
44
+ };
31
45
  className?: string;
32
46
  }
33
47
  /**
34
48
  * Pied d'un formulaire de page (profil, paramètres) : « Enregistrer »,
35
- * « Annuler » au besoin, et le statut, annoncé (« Enregistré »,
36
- * « Modifications non enregistrées »).
49
+ * « Annuler » au besoin, le retour général aux valeurs par défaut au
50
+ * besoin, et le statut, annoncé (« Enregistré », « Modifications non
51
+ * enregistrées »).
37
52
  */
38
- export declare function SaveBar({ enCours, desactive, enregistre, modifie, collante, masqueeAuRepos, onEnregistrer, onAnnuler, className, }: SaveBarProps): import("react").JSX.Element;
53
+ export declare function SaveBar({ enCours, desactive, enregistre, modifie, collante, masqueeAuRepos, onEnregistrer, onAnnuler, retablirDefauts, className, }: SaveBarProps): import("react").JSX.Element;
@@ -1,46 +1,60 @@
1
1
  import { Button as e } from "../ui/button.js";
2
- import { cn as t } from "cn";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
- import { CheckIcon as i } from "lucide-react";
2
+ import { ResetButton as t } from "./reset-button.js";
3
+ import { cn as n } from "cn";
4
+ import { useRef as r } from "react";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { CheckIcon as o } from "lucide-react";
5
7
  // src/components/etic/save-bar.tsx
6
- function a({ enCours: a = !1, desactive: o = !1, enregistre: s = !1, modifie: c = !1, collante: l = !1, masqueeAuRepos: u = !1, onEnregistrer: d, onAnnuler: f, className: p }) {
7
- let m = l && u && !c && !a && !s, h = /* @__PURE__ */ n(e, {
8
- type: d ? "button" : "submit",
9
- onClick: d,
10
- enCours: a,
8
+ function s({ enCours: s = !1, desactive: c = !1, enregistre: l = !1, modifie: u = !1, collante: d = !1, masqueeAuRepos: f = !1, onEnregistrer: p, onAnnuler: m, retablirDefauts: h, className: g }) {
9
+ let _ = r(null), v = d && f && !u && !s && !l, y = /* @__PURE__ */ i(e, {
10
+ ref: _,
11
+ type: p ? "button" : "submit",
12
+ onClick: p,
13
+ enCours: s,
11
14
  libelleEnCours: "Enregistrement…",
12
- disabled: o,
15
+ disabled: c,
13
16
  focusableWhenDisabled: !0,
14
17
  children: "Enregistrer"
15
- }), g = f ? /* @__PURE__ */ n(e, {
18
+ }), b = m ? /* @__PURE__ */ i(e, {
16
19
  variant: "outline",
17
- onClick: f,
18
- disabled: a,
20
+ onClick: () => {
21
+ _.current?.focus(), m();
22
+ },
23
+ disabled: s,
19
24
  focusableWhenDisabled: !0,
20
25
  children: "Annuler"
21
- }) : null, _ = /* @__PURE__ */ n("p", {
26
+ }) : null, x = h ? /* @__PURE__ */ i(t, {
27
+ masque: h.masque,
28
+ disabled: s,
29
+ cible: () => _.current,
30
+ onRetablir: h.onRetablir
31
+ }) : null, S = /* @__PURE__ */ i("p", {
22
32
  role: "status",
23
- className: t("text-sm text-muted-foreground", l && "me-auto min-w-0 flex-1", m && "sr-only"),
24
- children: c ? "Modifications non enregistrées" : s ? /* @__PURE__ */ r("span", {
33
+ className: n("text-sm text-muted-foreground", d && "me-auto min-w-0 flex-1", v && "sr-only"),
34
+ children: u ? "Modifications non enregistrées" : l ? /* @__PURE__ */ a("span", {
25
35
  className: "inline-flex items-center gap-1.5 font-medium text-success",
26
- children: [/* @__PURE__ */ n(i, {
36
+ children: [/* @__PURE__ */ i(o, {
27
37
  className: "size-4",
28
38
  "aria-hidden": !0
29
39
  }), "Enregistré"]
30
40
  }) : null
31
- }), v = m ? null : /* @__PURE__ */ r("div", {
41
+ }), C = v ? null : /* @__PURE__ */ a("div", {
32
42
  "data-slot": "save-bar-actions",
33
43
  className: "flex shrink-0 items-center gap-3",
34
- children: [l ? g : h, l ? h : g]
44
+ children: [
45
+ d ? x : y,
46
+ b,
47
+ d ? y : x
48
+ ]
35
49
  });
36
- return /* @__PURE__ */ r("div", {
50
+ return /* @__PURE__ */ a("div", {
37
51
  "data-slot": "save-bar",
38
- "data-collante": l || void 0,
39
- "data-repos": m || void 0,
40
- className: t("flex items-center gap-3", !l && "flex-wrap", m && "contents", l && !m && "justify-end rounded-xl border border-border bg-card px-4 py-3", l && (c || a) && "sticky bottom-4 z-10 shadow-sm", p),
41
- children: [l ? _ : v, l ? v : _]
52
+ "data-collante": d || void 0,
53
+ "data-repos": v || void 0,
54
+ className: n("flex items-center gap-3", !d && "flex-wrap", v && "contents", d && !v && "justify-end rounded-xl border border-border bg-card px-4 py-3", d && (u || s) && "sticky bottom-4 z-10 shadow-sm", g),
55
+ children: [d ? S : C, d ? C : S]
42
56
  });
43
57
  }
44
- export { a as SaveBar };
58
+ export { s as SaveBar };
45
59
 
46
60
  //# sourceMappingURL=save-bar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"save-bar.js","names":["SaveBar","auRepos","collante","masqueeAuRepos","modifie","enCours","enregistre","enregistrer","Button","onEnregistrer","desactive","annuler","onAnnuler","statut","cn","CheckIcon","boutons","className"],"sources":["../../../src/components/etic/save-bar.tsx"],"sourcesContent":["import { cn } from \"cn\"\nimport { CheckIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\n\nexport interface SaveBarProps {\n /** Enregistrement en cours : « Enregistrer » devient « Enregistrement… »,\n * occupé (`aria-busy`), ignore les clics, mais garde le focus ;\n * « Annuler » attend la fin. */\n enCours?: boolean\n /** Rien à enregistrer, ou une saisie à corriger d'abord. */\n desactive?: boolean\n /** Affiche « Enregistré » : la dernière mutation a réussi\n * (`mutation.isSuccess`). `modifie` l'emporte. */\n enregistre?: boolean\n /** Des modifications attendent : le statut dit « Modifications non\n * enregistrées », la raison pour laquelle « Enregistrer » est actif,\n * même après un enregistrement réussi. */\n modifie?: boolean\n /** Pied d'un formulaire plus haut que l'écran, sur une carte opaque,\n * boutons à droite, statut à gauche. Tant que `modifie` est vrai (ou\n * pendant l'envoi), la barre se colle en bas de l'écran ; sinon, elle\n * reste à sa place : elle ne flotte pas sur le contenu sans raison. Les\n * bords de la carte s'alignent sur ceux des cartes de la page. */\n collante?: boolean\n /** Avec `collante` : la barre n'apparaît que lorsqu'elle a quelque chose\n * à dire (modifications, envoi en cours, « Enregistré »). Au repos, il ne\n * reste que sa zone de statut, invisible et sans place, pour que le\n * premier message soit annoncé. */\n masqueeAuRepos?: boolean\n /** Sans gestionnaire, « Enregistrer » soumet le formulaire qui l'entoure. */\n onEnregistrer?: () => void\n /** Revenir à ce qui est enregistré : affiche « Annuler ». À ne passer que\n * s'il y a des modifications (`onAnnuler={modifie ? annuler : undefined}`). */\n onAnnuler?: () => void\n className?: string\n}\n\n/**\n * Pied d'un formulaire de page (profil, paramètres) : « Enregistrer »,\n * « Annuler » au besoin, et le statut, annoncé (« Enregistré »,\n * « Modifications non enregistrées »).\n */\nexport function SaveBar({\n enCours = false,\n desactive = false,\n enregistre = false,\n modifie = false,\n collante = false,\n masqueeAuRepos = false,\n onEnregistrer,\n onAnnuler,\n className,\n}: SaveBarProps) {\n const auRepos =\n collante && masqueeAuRepos && !modifie && !enCours && !enregistre\n const enregistrer = (\n <Button\n type={onEnregistrer ? \"button\" : \"submit\"}\n onClick={onEnregistrer}\n enCours={enCours}\n libelleEnCours=\"Enregistrement…\"\n // Désactivé mais focalisable : le bouton qu'on vient d'activer ne\n // rend pas le focus à <body> quand l'enregistrement finit et qu'il ne\n // reste rien à enregistrer.\n disabled={desactive}\n focusableWhenDisabled\n >\n Enregistrer\n </Button>\n )\n const annuler = onAnnuler ? (\n <Button\n variant=\"outline\"\n onClick={onAnnuler}\n disabled={enCours}\n focusableWhenDisabled\n >\n Annuler\n </Button>\n ) : null\n // Toujours présent : une zone `status` ajoutée en même temps que son texte\n // n'est pas annoncée.\n const statut = (\n <p\n role=\"status\"\n className={cn(\n \"text-sm text-muted-foreground\",\n // Le statut se replie sur deux lignes plutôt que de séparer les\n // boutons de la barre.\n collante && \"me-auto min-w-0 flex-1\",\n auRepos && \"sr-only\"\n )}\n >\n {/* Une modification faite après l'enregistrement l'emporte :\n « Enregistré » ne vaut que pour ce qui est à l'écran. */}\n {modifie ? (\n \"Modifications non enregistrées\"\n ) : enregistre ? (\n <span className=\"inline-flex items-center gap-1.5 font-medium text-success\">\n <CheckIcon className=\"size-4\" aria-hidden />\n Enregistré\n </span>\n ) : null}\n </p>\n )\n\n // Les deux boutons ne se séparent jamais : au téléphone, c'est le statut\n // qui passe à la ligne (barre simple) ou se replie (barre collante).\n const boutons = auRepos ? null : (\n <div\n data-slot=\"save-bar-actions\"\n className=\"flex shrink-0 items-center gap-3\"\n >\n {/* Ordre du DOM = ordre visuel : « Enregistrer » d'abord, ou à droite\n quand la barre est collante. */}\n {collante ? annuler : enregistrer}\n {collante ? enregistrer : annuler}\n </div>\n )\n\n return (\n <div\n data-slot=\"save-bar\"\n data-collante={collante || undefined}\n data-repos={auRepos || undefined}\n className={cn(\n \"flex items-center gap-3\",\n !collante && \"flex-wrap\",\n // Au repos, la barre ne prend aucune place : seule reste la zone de\n // statut (une zone `status` ajoutée en même temps que son texte\n // n'est pas annoncée).\n auRepos && \"contents\",\n // Toujours sur sa carte : sans elle, les marges intérieures\n // décalaient les boutons par rapport aux cartes de la page. Carte\n // pleinement opaque : un fond translucide laissait deviner, flou, le\n // texte qu'elle recouvre.\n collante &&\n !auRepos &&\n \"justify-end rounded-xl border border-border bg-card px-4 py-3\",\n collante && (modifie || enCours) && \"sticky bottom-4 z-10 shadow-sm\",\n className\n )}\n >\n {collante ? statut : boutons}\n {collante ? boutons : statut}\n </div>\n )\n}\n"],"mappings":";;;;;AA2CA,SAAgBA,EAAQ,EACtB,aAAU,IACV,eAAY,IACZ,gBAAa,IACb,aAAU,IACV,cAAW,IACX,oBAAiB,IACjB,kBACA,cACA,gBACe;CACf,IAAMC,IACJC,KAAYC,KAAkB,CAACC,KAAW,CAACC,KAAW,CAACC,GACnDC,IACJ,kBAACC,GAAD;EACE,MAAMC,IAAgB,WAAW;EACjC,SAASA;EACA;EACT,gBAAe;EAIf,UAAUC;EACV,uBAAA;EACD,UAAA;CAEO,CAAA,GAEJC,IAAUC,IACd,kBAACJ,GAAD;EACE,SAAQ;EACR,SAASI;EACT,UAAUP;EACV,uBAAA;EACD,UAAA;CAEO,CAAA,IACN,MAGEQ,IACJ,kBAAC,KAAD;EACE,MAAK;EACL,WAAWC,EACT,iCAGAZ,KAAY,0BACZD,KAAW,SACb;EAIC,UAAAG,IACC,mCACEE,IACF,kBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACE,kBAACS,GAAD;IAAW,WAAU;IAAS,eAAA;GAAa,CAAA,GAAC,YAExC;EACJ,CAAA,IAAA;CACH,CAAA,GAKCC,IAAUf,IAAU,OACxB,kBAAC,OAAD;EACE,aAAU;EACV,WAAU;EAFZ,UAAA,CAMGC,IAAWS,IAAUJ,GACrBL,IAAWK,IAAcI,CACvB;;CAGP,OACE,kBAAC,OAAD;EACE,aAAU;EACV,iBAAeT,KAAY,KAAA;EAC3B,cAAYD,KAAW,KAAA;EACvB,WAAWa,EACT,2BACA,CAACZ,KAAY,aAIbD,KAAW,YAKXC,KACE,CAACD,KACD,iEACFC,MAAaE,KAAWC,MAAY,kCACpCY,CACF;EApBF,UAAA,CAsBGf,IAAWW,IAASG,GACpBd,IAAWc,IAAUH,CACnB;;AAET"}
1
+ {"version":3,"file":"save-bar.js","names":["SaveBar","refEnregistrer","useRef","auRepos","collante","masqueeAuRepos","modifie","enCours","enregistre","enregistrer","Button","onEnregistrer","desactive","annuler","onAnnuler","retablir","retablirDefauts","ResetButton","statut","cn","CheckIcon","boutons","className"],"sources":["../../../src/components/etic/save-bar.tsx"],"sourcesContent":["import { useRef } from \"react\"\nimport { cn } from \"cn\"\nimport { CheckIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport { ResetButton } from \"@etic-ui/components/etic/reset-button\"\n\nexport interface SaveBarProps {\n /** Enregistrement en cours : « Enregistrer » devient « Enregistrement… »,\n * occupé (`aria-busy`), ignore les clics, mais garde le focus ;\n * « Annuler » attend la fin. */\n enCours?: boolean\n /** Rien à enregistrer, ou une saisie à corriger d'abord. */\n desactive?: boolean\n /** Affiche « Enregistré » : la dernière mutation a réussi\n * (`mutation.isSuccess`). `modifie` l'emporte. */\n enregistre?: boolean\n /** Des modifications attendent : le statut dit « Modifications non\n * enregistrées », la raison pour laquelle « Enregistrer » est actif,\n * même après un enregistrement réussi. */\n modifie?: boolean\n /** Pied d'un formulaire plus haut que l'écran, sur une carte opaque,\n * boutons à droite, statut à gauche. Tant que `modifie` est vrai (ou\n * pendant l'envoi), la barre se colle en bas de l'écran ; sinon, elle\n * reste à sa place : elle ne flotte pas sur le contenu sans raison. Les\n * bords de la carte s'alignent sur ceux des cartes de la page. */\n collante?: boolean\n /** Avec `collante` : la barre n'apparaît que lorsqu'elle a quelque chose\n * à dire (modifications, envoi en cours, « Enregistré »). Au repos, il ne\n * reste que sa zone de statut, invisible et sans place, pour que le\n * premier message soit annoncé. */\n masqueeAuRepos?: boolean\n /** Sans gestionnaire, « Enregistrer » soumet le formulaire qui l'entoure. */\n onEnregistrer?: () => void\n /** Revenir à ce qui est enregistré : affiche « Annuler ». À ne passer que\n * s'il y a des modifications (`onAnnuler={modifie ? annuler : undefined}`).\n * Au clic, le focus passe à « Enregistrer » : « Annuler » disparaît.\n * Avec `masqueeAuRepos`, toute la barre disparaît : c'est à l'application\n * de rendre le focus (au formulaire). */\n onAnnuler?: () => void\n /**\n * Formulaire dont les champs ont une valeur par défaut : le bouton\n * général ↶ (`ResetButton`), devant « Annuler », qui remet tous les\n * champs à leur défaut sans rien enregistrer. `masque` quand aucun champ\n * ne s'en écarte (il garde sa place). Au clic, le focus passe à\n * « Enregistrer », l'étape suivante.\n */\n retablirDefauts?: {\n onRetablir: () => void\n masque?: boolean\n }\n className?: string\n}\n\n/**\n * Pied d'un formulaire de page (profil, paramètres) : « Enregistrer »,\n * « Annuler » au besoin, le retour général aux valeurs par défaut au\n * besoin, et le statut, annoncé (« Enregistré », « Modifications non\n * enregistrées »).\n */\nexport function SaveBar({\n enCours = false,\n desactive = false,\n enregistre = false,\n modifie = false,\n collante = false,\n masqueeAuRepos = false,\n onEnregistrer,\n onAnnuler,\n retablirDefauts,\n className,\n}: SaveBarProps) {\n const refEnregistrer = useRef<HTMLButtonElement>(null)\n const auRepos =\n collante && masqueeAuRepos && !modifie && !enCours && !enregistre\n const enregistrer = (\n <Button\n ref={refEnregistrer}\n type={onEnregistrer ? \"button\" : \"submit\"}\n onClick={onEnregistrer}\n enCours={enCours}\n libelleEnCours=\"Enregistrement…\"\n // Désactivé mais focalisable : le bouton qu'on vient d'activer ne\n // rend pas le focus à <body> quand l'enregistrement finit et qu'il ne\n // reste rien à enregistrer.\n disabled={desactive}\n focusableWhenDisabled\n >\n Enregistrer\n </Button>\n )\n const annuler = onAnnuler ? (\n <Button\n variant=\"outline\"\n onClick={() => {\n // « Annuler » disparaît avec les modifications : sans cela, le\n // focus tomberait sur la page.\n refEnregistrer.current?.focus()\n onAnnuler()\n }}\n disabled={enCours}\n focusableWhenDisabled\n >\n Annuler\n </Button>\n ) : null\n const retablir = retablirDefauts ? (\n <ResetButton\n masque={retablirDefauts.masque}\n disabled={enCours}\n cible={() => refEnregistrer.current}\n onRetablir={retablirDefauts.onRetablir}\n />\n ) : null\n // Toujours présent : une zone `status` ajoutée en même temps que son texte\n // n'est pas annoncée.\n const statut = (\n <p\n role=\"status\"\n className={cn(\n \"text-sm text-muted-foreground\",\n // Le statut se replie sur deux lignes plutôt que de séparer les\n // boutons de la barre.\n collante && \"me-auto min-w-0 flex-1\",\n auRepos && \"sr-only\"\n )}\n >\n {/* Une modification faite après l'enregistrement l'emporte :\n « Enregistré » ne vaut que pour ce qui est à l'écran. */}\n {modifie ? (\n \"Modifications non enregistrées\"\n ) : enregistre ? (\n <span className=\"inline-flex items-center gap-1.5 font-medium text-success\">\n <CheckIcon className=\"size-4\" aria-hidden />\n Enregistré\n </span>\n ) : null}\n </p>\n )\n\n // Les deux boutons ne se séparent jamais : au téléphone, c'est le statut\n // qui passe à la ligne (barre simple) ou se replie (barre collante).\n const boutons = auRepos ? null : (\n <div\n data-slot=\"save-bar-actions\"\n className=\"flex shrink-0 items-center gap-3\"\n >\n {/* Ordre du DOM = ordre visuel : « Enregistrer » d'abord, ou à droite\n quand la barre est collante ; le retour aux défauts, l'action la\n plus rare, à l'autre bout. */}\n {collante ? retablir : enregistrer}\n {annuler}\n {collante ? enregistrer : retablir}\n </div>\n )\n\n return (\n <div\n data-slot=\"save-bar\"\n data-collante={collante || undefined}\n data-repos={auRepos || undefined}\n className={cn(\n \"flex items-center gap-3\",\n !collante && \"flex-wrap\",\n // Au repos, la barre ne prend aucune place : seule reste la zone de\n // statut (une zone `status` ajoutée en même temps que son texte\n // n'est pas annoncée).\n auRepos && \"contents\",\n // Toujours sur sa carte : sans elle, les marges intérieures\n // décalaient les boutons par rapport aux cartes de la page. Carte\n // pleinement opaque : un fond translucide laissait deviner, flou, le\n // texte qu'elle recouvre.\n collante &&\n !auRepos &&\n \"justify-end rounded-xl border border-border bg-card px-4 py-3\",\n collante && (modifie || enCours) && \"sticky bottom-4 z-10 shadow-sm\",\n className\n )}\n >\n {collante ? statut : boutons}\n {collante ? boutons : statut}\n </div>\n )\n}\n"],"mappings":";;;;;;;AA4DA,SAAgBA,EAAQ,EACtB,aAAU,IACV,eAAY,IACZ,gBAAa,IACb,aAAU,IACV,cAAW,IACX,oBAAiB,IACjB,kBACA,cACA,oBACA,gBACe;CACf,IAAMC,IAAiBC,EAA0B,IAAI,GAC/CC,IACJC,KAAYC,KAAkB,CAACC,KAAW,CAACC,KAAW,CAACC,GACnDC,IACJ,kBAACC,GAAD;EACE,KAAKT;EACL,MAAMU,IAAgB,WAAW;EACjC,SAASA;EACA;EACT,gBAAe;EAIf,UAAUC;EACV,uBAAA;EACD,UAAA;CAEO,CAAA,GAEJC,IAAUC,IACd,kBAACJ,GAAD;EACE,SAAQ;EACR,eAAe;GAIb,AADAT,EAAe,SAAS,MAAM,GAC9Ba,EAAU;EACZ;EACA,UAAUP;EACV,uBAAA;EACD,UAAA;CAEO,CAAA,IACN,MACEQ,IAAWC,IACf,kBAACC,GAAD;EACE,QAAQD,EAAgB;EACxB,UAAUT;EACV,aAAaN,EAAe;EAC5B,YAAYe,EAAgB;CAC7B,CAAA,IACC,MAGEE,IACJ,kBAAC,KAAD;EACE,MAAK;EACL,WAAWC,EACT,iCAGAf,KAAY,0BACZD,KAAW,SACb;EAIC,UAAAG,IACC,mCACEE,IACF,kBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACE,kBAACY,GAAD;IAAW,WAAU;IAAS,eAAA;GAAa,CAAA,GAAC,YAExC;EACJ,CAAA,IAAA;CACH,CAAA,GAKCC,IAAUlB,IAAU,OACxB,kBAAC,OAAD;EACE,aAAU;EACV,WAAU;EAFZ,UAAA;GAOGC,IAAWW,IAAWN;GACtBI;GACAT,IAAWK,IAAcM;EACvB;;CAGP,OACE,kBAAC,OAAD;EACE,aAAU;EACV,iBAAeX,KAAY,KAAA;EAC3B,cAAYD,KAAW,KAAA;EACvB,WAAWgB,EACT,2BACA,CAACf,KAAY,aAIbD,KAAW,YAKXC,KACE,CAACD,KACD,iEACFC,MAAaE,KAAWC,MAAY,kCACpCe,CACF;EApBF,UAAA,CAsBGlB,IAAWc,IAASG,GACpBjB,IAAWiB,IAAUH,CACnB;;AAET"}
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+ import { LucideIcon } from 'lucide-react';
3
+ import { StatusTon } from '../../lib/ton';
4
+ export interface VerdictPanelProps {
5
+ /** L'état d'ensemble : « success » tout va bien, « warning » à
6
+ * surveiller, « destructive » en panne. */
7
+ ton: StatusTon;
8
+ /** La phrase qui dit l'état : « Tout fonctionne », « 2 points
9
+ * d'attention ». */
10
+ titre: ReactNode;
11
+ /** Son détail, sous la phrase, en petit. */
12
+ detail?: ReactNode;
13
+ /** L'action qui y répond (un bouton), à droite ; passe sous le texte
14
+ * quand la place manque. */
15
+ action?: ReactNode;
16
+ /** Autre signe que celui du ton (icône lucide). */
17
+ icone?: LucideIcon;
18
+ className?: string;
19
+ }
20
+ /**
21
+ * Le verdict d'une page de supervision, lu d'un coup d'œil avant le
22
+ * détail : un signe coloré en pastille, une phrase, son détail et au besoin
23
+ * l'action qui y répond, dans une carte au liseré du ton.
24
+ */
25
+ export declare function VerdictPanel({ ton, titre, detail, action, icone, className, }: VerdictPanelProps): import("react").JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { Card as e } from "../ui/card.js";
2
+ import { TONS as t } from "../../lib/ton.js";
3
+ import { cn as n } from "cn";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import { CheckIcon as a, InfoIcon as o, MinusIcon as s, TriangleAlertIcon as c, XIcon as l } from "lucide-react";
6
+ // src/components/etic/verdict-panel.tsx
7
+ var u = {
8
+ neutral: s,
9
+ info: o,
10
+ success: a,
11
+ warning: c,
12
+ destructive: l
13
+ };
14
+ function d({ ton: a, titre: o, detail: s, action: c, icone: l, className: d }) {
15
+ let f = l ?? u[a];
16
+ return /* @__PURE__ */ i(e, {
17
+ "data-slot": "verdict-panel",
18
+ "data-ton": a,
19
+ className: n("flex-row flex-wrap items-center gap-3.5 px-4 py-3.5", t[a].cadre, d),
20
+ children: [
21
+ /* @__PURE__ */ r("span", {
22
+ "aria-hidden": !0,
23
+ className: n("grid size-9 shrink-0 place-items-center rounded-full", t[a].medaillon),
24
+ children: /* @__PURE__ */ r(f, { className: "size-4.5" })
25
+ }),
26
+ /* @__PURE__ */ i("div", {
27
+ className: "min-w-48 flex-1",
28
+ children: [/* @__PURE__ */ r("p", {
29
+ className: "text-base font-semibold",
30
+ children: o
31
+ }), s ? /* @__PURE__ */ r("div", {
32
+ className: "mt-0.5 text-xs text-muted-foreground",
33
+ children: s
34
+ }) : null]
35
+ }),
36
+ c
37
+ ]
38
+ });
39
+ }
40
+ export { d as VerdictPanel };
41
+
42
+ //# sourceMappingURL=verdict-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict-panel.js","names":["SIGNES","MinusIcon","InfoIcon","CheckIcon","TriangleAlertIcon","XIcon","VerdictPanel","Signe","icone","ton","Card","cn","TONS","className","titre","detail","action"],"sources":["../../../src/components/etic/verdict-panel.tsx"],"sourcesContent":["import type { ReactNode } from \"react\"\nimport { cn } from \"cn\"\nimport {\n CheckIcon,\n InfoIcon,\n MinusIcon,\n TriangleAlertIcon,\n XIcon,\n type LucideIcon,\n} from \"lucide-react\"\n\nimport { Card } from \"@etic-ui/components/ui/card\"\nimport { TONS, type StatusTon } from \"@etic-ui/lib/ton\"\n\n/** Le signe de chaque ton : la couleur porte l'état, le signe le redit pour\n * qui ne la voit pas. */\nconst SIGNES: Record<StatusTon, LucideIcon> = {\n neutral: MinusIcon,\n info: InfoIcon,\n success: CheckIcon,\n warning: TriangleAlertIcon,\n destructive: XIcon,\n}\n\nexport interface VerdictPanelProps {\n /** L'état d'ensemble : « success » tout va bien, « warning » à\n * surveiller, « destructive » en panne. */\n ton: StatusTon\n /** La phrase qui dit l'état : « Tout fonctionne », « 2 points\n * d'attention ». */\n titre: ReactNode\n /** Son détail, sous la phrase, en petit. */\n detail?: ReactNode\n /** L'action qui y répond (un bouton), à droite ; passe sous le texte\n * quand la place manque. */\n action?: ReactNode\n /** Autre signe que celui du ton (icône lucide). */\n icone?: LucideIcon\n className?: string\n}\n\n/**\n * Le verdict d'une page de supervision, lu d'un coup d'œil avant le\n * détail : un signe coloré en pastille, une phrase, son détail et au besoin\n * l'action qui y répond, dans une carte au liseré du ton.\n */\nexport function VerdictPanel({\n ton,\n titre,\n detail,\n action,\n icone,\n className,\n}: VerdictPanelProps) {\n const Signe = icone ?? SIGNES[ton]\n return (\n <Card\n data-slot=\"verdict-panel\"\n data-ton={ton}\n className={cn(\n \"flex-row flex-wrap items-center gap-3.5 px-4 py-3.5\",\n TONS[ton].cadre,\n className\n )}\n >\n <span\n aria-hidden\n className={cn(\n \"grid size-9 shrink-0 place-items-center rounded-full\",\n TONS[ton].medaillon\n )}\n >\n <Signe className=\"size-4.5\" />\n </span>\n <div className=\"min-w-48 flex-1\">\n <p className=\"text-base font-semibold\">{titre}</p>\n {detail ? (\n <div className=\"mt-0.5 text-xs text-muted-foreground\">{detail}</div>\n ) : null}\n </div>\n {action}\n </Card>\n )\n}\n"],"mappings":";;;;;;AAgBA,IAAMA,IAAwC;CAC5C,SAASC;CACT,MAAMC;CACN,SAASC;CACT,SAASC;CACT,aAAaC;AACf;AAwBA,SAAgBC,EAAa,EAC3B,QACA,UACA,WACA,WACA,UACA,gBACoB;CACpB,IAAMC,IAAQC,KAASR,EAAOS;CAC9B,OACE,kBAACC,GAAD;EACE,aAAU;EACV,YAAUD;EACV,WAAWE,EACT,uDACAC,EAAKH,EAAI,CAAC,OACVI,CACF;EAPF,UAAA;GASE,kBAAC,QAAD;IACE,eAAA;IACA,WAAWF,EACT,wDACAC,EAAKH,EAAI,CAAC,SACZ;IAEA,UAAA,kBAACF,GAAD,EAAO,WAAU,WAAY,CAAA;GACzB,CAAA;GACN,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAA2B,UAAAO;IAAS,CAAA,GAChDC,IACC,kBAAC,OAAD;KAAK,WAAU;KAAwC,UAAAA;IAAY,CAAA,IACjE,IACD;;GACJC;EACG;;AAEV"}
@@ -0,0 +1,44 @@
1
+ import { TooltipValueType } from 'recharts';
2
+ import * as React from "react";
3
+ import * as RechartsPrimitive from "recharts";
4
+ declare const THEMES: {
5
+ readonly light: "";
6
+ readonly dark: ".dark";
7
+ };
8
+ type TooltipNameType = number | string;
9
+ export type ChartConfig = Record<string, {
10
+ label?: React.ReactNode;
11
+ icon?: React.ComponentType;
12
+ } & ({
13
+ color?: string;
14
+ theme?: never;
15
+ } | {
16
+ color?: never;
17
+ theme: Record<keyof typeof THEMES, string>;
18
+ })>;
19
+ declare function ChartContainer({ id, className, children, config, initialDimension, ...props }: React.ComponentProps<"div"> & {
20
+ config: ChartConfig;
21
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
22
+ initialDimension?: {
23
+ width: number;
24
+ height: number;
25
+ };
26
+ }): React.JSX.Element;
27
+ declare const ChartStyle: ({ id, config }: {
28
+ id: string;
29
+ config: ChartConfig;
30
+ }) => React.JSX.Element | null;
31
+ declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
32
+ declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> & React.ComponentProps<"div"> & {
33
+ hideLabel?: boolean;
34
+ hideIndicator?: boolean;
35
+ indicator?: "line" | "dot" | "dashed";
36
+ nameKey?: string;
37
+ labelKey?: string;
38
+ } & Omit<RechartsPrimitive.DefaultTooltipContentProps<TooltipValueType, TooltipNameType>, "accessibilityLayer">): React.JSX.Element | null;
39
+ declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
40
+ declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: React.ComponentProps<"div"> & {
41
+ hideIcon?: boolean;
42
+ nameKey?: string;
43
+ } & RechartsPrimitive.DefaultLegendContentProps): React.JSX.Element | null;
44
+ export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
@@ -0,0 +1,131 @@
1
+ import { cn as e } from "cn";
2
+ import * as t from "react";
3
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ import * as a from "recharts";
5
+ // src/components/ui/chart.tsx
6
+ var o = {
7
+ light: "",
8
+ dark: ".dark"
9
+ }, s = {
10
+ width: 320,
11
+ height: 200
12
+ }, c = t.createContext(null);
13
+ function l() {
14
+ let e = t.useContext(c);
15
+ if (!e) throw Error("useChart must be used within a <ChartContainer />");
16
+ return e;
17
+ }
18
+ function u({ id: n, className: o, children: l, config: u, initialDimension: f = s, ...p }) {
19
+ let m = t.useId(), h = `chart-${n ?? m.replace(/:/g, "")}`;
20
+ return /* @__PURE__ */ r(c.Provider, {
21
+ value: { config: u },
22
+ children: /* @__PURE__ */ i("div", {
23
+ "data-slot": "chart",
24
+ "data-chart": h,
25
+ className: e("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", o),
26
+ ...p,
27
+ children: [/* @__PURE__ */ r(d, {
28
+ id: h,
29
+ config: u
30
+ }), /* @__PURE__ */ r(a.ResponsiveContainer, {
31
+ initialDimension: f,
32
+ children: l
33
+ })]
34
+ })
35
+ });
36
+ }
37
+ var d = ({ id: e, config: t }) => {
38
+ let n = Object.entries(t).filter(([, e]) => e.theme ?? e.color);
39
+ return n.length ? /* @__PURE__ */ r("style", { dangerouslySetInnerHTML: { __html: Object.entries(o).map(([t, r]) => `
40
+ ${r} [data-chart=${e}] {
41
+ ${n.map(([e, n]) => {
42
+ let r = n.theme?.[t] ?? n.color;
43
+ return r ? ` --color-${e}: ${r};` : null;
44
+ }).join("\n")}
45
+ }
46
+ `).join("\n") } }) : null;
47
+ }, f = a.Tooltip;
48
+ function p({ active: a, payload: o, className: s, indicator: c = "dot", hideLabel: u = !1, hideIndicator: d = !1, label: f, labelFormatter: p, labelClassName: m, formatter: h, color: _, nameKey: v, labelKey: y }) {
49
+ let { config: b } = l(), x = t.useMemo(() => {
50
+ if (u || !o?.length) return null;
51
+ let [t] = o, n = `${y ?? t?.dataKey ?? t?.name ?? "value"}`, i = g(b, t, n), a = !y && typeof f == "string" ? b[f]?.label ?? f : i?.label;
52
+ return p ? /* @__PURE__ */ r("div", {
53
+ className: e("font-medium", m),
54
+ children: p(a, o)
55
+ }) : a ? /* @__PURE__ */ r("div", {
56
+ className: e("font-medium", m),
57
+ children: a
58
+ }) : null;
59
+ }, [
60
+ f,
61
+ p,
62
+ o,
63
+ u,
64
+ m,
65
+ b,
66
+ y
67
+ ]);
68
+ if (!a || !o?.length) return null;
69
+ let S = o.length === 1 && c !== "dot";
70
+ return /* @__PURE__ */ i("div", {
71
+ className: e("grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl", s),
72
+ children: [S ? null : x, /* @__PURE__ */ r("div", {
73
+ className: "grid gap-1.5",
74
+ children: o.filter((e) => e.type !== "none").map((t, a) => {
75
+ let o = `${v ?? t.name ?? t.dataKey ?? "value"}`, s = g(b, t, o), l = _ ?? t.payload?.fill ?? t.color;
76
+ return /* @__PURE__ */ r("div", {
77
+ className: e("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", c === "dot" && "items-center"),
78
+ children: h && t?.value !== void 0 && t.name ? h(t.value, t.name, t, a, t.payload) : /* @__PURE__ */ i(n, { children: [s?.icon ? /* @__PURE__ */ r(s.icon, {}) : !d && /* @__PURE__ */ r("div", {
79
+ className: e("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", {
80
+ "h-2.5 w-2.5": c === "dot",
81
+ "w-1": c === "line",
82
+ "w-0 border-[1.5px] border-dashed bg-transparent": c === "dashed",
83
+ "my-0.5": S && c === "dashed"
84
+ }),
85
+ style: {
86
+ "--color-bg": l,
87
+ "--color-border": l
88
+ }
89
+ }), /* @__PURE__ */ i("div", {
90
+ className: e("flex flex-1 justify-between leading-none", S ? "items-end" : "items-center"),
91
+ children: [/* @__PURE__ */ i("div", {
92
+ className: "grid gap-1.5",
93
+ children: [S ? x : null, /* @__PURE__ */ r("span", {
94
+ className: "text-muted-foreground",
95
+ children: s?.label ?? t.name
96
+ })]
97
+ }), t.value != null && /* @__PURE__ */ r("span", {
98
+ className: "font-mono font-medium text-foreground tabular-nums",
99
+ children: typeof t.value == "number" ? t.value.toLocaleString() : String(t.value)
100
+ })]
101
+ })] })
102
+ }, a);
103
+ })
104
+ })]
105
+ });
106
+ }
107
+ var m = a.Legend;
108
+ function h({ className: t, hideIcon: n = !1, payload: a, verticalAlign: o = "bottom", nameKey: s }) {
109
+ let { config: c } = l();
110
+ return a?.length ? /* @__PURE__ */ r("div", {
111
+ className: e("flex items-center justify-center gap-4", o === "top" ? "pb-3" : "pt-3", t),
112
+ children: a.filter((e) => e.type !== "none").map((t, a) => {
113
+ let o = `${s ?? t.dataKey ?? "value"}`, l = g(c, t, o);
114
+ return /* @__PURE__ */ i("div", {
115
+ className: e("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),
116
+ children: [l?.icon && !n ? /* @__PURE__ */ r(l.icon, {}) : /* @__PURE__ */ r("div", {
117
+ className: "h-2 w-2 shrink-0 rounded-[2px]",
118
+ style: { backgroundColor: t.color }
119
+ }), l?.label]
120
+ }, a);
121
+ })
122
+ }) : null;
123
+ }
124
+ function g(e, t, n) {
125
+ if (typeof t != "object" || !t) return;
126
+ let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
127
+ return n in t && typeof t[n] == "string" ? i = t[n] : r && n in r && typeof r[n] == "string" && (i = r[n]), i in e ? e[i] : e[n];
128
+ }
129
+ export { u as ChartContainer, m as ChartLegend, h as ChartLegendContent, d as ChartStyle, f as ChartTooltip, p as ChartTooltipContent };
130
+
131
+ //# sourceMappingURL=chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.js","names":["_Fragment","React","Fragment$1","RechartsPrimitive","THEMES","INITIAL_DIMENSION","ChartContext","useChart","context","ChartContainer","props","uniqueId","chartId","id","cn","className","ChartStyle","colorConfig","config","theme","prefix","key","itemConfig","color","ChartTooltip","ChartTooltipContent","tooltipLabel","hideLabel","payload","item","labelKey","getPayloadConfigFromPayload","value","label","labelFormatter","labelClassName","active","nestLabel","indicator","nameKey","indicatorColor","formatter","index","hideIndicator","ChartLegend","ChartLegendContent","verticalAlign","hideIcon","payloadPayload","configLabelKey"],"sources":["../../../src/components/ui/chart.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { cn } from \"cn\"\nimport * as RechartsPrimitive from \"recharts\"\nimport type { TooltipValueType } from \"recharts\"\n\n// Format: { THEME_NAME: CSS_SELECTOR }\nconst THEMES = { light: \"\", dark: \".dark\" } as const\n\nconst INITIAL_DIMENSION = { width: 320, height: 200 } as const\ntype TooltipNameType = number | string\n\nexport type ChartConfig = Record<\n string,\n {\n label?: React.ReactNode\n icon?: React.ComponentType\n } & (\n | { color?: string; theme?: never }\n | { color?: never; theme: Record<keyof typeof THEMES, string> }\n )\n>\n\ntype ChartContextProps = {\n config: ChartConfig\n}\n\nconst ChartContext = React.createContext<ChartContextProps | null>(null)\n\nfunction useChart() {\n const context = React.useContext(ChartContext)\n\n if (!context) {\n throw new Error(\"useChart must be used within a <ChartContainer />\")\n }\n\n return context\n}\n\nfunction ChartContainer({\n id,\n className,\n children,\n config,\n initialDimension = INITIAL_DIMENSION,\n ...props\n}: React.ComponentProps<\"div\"> & {\n config: ChartConfig\n children: React.ComponentProps<\n typeof RechartsPrimitive.ResponsiveContainer\n >[\"children\"]\n initialDimension?: {\n width: number\n height: number\n }\n}) {\n const uniqueId = React.useId()\n const chartId = `chart-${id ?? uniqueId.replace(/:/g, \"\")}`\n\n return (\n <ChartContext.Provider value={{ config }}>\n <div\n data-slot=\"chart\"\n data-chart={chartId}\n className={cn(\n \"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden\",\n className\n )}\n {...props}\n >\n <ChartStyle id={chartId} config={config} />\n <RechartsPrimitive.ResponsiveContainer\n initialDimension={initialDimension}\n >\n {children}\n </RechartsPrimitive.ResponsiveContainer>\n </div>\n </ChartContext.Provider>\n )\n}\n\nconst ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {\n const colorConfig = Object.entries(config).filter(\n ([, config]) => config.theme ?? config.color\n )\n\n if (!colorConfig.length) {\n return null\n }\n\n return (\n <style\n dangerouslySetInnerHTML={{\n __html: Object.entries(THEMES)\n .map(\n ([theme, prefix]) => `\n${prefix} [data-chart=${id}] {\n${colorConfig\n .map(([key, itemConfig]) => {\n const color =\n itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??\n itemConfig.color\n return color ? ` --color-${key}: ${color};` : null\n })\n .join(\"\\n\")}\n}\n`\n )\n .join(\"\\n\"),\n }}\n />\n )\n}\n\nconst ChartTooltip = RechartsPrimitive.Tooltip\n\nfunction ChartTooltipContent({\n active,\n payload,\n className,\n indicator = \"dot\",\n hideLabel = false,\n hideIndicator = false,\n label,\n labelFormatter,\n labelClassName,\n formatter,\n color,\n nameKey,\n labelKey,\n}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &\n React.ComponentProps<\"div\"> & {\n hideLabel?: boolean\n hideIndicator?: boolean\n indicator?: \"line\" | \"dot\" | \"dashed\"\n nameKey?: string\n labelKey?: string\n } & Omit<\n RechartsPrimitive.DefaultTooltipContentProps<\n TooltipValueType,\n TooltipNameType\n >,\n \"accessibilityLayer\"\n >) {\n const { config } = useChart()\n\n const tooltipLabel = React.useMemo(() => {\n if (hideLabel || !payload?.length) {\n return null\n }\n\n const [item] = payload\n const key = `${labelKey ?? item?.dataKey ?? item?.name ?? \"value\"}`\n const itemConfig = getPayloadConfigFromPayload(config, item, key)\n const value =\n !labelKey && typeof label === \"string\"\n ? (config[label]?.label ?? label)\n : itemConfig?.label\n\n if (labelFormatter) {\n return (\n <div className={cn(\"font-medium\", labelClassName)}>\n {labelFormatter(value, payload)}\n </div>\n )\n }\n\n if (!value) {\n return null\n }\n\n return <div className={cn(\"font-medium\", labelClassName)}>{value}</div>\n }, [\n label,\n labelFormatter,\n payload,\n hideLabel,\n labelClassName,\n config,\n labelKey,\n ])\n\n if (!active || !payload?.length) {\n return null\n }\n\n const nestLabel = payload.length === 1 && indicator !== \"dot\"\n\n return (\n <div\n className={cn(\n \"grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl\",\n className\n )}\n >\n {!nestLabel ? tooltipLabel : null}\n <div className=\"grid gap-1.5\">\n {payload\n .filter((item) => item.type !== \"none\")\n .map((item, index) => {\n const key = `${nameKey ?? item.name ?? item.dataKey ?? \"value\"}`\n const itemConfig = getPayloadConfigFromPayload(config, item, key)\n const indicatorColor = color ?? item.payload?.fill ?? item.color\n\n return (\n <div\n key={index}\n className={cn(\n \"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground\",\n indicator === \"dot\" && \"items-center\"\n )}\n >\n {formatter && item?.value !== undefined && item.name ? (\n formatter(item.value, item.name, item, index, item.payload)\n ) : (\n <>\n {itemConfig?.icon ? (\n <itemConfig.icon />\n ) : (\n !hideIndicator && (\n <div\n className={cn(\n \"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)\",\n {\n \"h-2.5 w-2.5\": indicator === \"dot\",\n \"w-1\": indicator === \"line\",\n \"w-0 border-[1.5px] border-dashed bg-transparent\":\n indicator === \"dashed\",\n \"my-0.5\": nestLabel && indicator === \"dashed\",\n }\n )}\n style={\n {\n \"--color-bg\": indicatorColor,\n \"--color-border\": indicatorColor,\n } as React.CSSProperties\n }\n />\n )\n )}\n <div\n className={cn(\n \"flex flex-1 justify-between leading-none\",\n nestLabel ? \"items-end\" : \"items-center\"\n )}\n >\n <div className=\"grid gap-1.5\">\n {nestLabel ? tooltipLabel : null}\n <span className=\"text-muted-foreground\">\n {itemConfig?.label ?? item.name}\n </span>\n </div>\n {item.value != null && (\n <span className=\"font-mono font-medium text-foreground tabular-nums\">\n {typeof item.value === \"number\"\n ? item.value.toLocaleString()\n : String(item.value)}\n </span>\n )}\n </div>\n </>\n )}\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n\nconst ChartLegend = RechartsPrimitive.Legend\n\nfunction ChartLegendContent({\n className,\n hideIcon = false,\n payload,\n verticalAlign = \"bottom\",\n nameKey,\n}: React.ComponentProps<\"div\"> & {\n hideIcon?: boolean\n nameKey?: string\n} & RechartsPrimitive.DefaultLegendContentProps) {\n const { config } = useChart()\n\n if (!payload?.length) {\n return null\n }\n\n return (\n <div\n className={cn(\n \"flex items-center justify-center gap-4\",\n verticalAlign === \"top\" ? \"pb-3\" : \"pt-3\",\n className\n )}\n >\n {payload\n .filter((item) => item.type !== \"none\")\n .map((item, index) => {\n const key = `${nameKey ?? item.dataKey ?? \"value\"}`\n const itemConfig = getPayloadConfigFromPayload(config, item, key)\n\n return (\n <div\n key={index}\n className={cn(\n \"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground\"\n )}\n >\n {itemConfig?.icon && !hideIcon ? (\n <itemConfig.icon />\n ) : (\n <div\n className=\"h-2 w-2 shrink-0 rounded-[2px]\"\n style={{\n backgroundColor: item.color,\n }}\n />\n )}\n {itemConfig?.label}\n </div>\n )\n })}\n </div>\n )\n}\n\nfunction getPayloadConfigFromPayload(\n config: ChartConfig,\n payload: unknown,\n key: string\n) {\n if (typeof payload !== \"object\" || payload === null) {\n return undefined\n }\n\n const payloadPayload =\n \"payload\" in payload &&\n typeof payload.payload === \"object\" &&\n payload.payload !== null\n ? payload.payload\n : undefined\n\n let configLabelKey: string = key\n\n if (\n key in payload &&\n typeof payload[key as keyof typeof payload] === \"string\"\n ) {\n configLabelKey = payload[key as keyof typeof payload] as string\n } else if (\n payloadPayload &&\n key in payloadPayload &&\n typeof payloadPayload[key as keyof typeof payloadPayload] === \"string\"\n ) {\n configLabelKey = payloadPayload[\n key as keyof typeof payloadPayload\n ] as string\n }\n\n return configLabelKey in config ? config[configLabelKey] : config[key]\n}\n\nexport {\n ChartContainer,\n ChartTooltip,\n ChartTooltipContent,\n ChartLegend,\n ChartLegendContent,\n ChartStyle,\n}\n"],"mappings":"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"}