@etic-insa/ui 0.4.0 → 0.4.1
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 +19 -6
- package/dist/components/etic/data-table-bulk-actions.d.ts +3 -4
- package/dist/components/etic/data-table-bulk-actions.js.map +1 -1
- package/dist/components/etic/phone-input.js +1 -1
- package/dist/components/etic/phone-input.js.map +1 -1
- package/dist/components/ui/calendar.js +119 -81
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts +2 -2
- package/dist/components/ui/dropdown-menu.js +102 -68
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/styles.css +5 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -965,12 +965,25 @@ npm run build # dist/ : un module par composant, types, styles.css
|
|
|
965
965
|
react-day-picker (mois, jours et libellés d'accessibilité) et `weekStartsOn={1}` ;
|
|
966
966
|
- jours du calendrier de 36 px sous le seuil mobile (cible tactile), 28 px au-delà comme
|
|
967
967
|
dans shadcn : `--cell-size` de `calendar.tsx` ;
|
|
968
|
+
- listes du mois et de l'année du calendrier (`captionLayout="dropdown"`, `listesMoisAnnee` de
|
|
969
|
+
`DatePicker`) : le `Select` de la bibliothèque, à l'allure du libellé, au lieu du `<select>`
|
|
970
|
+
natif transparent de shadcn, dont la liste ouverte était celle du système. Les composants
|
|
971
|
+
passés à react-day-picker sont définis une fois (shadcn les écrit en ligne) : recréés à
|
|
972
|
+
chaque rendu, ils remontaient tout le calendrier quand son parent le redessinait (mois piloté
|
|
973
|
+
par `month`), et le focus d'une liste se perdait ;
|
|
968
974
|
- thème (`styles.css`) : `--destructive` plus foncé en clair et plus clair en sombre
|
|
969
975
|
(≥ 4,5:1 sur sa teinte : bouton et badge `destructive`, y compris dans un pied de
|
|
970
976
|
dialogue) ; contrastes vérifiés par `src/theme.test.ts` ;
|
|
971
977
|
- l'accent comme texte en `text-primary-text` au lieu de `text-primary` : variante `link` de
|
|
972
978
|
`button.tsx` et `badge.tsx`, liens survolés de `empty.tsx`, `field.tsx` et `item.tsx` ;
|
|
973
979
|
- import inutilisé de React retiré de `scroll-area.tsx` (sans quoi `tsc` échoue) ;
|
|
980
|
+
- `dropdown-menu.tsx` : `DropdownMenu` suit son déclencheur, et `DropdownMenuContent` (menu
|
|
981
|
+
principal, pas les sous-menus) ne rend pas le focus quand ce déclencheur a été retiré du DOM
|
|
982
|
+
(`finalFocus` par défaut) ; Base UI le renvoyait sinon au dernier menu ou sélecteur ouvert
|
|
983
|
+
ailleurs dans la page. Le focus tombe sur `<body>`, où les rattrapages des composants le
|
|
984
|
+
reprennent. Un focus parti ailleurs (dialogue ouvert par une entrée) y reste. Un
|
|
985
|
+
`finalFocus` donné passe d'abord ; s'il vaut `true`, la garde s'applique. Les autres popups
|
|
986
|
+
(dialogue, sélecteur, popover, combobox) ont le même repli et ne sont pas encore corrigés ;
|
|
974
987
|
- `button.tsx` : un bouton `aria-disabled` (désactivé mais focalisable, `focusableWhenDisabled`)
|
|
975
988
|
est estompé comme un bouton `disabled`, curseur interdit (d'attente s'il est `enCours`), sans
|
|
976
989
|
enfoncement au clic ; pas de `pointer-events-none`, qui couperait l'infobulle de sa raison ;
|
|
@@ -992,12 +1005,12 @@ npm run build # dist/ : un module par composant, types, styles.css
|
|
|
992
1005
|
- case à cocher partielle (`indeterminate`) : `checkbox.tsx` affiche un trait sur fond plein,
|
|
993
1006
|
comme une case cochée, au lieu de la coche sur fond vide de shadcn (on croyait tout coché) ;
|
|
994
1007
|
- bord d'une case à cocher vide en `--control-border` (`styles.css`) au lieu de `--input` :
|
|
995
|
-
`--muted-foreground`
|
|
996
|
-
|
|
1008
|
+
`--muted-foreground` en clair (≥ 3:1, le bord de Nova se voyait à peine), `--input` en
|
|
1009
|
+
sombre, comme shadcn (exception assumée à WCAG 1.4.11 : plus discret) ;
|
|
997
1010
|
- même règle pour le contour d'une radio non cochée (`radio-group.tsx`, focus dans un
|
|
998
1011
|
`field-label` compris) et le rail d'un switch éteint (`switch.tsx`, `--control-border` à la
|
|
999
|
-
place de `bg-input`) : ≥ 3:1 sur la page et sur une carte
|
|
1000
|
-
|
|
1012
|
+
place de `bg-input`) : ≥ 3:1 sur la page et sur une carte en clair, `--input` en sombre ;
|
|
1013
|
+
le pouce reste distinct du rail ;
|
|
1001
1014
|
- variantes `warning`, `info` et `success` ajoutées à `alert.tsx`, sur le modèle de
|
|
1002
1015
|
`destructive` (fond de carte, texte de la couleur, description à 90 %), et couleur `--info`
|
|
1003
1016
|
dans `styles.css` ;
|
|
@@ -1087,8 +1100,8 @@ overflow-y-auto`), en-tête, croix et pied restant visibles ; sans elle, tout le
|
|
|
1087
1100
|
sombre), pris par le `body` au lieu de `bg-background`, `--background` restant celui du
|
|
1088
1101
|
registre ; `--success` clair un cran plus foncé (≥ 4,5:1 sur sa teinte posée sur la page
|
|
1089
1102
|
zinc-50) ; `--muted-foreground` celui du preset (zinc-500, 4,39:1 sur `--muted` en clair :
|
|
1090
|
-
contraste faible accepté) ; `--control-border`
|
|
1091
|
-
|
|
1103
|
+
contraste faible accepté) ; `--control-border` en clair seulement (`--input` du registre
|
|
1104
|
+
en sombre, exception assumée à WCAG 1.4.11) ; `--sidebar`
|
|
1092
1105
|
clair = `--background` (barre latérale blanche, au lieu du zinc-50 du registre) ;
|
|
1093
1106
|
`color-scheme` dans `:root` et `.dark`. Les valeurs sont commentées dans `styles.css` ;
|
|
1094
1107
|
`theme.test.ts` compare chaque jeton au registre, écarts (`ECARTS`) exceptés, et en vérifie
|
|
@@ -14,10 +14,9 @@ interface DataTableBulkActionsCommun {
|
|
|
14
14
|
children: ReactNode;
|
|
15
15
|
/** Actions moins fréquentes, rangées dans le menu « … » de la barre :
|
|
16
16
|
* des `DropdownMenuItem`. Le menu porte aussi « Sélectionner les 137 »
|
|
17
|
-
* quand il est proposé.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* dans `DropdownMenuContent`, pour tous les menus). */
|
|
17
|
+
* quand il est proposé. Une entrée qui vide aussitôt la sélection
|
|
18
|
+
* démonte la barre et son menu : le focus tombe alors sur la page, pas
|
|
19
|
+
* sur un autre menu (`DropdownMenuContent`). */
|
|
21
20
|
actionsSecondaires?: ReactNode;
|
|
22
21
|
className?: string;
|
|
23
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-bulk-actions.js","names":["_Fragment","Fragment$1","echapPourUnChamp","event","cible","selectionDe","props","meta","metaDe","table","aProposer","nombre","DataTableBulkActions","UNITE_PAR_DEFAUT","idResume","useId","barreRef","useRef","boutonDeselectionner","apresFermeture","vider","visible","sur","surTotal","nombreFr","resume","uniteAccordee","unite","participe","feminin","focusDansBarre","toutDeselectionner","focaliserTableau","racine","perdu","dejaVisible","setDejaVisible","useState","surTouche","useEffectEvent","surToucheDansBarre","useEffect","vers","cn","className","Separator","DropdownMenu","ouvert","action","Tooltip","TooltipTrigger","DropdownMenuTrigger","Button","proposition","actionsSecondaires","MoreHorizontalIcon","TooltipContent","DropdownMenuContent","DropdownMenuItem","ListChecksIcon","DropdownMenuSeparator","TooltipButton","XIcon"],"sources":["../../../src/components/etic/data-table-bulk-actions.tsx"],"sourcesContent":["import {\n useEffect,\n useEffectEvent,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from \"react\"\nimport type { RowData } from \"@tanstack/react-table\"\nimport { cn } from \"cn\"\nimport { ListChecksIcon, MoreHorizontalIcon, XIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@etic-ui/components/ui/tooltip\"\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@etic-ui/components/ui/dropdown-menu\"\nimport { TooltipButton } from \"@etic-ui/components/etic/tooltip-button\"\nimport { Separator } from \"@etic-ui/components/ui/separator\"\nimport {\n metaDe,\n type DataTableInstance,\n} from \"@etic-ui/components/etic/data-table\"\nimport { focaliserTableau } from \"@etic-ui/components/etic/data-table-focus\"\nimport {\n UNITE_PAR_DEFAUT,\n nombreFr,\n participe,\n uniteAccordee,\n type DataTableUnite,\n} from \"@etic-ui/components/etic/data-table-format\"\n\n/** Un Échap tapé dans un champ (recherche dans une cellule…) lui revient. */\nfunction echapPourUnChamp(event: KeyboardEvent): boolean {\n if (event.defaultPrevented) return true\n const cible = event.target\n return (\n cible instanceof HTMLElement &&\n (cible.isContentEditable ||\n /^(INPUT|TEXTAREA|SELECT)$/.test(cible.tagName)) &&\n !(cible instanceof HTMLInputElement && cible.type === \"checkbox\")\n )\n}\n\ninterface DataTableBulkActionsCommun {\n /** Nom des éléments : « 3 personnes sélectionnées ». « élément »,\n * « éléments » par défaut. */\n unite?: DataTableUnite\n /** Accorde « sélectionnées » au féminin. */\n feminin?: boolean\n /** Les actions : boutons `size=\"sm\"`. Les lignes visées viennent de\n * `table.getSelectedRowModel()` (ou `getSelectedRowIds()`) ; quand\n * `toutSelectionne` est vrai, l'action porte sur tous les éléments. */\n children: ReactNode\n /** Actions moins fréquentes, rangées dans le menu « … » de la barre :\n * des `DropdownMenuItem`. Le menu porte aussi « Sélectionner les 137 »\n * quand il est proposé. Limite connue : une entrée qui vide aussitôt la\n * sélection démonte la barre et son menu, et Base UI rend alors le focus\n * au dernier menu ou sélecteur ouvert ailleurs dans la page (à corriger\n * dans `DropdownMenuContent`, pour tous les menus). */\n actionsSecondaires?: ReactNode\n className?: string\n}\n\n/** Barre branchée sur l'instance d'un `DataTable`. */\nexport interface DataTableBulkActionsTableProps<\n TData extends RowData,\n> extends DataTableBulkActionsCommun {\n table: DataTableInstance<TData>\n}\n\n/**\n * Barre d'un tableau rendu à la main, sans instance `useDataTable` : la\n * sélection est celle de l'application.\n */\nexport interface DataTableBulkActionsSelectionProps extends DataTableBulkActionsCommun {\n table?: never\n /** Nombre d'éléments sélectionnés ; la barre s'affiche dès 1. */\n nombre: number\n /** « Tout désélectionner » et Échap. */\n onToutDeselectionner: () => void\n /** Cadre du tableau : Échap y vide la sélection, et le focus y revient\n * (sa case d'en-tête, sinon le cadre) quand la barre disparaît. */\n racine?: RefObject<HTMLElement | null>\n}\n\nexport type DataTableBulkActionsProps<TData extends RowData = RowData> =\n DataTableBulkActionsTableProps<TData> | DataTableBulkActionsSelectionProps\n\n/** Nombre, remise à zéro et cadre, lus dans le tableau ou donnés ; avec un\n * tableau, le total (« 25 membres sur 137 ») et sa proposition\n * (« Sélectionner les 137 »). */\nfunction selectionDe<TData extends RowData>(\n props: DataTableBulkActionsProps<TData>\n): {\n nombre: number\n toutDeselectionner: () => void\n racine: () => HTMLElement | null\n /** Total dont la sélection n'est qu'une partie. */\n surTotal?: number\n /** Total à proposer et son action. */\n proposition?: { total: number; selectionner: () => void }\n} {\n if (!props.table)\n return {\n nombre: props.nombre,\n toutDeselectionner: props.onToutDeselectionner,\n racine: () => props.racine?.current ?? null,\n }\n const { table } = props\n const meta = metaDe(table)\n const aProposer = meta.totalAProposer\n // « Tous sélectionnés » : le total, pas seulement les lignes de la page.\n const nombre =\n meta.toutSelectionne && meta.total !== undefined\n ? meta.total\n : table.getSelectedRowIds().length\n return {\n nombre,\n toutDeselectionner: meta.toutDeselectionner,\n racine: () => meta.racine.current,\n surTotal:\n meta.total !== undefined && meta.total > nombre ? meta.total : undefined,\n proposition:\n aProposer === undefined\n ? undefined\n : {\n total: aProposer,\n selectionner: () => meta.changerToutSelectionne(true),\n },\n }\n}\n\n/**\n * Barre d'actions groupées : apparaît avec la sélection, dit combien\n * d'éléments sont sélectionnés, porte les actions et « Tout désélectionner »\n * (aussi Échap, quand le focus est dans le tableau ou dans la barre). À\n * placer une fois, après le tableau : collante en bas de l'écran, elle reste\n * à portée au-dessus d'un long tableau sans le décaler.\n *\n * Quand elle disparaît avec le focus dedans (« Tout désélectionner », Échap,\n * action qui vide la sélection), le focus passe à la case d'en-tête du\n * tableau plutôt que de tomber sur `<body>`.\n *\n * Avec le `total` du tableau, le compte le situe (« 25 membres sur 137\n * sélectionnés ») ; quand toute la page est cochée, le menu « … » propose\n * « Sélectionner les 137 membres » (à la Gmail), à côté des\n * `actionsSecondaires`. Le menu n'apparaît que s'il a quelque chose à\n * proposer ; « Tout désélectionner » est une croix seule, avec infobulle.\n *\n * Avec `table`, elle suit la sélection d'un `DataTable` ; avec `nombre`,\n * `onToutDeselectionner` et `racine`, celle d'un tableau rendu à la main.\n * Sur téléphone, le compte, « … » et « × » restent ensemble sur la première\n * ligne, les actions passent dessous.\n */\nexport function DataTableBulkActions<TData extends RowData>(\n props: DataTableBulkActionsProps<TData>\n) {\n const {\n unite = UNITE_PAR_DEFAUT,\n feminin = false,\n children,\n actionsSecondaires,\n className,\n } = props\n const idResume = useId()\n const barreRef = useRef<HTMLDivElement>(null)\n const boutonDeselectionner = useRef<HTMLButtonElement>(null)\n // Entrée de « … » choisie, à exécuter une fois le menu fermé.\n const apresFermeture = useRef<(() => void) | null>(null)\n const {\n nombre,\n toutDeselectionner: vider,\n racine,\n surTotal,\n proposition,\n } = selectionDe(props)\n const visible = nombre > 0\n // « membres sur 137 sélectionnés », après le nombre (en gras à l'écran).\n const sur = surTotal === undefined ? \"\" : ` sur ${nombreFr(surTotal)}`\n const resume = `${uniteAccordee(nombre, unite)}${sur} ${participe(\"sélectionné\", nombre, feminin)}`\n\n // Dernier élément de la barre qui a eu le focus, tant que le focus n'est\n // pas parti ailleurs : s'il disparaît, on rattrape le focus — au tableau\n // si la barre est partie avec lui, sinon à « Tout désélectionner », qui\n // reste (action retirée de `children`). « … », lui, reste monté : son menu\n // rend le focus par `finalFocus`.\n const focusDansBarre = useRef<HTMLElement | null>(null)\n const toutDeselectionner = () => {\n if (barreRef.current?.contains(document.activeElement))\n focaliserTableau(racine())\n vider()\n }\n useLayoutEffect(() => {\n const perdu = focusDansBarre.current\n // Retiré du DOM, ou masqué sur place (« … » sans rien à proposer).\n const disparu =\n !!perdu && (!perdu.isConnected || perdu.closest(\"[hidden]\") !== null)\n if (\n !disparu ||\n (document.activeElement && document.activeElement !== document.body)\n ) {\n if (!visible) focusDansBarre.current = null\n return\n }\n focusDansBarre.current = null\n if (visible) boutonDeselectionner.current?.focus()\n else focaliserTableau(racine())\n })\n\n // Une sélection effacée est dite : la zone garderait sinon le dernier\n // compte. Rien avant la première sélection.\n const [dejaVisible, setDejaVisible] = useState(visible)\n if (visible && !dejaVisible) setDejaVisible(true)\n\n const surTouche = useEffectEvent((event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || echapPourUnChamp(event)) return\n // Échap ne s'adresse à la barre que depuis le tableau ou la barre : pas\n // depuis la navigation, ni depuis un dialogue ou un menu (rendus hors du\n // tableau, dans un portail).\n const cible = event.target as Node\n const dansTableau = racine()?.contains(cible) ?? false\n if (!dansTableau && !barreRef.current?.contains(cible)) return\n toutDeselectionner()\n })\n // Depuis un bouton de la barre, Échap est pris avant son infobulle (la\n // croix, « … ») : elle le consommerait, et il en faudrait un second.\n const surToucheDansBarre = useEffectEvent((event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || echapPourUnChamp(event)) return\n const cible = event.target as HTMLElement\n if (!barreRef.current?.contains(cible)) return\n // Déclencheur d'un menu ou d'un dialogue ouvert (`aria-expanded`), focus\n // encore sur lui : Échap ferme d'abord ce qu'il a ouvert. Son infobulle,\n // elle, ne compte pas.\n if (cible.getAttribute(\"aria-expanded\") === \"true\") return\n event.preventDefault()\n toutDeselectionner()\n })\n useEffect(() => {\n if (!visible) return\n document.addEventListener(\"keydown\", surToucheDansBarre, true)\n document.addEventListener(\"keydown\", surTouche)\n return () => {\n document.removeEventListener(\"keydown\", surToucheDansBarre, true)\n document.removeEventListener(\"keydown\", surTouche)\n }\n }, [visible])\n\n return (\n <>\n {/* Toujours montée : une zone annoncée insérée avec son texte n'est\n pas lue de façon fiable, la première case cochée passerait sous\n silence. */}\n <div\n data-slot=\"data-table-bulk-actions-status\"\n className=\"sr-only\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {visible\n ? `${nombreFr(nombre)} ${resume}`\n : dejaVisible\n ? \"Sélection effacée\"\n : null}\n </div>\n {visible ? (\n <div\n ref={barreRef}\n data-slot=\"data-table-bulk-actions\"\n role=\"toolbar\"\n aria-labelledby={idResume}\n onFocus={(event) => {\n focusDansBarre.current = event.target\n }}\n onBlur={(event) => {\n const vers = event.relatedTarget\n if (vers && !event.currentTarget.contains(vers))\n focusDansBarre.current = null\n }}\n className={cn(\n \"sticky bottom-4 z-20 mx-auto flex w-fit max-w-full flex-wrap items-center gap-2 rounded-xl border bg-popover p-1.5 pl-3 text-sm text-popover-foreground shadow-lg\",\n className\n )}\n >\n <span id={idResume} className=\"whitespace-nowrap\">\n <strong className=\"font-medium tabular-nums\">\n {nombreFr(nombre)}\n </strong>{\" \"}\n {resume}\n </span>\n <Separator\n orientation=\"vertical\"\n className=\"h-5 self-center! max-sm:hidden\"\n />\n {/* Sur mobile, le compte, « … » et « Tout désélectionner » forment\n la première ligne, les actions la suivante : la barre ne finit\n plus sur une croix seule, et les actions gardent toute leur\n ligne. L'ordre du DOM (celui de la tabulation) reste celui du\n bureau. */}\n <div className=\"flex flex-wrap items-center gap-1.5 max-sm:order-last max-sm:basis-full\">\n {children}\n </div>\n <div className=\"flex items-center gap-1.5 max-sm:ml-auto\">\n {/* Toujours monté avec la barre, masqué quand il n'a rien à\n proposer : démonté juste après une entrée choisie, le menu\n rendait le focus au dernier menu ou sélecteur ouvert ailleurs\n dans la page, par-dessus « Tout désélectionner ». */}\n <DropdownMenu\n onOpenChange={(ouvert) => {\n // Une entrée choisie lors d'une fermeture inachevée (barre\n // démontée entre-temps) ne vaut pas pour l'ouverture suivante.\n if (ouvert) apresFermeture.current = null\n }}\n onOpenChangeComplete={(ouvert) => {\n // L'entrée choisie n'agit qu'une fois le menu fermé et le\n // focus rendu (voir `finalFocus`).\n if (ouvert) return\n const action = apresFermeture.current\n apresFermeture.current = null\n action?.()\n }}\n >\n {/* Comme `DataTableRowActions` : infobulle, puis menu. */}\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Plus d'actions\"\n hidden={!proposition && !actionsSecondaires}\n />\n }\n />\n }\n >\n <MoreHorizontalIcon />\n </TooltipTrigger>\n <TooltipContent>Plus d'actions</TooltipContent>\n </Tooltip>\n <DropdownMenuContent\n side=\"top\"\n align=\"end\"\n className=\"w-auto\"\n // « Sélectionner les 137 » choisi sans autre entrée : « … »\n // va être masqué, le focus va droit à « Tout\n // désélectionner ».\n finalFocus={() =>\n apresFermeture.current && !actionsSecondaires\n ? boutonDeselectionner.current\n : true\n }\n >\n {proposition ? (\n <DropdownMenuItem\n onClick={() => {\n apresFermeture.current = proposition.selectionner\n }}\n >\n <ListChecksIcon />\n {`Sélectionner les ${nombreFr(proposition.total)} ${unite.pluriel}`}\n </DropdownMenuItem>\n ) : null}\n {proposition && actionsSecondaires ? (\n <DropdownMenuSeparator />\n ) : null}\n {actionsSecondaires}\n </DropdownMenuContent>\n </DropdownMenu>\n <TooltipButton\n ref={boutonDeselectionner}\n variant=\"ghost\"\n size=\"icon-sm\"\n infobulle=\"Tout désélectionner\"\n onClick={toutDeselectionner}\n aria-keyshortcuts=\"Escape\"\n >\n <XIcon />\n </TooltipButton>\n </div>\n </div>\n ) : null}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA2CA,SAASE,EAAiB,GAA+B;CACvD,IAAIC,EAAM,kBAAkB,OAAO;CACnC,IAAMC,IAAQD,EAAM;CACpB,OACEC,aAAiB,gBAChBA,EAAM,qBACL,4BAA4B,KAAKA,EAAM,OAAO,MAChD,EAAEA,aAAiB,oBAAoBA,EAAM,SAAS;AAE1D;AAkDA,SAASC,EACP,GASA;CACA,IAAI,CAACC,EAAM,OACT,OAAO;EACL,QAAQA,EAAM;EACd,oBAAoBA,EAAM;EAC1B,cAAcA,EAAM,QAA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,GAAA,kBAACO,GAAD;KACE,KAAK3C;KACL,SAAQ;KACR,MAAK;KACL,WAAU;KACV,SAASa;KACT,qBAAkB;KAElB,UAAA,kBAAC+B,IAAD,CAAQ,CAAA;IACK,CAAA,CACZ;;EACF;CACH,CAAA,IAAA,IACJ,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"data-table-bulk-actions.js","names":["_Fragment","Fragment$1","echapPourUnChamp","event","cible","selectionDe","props","meta","metaDe","table","aProposer","nombre","DataTableBulkActions","UNITE_PAR_DEFAUT","idResume","useId","barreRef","useRef","boutonDeselectionner","apresFermeture","vider","visible","sur","surTotal","nombreFr","resume","uniteAccordee","unite","participe","feminin","focusDansBarre","toutDeselectionner","focaliserTableau","racine","perdu","dejaVisible","setDejaVisible","useState","surTouche","useEffectEvent","surToucheDansBarre","useEffect","vers","cn","className","Separator","DropdownMenu","ouvert","action","Tooltip","TooltipTrigger","DropdownMenuTrigger","Button","proposition","actionsSecondaires","MoreHorizontalIcon","TooltipContent","DropdownMenuContent","DropdownMenuItem","ListChecksIcon","DropdownMenuSeparator","TooltipButton","XIcon"],"sources":["../../../src/components/etic/data-table-bulk-actions.tsx"],"sourcesContent":["import {\n useEffect,\n useEffectEvent,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from \"react\"\nimport type { RowData } from \"@tanstack/react-table\"\nimport { cn } from \"cn\"\nimport { ListChecksIcon, MoreHorizontalIcon, XIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@etic-ui/components/ui/tooltip\"\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@etic-ui/components/ui/dropdown-menu\"\nimport { TooltipButton } from \"@etic-ui/components/etic/tooltip-button\"\nimport { Separator } from \"@etic-ui/components/ui/separator\"\nimport {\n metaDe,\n type DataTableInstance,\n} from \"@etic-ui/components/etic/data-table\"\nimport { focaliserTableau } from \"@etic-ui/components/etic/data-table-focus\"\nimport {\n UNITE_PAR_DEFAUT,\n nombreFr,\n participe,\n uniteAccordee,\n type DataTableUnite,\n} from \"@etic-ui/components/etic/data-table-format\"\n\n/** Un Échap tapé dans un champ (recherche dans une cellule…) lui revient. */\nfunction echapPourUnChamp(event: KeyboardEvent): boolean {\n if (event.defaultPrevented) return true\n const cible = event.target\n return (\n cible instanceof HTMLElement &&\n (cible.isContentEditable ||\n /^(INPUT|TEXTAREA|SELECT)$/.test(cible.tagName)) &&\n !(cible instanceof HTMLInputElement && cible.type === \"checkbox\")\n )\n}\n\ninterface DataTableBulkActionsCommun {\n /** Nom des éléments : « 3 personnes sélectionnées ». « élément »,\n * « éléments » par défaut. */\n unite?: DataTableUnite\n /** Accorde « sélectionnées » au féminin. */\n feminin?: boolean\n /** Les actions : boutons `size=\"sm\"`. Les lignes visées viennent de\n * `table.getSelectedRowModel()` (ou `getSelectedRowIds()`) ; quand\n * `toutSelectionne` est vrai, l'action porte sur tous les éléments. */\n children: ReactNode\n /** Actions moins fréquentes, rangées dans le menu « … » de la barre :\n * des `DropdownMenuItem`. Le menu porte aussi « Sélectionner les 137 »\n * quand il est proposé. Une entrée qui vide aussitôt la sélection\n * démonte la barre et son menu : le focus tombe alors sur la page, pas\n * sur un autre menu (`DropdownMenuContent`). */\n actionsSecondaires?: ReactNode\n className?: string\n}\n\n/** Barre branchée sur l'instance d'un `DataTable`. */\nexport interface DataTableBulkActionsTableProps<\n TData extends RowData,\n> extends DataTableBulkActionsCommun {\n table: DataTableInstance<TData>\n}\n\n/**\n * Barre d'un tableau rendu à la main, sans instance `useDataTable` : la\n * sélection est celle de l'application.\n */\nexport interface DataTableBulkActionsSelectionProps extends DataTableBulkActionsCommun {\n table?: never\n /** Nombre d'éléments sélectionnés ; la barre s'affiche dès 1. */\n nombre: number\n /** « Tout désélectionner » et Échap. */\n onToutDeselectionner: () => void\n /** Cadre du tableau : Échap y vide la sélection, et le focus y revient\n * (sa case d'en-tête, sinon le cadre) quand la barre disparaît. */\n racine?: RefObject<HTMLElement | null>\n}\n\nexport type DataTableBulkActionsProps<TData extends RowData = RowData> =\n DataTableBulkActionsTableProps<TData> | DataTableBulkActionsSelectionProps\n\n/** Nombre, remise à zéro et cadre, lus dans le tableau ou donnés ; avec un\n * tableau, le total (« 25 membres sur 137 ») et sa proposition\n * (« Sélectionner les 137 »). */\nfunction selectionDe<TData extends RowData>(\n props: DataTableBulkActionsProps<TData>\n): {\n nombre: number\n toutDeselectionner: () => void\n racine: () => HTMLElement | null\n /** Total dont la sélection n'est qu'une partie. */\n surTotal?: number\n /** Total à proposer et son action. */\n proposition?: { total: number; selectionner: () => void }\n} {\n if (!props.table)\n return {\n nombre: props.nombre,\n toutDeselectionner: props.onToutDeselectionner,\n racine: () => props.racine?.current ?? null,\n }\n const { table } = props\n const meta = metaDe(table)\n const aProposer = meta.totalAProposer\n // « Tous sélectionnés » : le total, pas seulement les lignes de la page.\n const nombre =\n meta.toutSelectionne && meta.total !== undefined\n ? meta.total\n : table.getSelectedRowIds().length\n return {\n nombre,\n toutDeselectionner: meta.toutDeselectionner,\n racine: () => meta.racine.current,\n surTotal:\n meta.total !== undefined && meta.total > nombre ? meta.total : undefined,\n proposition:\n aProposer === undefined\n ? undefined\n : {\n total: aProposer,\n selectionner: () => meta.changerToutSelectionne(true),\n },\n }\n}\n\n/**\n * Barre d'actions groupées : apparaît avec la sélection, dit combien\n * d'éléments sont sélectionnés, porte les actions et « Tout désélectionner »\n * (aussi Échap, quand le focus est dans le tableau ou dans la barre). À\n * placer une fois, après le tableau : collante en bas de l'écran, elle reste\n * à portée au-dessus d'un long tableau sans le décaler.\n *\n * Quand elle disparaît avec le focus dedans (« Tout désélectionner », Échap,\n * action qui vide la sélection), le focus passe à la case d'en-tête du\n * tableau plutôt que de tomber sur `<body>`.\n *\n * Avec le `total` du tableau, le compte le situe (« 25 membres sur 137\n * sélectionnés ») ; quand toute la page est cochée, le menu « … » propose\n * « Sélectionner les 137 membres » (à la Gmail), à côté des\n * `actionsSecondaires`. Le menu n'apparaît que s'il a quelque chose à\n * proposer ; « Tout désélectionner » est une croix seule, avec infobulle.\n *\n * Avec `table`, elle suit la sélection d'un `DataTable` ; avec `nombre`,\n * `onToutDeselectionner` et `racine`, celle d'un tableau rendu à la main.\n * Sur téléphone, le compte, « … » et « × » restent ensemble sur la première\n * ligne, les actions passent dessous.\n */\nexport function DataTableBulkActions<TData extends RowData>(\n props: DataTableBulkActionsProps<TData>\n) {\n const {\n unite = UNITE_PAR_DEFAUT,\n feminin = false,\n children,\n actionsSecondaires,\n className,\n } = props\n const idResume = useId()\n const barreRef = useRef<HTMLDivElement>(null)\n const boutonDeselectionner = useRef<HTMLButtonElement>(null)\n // Entrée de « … » choisie, à exécuter une fois le menu fermé.\n const apresFermeture = useRef<(() => void) | null>(null)\n const {\n nombre,\n toutDeselectionner: vider,\n racine,\n surTotal,\n proposition,\n } = selectionDe(props)\n const visible = nombre > 0\n // « membres sur 137 sélectionnés », après le nombre (en gras à l'écran).\n const sur = surTotal === undefined ? \"\" : ` sur ${nombreFr(surTotal)}`\n const resume = `${uniteAccordee(nombre, unite)}${sur} ${participe(\"sélectionné\", nombre, feminin)}`\n\n // Dernier élément de la barre qui a eu le focus, tant que le focus n'est\n // pas parti ailleurs : s'il disparaît, on rattrape le focus — au tableau\n // si la barre est partie avec lui, sinon à « Tout désélectionner », qui\n // reste (action retirée de `children`). « … », lui, reste monté : son menu\n // rend le focus par `finalFocus`.\n const focusDansBarre = useRef<HTMLElement | null>(null)\n const toutDeselectionner = () => {\n if (barreRef.current?.contains(document.activeElement))\n focaliserTableau(racine())\n vider()\n }\n useLayoutEffect(() => {\n const perdu = focusDansBarre.current\n // Retiré du DOM, ou masqué sur place (« … » sans rien à proposer).\n const disparu =\n !!perdu && (!perdu.isConnected || perdu.closest(\"[hidden]\") !== null)\n if (\n !disparu ||\n (document.activeElement && document.activeElement !== document.body)\n ) {\n if (!visible) focusDansBarre.current = null\n return\n }\n focusDansBarre.current = null\n if (visible) boutonDeselectionner.current?.focus()\n else focaliserTableau(racine())\n })\n\n // Une sélection effacée est dite : la zone garderait sinon le dernier\n // compte. Rien avant la première sélection.\n const [dejaVisible, setDejaVisible] = useState(visible)\n if (visible && !dejaVisible) setDejaVisible(true)\n\n const surTouche = useEffectEvent((event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || echapPourUnChamp(event)) return\n // Échap ne s'adresse à la barre que depuis le tableau ou la barre : pas\n // depuis la navigation, ni depuis un dialogue ou un menu (rendus hors du\n // tableau, dans un portail).\n const cible = event.target as Node\n const dansTableau = racine()?.contains(cible) ?? false\n if (!dansTableau && !barreRef.current?.contains(cible)) return\n toutDeselectionner()\n })\n // Depuis un bouton de la barre, Échap est pris avant son infobulle (la\n // croix, « … ») : elle le consommerait, et il en faudrait un second.\n const surToucheDansBarre = useEffectEvent((event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || echapPourUnChamp(event)) return\n const cible = event.target as HTMLElement\n if (!barreRef.current?.contains(cible)) return\n // Déclencheur d'un menu ou d'un dialogue ouvert (`aria-expanded`), focus\n // encore sur lui : Échap ferme d'abord ce qu'il a ouvert. Son infobulle,\n // elle, ne compte pas.\n if (cible.getAttribute(\"aria-expanded\") === \"true\") return\n event.preventDefault()\n toutDeselectionner()\n })\n useEffect(() => {\n if (!visible) return\n document.addEventListener(\"keydown\", surToucheDansBarre, true)\n document.addEventListener(\"keydown\", surTouche)\n return () => {\n document.removeEventListener(\"keydown\", surToucheDansBarre, true)\n document.removeEventListener(\"keydown\", surTouche)\n }\n }, [visible])\n\n return (\n <>\n {/* Toujours montée : une zone annoncée insérée avec son texte n'est\n pas lue de façon fiable, la première case cochée passerait sous\n silence. */}\n <div\n data-slot=\"data-table-bulk-actions-status\"\n className=\"sr-only\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {visible\n ? `${nombreFr(nombre)} ${resume}`\n : dejaVisible\n ? \"Sélection effacée\"\n : null}\n </div>\n {visible ? (\n <div\n ref={barreRef}\n data-slot=\"data-table-bulk-actions\"\n role=\"toolbar\"\n aria-labelledby={idResume}\n onFocus={(event) => {\n focusDansBarre.current = event.target\n }}\n onBlur={(event) => {\n const vers = event.relatedTarget\n if (vers && !event.currentTarget.contains(vers))\n focusDansBarre.current = null\n }}\n className={cn(\n \"sticky bottom-4 z-20 mx-auto flex w-fit max-w-full flex-wrap items-center gap-2 rounded-xl border bg-popover p-1.5 pl-3 text-sm text-popover-foreground shadow-lg\",\n className\n )}\n >\n <span id={idResume} className=\"whitespace-nowrap\">\n <strong className=\"font-medium tabular-nums\">\n {nombreFr(nombre)}\n </strong>{\" \"}\n {resume}\n </span>\n <Separator\n orientation=\"vertical\"\n className=\"h-5 self-center! max-sm:hidden\"\n />\n {/* Sur mobile, le compte, « … » et « Tout désélectionner » forment\n la première ligne, les actions la suivante : la barre ne finit\n plus sur une croix seule, et les actions gardent toute leur\n ligne. L'ordre du DOM (celui de la tabulation) reste celui du\n bureau. */}\n <div className=\"flex flex-wrap items-center gap-1.5 max-sm:order-last max-sm:basis-full\">\n {children}\n </div>\n <div className=\"flex items-center gap-1.5 max-sm:ml-auto\">\n {/* Toujours monté avec la barre, masqué quand il n'a rien à\n proposer : démonté juste après une entrée choisie, le menu\n rendait le focus au dernier menu ou sélecteur ouvert ailleurs\n dans la page, par-dessus « Tout désélectionner ». */}\n <DropdownMenu\n onOpenChange={(ouvert) => {\n // Une entrée choisie lors d'une fermeture inachevée (barre\n // démontée entre-temps) ne vaut pas pour l'ouverture suivante.\n if (ouvert) apresFermeture.current = null\n }}\n onOpenChangeComplete={(ouvert) => {\n // L'entrée choisie n'agit qu'une fois le menu fermé et le\n // focus rendu (voir `finalFocus`).\n if (ouvert) return\n const action = apresFermeture.current\n apresFermeture.current = null\n action?.()\n }}\n >\n {/* Comme `DataTableRowActions` : infobulle, puis menu. */}\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Plus d'actions\"\n hidden={!proposition && !actionsSecondaires}\n />\n }\n />\n }\n >\n <MoreHorizontalIcon />\n </TooltipTrigger>\n <TooltipContent>Plus d'actions</TooltipContent>\n </Tooltip>\n <DropdownMenuContent\n side=\"top\"\n align=\"end\"\n className=\"w-auto\"\n // « Sélectionner les 137 » choisi sans autre entrée : « … »\n // va être masqué, le focus va droit à « Tout\n // désélectionner ».\n finalFocus={() =>\n apresFermeture.current && !actionsSecondaires\n ? boutonDeselectionner.current\n : true\n }\n >\n {proposition ? (\n <DropdownMenuItem\n onClick={() => {\n apresFermeture.current = proposition.selectionner\n }}\n >\n <ListChecksIcon />\n {`Sélectionner les ${nombreFr(proposition.total)} ${unite.pluriel}`}\n </DropdownMenuItem>\n ) : null}\n {proposition && actionsSecondaires ? (\n <DropdownMenuSeparator />\n ) : null}\n {actionsSecondaires}\n </DropdownMenuContent>\n </DropdownMenu>\n <TooltipButton\n ref={boutonDeselectionner}\n variant=\"ghost\"\n size=\"icon-sm\"\n infobulle=\"Tout désélectionner\"\n onClick={toutDeselectionner}\n aria-keyshortcuts=\"Escape\"\n >\n <XIcon />\n </TooltipButton>\n </div>\n </div>\n ) : null}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA2CA,SAASE,EAAiB,GAA+B;CACvD,IAAIC,EAAM,kBAAkB,OAAO;CACnC,IAAMC,IAAQD,EAAM;CACpB,OACEC,aAAiB,gBAChBA,EAAM,qBACL,4BAA4B,KAAKA,EAAM,OAAO,MAChD,EAAEA,aAAiB,oBAAoBA,EAAM,SAAS;AAE1D;AAiDA,SAASC,EACP,GASA;CACA,IAAI,CAACC,EAAM,OACT,OAAO;EACL,QAAQA,EAAM;EACd,oBAAoBA,EAAM;EAC1B,cAAcA,EAAM,QAAQ,WAAW;CACzC;CACF,IAAM,EAAE,aAAUA,GACZC,IAAOC,EAAOC,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,WAAU;KACV,SAASa;KACT,qBAAkB;KAElB,UAAA,kBAAC+B,IAAD,CAAQ,CAAA;IACK,CAAA,CACZ;;EACF;CACH,CAAA,IAAA,IACJ,EAAA,CAAA;AAEN"}
|
|
@@ -69,7 +69,7 @@ function A({ valeur: y, onValeurChange: S, paysParDefaut: T = "FR", pays: k, dis
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
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),
|
|
72
|
+
className: p("has-[[data-slot=input]:not([aria-invalid=true]):focus-visible]:ring-3 has-[[data-slot=input]:not([aria-invalid=true]):focus-visible]:ring-ring/50 has-[[data-slot=input]:not([aria-invalid=true]):focus-visible]:*:data-[slot=combobox-trigger]:border-ring *:data-[slot=input]:focus-visible:ring-0", "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
73
|
children: [/* @__PURE__ */ v(n, {
|
|
74
74
|
items: q,
|
|
75
75
|
value: q.find((e) => e.value === H.pays) ?? null,
|
|
@@ -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","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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,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
|
+
{"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 // De même au focus du numéro, hors erreur : bordure bleue sur le\n // sélecteur de pays et halo du groupe, à la place de celui du\n // numéro, qui n'en entourait que la moitié.\n \"has-[[data-slot=input]:not([aria-invalid=true]):focus-visible]:ring-3 has-[[data-slot=input]:not([aria-invalid=true]):focus-visible]:ring-ring/50 has-[[data-slot=input]:not([aria-invalid=true]):focus-visible]:*:data-[slot=combobox-trigger]:border-ring *:data-[slot=input]:focus-visible:ring-0\",\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,EAA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C,EAAO,KAAK,EAAE,IAAI5B,EAAsB4B,EAAO,KAAK,MAC/D,KAEO,CAAA;GACA,CAAA,GACjB,kBAACY,GAAD;IAAiB,WAAU;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,96 +1,134 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Button as e, buttonVariants as t } from "./button.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "./select.js";
|
|
4
|
+
import { cn as s } from "cn";
|
|
5
|
+
import * as c from "react";
|
|
6
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronDownIcon as d, ChevronLeftIcon as f, ChevronRightIcon as p } from "lucide-react";
|
|
8
|
+
import { DayPicker as m, getDefaultClassNames as h } from "react-day-picker";
|
|
9
|
+
import { fr as g } from "react-day-picker/locale/fr";
|
|
9
10
|
// src/components/ui/calendar.tsx
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
function _({ options: e = [], value: t, onChange: s, disabled: c, "aria-label": d }) {
|
|
12
|
+
let f = e.map(({ value: e, label: t }) => ({
|
|
13
|
+
value: e,
|
|
14
|
+
label: t
|
|
15
|
+
}));
|
|
16
|
+
return /* @__PURE__ */ u(n, {
|
|
17
|
+
items: f,
|
|
18
|
+
value: Number(t),
|
|
19
|
+
disabled: c,
|
|
20
|
+
onValueChange: (e) => {
|
|
21
|
+
e !== null && s?.({ target: { value: String(e) } });
|
|
22
|
+
},
|
|
23
|
+
children: [/* @__PURE__ */ l(a, {
|
|
24
|
+
size: "sm",
|
|
25
|
+
"aria-label": d,
|
|
26
|
+
className: "relative z-10 gap-1 border-none bg-transparent px-1.5 font-medium shadow-none hover:bg-muted data-[size=sm]:h-(--cell-size) dark:bg-transparent dark:hover:bg-muted [&_svg]:size-3.5",
|
|
27
|
+
children: /* @__PURE__ */ l(o, {})
|
|
28
|
+
}), /* @__PURE__ */ l(r, {
|
|
29
|
+
className: "max-h-[min(22rem,var(--available-height))] min-w-0",
|
|
30
|
+
children: e.map((e) => /* @__PURE__ */ l(i, {
|
|
31
|
+
value: e.value,
|
|
32
|
+
disabled: e.disabled,
|
|
33
|
+
children: e.label
|
|
34
|
+
}, e.value))
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function v({ className: e, rootRef: t, ...n }) {
|
|
39
|
+
return /* @__PURE__ */ l("div", {
|
|
40
|
+
"data-slot": "calendar",
|
|
41
|
+
ref: t,
|
|
42
|
+
className: s(e),
|
|
43
|
+
...n
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function y({ className: e, orientation: t, ...n }) {
|
|
47
|
+
return l(t === "left" ? f : t === "right" ? p : d, {
|
|
48
|
+
className: s("size-4", e),
|
|
49
|
+
...n
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function b({ children: e, ...t }) {
|
|
53
|
+
return /* @__PURE__ */ l("td", {
|
|
54
|
+
...t,
|
|
55
|
+
children: /* @__PURE__ */ l("div", {
|
|
56
|
+
className: "flex size-(--cell-size) items-center justify-center text-center",
|
|
57
|
+
children: e
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function x({ className: e, classNames: n, showOutsideDays: r = !0, captionLayout: i = "label", buttonVariant: a = "ghost", locale: o = g, weekStartsOn: u = 1, formatters: d, components: f, ...p }) {
|
|
62
|
+
let x = h(), C = c.useMemo(() => ({
|
|
63
|
+
Root: v,
|
|
64
|
+
Chevron: y,
|
|
65
|
+
DayButton: (e) => /* @__PURE__ */ l(S, {
|
|
66
|
+
locale: o,
|
|
67
|
+
...e
|
|
68
|
+
}),
|
|
69
|
+
Dropdown: _,
|
|
70
|
+
WeekNumber: b,
|
|
71
|
+
...f
|
|
72
|
+
}), [o, f]);
|
|
73
|
+
return /* @__PURE__ */ l(m, {
|
|
74
|
+
showOutsideDays: r,
|
|
75
|
+
className: s("group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(9)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent min-[1025px]:[--cell-size:--spacing(7)]", String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, e),
|
|
76
|
+
captionLayout: i,
|
|
77
|
+
locale: o,
|
|
78
|
+
weekStartsOn: u,
|
|
18
79
|
formatters: {
|
|
19
|
-
formatMonthDropdown: (e) => e.toLocaleString(
|
|
20
|
-
...
|
|
80
|
+
formatMonthDropdown: (e) => e.toLocaleString(o?.code, { month: "short" }),
|
|
81
|
+
...d
|
|
21
82
|
},
|
|
22
83
|
classNames: {
|
|
23
|
-
root:
|
|
24
|
-
months:
|
|
25
|
-
month:
|
|
26
|
-
nav:
|
|
27
|
-
button_previous:
|
|
28
|
-
button_next:
|
|
29
|
-
month_caption:
|
|
30
|
-
dropdowns:
|
|
31
|
-
dropdown_root:
|
|
32
|
-
dropdown:
|
|
33
|
-
caption_label:
|
|
34
|
-
month_grid:
|
|
35
|
-
weekdays:
|
|
36
|
-
weekday:
|
|
37
|
-
week:
|
|
38
|
-
week_number_header:
|
|
39
|
-
week_number:
|
|
40
|
-
day:
|
|
41
|
-
range_start:
|
|
42
|
-
range_middle:
|
|
43
|
-
range_end:
|
|
44
|
-
today:
|
|
45
|
-
outside:
|
|
46
|
-
disabled:
|
|
47
|
-
hidden:
|
|
48
|
-
...
|
|
49
|
-
},
|
|
50
|
-
components: {
|
|
51
|
-
Root: ({ className: e, rootRef: t, ...r }) => /* @__PURE__ */ i("div", {
|
|
52
|
-
"data-slot": "calendar",
|
|
53
|
-
ref: t,
|
|
54
|
-
className: n(e),
|
|
55
|
-
...r
|
|
56
|
-
}),
|
|
57
|
-
Chevron: ({ className: e, orientation: t, ...r }) => i(t === "left" ? o : t === "right" ? s : a, {
|
|
58
|
-
className: n("size-4", e),
|
|
59
|
-
...r
|
|
60
|
-
}),
|
|
61
|
-
DayButton: ({ ...e }) => /* @__PURE__ */ i(f, {
|
|
62
|
-
locale: h,
|
|
63
|
-
...e
|
|
64
|
-
}),
|
|
65
|
-
WeekNumber: ({ children: e, ...t }) => /* @__PURE__ */ i("td", {
|
|
66
|
-
...t,
|
|
67
|
-
children: /* @__PURE__ */ i("div", {
|
|
68
|
-
className: "flex size-(--cell-size) items-center justify-center text-center",
|
|
69
|
-
children: e
|
|
70
|
-
})
|
|
71
|
-
}),
|
|
72
|
-
...v
|
|
84
|
+
root: s("w-fit", x.root),
|
|
85
|
+
months: s("relative flex flex-col gap-4 md:flex-row", x.months),
|
|
86
|
+
month: s("flex w-full flex-col gap-4", x.month),
|
|
87
|
+
nav: s("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1", x.nav),
|
|
88
|
+
button_previous: s(t({ variant: a }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", x.button_previous),
|
|
89
|
+
button_next: s(t({ variant: a }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", x.button_next),
|
|
90
|
+
month_caption: s("flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)", x.month_caption),
|
|
91
|
+
dropdowns: s("flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium", x.dropdowns),
|
|
92
|
+
dropdown_root: s("relative rounded-(--cell-radius)", x.dropdown_root),
|
|
93
|
+
dropdown: s("absolute inset-0 bg-popover opacity-0", x.dropdown),
|
|
94
|
+
caption_label: s("font-medium select-none", i === "label" ? "text-sm" : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground", x.caption_label),
|
|
95
|
+
month_grid: s("w-full border-collapse", x.month_grid),
|
|
96
|
+
weekdays: s("flex", x.weekdays),
|
|
97
|
+
weekday: s("flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none", x.weekday),
|
|
98
|
+
week: s("mt-2 flex w-full", x.week),
|
|
99
|
+
week_number_header: s("w-(--cell-size) select-none", x.week_number_header),
|
|
100
|
+
week_number: s("text-[0.8rem] text-muted-foreground select-none", x.week_number),
|
|
101
|
+
day: s("group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)", p.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)" : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)", x.day),
|
|
102
|
+
range_start: s("relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted", x.range_start),
|
|
103
|
+
range_middle: s("rounded-none", x.range_middle),
|
|
104
|
+
range_end: s("relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted", x.range_end),
|
|
105
|
+
today: s("rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none", x.today),
|
|
106
|
+
outside: s("text-muted-foreground aria-selected:text-muted-foreground", x.outside),
|
|
107
|
+
disabled: s("text-muted-foreground opacity-50", x.disabled),
|
|
108
|
+
hidden: s("invisible", x.hidden),
|
|
109
|
+
...n
|
|
73
110
|
},
|
|
74
|
-
|
|
111
|
+
components: C,
|
|
112
|
+
...p
|
|
75
113
|
});
|
|
76
114
|
}
|
|
77
|
-
function
|
|
78
|
-
let
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
}, [
|
|
82
|
-
ref:
|
|
115
|
+
function S({ className: t, day: n, modifiers: r, locale: i, ...a }) {
|
|
116
|
+
let o = h(), u = c.useRef(null);
|
|
117
|
+
return c.useEffect(() => {
|
|
118
|
+
r.focused && u.current?.focus();
|
|
119
|
+
}, [r.focused]), /* @__PURE__ */ l(e, {
|
|
120
|
+
ref: u,
|
|
83
121
|
variant: "ghost",
|
|
84
122
|
size: "icon",
|
|
85
|
-
"data-day":
|
|
86
|
-
"data-selected-single":
|
|
87
|
-
"data-range-start":
|
|
88
|
-
"data-range-end":
|
|
89
|
-
"data-range-middle":
|
|
90
|
-
className:
|
|
91
|
-
...
|
|
123
|
+
"data-day": n.date.toLocaleDateString(i?.code),
|
|
124
|
+
"data-selected-single": r.selected && !r.range_start && !r.range_end && !r.range_middle,
|
|
125
|
+
"data-range-start": r.range_start,
|
|
126
|
+
"data-range-end": r.range_end,
|
|
127
|
+
"data-range-middle": r.range_middle,
|
|
128
|
+
className: s("relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70", o.day, t),
|
|
129
|
+
...a
|
|
92
130
|
});
|
|
93
131
|
}
|
|
94
|
-
export {
|
|
132
|
+
export { x as Calendar, S as CalendarDayButton };
|
|
95
133
|
|
|
96
134
|
//# sourceMappingURL=calendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","names":["React","Calendar","fr","props","defaultClassNames","getDefaultClassNames","DayPicker","cn","className","date","locale","formatters","buttonVariants","buttonVariant","captionLayout","classNames","rootRef","jsx","orientation","ChevronLeftIcon","ChevronRightIcon","ChevronDownIcon","CalendarDayButton","components","ref","modifiers","Button","day"],"sources":["../../../src/components/ui/calendar.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"cn\"\nimport {\n DayPicker,\n getDefaultClassNames,\n type DayButton,\n type Locale,\n} from \"react-day-picker\"\n// La seule locale française : `react-day-picker/locale` les charge toutes.\nimport { fr } from \"react-day-picker/locale/fr\"\n\nimport { Button, buttonVariants } from \"@etic-ui/components/ui/button\"\nimport {\n ChevronLeftIcon,\n ChevronRightIcon,\n ChevronDownIcon,\n} from \"lucide-react\"\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n captionLayout = \"label\",\n buttonVariant = \"ghost\",\n locale = fr,\n weekStartsOn = 1,\n formatters,\n components,\n ...props\n}: React.ComponentProps<typeof DayPicker> & {\n buttonVariant?: React.ComponentProps<typeof Button>[\"variant\"]\n}) {\n const defaultClassNames = getDefaultClassNames()\n\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn(\n \"group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(9)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent min-[1025px]:[--cell-size:--spacing(7)]\",\n String.raw`rtl:**:[.rdp-button\\_next>svg]:rotate-180`,\n String.raw`rtl:**:[.rdp-button\\_previous>svg]:rotate-180`,\n className\n )}\n captionLayout={captionLayout}\n locale={locale}\n weekStartsOn={weekStartsOn}\n formatters={{\n formatMonthDropdown: (date) =>\n date.toLocaleString(locale?.code, { month: \"short\" }),\n ...formatters,\n }}\n classNames={{\n root: cn(\"w-fit\", defaultClassNames.root),\n months: cn(\n \"relative flex flex-col gap-4 md:flex-row\",\n defaultClassNames.months\n ),\n month: cn(\"flex w-full flex-col gap-4\", defaultClassNames.month),\n nav: cn(\n \"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1\",\n defaultClassNames.nav\n ),\n button_previous: cn(\n buttonVariants({ variant: buttonVariant }),\n \"size-(--cell-size) p-0 select-none aria-disabled:opacity-50\",\n defaultClassNames.button_previous\n ),\n button_next: cn(\n buttonVariants({ variant: buttonVariant }),\n \"size-(--cell-size) p-0 select-none aria-disabled:opacity-50\",\n defaultClassNames.button_next\n ),\n month_caption: cn(\n \"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)\",\n defaultClassNames.month_caption\n ),\n dropdowns: cn(\n \"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium\",\n defaultClassNames.dropdowns\n ),\n dropdown_root: cn(\n \"relative rounded-(--cell-radius)\",\n defaultClassNames.dropdown_root\n ),\n dropdown: cn(\n \"absolute inset-0 bg-popover opacity-0\",\n defaultClassNames.dropdown\n ),\n caption_label: cn(\n \"font-medium select-none\",\n captionLayout === \"label\"\n ? \"text-sm\"\n : \"flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground\",\n defaultClassNames.caption_label\n ),\n month_grid: cn(\"w-full border-collapse\", defaultClassNames.month_grid),\n weekdays: cn(\"flex\", defaultClassNames.weekdays),\n weekday: cn(\n \"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none\",\n defaultClassNames.weekday\n ),\n week: cn(\"mt-2 flex w-full\", defaultClassNames.week),\n week_number_header: cn(\n \"w-(--cell-size) select-none\",\n defaultClassNames.week_number_header\n ),\n week_number: cn(\n \"text-[0.8rem] text-muted-foreground select-none\",\n defaultClassNames.week_number\n ),\n day: cn(\n \"group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)\",\n props.showWeekNumber\n ? \"[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)\"\n : \"[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)\",\n defaultClassNames.day\n ),\n range_start: cn(\n \"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted\",\n defaultClassNames.range_start\n ),\n range_middle: cn(\"rounded-none\", defaultClassNames.range_middle),\n range_end: cn(\n \"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted\",\n defaultClassNames.range_end\n ),\n today: cn(\n \"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none\",\n defaultClassNames.today\n ),\n outside: cn(\n \"text-muted-foreground aria-selected:text-muted-foreground\",\n defaultClassNames.outside\n ),\n disabled: cn(\n \"text-muted-foreground opacity-50\",\n defaultClassNames.disabled\n ),\n hidden: cn(\"invisible\", defaultClassNames.hidden),\n ...classNames,\n }}\n components={{\n Root: ({ className, rootRef, ...props }) => {\n return (\n <div\n data-slot=\"calendar\"\n ref={rootRef}\n className={cn(className)}\n {...props}\n />\n )\n },\n Chevron: ({ className, orientation, ...props }) => {\n if (orientation === \"left\") {\n return (\n <ChevronLeftIcon className={cn(\"size-4\", className)} {...props} />\n )\n }\n\n if (orientation === \"right\") {\n return (\n <ChevronRightIcon\n className={cn(\"size-4\", className)}\n {...props}\n />\n )\n }\n\n return (\n <ChevronDownIcon className={cn(\"size-4\", className)} {...props} />\n )\n },\n DayButton: ({ ...props }) => (\n <CalendarDayButton locale={locale} {...props} />\n ),\n WeekNumber: ({ children, ...props }) => {\n return (\n <td {...props}>\n <div className=\"flex size-(--cell-size) items-center justify-center text-center\">\n {children}\n </div>\n </td>\n )\n },\n ...components,\n }}\n {...props}\n />\n )\n}\n\nfunction CalendarDayButton({\n className,\n day,\n modifiers,\n locale,\n ...props\n}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {\n const defaultClassNames = getDefaultClassNames()\n\n const ref = React.useRef<HTMLButtonElement>(null)\n React.useEffect(() => {\n if (modifiers.focused) ref.current?.focus()\n }, [modifiers.focused])\n\n return (\n <Button\n ref={ref}\n variant=\"ghost\"\n size=\"icon\"\n data-day={day.date.toLocaleDateString(locale?.code)}\n data-selected-single={\n modifiers.selected &&\n !modifiers.range_start &&\n !modifiers.range_end &&\n !modifiers.range_middle\n }\n data-range-start={modifiers.range_start}\n data-range-end={modifiers.range_end}\n data-range-middle={modifiers.range_middle}\n className={cn(\n \"relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70\",\n defaultClassNames.day,\n className\n )}\n {...props}\n />\n )\n}\n\nexport { Calendar, CalendarDayButton }\n"],"mappings":";;;;;;;;;AAoBA,SAASC,EAAS,EAChB,cACA,eACA,qBAAkB,IAClB,mBAAgB,SAChB,mBAAgB,SAChB,YAASC,GACT,kBAAe,GACf,eACA,eACA,GAAGC,KAGF;CACD,IAAMC,IAAoBC,EAAqB;CAE/C,OACE,kBAACC,GAAD;EACmB;EACjB,WAAWC,EACT,iOACA,OAAO,GAAG,6CACV,OAAO,GAAG,iDACVC,CACF;EACe;EACP;EACM;EACd,YAAY;GACV,sBAAsB,MACpBC,EAAK,eAAeC,GAAQ,MAAM,EAAE,OAAO,QAAQ,CAAC;GACtD,GAAGC;EACL;EACA,YAAY;GACV,MAAMJ,EAAG,SAASH,EAAkB,IAAI;GACxC,QAAQG,EACN,4CACAH,EAAkB,MACpB;GACA,OAAOG,EAAG,8BAA8BH,EAAkB,KAAK;GAC/D,KAAKG,EACH,2EACAH,EAAkB,GACpB;GACA,iBAAiBG,EACfK,EAAe,EAAE,SAASC,EAAc,CAAC,GACzC,+DACAT,EAAkB,eACpB;GACA,aAAaG,EACXK,EAAe,EAAE,SAASC,EAAc,CAAC,GACzC,+DACAT,EAAkB,WACpB;GACA,eAAeG,EACb,4EACAH,EAAkB,aACpB;GACA,WAAWG,EACT,uFACAH,EAAkB,SACpB;GACA,eAAe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GAGR,GAAGoB;EACL;EACA,GAAIpB;CACL,CAAA;AAEL;AAEA,SAASmB,EAAkB,EACzB,cACA,QACA,cACA,WACA,GAAGnB,KACqE;CACxE,IAAMC,IAAoBC,EAAqB,GAEzCmB,IAAMxB,EAAM,OAA0B,IAAI;CAKhD,OAJAA,EAAM,gBAAgB;EACpB,AAAIyB,EAAU,WAASD,EAAI,SAAS,MAAM;CAC5C,GAAG,CAACC,EAAU,OAAO,CAAC,GAGpB,kBAACC,GAAD;EACO;EACL,SAAQ;EACR,MAAK;EACL,YAAUC,EAAI,KAAK,mBAAmBjB,GAAQ,IAAI;EAClD,wBACEe,EAAU,YACV,CAACA,EAAU,eACX,CAACA,EAAU,aACX,CAACA,EAAU;EAEb,oBAAkBA,EAAU;EAC5B,kBAAgBA,EAAU;EAC1B,qBAAmBA,EAAU;EAC7B,WAAWlB,EACT,w7BACAH,EAAkB,KAClBI,CACF;EACA,GAAIL;CACL,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"calendar.js","names":["React","CalendarDropdown","ariaLabel","items","options","Select","value","choisie","onChange","SelectTrigger","SelectValue","SelectContent","SelectItem","option","CalendarRoot","props","rootRef","cn","className","CalendarChevron","jsx","orientation","ChevronLeftIcon","ChevronRightIcon","ChevronDownIcon","CalendarWeekNumber","Calendar","fr","defaultClassNames","getDefaultClassNames","composants","CalendarDayButton","components","locale","DayPicker","date","formatters","buttonVariants","buttonVariant","captionLayout","classNames","ref","modifiers","Button","day"],"sources":["../../../src/components/ui/calendar.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"cn\"\nimport {\n DayPicker,\n getDefaultClassNames,\n type CustomComponents,\n type DayButton,\n type DropdownProps,\n type Locale,\n} from \"react-day-picker\"\n// La seule locale française : `react-day-picker/locale` les charge toutes.\nimport { fr } from \"react-day-picker/locale/fr\"\n\nimport { Button, buttonVariants } from \"@etic-ui/components/ui/button\"\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@etic-ui/components/ui/select\"\nimport {\n ChevronLeftIcon,\n ChevronRightIcon,\n ChevronDownIcon,\n} from \"lucide-react\"\n\n/**\n * Liste du mois ou de l'année (`captionLayout=\"dropdown\"`). Écart avec\n * shadcn : son `<select>` natif, transparent sur un libellé, ouvrait la liste\n * du système, sans le style de la bibliothèque. Ici, le `Select` de la\n * bibliothèque, à l'allure du libellé (sans bordure ni fond). react-day-picker\n * attend un `onChange` de `<select>` : il ne lit que `event.target.value`.\n */\nfunction CalendarDropdown({\n options = [],\n value,\n onChange,\n disabled,\n \"aria-label\": ariaLabel,\n}: DropdownProps) {\n const items = options.map(({ value, label }) => ({ value, label }))\n return (\n <Select\n items={items}\n value={Number(value)}\n disabled={disabled}\n onValueChange={(choisie) => {\n if (choisie === null) return\n onChange?.({\n target: { value: String(choisie) },\n } as React.ChangeEvent<HTMLSelectElement>)\n }}\n >\n <SelectTrigger\n size=\"sm\"\n aria-label={ariaLabel}\n // relative z-10 : au-dessus de la barre des flèches, posée en absolu\n // sur toute la largeur, qui prenait les clics. Hauteur des flèches\n // (--cell-size) : cible tactile de 36 px sur mobile.\n className=\"relative z-10 gap-1 border-none bg-transparent px-1.5 font-medium shadow-none hover:bg-muted data-[size=sm]:h-(--cell-size) dark:bg-transparent dark:hover:bg-muted [&_svg]:size-3.5\"\n >\n <SelectValue />\n </SelectTrigger>\n {/* Les douze mois tiennent sans défiler ; une liste d'années, qui peut\n compter un siècle, défile. */}\n <SelectContent className=\"max-h-[min(22rem,var(--available-height))] min-w-0\">\n {options.map((option) => (\n <SelectItem\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )\n}\n\nfunction CalendarRoot({\n className,\n rootRef,\n ...props\n}: CustomComponents[\"Root\"] extends React.ComponentType<infer P> ? P : never) {\n return (\n <div\n data-slot=\"calendar\"\n ref={rootRef}\n className={cn(className)}\n {...props}\n />\n )\n}\n\nfunction CalendarChevron({\n className,\n orientation,\n ...props\n}: CustomComponents[\"Chevron\"] extends React.ComponentType<infer P>\n ? P\n : never) {\n if (orientation === \"left\") {\n return <ChevronLeftIcon className={cn(\"size-4\", className)} {...props} />\n }\n\n if (orientation === \"right\") {\n return <ChevronRightIcon className={cn(\"size-4\", className)} {...props} />\n }\n\n return <ChevronDownIcon className={cn(\"size-4\", className)} {...props} />\n}\n\nfunction CalendarWeekNumber({\n children,\n ...props\n}: CustomComponents[\"WeekNumber\"] extends React.ComponentType<infer P>\n ? P\n : never) {\n return (\n <td {...props}>\n <div className=\"flex size-(--cell-size) items-center justify-center text-center\">\n {children}\n </div>\n </td>\n )\n}\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n captionLayout = \"label\",\n buttonVariant = \"ghost\",\n locale = fr,\n weekStartsOn = 1,\n formatters,\n components,\n ...props\n}: React.ComponentProps<typeof DayPicker> & {\n buttonVariant?: React.ComponentProps<typeof Button>[\"variant\"]\n}) {\n const defaultClassNames = getDefaultClassNames()\n // Écart avec shadcn, qui les écrit en ligne : des composants recréés à\n // chaque rendu sont, pour React, d'un type nouveau, et tout le calendrier\n // était remonté quand le parent le redessinait (mois piloté par `month`,\n // comme dans DatePicker) : le focus d'une liste du mois ou de l'année se\n // perdait. Ils ne changent qu'avec la locale ou `components`.\n const composants = React.useMemo(\n () => ({\n Root: CalendarRoot,\n Chevron: CalendarChevron,\n DayButton: (props: React.ComponentProps<typeof DayButton>) => (\n <CalendarDayButton locale={locale} {...props} />\n ),\n Dropdown: CalendarDropdown,\n WeekNumber: CalendarWeekNumber,\n ...components,\n }),\n [locale, components]\n )\n\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn(\n \"group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(9)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent min-[1025px]:[--cell-size:--spacing(7)]\",\n String.raw`rtl:**:[.rdp-button\\_next>svg]:rotate-180`,\n String.raw`rtl:**:[.rdp-button\\_previous>svg]:rotate-180`,\n className\n )}\n captionLayout={captionLayout}\n locale={locale}\n weekStartsOn={weekStartsOn}\n formatters={{\n formatMonthDropdown: (date) =>\n date.toLocaleString(locale?.code, { month: \"short\" }),\n ...formatters,\n }}\n classNames={{\n root: cn(\"w-fit\", defaultClassNames.root),\n months: cn(\n \"relative flex flex-col gap-4 md:flex-row\",\n defaultClassNames.months\n ),\n month: cn(\"flex w-full flex-col gap-4\", defaultClassNames.month),\n nav: cn(\n \"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1\",\n defaultClassNames.nav\n ),\n button_previous: cn(\n buttonVariants({ variant: buttonVariant }),\n \"size-(--cell-size) p-0 select-none aria-disabled:opacity-50\",\n defaultClassNames.button_previous\n ),\n button_next: cn(\n buttonVariants({ variant: buttonVariant }),\n \"size-(--cell-size) p-0 select-none aria-disabled:opacity-50\",\n defaultClassNames.button_next\n ),\n month_caption: cn(\n \"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)\",\n defaultClassNames.month_caption\n ),\n dropdowns: cn(\n \"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium\",\n defaultClassNames.dropdowns\n ),\n dropdown_root: cn(\n \"relative rounded-(--cell-radius)\",\n defaultClassNames.dropdown_root\n ),\n dropdown: cn(\n \"absolute inset-0 bg-popover opacity-0\",\n defaultClassNames.dropdown\n ),\n caption_label: cn(\n \"font-medium select-none\",\n captionLayout === \"label\"\n ? \"text-sm\"\n : \"flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground\",\n defaultClassNames.caption_label\n ),\n month_grid: cn(\"w-full border-collapse\", defaultClassNames.month_grid),\n weekdays: cn(\"flex\", defaultClassNames.weekdays),\n weekday: cn(\n \"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none\",\n defaultClassNames.weekday\n ),\n week: cn(\"mt-2 flex w-full\", defaultClassNames.week),\n week_number_header: cn(\n \"w-(--cell-size) select-none\",\n defaultClassNames.week_number_header\n ),\n week_number: cn(\n \"text-[0.8rem] text-muted-foreground select-none\",\n defaultClassNames.week_number\n ),\n day: cn(\n \"group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)\",\n props.showWeekNumber\n ? \"[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)\"\n : \"[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)\",\n defaultClassNames.day\n ),\n range_start: cn(\n \"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted\",\n defaultClassNames.range_start\n ),\n range_middle: cn(\"rounded-none\", defaultClassNames.range_middle),\n range_end: cn(\n \"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted\",\n defaultClassNames.range_end\n ),\n today: cn(\n \"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none\",\n defaultClassNames.today\n ),\n outside: cn(\n \"text-muted-foreground aria-selected:text-muted-foreground\",\n defaultClassNames.outside\n ),\n disabled: cn(\n \"text-muted-foreground opacity-50\",\n defaultClassNames.disabled\n ),\n hidden: cn(\"invisible\", defaultClassNames.hidden),\n ...classNames,\n }}\n components={composants}\n {...props}\n />\n )\n}\n\nfunction CalendarDayButton({\n className,\n day,\n modifiers,\n locale,\n ...props\n}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {\n const defaultClassNames = getDefaultClassNames()\n\n const ref = React.useRef<HTMLButtonElement>(null)\n React.useEffect(() => {\n if (modifiers.focused) ref.current?.focus()\n }, [modifiers.focused])\n\n return (\n <Button\n ref={ref}\n variant=\"ghost\"\n size=\"icon\"\n data-day={day.date.toLocaleDateString(locale?.code)}\n data-selected-single={\n modifiers.selected &&\n !modifiers.range_start &&\n !modifiers.range_end &&\n !modifiers.range_middle\n }\n data-range-start={modifiers.range_start}\n data-range-end={modifiers.range_end}\n data-range-middle={modifiers.range_middle}\n className={cn(\n \"relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70\",\n defaultClassNames.day,\n className\n )}\n {...props}\n />\n )\n}\n\nexport { Calendar, CalendarDayButton }\n"],"mappings":";;;;;;;;;;AAoCA,SAASC,EAAiB,EACxB,aAAU,CAAC,GACX,UACA,aACA,aACA,cAAcC,KACE;CAChB,IAAMC,IAAQC,EAAQ,KAAK,EAAE,UAAO,gBAAa;EAAE;EAAO;CAAM,EAAE;CAClE,OACE,kBAACC,GAAD;EACS;EACP,OAAO,OAAOC,CAAK;EACT;EACV,gBAAgB,MAAY;GAC1B,AAAIC,MAAY,QAChBC,IAAW,EACT,QAAQ,EAAE,OAAO,OAAOD,CAAO,EAAE,EACnC,CAAyC;EAC3C;EATF,UAAA,CAWE,kBAACE,GAAD;GACE,MAAK;GACL,cAAYP;GAIZ,WAAU;GAEV,UAAA,kBAACQ,GAAD,CAAc,CAAA;EACD,CAAA,GAGf,kBAACC,GAAD;GAAe,WAAU;GACtB,UAAAP,EAAQ,KAAK,MACZ,kBAACQ,GAAD;IAEE,OAAOC,EAAO;IACd,U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,WAASD,EAAI,SAAS,MAAM;CAC5C,GAAG,CAACC,EAAU,OAAO,CAAC,GAGpB,kBAACC,GAAD;EACO;EACL,SAAQ;EACR,MAAK;EACL,YAAUC,EAAI,KAAK,mBAAmBX,GAAQ,IAAI;EAClD,wBACES,EAAU,YACV,CAACA,EAAU,eACX,CAACA,EAAU,aACX,CAACA,EAAU;EAEb,oBAAkBA,EAAU;EAC5B,kBAAgBA,EAAU;EAC1B,qBAAmBA,EAAU;EAC7B,WAAWzB,EACT,w7BACAW,EAAkB,KAClBV,CACF;EACA,GAAIH;CACL,CAAA;AAEL"}
|
|
@@ -2,8 +2,8 @@ import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
declare function DropdownMenu({ ...props }: MenuPrimitive.Root.Props): React.JSX.Element;
|
|
4
4
|
declare function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props): React.JSX.Element;
|
|
5
|
-
declare function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props): React.JSX.Element;
|
|
6
|
-
declare function DropdownMenuContent({ align, alignOffset, side, sideOffset, className, ...props }: MenuPrimitive.Popup.Props & Pick<MenuPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">): React.JSX.Element;
|
|
5
|
+
declare function DropdownMenuTrigger({ ref, ...props }: MenuPrimitive.Trigger.Props): React.JSX.Element;
|
|
6
|
+
declare function DropdownMenuContent({ align, alignOffset, side, sideOffset, className, finalFocus, ...props }: MenuPrimitive.Popup.Props & Pick<MenuPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">): React.JSX.Element;
|
|
7
7
|
declare function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props): React.JSX.Element;
|
|
8
8
|
declare function DropdownMenuLabel({ className, inset, ...props }: MenuPrimitive.GroupLabel.Props & {
|
|
9
9
|
inset?: boolean;
|
|
@@ -1,137 +1,171 @@
|
|
|
1
1
|
import { cn as e } from "cn";
|
|
2
|
-
import "react";
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { CheckIcon as
|
|
5
|
-
import { Menu as
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { CheckIcon as i, ChevronRightIcon as a } from "lucide-react";
|
|
5
|
+
import { Menu as o } from "@base-ui/react/menu";
|
|
6
6
|
// src/components/ui/dropdown-menu.tsx
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
var s = t.createContext(null);
|
|
8
|
+
function c() {
|
|
9
|
+
let e = null;
|
|
10
|
+
return {
|
|
11
|
+
noter: (t) => {
|
|
12
|
+
t && (e = t);
|
|
13
|
+
},
|
|
14
|
+
lire: () => e
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function l(e, t) {
|
|
18
|
+
if (typeof e == "function") return e(t);
|
|
19
|
+
e && (e.current = t);
|
|
20
|
+
}
|
|
21
|
+
var u = t.createContext(!1);
|
|
22
|
+
function d(e, t, n) {
|
|
23
|
+
let r = typeof t == "function" ? t(e) : t ?? !0;
|
|
24
|
+
if (r !== !0) return r;
|
|
25
|
+
let i = document.activeElement;
|
|
26
|
+
if (i && i !== document.body && !i.closest("[data-slot^=\"dropdown-menu-\"]")) return !1;
|
|
27
|
+
let a = n?.lire();
|
|
28
|
+
return !a || a.isConnected;
|
|
29
|
+
}
|
|
30
|
+
function f({ ...e }) {
|
|
31
|
+
let [r] = t.useState(c);
|
|
32
|
+
return /* @__PURE__ */ n(s.Provider, {
|
|
33
|
+
value: r,
|
|
34
|
+
children: /* @__PURE__ */ n(o.Root, {
|
|
35
|
+
"data-slot": "dropdown-menu",
|
|
36
|
+
...e
|
|
37
|
+
})
|
|
11
38
|
});
|
|
12
39
|
}
|
|
13
|
-
function
|
|
14
|
-
return /* @__PURE__ */
|
|
40
|
+
function p({ ...e }) {
|
|
41
|
+
return /* @__PURE__ */ n(o.Portal, {
|
|
15
42
|
"data-slot": "dropdown-menu-portal",
|
|
16
43
|
...e
|
|
17
44
|
});
|
|
18
45
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
46
|
+
function m({ ref: e, ...r }) {
|
|
47
|
+
let i = t.useContext(s), a = t.useCallback((t) => (i?.noter(t), l(e, t)), [i, e]);
|
|
48
|
+
return /* @__PURE__ */ n(o.Trigger, {
|
|
21
49
|
"data-slot": "dropdown-menu-trigger",
|
|
22
|
-
|
|
50
|
+
ref: a,
|
|
51
|
+
...r
|
|
23
52
|
});
|
|
24
53
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
54
|
+
function h({ align: r = "start", alignOffset: i = 0, side: a = "bottom", sideOffset: c = 4, className: l, finalFocus: f, ...p }) {
|
|
55
|
+
let m = t.useContext(s), h = t.useContext(u);
|
|
56
|
+
return /* @__PURE__ */ n(o.Portal, { children: /* @__PURE__ */ n(o.Positioner, {
|
|
27
57
|
className: "isolate z-50 outline-none",
|
|
28
|
-
align:
|
|
29
|
-
alignOffset:
|
|
30
|
-
side:
|
|
31
|
-
sideOffset:
|
|
32
|
-
children: /* @__PURE__ */
|
|
58
|
+
align: r,
|
|
59
|
+
alignOffset: i,
|
|
60
|
+
side: a,
|
|
61
|
+
sideOffset: c,
|
|
62
|
+
children: /* @__PURE__ */ n(o.Popup, {
|
|
33
63
|
"data-slot": "dropdown-menu-content",
|
|
34
|
-
|
|
35
|
-
|
|
64
|
+
finalFocus: h || f && typeof f == "object" ? f : (e) => d(e, f, m),
|
|
65
|
+
className: e("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", l),
|
|
66
|
+
...p
|
|
36
67
|
})
|
|
37
68
|
}) });
|
|
38
69
|
}
|
|
39
|
-
function
|
|
40
|
-
return /* @__PURE__ */
|
|
70
|
+
function g({ ...e }) {
|
|
71
|
+
return /* @__PURE__ */ n(o.Group, {
|
|
41
72
|
"data-slot": "dropdown-menu-group",
|
|
42
73
|
...e
|
|
43
74
|
});
|
|
44
75
|
}
|
|
45
|
-
function
|
|
46
|
-
return /* @__PURE__ */
|
|
76
|
+
function _({ className: t, inset: r, ...i }) {
|
|
77
|
+
return /* @__PURE__ */ n(o.GroupLabel, {
|
|
47
78
|
"data-slot": "dropdown-menu-label",
|
|
48
79
|
"data-inset": r,
|
|
49
|
-
className: e("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
|
|
80
|
+
className: e("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7", t),
|
|
50
81
|
...i
|
|
51
82
|
});
|
|
52
83
|
}
|
|
53
|
-
function
|
|
54
|
-
return /* @__PURE__ */
|
|
84
|
+
function v({ className: t, inset: r, variant: i = "default", ...a }) {
|
|
85
|
+
return /* @__PURE__ */ n(o.Item, {
|
|
55
86
|
"data-slot": "dropdown-menu-item",
|
|
56
87
|
"data-inset": r,
|
|
57
88
|
"data-variant": i,
|
|
58
|
-
className: e("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
59
|
-
...
|
|
89
|
+
className: e("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive", t),
|
|
90
|
+
...a
|
|
60
91
|
});
|
|
61
92
|
}
|
|
62
|
-
function
|
|
63
|
-
return /* @__PURE__ */
|
|
93
|
+
function y({ ...e }) {
|
|
94
|
+
return /* @__PURE__ */ n(o.SubmenuRoot, {
|
|
64
95
|
"data-slot": "dropdown-menu-sub",
|
|
65
96
|
...e
|
|
66
97
|
});
|
|
67
98
|
}
|
|
68
|
-
function
|
|
69
|
-
return /* @__PURE__ */
|
|
99
|
+
function b({ className: t, inset: i, children: s, ...c }) {
|
|
100
|
+
return /* @__PURE__ */ r(o.SubmenuTrigger, {
|
|
70
101
|
"data-slot": "dropdown-menu-sub-trigger",
|
|
71
|
-
"data-inset":
|
|
72
|
-
className: e("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
102
|
+
"data-inset": i,
|
|
103
|
+
className: e("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", t),
|
|
73
104
|
...c,
|
|
74
|
-
children: [s, /* @__PURE__ */
|
|
105
|
+
children: [s, /* @__PURE__ */ n(a, { className: "ml-auto" })]
|
|
75
106
|
});
|
|
76
107
|
}
|
|
77
|
-
function
|
|
78
|
-
return /* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
108
|
+
function x({ align: t = "start", alignOffset: r = -3, side: i = "right", sideOffset: a = 0, className: o, ...s }) {
|
|
109
|
+
return /* @__PURE__ */ n(u.Provider, {
|
|
110
|
+
value: !0,
|
|
111
|
+
children: /* @__PURE__ */ n(h, {
|
|
112
|
+
"data-slot": "dropdown-menu-sub-content",
|
|
113
|
+
className: e("w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", o),
|
|
114
|
+
align: t,
|
|
115
|
+
alignOffset: r,
|
|
116
|
+
side: i,
|
|
117
|
+
sideOffset: a,
|
|
118
|
+
...s
|
|
119
|
+
})
|
|
86
120
|
});
|
|
87
121
|
}
|
|
88
|
-
function
|
|
89
|
-
return /* @__PURE__ */
|
|
122
|
+
function S({ className: t, children: a, checked: s, inset: c, ...l }) {
|
|
123
|
+
return /* @__PURE__ */ r(o.CheckboxItem, {
|
|
90
124
|
"data-slot": "dropdown-menu-checkbox-item",
|
|
91
125
|
"data-inset": c,
|
|
92
|
-
className: e("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
126
|
+
className: e("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", t),
|
|
93
127
|
checked: s,
|
|
94
128
|
...l,
|
|
95
|
-
children: [/* @__PURE__ */
|
|
129
|
+
children: [/* @__PURE__ */ n("span", {
|
|
96
130
|
className: "pointer-events-none absolute right-2 flex items-center justify-center",
|
|
97
131
|
"data-slot": "dropdown-menu-checkbox-item-indicator",
|
|
98
|
-
children: /* @__PURE__ */
|
|
99
|
-
}),
|
|
132
|
+
children: /* @__PURE__ */ n(o.CheckboxItemIndicator, { children: /* @__PURE__ */ n(i, {}) })
|
|
133
|
+
}), a]
|
|
100
134
|
});
|
|
101
135
|
}
|
|
102
|
-
function
|
|
103
|
-
return /* @__PURE__ */
|
|
136
|
+
function C({ ...e }) {
|
|
137
|
+
return /* @__PURE__ */ n(o.RadioGroup, {
|
|
104
138
|
"data-slot": "dropdown-menu-radio-group",
|
|
105
139
|
...e
|
|
106
140
|
});
|
|
107
141
|
}
|
|
108
|
-
function
|
|
109
|
-
return /* @__PURE__ */
|
|
142
|
+
function w({ className: t, children: a, inset: s, ...c }) {
|
|
143
|
+
return /* @__PURE__ */ r(o.RadioItem, {
|
|
110
144
|
"data-slot": "dropdown-menu-radio-item",
|
|
111
145
|
"data-inset": s,
|
|
112
|
-
className: e("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
146
|
+
className: e("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", t),
|
|
113
147
|
...c,
|
|
114
|
-
children: [/* @__PURE__ */
|
|
148
|
+
children: [/* @__PURE__ */ n("span", {
|
|
115
149
|
className: "pointer-events-none absolute right-2 flex items-center justify-center",
|
|
116
150
|
"data-slot": "dropdown-menu-radio-item-indicator",
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
}),
|
|
151
|
+
children: /* @__PURE__ */ n(o.RadioItemIndicator, { children: /* @__PURE__ */ n(i, {}) })
|
|
152
|
+
}), a]
|
|
119
153
|
});
|
|
120
154
|
}
|
|
121
|
-
function
|
|
122
|
-
return /* @__PURE__ */
|
|
155
|
+
function T({ className: t, ...r }) {
|
|
156
|
+
return /* @__PURE__ */ n(o.Separator, {
|
|
123
157
|
"data-slot": "dropdown-menu-separator",
|
|
124
|
-
className: e("-mx-1 my-1 h-px bg-border",
|
|
158
|
+
className: e("-mx-1 my-1 h-px bg-border", t),
|
|
125
159
|
...r
|
|
126
160
|
});
|
|
127
161
|
}
|
|
128
|
-
function
|
|
129
|
-
return /* @__PURE__ */
|
|
162
|
+
function E({ className: t, ...r }) {
|
|
163
|
+
return /* @__PURE__ */ n("span", {
|
|
130
164
|
"data-slot": "dropdown-menu-shortcut",
|
|
131
|
-
className: e("ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
|
|
165
|
+
className: e("ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground", t),
|
|
132
166
|
...r
|
|
133
167
|
});
|
|
134
168
|
}
|
|
135
|
-
export {
|
|
169
|
+
export { f as DropdownMenu, S as DropdownMenuCheckboxItem, h as DropdownMenuContent, g as DropdownMenuGroup, v as DropdownMenuItem, _ as DropdownMenuLabel, p as DropdownMenuPortal, C as DropdownMenuRadioGroup, w as DropdownMenuRadioItem, T as DropdownMenuSeparator, E as DropdownMenuShortcut, y as DropdownMenuSub, x as DropdownMenuSubContent, b as DropdownMenuSubTrigger, m as DropdownMenuTrigger };
|
|
136
170
|
|
|
137
171
|
//# sourceMappingURL=dropdown-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-menu.js","names":["MenuPrimitive","DropdownMenu","props","Menu","DropdownMenuPortal","DropdownMenuTrigger","DropdownMenuContent","cn","className","DropdownMenuGroup","DropdownMenuLabel","inset","DropdownMenuItem","variant","DropdownMenuSub","DropdownMenuSubTrigger","children","ChevronRightIcon","DropdownMenuSubContent","DropdownMenuCheckboxItem","CheckIcon","DropdownMenuRadioGroup","DropdownMenuRadioItem","DropdownMenuSeparator","DropdownMenuShortcut"],"sources":["../../../src/components/ui/dropdown-menu.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\"\nimport { cn } from \"cn\"\nimport { ChevronRightIcon, CheckIcon } from \"lucide-react\"\n\nfunction DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {\n return <MenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />\n}\n\nfunction DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {\n return <MenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" {...props} />\n}\n\nfunction DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {\n return <MenuPrimitive.Trigger data-slot=\"dropdown-menu-trigger\" {...props} />\n}\n\nfunction DropdownMenuContent({\n align = \"start\",\n alignOffset = 0,\n side = \"bottom\",\n sideOffset = 4,\n className,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<\n MenuPrimitive.Positioner.Props,\n \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\"\n >) {\n return (\n <MenuPrimitive.Portal>\n <MenuPrimitive.Positioner\n className=\"isolate z-50 outline-none\"\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n className={cn(\n \"z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95\",\n className\n )}\n {...props}\n />\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n )\n}\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return <MenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: MenuPrimitive.GroupLabel.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.GroupLabel\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n \"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = \"default\",\n ...props\n}: MenuPrimitive.Item.Props & {\n inset?: boolean\n variant?: \"default\" | \"destructive\"\n}) {\n return (\n <MenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {\n return <MenuPrimitive.SubmenuRoot data-slot=\"dropdown-menu-sub\" {...props} />\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: MenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.SubmenuTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n \"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"ml-auto\" />\n </MenuPrimitive.SubmenuTrigger>\n )\n}\n\nfunction DropdownMenuSubContent({\n align = \"start\",\n alignOffset = -3,\n side = \"right\",\n sideOffset = 0,\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuContent>) {\n return (\n <DropdownMenuContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n \"w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n className\n )}\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n \"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n checked={checked}\n {...props}\n >\n <span\n className=\"pointer-events-none absolute right-2 flex items-center justify-center\"\n data-slot=\"dropdown-menu-checkbox-item-indicator\"\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <CheckIcon />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </MenuPrimitive.CheckboxItem>\n )\n}\n\nfunction DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {\n return (\n <MenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n )\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n data-inset={inset}\n className={cn(\n \"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n >\n <span\n className=\"pointer-events-none absolute right-2 flex items-center justify-center\"\n data-slot=\"dropdown-menu-radio-item-indicator\"\n >\n <MenuPrimitive.RadioItemIndicator>\n <CheckIcon />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </MenuPrimitive.RadioItem>\n )\n}\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn(\"-mx-1 my-1 h-px bg-border\", className)}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n \"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n}\n"],"mappings":";;;;;;AAKA,SAASC,EAAa,EAAE,GAAGC,KAAmC;CAC5D,OAAO,kBAACF,EAAc,MAAf;EAAoB,aAAU;EAAgB,GAAIE;CAAQ,CAAA;AACnE;AAEA,SAASE,EAAmB,EAAE,GAAGF,KAAqC;CACpE,OAAO,kBAACF,EAAc,QAAf;EAAsB,aAAU;EAAuB,GAAIE;CAAQ,CAAA;AAC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,CACF;EACA,GAAIN;CACL,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","names":["MenuPrimitive","React","DeclencheurContext","creerSuivi","dernier","element","assignerRef","ref","valeur","SousMenuContext","focusFinal","voulu","donne","type","actif","declencheur","suivi","DropdownMenu","props","Menu","DropdownMenuPortal","DropdownMenuTrigger","lier","DropdownMenuContent","sousMenu","finalFocus","cn","className","DropdownMenuGroup","DropdownMenuLabel","inset","DropdownMenuItem","variant","DropdownMenuSub","DropdownMenuSubTrigger","children","ChevronRightIcon","DropdownMenuSubContent","DropdownMenuCheckboxItem","CheckIcon","DropdownMenuRadioGroup","DropdownMenuRadioItem","DropdownMenuSeparator","DropdownMenuShortcut"],"sources":["../../../src/components/ui/dropdown-menu.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\"\nimport { cn } from \"cn\"\nimport { ChevronRightIcon, CheckIcon } from \"lucide-react\"\n\n// Écart ETIC : le dernier déclencheur monté, pour le `finalFocus` par défaut\n// de DropdownMenuContent. Gardé une fois démonté : `isConnected` dit alors\n// qu'il a disparu. Un objet créé une fois plutôt qu'un état : noter le\n// déclencheur ne redessine pas le menu (un par ligne d'un tableau). Avec\n// plusieurs déclencheurs sur un même menu (non utilisé), c'est le dernier\n// monté qui compte.\ninterface SuiviDeclencheur {\n noter: (element: HTMLElement | null) => void\n lire: () => HTMLElement | null\n}\n\nconst DeclencheurContext = React.createContext<SuiviDeclencheur | null>(null)\n\nfunction creerSuivi(): SuiviDeclencheur {\n let dernier: HTMLElement | null = null\n return {\n noter: (element) => {\n if (element) dernier = element\n },\n lire: () => dernier,\n }\n}\n\n/** Transmet l'élément à la `ref` reçue, fonction ou objet ; rend le\n * nettoyage qu'une ref fonction peut renvoyer (React 19). */\nfunction assignerRef<T>(ref: React.Ref<T> | undefined, valeur: T | null) {\n if (typeof ref === \"function\") return ref(valeur)\n if (ref) ref.current = valeur\n}\n\n// Contenu d'un sous-menu : Base UI y a sa propre logique de retour de focus\n// (vers le menu parent), que la garde de DropdownMenuContent ne remplace pas.\nconst SousMenuContext = React.createContext(false)\n\ntype FinalFocus = MenuPrimitive.Popup.Props[\"finalFocus\"]\ntype FinalFocusFonction = Extract<FinalFocus, (...args: never) => unknown>\ntype TypeFermeture = Parameters<FinalFocusFonction>[0]\n\n/**\n * Écart ETIC : `finalFocus` du menu principal. À la fermeture, Base UI rend\n * le focus au déclencheur ; retiré du DOM (ligne supprimée, barre retirée),\n * il se repliait sur un historique global — un autre menu ou sélecteur de la\n * page. Rien n'est focalisé alors : le focus tombe sur `<body>`, où les\n * rattrapages (ligne supprimée d'un DataTable, barre d'actions) le\n * reprennent. Une fonction rendant le retour « explicite » pour Base UI, on\n * garde nous-mêmes sa règle : un focus parti ailleurs (dialogue ouvert depuis\n * une entrée) y reste. Le `finalFocus` donné passe d'abord ; s'il vaut\n * `true` (retour par défaut), la garde s'applique. (Une ref donnée est\n * passée telle quelle, sans garde.)\n */\nfunction focusFinal(\n type: TypeFermeture,\n donne: FinalFocusFonction | boolean | undefined,\n suivi: SuiviDeclencheur | null\n): ReturnType<FinalFocusFonction> {\n const voulu = typeof donne === \"function\" ? donne(type) : (donne ?? true)\n if (voulu !== true) return voulu\n const actif = document.activeElement\n if (\n actif &&\n actif !== document.body &&\n !actif.closest('[data-slot^=\"dropdown-menu-\"]')\n )\n return false\n const declencheur = suivi?.lire()\n return !declencheur || declencheur.isConnected\n}\n\nfunction DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {\n const [suivi] = React.useState(creerSuivi)\n return (\n <DeclencheurContext.Provider value={suivi}>\n <MenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />\n </DeclencheurContext.Provider>\n )\n}\n\nfunction DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {\n return <MenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" {...props} />\n}\n\nfunction DropdownMenuTrigger({ ref, ...props }: MenuPrimitive.Trigger.Props) {\n const suivi = React.useContext(DeclencheurContext)\n const lier = React.useCallback(\n (element: HTMLButtonElement | null) => {\n suivi?.noter(element)\n return assignerRef(ref, element)\n },\n [suivi, ref]\n )\n return (\n <MenuPrimitive.Trigger\n data-slot=\"dropdown-menu-trigger\"\n ref={lier}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuContent({\n align = \"start\",\n alignOffset = 0,\n side = \"bottom\",\n sideOffset = 4,\n className,\n finalFocus,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<\n MenuPrimitive.Positioner.Props,\n \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\"\n >) {\n const suivi = React.useContext(DeclencheurContext)\n const sousMenu = React.useContext(SousMenuContext)\n return (\n <MenuPrimitive.Portal>\n <MenuPrimitive.Positioner\n className=\"isolate z-50 outline-none\"\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n finalFocus={\n sousMenu || (finalFocus && typeof finalFocus === \"object\")\n ? finalFocus\n : (type: TypeFermeture) => focusFinal(type, finalFocus, suivi)\n }\n className={cn(\n \"z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95\",\n className\n )}\n {...props}\n />\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n )\n}\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return <MenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: MenuPrimitive.GroupLabel.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.GroupLabel\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n \"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = \"default\",\n ...props\n}: MenuPrimitive.Item.Props & {\n inset?: boolean\n variant?: \"default\" | \"destructive\"\n}) {\n return (\n <MenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {\n return <MenuPrimitive.SubmenuRoot data-slot=\"dropdown-menu-sub\" {...props} />\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: MenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.SubmenuTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n \"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"ml-auto\" />\n </MenuPrimitive.SubmenuTrigger>\n )\n}\n\nfunction DropdownMenuSubContent({\n align = \"start\",\n alignOffset = -3,\n side = \"right\",\n sideOffset = 0,\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuContent>) {\n return (\n <SousMenuContext.Provider value>\n <DropdownMenuContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n \"w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n className\n )}\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n {...props}\n />\n </SousMenuContext.Provider>\n )\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n \"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n checked={checked}\n {...props}\n >\n <span\n className=\"pointer-events-none absolute right-2 flex items-center justify-center\"\n data-slot=\"dropdown-menu-checkbox-item-indicator\"\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <CheckIcon />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </MenuPrimitive.CheckboxItem>\n )\n}\n\nfunction DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {\n return (\n <MenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n )\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n data-inset={inset}\n className={cn(\n \"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n >\n <span\n className=\"pointer-events-none absolute right-2 flex items-center justify-center\"\n data-slot=\"dropdown-menu-radio-item-indicator\"\n >\n <MenuPrimitive.RadioItemIndicator>\n <CheckIcon />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </MenuPrimitive.RadioItem>\n )\n}\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn(\"-mx-1 my-1 h-px bg-border\", className)}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n \"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n}\n"],"mappings":";;;;;;AAgBA,IAAME,IAAqBD,EAAM,cAAuC,IAAI;AAE5E,SAASE,IAA+B;CACtC,IAAIC,IAA8B;CAClC,OAAO;EACL,QAAQ,MAAY;GAClB,AAAIC,MAAS,IAAUA;EACzB;EACA,YAAYD;CACd;AACF;AAIA,SAASE,EAAe,GAA+B,GAAkB;CACvE,IAAI,OAAOC,KAAQ,YAAY,OAAOA,EAAIC,CAAM;CAChD,AAAID,MAAK,EAAI,UAAUC;AACzB;AAIA,IAAMC,IAAkBR,EAAM,cAAc,EAAK;AAkBjD,SAASS,EACP,GACA,GACA,GACgC;CAChC,IAAMC,IAAQ,OAAOC,KAAU,aAAaA,EAAMC,CAAI,IAAKD,KAAS;CACpE,IAAID,MAAU,IAAM,OAAOA;CAC3B,IAAMG,IAAQ,SAAS;CACvB,IACEA,KACAA,MAAU,SAAS,QACnB,CAACA,EAAM,QAAQ,iCAA+B,GAE9C,OAAO;CACT,IAAMC,IAAcC,GAAO,KAAK;CAChC,OAAO,CAACD,KAAeA,EAAY;AACrC;AAEA,SAASE,EAAa,EAAE,GAAGC,KAAmC;CAC5D,IAAM,CAACF,KAASf,EAAM,SAASE,CAAU;CACzC,OACE,kBAACD,EAAmB,UAApB;EAA6B,OAAOc;EAClC,UAAA,kBAAChB,EAAc,MAAf;GAAoB,aAAU;GAAgB,GAAIkB;EAAQ,CAAA;CAC/B,CAAA;AAEjC;AAEA,SAASE,EAAmB,EAAE,GAAGF,KAAqC;CACpE,OAAO,kBAAClB,EAAc,QAAf;EAAsB,aAAU;EAAuB,GAAIkB;CAAQ,CAAA;AAC5E;AAEA,SAASG,EAAoB,EAAE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WAAU;GACV,aAAU;GAEV,UAAA,kBAAClB,EAAc,oBAAf,EAAA,UACE,kBAACuC,GAAD,CAAY,CAAA,EACoB,CAAA;EAC9B,CAAA,GACLJ,CACsB;;AAE7B;AAEA,SAASO,EAAsB,EAC7B,cACA,GAAGxB,KAC6B;CAChC,OACE,kBAAClB,EAAc,WAAf;EACE,aAAU;EACV,WAAW0B,EAAG,6BAA6BC,CAAS;EACpD,GAAIT;CACL,CAAA;AAEL;AAEA,SAASyB,EAAqB,EAC5B,cACA,GAAGzB,KAC4B;CAC/B,OACE,kBAAC,QAAD;EACE,aAAU;EACV,WAAWQ,EACT,+GACAC,CACF;EACA,GAAIT;CACL,CAAA;AAEL"}
|
package/dist/styles.css
CHANGED
|
@@ -835,15 +835,11 @@
|
|
|
835
835
|
--info: #7cb4f5;
|
|
836
836
|
--border: oklch(1 0 0 / 10%);
|
|
837
837
|
--input: oklch(1 0 0 / 15%);
|
|
838
|
-
/*
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
Redéclaré ici
|
|
842
|
-
--control-border:
|
|
843
|
-
in oklab,
|
|
844
|
-
var(--muted-foreground) 65%,
|
|
845
|
-
transparent
|
|
846
|
-
);
|
|
838
|
+
/* --input du registre, comme shadcn : exception assumée à WCAG 1.4.11
|
|
839
|
+
(blanc à 15 %, sous 2:1). Le bord dérivé de --muted-foreground
|
|
840
|
+
ressortait trop sur le gris foncé, colonne de sélection d'un tableau en
|
|
841
|
+
tête. Redéclaré ici, pour un « dark » posé plus bas que <html>. */
|
|
842
|
+
--control-border: var(--input);
|
|
847
843
|
--chart-1: oklch(0.488 0.243 264.376);
|
|
848
844
|
--chart-2: oklch(0.696 0.17 162.48);
|
|
849
845
|
--chart-3: oklch(0.769 0.188 70.08);
|