@etic-insa/ui 0.4.2 → 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.
- package/README.md +182 -51
- package/dist/charts/index.d.ts +1 -0
- package/dist/charts/index.js +1 -0
- package/dist/components/etic/centered-screen.d.ts +19 -1
- package/dist/components/etic/centered-screen.js +35 -3
- package/dist/components/etic/centered-screen.js.map +1 -1
- package/dist/components/etic/data-table-toolbar.d.ts +6 -4
- package/dist/components/etic/data-table-toolbar.js +2 -2
- package/dist/components/etic/data-table-toolbar.js.map +1 -1
- package/dist/components/etic/data-table.d.ts +3 -1
- package/dist/components/etic/data-table.js.map +1 -1
- package/dist/components/etic/dropdown-menu-action.d.ts +30 -0
- package/dist/components/etic/dropdown-menu-action.js +30 -0
- package/dist/components/etic/dropdown-menu-action.js.map +1 -0
- package/dist/components/etic/error-banner.d.ts +44 -10
- package/dist/components/etic/error-banner.js +47 -28
- package/dist/components/etic/error-banner.js.map +1 -1
- package/dist/components/etic/form-dialog.d.ts +8 -1
- package/dist/components/etic/form-dialog.js +92 -60
- package/dist/components/etic/form-dialog.js.map +1 -1
- package/dist/components/etic/form-field.d.ts +10 -1
- package/dist/components/etic/form-field.js +32 -28
- package/dist/components/etic/form-field.js.map +1 -1
- package/dist/components/etic/page-header.d.ts +2 -1
- package/dist/components/etic/page-header.js +40 -52
- package/dist/components/etic/page-header.js.map +1 -1
- package/dist/components/etic/progress-ring.d.ts +23 -0
- package/dist/components/etic/progress-ring.js +46 -0
- package/dist/components/etic/progress-ring.js.map +1 -0
- package/dist/components/etic/reset-button.d.ts +37 -0
- package/dist/components/etic/reset-button.js +41 -0
- package/dist/components/etic/reset-button.js.map +1 -0
- package/dist/components/etic/save-bar.d.ts +29 -8
- package/dist/components/etic/save-bar.js +40 -25
- package/dist/components/etic/save-bar.js.map +1 -1
- package/dist/components/etic/verdict-panel.d.ts +25 -0
- package/dist/components/etic/verdict-panel.js +42 -0
- package/dist/components/etic/verdict-panel.js.map +1 -0
- package/dist/components/ui/chart.d.ts +44 -0
- package/dist/components/ui/chart.js +131 -0
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/components/ui/sheet.js +41 -36
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +49 -45
- package/dist/lib/ton.d.ts +7 -0
- package/dist/lib/ton.js +15 -0
- package/dist/lib/ton.js.map +1 -1
- package/dist/testing/index.d.ts +19 -0
- package/dist/testing/index.js +40 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +28 -3
- package/vite-plugin.d.ts +31 -0
- package/vite-plugin.js +162 -0
|
@@ -12,21 +12,42 @@ export interface SaveBarProps {
|
|
|
12
12
|
* enregistrées », la raison pour laquelle « Enregistrer » est actif,
|
|
13
13
|
* même après un enregistrement réussi. */
|
|
14
14
|
modifie?: boolean;
|
|
15
|
-
/** Pied d'un formulaire plus haut que l'écran,
|
|
16
|
-
* gauche. Tant que `modifie` est vrai
|
|
17
|
-
* l'
|
|
18
|
-
*
|
|
15
|
+
/** Pied d'un formulaire plus haut que l'écran, sur une carte opaque,
|
|
16
|
+
* boutons à droite, statut à gauche. Tant que `modifie` est vrai (ou
|
|
17
|
+
* pendant l'envoi), la barre se colle en bas de l'écran ; sinon, elle
|
|
18
|
+
* reste à sa place : elle ne flotte pas sur le contenu sans raison. Les
|
|
19
|
+
* bords de la carte s'alignent sur ceux des cartes de la page. */
|
|
19
20
|
collante?: boolean;
|
|
21
|
+
/** Avec `collante` : la barre n'apparaît que lorsqu'elle a quelque chose
|
|
22
|
+
* à dire (modifications, envoi en cours, « Enregistré »). Au repos, il ne
|
|
23
|
+
* reste que sa zone de statut, invisible et sans place, pour que le
|
|
24
|
+
* premier message soit annoncé. */
|
|
25
|
+
masqueeAuRepos?: boolean;
|
|
20
26
|
/** Sans gestionnaire, « Enregistrer » soumet le formulaire qui l'entoure. */
|
|
21
27
|
onEnregistrer?: () => void;
|
|
22
28
|
/** Revenir à ce qui est enregistré : affiche « Annuler ». À ne passer que
|
|
23
|
-
* 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). */
|
|
24
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
|
+
};
|
|
25
45
|
className?: string;
|
|
26
46
|
}
|
|
27
47
|
/**
|
|
28
48
|
* Pied d'un formulaire de page (profil, paramètres) : « Enregistrer »,
|
|
29
|
-
* « Annuler » au besoin,
|
|
30
|
-
* « Modifications non
|
|
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 »).
|
|
31
52
|
*/
|
|
32
|
-
export declare function SaveBar({ enCours, desactive, enregistre, modifie, collante, 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,45 +1,60 @@
|
|
|
1
1
|
import { Button as e } from "../ui/button.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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:
|
|
15
|
+
disabled: c,
|
|
13
16
|
focusableWhenDisabled: !0,
|
|
14
17
|
children: "Enregistrer"
|
|
15
|
-
}),
|
|
18
|
+
}), b = m ? /* @__PURE__ */ i(e, {
|
|
16
19
|
variant: "outline",
|
|
17
|
-
onClick:
|
|
18
|
-
|
|
20
|
+
onClick: () => {
|
|
21
|
+
_.current?.focus(), m();
|
|
22
|
+
},
|
|
23
|
+
disabled: s,
|
|
19
24
|
focusableWhenDisabled: !0,
|
|
20
25
|
children: "Annuler"
|
|
21
|
-
}) : null,
|
|
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:
|
|
24
|
-
children:
|
|
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__ */
|
|
36
|
+
children: [/* @__PURE__ */ i(o, {
|
|
27
37
|
className: "size-4",
|
|
28
38
|
"aria-hidden": !0
|
|
29
39
|
}), "Enregistré"]
|
|
30
40
|
}) : null
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"data-collante": l || void 0,
|
|
35
|
-
className: t("flex flex-wrap items-center gap-3", l && "justify-end rounded-xl border border-transparent px-4 py-3", l && (c || a) && "sticky bottom-4 z-10 border-border bg-card shadow-sm", f),
|
|
41
|
+
}), C = v ? null : /* @__PURE__ */ a("div", {
|
|
42
|
+
"data-slot": "save-bar-actions",
|
|
43
|
+
className: "flex shrink-0 items-center gap-3",
|
|
36
44
|
children: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
d ? x : y,
|
|
46
|
+
b,
|
|
47
|
+
d ? y : x
|
|
40
48
|
]
|
|
41
49
|
});
|
|
50
|
+
return /* @__PURE__ */ a("div", {
|
|
51
|
+
"data-slot": "save-bar",
|
|
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]
|
|
56
|
+
});
|
|
42
57
|
}
|
|
43
|
-
export {
|
|
58
|
+
export { s as SaveBar };
|
|
44
59
|
|
|
45
60
|
//# sourceMappingURL=save-bar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-bar.js","names":["SaveBar","enregistrer","Button","onEnregistrer","desactive","annuler","onAnnuler","
|
|
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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BGlB,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":";;;;;AAMA,IAAMI,IAAS;CAAE,OAAO;CAAI,MAAM;AAAQ,GAEpCC,IAAoB;CAAE,OAAO;CAAK,QAAQ;AAAI,GAkB9CC,IAAeL,EAAM,cAAwC,IAAI;AAEvE,SAASM,IAAW;CAClB,IAAMC,IAAUP,EAAM,WAAWK,CAAY;CAE7C,IAAI,CAACE,GACH,MAAU,MAAM,mDAAmD;CAGrE,OAAOA;AACT;AAEA,SAASC,EAAe,EACtB,OACA,cACA,aACA,WACA,sBAAmBJ,GACnB,GAAGK,KAUF;CACD,IAAMC,IAAWV,EAAM,MAAM,GACvBW,IAAU,SAASC,KAAMF,EAAS,QAAQ,MAAM,EAAE;CAExD,OACE,kBAACL,EAAa,UAAd;EAAuB,OAAO,EAAE,UAAO;EACrC,UAAA,kBAAC,OAAD;GACE,aAAU;GACV,cAAYM;GACZ,WAAWE,EACT,+pBACAC,CACF;GACA,GAAIL;GAPN,UAAA,CASE,kBAACM,GAAD;IAAY,IAAIJ;IAAiB;GAAS,CAAA,GAC1C,kBAACT,EAAkB,qBAAnB;IACoB;IAEjB;GACoC,CAAA,CACpC;;CACgB,CAAA;AAE3B;AAEA,IAAMa,KAAc,EAAE,OAAI,gBAAkD;CAC1E,IAAMC,IAAc,OAAO,QAAQC,CAAM,CAAC,CAAC,QACxC,GAAGA,OAAYA,EAAO,SAASA,EAAO,KACzC;CAMA,OAJKD,EAAY,SAKf,kBAAC,SAAD,EACE,yBAAyB,EACvB,QAAQ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AczC,EAAkB;AAEtC,SAAS0C,EAAmB,EAC1B,cACA,cAAW,IACX,YACA,mBAAgB,UAChB,cAI+C;CAC/C,IAAM,EAAE,cAAWtC,EAAS;CAM5B,OAJKqB,GAAS,SAKZ,kBAAC,OAAD;EACE,WAAWd,EACT,0CACAgC,MAAkB,QAAQ,SAAS,QACnC/B,CACF;EAEC,UAAAa,EACE,QAAQ,MAASC,EAAK,SAAS,MAAM,CAAC,CACtC,KAAK,GAAM,MAAU;GACpB,IAAMR,IAAM,GAAGkB,KAAWV,EAAK,WAAW,WACpCP,IAAaS,EAA4Bb,GAAQW,GAAMR,CAAG;GAEhE,OACE,kBAAC,OAAD;IAEE,WAAWP,EACT,iFACF;IAJF,UAAA,CAMGQ,GAAY,QAAQ,CAACyB,IACpB,kBAACzB,EAAW,MAAZ,CAAkB,CAAA,IAElB,kBAAC,OAAD;KACE,WAAU;KACV,OAAO,EACL,iBAAiBO,EAAK,MACxB;IACD,CAAA,GAEFP,GAAY,KACV;GAhBE,GAAAoB,CAgBF;EAET,CAAC;CACA,CAAA,IAtCE;AAwCX;AAEA,SAASX,EACP,GACA,GACA,GACA;CACA,IAAI,OAAOH,KAAY,aAAYA,GACjC;CAGF,IAAMoB,IACJ,aAAapB,KACb,OAAOA,EAAQ,WAAY,YAC3BA,EAAQ,YAAY,OAChBA,EAAQ,UACR,KAAA,GAEFqB,IAAyB5B;CAiB7B,OAdEA,KAAOO,KACP,OAAOA,EAAQP,MAAiC,WAEhD,IAAiBO,EAAQP,KAEzB2B,KACA3B,KAAO2B,KACP,OAAOA,EAAe3B,MAAwC,aAE9D,IAAiB2B,EACf3B,KAIG4B,KAAkB/B,IAASA,EAAO+B,KAAkB/B,EAAOG;AACpE"}
|
|
@@ -1,90 +1,95 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Button as e } from "./button.js";
|
|
3
3
|
import { cn as t } from "cn";
|
|
4
|
-
import "react";
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { XIcon as
|
|
7
|
-
import { Dialog as
|
|
4
|
+
import * as n from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
import { XIcon as a } from "lucide-react";
|
|
7
|
+
import { Dialog as o } from "@base-ui/react/dialog";
|
|
8
8
|
// src/components/ui/sheet.tsx
|
|
9
|
-
function
|
|
10
|
-
return /* @__PURE__ */
|
|
9
|
+
function s({ ...e }) {
|
|
10
|
+
return /* @__PURE__ */ r(o.Root, {
|
|
11
11
|
"data-slot": "sheet",
|
|
12
12
|
...e
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return /* @__PURE__ */
|
|
15
|
+
function c({ ...e }) {
|
|
16
|
+
return /* @__PURE__ */ r(o.Trigger, {
|
|
17
17
|
"data-slot": "sheet-trigger",
|
|
18
18
|
...e
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return /* @__PURE__ */
|
|
21
|
+
function l({ ...e }) {
|
|
22
|
+
return /* @__PURE__ */ r(o.Close, {
|
|
23
23
|
"data-slot": "sheet-close",
|
|
24
24
|
...e
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var u = n.createContext(!1);
|
|
28
|
+
function d({ ...e }) {
|
|
29
|
+
return /* @__PURE__ */ r(o.Portal, {
|
|
29
30
|
"data-slot": "sheet-portal",
|
|
30
31
|
...e
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
return /* @__PURE__ */
|
|
34
|
+
function f({ className: e, ...n }) {
|
|
35
|
+
return /* @__PURE__ */ r(o.Backdrop, {
|
|
35
36
|
"data-slot": "sheet-overlay",
|
|
36
37
|
className: t("fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs", e),
|
|
37
|
-
...
|
|
38
|
+
...n
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
-
return /* @__PURE__ */
|
|
41
|
+
function p({ className: n, children: s, side: c = "right", showCloseButton: l = !0, ...p }) {
|
|
42
|
+
return /* @__PURE__ */ i(d, { children: [/* @__PURE__ */ r(f, {}), /* @__PURE__ */ i(o.Popup, {
|
|
42
43
|
"data-slot": "sheet-content",
|
|
43
44
|
"data-side": c,
|
|
44
|
-
className: t("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
|
|
45
|
-
...
|
|
46
|
-
children: [
|
|
45
|
+
className: t("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm", n),
|
|
46
|
+
...p,
|
|
47
|
+
children: [/* @__PURE__ */ r(u.Provider, {
|
|
48
|
+
value: l,
|
|
49
|
+
children: s
|
|
50
|
+
}), l && /* @__PURE__ */ i(o.Close, {
|
|
47
51
|
"data-slot": "sheet-close",
|
|
48
|
-
render: /* @__PURE__ */
|
|
52
|
+
render: /* @__PURE__ */ r(e, {
|
|
49
53
|
variant: "ghost",
|
|
50
54
|
className: "absolute top-3 right-3",
|
|
51
55
|
size: "icon-sm"
|
|
52
56
|
}),
|
|
53
|
-
children: [/* @__PURE__ */
|
|
57
|
+
children: [/* @__PURE__ */ r(a, {}), /* @__PURE__ */ r("span", {
|
|
54
58
|
className: "sr-only",
|
|
55
59
|
children: "Fermer"
|
|
56
60
|
})]
|
|
57
61
|
})]
|
|
58
62
|
})] });
|
|
59
63
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
64
|
+
function m({ className: e, ...i }) {
|
|
65
|
+
let a = n.useContext(u);
|
|
66
|
+
return /* @__PURE__ */ r("div", {
|
|
62
67
|
"data-slot": "sheet-header",
|
|
63
|
-
className: t("flex flex-col gap-0.5 p-4", e),
|
|
64
|
-
...
|
|
68
|
+
className: t("flex flex-col gap-0.5 p-4", a && "pr-12", e),
|
|
69
|
+
...i
|
|
65
70
|
});
|
|
66
71
|
}
|
|
67
|
-
function
|
|
68
|
-
return /* @__PURE__ */
|
|
72
|
+
function h({ className: e, ...n }) {
|
|
73
|
+
return /* @__PURE__ */ r("div", {
|
|
69
74
|
"data-slot": "sheet-footer",
|
|
70
75
|
className: t("mt-auto flex flex-col gap-2 p-4", e),
|
|
71
|
-
...
|
|
76
|
+
...n
|
|
72
77
|
});
|
|
73
78
|
}
|
|
74
|
-
function
|
|
75
|
-
return /* @__PURE__ */
|
|
79
|
+
function g({ className: e, ...n }) {
|
|
80
|
+
return /* @__PURE__ */ r(o.Title, {
|
|
76
81
|
"data-slot": "sheet-title",
|
|
77
82
|
className: t("font-heading text-base font-medium text-foreground", e),
|
|
78
|
-
...
|
|
83
|
+
...n
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
|
-
function
|
|
82
|
-
return /* @__PURE__ */
|
|
86
|
+
function _({ className: e, ...n }) {
|
|
87
|
+
return /* @__PURE__ */ r(o.Description, {
|
|
83
88
|
"data-slot": "sheet-description",
|
|
84
89
|
className: t("text-sm text-muted-foreground", e),
|
|
85
|
-
...
|
|
90
|
+
...n
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
|
-
export {
|
|
93
|
+
export { s as Sheet, l as SheetClose, p as SheetContent, _ as SheetDescription, h as SheetFooter, m as SheetHeader, g as SheetTitle, c as SheetTrigger };
|
|
89
94
|
|
|
90
95
|
//# sourceMappingURL=sheet.js.map
|