@etic-insa/ui 0.2.0 → 0.4.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 +490 -52
- package/dist/components/etic/action.d.ts +16 -7
- package/dist/components/etic/action.js +25 -25
- package/dist/components/etic/action.js.map +1 -1
- package/dist/components/etic/app-shell.d.ts +20 -8
- package/dist/components/etic/app-shell.js +164 -120
- package/dist/components/etic/app-shell.js.map +1 -1
- package/dist/components/etic/auth-image.d.ts +29 -6
- package/dist/components/etic/auth-image.js +41 -18
- package/dist/components/etic/auth-image.js.map +1 -1
- package/dist/components/etic/button-link.d.ts +19 -0
- package/dist/components/etic/button-link.js +19 -0
- package/dist/components/etic/button-link.js.map +1 -0
- package/dist/components/etic/centered-screen.d.ts +13 -0
- package/dist/components/etic/centered-screen.js +13 -0
- package/dist/components/etic/centered-screen.js.map +1 -0
- package/dist/components/etic/confirm-dialog.d.ts +33 -3
- package/dist/components/etic/confirm-dialog.js +92 -67
- package/dist/components/etic/confirm-dialog.js.map +1 -1
- package/dist/components/etic/copy-button.d.ts +3 -2
- package/dist/components/etic/copy-button.js +3 -3
- package/dist/components/etic/copy-button.js.map +1 -1
- package/dist/components/etic/data-table-bulk-actions.d.ts +41 -4
- package/dist/components/etic/data-table-bulk-actions.js +114 -60
- package/dist/components/etic/data-table-bulk-actions.js.map +1 -1
- package/dist/components/etic/data-table-focus.d.ts +17 -0
- package/dist/components/etic/data-table-focus.js +29 -0
- package/dist/components/etic/data-table-focus.js.map +1 -0
- package/dist/components/etic/data-table-format.d.ts +3 -10
- package/dist/components/etic/data-table-format.js +4 -3
- package/dist/components/etic/data-table-format.js.map +1 -1
- package/dist/components/etic/data-table-pagination.d.ts +20 -6
- package/dist/components/etic/data-table-pagination.js +73 -43
- package/dist/components/etic/data-table-pagination.js.map +1 -1
- package/dist/components/etic/data-table-toolbar.d.ts +34 -13
- package/dist/components/etic/data-table-toolbar.js +66 -62
- package/dist/components/etic/data-table-toolbar.js.map +1 -1
- package/dist/components/etic/data-table-view-options.d.ts +44 -4
- package/dist/components/etic/data-table-view-options.js +145 -98
- package/dist/components/etic/data-table-view-options.js.map +1 -1
- package/dist/components/etic/data-table.d.ts +183 -17
- package/dist/components/etic/data-table.js +396 -241
- package/dist/components/etic/data-table.js.map +1 -1
- package/dist/components/etic/date-picker.d.ts +5 -1
- package/dist/components/etic/date-picker.js +97 -84
- package/dist/components/etic/date-picker.js.map +1 -1
- package/dist/components/etic/delete-button.d.ts +12 -4
- package/dist/components/etic/delete-button.js +21 -22
- package/dist/components/etic/delete-button.js.map +1 -1
- package/dist/components/etic/detail-list.d.ts +18 -4
- package/dist/components/etic/detail-list.js +30 -20
- package/dist/components/etic/detail-list.js.map +1 -1
- package/dist/components/etic/disclosure.d.ts +52 -0
- package/dist/components/etic/disclosure.js +71 -0
- package/dist/components/etic/disclosure.js.map +1 -0
- package/dist/components/etic/draft-resume-dialog.d.ts +42 -0
- package/dist/components/etic/draft-resume-dialog.js +60 -0
- package/dist/components/etic/draft-resume-dialog.js.map +1 -0
- package/dist/components/etic/error-banner.js +34 -38
- package/dist/components/etic/error-banner.js.map +1 -1
- package/dist/components/etic/error-boundary.js +4 -3
- package/dist/components/etic/error-boundary.js.map +1 -1
- package/dist/components/etic/explained-badge.d.ts +26 -0
- package/dist/components/etic/explained-badge.js +17 -0
- package/dist/components/etic/explained-badge.js.map +1 -0
- package/dist/components/etic/file-upload.js +66 -71
- package/dist/components/etic/file-upload.js.map +1 -1
- package/dist/components/etic/form-dialog.d.ts +25 -2
- package/dist/components/etic/form-dialog.js +95 -77
- package/dist/components/etic/form-dialog.js.map +1 -1
- package/dist/components/etic/icon-toggle.d.ts +27 -9
- package/dist/components/etic/icon-toggle.js +31 -19
- package/dist/components/etic/icon-toggle.js.map +1 -1
- package/dist/components/etic/lien.d.ts +34 -0
- package/dist/components/etic/lien.js +17 -0
- package/dist/components/etic/lien.js.map +1 -0
- package/dist/components/etic/loading.d.ts +0 -8
- package/dist/components/etic/loading.js +17 -25
- package/dist/components/etic/loading.js.map +1 -1
- package/dist/components/etic/page-container.d.ts +10 -0
- package/dist/components/etic/page-container.js +9 -5
- package/dist/components/etic/page-container.js.map +1 -1
- package/dist/components/etic/page-header.d.ts +19 -5
- package/dist/components/etic/page-header.js +60 -44
- package/dist/components/etic/page-header.js.map +1 -1
- package/dist/components/etic/phone-input.d.ts +16 -0
- package/dist/components/etic/phone-input.js +71 -65
- package/dist/components/etic/phone-input.js.map +1 -1
- package/dist/components/etic/query-boundary.d.ts +25 -2
- package/dist/components/etic/query-boundary.js +24 -12
- package/dist/components/etic/query-boundary.js.map +1 -1
- package/dist/components/etic/removable-badge.d.ts +30 -0
- package/dist/components/etic/removable-badge.js +39 -0
- package/dist/components/etic/removable-badge.js.map +1 -0
- package/dist/components/etic/save-bar.d.ts +32 -0
- package/dist/components/etic/save-bar.js +45 -0
- package/dist/components/etic/save-bar.js.map +1 -0
- package/dist/components/etic/search-select.js +1 -1
- package/dist/components/etic/search-select.js.map +1 -1
- package/dist/components/etic/segmented-control.d.ts +6 -2
- package/dist/components/etic/segmented-control.js +28 -27
- package/dist/components/etic/segmented-control.js.map +1 -1
- package/dist/components/etic/stat-grid.d.ts +15 -0
- package/dist/components/etic/stat-grid.js +17 -0
- package/dist/components/etic/stat-grid.js.map +1 -0
- package/dist/components/etic/stat-tile.d.ts +10 -3
- package/dist/components/etic/stat-tile.js +32 -24
- package/dist/components/etic/stat-tile.js.map +1 -1
- package/dist/components/etic/status-badge.d.ts +2 -4
- package/dist/components/etic/status-badge.js +13 -23
- package/dist/components/etic/status-badge.js.map +1 -1
- package/dist/components/etic/tailles-dialogue.d.ts +8 -0
- package/dist/components/etic/tailles-dialogue.js +10 -0
- package/dist/components/etic/tailles-dialogue.js.map +1 -0
- package/dist/components/etic/theme-menu.d.ts +29 -2
- package/dist/components/etic/theme-menu.js +75 -44
- package/dist/components/etic/theme-menu.js.map +1 -1
- package/dist/components/etic/toggletip.d.ts +36 -0
- package/dist/components/etic/toggletip.js +59 -0
- package/dist/components/etic/toggletip.js.map +1 -0
- package/dist/components/etic/tooltip-button.d.ts +17 -3
- package/dist/components/etic/tooltip-button.js +19 -19
- package/dist/components/etic/tooltip-button.js.map +1 -1
- package/dist/components/etic/unsaved-changes.d.ts +41 -0
- package/dist/components/etic/unsaved-changes.js +17 -0
- package/dist/components/etic/unsaved-changes.js.map +1 -0
- package/dist/components/etic/use-draft-autosave.d.ts +3 -1
- package/dist/components/etic/use-draft-autosave.js +74 -78
- package/dist/components/etic/use-draft-autosave.js.map +1 -1
- package/dist/components/etic/use-unsaved-changes-warning.d.ts +10 -0
- package/dist/components/etic/use-unsaved-changes-warning.js +20 -0
- package/dist/components/etic/use-unsaved-changes-warning.js.map +1 -0
- package/dist/components/ui/alert-dialog.js +2 -2
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/avatar.d.ts +5 -1
- package/dist/components/ui/avatar.js +20 -11
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +3 -2
- package/dist/components/ui/badge.js +27 -14
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.js +13 -13
- package/dist/components/ui/button.d.ts +15 -2
- package/dist/components/ui/button.js +29 -17
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/combobox.d.ts +2 -2
- package/dist/components/ui/combobox.js +45 -32
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/dialog.d.ts +10 -1
- package/dist/components/ui/dialog.js +12 -5
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/popover.d.ts +1 -1
- package/dist/components/ui/popover.js +3 -2
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts +16 -2
- package/dist/components/ui/progress.js +34 -26
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/select.d.ts +10 -2
- package/dist/components/ui/select.js +70 -50
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +6 -1
- package/dist/components/ui/sidebar.js +92 -92
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/spinner.d.ts +7 -1
- package/dist/components/ui/spinner.js +9 -1
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.js +2 -2
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts +7 -2
- package/dist/components/ui/tooltip.js +27 -19
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/hooks/use-column-prefs.d.ts +84 -0
- package/dist/hooks/use-column-prefs.js +71 -0
- package/dist/hooks/use-column-prefs.js.map +1 -0
- package/dist/hooks/use-debounced-value.d.ts +13 -0
- package/dist/hooks/use-debounced-value.js +12 -0
- package/dist/hooks/use-debounced-value.js.map +1 -0
- package/dist/hooks/use-document-title.d.ts +5 -0
- package/dist/hooks/use-document-title.js +13 -0
- package/dist/hooks/use-document-title.js.map +1 -0
- package/dist/hooks/use-persisted-state.d.ts +43 -0
- package/dist/hooks/use-persisted-state.js +40 -0
- package/dist/hooks/use-persisted-state.js.map +1 -0
- package/dist/index.d.ts +40 -16
- package/dist/index.js +99 -76
- package/dist/lib/autofill.d.ts +18 -0
- package/dist/lib/autofill.js +10 -0
- package/dist/lib/autofill.js.map +1 -0
- package/dist/lib/dates.d.ts +20 -0
- package/dist/lib/dates.js +16 -0
- package/dist/lib/dates.js.map +1 -0
- package/dist/lib/focus-rendu.d.ts +24 -0
- package/dist/lib/focus-rendu.js +14 -0
- package/dist/lib/focus-rendu.js.map +1 -0
- package/dist/lib/format.d.ts +54 -0
- package/dist/lib/format.js +80 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/normalize.d.ts +28 -0
- package/dist/lib/normalize.js +21 -0
- package/dist/lib/normalize.js.map +1 -0
- package/dist/lib/ordre-colonnes.d.ts +15 -0
- package/dist/lib/ordre-colonnes.js +14 -0
- package/dist/lib/ordre-colonnes.js.map +1 -0
- package/dist/lib/ton.d.ts +23 -0
- package/dist/lib/ton.js +51 -0
- package/dist/lib/ton.js.map +1 -0
- package/dist/styles.css +141 -56
- package/dist/theme.d.ts +34 -0
- package/dist/theme.js +45 -0
- package/dist/theme.js.map +1 -0
- package/package.json +4 -2
- package/src/theme-boot.js +22 -0
|
@@ -2,103 +2,119 @@ import { Breadcrumb as e, BreadcrumbItem as t, BreadcrumbLink as n, BreadcrumbLi
|
|
|
2
2
|
import { Button as o } from "../ui/button.js";
|
|
3
3
|
import { DropdownMenu as s, DropdownMenuContent as c, DropdownMenuItem as l, DropdownMenuTrigger as u } from "../ui/dropdown-menu.js";
|
|
4
4
|
import { Tooltip as d, TooltipContent as f, TooltipTrigger as p } from "../ui/tooltip.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Fragment as g
|
|
8
|
-
import {
|
|
5
|
+
import { useLien as m } from "./lien.js";
|
|
6
|
+
import { cn as h } from "cn";
|
|
7
|
+
import { Fragment as g } from "react";
|
|
8
|
+
import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
9
|
+
import { EllipsisIcon as b } from "lucide-react";
|
|
9
10
|
// src/components/etic/page-header.tsx
|
|
10
|
-
function
|
|
11
|
-
return /* @__PURE__ */
|
|
11
|
+
function x({ titre: e, description: t, actions: n, tailleActions: r = "lg", className: i }) {
|
|
12
|
+
return /* @__PURE__ */ y("div", {
|
|
12
13
|
"data-slot": "page-header",
|
|
13
|
-
className:
|
|
14
|
-
children: [/* @__PURE__ */
|
|
14
|
+
className: h("flex flex-wrap items-start justify-between gap-x-4 gap-y-3", i),
|
|
15
|
+
children: [/* @__PURE__ */ y("div", {
|
|
15
16
|
className: "flex min-w-0 flex-col gap-1",
|
|
16
|
-
children: [/* @__PURE__ */
|
|
17
|
+
children: [/* @__PURE__ */ v("h1", {
|
|
17
18
|
className: "font-heading text-2xl font-semibold tracking-tight",
|
|
18
19
|
children: e
|
|
19
|
-
}), t ? /* @__PURE__ */
|
|
20
|
+
}), t ? /* @__PURE__ */ v("p", {
|
|
20
21
|
className: "text-sm text-muted-foreground",
|
|
21
22
|
children: t
|
|
22
23
|
}) : null]
|
|
23
|
-
}), n ? /* @__PURE__ */
|
|
24
|
+
}), n ? /* @__PURE__ */ v(S, {
|
|
25
|
+
taille: r,
|
|
26
|
+
children: n
|
|
27
|
+
}) : null]
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
function S({ taille: e, children: t }) {
|
|
31
|
+
return /* @__PURE__ */ v("div", {
|
|
32
|
+
"data-echelle": e,
|
|
33
|
+
className: h("flex flex-wrap items-center gap-2", C[e]),
|
|
34
|
+
children: t
|
|
30
35
|
});
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
var C = {
|
|
38
|
+
default: "[--bouton-hauteur:2rem] [--bouton-icone:2rem]",
|
|
39
|
+
lg: "[--bouton-hauteur:2.25rem] [--bouton-icone:2.25rem]"
|
|
40
|
+
};
|
|
41
|
+
function w({ chemin: o = [], titre: s, badges: c, meta: l, actions: u, actionsSecondaires: d = [], tailleActions: f = "lg", compact: p = !1, lien: _, className: b }) {
|
|
42
|
+
let x = m(_), C = u || d.length > 0 ? /* @__PURE__ */ y(S, {
|
|
43
|
+
taille: f,
|
|
44
|
+
children: [u, d.length > 0 ? /* @__PURE__ */ v(T, {
|
|
45
|
+
actions: d,
|
|
46
|
+
taille: f
|
|
47
|
+
}) : null]
|
|
48
|
+
}) : null, w = o.map(({ libelle: e, href: r }, i) => /* @__PURE__ */ y(g, { children: [/* @__PURE__ */ v(t, { children: /* @__PURE__ */ v(n, {
|
|
49
|
+
render: /* @__PURE__ */ v(x, { href: r }),
|
|
35
50
|
children: e
|
|
36
|
-
}) }), /* @__PURE__ */
|
|
37
|
-
return
|
|
51
|
+
}) }), /* @__PURE__ */ v(a, {})] }, i));
|
|
52
|
+
return p && o.length > 0 ? /* @__PURE__ */ y("div", {
|
|
38
53
|
"data-slot": "detail-header",
|
|
39
|
-
className:
|
|
40
|
-
children: [/* @__PURE__ */
|
|
54
|
+
className: h("flex flex-wrap items-center justify-between gap-x-4 gap-y-2", b),
|
|
55
|
+
children: [/* @__PURE__ */ v(e, {
|
|
41
56
|
className: "min-w-0",
|
|
42
|
-
children: /* @__PURE__ */
|
|
57
|
+
children: /* @__PURE__ */ y(r, { children: [w, /* @__PURE__ */ y(t, { children: [/* @__PURE__ */ v("h1", {
|
|
43
58
|
className: "text-sm font-medium",
|
|
44
|
-
children: /* @__PURE__ */
|
|
59
|
+
children: /* @__PURE__ */ v(i, {
|
|
45
60
|
role: void 0,
|
|
46
61
|
"aria-disabled": void 0,
|
|
47
62
|
children: s
|
|
48
63
|
})
|
|
49
64
|
}), c] })] })
|
|
50
|
-
}),
|
|
51
|
-
}) : /* @__PURE__ */
|
|
65
|
+
}), C]
|
|
66
|
+
}) : /* @__PURE__ */ y("div", {
|
|
52
67
|
"data-slot": "detail-header",
|
|
53
|
-
className:
|
|
54
|
-
children: [o.length > 0 ? /* @__PURE__ */
|
|
68
|
+
className: h("flex flex-col gap-3", b),
|
|
69
|
+
children: [o.length > 0 ? /* @__PURE__ */ v(e, { children: /* @__PURE__ */ y(r, { children: [w, /* @__PURE__ */ v(t, { children: /* @__PURE__ */ v(i, { children: s }) })] }) }) : null, /* @__PURE__ */ y("div", {
|
|
55
70
|
className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-3",
|
|
56
|
-
children: [/* @__PURE__ */
|
|
71
|
+
children: [/* @__PURE__ */ y("div", {
|
|
57
72
|
className: "flex min-w-0 flex-col gap-1",
|
|
58
|
-
children: [/* @__PURE__ */
|
|
73
|
+
children: [/* @__PURE__ */ y("div", {
|
|
59
74
|
className: "flex flex-wrap items-center gap-2",
|
|
60
|
-
children: [/* @__PURE__ */
|
|
75
|
+
children: [/* @__PURE__ */ v("h1", {
|
|
61
76
|
className: "font-heading text-2xl font-semibold tracking-tight break-words",
|
|
62
77
|
children: s
|
|
63
78
|
}), c]
|
|
64
|
-
}), l ? /* @__PURE__ */
|
|
79
|
+
}), l ? /* @__PURE__ */ v("p", {
|
|
65
80
|
className: "text-sm break-words text-muted-foreground",
|
|
66
81
|
children: l
|
|
67
82
|
}) : null]
|
|
68
|
-
}),
|
|
83
|
+
}), C]
|
|
69
84
|
})]
|
|
70
85
|
});
|
|
71
86
|
}
|
|
72
|
-
function
|
|
73
|
-
return /* @__PURE__ */
|
|
74
|
-
render: /* @__PURE__ */
|
|
87
|
+
function T({ actions: e, taille: t }) {
|
|
88
|
+
return /* @__PURE__ */ y(s, { children: [/* @__PURE__ */ y(d, { children: [/* @__PURE__ */ v(p, {
|
|
89
|
+
render: /* @__PURE__ */ v(u, { render: /* @__PURE__ */ v(o, {
|
|
75
90
|
variant: "outline",
|
|
76
91
|
size: "icon",
|
|
77
92
|
"aria-label": "Plus d'actions"
|
|
78
93
|
}) }),
|
|
79
|
-
children: /* @__PURE__ */
|
|
80
|
-
}), /* @__PURE__ */
|
|
94
|
+
children: /* @__PURE__ */ v(b, {})
|
|
95
|
+
}), /* @__PURE__ */ v(f, { children: "Plus d'actions" })] }), /* @__PURE__ */ v(c, {
|
|
81
96
|
align: "end",
|
|
97
|
+
sideOffset: t === "lg" ? 6 : 4,
|
|
82
98
|
className: "min-w-48",
|
|
83
|
-
children: e.map(({ libelle: e, onChoisir: t, icone: n, destructif: r, verrou: i }, a) => /* @__PURE__ */
|
|
99
|
+
children: e.map(({ libelle: e, onChoisir: t, icone: n, destructif: r, verrou: i }, a) => /* @__PURE__ */ v(l, {
|
|
84
100
|
variant: r ? "destructive" : "default",
|
|
85
101
|
disabled: !!i,
|
|
86
102
|
onClick: t,
|
|
87
103
|
className: i ? "data-disabled:opacity-100" : void 0,
|
|
88
|
-
children: i ? /* @__PURE__ */
|
|
104
|
+
children: i ? /* @__PURE__ */ y(_, { children: [n ? /* @__PURE__ */ v(n, { className: "opacity-50" }) : null, /* @__PURE__ */ y("span", {
|
|
89
105
|
className: "flex flex-col",
|
|
90
|
-
children: [/* @__PURE__ */
|
|
106
|
+
children: [/* @__PURE__ */ v("span", {
|
|
91
107
|
className: "opacity-50",
|
|
92
108
|
children: e
|
|
93
|
-
}), /* @__PURE__ */
|
|
109
|
+
}), /* @__PURE__ */ v("span", {
|
|
94
110
|
"data-slot": "detail-header-raison",
|
|
95
111
|
className: "text-xs text-muted-foreground",
|
|
96
112
|
children: i
|
|
97
113
|
})]
|
|
98
|
-
})] }) : /* @__PURE__ */
|
|
114
|
+
})] }) : /* @__PURE__ */ y(_, { children: [n ? /* @__PURE__ */ v(n, {}) : null, e] })
|
|
99
115
|
}, a))
|
|
100
116
|
})] });
|
|
101
117
|
}
|
|
102
|
-
export {
|
|
118
|
+
export { w as DetailHeader, x as PageHeader };
|
|
103
119
|
|
|
104
120
|
//# sourceMappingURL=page-header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header.js","names":["_Fragment","Fragment$1","PageHeader","cn","className","titre","description","actions","Actions","DetailHeader","Lien","lesActions","actionsSecondaires","MenuActions","etapes","chemin","Fragment","BreadcrumbItem","BreadcrumbLink","libelle","BreadcrumbSeparator","index","compact","Breadcrumb","BreadcrumbList","BreadcrumbPage","badges","meta","DropdownMenu","Tooltip","TooltipTrigger","DropdownMenuTrigger","Button","EllipsisIcon","TooltipContent","DropdownMenuContent","Icone","DropdownMenuItem","destructif","verrou","onChoisir"],"sources":["../../../src/components/etic/page-header.tsx"],"sourcesContent":["import { Fragment, type ReactNode } from \"react\"\nimport { cn } from \"cn\"\nimport { EllipsisIcon, type LucideIcon } from \"lucide-react\"\n\nimport {\n Breadcrumb,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n} from \"@etic-ui/components/ui/breadcrumb\"\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"@etic-ui/components/ui/dropdown-menu\"\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@etic-ui/components/ui/tooltip\"\nimport type { AppShellLienComposant } from \"@etic-ui/components/etic/app-shell\"\n\nexport interface PageHeaderProps {\n titre: ReactNode\n /** Ligne discrète sous le titre. */\n description?: ReactNode\n /** Boutons à droite (créer, exporter…) ; passent dessous sur un écran étroit. */\n actions?: ReactNode\n className?: string\n}\n\n/** En-tête d'une page : titre (le `<h1>`) et description à gauche, actions\n * à droite. */\nexport function PageHeader({\n titre,\n description,\n actions,\n className,\n}: PageHeaderProps) {\n return (\n <div\n data-slot=\"page-header\"\n className={cn(\n \"flex flex-wrap items-start justify-between gap-x-4 gap-y-3\",\n className\n )}\n >\n <div className=\"flex min-w-0 flex-col gap-1\">\n <h1 className=\"font-heading text-2xl font-semibold tracking-tight\">\n {titre}\n </h1>\n {description ? (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n ) : null}\n </div>\n {actions ? <Actions>{actions}</Actions> : null}\n </div>\n )\n}\n\nfunction Actions({ children }: { children: ReactNode }) {\n return <div className=\"flex flex-wrap items-center gap-2\">{children}</div>\n}\n\n/** Étape du fil d'Ariane, de la plus générale à la plus proche. */\nexport interface DetailHeaderEtape {\n libelle: string\n href: string\n}\n\n/** Action rare ou destructive, rangée sous « Plus d'actions ». */\nexport interface DetailHeaderActionSecondaire {\n libelle: string\n onChoisir: () => void\n icone?: LucideIcon\n /** En rouge. */\n destructif?: boolean\n /** Action impossible : l'entrée est grisée, ne fait rien, et cette raison\n * s'affiche sous son libellé (comme `verrou` de `TooltipButton`). */\n verrou?: string\n}\n\nexport interface DetailHeaderProps {\n /**\n * Où se trouve la fiche : le fil d'Ariane, qui y ramène quel que soit\n * l'historique du navigateur. La fiche elle-même (le titre) en est la\n * dernière étape.\n */\n chemin?: DetailHeaderEtape[]\n titre: string\n /** À côté du titre : badges de statut, marqueurs. */\n badges?: ReactNode\n /** Ligne discrète sous le titre : un code, une adresse. */\n meta?: ReactNode\n /** Actions courantes, en boutons. */\n actions?: ReactNode\n /** Actions rares ou destructives, derrière « Plus d'actions ». */\n actionsSecondaires?: DetailHeaderActionSecondaire[]\n /**\n * Fiche dont la première carte répète déjà le nom : le fil d'Ariane porte\n * seul le titre (le `<h1>`), actions sur la même ligne. Demande `chemin`.\n */\n compact?: boolean\n /** Composant de lien du routeur, comme pour `AppShell`. */\n lien?: AppShellLienComposant\n className?: string\n}\n\n/** En-tête d'une fiche (un élément d'une liste) : fil d'Ariane, titre,\n * badges, méta, actions courantes et menu des actions rares. */\nexport function DetailHeader({\n chemin = [],\n titre,\n badges,\n meta,\n actions,\n actionsSecondaires = [],\n compact = false,\n lien: Lien = \"a\",\n className,\n}: DetailHeaderProps) {\n const lesActions =\n actions || actionsSecondaires.length > 0 ? (\n <Actions>\n {actions}\n {actionsSecondaires.length > 0 ? (\n <MenuActions actions={actionsSecondaires} />\n ) : null}\n </Actions>\n ) : null\n\n const etapes = chemin.map(({ libelle, href }, index) => (\n <Fragment key={index}>\n <BreadcrumbItem>\n <BreadcrumbLink render={<Lien href={href} />}>{libelle}</BreadcrumbLink>\n </BreadcrumbItem>\n <BreadcrumbSeparator />\n </Fragment>\n ))\n\n // La dernière étape devient le titre de la page : sans elle, la page\n // n'aurait plus de <h1>.\n if (compact && chemin.length > 0) {\n return (\n <div\n data-slot=\"detail-header\"\n className={cn(\n \"flex flex-wrap items-center justify-between gap-x-4 gap-y-2\",\n className\n )}\n >\n <Breadcrumb className=\"min-w-0\">\n <BreadcrumbList>\n {etapes}\n <BreadcrumbItem>\n <h1 className=\"text-sm font-medium\">\n {/* Sans le rôle de lien désactivé de shadcn : le titre de la\n page ne s'annonce pas « lien, indisponible ». */}\n <BreadcrumbPage role={undefined} aria-disabled={undefined}>\n {titre}\n </BreadcrumbPage>\n </h1>\n {badges}\n </BreadcrumbItem>\n </BreadcrumbList>\n </Breadcrumb>\n {lesActions}\n </div>\n )\n }\n\n return (\n <div\n data-slot=\"detail-header\"\n className={cn(\"flex flex-col gap-3\", className)}\n >\n {chemin.length > 0 ? (\n <Breadcrumb>\n <BreadcrumbList>\n {etapes}\n <BreadcrumbItem>\n <BreadcrumbPage>{titre}</BreadcrumbPage>\n </BreadcrumbItem>\n </BreadcrumbList>\n </Breadcrumb>\n ) : null}\n <div className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-3\">\n <div className=\"flex min-w-0 flex-col gap-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h1 className=\"font-heading text-2xl font-semibold tracking-tight break-words\">\n {titre}\n </h1>\n {badges}\n </div>\n {meta ? (\n <p className=\"text-sm break-words text-muted-foreground\">{meta}</p>\n ) : null}\n </div>\n {lesActions}\n </div>\n </div>\n )\n}\n\nfunction MenuActions({ actions }: { actions: DetailHeaderActionSecondaire[] }) {\n return (\n <DropdownMenu>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"outline\"\n size=\"icon\"\n aria-label=\"Plus d'actions\"\n />\n }\n />\n }\n >\n <EllipsisIcon />\n </TooltipTrigger>\n <TooltipContent>Plus d'actions</TooltipContent>\n </Tooltip>\n <DropdownMenuContent align=\"end\" className=\"min-w-48\">\n {actions.map(\n ({ libelle, onChoisir, icone: Icone, destructif, verrou }, index) => (\n <DropdownMenuItem\n key={index}\n variant={destructif ? \"destructive\" : \"default\"}\n disabled={!!verrou}\n onClick={onChoisir}\n // La raison doit rester lisible (4,5:1) : seuls l'icône et le\n // libellé sont estompés, pas toute l'entrée.\n className={verrou ? \"data-disabled:opacity-100\" : undefined}\n >\n {verrou ? (\n <>\n {Icone ? <Icone className=\"opacity-50\" /> : null}\n {/* Une entrée désactivée ne reçoit pas le survol : la\n raison s'affiche sous le libellé. */}\n <span className=\"flex flex-col\">\n <span className=\"opacity-50\">{libelle}</span>\n <span\n data-slot=\"detail-header-raison\"\n className=\"text-xs text-muted-foreground\"\n >\n {verrou}\n </span>\n </span>\n </>\n ) : (\n <>\n {Icone ? <Icone /> : null}\n {libelle}\n </>\n )}\n </DropdownMenuItem>\n )\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n"],"mappings":";;;;;;;;;AAqCA,SAAgBE,EAAW,EACzB,UACA,gBACA,YACA,gBACkB;CAClB,OACE,kBAAC,OAAD;EACE,aAAU;EACV,WAAWC,EACT,8DACAC,CACF;EALF,UAAA,CAOE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,MAAD;IAAI,WAAU;IACX,UAAAC;GACC,CAAA,GACHC,IACC,kBAAC,KAAD;IAAG,WAAU;IAAiC,UAAAA;GAAe,CAAA,IAC3D,IACD;EACJ,CAAA,GAAAC,IAAU,kBAACC,GAAD,EAAA,UAAUD,EAAiB,CAAA,IAAI,IACvC;;AAET;AAEA,SAASC,EAAQ,EAAE,eAAqC;CACtD,OAAO,kBAAC,OAAD;EAAK,WAAU;EAAqC;CAAc,CAAA;AAC3E;AAgDA,SAAgBC,EAAa,EAC3B,YAAS,CAAC,GACV,UACA,WACA,SACA,YACA,wBAAqB,CAAC,GACtB,aAAU,IACV,MAAMC,IAAO,KACb,gBACoB;CACpB,IAAMC,IACJJ,KAAWK,EAAmB,SAAS,IACrC,kBAACJ,GAAD,EAAA,UAAA,CACGD,GACAK,EAAmB,SAAS,IAC3B,kBAACC,GAAD,EAAa,SAASD,EAAqB,CAAA,IACzC,IACG,EAAA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ChE,IACD;GACJ,CAAA,GAAAhB,CACE;EACF,CAAA,CAAA;;AAET;AAEA,SAASE,EAAY,EAAE,cAAwD;CAC7E,OACE,kBAACe,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;EACE,QACE,kBAACC,GAAD,EACE,QACE,kBAACC,GAAD;GACE,SAAQ;GACR,MAAK;GACL,cAAW;EACZ,CAAA,EAEJ,CAAA;EAGH,UAAA,kBAACC,GAAD,CAAe,CAAA;CACD,CAAA,GAChB,kBAACC,GAAD,EAAA,UAAgB,iBAA8B,CAAA,CACvC,EAAA,CAAA,GACT,kBAACC,GAAD;EAAqB,OAAM;EAAM,WAAU;EACxC,UAAA5B,EAAQ,KACN,EAAE,YAAS,cAAW,OAAO6B,GAAO,eAAY,aAAU,MACzD,kBAACC,GAAD;GAEE,SAASC,IAAa,gBAAgB;GACtC,UAAU,CAAC,CAACC;GACZ,SAASC;GAGT,WAAWD,IAAS,8BAA8B,KAAA;GAEjD,UAAAA,IACC,kBAAAvC,GAAA,EAAA,UAAA,CACGoC,IAAQ,kBAACA,GAAD,EAAO,WAAU,aAAc,CAAA,IAAI,MAG5C,kBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,kBAAC,QAAD;KAAM,WAAU;KAAc,UAAAjB;IAAc,CAAA,GAC5C,kBAAC,QAAD;KACE,aAAU;KACV,WAAU;KAET,UAAAoB;IACG,CAAA,CACF;GACN,CAAA,CAAA,EAAA,CAAA,IAEF,kBAAAvC,GAAA,EAAA,UAAA,CACGoC,IAAQ,kBAACA,GAAD,CAAQ,CAAA,IAAI,MACpBjB,CACD,EAAA,CAAA;EAEY,GA7BXE,CA6BW,CAEtB;CACmB,CAAA,CACT,EAAA,CAAA;AAElB"}
|
|
1
|
+
{"version":3,"file":"page-header.js","names":["_Fragment","Fragment$1","PageHeader","cn","className","titre","description","actions","Actions","tailleActions","taille","ECHELLES","DetailHeader","Lien","useLien","lien","lesActions","actionsSecondaires","MenuActions","etapes","chemin","Fragment","BreadcrumbItem","BreadcrumbLink","libelle","BreadcrumbSeparator","index","compact","Breadcrumb","BreadcrumbList","BreadcrumbPage","badges","meta","DropdownMenu","Tooltip","TooltipTrigger","DropdownMenuTrigger","Button","EllipsisIcon","TooltipContent","DropdownMenuContent","Icone","DropdownMenuItem","destructif","verrou","onChoisir"],"sources":["../../../src/components/etic/page-header.tsx"],"sourcesContent":["import { Fragment, type ReactNode } from \"react\"\nimport { cn } from \"cn\"\nimport { EllipsisIcon, type LucideIcon } from \"lucide-react\"\n\nimport {\n Breadcrumb,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n} from \"@etic-ui/components/ui/breadcrumb\"\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"@etic-ui/components/ui/dropdown-menu\"\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@etic-ui/components/ui/tooltip\"\nimport { useLien, type LienComposant } from \"@etic-ui/components/etic/lien\"\n\nexport interface PageHeaderProps {\n titre: ReactNode\n /** Ligne discrète sous le titre. */\n description?: ReactNode\n /** Boutons à droite (créer, exporter…) ; passent dessous sur un écran étroit. */\n actions?: ReactNode\n /**\n * Taille des boutons de `actions` : `lg` par défaut (36 px), sans `size`\n * à leur donner — `default` et `icon` y deviennent `lg` et `icon-lg`.\n * `\"default\"` garde les tailles données.\n */\n tailleActions?: TailleActions\n className?: string\n}\n\ntype TailleActions = \"default\" | \"lg\"\n\n/** En-tête d'une page : titre (le `<h1>`) et description à gauche, actions\n * à droite. */\nexport function PageHeader({\n titre,\n description,\n actions,\n tailleActions = \"lg\",\n className,\n}: PageHeaderProps) {\n return (\n <div\n data-slot=\"page-header\"\n className={cn(\n \"flex flex-wrap items-start justify-between gap-x-4 gap-y-3\",\n className\n )}\n >\n <div className=\"flex min-w-0 flex-col gap-1\">\n <h1 className=\"font-heading text-2xl font-semibold tracking-tight\">\n {titre}\n </h1>\n {description ? (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n ) : null}\n </div>\n {actions ? <Actions taille={tailleActions}>{actions}</Actions> : null}\n </div>\n )\n}\n\nfunction Actions({\n taille,\n children,\n}: {\n taille: TailleActions\n children: ReactNode\n}) {\n // Hauteur des tailles `default` et `icon` de `Button` (et de tout\n // `buttonVariants`) dans cette zone : héritée par ses descendants, pas par\n // un dialogue ouvert d'ici (rendu dans un portail). Posée aussi à\n // `default`, pour ne pas hériter d'une zone `lg` englobante.\n return (\n <div\n data-echelle={taille}\n className={cn(\"flex flex-wrap items-center gap-2\", ECHELLES[taille])}\n >\n {children}\n </div>\n )\n}\n\nconst ECHELLES: Record<TailleActions, string> = {\n default: \"[--bouton-hauteur:2rem] [--bouton-icone:2rem]\",\n lg: \"[--bouton-hauteur:2.25rem] [--bouton-icone:2.25rem]\",\n}\n\n/** Étape du fil d'Ariane, de la plus générale à la plus proche. */\nexport interface DetailHeaderEtape {\n libelle: string\n href: string\n}\n\n/** Action rare ou destructive, rangée sous « Plus d'actions ». */\nexport interface DetailHeaderActionSecondaire {\n libelle: string\n onChoisir: () => void\n icone?: LucideIcon\n /** En rouge. */\n destructif?: boolean\n /** Action impossible : l'entrée est grisée, ne fait rien, et cette raison\n * s'affiche sous son libellé (comme `verrou` de `TooltipButton`). */\n verrou?: string\n}\n\nexport interface DetailHeaderProps {\n /**\n * Où se trouve la fiche : le fil d'Ariane, qui y ramène quel que soit\n * l'historique du navigateur. La fiche elle-même (le titre) en est la\n * dernière étape.\n */\n chemin?: DetailHeaderEtape[]\n titre: string\n /** À côté du titre : badges de statut, marqueurs. */\n badges?: ReactNode\n /** Ligne discrète sous le titre : un code, une adresse. */\n meta?: ReactNode\n /** Actions courantes, en boutons. */\n actions?: ReactNode\n /** Actions rares ou destructives, derrière « Plus d'actions ». */\n actionsSecondaires?: DetailHeaderActionSecondaire[]\n /**\n * Taille des boutons de `actions` et du bouton « Plus d'actions » : `lg`\n * par défaut, comme `PageHeader` (voir sa `tailleActions`).\n */\n tailleActions?: TailleActions\n /**\n * Fiche dont la première carte répète déjà le nom : le fil d'Ariane porte\n * seul le titre (le `<h1>`), actions sur la même ligne. Demande `chemin`.\n */\n compact?: boolean\n /** Composant de lien du routeur ; par défaut, celui du `LienProvider`,\n * sinon un `<a>`. */\n lien?: LienComposant\n className?: string\n}\n\n/** En-tête d'une fiche (un élément d'une liste) : fil d'Ariane, titre,\n * badges, méta, actions courantes et menu des actions rares. */\nexport function DetailHeader({\n chemin = [],\n titre,\n badges,\n meta,\n actions,\n actionsSecondaires = [],\n tailleActions = \"lg\",\n compact = false,\n lien,\n className,\n}: DetailHeaderProps) {\n const Lien = useLien(lien)\n const lesActions =\n actions || actionsSecondaires.length > 0 ? (\n <Actions taille={tailleActions}>\n {actions}\n {actionsSecondaires.length > 0 ? (\n <MenuActions actions={actionsSecondaires} taille={tailleActions} />\n ) : null}\n </Actions>\n ) : null\n\n const etapes = chemin.map(({ libelle, href }, index) => (\n <Fragment key={index}>\n <BreadcrumbItem>\n <BreadcrumbLink render={<Lien href={href} />}>{libelle}</BreadcrumbLink>\n </BreadcrumbItem>\n <BreadcrumbSeparator />\n </Fragment>\n ))\n\n // La dernière étape devient le titre de la page : sans elle, la page\n // n'aurait plus de <h1>.\n if (compact && chemin.length > 0) {\n return (\n <div\n data-slot=\"detail-header\"\n className={cn(\n \"flex flex-wrap items-center justify-between gap-x-4 gap-y-2\",\n className\n )}\n >\n <Breadcrumb className=\"min-w-0\">\n <BreadcrumbList>\n {etapes}\n <BreadcrumbItem>\n <h1 className=\"text-sm font-medium\">\n {/* Sans le rôle de lien désactivé de shadcn : le titre de la\n page ne s'annonce pas « lien, indisponible ». */}\n <BreadcrumbPage role={undefined} aria-disabled={undefined}>\n {titre}\n </BreadcrumbPage>\n </h1>\n {badges}\n </BreadcrumbItem>\n </BreadcrumbList>\n </Breadcrumb>\n {lesActions}\n </div>\n )\n }\n\n return (\n <div\n data-slot=\"detail-header\"\n className={cn(\"flex flex-col gap-3\", className)}\n >\n {chemin.length > 0 ? (\n <Breadcrumb>\n <BreadcrumbList>\n {etapes}\n <BreadcrumbItem>\n <BreadcrumbPage>{titre}</BreadcrumbPage>\n </BreadcrumbItem>\n </BreadcrumbList>\n </Breadcrumb>\n ) : null}\n <div className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-3\">\n <div className=\"flex min-w-0 flex-col gap-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h1 className=\"font-heading text-2xl font-semibold tracking-tight break-words\">\n {titre}\n </h1>\n {badges}\n </div>\n {meta ? (\n <p className=\"text-sm break-words text-muted-foreground\">{meta}</p>\n ) : null}\n </div>\n {lesActions}\n </div>\n </div>\n )\n}\n\nfunction MenuActions({\n actions,\n taille,\n}: {\n actions: DetailHeaderActionSecondaire[]\n taille: TailleActions\n}) {\n return (\n <DropdownMenu>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n // `icon` : l'échelle de la zone (`data-echelle`) l'agrandit.\n <Button\n variant=\"outline\"\n size=\"icon\"\n aria-label=\"Plus d'actions\"\n />\n }\n />\n }\n >\n <EllipsisIcon />\n </TooltipTrigger>\n <TooltipContent>Plus d'actions</TooltipContent>\n </Tooltip>\n {/* L'écart suit la taille du bouton : 4 px sous un bouton de 32, 6 sous\n un de 36 — collé à de grands boutons, le menu paraissait à l'étroit. */}\n <DropdownMenuContent\n align=\"end\"\n sideOffset={taille === \"lg\" ? 6 : 4}\n className=\"min-w-48\"\n >\n {actions.map(\n ({ libelle, onChoisir, icone: Icone, destructif, verrou }, index) => (\n <DropdownMenuItem\n key={index}\n variant={destructif ? \"destructive\" : \"default\"}\n disabled={!!verrou}\n onClick={onChoisir}\n // La raison doit rester lisible (4,5:1) : seuls l'icône et le\n // libellé sont estompés, pas toute l'entrée.\n className={verrou ? \"data-disabled:opacity-100\" : undefined}\n >\n {verrou ? (\n <>\n {Icone ? <Icone className=\"opacity-50\" /> : null}\n {/* Une entrée désactivée ne reçoit pas le survol : la\n raison s'affiche sous le libellé. */}\n <span className=\"flex flex-col\">\n <span className=\"opacity-50\">{libelle}</span>\n <span\n data-slot=\"detail-header-raison\"\n className=\"text-xs text-muted-foreground\"\n >\n {verrou}\n </span>\n </span>\n </>\n ) : (\n <>\n {Icone ? <Icone /> : null}\n {libelle}\n </>\n )}\n </DropdownMenuItem>\n )\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n"],"mappings":";;;;;;;;;;AA6CA,SAAgBE,EAAW,EACzB,UACA,gBACA,YACA,mBAAgB,MAChB,gBACkB;CAClB,OACE,kBAAC,OAAD;EACE,aAAU;EACV,WAAWC,EACT,8DACAC,CACF;EALF,UAAA,CAOE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,MAAD;IAAI,WAAU;IACX,UAAAC;GACC,CAAA,GACHC,IACC,kBAAC,KAAD;IAAG,WAAU;IAAiC,UAAAA;GAAe,CAAA,IAC3D,IACD;EACJ,CAAA,GAAAC,IAAU,kBAACC,GAAD;GAAS,QAAQC;GAAgB,UAAAF;EAAiB,CAAA,IAAI,IAC9D;;AAET;AAEA,SAASC,EAAQ,EACf,WACA,eAIC;CAKD,OACE,kBAAC,OAAD;EACE,gBAAcE;EACd,WAAWP,EAAG,qCAAqCQ,EAASD,EAAO;EAElE;CACE,CAAA;AAET;AAEA,IAAMC,IAA0C;CAC9C,SAAS;CACT,IAAI;AACN;AAsDA,SAAgBC,EAAa,EAC3B,YAAS,CAAC,GACV,UACA,WACA,SACA,YACA,wBAAqB,CAAC,GACtB,mBAAgB,MAChB,aAAU,IACV,SACA,gBACoB;CACpB,IAAMC,IAAOC,EAAQC,CAAI,GACnBC,IACJT,KAAWU,EAAmB,SAAS,IACrC,kBAACT,GAAD;EAAS,QAAQC;EAAjB,UAAA,CACGF,GACAU,EAAmB,SAAS,IAC3B,kBAACC,GA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omit<ComponentProps<"input">, "value" |
|
|
|
18
18
|
/** Pays proposés dans la liste ; tous par défaut. */
|
|
19
19
|
pays?: CountryCode[];
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Numéro à afficher hors d'un champ (fiche, liste), sans drapeau ni
|
|
23
|
+
* sélecteur de pays : au format national pour un numéro du pays par défaut
|
|
24
|
+
* (« 06 55 18 92 45 »), au format international pour tout autre, pour que
|
|
25
|
+
* son pays se lise (« +44 20 7946 0958 »). Le `PhoneInput`, lui, écrit
|
|
26
|
+
* toujours le numéro au format national, son pays étant montré par le
|
|
27
|
+
* drapeau. Un numéro illisible ou invalide est rendu tel quel ; `null`,
|
|
28
|
+
* `undefined` et "" donnent "". Affichage seulement : la valeur E.164 reste
|
|
29
|
+
* celle des liens `tel:` et des recherches.
|
|
30
|
+
*
|
|
31
|
+
* Chaque appel relit le numéro (libphonenumber-js) : dans une longue liste,
|
|
32
|
+
* mémoïser le résultat (`useMemo` sur les lignes, ou au chargement).
|
|
33
|
+
*/
|
|
34
|
+
export declare function formaterTelephone(numero: string | null | undefined, { paysParDefaut }?: {
|
|
35
|
+
paysParDefaut?: CountryCode;
|
|
36
|
+
}): string;
|
|
21
37
|
/**
|
|
22
38
|
* Numéro de téléphone avec sélecteur de pays (Combobox de shadcn : drapeau et
|
|
23
39
|
* indicatif, recherche sur le nom du pays ou l'indicatif) : lu, validé et mis
|
|
@@ -3,33 +3,34 @@ import { ButtonGroup as t } from "../ui/button-group.js";
|
|
|
3
3
|
import { Combobox as n, ComboboxContent as r, ComboboxEmpty as i, ComboboxInput as a, ComboboxItem as o, ComboboxList as s, ComboboxTrigger as c, ComboboxValue as l } from "../ui/combobox.js";
|
|
4
4
|
import { Input as u } from "../ui/input.js";
|
|
5
5
|
import { attributsDuChamp as d, useFormField as f } from "./form-field-context.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import S from "libphonenumber-js
|
|
6
|
+
import { cn as p } from "cn";
|
|
7
|
+
import { useMemo as m, useState as h } from "react";
|
|
8
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
9
|
+
import { getCountries as y, getCountryCallingCode as b, getExampleNumber as x, parsePhoneNumberFromString as S } from "libphonenumber-js";
|
|
10
|
+
import C from "libphonenumber-js/mobile/examples";
|
|
10
11
|
// src/components/etic/phone-input.tsx
|
|
11
|
-
function
|
|
12
|
+
function w(e) {
|
|
12
13
|
return String.fromCodePoint(...[...e].map((e) => 127462 + e.charCodeAt(0) - 65));
|
|
13
14
|
}
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
if (!
|
|
15
|
+
var T;
|
|
16
|
+
function E() {
|
|
17
|
+
if (!T) {
|
|
17
18
|
let e = new Intl.DisplayNames(["fr"], { type: "region" }), t = new Intl.Collator("fr");
|
|
18
|
-
|
|
19
|
+
T = y().map((t) => ({
|
|
19
20
|
code: t,
|
|
20
21
|
nom: e.of(t) ?? t
|
|
21
22
|
})).sort((e, n) => t.compare(e.nom, n.nom)).map(({ code: e, nom: t }) => ({
|
|
22
23
|
value: e,
|
|
23
|
-
label: `${t} +${
|
|
24
|
+
label: `${t} +${b(e)}`
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
function E(e, t) {
|
|
29
|
-
return x(e, t);
|
|
27
|
+
return T;
|
|
30
28
|
}
|
|
31
29
|
function D(e, t) {
|
|
32
|
-
|
|
30
|
+
return S(e, t);
|
|
31
|
+
}
|
|
32
|
+
function O(e, t) {
|
|
33
|
+
let n = e ? D(e, t) : void 0;
|
|
33
34
|
if (!n) return {
|
|
34
35
|
texte: e,
|
|
35
36
|
pays: t
|
|
@@ -40,94 +41,99 @@ function D(e, t) {
|
|
|
40
41
|
pays: r
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, [G]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
function k(e, { paysParDefaut: t = "FR" } = {}) {
|
|
45
|
+
if (!e) return "";
|
|
46
|
+
let n = D(e, t);
|
|
47
|
+
return n?.isValid() ? n.country === t ? n.formatNational() : n.formatInternational() : e;
|
|
48
|
+
}
|
|
49
|
+
function A({ valeur: y, onValeurChange: S, paysParDefaut: T = "FR", pays: k, disabled: A, className: j, onBlur: M, placeholder: N, id: P, name: F, form: I, required: L, "aria-describedby": R, "aria-invalid": z, ...B }) {
|
|
50
|
+
let V = d(f(), {
|
|
51
|
+
id: P,
|
|
52
|
+
required: L,
|
|
53
|
+
"aria-describedby": R,
|
|
54
|
+
"aria-invalid": z
|
|
55
|
+
}), [H, U] = h(() => O(y, T)), [W, G] = h(y);
|
|
56
|
+
y !== W && (G(y), U(O(y, H.pays)));
|
|
57
|
+
let K = k?.join(","), q = m(() => {
|
|
58
|
+
let e = K ? new Set(K.split(",")) : void 0;
|
|
59
|
+
return e ? E().filter((t) => e.has(t.value)) : E();
|
|
60
|
+
}, [K]);
|
|
61
|
+
function J(e, t) {
|
|
62
|
+
let n = e.trim() ? D(e, t) : void 0, r = e.trim().startsWith("+") && n?.country ? n.country : t, i = n?.isPossible() ? n.number : e.trim();
|
|
63
|
+
U({
|
|
58
64
|
texte: e,
|
|
59
65
|
pays: r
|
|
60
|
-
}),
|
|
66
|
+
}), G(i), (i !== y || r !== H.pays) && S(i, {
|
|
61
67
|
valide: n?.isValid() ?? !1,
|
|
62
68
|
pays: r
|
|
63
69
|
});
|
|
64
70
|
}
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
className:
|
|
67
|
-
children: [/* @__PURE__ */
|
|
68
|
-
items:
|
|
69
|
-
value:
|
|
71
|
+
return /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v(t, {
|
|
72
|
+
className: p("rounded-lg has-[[data-slot=input][aria-invalid=true]]:ring-3 has-[[data-slot=input][aria-invalid=true]]:ring-destructive/20 has-[[data-slot=input][aria-invalid=true]]:*:data-[slot=combobox-trigger]:border-destructive *:data-[slot=input]:aria-invalid:ring-0 dark:has-[[data-slot=input][aria-invalid=true]]:ring-destructive/40 dark:has-[[data-slot=input][aria-invalid=true]]:*:data-[slot=combobox-trigger]:border-destructive/50", j),
|
|
73
|
+
children: [/* @__PURE__ */ v(n, {
|
|
74
|
+
items: q,
|
|
75
|
+
value: q.find((e) => e.value === H.pays) ?? null,
|
|
70
76
|
isItemEqualToValue: (e, t) => e.value === t.value,
|
|
71
77
|
autoHighlight: !0,
|
|
72
78
|
onValueChange: (e) => {
|
|
73
79
|
if (!e) return;
|
|
74
|
-
let t =
|
|
75
|
-
|
|
80
|
+
let t = H.texte.trim().startsWith("+") ? void 0 : D(H.texte, e.value);
|
|
81
|
+
J(t?.isValid() ? t.formatNational() : H.texte, e.value);
|
|
76
82
|
},
|
|
77
|
-
disabled:
|
|
78
|
-
children: [/* @__PURE__ */
|
|
79
|
-
render: /* @__PURE__ */
|
|
83
|
+
disabled: A,
|
|
84
|
+
children: [/* @__PURE__ */ _(c, {
|
|
85
|
+
render: /* @__PURE__ */ _(e, {
|
|
80
86
|
variant: "outline",
|
|
81
87
|
"aria-label": "Pays",
|
|
82
88
|
className: "text-base md:text-sm"
|
|
83
89
|
}),
|
|
84
|
-
children: /* @__PURE__ */
|
|
85
|
-
}), /* @__PURE__ */
|
|
90
|
+
children: /* @__PURE__ */ _(l, { children: (e) => e ? `${w(e.value)} +${b(e.value)}` : null })
|
|
91
|
+
}), /* @__PURE__ */ v(r, {
|
|
86
92
|
className: "w-72",
|
|
87
93
|
children: [
|
|
88
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ _(a, {
|
|
89
95
|
showTrigger: !1,
|
|
90
96
|
placeholder: "Pays ou indicatif",
|
|
91
97
|
"aria-label": "Rechercher un pays"
|
|
92
98
|
}),
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ _(i, { children: "Aucun pays trouvé." }),
|
|
100
|
+
/* @__PURE__ */ _(s, { children: (e) => /* @__PURE__ */ v(o, {
|
|
95
101
|
value: e,
|
|
96
|
-
children: [/* @__PURE__ */
|
|
102
|
+
children: [/* @__PURE__ */ _("span", {
|
|
97
103
|
"aria-hidden": "true",
|
|
98
|
-
children:
|
|
104
|
+
children: w(e.value)
|
|
99
105
|
}), e.label]
|
|
100
106
|
}, e.value) })
|
|
101
107
|
]
|
|
102
108
|
})]
|
|
103
|
-
}), /* @__PURE__ */
|
|
109
|
+
}), /* @__PURE__ */ _(u, {
|
|
104
110
|
type: "tel",
|
|
105
111
|
inputMode: "tel",
|
|
106
112
|
autoComplete: "tel-national",
|
|
107
|
-
...z,
|
|
108
113
|
...B,
|
|
109
|
-
|
|
114
|
+
...V,
|
|
115
|
+
form: I,
|
|
110
116
|
"aria-required": void 0,
|
|
111
|
-
disabled:
|
|
112
|
-
placeholder:
|
|
113
|
-
value:
|
|
114
|
-
onChange: (e) =>
|
|
117
|
+
disabled: A,
|
|
118
|
+
placeholder: N ?? x(H.pays, C)?.formatNational(),
|
|
119
|
+
value: H.texte,
|
|
120
|
+
onChange: (e) => J(e.target.value, H.pays),
|
|
115
121
|
onBlur: (e) => {
|
|
116
|
-
let t =
|
|
117
|
-
t?.isValid() &&
|
|
122
|
+
let t = D(H.texte, H.pays);
|
|
123
|
+
t?.isValid() && U({
|
|
118
124
|
texte: t.formatNational(),
|
|
119
|
-
pays:
|
|
120
|
-
}),
|
|
125
|
+
pays: H.pays
|
|
126
|
+
}), M?.(e);
|
|
121
127
|
}
|
|
122
128
|
})]
|
|
123
|
-
}),
|
|
129
|
+
}), F ? /* @__PURE__ */ _("input", {
|
|
124
130
|
type: "hidden",
|
|
125
|
-
name:
|
|
126
|
-
form:
|
|
127
|
-
disabled:
|
|
128
|
-
value:
|
|
131
|
+
name: F,
|
|
132
|
+
form: I,
|
|
133
|
+
disabled: A,
|
|
134
|
+
value: y
|
|
129
135
|
}) : null] });
|
|
130
136
|
}
|
|
131
|
-
export {
|
|
137
|
+
export { A as PhoneInput, k as formaterTelephone };
|
|
132
138
|
|
|
133
139
|
//# sourceMappingURL=phone-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-input.js","names":["_Fragment","Fragment$1","exemples","drapeau","pays","lettre","tousLesPays","listePays","noms","ordre","getCountries","code","a","b","nom","getCountryCallingCode","lire","parsePhoneNumberFromString","texte","enTexte","numero","valeur","paysNumero","PhoneInput","paysProposes","ariaDescribedby","ariaInvalid","props","champ","attributsDuChamp","useFormField","etat","setEtat","useState","paysParDefaut","valeurVue","setValeurVue","clePays","options","useMemo","retenus","option","emettre","paysRetenu","sortie","onValeurChange","ButtonGroup","Combobox","ComboboxTrigger","Button","ComboboxValue","ComboboxContent","ComboboxInput","ComboboxEmpty","ComboboxList","ComboboxItem","Input","placeholder","getExampleNumber","event","onBlur","name"],"sources":["../../../src/components/etic/phone-input.tsx"],"sourcesContent":["import { useMemo, useState, type ComponentProps } from \"react\"\nimport {\n getCountries,\n getCountryCallingCode,\n getExampleNumber,\n parsePhoneNumberFromString,\n type CountryCode,\n} from \"libphonenumber-js\"\nimport exemples from \"libphonenumber-js/mobile/examples\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport { ButtonGroup } from \"@etic-ui/components/ui/button-group\"\nimport {\n Combobox,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxInput,\n ComboboxItem,\n ComboboxList,\n ComboboxTrigger,\n ComboboxValue,\n} from \"@etic-ui/components/ui/combobox\"\nimport { Input } from \"@etic-ui/components/ui/input\"\nimport {\n attributsDuChamp,\n useFormField,\n} from \"@etic-ui/components/etic/form-field-context\"\n\ninterface OptionPays {\n value: CountryCode\n /** « France +33 » : ce que la recherche lit. */\n label: string\n}\n\nexport type { CountryCode }\n\nexport interface PhoneInputDetails {\n /** Numéro complet et plausible pour son pays (longueur, préfixes). */\n valide: boolean\n /** Pays sélectionné, ou reconnu dans un numéro tapé avec « + ». */\n pays: CountryCode\n}\n\nexport interface PhoneInputProps extends Omit<\n ComponentProps<\"input\">,\n \"value\" | \"defaultValue\" | \"onChange\"\n> {\n /** Numéro au format E.164 (« +33612345678 »), ou \"\" s'il n'y en a pas. */\n valeur: string\n /** Reçoit le numéro en E.164 dès qu'il a une longueur possible ; sinon le\n * texte tapé (et `valide` à faux) ; \"\" si le champ est vide. */\n onValeurChange: (valeur: string, details: PhoneInputDetails) => void\n /** Pays proposé tant que le numéro n'en indique pas d'autre. */\n paysParDefaut?: CountryCode\n /** Pays proposés dans la liste ; tous par défaut. */\n pays?: CountryCode[]\n}\n\n/** Drapeau en emoji, à partir des deux lettres du pays. */\nfunction drapeau(pays: CountryCode) {\n return String.fromCodePoint(\n ...[...pays].map((lettre) => 0x1f1e6 + lettre.charCodeAt(0) - 65)\n )\n}\n\n// Tous les pays, triés par leur nom à la française : calculés une fois, au\n// premier rendu d'un PhoneInput, puis filtrés par instance.\nlet tousLesPays: OptionPays[] | undefined\n\nfunction listePays(): OptionPays[] {\n if (!tousLesPays) {\n const noms = new Intl.DisplayNames([\"fr\"], { type: \"region\" })\n // Tri sur le nom seul : « Saint-Martin » avant « Saint-Martin (partie\n // néerlandaise) », quel que soit l'indicatif.\n const ordre = new Intl.Collator(\"fr\")\n tousLesPays = getCountries()\n .map((code) => ({ code, nom: noms.of(code) ?? code }))\n .sort((a, b) => ordre.compare(a.nom, b.nom))\n .map(({ code, nom }) => ({\n value: code,\n label: `${nom} +${getCountryCallingCode(code)}`,\n }))\n }\n return tousLesPays\n}\n\nfunction lire(texte: string, pays: CountryCode) {\n return parsePhoneNumberFromString(texte, pays)\n}\n\nfunction enTexte(valeur: string, pays: CountryCode) {\n const numero = valeur ? lire(valeur, pays) : undefined\n if (!numero) return { texte: valeur, pays }\n const paysNumero = numero.country ?? pays\n return { texte: numero.formatNational(), pays: paysNumero }\n}\n\n/**\n * Numéro de téléphone avec sélecteur de pays (Combobox de shadcn : drapeau et\n * indicatif, recherche sur le nom du pays ou l'indicatif) : lu, validé et mis\n * en forme par libphonenumber-js, rendu en E.164. Le numéro se tape\n * librement ; il est mis en forme en quittant le champ. Un numéro tapé avec\n * son indicatif (« +44… ») choisit le pays.\n *\n * `className` va à l'enveloppe (`ButtonGroup`), le reste au champ du numéro ;\n * avec `name`, un champ caché soumet la valeur (E.164), pas le texte affiché.\n */\nexport function PhoneInput({\n valeur,\n onValeurChange,\n paysParDefaut = \"FR\",\n pays: paysProposes,\n disabled,\n className,\n onBlur,\n placeholder,\n id,\n name,\n form,\n required,\n \"aria-describedby\": ariaDescribedby,\n \"aria-invalid\": ariaInvalid,\n ...props\n}: PhoneInputProps) {\n const champ = attributsDuChamp(useFormField(), {\n id,\n required,\n \"aria-describedby\": ariaDescribedby,\n \"aria-invalid\": ariaInvalid,\n })\n const [etat, setEtat] = useState(() => enTexte(valeur, paysParDefaut))\n // Dernière valeur vue (reçue ou émise) : une autre valeur, venue de\n // l'application, remplace la saisie.\n const [valeurVue, setValeurVue] = useState(valeur)\n if (valeur !== valeurVue) {\n setValeurVue(valeur)\n setEtat(enTexte(valeur, etat.pays))\n }\n\n // Clé stable : un tableau `pays` écrit en ligne ne refait pas le filtre.\n const clePays = paysProposes?.join(\",\")\n const options = useMemo<OptionPays[]>(() => {\n const retenus = clePays ? new Set(clePays.split(\",\")) : undefined\n return retenus\n ? listePays().filter((option) => retenus.has(option.value))\n : listePays()\n }, [clePays])\n\n function emettre(texte: string, pays: CountryCode) {\n const numero = texte.trim() ? lire(texte, pays) : undefined\n // Un numéro international désigne son pays : la liste le suit.\n const paysRetenu =\n texte.trim().startsWith(\"+\") && numero?.country ? numero.country : pays\n // Un numéro incomplet n'a pas d'écriture E.164 fiable (« 06 1 » donnerait\n // « +33061 ») : on rend alors le texte tapé.\n const sortie = numero?.isPossible() ? numero.number : texte.trim()\n setEtat({ texte, pays: paysRetenu })\n setValeurVue(sortie)\n if (sortie !== valeur || paysRetenu !== etat.pays)\n onValeurChange(sortie, {\n valide: numero?.isValid() ?? false,\n pays: paysRetenu,\n })\n }\n\n return (\n <>\n <ButtonGroup className={className}>\n <Combobox<OptionPays>\n items={options}\n value={options.find((option) => option.value === etat.pays) ?? null}\n isItemEqualToValue={(a, b) => a.value === b.value}\n // La recherche surligne le premier pays trouvé : Entrée le choisit.\n autoHighlight\n onValueChange={(option) => {\n if (!option) return\n // Le numéro national prend l'écriture du nouveau pays (« 04 70 12\n // 34 56 » devient « 0470 12 34 56 » en Belgique) ; un numéro\n // international garde son pays, et sa saisie.\n const numero = etat.texte.trim().startsWith(\"+\")\n ? undefined\n : lire(etat.texte, option.value)\n emettre(\n numero?.isValid() ? numero.formatNational() : etat.texte,\n option.value\n )\n }}\n disabled={disabled}\n >\n <ComboboxTrigger\n render={\n // 16 px sous md comme le champ : pas de zoom d'iOS, ni de tailles\n // mêlées dans la ligne.\n <Button\n variant=\"outline\"\n aria-label=\"Pays\"\n className=\"text-base md:text-sm\"\n />\n }\n >\n <ComboboxValue>\n {(option: OptionPays | null) =>\n option\n ? `${drapeau(option.value)} +${getCountryCallingCode(option.value)}`\n : null\n }\n </ComboboxValue>\n </ComboboxTrigger>\n <ComboboxContent className=\"w-72\">\n <ComboboxInput\n showTrigger={false}\n placeholder=\"Pays ou indicatif\"\n aria-label=\"Rechercher un pays\"\n />\n <ComboboxEmpty>Aucun pays trouvé.</ComboboxEmpty>\n <ComboboxList>\n {(option: OptionPays) => (\n <ComboboxItem key={option.value} value={option}>\n <span aria-hidden=\"true\">{drapeau(option.value)}</span>\n {option.label}\n </ComboboxItem>\n )}\n </ComboboxList>\n </ComboboxContent>\n </Combobox>\n <Input\n type=\"tel\"\n inputMode=\"tel\"\n autoComplete=\"tel-national\"\n {...props}\n {...champ}\n form={form}\n // Le `aria-required` posé par FormField cède au vrai `required`.\n aria-required={undefined}\n disabled={disabled}\n placeholder={\n placeholder ??\n getExampleNumber(etat.pays, exemples)?.formatNational()\n }\n value={etat.texte}\n onChange={(event) => emettre(event.target.value, etat.pays)}\n onBlur={(event) => {\n const numero = lire(etat.texte, etat.pays)\n if (numero?.isValid())\n setEtat({ texte: numero.formatNational(), pays: etat.pays })\n onBlur?.(event)\n }}\n />\n </ButtonGroup>\n {/* Hors du ButtonGroup, dont les arrondis suivent :first-child et\n :last-child. */}\n {name ? (\n <input\n type=\"hidden\"\n name={name}\n form={form}\n disabled={disabled}\n value={valeur}\n />\n ) : null}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;AA2DA,SAASG,EAAQ,GAAmB;CAClC,OAAO,OAAO,cACZ,GAAG,CAAC,GAAGC,CAAI,CAAC,CAAC,KAAK,MAAW,SAAUC,EAAO,WAAW,CAAC,IAAI,EAAE,CAClE;AACF;AAIA,IAAIC;AAEJ,SAASC,IAA0B;CACjC,IAAI,CAACD,GAAa;EAChB,IAAME,IAAO,IAAI,KAAK,aAAa,CAAC,IAAI,GAAG,EAAE,MAAM,SAAS,CAAC,GAGvDC,IAAQ,IAAI,KAAK,SAAS,IAAI;EACpC,IAAcC,EAAa,CAAC,CACzB,KAAK,OAAU;GAAE;GAAM,KAAKF,EAAK,GAAGG,CAAI,KAAKA;EAAK,EAAE,CAAC,CACrD,MAAM,GAAG,MAAMF,EAAM,QAAQG,EAAE,KAAKC,EAAE,GAAG,CAAC,CAAC,CAC3C,KAAK,EAAE,SAAM,cAAW;GACvB,OAAOF;GACP,OAAO,GAAGG,EAAI,IAAIC,EAAsBJ,CAAI;EAC9C,EAAE;CACN;CACA,OAAOL;AACT;AAEA,SAASU,EAAK,GAAe,GAAmB;CAC9C,OAAOC,EAA2BC,GAAOd,CAAI;AAC/C;AAEA,SAASe,EAAQ,GAAgB,GAAmB;CAClD,IAAMC,IAASC,IAASL,EAAKK,GAAQjB,CAAI,IAAI,KAAA;CAC7C,IAAI,CAACgB,GAAQ,OAAO;EAAE,OAAOC;EA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GACJ,GAAIC;GACE;GAEN,iBAAe,KAAA;GACL;GACV,aACE6B,KACAC,EAAiB3B,EAAK,MAAM7B,CAAQ,CAAC,EAAE,eAAe;GAExD,OAAO6B,EAAK;GACZ,WAAW,MAAUW,EAAQiB,EAAM,OAAO,OAAO5B,EAAK,IAAI;GAC1D,SAAS,MAAU;IACjB,IAAMX,IAASJ,EAAKe,EAAK,OAAOA,EAAK,IAAI;IAGzC,AAFIX,GAAQ,QAAQ,KAClBY,EAAQ;KAAE,OAAOZ,EAAO,eAAe;KAAG,MAAMW,EAAK;IAAK,CAAC,GAC7D6B,IAASD,CAAK;GAChB;EACD,CAAA,CACU;CAGZ,CAAA,GAAAE,IACC,kBAAC,SAAD;EACE,MAAK;EACC;EACA;EACI;EACV,OAAOxC;CACR,CAAA,IACC,IACJ,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"phone-input.js","names":["_Fragment","Fragment$1","exemples","drapeau","pays","lettre","tousLesPays","listePays","noms","ordre","getCountries","code","a","b","nom","getCountryCallingCode","lire","parsePhoneNumberFromString","texte","enTexte","numero","valeur","paysNumero","formaterTelephone","lu","paysParDefaut","PhoneInput","paysProposes","ariaDescribedby","ariaInvalid","props","champ","attributsDuChamp","useFormField","etat","setEtat","useState","valeurVue","setValeurVue","clePays","options","useMemo","retenus","option","emettre","paysRetenu","sortie","onValeurChange","ButtonGroup","cn","className","Combobox","ComboboxTrigger","Button","ComboboxValue","ComboboxContent","ComboboxInput","ComboboxEmpty","ComboboxList","ComboboxItem","Input","placeholder","getExampleNumber","event","onBlur","name"],"sources":["../../../src/components/etic/phone-input.tsx"],"sourcesContent":["import { useMemo, useState, type ComponentProps } from \"react\"\nimport {\n getCountries,\n getCountryCallingCode,\n getExampleNumber,\n parsePhoneNumberFromString,\n type CountryCode,\n} from \"libphonenumber-js\"\nimport exemples from \"libphonenumber-js/mobile/examples\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport { ButtonGroup } from \"@etic-ui/components/ui/button-group\"\nimport {\n Combobox,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxInput,\n ComboboxItem,\n ComboboxList,\n ComboboxTrigger,\n ComboboxValue,\n} from \"@etic-ui/components/ui/combobox\"\nimport { Input } from \"@etic-ui/components/ui/input\"\nimport {\n attributsDuChamp,\n useFormField,\n} from \"@etic-ui/components/etic/form-field-context\"\n\ninterface OptionPays {\n value: CountryCode\n /** « France +33 » : ce que la recherche lit. */\n label: string\n}\n\nexport type { CountryCode }\n\nexport interface PhoneInputDetails {\n /** Numéro complet et plausible pour son pays (longueur, préfixes). */\n valide: boolean\n /** Pays sélectionné, ou reconnu dans un numéro tapé avec « + ». */\n pays: CountryCode\n}\n\nexport interface PhoneInputProps extends Omit<\n ComponentProps<\"input\">,\n \"value\" | \"defaultValue\" | \"onChange\"\n> {\n /** Numéro au format E.164 (« +33612345678 »), ou \"\" s'il n'y en a pas. */\n valeur: string\n /** Reçoit le numéro en E.164 dès qu'il a une longueur possible ; sinon le\n * texte tapé (et `valide` à faux) ; \"\" si le champ est vide. */\n onValeurChange: (valeur: string, details: PhoneInputDetails) => void\n /** Pays proposé tant que le numéro n'en indique pas d'autre. */\n paysParDefaut?: CountryCode\n /** Pays proposés dans la liste ; tous par défaut. */\n pays?: CountryCode[]\n}\n\n/** Drapeau en emoji, à partir des deux lettres du pays. */\nfunction drapeau(pays: CountryCode) {\n return String.fromCodePoint(\n ...[...pays].map((lettre) => 0x1f1e6 + lettre.charCodeAt(0) - 65)\n )\n}\n\n// Tous les pays, triés par leur nom à la française : calculés une fois, au\n// premier rendu d'un PhoneInput, puis filtrés par instance.\nlet tousLesPays: OptionPays[] | undefined\n\nfunction listePays(): OptionPays[] {\n if (!tousLesPays) {\n const noms = new Intl.DisplayNames([\"fr\"], { type: \"region\" })\n // Tri sur le nom seul : « Saint-Martin » avant « Saint-Martin (partie\n // néerlandaise) », quel que soit l'indicatif.\n const ordre = new Intl.Collator(\"fr\")\n tousLesPays = getCountries()\n .map((code) => ({ code, nom: noms.of(code) ?? code }))\n .sort((a, b) => ordre.compare(a.nom, b.nom))\n .map(({ code, nom }) => ({\n value: code,\n label: `${nom} +${getCountryCallingCode(code)}`,\n }))\n }\n return tousLesPays\n}\n\nfunction lire(texte: string, pays: CountryCode) {\n return parsePhoneNumberFromString(texte, pays)\n}\n\nfunction enTexte(valeur: string, pays: CountryCode) {\n const numero = valeur ? lire(valeur, pays) : undefined\n if (!numero) return { texte: valeur, pays }\n const paysNumero = numero.country ?? pays\n return { texte: numero.formatNational(), pays: paysNumero }\n}\n\n/**\n * Numéro à afficher hors d'un champ (fiche, liste), sans drapeau ni\n * sélecteur de pays : au format national pour un numéro du pays par défaut\n * (« 06 55 18 92 45 »), au format international pour tout autre, pour que\n * son pays se lise (« +44 20 7946 0958 »). Le `PhoneInput`, lui, écrit\n * toujours le numéro au format national, son pays étant montré par le\n * drapeau. Un numéro illisible ou invalide est rendu tel quel ; `null`,\n * `undefined` et \"\" donnent \"\". Affichage seulement : la valeur E.164 reste\n * celle des liens `tel:` et des recherches.\n *\n * Chaque appel relit le numéro (libphonenumber-js) : dans une longue liste,\n * mémoïser le résultat (`useMemo` sur les lignes, ou au chargement).\n */\nexport function formaterTelephone(\n numero: string | null | undefined,\n { paysParDefaut = \"FR\" }: { paysParDefaut?: CountryCode } = {}\n): string {\n if (!numero) return \"\"\n const lu = lire(numero, paysParDefaut)\n if (!lu?.isValid()) return numero\n return lu.country === paysParDefaut\n ? lu.formatNational()\n : lu.formatInternational()\n}\n\n/**\n * Numéro de téléphone avec sélecteur de pays (Combobox de shadcn : drapeau et\n * indicatif, recherche sur le nom du pays ou l'indicatif) : lu, validé et mis\n * en forme par libphonenumber-js, rendu en E.164. Le numéro se tape\n * librement ; il est mis en forme en quittant le champ. Un numéro tapé avec\n * son indicatif (« +44… ») choisit le pays.\n *\n * `className` va à l'enveloppe (`ButtonGroup`), le reste au champ du numéro ;\n * avec `name`, un champ caché soumet la valeur (E.164), pas le texte affiché.\n */\nexport function PhoneInput({\n valeur,\n onValeurChange,\n paysParDefaut = \"FR\",\n pays: paysProposes,\n disabled,\n className,\n onBlur,\n placeholder,\n id,\n name,\n form,\n required,\n \"aria-describedby\": ariaDescribedby,\n \"aria-invalid\": ariaInvalid,\n ...props\n}: PhoneInputProps) {\n const champ = attributsDuChamp(useFormField(), {\n id,\n required,\n \"aria-describedby\": ariaDescribedby,\n \"aria-invalid\": ariaInvalid,\n })\n const [etat, setEtat] = useState(() => enTexte(valeur, paysParDefaut))\n // Dernière valeur vue (reçue ou émise) : une autre valeur, venue de\n // l'application, remplace la saisie.\n const [valeurVue, setValeurVue] = useState(valeur)\n if (valeur !== valeurVue) {\n setValeurVue(valeur)\n setEtat(enTexte(valeur, etat.pays))\n }\n\n // Clé stable : un tableau `pays` écrit en ligne ne refait pas le filtre.\n const clePays = paysProposes?.join(\",\")\n const options = useMemo<OptionPays[]>(() => {\n const retenus = clePays ? new Set(clePays.split(\",\")) : undefined\n return retenus\n ? listePays().filter((option) => retenus.has(option.value))\n : listePays()\n }, [clePays])\n\n function emettre(texte: string, pays: CountryCode) {\n const numero = texte.trim() ? lire(texte, pays) : undefined\n // Un numéro international désigne son pays : la liste le suit.\n const paysRetenu =\n texte.trim().startsWith(\"+\") && numero?.country ? numero.country : pays\n // Un numéro incomplet n'a pas d'écriture E.164 fiable (« 06 1 » donnerait\n // « +33061 ») : on rend alors le texte tapé.\n const sortie = numero?.isPossible() ? numero.number : texte.trim()\n setEtat({ texte, pays: paysRetenu })\n setValeurVue(sortie)\n if (sortie !== valeur || paysRetenu !== etat.pays)\n onValeurChange(sortie, {\n valide: numero?.isValid() ?? false,\n pays: paysRetenu,\n })\n }\n\n return (\n <>\n <ButtonGroup\n className={cn(\n // En erreur, tout le groupe est traité comme un seul champ, à la\n // manière d'`InputGroup` : bordure rouge sur le sélecteur de pays\n // comme sur le numéro, et un seul halo, celui du groupe (le numéro\n // perd le sien, qui chevauchait le bouton). Dérivé en CSS de\n // l'`aria-invalid` du numéro ; `aria-invalid` sur un bouton\n // n'aurait pas de sens.\n \"rounded-lg has-[[data-slot=input][aria-invalid=true]]:ring-3 has-[[data-slot=input][aria-invalid=true]]:ring-destructive/20 has-[[data-slot=input][aria-invalid=true]]:*:data-[slot=combobox-trigger]:border-destructive *:data-[slot=input]:aria-invalid:ring-0 dark:has-[[data-slot=input][aria-invalid=true]]:ring-destructive/40 dark:has-[[data-slot=input][aria-invalid=true]]:*:data-[slot=combobox-trigger]:border-destructive/50\",\n className\n )}\n >\n <Combobox<OptionPays>\n items={options}\n value={options.find((option) => option.value === etat.pays) ?? null}\n isItemEqualToValue={(a, b) => a.value === b.value}\n // La recherche surligne le premier pays trouvé : Entrée le choisit.\n autoHighlight\n onValueChange={(option) => {\n if (!option) return\n // Le numéro national prend l'écriture du nouveau pays (« 04 70 12\n // 34 56 » devient « 0470 12 34 56 » en Belgique) ; un numéro\n // international garde son pays, et sa saisie.\n const numero = etat.texte.trim().startsWith(\"+\")\n ? undefined\n : lire(etat.texte, option.value)\n emettre(\n numero?.isValid() ? numero.formatNational() : etat.texte,\n option.value\n )\n }}\n disabled={disabled}\n >\n <ComboboxTrigger\n render={\n // 16 px sous md comme le champ : pas de zoom d'iOS, ni de tailles\n // mêlées dans la ligne.\n <Button\n variant=\"outline\"\n aria-label=\"Pays\"\n className=\"text-base md:text-sm\"\n />\n }\n >\n <ComboboxValue>\n {(option: OptionPays | null) =>\n option\n ? `${drapeau(option.value)} +${getCountryCallingCode(option.value)}`\n : null\n }\n </ComboboxValue>\n </ComboboxTrigger>\n <ComboboxContent className=\"w-72\">\n <ComboboxInput\n showTrigger={false}\n placeholder=\"Pays ou indicatif\"\n aria-label=\"Rechercher un pays\"\n />\n <ComboboxEmpty>Aucun pays trouvé.</ComboboxEmpty>\n <ComboboxList>\n {(option: OptionPays) => (\n <ComboboxItem key={option.value} value={option}>\n <span aria-hidden=\"true\">{drapeau(option.value)}</span>\n {option.label}\n </ComboboxItem>\n )}\n </ComboboxList>\n </ComboboxContent>\n </Combobox>\n <Input\n type=\"tel\"\n inputMode=\"tel\"\n autoComplete=\"tel-national\"\n {...props}\n {...champ}\n form={form}\n // Le `aria-required` posé par FormField cède au vrai `required`.\n aria-required={undefined}\n disabled={disabled}\n placeholder={\n placeholder ??\n getExampleNumber(etat.pays, exemples)?.formatNational()\n }\n value={etat.texte}\n onChange={(event) => emettre(event.target.value, etat.pays)}\n onBlur={(event) => {\n const numero = lire(etat.texte, etat.pays)\n if (numero?.isValid())\n setEtat({ texte: numero.formatNational(), pays: etat.pays })\n onBlur?.(event)\n }}\n />\n </ButtonGroup>\n {/* Hors du ButtonGroup, dont les arrondis suivent :first-child et\n :last-child. */}\n {name ? (\n <input\n type=\"hidden\"\n name={name}\n form={form}\n disabled={disabled}\n value={valeur}\n />\n ) : null}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;AA4DA,SAASG,EAAQ,GAAmB;CAClC,OAAO,OAAO,cACZ,GAAG,CAAC,GAAGC,CAAI,CAAC,CAAC,KAAK,MAAW,SAAUC,EAAO,WAAW,CAAC,IAAI,EAAE,CAClE;AACF;AAIA,IAAIC;AAEJ,SAASC,IAA0B;CACjC,IAAI,CAACD,GAAa;EAChB,IAAME,IAAO,IAAI,KAAK,aAAa,CAAC,IAAI,GAAG,EAAE,MAAM,SAAS,CAAC,GAGvDC,IAAQ,IAAI,KAAK,SAAS,IAAI;EACpC,IAAcC,EAAa,CAAC,CACzB,KAAK,OAAU;GAAE;GAAM,KAAKF,EAAK,GAAGG,CAAI,KAAKA;EAAK,EAAE,CAAC,CACrD,MAAM,GAAG,MAAMF,EAAM,QAAQG,EAAE,KAAKC,EAAE,GAAG,CAAC,CAAC,CAC3C,KAAK,EAAE,SAAM,cAAW;GACvB,OAAOF;GACP,OAAO,GAAGG,EAAI,IAAIC,EAAsBJ,CAAI;EAC9C,EAAE;CACN;CACA,OAAOL;AACT;AAEA,SAASU,EAAK,GAAe,GAAmB;CAC9C,OAAOC,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IAA3B,UAAA;KACE,kBAACC,GAAD;MACE,aAAa;MACb,aAAY;MACZ,cAAW;KACZ,CAAA;KACD,kBAACC,GAAD,EAAA,UAAe,qBAAiC,CAAA;KAChD,kBAACC,GAAD,EAAA,WACI,MACA,kBAACC,GAAD;MAAiC,OAAOhB;MAAxC,UAAA,CACE,kBAAC,QAAD;OAAM,eAAY;OAAQ,UAAAxC,EAAQwC,EAAO,KAAK;MAAQ,CAAA,GACrDA,EAAO,KACI;KAHK,GAAAA,EAAO,KAGZ,EAEJ,CAAA;IACC;GACT,CAAA,CAAA;EACV,CAAA,GAAA,kBAACiB,GAAD;GACE,MAAK;GACL,WAAU;GACV,cAAa;GACb,GAAI9B;GACJ,GAAIC;GACE;GAEN,iBAAe,KAAA;GACL;GACV,aACE8B,KACAC,EAAiB5B,EAAK,MAAMhC,CAAQ,CAAC,EAAE,eAAe;GAExD,OAAOgC,EAAK;GACZ,WAAW,MAAUU,EAAQmB,EAAM,OAAO,OAAO7B,EAAK,IAAI;GAC1D,SAAS,MAAU;IACjB,IAAMd,IAASJ,EAAKkB,EAAK,OAAOA,EAAK,IAAI;IAGzC,AAFId,GAAQ,QAAQ,KAClBe,EAAQ;KAAE,OAAOf,EAAO,eAAe;KAAG,MAAMc,EAAK;IAAK,CAAC,GAC7D8B,IAASD,CAAK;GAChB;EACD,CAAA,CACU;CAGZ,CAAA,GAAAE,IACC,kBAAC,SAAD;EACE,MAAK;EACC;EACA;EACI;EACV,OAAO5C;CACR,CAAA,IACC,IACJ,EAAA,CAAA;AAEN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { ErrorBannerProps } from './error-banner';
|
|
2
3
|
/**
|
|
3
4
|
* Ce que `QueryBoundary` lit d'une requête : le résultat de `useQuery` de
|
|
4
5
|
* TanStack Query convient tel quel. Décrit ici plutôt qu'importé, pour que
|
|
@@ -35,11 +36,33 @@ export interface QueryBoundaryProps<T> {
|
|
|
35
36
|
/** Force le chargement : requête qui attend encore son entrée (une
|
|
36
37
|
* requête désactivée n'est ni en cours ni chargée). */
|
|
37
38
|
enAttente?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Affiché à la place du bandeau d'erreur quand l'élément demandé n'existe
|
|
41
|
+
* pas (fiche supprimée, adresse erronée) : une chaîne devient le titre d'un
|
|
42
|
+
* `EmptyState`, un nœud (avec un lien de retour…) est rendu tel quel. Sans
|
|
43
|
+
* lui, « introuvable » est une erreur comme une autre. « Introuvable » : une
|
|
44
|
+
* erreur de `status` 404 (`ErreurApi` de `@etic-insa/auth`, ou toute erreur
|
|
45
|
+
* de même forme). Les autres échecs (réseau, 500…) gardent le bandeau et
|
|
46
|
+
* « Réessayer » : ils ne sont jamais annoncés comme « introuvable ».
|
|
47
|
+
*/
|
|
48
|
+
introuvable?: ReactNode;
|
|
49
|
+
}
|
|
50
|
+
export interface QueryErrorBannerProps extends Omit<ErrorBannerProps, "erreur" | "onReessayer" | "enCours"> {
|
|
51
|
+
/** Le résultat de `useQuery` convient tel quel. */
|
|
52
|
+
requete: Pick<QueryBoundaryRequete<unknown>, "isError" | "error" | "isFetching" | "refetch">;
|
|
38
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* L'échec d'une requête de lecture, avec « Réessayer » (occupé pendant la
|
|
56
|
+
* nouvelle tentative) ; rien tant qu'elle n'a pas échoué. Le bandeau de
|
|
57
|
+
* `QueryBoundary`, pour une page qui place elle-même ses données (liste
|
|
58
|
+
* gardée à l'écran, plusieurs requêtes…).
|
|
59
|
+
*/
|
|
60
|
+
export declare function QueryErrorBanner({ requete, ...props }: QueryErrorBannerProps): import("react").JSX.Element | null;
|
|
39
61
|
/**
|
|
40
62
|
* Les quatre états d'une requête, partout pareils : squelette pendant le
|
|
41
63
|
* chargement, bandeau d'erreur avec « Réessayer », état vide, puis les
|
|
42
|
-
* données. La page n'écrit que le dernier.
|
|
64
|
+
* données. La page n'écrit que le dernier. Une fiche ajoute `introuvable`
|
|
65
|
+
* (404), distinct d'une panne.
|
|
43
66
|
*
|
|
44
67
|
* Aucune enveloppe : le bandeau et le contenu sont rendus directement dans
|
|
45
68
|
* le parent (grille, flex…), qui règle l'espacement (`flex flex-col gap-4`
|
|
@@ -47,4 +70,4 @@ export interface QueryBoundaryProps<T> {
|
|
|
47
70
|
* (vide sans erreur) : l'échec d'une actualisation l'affiche au-dessus des
|
|
48
71
|
* données sans démonter celles-ci (saisie, sélection, défilement gardés).
|
|
49
72
|
*/
|
|
50
|
-
export declare function QueryBoundary<T>({ requete, children, vide, estVide, squelette, enAttente, }: QueryBoundaryProps<T>): import("react").JSX.Element;
|
|
73
|
+
export declare function QueryBoundary<T>({ requete, children, vide, estVide, squelette, enAttente, introuvable, }: QueryBoundaryProps<T>): import("react").JSX.Element;
|