@etic-insa/ui 0.0.0-stage → 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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +193 -2
  3. package/dist/components/etic/app-shell.d.ts +69 -0
  4. package/dist/components/etic/app-shell.js +180 -0
  5. package/dist/components/etic/app-shell.js.map +1 -0
  6. package/dist/components/etic/theme-menu.d.ts +19 -0
  7. package/dist/components/etic/theme-menu.js +66 -0
  8. package/dist/components/etic/theme-menu.js.map +1 -0
  9. package/dist/components/ui/alert-dialog.d.ts +18 -0
  10. package/dist/components/ui/alert-dialog.js +95 -0
  11. package/dist/components/ui/alert-dialog.js.map +1 -0
  12. package/dist/components/ui/avatar.d.ts +11 -0
  13. package/dist/components/ui/avatar.js +52 -0
  14. package/dist/components/ui/avatar.js.map +1 -0
  15. package/dist/components/ui/button.d.ts +8 -0
  16. package/dist/components/ui/button.js +45 -0
  17. package/dist/components/ui/button.js.map +1 -0
  18. package/dist/components/ui/dropdown-menu.d.ts +29 -0
  19. package/dist/components/ui/dropdown-menu.js +137 -0
  20. package/dist/components/ui/dropdown-menu.js.map +1 -0
  21. package/dist/components/ui/input.d.ts +3 -0
  22. package/dist/components/ui/input.js +16 -0
  23. package/dist/components/ui/input.js.map +1 -0
  24. package/dist/components/ui/separator.d.ts +3 -0
  25. package/dist/components/ui/separator.js +15 -0
  26. package/dist/components/ui/separator.js.map +1 -0
  27. package/dist/components/ui/sheet.d.ts +14 -0
  28. package/dist/components/ui/sheet.js +90 -0
  29. package/dist/components/ui/sheet.js.map +1 -0
  30. package/dist/components/ui/sidebar.d.ts +63 -0
  31. package/dist/components/ui/sidebar.js +358 -0
  32. package/dist/components/ui/sidebar.js.map +1 -0
  33. package/dist/components/ui/skeleton.d.ts +2 -0
  34. package/dist/components/ui/skeleton.js +13 -0
  35. package/dist/components/ui/skeleton.js.map +1 -0
  36. package/dist/components/ui/tooltip.d.ts +6 -0
  37. package/dist/components/ui/tooltip.js +42 -0
  38. package/dist/components/ui/tooltip.js.map +1 -0
  39. package/dist/hooks/use-mobile.d.ts +18 -0
  40. package/dist/hooks/use-mobile.js +16 -0
  41. package/dist/hooks/use-mobile.js.map +1 -0
  42. package/dist/index.d.ts +14 -0
  43. package/dist/index.js +15 -0
  44. package/dist/lib/utils.d.ts +1 -0
  45. package/dist/lib/utils.js +1 -0
  46. package/dist/styles.css +802 -0
  47. package/package.json +73 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 etic-insa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,194 @@
