@etic-insa/ui 0.2.0 → 0.3.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 (222) hide show
  1. package/README.md +438 -37
  2. package/dist/components/etic/action.d.ts +16 -7
  3. package/dist/components/etic/action.js +25 -25
  4. package/dist/components/etic/action.js.map +1 -1
  5. package/dist/components/etic/app-shell.d.ts +16 -7
  6. package/dist/components/etic/app-shell.js +92 -85
  7. package/dist/components/etic/app-shell.js.map +1 -1
  8. package/dist/components/etic/auth-image.d.ts +29 -6
  9. package/dist/components/etic/auth-image.js +41 -18
  10. package/dist/components/etic/auth-image.js.map +1 -1
  11. package/dist/components/etic/button-link.d.ts +19 -0
  12. package/dist/components/etic/button-link.js +19 -0
  13. package/dist/components/etic/button-link.js.map +1 -0
  14. package/dist/components/etic/centered-screen.d.ts +13 -0
  15. package/dist/components/etic/centered-screen.js +13 -0
  16. package/dist/components/etic/centered-screen.js.map +1 -0
  17. package/dist/components/etic/confirm-dialog.d.ts +33 -3
  18. package/dist/components/etic/confirm-dialog.js +92 -67
  19. package/dist/components/etic/confirm-dialog.js.map +1 -1
  20. package/dist/components/etic/copy-button.d.ts +3 -2
  21. package/dist/components/etic/copy-button.js +3 -3
  22. package/dist/components/etic/copy-button.js.map +1 -1
  23. package/dist/components/etic/data-table-bulk-actions.d.ts +28 -4
  24. package/dist/components/etic/data-table-bulk-actions.js +48 -41
  25. package/dist/components/etic/data-table-bulk-actions.js.map +1 -1
  26. package/dist/components/etic/data-table-focus.d.ts +17 -0
  27. package/dist/components/etic/data-table-focus.js +29 -0
  28. package/dist/components/etic/data-table-focus.js.map +1 -0
  29. package/dist/components/etic/data-table-format.d.ts +3 -10
  30. package/dist/components/etic/data-table-format.js +4 -3
  31. package/dist/components/etic/data-table-format.js.map +1 -1
  32. package/dist/components/etic/data-table-pagination.d.ts +20 -6
  33. package/dist/components/etic/data-table-pagination.js +73 -43
  34. package/dist/components/etic/data-table-pagination.js.map +1 -1
  35. package/dist/components/etic/data-table-toolbar.d.ts +34 -13
  36. package/dist/components/etic/data-table-toolbar.js +66 -62
  37. package/dist/components/etic/data-table-toolbar.js.map +1 -1
  38. package/dist/components/etic/data-table-view-options.d.ts +44 -4
  39. package/dist/components/etic/data-table-view-options.js +145 -98
  40. package/dist/components/etic/data-table-view-options.js.map +1 -1
  41. package/dist/components/etic/data-table.d.ts +173 -15
  42. package/dist/components/etic/data-table.js +381 -202
  43. package/dist/components/etic/data-table.js.map +1 -1
  44. package/dist/components/etic/date-picker.d.ts +5 -1
  45. package/dist/components/etic/date-picker.js +97 -84
  46. package/dist/components/etic/date-picker.js.map +1 -1
  47. package/dist/components/etic/delete-button.d.ts +12 -4
  48. package/dist/components/etic/delete-button.js +21 -22
  49. package/dist/components/etic/delete-button.js.map +1 -1
  50. package/dist/components/etic/detail-list.d.ts +16 -4
  51. package/dist/components/etic/detail-list.js +30 -20
  52. package/dist/components/etic/detail-list.js.map +1 -1
  53. package/dist/components/etic/disclosure.d.ts +52 -0
  54. package/dist/components/etic/disclosure.js +70 -0
  55. package/dist/components/etic/disclosure.js.map +1 -0
  56. package/dist/components/etic/draft-resume-dialog.d.ts +42 -0
  57. package/dist/components/etic/draft-resume-dialog.js +60 -0
  58. package/dist/components/etic/draft-resume-dialog.js.map +1 -0
  59. package/dist/components/etic/error-banner.js +34 -38
  60. package/dist/components/etic/error-banner.js.map +1 -1
  61. package/dist/components/etic/error-boundary.js +4 -3
  62. package/dist/components/etic/error-boundary.js.map +1 -1
  63. package/dist/components/etic/explained-badge.d.ts +26 -0
  64. package/dist/components/etic/explained-badge.js +17 -0
  65. package/dist/components/etic/explained-badge.js.map +1 -0
  66. package/dist/components/etic/file-upload.js +66 -71
  67. package/dist/components/etic/file-upload.js.map +1 -1
  68. package/dist/components/etic/form-dialog.d.ts +25 -2
  69. package/dist/components/etic/form-dialog.js +95 -77
  70. package/dist/components/etic/form-dialog.js.map +1 -1
  71. package/dist/components/etic/icon-toggle.d.ts +27 -9
  72. package/dist/components/etic/icon-toggle.js +31 -19
  73. package/dist/components/etic/icon-toggle.js.map +1 -1
  74. package/dist/components/etic/lien.d.ts +34 -0
  75. package/dist/components/etic/lien.js +17 -0
  76. package/dist/components/etic/lien.js.map +1 -0
  77. package/dist/components/etic/loading.d.ts +0 -8
  78. package/dist/components/etic/loading.js +17 -25
  79. package/dist/components/etic/loading.js.map +1 -1
  80. package/dist/components/etic/page-container.d.ts +10 -0
  81. package/dist/components/etic/page-container.js +9 -5
  82. package/dist/components/etic/page-container.js.map +1 -1
  83. package/dist/components/etic/page-header.d.ts +10 -4
  84. package/dist/components/etic/page-header.js +48 -43
  85. package/dist/components/etic/page-header.js.map +1 -1
  86. package/dist/components/etic/phone-input.d.ts +16 -0
  87. package/dist/components/etic/phone-input.js +71 -65
  88. package/dist/components/etic/phone-input.js.map +1 -1
  89. package/dist/components/etic/query-boundary.d.ts +25 -2
  90. package/dist/components/etic/query-boundary.js +24 -12
  91. package/dist/components/etic/query-boundary.js.map +1 -1
  92. package/dist/components/etic/removable-badge.d.ts +30 -0
  93. package/dist/components/etic/removable-badge.js +31 -0
  94. package/dist/components/etic/removable-badge.js.map +1 -0
  95. package/dist/components/etic/save-bar.d.ts +31 -0
  96. package/dist/components/etic/save-bar.js +45 -0
  97. package/dist/components/etic/save-bar.js.map +1 -0
  98. package/dist/components/etic/search-select.js +1 -1
  99. package/dist/components/etic/search-select.js.map +1 -1
  100. package/dist/components/etic/segmented-control.d.ts +6 -2
  101. package/dist/components/etic/segmented-control.js +28 -27
  102. package/dist/components/etic/segmented-control.js.map +1 -1
  103. package/dist/components/etic/stat-grid.d.ts +15 -0
  104. package/dist/components/etic/stat-grid.js +17 -0
  105. package/dist/components/etic/stat-grid.js.map +1 -0
  106. package/dist/components/etic/stat-tile.d.ts +1 -1
  107. package/dist/components/etic/stat-tile.js +12 -18
  108. package/dist/components/etic/stat-tile.js.map +1 -1
  109. package/dist/components/etic/status-badge.d.ts +2 -4
  110. package/dist/components/etic/status-badge.js +13 -23
  111. package/dist/components/etic/status-badge.js.map +1 -1
  112. package/dist/components/etic/tailles-dialogue.d.ts +8 -0
  113. package/dist/components/etic/tailles-dialogue.js +10 -0
  114. package/dist/components/etic/tailles-dialogue.js.map +1 -0
  115. package/dist/components/etic/theme-menu.d.ts +1 -2
  116. package/dist/components/etic/theme-menu.js +45 -41
  117. package/dist/components/etic/theme-menu.js.map +1 -1
  118. package/dist/components/etic/toggletip.d.ts +36 -0
  119. package/dist/components/etic/toggletip.js +59 -0
  120. package/dist/components/etic/toggletip.js.map +1 -0
  121. package/dist/components/etic/tooltip-button.d.ts +13 -3
  122. package/dist/components/etic/tooltip-button.js +19 -19
  123. package/dist/components/etic/tooltip-button.js.map +1 -1
  124. package/dist/components/etic/unsaved-changes.d.ts +41 -0
  125. package/dist/components/etic/unsaved-changes.js +17 -0
  126. package/dist/components/etic/unsaved-changes.js.map +1 -0
  127. package/dist/components/etic/use-draft-autosave.d.ts +3 -1
  128. package/dist/components/etic/use-draft-autosave.js +74 -78
  129. package/dist/components/etic/use-draft-autosave.js.map +1 -1
  130. package/dist/components/etic/use-unsaved-changes-warning.d.ts +10 -0
  131. package/dist/components/etic/use-unsaved-changes-warning.js +20 -0
  132. package/dist/components/etic/use-unsaved-changes-warning.js.map +1 -0
  133. package/dist/components/ui/alert-dialog.js +2 -2
  134. package/dist/components/ui/alert-dialog.js.map +1 -1
  135. package/dist/components/ui/avatar.d.ts +5 -1
  136. package/dist/components/ui/avatar.js +20 -11
  137. package/dist/components/ui/avatar.js.map +1 -1
  138. package/dist/components/ui/badge.d.ts +3 -2
  139. package/dist/components/ui/badge.js +27 -14
  140. package/dist/components/ui/badge.js.map +1 -1
  141. package/dist/components/ui/breadcrumb.js +13 -13
  142. package/dist/components/ui/button.d.ts +15 -2
  143. package/dist/components/ui/button.js +27 -15
  144. package/dist/components/ui/button.js.map +1 -1
  145. package/dist/components/ui/calendar.js +1 -1
  146. package/dist/components/ui/calendar.js.map +1 -1
  147. package/dist/components/ui/checkbox.js +1 -1
  148. package/dist/components/ui/checkbox.js.map +1 -1
  149. package/dist/components/ui/combobox.d.ts +2 -2
  150. package/dist/components/ui/combobox.js +45 -32
  151. package/dist/components/ui/combobox.js.map +1 -1
  152. package/dist/components/ui/dialog.d.ts +10 -1
  153. package/dist/components/ui/dialog.js +12 -5
  154. package/dist/components/ui/dialog.js.map +1 -1
  155. package/dist/components/ui/input-group.d.ts +1 -1
  156. package/dist/components/ui/popover.d.ts +1 -1
  157. package/dist/components/ui/popover.js +3 -2
  158. package/dist/components/ui/popover.js.map +1 -1
  159. package/dist/components/ui/progress.d.ts +16 -2
  160. package/dist/components/ui/progress.js +34 -26
  161. package/dist/components/ui/progress.js.map +1 -1
  162. package/dist/components/ui/radio-group.js +1 -1
  163. package/dist/components/ui/radio-group.js.map +1 -1
  164. package/dist/components/ui/select.d.ts +10 -2
  165. package/dist/components/ui/select.js +70 -50
  166. package/dist/components/ui/select.js.map +1 -1
  167. package/dist/components/ui/sidebar.d.ts +6 -1
  168. package/dist/components/ui/sidebar.js +92 -92
  169. package/dist/components/ui/sidebar.js.map +1 -1
  170. package/dist/components/ui/spinner.d.ts +7 -1
  171. package/dist/components/ui/spinner.js +9 -1
  172. package/dist/components/ui/spinner.js.map +1 -1
  173. package/dist/components/ui/switch.js +1 -1
  174. package/dist/components/ui/switch.js.map +1 -1
  175. package/dist/components/ui/table.js +1 -1
  176. package/dist/components/ui/table.js.map +1 -1
  177. package/dist/components/ui/tabs.js +2 -2
  178. package/dist/components/ui/tabs.js.map +1 -1
  179. package/dist/components/ui/tooltip.d.ts +7 -2
  180. package/dist/components/ui/tooltip.js +27 -19
  181. package/dist/components/ui/tooltip.js.map +1 -1
  182. package/dist/hooks/use-column-prefs.d.ts +84 -0
  183. package/dist/hooks/use-column-prefs.js +71 -0
  184. package/dist/hooks/use-column-prefs.js.map +1 -0
  185. package/dist/hooks/use-debounced-value.d.ts +13 -0
  186. package/dist/hooks/use-debounced-value.js +12 -0
  187. package/dist/hooks/use-debounced-value.js.map +1 -0
  188. package/dist/hooks/use-document-title.d.ts +5 -0
  189. package/dist/hooks/use-document-title.js +13 -0
  190. package/dist/hooks/use-document-title.js.map +1 -0
  191. package/dist/hooks/use-persisted-state.d.ts +43 -0
  192. package/dist/hooks/use-persisted-state.js +40 -0
  193. package/dist/hooks/use-persisted-state.js.map +1 -0
  194. package/dist/index.d.ts +40 -16
  195. package/dist/index.js +99 -76
  196. package/dist/lib/autofill.d.ts +18 -0
  197. package/dist/lib/autofill.js +10 -0
  198. package/dist/lib/autofill.js.map +1 -0
  199. package/dist/lib/dates.d.ts +20 -0
  200. package/dist/lib/dates.js +16 -0
  201. package/dist/lib/dates.js.map +1 -0
  202. package/dist/lib/focus-rendu.d.ts +24 -0
  203. package/dist/lib/focus-rendu.js +14 -0
  204. package/dist/lib/focus-rendu.js.map +1 -0
  205. package/dist/lib/format.d.ts +54 -0
  206. package/dist/lib/format.js +80 -0
  207. package/dist/lib/format.js.map +1 -0
  208. package/dist/lib/normalize.d.ts +28 -0
  209. package/dist/lib/normalize.js +21 -0
  210. package/dist/lib/normalize.js.map +1 -0
  211. package/dist/lib/ordre-colonnes.d.ts +15 -0
  212. package/dist/lib/ordre-colonnes.js +14 -0
  213. package/dist/lib/ordre-colonnes.js.map +1 -0
  214. package/dist/lib/ton.d.ts +23 -0
  215. package/dist/lib/ton.js +51 -0
  216. package/dist/lib/ton.js.map +1 -0
  217. package/dist/styles.css +110 -63
  218. package/dist/theme.d.ts +34 -0
  219. package/dist/theme.js +45 -0
  220. package/dist/theme.js.map +1 -0
  221. package/package.json +4 -2
  222. package/src/theme-boot.js +22 -0
