@etic-insa/ui 0.0.0 → 0.1.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 +61 -5
- package/dist/components/etic/app-shell.d.ts +69 -0
- package/dist/components/etic/app-shell.js +180 -0
- package/dist/components/etic/app-shell.js.map +1 -0
- package/dist/components/etic/theme-menu.d.ts +19 -0
- package/dist/components/etic/theme-menu.js +66 -0
- package/dist/components/etic/theme-menu.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert-dialog.js +95 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +11 -0
- package/dist/components/ui/avatar.js +52 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +29 -0
- package/dist/components/ui/dropdown-menu.js +137 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +16 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/separator.js +15 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.js +90 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +63 -0
- package/dist/components/ui/sidebar.js +358 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +13 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/tooltip.js +42 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +18 -0
- package/dist/hooks/use-mobile.js +16 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +14 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ pas publié et n'est pas la référence d'une application.
|
|
|
58
58
|
|
|
59
59
|
Dans les classes, l'accent comme texte s'écrit `text-primary-text`, jamais `text-primary`. Les
|
|
60
60
|
composants shadcn d'origine (`src/components/ui/`) emploient parfois `text-primary` (variante
|
|
61
|
-
`link` du bouton) :
|
|
61
|
+
`link` du bouton) : à corriger, dans le composant ou dans une enveloppe ETIC. **Limite actuelle** : le `Button`
|
|
62
62
|
exporté est encore celui de shadcn ; avec un accent clair (Docs, Intervenant, Browser), sa
|
|
63
63
|
variante `link` est illisible en thème clair. Ne pas l'employer avant son enveloppe.
|
|
64
64
|
|
|
@@ -76,6 +76,55 @@ export function Export() {
|
|
|
76
76
|
}
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
### Coquille d'application
|
|
80
|
+
|
|
81
|
+
`AppShell` pose la mise en page commune : barre latérale de shadcn (marque, rubriques, menu du
|
|
82
|
+
compte, thème), repliable en colonne d'icônes sur ordinateur (rail ou Ctrl+B, état gardé dans le
|
|
83
|
+
cookie `sidebar_state` de shadcn), qui devient un tiroir ouvert par une barre du haut sous
|
|
84
|
+
1 025 px (téléphones et tablettes). Il ne connaît ni le routeur ni l'authentification : l'application donne les liens et
|
|
85
|
+
leur état actif, le compte et le thème, et son composant de lien.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { AppShell } from "@etic-insa/ui"
|
|
89
|
+
import { Link, Outlet, useLocation } from "react-router-dom"
|
|
90
|
+
import { UsersIcon } from "lucide-react"
|
|
91
|
+
|
|
92
|
+
const LienRouteur = ({ href, ...props }: React.ComponentProps<"a">) => (
|
|
93
|
+
<Link to={href!} {...props} />
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
export function MiseEnPage() {
|
|
97
|
+
const { pathname } = useLocation()
|
|
98
|
+
return (
|
|
99
|
+
<AppShell
|
|
100
|
+
application={{ nom: "ETIC Docs", logo: <img src={logo} alt="" /> }}
|
|
101
|
+
sections={[
|
|
102
|
+
{
|
|
103
|
+
titre: "Études",
|
|
104
|
+
liens: [
|
|
105
|
+
{
|
|
106
|
+
libelle: "Études",
|
|
107
|
+
href: "/etudes",
|
|
108
|
+
icone: UsersIcon,
|
|
109
|
+
actif: pathname.startsWith("/etudes"),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
]}
|
|
114
|
+
compte={{ nom: "Ada Lovelace", initiales: "AL", seDeconnecter }}
|
|
115
|
+
theme={{ valeur: theme, changer: changerTheme }}
|
|
116
|
+
lien={LienRouteur}
|
|
117
|
+
>
|
|
118
|
+
<Outlet />
|
|
119
|
+
</AppShell>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`changer` peut renvoyer une promesse : rejetée, elle affiche « Thème non enregistré ». La
|
|
125
|
+
déconnexion est toujours confirmée. La coquille fournit l'élément `<main>` : les pages n'en
|
|
126
|
+
ajoutent pas. `ThemeMenu` existe aussi seul (page de connexion…).
|
|
127
|
+
|
|
79
128
|
### Développer contre les sources locales
|
|
80
129
|
|
|
81
130
|
Pour voir une modification de la bibliothèque instantanément dans une application, sans publier,
|
|
@@ -112,7 +161,7 @@ d'`etic-packages` installe tous les paquets.
|
|
|
112
161
|
|
|
113
162
|
```sh
|
|
114
163
|
# depuis packages/ui
|
|
115
|
-
npm run dev # atelier : tous les composants,
|
|
164
|
+
npm run dev # atelier : tous les composants, thème au pied de la barre latérale
|
|
116
165
|
npm test # vitest
|
|
117
166
|
npm run typecheck
|
|
118
167
|
npm run lint
|
|
@@ -122,9 +171,16 @@ npm run build # dist/ : un module par composant, types, styles.css
|
|
|
122
171
|
|
|
123
172
|
### Organisation
|
|
124
173
|
|
|
125
|
-
- `src/components/ui/` : composants shadcn
|
|
126
|
-
(`npx shadcn add <composant>`).
|
|
127
|
-
|
|
174
|
+
- `src/components/ui/` et `src/hooks/` : composants shadcn, copiés par le CLI
|
|
175
|
+
(`npx shadcn add <composant>`). Ce code est le nôtre et se modifie comme le reste. Chaque
|
|
176
|
+
modification est listée ci-dessous, pour pouvoir la réappliquer si l'on reprend un jour la
|
|
177
|
+
version de shadcn (`npx shadcn add <composant> --diff`, puis `--overwrite`) ;
|
|
178
|
+
`src/ecarts-shadcn.test.ts` échoue si elle a disparu :
|
|
179
|
+
- seuil mobile à 1 024 px compris au lieu de 768 px : `hooks/use-mobile.ts` (réécrit avec
|
|
180
|
+
`useSyncExternalStore`, juste dès le premier rendu) et les variantes `md:` de
|
|
181
|
+
`components/ui/sidebar.tsx`, devenues `min-[1025px]:` ;
|
|
182
|
+
- textes en français, lus par les lecteurs d'écran : `sidebar.tsx` (« Menu »,
|
|
183
|
+
« Afficher ou masquer le menu »), `sheet.tsx` (« Fermer »).
|
|
128
184
|
- `src/components/etic/` : composants ETIC qui importent ceux de `ui/` et ajoutent
|
|
129
185
|
comportement, composition ou variantes.
|
|
130
186
|
- `src/index.ts` : tout ce qu'une application peut importer. Un composant non exporté ici
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ComponentProps, ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { LucideIcon } from 'lucide-react';
|
|
3
|
+
import { ThemeMenuProps } from './theme-menu';
|
|
4
|
+
/** Lien du routeur de l'application (react-router, TanStack Router…), qui
|
|
5
|
+
* reçoit `href` comme un `<a>`. Par défaut, un `<a>` : rechargement complet. */
|
|
6
|
+
export type AppShellLienComposant = ComponentType<ComponentProps<"a">> | "a";
|
|
7
|
+
export interface AppShellLien {
|
|
8
|
+
libelle: string;
|
|
9
|
+
href: string;
|
|
10
|
+
icone?: LucideIcon;
|
|
11
|
+
/** Page à l'écran. Calculé par l'application, seule à savoir qu'une fiche
|
|
12
|
+
* appartient à telle rubrique. */
|
|
13
|
+
actif?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface AppShellSection {
|
|
16
|
+
titre?: string;
|
|
17
|
+
liens: AppShellLien[];
|
|
18
|
+
}
|
|
19
|
+
/** Entrée du menu du compte : un lien, ou une action. */
|
|
20
|
+
export type AppShellEntreeCompte = {
|
|
21
|
+
libelle: string;
|
|
22
|
+
icone?: LucideIcon;
|
|
23
|
+
} & ({
|
|
24
|
+
href: string;
|
|
25
|
+
onSelect?: never;
|
|
26
|
+
} | {
|
|
27
|
+
onSelect: () => void;
|
|
28
|
+
href?: never;
|
|
29
|
+
});
|
|
30
|
+
export interface AppShellCompte {
|
|
31
|
+
/** « Prénom Nom », ou le rôle d'un compte fonctionnel. */
|
|
32
|
+
nom: string;
|
|
33
|
+
/** Seconde ligne, l'adresse par exemple. */
|
|
34
|
+
detail?: string;
|
|
35
|
+
initiales: string;
|
|
36
|
+
/** Photo ; les initiales s'affichent tant qu'elle manque ou charge. */
|
|
37
|
+
photo?: string | null;
|
|
38
|
+
/** La fiche du compte est la page à l'écran. */
|
|
39
|
+
actif?: boolean;
|
|
40
|
+
/** Entrées du menu du compte, avant « Se déconnecter ». */
|
|
41
|
+
entrees?: AppShellEntreeCompte[];
|
|
42
|
+
/** Appelé après confirmation. */
|
|
43
|
+
seDeconnecter: () => void;
|
|
44
|
+
}
|
|
45
|
+
export interface AppShellProps {
|
|
46
|
+
application: {
|
|
47
|
+
nom: string;
|
|
48
|
+
sousTitre?: string;
|
|
49
|
+
/** Image ou icône, 28 px de côté environ. */
|
|
50
|
+
logo?: ReactNode;
|
|
51
|
+
/** Lien de la marque ; « / » par défaut. */
|
|
52
|
+
href?: string;
|
|
53
|
+
};
|
|
54
|
+
sections: AppShellSection[];
|
|
55
|
+
compte?: AppShellCompte;
|
|
56
|
+
theme?: Pick<ThemeMenuProps, "valeur" | "changer">;
|
|
57
|
+
lien?: AppShellLienComposant;
|
|
58
|
+
/** Au-dessus du contenu, sur toute sa largeur (bandeau d'erreur…). */
|
|
59
|
+
bandeau?: ReactNode;
|
|
60
|
+
children: ReactNode;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Coquille commune des applications ETIC : la barre latérale de shadcn
|
|
64
|
+
* (navigation par rubriques, menu du compte, thème), qui devient un tiroir
|
|
65
|
+
* sous 1 025 px, ouvert par une barre du haut. Le tiroir se referme quand on
|
|
66
|
+
* suit un de ses liens. Ne connaît ni le routeur ni l'authentification : l'application
|
|
67
|
+
* fournit les liens, l'état actif, le compte et le thème.
|
|
68
|
+
*/
|
|
69
|
+
export declare function AppShell({ application, sections, compte, theme, lien: Lien, bandeau, children, }: AppShellProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { AlertDialog as e, AlertDialogAction as t, AlertDialogCancel as n, AlertDialogContent as r, AlertDialogDescription as i, AlertDialogFooter as a, AlertDialogHeader as o, AlertDialogTitle as s } from "../ui/alert-dialog.js";
|
|
2
|
+
import { Avatar as c, AvatarFallback as l, AvatarImage as u } from "../ui/avatar.js";
|
|
3
|
+
import { DropdownMenu as d, DropdownMenuContent as f, DropdownMenuGroup as p, DropdownMenuItem as m, DropdownMenuSeparator as h, DropdownMenuTrigger as g } from "../ui/dropdown-menu.js";
|
|
4
|
+
import { Sidebar as _, SidebarContent as v, SidebarFooter as y, SidebarGroup as b, SidebarGroupContent as x, SidebarGroupLabel as S, SidebarHeader as C, SidebarInset as w, SidebarMenu as T, SidebarMenuButton as E, SidebarMenuItem as D, SidebarProvider as O, SidebarRail as k, SidebarTrigger as A, useSidebar as j } from "../ui/sidebar.js";
|
|
5
|
+
import { TooltipProvider as M } from "../ui/tooltip.js";
|
|
6
|
+
import { ThemeMenu as N } from "./theme-menu.js";
|
|
7
|
+
import { cn as P } from "cn";
|
|
8
|
+
import { useState as F } from "react";
|
|
9
|
+
import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
|
|
10
|
+
import { ChevronsUpDownIcon as z, LogOutIcon as B } from "lucide-react";
|
|
11
|
+
// src/components/etic/app-shell.tsx
|
|
12
|
+
function V({ application: e, sections: t, compte: n, theme: r, lien: i = "a", bandeau: a, children: o }) {
|
|
13
|
+
return /* @__PURE__ */ L(M, { children: /* @__PURE__ */ R(O, {
|
|
14
|
+
defaultOpen: !H(),
|
|
15
|
+
children: [/* @__PURE__ */ R(W, { children: [
|
|
16
|
+
/* @__PURE__ */ L(C, { children: /* @__PURE__ */ L(K, {
|
|
17
|
+
application: e,
|
|
18
|
+
Lien: i
|
|
19
|
+
}) }),
|
|
20
|
+
/* @__PURE__ */ L(v, { children: /* @__PURE__ */ L(q, {
|
|
21
|
+
sections: t,
|
|
22
|
+
Lien: i
|
|
23
|
+
}) }),
|
|
24
|
+
n || r ? /* @__PURE__ */ R(y, {
|
|
25
|
+
className: "flex-row items-center gap-2 group-data-[collapsible=icon]:flex-col",
|
|
26
|
+
children: [n ? /* @__PURE__ */ L(J, {
|
|
27
|
+
compte: n,
|
|
28
|
+
Lien: i
|
|
29
|
+
}) : null, r ? /* @__PURE__ */ L(N, {
|
|
30
|
+
...r,
|
|
31
|
+
side: "top",
|
|
32
|
+
className: "size-12 shrink-0 bg-sidebar group-data-[collapsible=icon]:size-8"
|
|
33
|
+
}) : null]
|
|
34
|
+
}) : null
|
|
35
|
+
] }), /* @__PURE__ */ R(w, {
|
|
36
|
+
className: "min-w-0",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ L(Y, {
|
|
39
|
+
application: e,
|
|
40
|
+
Lien: i
|
|
41
|
+
}),
|
|
42
|
+
a,
|
|
43
|
+
o
|
|
44
|
+
]
|
|
45
|
+
})]
|
|
46
|
+
}) });
|
|
47
|
+
}
|
|
48
|
+
function H() {
|
|
49
|
+
return typeof document < "u" && /(?:^|;\s*)sidebar_state=false(?:;|$)/.test(document.cookie);
|
|
50
|
+
}
|
|
51
|
+
var U = "data-ferme-tiroir";
|
|
52
|
+
function W({ children: e }) {
|
|
53
|
+
let { isMobile: t, setOpenMobile: n } = j();
|
|
54
|
+
return /* @__PURE__ */ R(_, {
|
|
55
|
+
collapsible: "icon",
|
|
56
|
+
children: [/* @__PURE__ */ L("div", {
|
|
57
|
+
className: "contents",
|
|
58
|
+
onClick: (e) => {
|
|
59
|
+
!t || e.ctrlKey || e.metaKey || e.shiftKey || e.target.closest(`a[href], [${U}]`) && n(!1);
|
|
60
|
+
},
|
|
61
|
+
children: e
|
|
62
|
+
}), /* @__PURE__ */ L(k, {})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function G({ application: e, className: t }) {
|
|
66
|
+
return e.logo ? /* @__PURE__ */ L("span", {
|
|
67
|
+
className: P("flex shrink-0 items-center justify-center [&_img]:size-full [&_svg]:size-full", t),
|
|
68
|
+
children: e.logo
|
|
69
|
+
}) : null;
|
|
70
|
+
}
|
|
71
|
+
function K({ application: e, Lien: t }) {
|
|
72
|
+
return /* @__PURE__ */ L(T, { children: /* @__PURE__ */ L(D, { children: /* @__PURE__ */ R(E, {
|
|
73
|
+
size: "lg",
|
|
74
|
+
render: /* @__PURE__ */ L(t, { href: e.href ?? "/" }),
|
|
75
|
+
children: [/* @__PURE__ */ L(G, {
|
|
76
|
+
application: e,
|
|
77
|
+
className: "size-7"
|
|
78
|
+
}), /* @__PURE__ */ R("span", {
|
|
79
|
+
className: "grid flex-1 text-left leading-tight",
|
|
80
|
+
children: [/* @__PURE__ */ L("span", {
|
|
81
|
+
className: "truncate font-semibold",
|
|
82
|
+
children: e.nom
|
|
83
|
+
}), e.sousTitre ? /* @__PURE__ */ L("span", {
|
|
84
|
+
className: "truncate text-xs text-muted-foreground",
|
|
85
|
+
children: e.sousTitre
|
|
86
|
+
}) : null]
|
|
87
|
+
})]
|
|
88
|
+
}) }) });
|
|
89
|
+
}
|
|
90
|
+
function q({ sections: e, Lien: t }) {
|
|
91
|
+
return /* @__PURE__ */ L("nav", {
|
|
92
|
+
"aria-label": "Navigation principale",
|
|
93
|
+
children: e.map((e, n) => /* @__PURE__ */ R(b, { children: [e.titre ? /* @__PURE__ */ L(S, { children: e.titre }) : null, /* @__PURE__ */ L(x, { children: /* @__PURE__ */ L(T, { children: e.liens.map(({ libelle: e, href: n, icone: r, actif: i }, a) => /* @__PURE__ */ L(D, { children: /* @__PURE__ */ R(E, {
|
|
94
|
+
isActive: i,
|
|
95
|
+
tooltip: e,
|
|
96
|
+
render: /* @__PURE__ */ L(t, {
|
|
97
|
+
href: n,
|
|
98
|
+
"aria-current": i ? "page" : void 0
|
|
99
|
+
}),
|
|
100
|
+
children: [r ? /* @__PURE__ */ L(r, {}) : null, /* @__PURE__ */ L("span", { children: e })]
|
|
101
|
+
}) }, a)) }) })] }, n))
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function J({ compte: _, Lien: v }) {
|
|
105
|
+
let [y, b] = F(!1);
|
|
106
|
+
return /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(T, {
|
|
107
|
+
className: "min-w-0 flex-1",
|
|
108
|
+
children: /* @__PURE__ */ L(D, { children: /* @__PURE__ */ R(d, { children: [/* @__PURE__ */ R(g, {
|
|
109
|
+
render: /* @__PURE__ */ L(E, {
|
|
110
|
+
size: "lg",
|
|
111
|
+
isActive: _.actif,
|
|
112
|
+
"aria-label": `${_.nom}, menu du compte`,
|
|
113
|
+
className: "data-popup-open:bg-sidebar-accent data-popup-open:text-sidebar-accent-foreground"
|
|
114
|
+
}),
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ R(c, { children: [_.photo ? /* @__PURE__ */ L(u, {
|
|
117
|
+
src: _.photo,
|
|
118
|
+
alt: ""
|
|
119
|
+
}) : null, /* @__PURE__ */ L(l, { children: _.initiales })] }),
|
|
120
|
+
/* @__PURE__ */ R("span", {
|
|
121
|
+
className: "grid flex-1 text-left leading-tight",
|
|
122
|
+
children: [/* @__PURE__ */ L("span", {
|
|
123
|
+
className: "truncate font-medium",
|
|
124
|
+
children: _.nom
|
|
125
|
+
}), _.detail ? /* @__PURE__ */ L("span", {
|
|
126
|
+
className: "truncate text-xs text-muted-foreground",
|
|
127
|
+
children: _.detail
|
|
128
|
+
}) : null]
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ L(z, { className: "ml-auto" })
|
|
131
|
+
]
|
|
132
|
+
}), /* @__PURE__ */ R(f, {
|
|
133
|
+
side: "top",
|
|
134
|
+
align: "start",
|
|
135
|
+
className: "min-w-56",
|
|
136
|
+
children: [_.entrees?.length ? /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(p, { children: _.entrees.map(({ libelle: e, icone: t, href: n, onSelect: r }, i) => /* @__PURE__ */ R(m, {
|
|
137
|
+
render: n ? /* @__PURE__ */ L(v, { href: n }) : void 0,
|
|
138
|
+
onClick: r,
|
|
139
|
+
[U]: !0,
|
|
140
|
+
children: [t ? /* @__PURE__ */ L(t, {}) : null, e]
|
|
141
|
+
}, i)) }), /* @__PURE__ */ L(h, {})] }) : null, /* @__PURE__ */ R(m, {
|
|
142
|
+
onClick: () => b(!0),
|
|
143
|
+
children: [/* @__PURE__ */ L(B, {}), "Se déconnecter"]
|
|
144
|
+
})]
|
|
145
|
+
})] }) })
|
|
146
|
+
}), /* @__PURE__ */ L(e, {
|
|
147
|
+
open: y,
|
|
148
|
+
onOpenChange: b,
|
|
149
|
+
children: /* @__PURE__ */ R(r, { children: [/* @__PURE__ */ R(o, { children: [/* @__PURE__ */ L(s, { children: "Se déconnecter" }), /* @__PURE__ */ L(i, { children: "Voulez-vous vraiment vous déconnecter ?" })] }), /* @__PURE__ */ R(a, { children: [/* @__PURE__ */ L(n, { children: "Annuler" }), /* @__PURE__ */ L(t, {
|
|
150
|
+
onClick: () => {
|
|
151
|
+
b(!1), _.seDeconnecter();
|
|
152
|
+
},
|
|
153
|
+
children: "Se déconnecter"
|
|
154
|
+
})] })] })
|
|
155
|
+
})] });
|
|
156
|
+
}
|
|
157
|
+
function Y({ application: e, Lien: t }) {
|
|
158
|
+
let { isMobile: n, openMobile: r } = j();
|
|
159
|
+
return n ? /* @__PURE__ */ R("header", {
|
|
160
|
+
className: "sticky top-0 z-10 flex h-12 shrink-0 items-center gap-2 border-b bg-background px-2",
|
|
161
|
+
children: [/* @__PURE__ */ L(A, {
|
|
162
|
+
"aria-label": "Ouvrir le menu",
|
|
163
|
+
"aria-expanded": r,
|
|
164
|
+
className: "size-9"
|
|
165
|
+
}), /* @__PURE__ */ R(t, {
|
|
166
|
+
href: e.href ?? "/",
|
|
167
|
+
className: "flex min-w-0 items-center gap-2 rounded-md px-1 font-semibold outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
168
|
+
children: [/* @__PURE__ */ L(G, {
|
|
169
|
+
application: e,
|
|
170
|
+
className: "size-6"
|
|
171
|
+
}), /* @__PURE__ */ L("span", {
|
|
172
|
+
className: "truncate",
|
|
173
|
+
children: e.nom
|
|
174
|
+
})]
|
|
175
|
+
})]
|
|
176
|
+
}) : null;
|
|
177
|
+
}
|
|
178
|
+
export { V as AppShell };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=app-shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-shell.js","names":["_Fragment","AppShell","Lien","TooltipProvider","SidebarProvider","colonneRepliee","Colonne","SidebarHeader","Marque","SidebarContent","Navigation","compte","theme","SidebarFooter","MenuCompte","ThemeMenu","SidebarInset","BarreMobile","bandeau","children","FERME_TIROIR","useSidebar","Sidebar","isMobile","event","setOpenMobile","SidebarRail","Logo","application","cn","className","SidebarMenu","SidebarMenuItem","SidebarMenuButton","sections","SidebarGroup","section","SidebarGroupLabel","SidebarGroupContent","Icone","actif","libelle","i","index","confirmer","setConfirmer","useState","Fragment","DropdownMenu","DropdownMenuTrigger","Avatar","AvatarImage","AvatarFallback","ChevronsUpDownIcon","DropdownMenuContent","DropdownMenuGroup","DropdownMenuItem","href","onSelect","DropdownMenuSeparator","LogOutIcon","AlertDialog","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","SidebarTrigger","openMobile"],"sources":["../../../src/components/etic/app-shell.tsx"],"sourcesContent":["import {\n useState,\n type ComponentProps,\n type ComponentType,\n type ReactNode,\n} from \"react\"\nimport { cn } from \"cn\"\nimport { ChevronsUpDownIcon, LogOutIcon, type LucideIcon } from \"lucide-react\"\n\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from \"@etic-ui/components/ui/alert-dialog\"\nimport {\n Avatar,\n AvatarFallback,\n AvatarImage,\n} from \"@etic-ui/components/ui/avatar\"\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@etic-ui/components/ui/dropdown-menu\"\nimport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarInset,\n SidebarMenu,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarProvider,\n SidebarRail,\n SidebarTrigger,\n useSidebar,\n} from \"@etic-ui/components/ui/sidebar\"\nimport { TooltipProvider } from \"@etic-ui/components/ui/tooltip\"\nimport {\n ThemeMenu,\n type ThemeMenuProps,\n} from \"@etic-ui/components/etic/theme-menu\"\n\n/** Lien du routeur de l'application (react-router, TanStack Router…), qui\n * reçoit `href` comme un `<a>`. Par défaut, un `<a>` : rechargement complet. */\nexport type AppShellLienComposant = ComponentType<ComponentProps<\"a\">> | \"a\"\n\nexport interface AppShellLien {\n libelle: string\n href: string\n icone?: LucideIcon\n /** Page à l'écran. Calculé par l'application, seule à savoir qu'une fiche\n * appartient à telle rubrique. */\n actif?: boolean\n}\n\nexport interface AppShellSection {\n titre?: string\n liens: AppShellLien[]\n}\n\n/** Entrée du menu du compte : un lien, ou une action. */\nexport type AppShellEntreeCompte = {\n libelle: string\n icone?: LucideIcon\n} & (\n { href: string; onSelect?: never } | { onSelect: () => void; href?: never }\n)\n\nexport interface AppShellCompte {\n /** « Prénom Nom », ou le rôle d'un compte fonctionnel. */\n nom: string\n /** Seconde ligne, l'adresse par exemple. */\n detail?: string\n initiales: string\n /** Photo ; les initiales s'affichent tant qu'elle manque ou charge. */\n photo?: string | null\n /** La fiche du compte est la page à l'écran. */\n actif?: boolean\n /** Entrées du menu du compte, avant « Se déconnecter ». */\n entrees?: AppShellEntreeCompte[]\n /** Appelé après confirmation. */\n seDeconnecter: () => void\n}\n\nexport interface AppShellProps {\n application: {\n nom: string\n sousTitre?: string\n /** Image ou icône, 28 px de côté environ. */\n logo?: ReactNode\n /** Lien de la marque ; « / » par défaut. */\n href?: string\n }\n sections: AppShellSection[]\n compte?: AppShellCompte\n theme?: Pick<ThemeMenuProps, \"valeur\" | \"changer\">\n lien?: AppShellLienComposant\n /** Au-dessus du contenu, sur toute sa largeur (bandeau d'erreur…). */\n bandeau?: ReactNode\n children: ReactNode\n}\n\n/**\n * Coquille commune des applications ETIC : la barre latérale de shadcn\n * (navigation par rubriques, menu du compte, thème), qui devient un tiroir\n * sous 1 025 px, ouvert par une barre du haut. Le tiroir se referme quand on\n * suit un de ses liens. Ne connaît ni le routeur ni l'authentification : l'application\n * fournit les liens, l'état actif, le compte et le thème.\n */\nexport function AppShell({\n application,\n sections,\n compte,\n theme,\n lien: Lien = \"a\",\n bandeau,\n children,\n}: AppShellProps) {\n return (\n <TooltipProvider>\n <SidebarProvider defaultOpen={!colonneRepliee()}>\n <Colonne>\n <SidebarHeader>\n <Marque application={application} Lien={Lien} />\n </SidebarHeader>\n <SidebarContent>\n <Navigation sections={sections} Lien={Lien} />\n </SidebarContent>\n {compte || theme ? (\n <SidebarFooter className=\"flex-row items-center gap-2 group-data-[collapsible=icon]:flex-col\">\n {compte ? <MenuCompte compte={compte} Lien={Lien} /> : null}\n {theme ? (\n <ThemeMenu\n {...theme}\n side=\"top\"\n className=\"size-12 shrink-0 bg-sidebar group-data-[collapsible=icon]:size-8\"\n />\n ) : null}\n </SidebarFooter>\n ) : null}\n </Colonne>\n <SidebarInset className=\"min-w-0\">\n <BarreMobile application={application} Lien={Lien} />\n {bandeau}\n {children}\n </SidebarInset>\n </SidebarProvider>\n </TooltipProvider>\n )\n}\n\n/** Colonne repliée lors de la dernière visite : shadcn écrit le cookie\n * `sidebar_state` à chaque repli, sans le relire. */\nfunction colonneRepliee() {\n return (\n typeof document !== \"undefined\" &&\n /(?:^|;\\s*)sidebar_state=false(?:;|$)/.test(document.cookie)\n )\n}\n\n/** Attribut des éléments, autres que les liens, qui referment le tiroir. */\nconst FERME_TIROIR = \"data-ferme-tiroir\"\n\n/**\n * La barre latérale. Sur ordinateur, elle se replie en colonne d'icônes\n * (rail, ou Ctrl+B), comme dans shadcn. Sur mobile, le tiroir se referme dès\n * qu'on suit un de ses liens dans la page, ou une entrée marquée\n * `data-ferme-tiroir` : un seul écouteur, qui reçoit aussi les clics des\n * menus ouverts depuis le tiroir (React fait remonter les évènements des\n * portails dans l'arbre des composants). Un clic qui ouvre un nouvel onglet\n * (Ctrl, Cmd, Maj) le laisse ouvert.\n */\nfunction Colonne({ children }: { children: ReactNode }) {\n const { isMobile, setOpenMobile } = useSidebar()\n return (\n <Sidebar collapsible=\"icon\">\n <div\n className=\"contents\"\n onClick={(event) => {\n if (!isMobile || event.ctrlKey || event.metaKey || event.shiftKey) {\n return\n }\n const cible = event.target as Element\n if (cible.closest(`a[href], [${FERME_TIROIR}]`)) setOpenMobile(false)\n }}\n >\n {children}\n </div>\n <SidebarRail />\n </Sidebar>\n )\n}\n\nfunction Logo({\n application,\n className,\n}: Pick<AppShellProps, \"application\"> & { className: string }) {\n return application.logo ? (\n <span\n className={cn(\n \"flex shrink-0 items-center justify-center [&_img]:size-full [&_svg]:size-full\",\n className\n )}\n >\n {application.logo}\n </span>\n ) : null\n}\n\nfunction Marque({\n application,\n Lien,\n}: Pick<AppShellProps, \"application\"> & { Lien: AppShellLienComposant }) {\n return (\n <SidebarMenu>\n <SidebarMenuItem>\n <SidebarMenuButton\n size=\"lg\"\n render={<Lien href={application.href ?? \"/\"} />}\n >\n <Logo application={application} className=\"size-7\" />\n <span className=\"grid flex-1 text-left leading-tight\">\n <span className=\"truncate font-semibold\">{application.nom}</span>\n {application.sousTitre ? (\n <span className=\"truncate text-xs text-muted-foreground\">\n {application.sousTitre}\n </span>\n ) : null}\n </span>\n </SidebarMenuButton>\n </SidebarMenuItem>\n </SidebarMenu>\n )\n}\n\nfunction Navigation({\n sections,\n Lien,\n}: Pick<AppShellProps, \"sections\"> & { Lien: AppShellLienComposant }) {\n return (\n <nav aria-label=\"Navigation principale\">\n {sections.map((section, index) => (\n <SidebarGroup key={index}>\n {section.titre ? (\n <SidebarGroupLabel>{section.titre}</SidebarGroupLabel>\n ) : null}\n <SidebarGroupContent>\n <SidebarMenu>\n {section.liens.map(\n ({ libelle, href, icone: Icone, actif }, i) => (\n <SidebarMenuItem key={i}>\n <SidebarMenuButton\n isActive={actif}\n tooltip={libelle}\n render={\n <Lien\n href={href}\n aria-current={actif ? \"page\" : undefined}\n />\n }\n >\n {Icone ? <Icone /> : null}\n <span>{libelle}</span>\n </SidebarMenuButton>\n </SidebarMenuItem>\n )\n )}\n </SidebarMenu>\n </SidebarGroupContent>\n </SidebarGroup>\n ))}\n </nav>\n )\n}\n\nfunction MenuCompte({\n compte,\n Lien,\n}: {\n compte: AppShellCompte\n Lien: AppShellLienComposant\n}) {\n const [confirmer, setConfirmer] = useState(false)\n\n return (\n <>\n <SidebarMenu className=\"min-w-0 flex-1\">\n <SidebarMenuItem>\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <SidebarMenuButton\n size=\"lg\"\n isActive={compte.actif}\n aria-label={`${compte.nom}, menu du compte`}\n className=\"data-popup-open:bg-sidebar-accent data-popup-open:text-sidebar-accent-foreground\"\n />\n }\n >\n <Avatar>\n {compte.photo ? (\n <AvatarImage src={compte.photo} alt=\"\" />\n ) : null}\n <AvatarFallback>{compte.initiales}</AvatarFallback>\n </Avatar>\n <span className=\"grid flex-1 text-left leading-tight\">\n <span className=\"truncate font-medium\">{compte.nom}</span>\n {compte.detail ? (\n <span className=\"truncate text-xs text-muted-foreground\">\n {compte.detail}\n </span>\n ) : null}\n </span>\n <ChevronsUpDownIcon className=\"ml-auto\" />\n </DropdownMenuTrigger>\n <DropdownMenuContent side=\"top\" align=\"start\" className=\"min-w-56\">\n {compte.entrees?.length ? (\n <>\n <DropdownMenuGroup>\n {compte.entrees.map(\n ({ libelle, icone: Icone, href, onSelect }, i) => (\n <DropdownMenuItem\n key={i}\n render={href ? <Lien href={href} /> : undefined}\n onClick={onSelect}\n {...{ [FERME_TIROIR]: true }}\n >\n {Icone ? <Icone /> : null}\n {libelle}\n </DropdownMenuItem>\n )\n )}\n </DropdownMenuGroup>\n <DropdownMenuSeparator />\n </>\n ) : null}\n <DropdownMenuItem onClick={() => setConfirmer(true)}>\n <LogOutIcon />\n Se déconnecter\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </SidebarMenuItem>\n </SidebarMenu>\n\n <AlertDialog open={confirmer} onOpenChange={setConfirmer}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Se déconnecter</AlertDialogTitle>\n <AlertDialogDescription>\n Voulez-vous vraiment vous déconnecter ?\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Annuler</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n setConfirmer(false)\n compte.seDeconnecter()\n }}\n >\n Se déconnecter\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </>\n )\n}\n\n/** Sous le seuil mobile, la barre latérale n'est plus à l'écran : cette barre\n * porte le bouton qui l'ouvre en tiroir, et la marque. */\nfunction BarreMobile({\n application,\n Lien,\n}: Pick<AppShellProps, \"application\"> & { Lien: AppShellLienComposant }) {\n const { isMobile, openMobile } = useSidebar()\n if (!isMobile) return null\n return (\n <header className=\"sticky top-0 z-10 flex h-12 shrink-0 items-center gap-2 border-b bg-background px-2\">\n <SidebarTrigger\n aria-label=\"Ouvrir le menu\"\n aria-expanded={openMobile}\n className=\"size-9\"\n />\n <Lien\n href={application.href ?? \"/\"}\n className=\"flex min-w-0 items-center gap-2 rounded-md px-1 font-semibold outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <Logo application={application} className=\"size-6\" />\n <span className=\"truncate\">{application.nom}</span>\n </Lien>\n </header>\n )\n}\n"],"mappings":";;;;;;;;;;;AA0HA,SAAgBC,EAAS,EACvB,gBACA,aACA,WACA,UACA,MAAMC,IAAO,KACb,YACA,eACgB;CAChB,OACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD;EAAiB,aAAa,CAACC,EAAe;EAA9C,UAAA,CACE,kBAACC,GAAD,EAAA,UAAA;GACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD;IAAqB;IAAmB;GAAO,CAAA,EAClC,CAAA;GACf,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD;IAAsB;IAAgB;GAAO,CAAA,EAC/B,CAAA;GACfC,KAAUC,IACT,kBAACC,GAAD;IAAe,WAAU;IAAzB,UAAA,CACGF,IAAS,kBAACG,GAAD;KAAoB;KAAc;IAAO,CAAA,IAAI,MACtDF,IACC,kBAACG,GAAD;KACE,GAAIH;KACJ,MAAK;KACL,WAAU;IACX,CAAA,IACC,IACS;GACb,CAAA,IAAA;EACG,EAAA,CAAA,GACT,kBAACI,GAAD;GAAc,WAAU;GAAxB,UAAA;IACE,kBAACC,GAAD;KAA0B;KAAmB;IAAO,CAAA;IACnDC;IACAC;GACW;EACC,CAAA,CAAA;CACF,CAAA,EAAA,CAAA;AAErB;AAIA,SAASd,IAAiB;CACxB,OACE,OAAO,WAAa,OACpB,uCAAuC,KAAK,SAAS,MAAM;AAE/D;AAGA,IAAMe,IAAe;AAWrB,SAASd,EAAQ,EAAE,eAAqC;CACtD,IAAM,EAAE,aAAU,qBAAkBe,EAAW;CAC/C,OACE,kBAACC,GAAD;EAAS,aAAY;EAArB,UAAA,CACE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ACD,kBAACpE,GAAD;GACE,MAAM0B,EAAY,QAAQ;GAC1B,WAAU;GAFZ,UAAA,CAIE,kBAACD,GAAD;IAAmB;IAAa,WAAU;GAAU,CAAA,GACpD,kBAAC,QAAD;IAAM,WAAU;IAAY,UAAAC,EAAY;GAAU,CAAA,CAC9C;EACA,CAAA,CAAA;C,KAfY;AAiBxB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Préférence de thème d'un compte, commune à toute la suite. */
|
|
2
|
+
export type ThemePreference = "light" | "system" | "dark";
|
|
3
|
+
export interface ThemeMenuProps {
|
|
4
|
+
valeur: ThemePreference;
|
|
5
|
+
/** Enregistre le choix. Une promesse rejetée affiche « Thème non
|
|
6
|
+
* enregistré » sous le bouton. */
|
|
7
|
+
changer: (theme: ThemePreference) => void | Promise<unknown>;
|
|
8
|
+
/** Côté où s'ouvre le menu. */
|
|
9
|
+
side?: "top" | "bottom";
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Choix du thème : un bouton dont l'icône montre le thème choisi, et qui ouvre
|
|
14
|
+
* Clair / Système / Sombre, sur le modèle du « mode toggle » de shadcn. Un menu
|
|
15
|
+
* plutôt qu'un bouton qui fait défiler les thèmes : passer à « Système » ne
|
|
16
|
+
* change souvent rien à l'écran, et un clic sans effet visible passerait pour
|
|
17
|
+
* un clic raté.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ThemeMenu({ valeur, changer, side, className, }: ThemeMenuProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Button as e } from "../ui/button.js";
|
|
2
|
+
import { DropdownMenu as t, DropdownMenuContent as n, DropdownMenuGroup as r, DropdownMenuLabel as i, DropdownMenuRadioGroup as a, DropdownMenuRadioItem as o, DropdownMenuTrigger as s } from "../ui/dropdown-menu.js";
|
|
3
|
+
import { Tooltip as c, TooltipContent as l, TooltipTrigger as u } from "../ui/tooltip.js";
|
|
4
|
+
import { cn as d } from "cn";
|
|
5
|
+
import { useRef as f, useState as p } from "react";
|
|
6
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
7
|
+
import { MonitorIcon as g, MoonIcon as _, SunIcon as v } from "lucide-react";
|
|
8
|
+
// src/components/etic/theme-menu.tsx
|
|
9
|
+
var y = {
|
|
10
|
+
light: {
|
|
11
|
+
libelle: "Clair",
|
|
12
|
+
Icone: v
|
|
13
|
+
},
|
|
14
|
+
system: {
|
|
15
|
+
libelle: "Système",
|
|
16
|
+
Icone: g
|
|
17
|
+
},
|
|
18
|
+
dark: {
|
|
19
|
+
libelle: "Sombre",
|
|
20
|
+
Icone: _
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function b({ valeur: g, changer: _, side: v = "bottom", className: b }) {
|
|
24
|
+
let [x, S] = p(!1), C = f(0), { Icone: w } = y[g], T = `Thème : ${y[g].libelle}`, E = (e) => {
|
|
25
|
+
if (S(!1), e === g) return;
|
|
26
|
+
let t = ++C.current;
|
|
27
|
+
Promise.resolve().then(() => _(e)).catch(() => {
|
|
28
|
+
t === C.current && S(!0);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ h("div", {
|
|
32
|
+
className: "relative",
|
|
33
|
+
children: [/* @__PURE__ */ h(t, {
|
|
34
|
+
onOpenChange: (e) => e && S(!1),
|
|
35
|
+
children: [/* @__PURE__ */ h(c, { children: [/* @__PURE__ */ m(u, {
|
|
36
|
+
render: /* @__PURE__ */ m(s, { render: /* @__PURE__ */ m(e, {
|
|
37
|
+
variant: "outline",
|
|
38
|
+
size: "icon",
|
|
39
|
+
className: b,
|
|
40
|
+
"aria-label": T
|
|
41
|
+
}) }),
|
|
42
|
+
children: /* @__PURE__ */ m(w, {})
|
|
43
|
+
}), /* @__PURE__ */ m(l, { children: T })] }), /* @__PURE__ */ m(n, {
|
|
44
|
+
side: v,
|
|
45
|
+
align: "end",
|
|
46
|
+
className: "w-40",
|
|
47
|
+
children: /* @__PURE__ */ h(r, { children: [/* @__PURE__ */ m(i, { children: "Thème de l'interface" }), /* @__PURE__ */ m(a, {
|
|
48
|
+
value: g,
|
|
49
|
+
onValueChange: (e) => E(e),
|
|
50
|
+
children: Object.entries(y).map(([e, { libelle: t, Icone: n }]) => /* @__PURE__ */ h(o, {
|
|
51
|
+
value: e,
|
|
52
|
+
closeOnClick: !0,
|
|
53
|
+
children: [/* @__PURE__ */ m(n, {}), t]
|
|
54
|
+
}, e))
|
|
55
|
+
})] })
|
|
56
|
+
})]
|
|
57
|
+
}), x ? /* @__PURE__ */ m("p", {
|
|
58
|
+
role: "alert",
|
|
59
|
+
className: d("absolute right-0 z-10 w-max max-w-56 rounded-md bg-popover px-2 py-1 text-xs text-destructive shadow-md ring-1 ring-foreground/10", v === "top" ? "bottom-full mb-2" : "top-full mt-2"),
|
|
60
|
+
children: "Thème non enregistré, réessayez."
|
|
61
|
+
}) : null]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export { b as ThemeMenu };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=theme-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-menu.js","names":["OPTIONS","SunIcon","MonitorIcon","MoonIcon","ThemeMenu","echec","setEchec","useState","dernierChoix","useRef","IconeActuelle","valeur","libelle","choisir","theme","numero","changer","DropdownMenu","ouvert","Tooltip","TooltipTrigger","DropdownMenuTrigger","Button","TooltipContent","DropdownMenuContent","DropdownMenuGroup","DropdownMenuLabel","DropdownMenuRadioGroup","option","DropdownMenuRadioItem","Icone","cn","side"],"sources":["../../../src/components/etic/theme-menu.tsx"],"sourcesContent":["import { useRef, useState } from \"react\"\nimport { cn } from \"cn\"\nimport { MonitorIcon, MoonIcon, SunIcon, type LucideIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuTrigger,\n} from \"@etic-ui/components/ui/dropdown-menu\"\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@etic-ui/components/ui/tooltip\"\n\n/** Préférence de thème d'un compte, commune à toute la suite. */\nexport type ThemePreference = \"light\" | \"system\" | \"dark\"\n\n// Dans l'ordre du menu.\nconst OPTIONS: Record<ThemePreference, { libelle: string; Icone: LucideIcon }> =\n {\n light: { libelle: \"Clair\", Icone: SunIcon },\n system: { libelle: \"Système\", Icone: MonitorIcon },\n dark: { libelle: \"Sombre\", Icone: MoonIcon },\n }\n\nexport interface ThemeMenuProps {\n valeur: ThemePreference\n /** Enregistre le choix. Une promesse rejetée affiche « Thème non\n * enregistré » sous le bouton. */\n changer: (theme: ThemePreference) => void | Promise<unknown>\n /** Côté où s'ouvre le menu. */\n side?: \"top\" | \"bottom\"\n className?: string\n}\n\n/**\n * Choix du thème : un bouton dont l'icône montre le thème choisi, et qui ouvre\n * Clair / Système / Sombre, sur le modèle du « mode toggle » de shadcn. Un menu\n * plutôt qu'un bouton qui fait défiler les thèmes : passer à « Système » ne\n * change souvent rien à l'écran, et un clic sans effet visible passerait pour\n * un clic raté.\n */\nexport function ThemeMenu({\n valeur,\n changer,\n side = \"bottom\",\n className,\n}: ThemeMenuProps) {\n const [echec, setEchec] = useState(false)\n // Numéro du dernier choix : l'échec d'un choix déjà remplacé ne s'affiche pas.\n const dernierChoix = useRef(0)\n const { Icone: IconeActuelle } = OPTIONS[valeur]\n const libelle = `Thème : ${OPTIONS[valeur].libelle}`\n\n const choisir = (theme: ThemePreference) => {\n setEchec(false)\n if (theme === valeur) return\n const numero = ++dernierChoix.current\n Promise.resolve()\n .then(() => changer(theme))\n .catch(() => {\n if (numero === dernierChoix.current) setEchec(true)\n })\n }\n\n return (\n <div className=\"relative\">\n <DropdownMenu onOpenChange={(ouvert) => ouvert && setEchec(false)}>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"outline\"\n size=\"icon\"\n className={className}\n aria-label={libelle}\n />\n }\n />\n }\n >\n <IconeActuelle />\n </TooltipTrigger>\n <TooltipContent>{libelle}</TooltipContent>\n </Tooltip>\n <DropdownMenuContent side={side} align=\"end\" className=\"w-40\">\n <DropdownMenuGroup>\n <DropdownMenuLabel>Thème de l'interface</DropdownMenuLabel>\n <DropdownMenuRadioGroup\n value={valeur}\n onValueChange={(theme) => choisir(theme as ThemePreference)}\n >\n {Object.entries(OPTIONS).map(([option, { libelle, Icone }]) => (\n <DropdownMenuRadioItem key={option} value={option} closeOnClick>\n <Icone />\n {libelle}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n {echec ? (\n <p\n role=\"alert\"\n className={cn(\n \"absolute right-0 z-10 w-max max-w-56 rounded-md bg-popover px-2 py-1 text-xs text-destructive shadow-md ring-1 ring-foreground/10\",\n side === \"top\" ? \"bottom-full mb-2\" : \"top-full mt-2\"\n )}\n >\n Thème non enregistré, réessayez.\n </p>\n ) : null}\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAwBA,IAAMA,IACJ;CACE,OAAO;EAAE,SAAS;EAAS,OAAOC;CAAQ;CAC1C,QAAQ;EAAE,SAAS;EAAW,OAAOC;CAAY;CACjD,MAAM;EAAE,SAAS;EAAU,OAAOC;CAAS;AAC7C;AAmBF,SAAgBC,EAAU,EACxB,WACA,YACA,UAAO,UACP,gBACiB;CACjB,IAAM,CAACC,GAAOC,KAAYC,EAAS,EAAK,GAElCC,IAAeC,EAAO,CAAC,GACvB,EAAE,OAAOC,MAAkBV,EAAQW,IACnCC,IAAU,WAAWZ,EAAQW,EAAO,CAAC,WAErCE,KAAW,MAA2B;EAE1C,IADAP,EAAS,EAAK,GACVQ,MAAUH,GAAQ;EACtB,IAAMI,IAAS,EAAEP,EAAa;EAC9B,QAAQ,QAAQ,CAAC,CACd,WAAWQ,EAAQF,CAAK,CAAC,CAAC,CAC1B,YAAY;GACX,AAAIC,MAAWP,EAAa,WAASF,EAAS,EAAI;EACpD,CAAC;CACL;CAEA,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACW,GAAD;GAAc,eAAe,MAAWC,KAAUZ,EAAS,EAAK;GAAhE,UAAA,CACE,kBAACa,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;IACE,QACE,kBAACC,GAAD,EACE,QACE,kBAACC,GAAD;KACE,SAAQ;KACR,MAAK;KACM;KACX,cAAYV;IACb,CAAA,EAEJ,CAAA;IAGH,UAAA,kBAACF,GAAD,CAAgB,CAAA;GACF,CAAA,GAChB,kBAACa,GAAD,EAAA,UAAiBX,EAAwB,CAAA,CAClC,EAAA,CAAA,GACT,kBAACY,GAAD;IAA2B;IAAM,OAAM;IAAM,WAAU;IACrD,UAAA,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAmB,uBAAuC,CAAA,GAC1D,kBAACC,GAAD;KACE,OAAOhB;KACP,gBAAgB,MAAUE,EAAQC,CAAwB;KAEzD,UAAA,OAAO,QAAQd,CAAO,CAAC,CAAC,KAAK,CAAC4B,GAAQ,EAAE,YAAS,gBAChD,kBAACC,GAAD;MAAoC,OAAOD;MAAQ,cAAA;MAAnD,UAAA,CACE,kBAACE,GAAD,CAAQ,CAAA,GACPlB,CACoB;KAHK,GAAAgB,CAGL,CACxB;IACqB,CAAA,CACP,EAAA,CAAA;GACA,CAAA,CACT;EACb,CAAA,GAAAvB,IACC,kBAAC,KAAD;GACE,MAAK;GACL,WAAW0B,EACT,qIACAC,MAAS,QAAQ,qBAAqB,eACxC;GACD,UAAA;EAEE,CAAA,IACD,IACD;;AAET"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';
|
|
2
|
+
import { Button } from './button';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
declare function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props): React.JSX.Element;
|
|
5
|
+
declare function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props): React.JSX.Element;
|
|
6
|
+
declare function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props): React.JSX.Element;
|
|
7
|
+
declare function AlertDialogOverlay({ className, ...props }: AlertDialogPrimitive.Backdrop.Props): React.JSX.Element;
|
|
8
|
+
declare function AlertDialogContent({ className, size, ...props }: AlertDialogPrimitive.Popup.Props & {
|
|
9
|
+
size?: "default" | "sm";
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
12
|
+
declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
13
|
+
declare function AlertDialogMedia({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
14
|
+
declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): React.JSX.Element;
|
|
15
|
+
declare function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): React.JSX.Element;
|
|
16
|
+
declare function AlertDialogAction({ className, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
17
|
+
declare function AlertDialogCancel({ className, variant, size, ...props }: AlertDialogPrimitive.Close.Props & Pick<React.ComponentProps<typeof Button>, "variant" | "size">): React.JSX.Element;
|
|
18
|
+
export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Button as e } from "./button.js";
|
|
2
|
+
import { cn as t } from "cn";
|
|
3
|
+
import "react";
|
|
4
|
+
import { AlertDialog as n } from "@base-ui/react/alert-dialog";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
// src/components/ui/alert-dialog.tsx
|
|
7
|
+
function a({ ...e }) {
|
|
8
|
+
return /* @__PURE__ */ r(n.Root, {
|
|
9
|
+
"data-slot": "alert-dialog",
|
|
10
|
+
...e
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function o({ ...e }) {
|
|
14
|
+
return /* @__PURE__ */ r(n.Trigger, {
|
|
15
|
+
"data-slot": "alert-dialog-trigger",
|
|
16
|
+
...e
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function s({ ...e }) {
|
|
20
|
+
return /* @__PURE__ */ r(n.Portal, {
|
|
21
|
+
"data-slot": "alert-dialog-portal",
|
|
22
|
+
...e
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function c({ className: e, ...i }) {
|
|
26
|
+
return /* @__PURE__ */ r(n.Backdrop, {
|
|
27
|
+
"data-slot": "alert-dialog-overlay",
|
|
28
|
+
className: t("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", e),
|
|
29
|
+
...i
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function l({ className: e, size: a = "default", ...o }) {
|
|
33
|
+
return /* @__PURE__ */ i(s, { children: [/* @__PURE__ */ r(c, {}), /* @__PURE__ */ r(n.Popup, {
|
|
34
|
+
"data-slot": "alert-dialog-content",
|
|
35
|
+
"data-size": a,
|
|
36
|
+
className: t("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", e),
|
|
37
|
+
...o
|
|
38
|
+
})] });
|
|
39
|
+
}
|
|
40
|
+
function u({ className: e, ...n }) {
|
|
41
|
+
return /* @__PURE__ */ r("div", {
|
|
42
|
+
"data-slot": "alert-dialog-header",
|
|
43
|
+
className: t("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", e),
|
|
44
|
+
...n
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function d({ className: e, ...n }) {
|
|
48
|
+
return /* @__PURE__ */ r("div", {
|
|
49
|
+
"data-slot": "alert-dialog-footer",
|
|
50
|
+
className: t("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end", e),
|
|
51
|
+
...n
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function f({ className: e, ...n }) {
|
|
55
|
+
return /* @__PURE__ */ r("div", {
|
|
56
|
+
"data-slot": "alert-dialog-media",
|
|
57
|
+
className: t("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6", e),
|
|
58
|
+
...n
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function p({ className: e, ...i }) {
|
|
62
|
+
return /* @__PURE__ */ r(n.Title, {
|
|
63
|
+
"data-slot": "alert-dialog-title",
|
|
64
|
+
className: t("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", e),
|
|
65
|
+
...i
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function m({ className: e, ...i }) {
|
|
69
|
+
return /* @__PURE__ */ r(n.Description, {
|
|
70
|
+
"data-slot": "alert-dialog-description",
|
|
71
|
+
className: t("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", e),
|
|
72
|
+
...i
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function h({ className: n, ...i }) {
|
|
76
|
+
return /* @__PURE__ */ r(e, {
|
|
77
|
+
"data-slot": "alert-dialog-action",
|
|
78
|
+
className: t(n),
|
|
79
|
+
...i
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function g({ className: i, variant: a = "outline", size: o = "default", ...s }) {
|
|
83
|
+
return /* @__PURE__ */ r(n.Close, {
|
|
84
|
+
"data-slot": "alert-dialog-cancel",
|
|
85
|
+
className: t(i),
|
|
86
|
+
render: /* @__PURE__ */ r(e, {
|
|
87
|
+
variant: a,
|
|
88
|
+
size: o
|
|
89
|
+
}),
|
|
90
|
+
...s
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export { a as AlertDialog, h as AlertDialogAction, g as AlertDialogCancel, l as AlertDialogContent, m as AlertDialogDescription, d as AlertDialogFooter, u as AlertDialogHeader, f as AlertDialogMedia, c as AlertDialogOverlay, s as AlertDialogPortal, p as AlertDialogTitle, o as AlertDialogTrigger };
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=alert-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-dialog.js","names":["AlertDialog","AlertDialogPrimitive","AlertDialog$1","props","AlertDialog","AlertDialogTrigger","AlertDialogPortal","AlertDialogOverlay","cn","className","AlertDialogContent","size","AlertDialogHeader","AlertDialogFooter","AlertDialogMedia","AlertDialogTitle","AlertDialogDescription","AlertDialogAction","Button","AlertDialogCancel"],"sources":["../../../src/components/ui/alert-dialog.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { AlertDialog as AlertDialogPrimitive } from \"@base-ui/react/alert-dialog\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\n\nfunction AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {\n return <AlertDialogPrimitive.Root data-slot=\"alert-dialog\" {...props} />\n}\n\nfunction AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {\n return (\n <AlertDialogPrimitive.Trigger data-slot=\"alert-dialog-trigger\" {...props} />\n )\n}\n\nfunction AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {\n return (\n <AlertDialogPrimitive.Portal data-slot=\"alert-dialog-portal\" {...props} />\n )\n}\n\nfunction AlertDialogOverlay({\n className,\n ...props\n}: AlertDialogPrimitive.Backdrop.Props) {\n return (\n <AlertDialogPrimitive.Backdrop\n data-slot=\"alert-dialog-overlay\"\n className={cn(\n \"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogContent({\n className,\n size = \"default\",\n ...props\n}: AlertDialogPrimitive.Popup.Props & {\n size?: \"default\" | \"sm\"\n}) {\n return (\n <AlertDialogPortal>\n <AlertDialogOverlay />\n <AlertDialogPrimitive.Popup\n data-slot=\"alert-dialog-content\"\n data-size={size}\n className={cn(\n \"group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n className\n )}\n {...props}\n />\n </AlertDialogPortal>\n )\n}\n\nfunction AlertDialogHeader({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-dialog-header\"\n className={cn(\n \"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogFooter({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-dialog-footer\"\n className={cn(\n \"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogMedia({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-dialog-media\"\n className={cn(\n \"mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogTitle({\n className,\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {\n return (\n <AlertDialogPrimitive.Title\n data-slot=\"alert-dialog-title\"\n className={cn(\n \"font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {\n return (\n <AlertDialogPrimitive.Description\n data-slot=\"alert-dialog-description\"\n className={cn(\n \"text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogAction({\n className,\n ...props\n}: React.ComponentProps<typeof Button>) {\n return (\n <Button\n data-slot=\"alert-dialog-action\"\n className={cn(className)}\n {...props}\n />\n )\n}\n\nfunction AlertDialogCancel({\n className,\n variant = \"outline\",\n size = \"default\",\n ...props\n}: AlertDialogPrimitive.Close.Props &\n Pick<React.ComponentProps<typeof Button>, \"variant\" | \"size\">) {\n return (\n <AlertDialogPrimitive.Close\n data-slot=\"alert-dialog-cancel\"\n className={cn(className)}\n render={<Button variant={variant} size={size} />}\n {...props}\n />\n )\n}\n\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogMedia,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger,\n}\n"],"mappings":";;;;;;AAMA,SAASA,EAAY,EAAE,GAAGG,KAA0C;CAClE,OAAO,kBAACF,EAAqB,MAAtB;EAA2B,aAAU;EAAe,GAAIE;CAAQ,CAAA;AACzE;AAEA,SAASE,EAAmB,EAAE,GAAGF,KAA6C;CAC5E,OACE,kBAACF,EAAqB,SAAtB;EAA8B,aAAU;EAAuB,GAAIE;CAAQ,CAAA;AAE/E;AAEA,SAASG,EAAkB,EAAE,GAAGH,KAA4C;CAC1E,OACE,kBAACF,EAAqB,QAAtB;EAA6B,aAAU;EAAsB,GAAIE;CAAQ,CAAA;AAE7E;AAEA,SAASI,EAAmB,EAC1B,cACA,GAAGJ,KACmC;CACtC,OACE,kBAACF,EAAqB,UAAtB;EACE,aAAU;EACV,WAAWO,EACT,yLACAC,CACF;EACA,GAAIN;CACL,CAAA;AAEL;AAEA,SAASO,EAAmB,EAC1B,cACA,UAAO,WACP,GAAGP,KAGF;CACD,OACE,kBAACG,GAAD,EAAA,UAA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@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Avatar as AvatarPrimitive } from '@base-ui/react/avatar';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare function Avatar({ className, size, ...props }: AvatarPrimitive.Root.Props & {
|
|
4
|
+
size?: "default" | "sm" | "lg";
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props): React.JSX.Element;
|
|
7
|
+
declare function AvatarFallback({ className, ...props }: AvatarPrimitive.Fallback.Props): React.JSX.Element;
|
|
8
|
+
declare function AvatarBadge({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
9
|
+
declare function AvatarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
10
|
+
declare function AvatarGroupCount({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
11
|
+
export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge, };
|