1
- # Temporary Holding Version
1
+ # @etic-insa/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Bibliothèque de composants React des applications ETIC (ETIC Members, ETIC Docs…), construite
4
+ sur [shadcn/ui](https://ui.shadcn.com) (style Nova, couleur de base Neutral) et
5
+ [Base UI](https://base-ui.com), avec Tailwind CSS 4, les icônes lucide et la police Geist.
6
+
7
+ ## Utiliser la bibliothèque dans une application
8
+
9
+ ```sh
10
+ npm i @etic-insa/ui
11
+ ```
12
+
13
+ Prérequis : React 19 et Tailwind CSS 4 (`tailwindcss` et `@tailwindcss/vite`).
14
+
15
+ ```css
16
+ /* CSS principal de l'application */
17
+ @import "tailwindcss";
18
+ @import "@etic-insa/ui/styles.css";
19
+ /* Tailwind doit lire les classes des composants ; chemin relatif à ce fichier */
20
+ @source "../node_modules/@etic-insa/ui/dist";
21
+
22
+ /* Couleur d'accent de l'application : les quatre variables, en clair ET en sombre. */
23
+ :root {
24
+ --primary: #2f5fdb;
25
+ --primary-foreground: #ffffff;
26
+ --primary-text: #2f5fdb;
27
+ --ring: #2f5fdb;
28
+ }
29
+ .dark {
30
+ --primary: #6d92f2;
31
+ --primary-foreground: #0e1116;
32
+ --primary-text: #6d92f2;
33
+ --ring: #6d92f2;
34
+ }
35
+ ```
36
+
37
+ ### Thème et couleur d'accent
38
+
39
+ La bibliothèque fournit tout le thème (neutres, rayons, police, couleurs `destructive`, `success`
40
+ et `warning`, clair et sombre) sauf la couleur d'accent. Chaque application remplit, après
41
+ l'import de `styles.css`, en `:root` et en `.dark`, quatre variables :
42
+
43
+ | Variable | Rôle | Exigence |
44
+ | ---------------------- | ------------------------------------ | -------------------------------- |
45
+ | `--primary` | aplats : bouton principal, sélection | — |
46
+ | `--primary-foreground` | texte posé sur `--primary` | ≥ 4,5:1 sur `--primary` |
47
+ | `--primary-text` | l'accent employé comme texte ou lien | ≥ 4,5:1 sur le fond et `--muted` |
48
+ | `--ring` | anneau de focus | ≥ 3:1 sur le fond et `--muted` |
49
+
50
+ Un accent clair (orange, jaune, vert pâle) ne supporte ni texte blanc ni rôle de texte : il prend
51
+ un `--primary-foreground` foncé et un `--primary-text` plus sombre que lui.
52
+
53
+ Les couleurs appartiennent à chaque application : la bibliothèque n'en livre aucune et ne
54
+ connaît pas les applications. [`atelier/accents.css`](atelier/accents.css) contient seulement
55
+ des exemples, aux couleurs des applications ETIC, pour voir les composants avec un vrai accent
56
+ dans l'atelier ; `npm test` vérifie que ces exemples tiennent les exigences ci-dessus. Il n'est
57
+ pas publié et n'est pas la référence d'une application.
58
+
59
+ Dans les classes, l'accent comme texte s'écrit `text-primary-text`, jamais `text-primary`. Les
60
+ composants shadcn d'origine (`src/components/ui/`) emploient parfois `text-primary` (variante
61
+ `link` du bouton) : à corriger, dans le composant ou dans une enveloppe ETIC. **Limite actuelle** : le `Button`
62
+ exporté est encore celui de shadcn ; avec un accent clair (Docs, Intervenant, Browser), sa
63
+ variante `link` est illisible en thème clair. Ne pas l'employer avant son enveloppe.
64
+
65
+ Le thème sombre s'active par la classe `dark` sur `<html>`.
66
+
67
+ ```tsx
68
+ import { Button } from "@etic-insa/ui"
69
+
70
+ export function Export() {
71
+ return (
72
+ <Button variant="outline" className="w-full">
73
+ Exporter
74
+ </Button>
75
+ )
76
+ }
77
+ ```
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
+
128
+ ### Développer contre les sources locales
129
+
130
+ Pour voir une modification de la bibliothèque instantanément dans une application, sans publier,
131
+ avec le dépôt `etic-packages` cloné sur le même poste :
132
+
133
+ ```ts
134
+ // vite.config.ts de l'application : en développement seulement
135
+ // (chemin vers packages/ui/src, ici pour une application à côté d'etic-packages)
136
+ const UI_SRC = path.resolve(__dirname, "../etic-packages/packages/ui/src")
137
+
138
+ export default defineConfig(({ command }) => ({
139
+ resolve:
140
+ command === "serve"
141
+ ? {
142
+ alias: {
143
+ "@etic-insa/ui": UI_SRC,
144
+ // les composants s'importent entre eux par « @etic-ui/… »
145
+ "@etic-ui": UI_SRC,
146
+ },
147
+ // une seule copie de React, même si etic-packages a ses propres node_modules
148
+ dedupe: ["react", "react-dom"],
149
+ }
150
+ : {},
151
+ }))
152
+ ```
153
+
154
+ Côté CSS, ajouter un `@source` vers ce même dossier `src` et importer son `styles.css` au lieu
155
+ de celui du paquet.
156
+
157
+ ## Développer la bibliothèque
158
+
159
+ Node : la version de `.nvmrc` (`nvm use`). Dépôt monorepo : `npm install` à la racine
160
+ d'`etic-packages` installe tous les paquets.
161
+
162
+ ```sh
163
+ # depuis packages/ui
164
+ npm run dev # atelier : tous les composants, thème au pied de la barre latérale
165
+ npm test # vitest
166
+ npm run typecheck
167
+ npm run lint
168
+ npm run build # dist/ : un module par composant, types, styles.css
169
+ # depuis la racine : les mêmes scripts pour tous les paquets, plus npm run format:check
170
+ ```
171
+
172
+ ### Organisation
173
+
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 »).
184
+ - `src/components/etic/` : composants ETIC qui importent ceux de `ui/` et ajoutent
185
+ comportement, composition ou variantes.
186
+ - `src/index.ts` : tout ce qu'une application peut importer. Un composant non exporté ici
187
+ n'existe pas pour les applications.
188
+ - `src/styles.css` : thème commun (clair et sombre). Au build, `scripts/build-css.mjs` y recopie
189
+ `shadcn/tailwind.css`, pour que les applications n'aient pas à installer le CLI shadcn.
190
+ - `atelier/` : la page de démonstration servie par `npm run dev`. Elle n'est pas publiée.
191
+
192
+ ### Règle absolue
193
+
194
+ Le paquet et ce dépôt sont publics : aucun secret, URL interne, nom de client ni code métier.
@@ -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,kBAAC,OAAD;GACE,WAAU;GACV,UAAU,MAAU;IAClB,AAAI,CAACC,KAAYC,EAAM,WAAWA,EAAM,WAAWA,EAAM,YAG3CA,EAAM,OACV,QAAQ,aAAaJ,EAAa,EAAE,KAAGK,EAAc,EAAK;GACtE;GAEC;EACE,CAAA,G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;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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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, };