@@ -2,103 +2,108 @@ 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 { cn as m } from "cn";
6
- import { Fragment as h } from "react";
7
- import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
8
- import { EllipsisIcon as y } from "lucide-react";
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 b({ titre: e, description: t, actions: n, className: r }) {
11
- return /* @__PURE__ */ v("div", {
11
+ function x({ titre: e, description: t, actions: n, className: r }) {
12
+ return /* @__PURE__ */ y("div", {
12
13
  "data-slot": "page-header",
13
- className: m("flex flex-wrap items-start justify-between gap-x-4 gap-y-3", r),
14
- children: [/* @__PURE__ */ v("div", {
14
+ className: h("flex flex-wrap items-start justify-between gap-x-4 gap-y-3", r),
15
+ children: [/* @__PURE__ */ y("div", {
15
16
  className: "flex min-w-0 flex-col gap-1",
16
- children: [/* @__PURE__ */ _("h1", {
17
+ children: [/* @__PURE__ */ v("h1", {
17
18
  className: "font-heading text-2xl font-semibold tracking-tight",
18
19
  children: e
19
- }), t ? /* @__PURE__ */ _("p", {
20
+ }), t ? /* @__PURE__ */ v("p", {
20
21
  className: "text-sm text-muted-foreground",
21
22
  children: t
22
23
  }) : null]
23
- }), n ? /* @__PURE__ */ _(x, { children: n }) : null]
24
+ }), n ? /* @__PURE__ */ v(S, { children: n }) : null]
24
25
  });
25
26
  }
26
- function x({ children: e }) {
27
- return /* @__PURE__ */ _("div", {
27
+ function S({ children: e }) {
28
+ return /* @__PURE__ */ v("div", {
28
29
  className: "flex flex-wrap items-center gap-2",
29
30
  children: e
30
31
  });
31
32
  }
32
- function S({ chemin: o = [], titre: s, badges: c, meta: l, actions: u, actionsSecondaires: d = [], compact: f = !1, lien: p = "a", className: g }) {
33
- let y = u || d.length > 0 ? /* @__PURE__ */ v(x, { children: [u, d.length > 0 ? /* @__PURE__ */ _(C, { actions: d }) : null] }) : null, b = o.map(({ libelle: e, href: r }, i) => /* @__PURE__ */ v(h, { children: [/* @__PURE__ */ _(t, { children: /* @__PURE__ */ _(n, {
34
- render: /* @__PURE__ */ _(p, { href: r }),
33
+ function C({ chemin: o = [], titre: s, badges: c, meta: l, actions: u, actionsSecondaires: d = [], tailleActions: f = "default", compact: p = !1, lien: _, className: b }) {
34
+ let x = m(_), C = u || d.length > 0 ? /* @__PURE__ */ y(S, { children: [u, d.length > 0 ? /* @__PURE__ */ v(w, {
35
+ actions: d,
36
+ taille: f
37
+ }) : null] }) : null, T = o.map(({ libelle: e, href: r }, i) => /* @__PURE__ */ y(g, { children: [/* @__PURE__ */ v(t, { children: /* @__PURE__ */ v(n, {
38
+ render: /* @__PURE__ */ v(x, { href: r }),
35
39
  children: e
36
- }) }), /* @__PURE__ */ _(a, {})] }, i));
37
- return f && o.length > 0 ? /* @__PURE__ */ v("div", {
40
+ }) }), /* @__PURE__ */ v(a, {})] }, i));
41
+ return p && o.length > 0 ? /* @__PURE__ */ y("div", {
38
42
  "data-slot": "detail-header",
39
- className: m("flex flex-wrap items-center justify-between gap-x-4 gap-y-2", g),
40
- children: [/* @__PURE__ */ _(e, {
43
+ className: h("flex flex-wrap items-center justify-between gap-x-4 gap-y-2", b),
44
+ children: [/* @__PURE__ */ v(e, {
41
45
  className: "min-w-0",
42
- children: /* @__PURE__ */ v(r, { children: [b, /* @__PURE__ */ v(t, { children: [/* @__PURE__ */ _("h1", {
46
+ children: /* @__PURE__ */ y(r, { children: [T, /* @__PURE__ */ y(t, { children: [/* @__PURE__ */ v("h1", {
43
47
  className: "text-sm font-medium",
44
- children: /* @__PURE__ */ _(i, {
48
+ children: /* @__PURE__ */ v(i, {
45
49
  role: void 0,
46
50
  "aria-disabled": void 0,
47
51
  children: s
48
52
  })
49
53
  }), c] })] })
50
- }), y]
51
- }) : /* @__PURE__ */ v("div", {
54
+ }), C]
55
+ }) : /* @__PURE__ */ y("div", {
52
56
  "data-slot": "detail-header",
53
- className: m("flex flex-col gap-3", g),
54
- children: [o.length > 0 ? /* @__PURE__ */ _(e, { children: /* @__PURE__ */ v(r, { children: [b, /* @__PURE__ */ _(t, { children: /* @__PURE__ */ _(i, { children: s }) })] }) }) : null, /* @__PURE__ */ v("div", {
57
+ className: h("flex flex-col gap-3", b),
58
+ children: [o.length > 0 ? /* @__PURE__ */ v(e, { children: /* @__PURE__ */ y(r, { children: [T, /* @__PURE__ */ v(t, { children: /* @__PURE__ */ v(i, { children: s }) })] }) }) : null, /* @__PURE__ */ y("div", {
55
59
  className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-3",
56
- children: [/* @__PURE__ */ v("div", {
60
+ children: [/* @__PURE__ */ y("div", {
57
61
  className: "flex min-w-0 flex-col gap-1",
58
- children: [/* @__PURE__ */ v("div", {
62
+ children: [/* @__PURE__ */ y("div", {
59
63
  className: "flex flex-wrap items-center gap-2",
60
- children: [/* @__PURE__ */ _("h1", {
64
+ children: [/* @__PURE__ */ v("h1", {
61
65
  className: "font-heading text-2xl font-semibold tracking-tight break-words",
62
66
  children: s
63
67
  }), c]
64
- }), l ? /* @__PURE__ */ _("p", {
68
+ }), l ? /* @__PURE__ */ v("p", {
65
69
  className: "text-sm break-words text-muted-foreground",
66
70
  children: l
67
71
  }) : null]
68
- }), y]
72
+ }), C]
69
73
  })]
70
74
  });
71
75
  }
72
- function C({ actions: e }) {
73
- return /* @__PURE__ */ v(s, { children: [/* @__PURE__ */ v(d, { children: [/* @__PURE__ */ _(p, {
74
- render: /* @__PURE__ */ _(u, { render: /* @__PURE__ */ _(o, {
76
+ function w({ actions: e, taille: t }) {
77
+ return /* @__PURE__ */ y(s, { children: [/* @__PURE__ */ y(d, { children: [/* @__PURE__ */ v(p, {
78
+ render: /* @__PURE__ */ v(u, { render: /* @__PURE__ */ v(o, {
75
79
  variant: "outline",
76
- size: "icon",
80
+ size: t === "lg" ? "icon-lg" : "icon",
77
81
  "aria-label": "Plus d'actions"
78
82
  }) }),
79
- children: /* @__PURE__ */ _(y, {})
80
- }), /* @__PURE__ */ _(f, { children: "Plus d'actions" })] }), /* @__PURE__ */ _(c, {
83
+ children: /* @__PURE__ */ v(b, {})
84
+ }), /* @__PURE__ */ v(f, { children: "Plus d'actions" })] }), /* @__PURE__ */ v(c, {
81
85
  align: "end",
86
+ sideOffset: t === "lg" ? 6 : 4,
82
87
  className: "min-w-48",
83
- children: e.map(({ libelle: e, onChoisir: t, icone: n, destructif: r, verrou: i }, a) => /* @__PURE__ */ _(l, {
88
+ children: e.map(({ libelle: e, onChoisir: t, icone: n, destructif: r, verrou: i }, a) => /* @__PURE__ */ v(l, {
84
89
  variant: r ? "destructive" : "default",
85
90
  disabled: !!i,
86
91
  onClick: t,
87
92
  className: i ? "data-disabled:opacity-100" : void 0,
88
- children: i ? /* @__PURE__ */ v(g, { children: [n ? /* @__PURE__ */ _(n, { className: "opacity-50" }) : null, /* @__PURE__ */ v("span", {
93
+ children: i ? /* @__PURE__ */ y(_, { children: [n ? /* @__PURE__ */ v(n, { className: "opacity-50" }) : null, /* @__PURE__ */ y("span", {
89
94
  className: "flex flex-col",
90
- children: [/* @__PURE__ */ _("span", {
95
+ children: [/* @__PURE__ */ v("span", {
91
96
  className: "opacity-50",
92
97
  children: e
93
- }), /* @__PURE__ */ _("span", {
98
+ }), /* @__PURE__ */ v("span", {
94
99
  "data-slot": "detail-header-raison",
95
100
  className: "text-xs text-muted-foreground",
96
101
  children: i
97
102
  })]
98
- })] }) : /* @__PURE__ */ v(g, { children: [n ? /* @__PURE__ */ _(n, {}) : null, e] })
103
+ })] }) : /* @__PURE__ */ y(_, { children: [n ? /* @__PURE__ */ v(n, {}) : null, e] })
99
104
  }, a))
100
105
  })] });
101
106
  }
102
- export { S as DetailHeader, b as PageHeader };
107
+ export { C as DetailHeader, x as PageHeader };
103
108
 
104
109
  //# 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,OAA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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","DetailHeader","Lien","useLien","lien","lesActions","actionsSecondaires","MenuActions","tailleActions","etapes","chemin","Fragment","BreadcrumbItem","BreadcrumbLink","libelle","BreadcrumbSeparator","index","compact","Breadcrumb","BreadcrumbList","BreadcrumbPage","badges","meta","DropdownMenu","Tooltip","TooltipTrigger","DropdownMenuTrigger","Button","taille","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 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 * Taille des boutons de `actions` (leur `size`, à leur donner) : le bouton\n * « Plus d'actions » la suit (`icon` ou `icon-lg`) pour rester aligné.\n */\n tailleActions?: \"default\" | \"lg\"\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 = \"default\",\n compact = false,\n lien,\n className,\n}: DetailHeaderProps) {\n const Lien = useLien(lien)\n const lesActions =\n actions || actionsSecondaires.length > 0 ? (\n <Actions>\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: \"default\" | \"lg\"\n}) {\n return (\n <DropdownMenu>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"outline\"\n size={taille === \"lg\" ? \"icon-lg\" : \"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":";;;;;;;;;;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;AAsDA,SAAgBC,EAAa,EAC3B,YAAS,CAAC,GACV,UACA,WACA,SACA,YACA,wBAAqB,CAAC,GACtB,mBAAgB,WAChB,aAAU,IACV,SACA,gBACoB;CACpB,IAAMC,IAAOC,EAAQC,CAAI,GACnBC,IACJN,KAAWO,EAAmB,SAAS,IACrC,kBAACN,GAAD,EAAA,UAAA,CACGD,GACAO,EAAmB,SAAS,IAC3B,kBAACC,GAAD;EAAa,SAASD;EAAoB,QAAQE;CAAgB,CAAA,IAChE,IACG,EAAA,CAAA,IACP,MAEAC,IAASC,EAAO,KAAK,EAAE,YAAS,WAAQ,MAC5C,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD;EAAgB,QAAQ,kBAACX,GAAD,EAAY,QAAO,CAAA;EAAI,UAAAY;CAAwB,CAAA,EACzD,CAAA,GAChB,kBAACC,GAAD,CAAsB,CAAA,CACd,EAAA,GALKC,CAKL,CACX;CAiCD,OA7BIC,KAAWP,EAAO,S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H,UAAA,kBAACC,GAAD,CAAe,CAAA;CACD,CAAA,GAChB,kBAACC,GAAD,EAAA,UAAgB,iBAA8B,CAAA,CACvC,EAAA,CAAA,GAGT,kBAACC,GAAD;EACE,OAAM;EACN,YAAYH,MAAW,OAAO,IAAI;EAClC,WAAU;EAET,UAAA7B,EAAQ,KACN,EAAE,YAAS,cAAW,OAAOiC,GAAO,eAAY,aAAU,MACzD,kBAACC,GAAD;GAEE,SAASC,IAAa,gBAAgB;GACtC,UAAU,CAAC,CAACC;GACZ,SAASC;GAGT,WAAWD,IAAS,8BAA8B,KAAA;GAEjD,UAAAA,IACC,kBAAA3C,GAAA,EAAA,UAAA,CACGwC,IAAQ,kBAACA,GAAD,EAAO,WAAU,aAAc,CAAA,IAAI,MAG5C,kBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,kBAAC,QAAD;KAAM,WAAU;KAAc,UAAAlB;IAAc,CAAA,GAC5C,kBAAC,QAAD;KACE,aAAU;KACV,WAAU;KAET,UAAAqB;IACG,CAAA,CACF;GACN,CAAA,CAAA,EAAA,CAAA,IAEF,kBAAA3C,GAAA,EAAA,UAAA,CACGwC,IAAQ,kBAACA,GAAD,CAAQ,CAAA,IAAI,MACpBlB,CACD,EAAA,CAAA;EAEY,GA7BXE,CA6BW,CAEtB;CACmB,CAAA,CACT,EAAA,CAAA;AAElB"}
@@ -18,6 +18,22 @@ export interface PhoneInputProps extends 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 { useMemo as p, useState as m } from "react";
7
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
8
- import { getCountries as v, getCountryCallingCode as y, getExampleNumber as b, parsePhoneNumberFromString as x } from "libphonenumber-js";
9
- import S from "libphonenumber-js/mobile/examples";
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 C(e) {
12
+ function w(e) {
12
13
  return String.fromCodePoint(...[...e].map((e) => 127462 + e.charCodeAt(0) - 65));
13
14
  }
14
- var w;
15
- function T() {
16
- if (!w) {
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
- w = v().map((t) => ({
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} +${y(e)}`
24
+ label: `${t} +${b(e)}`
24
25
  }));
25
26
  }
26
- return w;
27
- }
28
- function E(e, t) {
29
- return x(e, t);
27
+ return T;
30
28
  }
31
29
  function D(e, t) {
32
- let n = e ? E(e, t) : void 0;
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 O({ valeur: v, onValeurChange: x, paysParDefaut: w = "FR", pays: O, disabled: k, className: A, onBlur: j, placeholder: M, id: N, name: P, form: F, required: I, "aria-describedby": L, "aria-invalid": R, ...z }) {
44
- let B = d(f(), {
45
- id: N,
46
- required: I,
47
- "aria-describedby": L,
48
- "aria-invalid": R
49
- }), [V, H] = m(() => D(v, w)), [U, W] = m(v);
50
- v !== U && (W(v), H(D(v, V.pays)));
51
- let G = O?.join(","), K = p(() => {
52
- let e = G ? new Set(G.split(",")) : void 0;
53
- return e ? T().filter((t) => e.has(t.value)) : T();
54
- }, [G]);
55
- function q(e, t) {
56
- let n = e.trim() ? E(e, t) : void 0, r = e.trim().startsWith("+") && n?.country ? n.country : t, i = n?.isPossible() ? n.number : e.trim();
57
- H({
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
- }), W(i), (i !== v || r !== V.pays) && x(i, {
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__ */ _(h, { children: [/* @__PURE__ */ _(t, {
66
- className: A,
67
- children: [/* @__PURE__ */ _(n, {
68
- items: K,
69
- value: K.find((e) => e.value === V.pays) ?? null,
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 = V.texte.trim().startsWith("+") ? void 0 : E(V.texte, e.value);
75
- q(t?.isValid() ? t.formatNational() : V.texte, e.value);
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: k,
78
- children: [/* @__PURE__ */ g(c, {
79
- render: /* @__PURE__ */ g(e, {
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__ */ g(l, { children: (e) => e ? `${C(e.value)} +${y(e.value)}` : null })
85
- }), /* @__PURE__ */ _(r, {
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__ */ g(a, {
94
+ /* @__PURE__ */ _(a, {
89
95
  showTrigger: !1,
90
96
  placeholder: "Pays ou indicatif",
91
97
  "aria-label": "Rechercher un pays"
92
98
  }),
93
- /* @__PURE__ */ g(i, { children: "Aucun pays trouvé." }),
94
- /* @__PURE__ */ g(s, { children: (e) => /* @__PURE__ */ _(o, {
99
+ /* @__PURE__ */ _(i, { children: "Aucun pays trouvé." }),
100
+ /* @__PURE__ */ _(s, { children: (e) => /* @__PURE__ */ v(o, {
95
101
  value: e,
96
- children: [/* @__PURE__ */ g("span", {
102
+ children: [/* @__PURE__ */ _("span", {
97
103
  "aria-hidden": "true",
98
- children: C(e.value)
104
+ children: w(e.value)
99
105
  }), e.label]
100
106
  }, e.value) })
101
107
  ]
102
108
  })]
103
- }), /* @__PURE__ */ g(u, {
109
+ }), /* @__PURE__ */ _(u, {
104
110
  type: "tel",
105
111
  inputMode: "tel",
106
112
  autoComplete: "tel-national",
107
- ...z,
108
113
  ...B,
109
- form: F,
114
+ ...V,
115
+ form: I,
110
116
  "aria-required": void 0,
111
- disabled: k,
112
- placeholder: M ?? b(V.pays, S)?.formatNational(),
113
- value: V.texte,
114
- onChange: (e) => q(e.target.value, V.pays),
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 = E(V.texte, V.pays);
117
- t?.isValid() && H({
122
+ let t = D(H.texte, H.pays);
123
+ t?.isValid() && U({
118
124
  texte: t.formatNational(),
119
- pays: V.pays
120
- }), j?.(e);
125
+ pays: H.pays
126
+ }), M?.(e);
121
127
  }
122
128
  })]
123
- }), P ? /* @__PURE__ */ g("input", {
129
+ }), F ? /* @__PURE__ */ _("input", {
124
130
  type: "hidden",
125
- name: P,
126
- form: F,
127
- disabled: k,
128
- value: v
131
+ name: F,
132
+ form: I,
133
+ disabled: A,
134
+ value: y
129
135
  }) : null] });
130
136
  }
131
- export { O as PhoneInput };
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,KA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A,UAAe,qBAAiC,CAAA;KAChD,kBAACC,GAAD,EAAA,WACI,MACA,kBAACC,GAAD;MAAiC,OAAOd;MAAxC,UAAA,CACE,kBAAC,QAAD;OAAM,eAAY;OAAQ,UAAAtC,EAAQsC,EAAO,KAAK;MAAQ,CAAA,GACrDA,EAAO,KACI;KAHK,GAAAA,EAAO,KAGZ,EAEJ,CAAA;IACC;GACT,CAAA,CAAA;EACV,CAAA,GAAA,kBAACe,GAAD;GACE,MAAK;GACL,WAAU;GACV,cAAa;GACb,GAAI7B;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,CACz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V,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;
@@ -2,24 +2,36 @@ import { EmptyState as e } from "./empty-state.js";
2
2
  import { ErrorBanner as t } from "./error-banner.js";
3
3
  import { SkeletonTable as n } from "./loading.js";
4
4
  import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
5
- import { InboxIcon as o } from "lucide-react";
5
+ import { InboxIcon as o, SearchXIcon as s } from "lucide-react";
6
6
  // src/components/etic/query-boundary.tsx
7
- function s(e) {
7
+ function c(e) {
8
8
  if (Array.isArray(e)) return e.length === 0;
9
9
  let t = e?.items;
10
10
  return Array.isArray(t) && t.length === 0;
11
11
  }
12
- function c({ requete: c, children: l, vide: u, estVide: d = s, squelette: f, enAttente: p = !1 }) {
13
- let { data: m, refetch: h } = c, g = p || c.isLoading, _ = c.isError && !p ? /* @__PURE__ */ i(t, {
14
- erreur: c.error,
15
- onReessayer: h ? () => void h() : void 0,
16
- enCours: !!c.isFetching
17
- }) : null, v = null;
18
- return g ? v = f ?? /* @__PURE__ */ i(n, {}) : m !== void 0 && (v = u !== void 0 && d(m) ? typeof u == "string" ? /* @__PURE__ */ i(e, {
19
- titre: u,
12
+ function l(e) {
13
+ return typeof e == "object" && !!e && e.status === 404;
14
+ }
15
+ function u({ requete: e, ...n }) {
16
+ if (!e.isError) return null;
17
+ let { refetch: r } = e;
18
+ return /* @__PURE__ */ i(t, {
19
+ erreur: e.error,
20
+ onReessayer: r ? () => void r() : void 0,
21
+ enCours: !!e.isFetching,
22
+ ...n
23
+ });
24
+ }
25
+ function d({ requete: t, children: d, vide: f, estVide: p = c, squelette: m, enAttente: h = !1, introuvable: g }) {
26
+ let { data: _ } = t, v = h || t.isLoading, y = t.isError && !h, b = g != null && g !== !1 && y && l(t.error), x = y && !b ? /* @__PURE__ */ i(u, { requete: t }) : null, S = null;
27
+ return b ? S = typeof g == "string" ? /* @__PURE__ */ i(e, {
28
+ titre: g,
29
+ icone: s
30
+ }) : g : v ? S = m ?? /* @__PURE__ */ i(n, {}) : _ !== void 0 && (S = f !== void 0 && p(_) ? typeof f == "string" ? /* @__PURE__ */ i(e, {
31
+ titre: f,
20
32
  icone: o
21
- }) : u : l(m)), /* @__PURE__ */ a(r, { children: [_, v] });
33
+ }) : f : d(_)), /* @__PURE__ */ a(r, { children: [x, S] });
22
34
  }
23
- export { c as QueryBoundary };
35
+ export { d as QueryBoundary, u as QueryErrorBanner };
24
36
 
25
37
  //# sourceMappingURL=query-boundary.js.map