@etic-insa/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +438 -37
- package/dist/components/etic/action.d.ts +16 -7
- package/dist/components/etic/action.js +25 -25
- package/dist/components/etic/action.js.map +1 -1
- package/dist/components/etic/app-shell.d.ts +16 -7
- package/dist/components/etic/app-shell.js +92 -85
- package/dist/components/etic/app-shell.js.map +1 -1
- package/dist/components/etic/auth-image.d.ts +29 -6
- package/dist/components/etic/auth-image.js +41 -18
- package/dist/components/etic/auth-image.js.map +1 -1
- package/dist/components/etic/button-link.d.ts +19 -0
- package/dist/components/etic/button-link.js +19 -0
- package/dist/components/etic/button-link.js.map +1 -0
- package/dist/components/etic/centered-screen.d.ts +13 -0
- package/dist/components/etic/centered-screen.js +13 -0
- package/dist/components/etic/centered-screen.js.map +1 -0
- package/dist/components/etic/confirm-dialog.d.ts +33 -3
- package/dist/components/etic/confirm-dialog.js +92 -67
- package/dist/components/etic/confirm-dialog.js.map +1 -1
- package/dist/components/etic/copy-button.d.ts +3 -2
- package/dist/components/etic/copy-button.js +3 -3
- package/dist/components/etic/copy-button.js.map +1 -1
- package/dist/components/etic/data-table-bulk-actions.d.ts +28 -4
- package/dist/components/etic/data-table-bulk-actions.js +48 -41
- package/dist/components/etic/data-table-bulk-actions.js.map +1 -1
- package/dist/components/etic/data-table-focus.d.ts +17 -0
- package/dist/components/etic/data-table-focus.js +29 -0
- package/dist/components/etic/data-table-focus.js.map +1 -0
- package/dist/components/etic/data-table-format.d.ts +3 -10
- package/dist/components/etic/data-table-format.js +4 -3
- package/dist/components/etic/data-table-format.js.map +1 -1
- package/dist/components/etic/data-table-pagination.d.ts +20 -6
- package/dist/components/etic/data-table-pagination.js +73 -43
- package/dist/components/etic/data-table-pagination.js.map +1 -1
- package/dist/components/etic/data-table-toolbar.d.ts +34 -13
- package/dist/components/etic/data-table-toolbar.js +66 -62
- package/dist/components/etic/data-table-toolbar.js.map +1 -1
- package/dist/components/etic/data-table-view-options.d.ts +44 -4
- package/dist/components/etic/data-table-view-options.js +145 -98
- package/dist/components/etic/data-table-view-options.js.map +1 -1
- package/dist/components/etic/data-table.d.ts +173 -15
- package/dist/components/etic/data-table.js +381 -202
- package/dist/components/etic/data-table.js.map +1 -1
- package/dist/components/etic/date-picker.d.ts +5 -1
- package/dist/components/etic/date-picker.js +97 -84
- package/dist/components/etic/date-picker.js.map +1 -1
- package/dist/components/etic/delete-button.d.ts +12 -4
- package/dist/components/etic/delete-button.js +21 -22
- package/dist/components/etic/delete-button.js.map +1 -1
- package/dist/components/etic/detail-list.d.ts +16 -4
- package/dist/components/etic/detail-list.js +30 -20
- package/dist/components/etic/detail-list.js.map +1 -1
- package/dist/components/etic/disclosure.d.ts +52 -0
- package/dist/components/etic/disclosure.js +70 -0
- package/dist/components/etic/disclosure.js.map +1 -0
- package/dist/components/etic/draft-resume-dialog.d.ts +42 -0
- package/dist/components/etic/draft-resume-dialog.js +60 -0
- package/dist/components/etic/draft-resume-dialog.js.map +1 -0
- package/dist/components/etic/error-banner.js +34 -38
- package/dist/components/etic/error-banner.js.map +1 -1
- package/dist/components/etic/error-boundary.js +4 -3
- package/dist/components/etic/error-boundary.js.map +1 -1
- package/dist/components/etic/explained-badge.d.ts +26 -0
- package/dist/components/etic/explained-badge.js +17 -0
- package/dist/components/etic/explained-badge.js.map +1 -0
- package/dist/components/etic/file-upload.js +66 -71
- package/dist/components/etic/file-upload.js.map +1 -1
- package/dist/components/etic/form-dialog.d.ts +25 -2
- package/dist/components/etic/form-dialog.js +95 -77
- package/dist/components/etic/form-dialog.js.map +1 -1
- package/dist/components/etic/icon-toggle.d.ts +27 -9
- package/dist/components/etic/icon-toggle.js +31 -19
- package/dist/components/etic/icon-toggle.js.map +1 -1
- package/dist/components/etic/lien.d.ts +34 -0
- package/dist/components/etic/lien.js +17 -0
- package/dist/components/etic/lien.js.map +1 -0
- package/dist/components/etic/loading.d.ts +0 -8
- package/dist/components/etic/loading.js +17 -25
- package/dist/components/etic/loading.js.map +1 -1
- package/dist/components/etic/page-container.d.ts +10 -0
- package/dist/components/etic/page-container.js +9 -5
- package/dist/components/etic/page-container.js.map +1 -1
- package/dist/components/etic/page-header.d.ts +10 -4
- package/dist/components/etic/page-header.js +48 -43
- package/dist/components/etic/page-header.js.map +1 -1
- package/dist/components/etic/phone-input.d.ts +16 -0
- package/dist/components/etic/phone-input.js +71 -65
- package/dist/components/etic/phone-input.js.map +1 -1
- package/dist/components/etic/query-boundary.d.ts +25 -2
- package/dist/components/etic/query-boundary.js +24 -12
- package/dist/components/etic/query-boundary.js.map +1 -1
- package/dist/components/etic/removable-badge.d.ts +30 -0
- package/dist/components/etic/removable-badge.js +31 -0
- package/dist/components/etic/removable-badge.js.map +1 -0
- package/dist/components/etic/save-bar.d.ts +31 -0
- package/dist/components/etic/save-bar.js +45 -0
- package/dist/components/etic/save-bar.js.map +1 -0
- package/dist/components/etic/search-select.js +1 -1
- package/dist/components/etic/search-select.js.map +1 -1
- package/dist/components/etic/segmented-control.d.ts +6 -2
- package/dist/components/etic/segmented-control.js +28 -27
- package/dist/components/etic/segmented-control.js.map +1 -1
- package/dist/components/etic/stat-grid.d.ts +15 -0
- package/dist/components/etic/stat-grid.js +17 -0
- package/dist/components/etic/stat-grid.js.map +1 -0
- package/dist/components/etic/stat-tile.d.ts +1 -1
- package/dist/components/etic/stat-tile.js +12 -18
- package/dist/components/etic/stat-tile.js.map +1 -1
- package/dist/components/etic/status-badge.d.ts +2 -4
- package/dist/components/etic/status-badge.js +13 -23
- package/dist/components/etic/status-badge.js.map +1 -1
- package/dist/components/etic/tailles-dialogue.d.ts +8 -0
- package/dist/components/etic/tailles-dialogue.js +10 -0
- package/dist/components/etic/tailles-dialogue.js.map +1 -0
- package/dist/components/etic/theme-menu.d.ts +1 -2
- package/dist/components/etic/theme-menu.js +45 -41
- package/dist/components/etic/theme-menu.js.map +1 -1
- package/dist/components/etic/toggletip.d.ts +36 -0
- package/dist/components/etic/toggletip.js +59 -0
- package/dist/components/etic/toggletip.js.map +1 -0
- package/dist/components/etic/tooltip-button.d.ts +13 -3
- package/dist/components/etic/tooltip-button.js +19 -19
- package/dist/components/etic/tooltip-button.js.map +1 -1
- package/dist/components/etic/unsaved-changes.d.ts +41 -0
- package/dist/components/etic/unsaved-changes.js +17 -0
- package/dist/components/etic/unsaved-changes.js.map +1 -0
- package/dist/components/etic/use-draft-autosave.d.ts +3 -1
- package/dist/components/etic/use-draft-autosave.js +74 -78
- package/dist/components/etic/use-draft-autosave.js.map +1 -1
- package/dist/components/etic/use-unsaved-changes-warning.d.ts +10 -0
- package/dist/components/etic/use-unsaved-changes-warning.js +20 -0
- package/dist/components/etic/use-unsaved-changes-warning.js.map +1 -0
- package/dist/components/ui/alert-dialog.js +2 -2
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/avatar.d.ts +5 -1
- package/dist/components/ui/avatar.js +20 -11
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +3 -2
- package/dist/components/ui/badge.js +27 -14
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.js +13 -13
- package/dist/components/ui/button.d.ts +15 -2
- package/dist/components/ui/button.js +27 -15
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/combobox.d.ts +2 -2
- package/dist/components/ui/combobox.js +45 -32
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/dialog.d.ts +10 -1
- package/dist/components/ui/dialog.js +12 -5
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/popover.d.ts +1 -1
- package/dist/components/ui/popover.js +3 -2
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts +16 -2
- package/dist/components/ui/progress.js +34 -26
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/select.d.ts +10 -2
- package/dist/components/ui/select.js +70 -50
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +6 -1
- package/dist/components/ui/sidebar.js +92 -92
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/spinner.d.ts +7 -1
- package/dist/components/ui/spinner.js +9 -1
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.js +2 -2
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts +7 -2
- package/dist/components/ui/tooltip.js +27 -19
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/hooks/use-column-prefs.d.ts +84 -0
- package/dist/hooks/use-column-prefs.js +71 -0
- package/dist/hooks/use-column-prefs.js.map +1 -0
- package/dist/hooks/use-debounced-value.d.ts +13 -0
- package/dist/hooks/use-debounced-value.js +12 -0
- package/dist/hooks/use-debounced-value.js.map +1 -0
- package/dist/hooks/use-document-title.d.ts +5 -0
- package/dist/hooks/use-document-title.js +13 -0
- package/dist/hooks/use-document-title.js.map +1 -0
- package/dist/hooks/use-persisted-state.d.ts +43 -0
- package/dist/hooks/use-persisted-state.js +40 -0
- package/dist/hooks/use-persisted-state.js.map +1 -0
- package/dist/index.d.ts +40 -16
- package/dist/index.js +99 -76
- package/dist/lib/autofill.d.ts +18 -0
- package/dist/lib/autofill.js +10 -0
- package/dist/lib/autofill.js.map +1 -0
- package/dist/lib/dates.d.ts +20 -0
- package/dist/lib/dates.js +16 -0
- package/dist/lib/dates.js.map +1 -0
- package/dist/lib/focus-rendu.d.ts +24 -0
- package/dist/lib/focus-rendu.js +14 -0
- package/dist/lib/focus-rendu.js.map +1 -0
- package/dist/lib/format.d.ts +54 -0
- package/dist/lib/format.js +80 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/normalize.d.ts +28 -0
- package/dist/lib/normalize.js +21 -0
- package/dist/lib/normalize.js.map +1 -0
- package/dist/lib/ordre-colonnes.d.ts +15 -0
- package/dist/lib/ordre-colonnes.js +14 -0
- package/dist/lib/ordre-colonnes.js.map +1 -0
- package/dist/lib/ton.d.ts +23 -0
- package/dist/lib/ton.js +51 -0
- package/dist/lib/ton.js.map +1 -0
- package/dist/styles.css +110 -63
- package/dist/theme.d.ts +34 -0
- package/dist/theme.js +45 -0
- package/dist/theme.js.map +1 -0
- package/package.json +4 -2
- package/src/theme-boot.js +22 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-dialog.js","names":["PREMIER_CHAMP","selecteur","LARGEURS","raisonInvalide","validity","validationMessage","texteDuLibelle","element","estCache","champ","libelleDuField","controleVisible","cible","nomDuChamp","visible","FormDialog","action","useAction","ouverture","useOuvertureDialogue","ouvert","onOuvertChange","invalides","setInvalides","useState","formulaire","useRef","champs","boutonEnvoi","marques","demarquer","tout","Dialog","suivant","declencheur","DialogTrigger","DialogContent","cn","taille","className","DialogHeader","DialogTitle","titre","description","DialogDescription","event","envoiDesactive","verrouEnvoi","form","fautifs","onEnvoyer","ErrorBanner","nom","raison","index","DialogFooter","Button","TooltipButton","SpinnerBouton","libelleEnvoyer","XIcon"],"sources":["../../../src/components/etic/form-dialog.tsx"],"sourcesContent":["import {\n useRef,\n useState,\n type FormEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\"\nimport { cn } from \"cn\"\nimport { XIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"@etic-ui/components/ui/dialog\"\nimport {\n SpinnerBouton,\n useAction,\n useOuvertureDialogue,\n} from \"@etic-ui/components/etic/action\"\nimport type { DialogFinalFocus } from \"@etic-ui/components/etic/confirm-dialog\"\nimport { ErrorBanner } from \"@etic-ui/components/etic/error-banner\"\nimport { TooltipButton } from \"@etic-ui/components/etic/tooltip-button\"\n\n/**\n * Premier champ où l'on tape : ni case, ni bouton radio, ni fichier, ni\n * liste déroulante (elle a déjà une valeur valable), ni champ désactivé ou\n * en lecture seule, ni l'entrée cachée d'un `Select` ou d'un `Combobox` de\n * Base UI (`aria-hidden`, hors tabulation).\n */\nconst PREMIER_CHAMP = [\n 'input:not([type=\"checkbox\"]):not([type=\"radio\"]):not([type=\"file\"]):not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"])',\n \"textarea\",\n]\n .map(\n (selecteur) =>\n `${selecteur}:not([disabled]):not([readonly]):not([tabindex=\"-1\"]):not([aria-hidden=\"true\"])`\n )\n .join(\", \")\n\n/** Largeur du dialogue, selon la densité du formulaire. */\nexport type FormDialogTaille = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nconst LARGEURS: Record<FormDialogTaille, string> = {\n sm: \"sm:max-w-sm\",\n md: \"sm:max-w-lg\",\n lg: \"sm:max-w-2xl\",\n xl: \"sm:max-w-4xl\",\n}\n\ntype ChampValidable = HTMLElement & {\n willValidate: boolean\n validity: ValidityState\n validationMessage: string\n labels?: NodeListOf<HTMLLabelElement> | null\n name?: string\n}\n\n/** Ce qui ne va pas dans un champ, en français (la bulle native du\n * navigateur parle sa langue, et l'erreur n'est pas reliée au champ). */\nfunction raisonInvalide({ validity, validationMessage }: ChampValidable) {\n if (validity.valueMissing) return \"obligatoire\"\n if (validity.typeMismatch || validity.patternMismatch)\n return \"format invalide\"\n if (validity.tooShort) return \"trop court\"\n if (validity.tooLong) return \"trop long\"\n if (validity.rangeUnderflow) return \"valeur trop petite\"\n if (validity.rangeOverflow) return \"valeur trop grande\"\n if (validity.stepMismatch) return \"valeur non permise\"\n if (validity.badInput) return \"valeur illisible\"\n // Message posé par l'application (setCustomValidity), déjà dans sa langue.\n return validationMessage || \"valeur invalide\"\n}\n\n/** Texte d'un libellé, sans l'astérisque de RequiredMark. */\nfunction texteDuLibelle(element: Element | null | undefined) {\n return element?.textContent?.replace(/\\s*\\*\\s*$/, \"\").trim() || undefined\n}\n\n/**\n * Entrée cachée qui porte la valeur d'un composite (Select, Combobox de Base\n * UI, SearchSelect…) : ni libellé ni focus. Le champ visible est alors celui\n * que vise le libellé de son `FormField` (`[data-slot=field]` parent).\n */\nfunction estCache(champ: ChampValidable) {\n return (\n champ.getAttribute(\"aria-hidden\") === \"true\" ||\n champ.getAttribute(\"type\") === \"hidden\" ||\n champ.tabIndex < 0\n )\n}\n\nfunction libelleDuField(champ: ChampValidable) {\n return champ\n .closest('[data-slot=\"field\"]')\n ?.querySelector<HTMLLabelElement>('[data-slot=\"field-label\"]')\n}\n\n/** Contrôle que voit l'utilisateur : le champ lui-même, ou pour une entrée\n * cachée, le contrôle que vise le libellé de son `FormField`. */\nfunction controleVisible(champ: ChampValidable): HTMLElement {\n if (!estCache(champ)) return champ\n const cible = libelleDuField(champ)?.htmlFor\n return (cible && document.getElementById(cible)) || champ\n}\n\nfunction nomDuChamp(champ: ChampValidable) {\n const visible = controleVisible(champ)\n const etiquettes = (visible as ChampValidable).labels ?? champ.labels\n const nomme =\n texteDuLibelle(etiquettes?.[0]) ||\n visible.getAttribute(\"aria-label\")?.trim() ||\n texteDuLibelle(\n document.getElementById(\n visible.getAttribute(\"aria-labelledby\")?.split(/\\s+/)[0] ?? \"\"\n )\n ) ||\n texteDuLibelle(libelleDuField(champ))\n return nomme || champ.name || \"Champ\"\n}\n\nexport interface FormDialogProps {\n titre: string\n description?: ReactNode\n /** Les champs du formulaire. */\n children: ReactNode\n /**\n * Envoi du formulaire (l'évènement a déjà son `preventDefault`), appelé\n * seulement si les contraintes des champs (`required`, `type`, `pattern`…)\n * sont tenues : sinon le dialogue liste en français les champs à corriger\n * et met le focus sur le premier. Si l'envoi renvoie une promesse, le\n * dialogue l'attend (champs et pied occupés, impossible à fermer), se ferme\n * quand elle aboutit et affiche l'erreur en tête du formulaire si elle\n * échoue. Sinon, il se ferme aussitôt. Renvoyer `false` (ou une promesse\n * résolue à `false`) le garde ouvert, sans erreur.\n */\n onEnvoyer: (event: FormEvent<HTMLFormElement>) => unknown\n /** « Enregistrer » par défaut. */\n libelleEnvoyer?: string\n /** Bouton d'envoi désactivé : formulaire incomplet, rien de modifié… */\n envoiDesactive?: boolean\n /** Envoi impossible, et pourquoi : le bouton reste focalisable et son\n * infobulle donne la raison (voir `TooltipButton`). */\n verrouEnvoi?: string\n /** « md » par défaut ; « sm » pour un seul champ, « lg » ou « xl » pour\n * un formulaire dense. */\n taille?: FormDialogTaille\n /** Ouverture contrôlée par l'application… */\n ouvert?: boolean\n onOuvertChange?: (ouvert: boolean) => void\n /** …ou bouton qui ouvre le dialogue, rendu à sa place. */\n declencheur?: ReactElement\n /** Où mettre le focus à la fermeture (voir `ConfirmDialog`). */\n finalFocus?: DialogFinalFocus\n className?: string\n}\n\n/**\n * Dialogue de création ou de modification, sur le `Dialog` de shadcn : un\n * formulaire, le pied « Annuler / Enregistrer », l'état d'envoi et l'erreur\n * d'envoi en tête. Il s'ouvre le curseur dans le premier champ à remplir.\n */\nexport function FormDialog({\n titre,\n description,\n children,\n onEnvoyer,\n libelleEnvoyer = \"Enregistrer\",\n envoiDesactive = false,\n verrouEnvoi,\n taille = \"md\",\n ouvert,\n onOuvertChange,\n declencheur,\n finalFocus,\n className,\n}: FormDialogProps) {\n const action = useAction()\n const ouverture = useOuvertureDialogue(ouvert, onOuvertChange, action.enCours)\n const [invalides, setInvalides] = useState<{ nom: string; raison: string }[]>(\n []\n )\n const formulaire = useRef<HTMLFormElement>(null)\n const champs = useRef<HTMLFieldSetElement>(null)\n const boutonEnvoi = useRef<HTMLButtonElement>(null)\n // Contrôles visibles marqués `aria-invalid` par le dialogue (et non par\n // l'application), avec le champ dont ils portent la contrainte.\n const marques = useRef(new Map<HTMLElement, ChampValidable>())\n\n /** Retire la marque des champs redevenus valides (tous si `tout`). */\n const demarquer = (tout = false) => {\n for (const [visible, champ] of marques.current) {\n if (!tout && !champ.validity.valid) continue\n visible.removeAttribute(\"aria-invalid\")\n marques.current.delete(visible)\n }\n }\n\n const envoyer = (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (action.enCours || envoiDesactive || verrouEnvoi) return\n const form = event.currentTarget\n // `willValidate` écarte les boutons, les champs désactivés et les\n // `fieldset`, qui ne sont pas soumis aux contraintes.\n const fautifs = Array.from(form.elements).filter(\n (element): element is ChampValidable =>\n \"willValidate\" in element &&\n element.willValidate === true &&\n !(element as ChampValidable).validity.valid\n )\n setInvalides(\n fautifs.map((champ) => ({\n nom: nomDuChamp(champ),\n raison: raisonInvalide(champ),\n }))\n )\n demarquer(true)\n for (const champ of fautifs) {\n const visible = controleVisible(champ)\n // Un `aria-invalid` posé par l'application (FormField en erreur) reste\n // le sien : le dialogue ne le retirera pas.\n const dejaInvalide = [\"true\", \"grammar\", \"spelling\"].includes(\n visible.getAttribute(\"aria-invalid\") ?? \"\"\n )\n if (dejaInvalide) continue\n visible.setAttribute(\"aria-invalid\", \"true\")\n marques.current.set(visible, champ)\n }\n if (fautifs.length > 0) {\n controleVisible(fautifs[0]).focus()\n return\n }\n // Les champs sont désactivés pendant l'envoi : celui qui a le focus (Entrée\n // y envoie) le perdrait au profit de <body>. Il passe au bouton d'envoi,\n // occupé mais focalisable.\n if (champs.current?.contains(document.activeElement)) {\n boutonEnvoi.current?.focus()\n }\n void action.lancer(\n () => onEnvoyer(event),\n () => ouverture.definir(false)\n )\n }\n\n return (\n <Dialog\n open={ouverture.ouvert}\n onOpenChange={ouverture.changer}\n onOpenChangeComplete={(suivant) => {\n if (suivant) return\n action.reinitialiser()\n setInvalides([])\n demarquer(true)\n }}\n >\n {declencheur ? <DialogTrigger render={declencheur} /> : null}\n <DialogContent\n showCloseButton={false}\n className={cn(\n \"max-h-[calc(100dvh-2rem)] overflow-y-auto\",\n LARGEURS[taille],\n className\n )}\n initialFocus={() =>\n formulaire.current?.querySelector<HTMLElement>(PREMIER_CHAMP) ?? true\n }\n finalFocus={finalFocus}\n >\n <DialogHeader>\n <DialogTitle>{titre}</DialogTitle>\n {description ? (\n <DialogDescription>{description}</DialogDescription>\n ) : null}\n </DialogHeader>\n <form\n ref={formulaire}\n onSubmit={envoyer}\n // Un champ corrigé perd sa marque dès la saisie (ou en sortant\n // d'un composite, dont l'entrée cachée n'émet rien).\n onInput={() => demarquer()}\n onChange={() => demarquer()}\n onBlur={() => demarquer()}\n noValidate\n aria-busy={action.enCours || undefined}\n className=\"flex flex-col gap-4\"\n >\n <ErrorBanner erreur={action.erreur} />\n <ErrorBanner\n erreur={invalides.length > 0}\n titre=\"Le formulaire est incomplet.\"\n description={\n <ul className=\"list-disc pl-4\">\n {invalides.map(({ nom, raison }, index) => (\n <li key={index}>\n {nom} : {raison}\n </li>\n ))}\n </ul>\n }\n />\n {/* Champs figés pendant l'envoi : une modification faite pendant\n l'attente serait perdue sans le savoir. */}\n <fieldset ref={champs} disabled={action.enCours} className=\"contents\">\n {children}\n </fieldset>\n <DialogFooter>\n <Button\n variant=\"outline\"\n disabled={action.enCours}\n focusableWhenDisabled\n onClick={() => ouverture.changer(false)}\n >\n Annuler\n </Button>\n <TooltipButton\n ref={boutonEnvoi}\n type=\"submit\"\n disabled={action.enCours || envoiDesactive}\n focusableWhenDisabled\n verrou={verrouEnvoi}\n aria-busy={action.enCours || undefined}\n >\n {action.enCours ? <SpinnerBouton /> : null}\n {libelleEnvoyer}\n </TooltipButton>\n </DialogFooter>\n </form>\n {/* La croix de shadcn, occupée comme « Annuler » pendant l'envoi. */}\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n data-slot=\"dialog-close\"\n className=\"absolute top-2 right-2\"\n disabled={action.enCours}\n focusableWhenDisabled\n onClick={() => ouverture.changer(false)}\n >\n <XIc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AAA;MAGD,kBAAC,YAAD;OAAU,KAAK3B;OAAQ,UAAUX,EAAO;OAAS,WAAU;OACxD;MACO,CAAA;MACV,kBAACuC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;OACE,SAAQ;OACR,UAAUxC,EAAO;OACjB,uBAAA;OACA,eAAeE,EAAU,QAAQ,EAAK;OACvC,UAAA;MAEO,CAAA,GACR,kBAACuC,GAAD;OACE,KAAK7B;OACL,MAAK;OACL,UAAUZ,EAAO,WAAW8B;OAC5B,uBAAA;OACA,QAAQC;OACR,aAAW/B,EAAO,WAAW,KAAA;OAN/B,UAAA,CAQGA,EAAO,UAAU,kBAAC0C,GAAD,CAAgB,CAAA,IAAI,MACrCC,CACY;MACH,CAAA,CAAA,EAAA,CAAA;KACV;;IAEN,kBAACH,GAAD;KACE,SAAQ;KACR,MAAK;KACL,aAAU;KACV,WAAU;KACV,UAAUxC,EAAO;KACjB,uBAAA;KACA,eAAeE,EAAU,QAAQ,EAAK;KAPxC,UAAA,CASE,kBAAC0C,GAAD,CAAQ,CAAA,GACR,kBAAC,QAAD;MAAM,WAAU;MAAU,UAAA;KAAY,CAAA,CAChC;;GACK;EACT,CAAA,CAAA;;AAEZ"}
|
|
1
|
+
{"version":3,"file":"form-dialog.js","names":["PREMIER_CHAMP","selecteur","estVisible","element","premier","racine","accepte","estTabulableActif","raisonInvalide","validity","validationMessage","texteDuLibelle","estCache","champ","libelleDuField","controleVisible","cible","nomDuChamp","visible","FormDialog","action","useAction","lanceur","setLanceur","useState","ouverture","useOuvertureDialogue","ouvert","onOuvertChange","invalides","setInvalides","champs","useRef","boutonEnvoi","marques","demarquer","tout","Dialog","suivant","declencheur","DialogTrigger","DialogContent","cn","LARGEURS_DIALOGUE","taille","className","DialogHeader","DialogTitle","titre","description","DialogDescription","event","envoiDesactive","verrouEnvoi","form","fautifs","onEnvoyer","DialogBody","ErrorBanner","nom","raison","index","DialogFooter","actionSecondaire","TooltipButton","Button","libelleAnnuler","libelleEnvoyer","XIcon"],"sources":["../../../src/components/etic/form-dialog.tsx"],"sourcesContent":["import {\n useRef,\n useState,\n type FormEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\"\nimport { cn } from \"cn\"\nimport { XIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n Dialog,\n DialogBody,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"@etic-ui/components/ui/dialog\"\nimport {\n useAction,\n useOuvertureDialogue,\n type ActionDialogue,\n} from \"@etic-ui/components/etic/action\"\nimport type { DialogFinalFocus } from \"@etic-ui/components/etic/confirm-dialog\"\nimport { ErrorBanner } from \"@etic-ui/components/etic/error-banner\"\nimport { TooltipButton } from \"@etic-ui/components/etic/tooltip-button\"\nimport {\n LARGEURS_DIALOGUE,\n type TailleDialogue,\n} from \"@etic-ui/components/etic/tailles-dialogue\"\n\n/**\n * Premier champ où l'on tape : ni case, ni bouton radio, ni fichier, ni\n * liste déroulante (elle a déjà une valeur valable), ni champ désactivé ou\n * en lecture seule, ni l'entrée cachée d'un `Select` ou d'un `Combobox` de\n * Base UI (`aria-hidden`, hors tabulation).\n */\nconst PREMIER_CHAMP = [\n 'input:not([type=\"checkbox\"]):not([type=\"radio\"]):not([type=\"file\"]):not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"])',\n \"textarea\",\n]\n .map(\n (selecteur) =>\n `${selecteur}:not([disabled]):not([readonly]):not([tabindex=\"-1\"]):not([aria-hidden=\"true\"])`\n )\n .join(\", \")\n\n/** Affiché : ni `display: none` (classe `hidden`, panneau replié…) ni\n * `visibility: hidden`, jusqu'à la racine. */\nfunction estVisible(element: HTMLElement) {\n return typeof element.checkVisibility === \"function\"\n ? element.checkVisibility({ visibilityProperty: true })\n : element.getClientRects().length > 0\n}\n\n/** Premier élément affiché de `racine` qui répond à `accepte`. */\nfunction premier(\n racine: HTMLElement | null,\n selecteur: string,\n accepte: (element: HTMLElement) => boolean = () => true\n) {\n if (!racine) return null\n return (\n Array.from(racine.querySelectorAll<HTMLElement>(selecteur)).find(\n (element) => accepte(element) && estVisible(element)\n ) ?? null\n )\n}\n\n/**\n * À défaut de champ où l'on tape (cases seules, liste, choix segmenté…) :\n * le premier contrôle actif atteignable à la tabulation. Sans ce second\n * niveau, le focus allait à « Annuler ».\n */\nfunction estTabulableActif(element: HTMLElement) {\n return (\n element.tabIndex >= 0 &&\n !element.matches(\n ':disabled, [data-disabled], [aria-disabled=\"true\"], [readonly]'\n ) &&\n !element.closest('[aria-hidden=\"true\"], [hidden], [inert]')\n )\n}\n\n/** Largeur du dialogue, selon la densité du formulaire. */\nexport type FormDialogTaille = TailleDialogue\n\ntype ChampValidable = HTMLElement & {\n willValidate: boolean\n validity: ValidityState\n validationMessage: string\n labels?: NodeListOf<HTMLLabelElement> | null\n name?: string\n}\n\n/** Ce qui ne va pas dans un champ, en français (la bulle native du\n * navigateur parle sa langue, et l'erreur n'est pas reliée au champ). */\nfunction raisonInvalide({ validity, validationMessage }: ChampValidable) {\n if (validity.valueMissing) return \"obligatoire\"\n if (validity.typeMismatch || validity.patternMismatch)\n return \"format invalide\"\n if (validity.tooShort) return \"trop court\"\n if (validity.tooLong) return \"trop long\"\n if (validity.rangeUnderflow) return \"valeur trop petite\"\n if (validity.rangeOverflow) return \"valeur trop grande\"\n if (validity.stepMismatch) return \"valeur non permise\"\n if (validity.badInput) return \"valeur illisible\"\n // Message posé par l'application (setCustomValidity), déjà dans sa langue.\n return validationMessage || \"valeur invalide\"\n}\n\n/** Texte d'un libellé, sans l'astérisque de RequiredMark. */\nfunction texteDuLibelle(element: Element | null | undefined) {\n return element?.textContent?.replace(/\\s*\\*\\s*$/, \"\").trim() || undefined\n}\n\n/**\n * Entrée cachée qui porte la valeur d'un composite (Select, Combobox de Base\n * UI, SearchSelect…) : ni libellé ni focus. Le champ visible est alors celui\n * que vise le libellé de son `FormField` (`[data-slot=field]` parent).\n */\nfunction estCache(champ: ChampValidable) {\n return (\n champ.getAttribute(\"aria-hidden\") === \"true\" ||\n champ.getAttribute(\"type\") === \"hidden\" ||\n champ.tabIndex < 0\n )\n}\n\nfunction libelleDuField(champ: ChampValidable) {\n return champ\n .closest('[data-slot=\"field\"]')\n ?.querySelector<HTMLLabelElement>('[data-slot=\"field-label\"]')\n}\n\n/** Contrôle que voit l'utilisateur : le champ lui-même, ou pour une entrée\n * cachée, le contrôle que vise le libellé de son `FormField`. */\nfunction controleVisible(champ: ChampValidable): HTMLElement {\n if (!estCache(champ)) return champ\n const cible = libelleDuField(champ)?.htmlFor\n return (cible && document.getElementById(cible)) || champ\n}\n\nfunction nomDuChamp(champ: ChampValidable) {\n const visible = controleVisible(champ)\n const etiquettes = (visible as ChampValidable).labels ?? champ.labels\n const nomme =\n texteDuLibelle(etiquettes?.[0]) ||\n visible.getAttribute(\"aria-label\")?.trim() ||\n texteDuLibelle(\n document.getElementById(\n visible.getAttribute(\"aria-labelledby\")?.split(/\\s+/)[0] ?? \"\"\n )\n ) ||\n texteDuLibelle(libelleDuField(champ))\n return nomme || champ.name || \"Champ\"\n}\n\nexport interface FormDialogActionSecondaire {\n libelle: string\n /**\n * L'action. Elle ne ferme pas le dialogue d'elle-même. Si elle renvoie une\n * promesse, le dialogue l'attend comme un envoi (ce bouton occupé, les\n * autres et les champs figés, impossible à fermer) et affiche l'erreur en\n * tête du formulaire si elle échoue.\n */\n onChoisir: ActionDialogue\n /** Sortie qui détruit : grise, rouge au survol (comme `destructif` de\n * `TooltipButton`). */\n destructif?: boolean\n}\n\nexport interface FormDialogProps {\n titre: string\n description?: ReactNode\n /** Les champs du formulaire. */\n children: ReactNode\n /**\n * Envoi du formulaire (l'évènement a déjà son `preventDefault`), appelé\n * seulement si les contraintes des champs (`required`, `type`, `pattern`…)\n * sont tenues : sinon le dialogue liste en français les champs à corriger\n * et met le focus sur le premier. Si l'envoi renvoie une promesse, le\n * dialogue l'attend (champs et pied occupés, impossible à fermer), se ferme\n * quand elle aboutit et affiche l'erreur en tête du formulaire si elle\n * échoue. Sinon, il se ferme aussitôt. Renvoyer `false` (ou une promesse\n * résolue à `false`) le garde ouvert, sans erreur.\n */\n onEnvoyer: (event: FormEvent<HTMLFormElement>) => unknown\n /** « Enregistrer » par défaut. */\n libelleEnvoyer?: string\n /** « Annuler » par défaut : « Plus tard »… Le bouton ferme le dialogue. */\n libelleAnnuler?: string\n /**\n * Une troisième sortie, en tête du pied (à gauche sur ordinateur), discrète :\n * « Se déconnecter »… Indisponible comme « Annuler » pendant l'envoi. Elle\n * ne ferme pas le dialogue d'elle-même.\n */\n actionSecondaire?: FormDialogActionSecondaire\n /** Bouton d'envoi désactivé : formulaire incomplet, rien de modifié… */\n envoiDesactive?: boolean\n /** Envoi impossible, et pourquoi : le bouton reste focalisable et son\n * infobulle donne la raison (voir `TooltipButton`). */\n verrouEnvoi?: string\n /** « md » par défaut ; « sm » pour un seul champ, « lg » ou « xl » pour\n * un formulaire dense. */\n taille?: FormDialogTaille\n /** Ouverture contrôlée par l'application… */\n ouvert?: boolean\n onOuvertChange?: (ouvert: boolean) => void\n /** …ou bouton qui ouvre le dialogue, rendu à sa place. */\n declencheur?: ReactElement\n /** Où mettre le focus à la fermeture (voir `ConfirmDialog`). */\n finalFocus?: DialogFinalFocus\n className?: string\n}\n\n/**\n * Dialogue de création ou de modification, sur le `Dialog` de shadcn : un\n * formulaire, le pied « Annuler / Enregistrer », l'état d'envoi et l'erreur\n * d'envoi en tête. Il s'ouvre le curseur dans le premier champ à remplir.\n */\nexport function FormDialog({\n titre,\n description,\n children,\n onEnvoyer,\n libelleEnvoyer = \"Enregistrer\",\n libelleAnnuler = \"Annuler\",\n actionSecondaire,\n envoiDesactive = false,\n verrouEnvoi,\n taille = \"md\",\n ouvert,\n onOuvertChange,\n declencheur,\n finalFocus,\n className,\n}: FormDialogProps) {\n const action = useAction()\n // Ce qui a lancé l'action en cours : l'envoi, ou l'action secondaire.\n const [lanceur, setLanceur] = useState<\"envoi\" | \"secondaire\">(\"envoi\")\n const ouverture = useOuvertureDialogue(ouvert, onOuvertChange, action.enCours)\n const [invalides, setInvalides] = useState<{ nom: string; raison: string }[]>(\n []\n )\n const champs = useRef<HTMLFieldSetElement>(null)\n const boutonEnvoi = useRef<HTMLButtonElement>(null)\n // Contrôles visibles marqués `aria-invalid` par le dialogue (et non par\n // l'application), avec le champ dont ils portent la contrainte.\n const marques = useRef(new Map<HTMLElement, ChampValidable>())\n\n /** Retire la marque des champs redevenus valides (tous si `tout`). */\n const demarquer = (tout = false) => {\n for (const [visible, champ] of marques.current) {\n if (!tout && !champ.validity.valid) continue\n visible.removeAttribute(\"aria-invalid\")\n marques.current.delete(visible)\n }\n }\n\n const envoyer = (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (action.enCours || envoiDesactive || verrouEnvoi) return\n const form = event.currentTarget\n // `willValidate` écarte les boutons, les champs désactivés et les\n // `fieldset`, qui ne sont pas soumis aux contraintes.\n const fautifs = Array.from(form.elements).filter(\n (element): element is ChampValidable =>\n \"willValidate\" in element &&\n element.willValidate === true &&\n !(element as ChampValidable).validity.valid\n )\n setInvalides(\n fautifs.map((champ) => ({\n nom: nomDuChamp(champ),\n raison: raisonInvalide(champ),\n }))\n )\n demarquer(true)\n for (const champ of fautifs) {\n const visible = controleVisible(champ)\n // Un `aria-invalid` posé par l'application (FormField en erreur) reste\n // le sien : le dialogue ne le retirera pas.\n const dejaInvalide = [\"true\", \"grammar\", \"spelling\"].includes(\n visible.getAttribute(\"aria-invalid\") ?? \"\"\n )\n if (dejaInvalide) continue\n visible.setAttribute(\"aria-invalid\", \"true\")\n marques.current.set(visible, champ)\n }\n if (fautifs.length > 0) {\n controleVisible(fautifs[0]).focus()\n return\n }\n // Les champs sont désactivés pendant l'envoi : celui qui a le focus (Entrée\n // y envoie) le perdrait au profit de <body>. Il passe au bouton d'envoi,\n // occupé mais focalisable.\n if (champs.current?.contains(document.activeElement)) {\n boutonEnvoi.current?.focus()\n }\n setLanceur(\"envoi\")\n void action.lancer(\n () => onEnvoyer(event),\n () => ouverture.definir(false)\n )\n }\n\n return (\n <Dialog\n open={ouverture.ouvert}\n onOpenChange={ouverture.changer}\n onOpenChangeComplete={(suivant) => {\n if (suivant) return\n action.reinitialiser()\n setInvalides([])\n demarquer(true)\n }}\n >\n {declencheur ? <DialogTrigger render={declencheur} /> : null}\n <DialogContent\n showCloseButton={false}\n className={cn(LARGEURS_DIALOGUE[taille], className)}\n initialFocus={() =>\n premier(champs.current, PREMIER_CHAMP) ??\n premier(champs.current, \"*\", estTabulableActif) ??\n true\n }\n finalFocus={finalFocus}\n >\n <DialogHeader>\n <DialogTitle>{titre}</DialogTitle>\n {description ? (\n <DialogDescription>{description}</DialogDescription>\n ) : null}\n </DialogHeader>\n <form\n onSubmit={envoyer}\n // Un champ corrigé perd sa marque dès la saisie (ou en sortant\n // d'un composite, dont l'entrée cachée n'émet rien).\n onInput={() => demarquer()}\n onChange={() => demarquer()}\n onBlur={() => demarquer()}\n noValidate\n aria-busy={action.enCours || undefined}\n // Peut rétrécir : seul le corps défile, le pied reste visible.\n className=\"flex min-h-0 flex-col gap-4\"\n >\n <DialogBody>\n <ErrorBanner erreur={action.erreur} />\n <ErrorBanner\n erreur={invalides.length > 0}\n titre=\"Le formulaire est incomplet.\"\n description={\n <ul className=\"list-disc pl-4\">\n {invalides.map(({ nom, raison }, index) => (\n <li key={index}>\n {nom} : {raison}\n </li>\n ))}\n </ul>\n }\n />\n {/* Champs figés pendant l'envoi : une modification faite pendant\n l'attente serait perdue sans le savoir. */}\n <fieldset\n ref={champs}\n disabled={action.enCours}\n className=\"contents\"\n >\n {children}\n </fieldset>\n </DialogBody>\n <DialogFooter>\n {actionSecondaire ? (\n // Sans cadre et rangée à part : elle ne répond pas au\n // formulaire, elle en sort.\n <TooltipButton\n variant=\"ghost\"\n destructif={actionSecondaire.destructif}\n className=\"sm:mr-auto\"\n disabled={action.enCours}\n focusableWhenDisabled\n enCours={action.enCours && lanceur === \"secondaire\"}\n // Désactivé pendant une action : Base UI ignore alors le clic.\n onClick={() => {\n setLanceur(\"secondaire\")\n void action.lancer(actionSecondaire.onChoisir)\n }}\n >\n {actionSecondaire.libelle}\n </TooltipButton>\n ) : null}\n <Button\n variant=\"outline\"\n disabled={action.enCours}\n focusableWhenDisabled\n onClick={() => ouverture.changer(false)}\n >\n {libelleAnnuler}\n </Button>\n <TooltipButton\n ref={boutonEnvoi}\n type=\"submit\"\n disabled={action.enCours || envoiDesactive}\n focusableWhenDisabled\n verrou={verrouEnvoi}\n enCours={action.enCours && lanceur === \"envoi\"}\n >\n {libelleEnvoyer}\n </TooltipButton>\n </DialogFooter>\n </form>\n {/* La croix de shadcn, occupée comme « Annuler » pendant l'envoi. */}\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n data-slot=\"dialog-close\"\n className=\"absolute top-2 right-2\"\n disabled={action.enCours}\n focusableWhenDisabled\n onClick={() => ouverture.changer(false)}\n >\n <XIcon />\n <span className=\"sr-only\">Fermer</span>\n </Button>\n </DialogContent>\n </Dialog>\n )\n}\n"],"mappings":";;;;;;;;;;;AAwCA,IAAMA,IAAgB,CACpB,kJACA,UACF,CAAC,CACE,KACE,MACC,GAAGC,EAAU,gFACjB,CAAC,CACA,KAAK,IAAI;AAIZ,SAASC,EAAW,GAAsB;CACxC,OAAO,OAAOC,EAAQ,mBAAoB,aACtCA,EAAQ,gBAAgB,EAAE,oBAAoB,GAAK,CAAC,IACpDA,EAAQ,eAAe,CAAC,CAAC,SAAS;AACxC;AAGA,SAASC,EACP,GACA,GACA,UAAmD,IACnD;CAEA,OADKC,IAEH,MAAM,KAAKA,EAAO,iBAA8BJ,CAAS,CAAC,CAAC,CAAC,MACzD,MAAYK,EAAQH,CAAO,KAAKD,EAAWC,CAAO,CACrD,KAAK,OAJa;AAMtB;AAOA,SAASI,EAAkB,GAAsB;CAC/C,OACEJ,EAAQ,YAAY,KACpB,CAACA,EAAQ,QACP,kEACF,KACA,CAACA,EAAQ,QA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,EAAA,UAAA;MACGC,IAGC,kBAACC,GAAD;OACE,SAAQ;OACR,YAAYD,EAAiB;OAC7B,WAAU;OACV,UAAU3C,EAAO;OACjB,uBAAA;OACA,SAASA,EAAO,WAAWE,MAAY;OAEvC,eAAe;QAEb,AADAC,EAAW,YAAY,GACvBH,EAAY,OAAO2C,EAAiB,SAAS;OAC/C;OAEC,UAAAA,EAAiB;MACL,CAAA,IACb;MACJ,kBAACE,GAAD;OACE,SAAQ;OACR,UAAU7C,EAAO;OACjB,uBAAA;OACA,eAAeK,EAAU,QAAQ,EAAK;OAErC,UAAAyC;MACK,CAAA;MACR,kBAACF,GAAD;OACE,KAAK/B;OACL,MAAK;OACL,UAAUb,EAAO,WAAWgC;OAC5B,uBAAA;OACA,QAAQC;OACR,SAASjC,EAAO,WAAWE,MAAY;OAEtC,UAAA6C;MACY,CAAA;KACH,EAAA,CAAA,CACV;;IAEN,kBAACF,GAAD;KACE,SAAQ;KACR,MAAK;KACL,aAAU;KACV,WAAU;KACV,UAAU7C,EAAO;KACjB,uBAAA;KACA,eAAeK,EAAU,QAAQ,EAAK;KAPxC,UAAA,CASE,kBAAC2C,GAAD,CAAQ,CAAA,GACR,kBAAC,QAAD;MAAM,WAAU;MAAU,UAAA;KAAY,CAAA,CAChC;;GACK;EACT,CAAA,CAAA;;AAEZ"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Toggle as TogglePrimitive } from '@base-ui/react/toggle';
|
|
2
2
|
import { LucideIcon } from 'lucide-react';
|
|
3
|
-
import {
|
|
4
|
-
export interface IconToggleProps extends Omit<
|
|
3
|
+
import { StatusTon } from '../../lib/ton';
|
|
4
|
+
export interface IconToggleProps extends Omit<TogglePrimitive.Props, "children" | "pressed" | "defaultPressed" | "onPressedChange" | "disabled" | "render" | "nativeButton"> {
|
|
5
|
+
/** `default` (fond transparent) par défaut, ou `outline` (cadre). */
|
|
6
|
+
variant?: "default" | "outline";
|
|
7
|
+
/** Taille du bouton carré : `sm` (28 px) par défaut, `default` (32 px)
|
|
8
|
+
* ou `lg` (36 px). Noms de la 0.2.0, gardés. */
|
|
9
|
+
size?: keyof typeof TAILLES;
|
|
5
10
|
/** État actuel : le marqueur est-il posé ? */
|
|
6
11
|
actif: boolean;
|
|
7
12
|
/** Appelé avec l'état voulu. */
|
|
@@ -17,17 +22,30 @@ export interface IconToggleProps extends Omit<ComponentProps<typeof Toggle>, "ch
|
|
|
17
22
|
activer: string;
|
|
18
23
|
desactiver: string;
|
|
19
24
|
};
|
|
20
|
-
/** Bascule en cours d'enregistrement :
|
|
21
|
-
* (`aria-busy`) et ne réagit
|
|
25
|
+
/** Bascule en cours d'enregistrement : comme un `Button` en cours, une
|
|
26
|
+
* roue remplace l'icône, le bouton est occupé (`aria-busy`) et ne réagit
|
|
27
|
+
* plus, mais garde le focus. */
|
|
22
28
|
enCours?: boolean;
|
|
23
29
|
/** Bascule impossible : le bouton reste focalisable, et son infobulle dit
|
|
24
30
|
* pourquoi. */
|
|
25
31
|
verrou?: string;
|
|
32
|
+
/** Couleur du bouton actif : `warning` (jaune) par défaut, le marqueur
|
|
33
|
+
* signale un élément sensible ; `neutral` pour le fond gris du Toggle. */
|
|
34
|
+
ton?: StatusTon;
|
|
26
35
|
}
|
|
36
|
+
/** Taille du `Button` à icône seule qui porte la bascule. */
|
|
37
|
+
declare const TAILLES: {
|
|
38
|
+
readonly default: "icon";
|
|
39
|
+
readonly sm: "icon-sm";
|
|
40
|
+
readonly lg: "icon-lg";
|
|
41
|
+
};
|
|
27
42
|
/**
|
|
28
43
|
* Bouton à icône qui pose ou retire un marqueur sensible (élément critique,
|
|
29
|
-
* protégé…), sur le `Toggle` de
|
|
30
|
-
*
|
|
31
|
-
*
|
|
44
|
+
* protégé…), sur le `Toggle` de Base UI rendu en `Button` à icône (comme la
|
|
45
|
+
* corbeille de `DeleteButton` à côté) : sans libellé visible, il porte son
|
|
46
|
+
* état (`aria-pressed`, en couleur de son `ton` quand il est actif), et son
|
|
47
|
+
* infobulle dit ce que ferait un clic. Son état « en cours » est celui du
|
|
48
|
+
* `Button`.
|
|
32
49
|
*/
|
|
33
|
-
export declare function IconToggle({ actif, onActifChange, icone: Icone, libelle, infobulles, enCours, verrou, size, className, ...props }: IconToggleProps): import("react").JSX.Element;
|
|
50
|
+
export declare function IconToggle({ actif, onActifChange, icone: Icone, libelle, infobulles, enCours, verrou, ton, variant, size, className, ...props }: IconToggleProps): import("react").JSX.Element;
|
|
51
|
+
export {};
|
|
@@ -1,28 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Button as e } from "../ui/button.js";
|
|
2
2
|
import { Tooltip as t, TooltipContent as n, TooltipTrigger as r } from "../ui/tooltip.js";
|
|
3
3
|
import { useRaisonVerrou as i } from "./tooltip-button.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { TONS as a } from "../../lib/ton.js";
|
|
5
|
+
import { cn as o } from "cn";
|
|
6
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { Toggle as u } from "@base-ui/react/toggle";
|
|
6
8
|
// src/components/etic/icon-toggle.tsx
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
var d = {
|
|
10
|
+
default: "icon",
|
|
11
|
+
sm: "icon-sm",
|
|
12
|
+
lg: "icon-lg"
|
|
13
|
+
};
|
|
14
|
+
function f({ actif: f, onActifChange: p, icone: m, libelle: h, infobulles: g, enCours: _ = !1, verrou: v, ton: y = "warning", variant: b = "default", size: x = "sm", className: S, ...C }) {
|
|
15
|
+
let { describedBy: w, raison: T } = i(v), E = g ? f ? g.desactiver : g.activer : h;
|
|
16
|
+
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l(t, { children: [/* @__PURE__ */ c(r, {
|
|
17
|
+
render: /* @__PURE__ */ c(u, {
|
|
18
|
+
...C,
|
|
19
|
+
"data-slot": "toggle",
|
|
20
|
+
pressed: f,
|
|
14
21
|
onPressedChange: (e) => {
|
|
15
|
-
|
|
22
|
+
!v && !_ && p(e);
|
|
16
23
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
render: /* @__PURE__ */ c(e, {
|
|
25
|
+
variant: b === "outline" ? "outline" : "ghost",
|
|
26
|
+
size: d[x],
|
|
27
|
+
disabled: !!v,
|
|
28
|
+
focusableWhenDisabled: !0,
|
|
29
|
+
enCours: _
|
|
30
|
+
}),
|
|
31
|
+
"aria-label": h,
|
|
32
|
+
"aria-describedby": w,
|
|
33
|
+
className: o("text-muted-foreground aria-pressed:bg-muted", a[y].basculeActive, S)
|
|
22
34
|
}),
|
|
23
|
-
children: /* @__PURE__ */
|
|
24
|
-
}), /* @__PURE__ */
|
|
35
|
+
children: /* @__PURE__ */ c(m, {})
|
|
36
|
+
}), /* @__PURE__ */ c(n, { children: v ?? E })] }), T] });
|
|
25
37
|
}
|
|
26
|
-
export {
|
|
38
|
+
export { f as IconToggle };
|
|
27
39
|
|
|
28
40
|
//# sourceMappingURL=icon-toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-toggle.js","names":["_Fragment","IconToggle","Icone","props","useRaisonVerrou","verrou","action","infobulles","actif","libelle","
|
|
1
|
+
{"version":3,"file":"icon-toggle.js","names":["_Fragment","TogglePrimitive","TAILLES","IconToggle","Icone","props","useRaisonVerrou","verrou","action","infobulles","actif","libelle","Fragment","Tooltip","TooltipTrigger","Toggle","enCours","onActifChange","suivant","Button","variant","size","describedBy","cn","TONS","ton","className","TooltipContent","raison"],"sources":["../../../src/components/etic/icon-toggle.tsx"],"sourcesContent":["import { Toggle as TogglePrimitive } from \"@base-ui/react/toggle\"\nimport { cn } from \"cn\"\nimport type { LucideIcon } 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 { useRaisonVerrou } from \"@etic-ui/components/etic/tooltip-button\"\nimport { TONS, type StatusTon } from \"@etic-ui/lib/ton\"\n\nexport interface IconToggleProps extends Omit<\n TogglePrimitive.Props,\n | \"children\"\n | \"pressed\"\n | \"defaultPressed\"\n | \"onPressedChange\"\n | \"disabled\"\n | \"render\"\n | \"nativeButton\"\n> {\n /** `default` (fond transparent) par défaut, ou `outline` (cadre). */\n variant?: \"default\" | \"outline\"\n /** Taille du bouton carré : `sm` (28 px) par défaut, `default` (32 px)\n * ou `lg` (36 px). Noms de la 0.2.0, gardés. */\n size?: keyof typeof TAILLES\n /** État actuel : le marqueur est-il posé ? */\n actif: boolean\n /** Appelé avec l'état voulu. */\n onActifChange: (actif: boolean) => void\n icone: LucideIcon\n /** Nom accessible, constant (l'état est porté par `aria-pressed`) :\n * « Groupe critique ». */\n libelle: string\n /** Infobulle selon l'état : ce que ferait un clic (« Marquer ce groupe\n * comme critique », « Retirer le marqueur critique »). Le libellé par\n * défaut. */\n infobulles?: { activer: string; desactiver: string }\n /** Bascule en cours d'enregistrement : comme un `Button` en cours, une\n * roue remplace l'icône, le bouton est occupé (`aria-busy`) et ne réagit\n * plus, mais garde le focus. */\n enCours?: boolean\n /** Bascule impossible : le bouton reste focalisable, et son infobulle dit\n * pourquoi. */\n verrou?: string\n /** Couleur du bouton actif : `warning` (jaune) par défaut, le marqueur\n * signale un élément sensible ; `neutral` pour le fond gris du Toggle. */\n ton?: StatusTon\n}\n\n/** Taille du `Button` à icône seule qui porte la bascule. */\nconst TAILLES = {\n default: \"icon\",\n sm: \"icon-sm\",\n lg: \"icon-lg\",\n} as const\n\n/**\n * Bouton à icône qui pose ou retire un marqueur sensible (élément critique,\n * protégé…), sur le `Toggle` de Base UI rendu en `Button` à icône (comme la\n * corbeille de `DeleteButton` à côté) : sans libellé visible, il porte son\n * état (`aria-pressed`, en couleur de son `ton` quand il est actif), et son\n * infobulle dit ce que ferait un clic. Son état « en cours » est celui du\n * `Button`.\n */\nexport function IconToggle({\n actif,\n onActifChange,\n icone: Icone,\n libelle,\n infobulles,\n enCours = false,\n verrou,\n ton = \"warning\",\n variant = \"default\",\n size = \"sm\",\n className,\n ...props\n}: IconToggleProps) {\n const { describedBy, raison } = useRaisonVerrou(verrou)\n const action = infobulles\n ? actif\n ? infobulles.desactiver\n : infobulles.activer\n : libelle\n return (\n <>\n <Tooltip>\n <TooltipTrigger\n render={\n <TogglePrimitive\n {...props}\n data-slot=\"toggle\"\n pressed={actif}\n onPressedChange={(suivant) => {\n if (!verrou && !enCours) onActifChange(suivant)\n }}\n // Ni le verrou ni l'enregistrement ne désactivent nativement le\n // bouton : il perdrait le focus (et le survol qui montre la\n // raison). Il est dit indisponible et ignore les clics.\n render={\n <Button\n variant={variant === \"outline\" ? \"outline\" : \"ghost\"}\n size={TAILLES[size]}\n disabled={!!verrou}\n focusableWhenDisabled\n enCours={enCours}\n />\n }\n aria-label={libelle}\n aria-describedby={describedBy}\n className={cn(\n // Inactif, en gris comme les icônes d'action voisines : seul\n // l'état actif attire l'œil.\n \"text-muted-foreground aria-pressed:bg-muted\",\n // Couleur du bouton actif, survol compris (le bouton passe\n // sinon en texte normal).\n TONS[ton].basculeActive,\n className\n )}\n />\n }\n >\n <Icone />\n </TooltipTrigger>\n <TooltipContent>{verrou ?? action}</TooltipContent>\n </Tooltip>\n {raison}\n </>\n )\n}\n"],"mappings":";;;;;;;;AAqDA,IAAME,IAAU;CACd,SAAS;CACT,IAAI;CACJ,IAAI;AACN;AAUA,SAAgBC,EAAW,EACzB,UACA,kBACA,OAAOC,GACP,YACA,eACA,aAAU,IACV,WACA,SAAM,WACN,aAAU,WACV,UAAO,MACP,cACA,GAAGC,KACe;CAClB,IAAM,EAAE,gBAAa,cAAWC,EAAgBC,CAAM,GAChDC,IAASC,IACXC,IACED,EAAW,aACXA,EAAW,UACbE;CACJ,OACE,kBAAAX,GAAA,EAAA,UAAA,CACE,kBAACa,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;EACE,QACE,kBAACb,GAAD;GACE,GAAII;GACJ,aAAU;GACV,SAASK;GACT,kBAAkB,MAAY;IAC5B,AAAI,CAACH,KAAU,CAACS,KAASC,EAAcC,CAAO;GAChD;GAIA,QACE,kBAACC,GAAD;IACE,SAASC,MAAY,YAAY,YAAY;IAC7C,MAAMlB,EAAQmB;IACd,UAAU,CAAC,CAACd;IACZ,uBAAA;IACS;GACV,CAAA;GAEH,cAAYI;GACZ,oBAAkBW;GAClB,WAAWC,EAGT,+CAGAC,EAAKC,EAAI,CAAC,eACVC,CACF;EACD,CAAA;EAGH,UAAA,kBAACtB,GAAD,CAAQ,CAAA;CACM,CAAA,GAChB,kBAACuB,GAAD,EAAA,UAAiBpB,KAAUC,EAAuB,CAAA,CAC3C,EAAA,CAAA,GACRoB,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ComponentProps, ComponentType, ReactNode } from 'react';
|
|
2
|
+
/** Lien du routeur de l'application (react-router, TanStack Router…), qui
|
|
3
|
+
* reçoit `href` comme un `<a>`. Par défaut, un `<a>` : rechargement complet. */
|
|
4
|
+
export type LienComposant = ComponentType<ComponentProps<"a">> | "a";
|
|
5
|
+
export interface LienProviderProps {
|
|
6
|
+
/**
|
|
7
|
+
* Le composant de lien du routeur, qui reçoit `href` comme un `<a>`. Une
|
|
8
|
+
* référence stable, définie au niveau du module : un composant écrit en
|
|
9
|
+
* ligne (`lien={(p) => <Link … />}`) serait nouveau à chaque rendu, et
|
|
10
|
+
* React remonterait tous les liens de l'application.
|
|
11
|
+
*/
|
|
12
|
+
lien: LienComposant;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Donne une fois pour toutes le lien du routeur aux composants qui en
|
|
17
|
+
* rendent un (`AppShell`, `DetailHeader`, `ButtonLink`, `DataTableCellLink`),
|
|
18
|
+
* à poser autour de l'application : sans lui, ils rendent un `<a>`. La prop
|
|
19
|
+
* `lien` d'un composant reste prioritaire (`lien="a"` pour un rechargement
|
|
20
|
+
* complet, un téléchargement ou une adresse externe).
|
|
21
|
+
*/
|
|
22
|
+
export declare function LienProvider({ lien, children }: LienProviderProps): import("react").JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* Le composant de lien à rendre : `lien` s'il est donné, sinon celui du
|
|
25
|
+
* `LienProvider` le plus proche, sinon `<a>`. Pour les liens propres d'une
|
|
26
|
+
* application : `const Lien = useLien()`, puis `<Lien href="/groupes">`.
|
|
27
|
+
*
|
|
28
|
+
* La valeur rendue est stable (une prop ou le contexte), mais la règle
|
|
29
|
+
* `react-hooks/static-components` ne peut pas le savoir : un `<Lien />` rendu
|
|
30
|
+
* directement par le composant qui appelle ce hook demande un
|
|
31
|
+
* `eslint-disable-next-line` commenté (`ButtonLink`, `DataTableCellLink`).
|
|
32
|
+
* Passé en prop à un sous-composant (`AppShell`), il n'en demande pas.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useLien(lien?: LienComposant): LienComposant;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "react";
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
// src/components/etic/lien.tsx
|
|
4
|
+
var r = e("a");
|
|
5
|
+
function i({ lien: e, children: t }) {
|
|
6
|
+
return /* @__PURE__ */ n(r.Provider, {
|
|
7
|
+
value: e,
|
|
8
|
+
children: t
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function a(e) {
|
|
12
|
+
let n = t(r);
|
|
13
|
+
return e ?? n;
|
|
14
|
+
}
|
|
15
|
+
export { i as LienProvider, a as useLien };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=lien.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lien.js","names":["ContexteLien","createContext","LienProvider","lien","useLien","fourni","useContext"],"sources":["../../../src/components/etic/lien.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n type ComponentProps,\n type ComponentType,\n type ReactNode,\n} from \"react\"\n\n/** Lien du routeur de l'application (react-router, TanStack Router…), qui\n * reçoit `href` comme un `<a>`. Par défaut, un `<a>` : rechargement complet. */\nexport type LienComposant = ComponentType<ComponentProps<\"a\">> | \"a\"\n\nconst ContexteLien = createContext<LienComposant>(\"a\")\n\nexport interface LienProviderProps {\n /**\n * Le composant de lien du routeur, qui reçoit `href` comme un `<a>`. Une\n * référence stable, définie au niveau du module : un composant écrit en\n * ligne (`lien={(p) => <Link … />}`) serait nouveau à chaque rendu, et\n * React remonterait tous les liens de l'application.\n */\n lien: LienComposant\n children: ReactNode\n}\n\n/**\n * Donne une fois pour toutes le lien du routeur aux composants qui en\n * rendent un (`AppShell`, `DetailHeader`, `ButtonLink`, `DataTableCellLink`),\n * à poser autour de l'application : sans lui, ils rendent un `<a>`. La prop\n * `lien` d'un composant reste prioritaire (`lien=\"a\"` pour un rechargement\n * complet, un téléchargement ou une adresse externe).\n */\nexport function LienProvider({ lien, children }: LienProviderProps) {\n return <ContexteLien.Provider value={lien}>{children}</ContexteLien.Provider>\n}\n\n/**\n * Le composant de lien à rendre : `lien` s'il est donné, sinon celui du\n * `LienProvider` le plus proche, sinon `<a>`. Pour les liens propres d'une\n * application : `const Lien = useLien()`, puis `<Lien href=\"/groupes\">`.\n *\n * La valeur rendue est stable (une prop ou le contexte), mais la règle\n * `react-hooks/static-components` ne peut pas le savoir : un `<Lien />` rendu\n * directement par le composant qui appelle ce hook demande un\n * `eslint-disable-next-line` commenté (`ButtonLink`, `DataTableCellLink`).\n * Passé en prop à un sous-composant (`AppShell`), il n'en demande pas.\n */\nexport function useLien(lien?: LienComposant): LienComposant {\n const fourni = useContext(ContexteLien)\n return lien ?? fourni\n}\n"],"mappings":";;;AAYA,IAAMA,IAAeC,EAA6B,GAAG;AAoBrD,SAAgBC,EAAa,EAAE,SAAM,eAA+B;CAClE,OAAO,kBAACF,EAAa,UAAd;EAAuB,OAAOG;EAAO;CAAgC,CAAA;AAC9E;AAaA,SAAgBC,EAAQ,GAAqC;CAC3D,IAAMC,IAASC,EAAWN,CAAY;CACtC,OAAOG,KAAQE;AACjB"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
|
-
import { Spinner } from '../ui/spinner';
|
|
3
|
-
/**
|
|
4
|
-
* Roue muette, à côté d'un texte qui dit déjà qu'on attend (bouton occupé,
|
|
5
|
-
* statut « Chargement… ») : sans rôle ni nom, cachée aux lecteurs d'écran.
|
|
6
|
-
* Usage interne.
|
|
7
|
-
*/
|
|
8
|
-
export declare function SpinnerDecoratif(props: ComponentProps<typeof Spinner>): import("react").JSX.Element;
|
|
9
1
|
export interface LoadingProps {
|
|
10
2
|
/** Annoncé aux lecteurs d'écran à chaque changement ; « Chargement… »
|
|
11
3
|
* par défaut. */
|
|
@@ -1,82 +1,74 @@
|
|
|
1
1
|
import { Card as e, CardContent as t } from "../ui/card.js";
|
|
2
2
|
import { Skeleton as n } from "../ui/skeleton.js";
|
|
3
|
-
import {
|
|
3
|
+
import { SpinnerDecoratif as r } from "../ui/spinner.js";
|
|
4
4
|
import { cn as i } from "cn";
|
|
5
5
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
6
|
// src/components/etic/loading.tsx
|
|
7
|
-
function s(e) {
|
|
8
|
-
return /* @__PURE__ */ a(r, {
|
|
9
|
-
...e,
|
|
10
|
-
role: void 0,
|
|
11
|
-
"aria-label": void 0,
|
|
12
|
-
"aria-hidden": !0
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function c({ libelle: e = "Chargement…", className: t }) {
|
|
7
|
+
function s({ libelle: e = "Chargement…", className: t }) {
|
|
16
8
|
return /* @__PURE__ */ o("div", {
|
|
17
9
|
role: "status",
|
|
18
10
|
className: i("flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground", t),
|
|
19
|
-
children: [/* @__PURE__ */ a(
|
|
11
|
+
children: [/* @__PURE__ */ a(r, {}), e]
|
|
20
12
|
});
|
|
21
13
|
}
|
|
22
|
-
function
|
|
14
|
+
function c() {
|
|
23
15
|
return /* @__PURE__ */ a("span", {
|
|
24
16
|
className: "sr-only",
|
|
25
17
|
role: "status",
|
|
26
18
|
children: "Chargement…"
|
|
27
19
|
});
|
|
28
20
|
}
|
|
29
|
-
var
|
|
21
|
+
var l = [
|
|
30
22
|
"w-[70%]",
|
|
31
23
|
"w-[55%]",
|
|
32
24
|
"w-[80%]",
|
|
33
25
|
"w-[40%]",
|
|
34
26
|
"w-[60%]"
|
|
35
27
|
];
|
|
36
|
-
function
|
|
28
|
+
function u({ lignes: e = 5, colonnes: t = 4, className: r }) {
|
|
37
29
|
return /* @__PURE__ */ o("div", {
|
|
38
30
|
className: i("flex flex-col gap-3 py-2", r),
|
|
39
|
-
children: [/* @__PURE__ */ a(
|
|
31
|
+
children: [/* @__PURE__ */ a(c, {}), Array.from({ length: e }, (e, r) => /* @__PURE__ */ a("div", {
|
|
40
32
|
"aria-hidden": !0,
|
|
41
33
|
className: "grid gap-4",
|
|
42
34
|
style: { gridTemplateColumns: `repeat(${t}, minmax(0, 1fr))` },
|
|
43
|
-
children: Array.from({ length: t }, (e, t) => /* @__PURE__ */ a(n, { className: i("h-4",
|
|
35
|
+
children: Array.from({ length: t }, (e, t) => /* @__PURE__ */ a(n, { className: i("h-4", l[(r + t) % l.length]) }, t))
|
|
44
36
|
}, r))]
|
|
45
37
|
});
|
|
46
38
|
}
|
|
47
|
-
function
|
|
39
|
+
function d({ lignes: r = 3, annoncer: s = !0, className: u }) {
|
|
48
40
|
return /* @__PURE__ */ a(e, {
|
|
49
|
-
className:
|
|
41
|
+
className: u,
|
|
50
42
|
children: /* @__PURE__ */ o(t, {
|
|
51
43
|
className: "flex flex-col gap-3",
|
|
52
|
-
children: [s ? /* @__PURE__ */ a(
|
|
44
|
+
children: [s ? /* @__PURE__ */ a(c, {}) : null, Array.from({ length: r }, (e, t) => /* @__PURE__ */ a(n, {
|
|
53
45
|
"aria-hidden": !0,
|
|
54
|
-
className: i("h-4",
|
|
46
|
+
className: i("h-4", l[(t + 3) % l.length])
|
|
55
47
|
}, t))]
|
|
56
48
|
})
|
|
57
49
|
});
|
|
58
50
|
}
|
|
59
|
-
function
|
|
51
|
+
function f({ className: e }) {
|
|
60
52
|
return /* @__PURE__ */ o("div", {
|
|
61
53
|
className: i("flex flex-col gap-6", e),
|
|
62
54
|
children: [
|
|
63
|
-
/* @__PURE__ */ a(
|
|
55
|
+
/* @__PURE__ */ a(c, {}),
|
|
64
56
|
/* @__PURE__ */ o("div", {
|
|
65
57
|
"aria-hidden": !0,
|
|
66
58
|
className: "flex flex-col gap-2",
|
|
67
59
|
children: [/* @__PURE__ */ a(n, { className: "h-4 w-40" }), /* @__PURE__ */ a(n, { className: "h-7 w-72 max-w-full" })]
|
|
68
60
|
}),
|
|
69
|
-
/* @__PURE__ */ a(
|
|
61
|
+
/* @__PURE__ */ a(d, {
|
|
70
62
|
lignes: 4,
|
|
71
63
|
annoncer: !1
|
|
72
64
|
}),
|
|
73
|
-
/* @__PURE__ */ a(
|
|
65
|
+
/* @__PURE__ */ a(d, {
|
|
74
66
|
lignes: 3,
|
|
75
67
|
annoncer: !1
|
|
76
68
|
})
|
|
77
69
|
]
|
|
78
70
|
});
|
|
79
71
|
}
|
|
80
|
-
export {
|
|
72
|
+
export { s as Loading, d as SkeletonCard, f as SkeletonPage, u as SkeletonTable };
|
|
81
73
|
|
|
82
74
|
//# sourceMappingURL=loading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading.js","names":["
|
|
1
|
+
{"version":3,"file":"loading.js","names":["Loading","cn","className","SpinnerDecoratif","libelle","StatutChargement","LARGEURS","SkeletonTable","lignes","colonnes","Skeleton","ligne","colonne","SkeletonCard","Card","CardContent","annoncer","index","SkeletonPage"],"sources":["../../../src/components/etic/loading.tsx"],"sourcesContent":["import { cn } from \"cn\"\n\nimport { Card, CardContent } from \"@etic-ui/components/ui/card\"\nimport { Skeleton } from \"@etic-ui/components/ui/skeleton\"\nimport { SpinnerDecoratif } from \"@etic-ui/components/ui/spinner\"\n\nexport interface LoadingProps {\n /** Annoncé aux lecteurs d'écran à chaque changement ; « Chargement… »\n * par défaut. */\n libelle?: string\n className?: string\n}\n\n/** Attente sans forme connue : roue et libellé, annoncés poliment\n * (`role=\"status\"`). */\nexport function Loading({ libelle = \"Chargement…\", className }: LoadingProps) {\n return (\n <div\n role=\"status\"\n className={cn(\n \"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground\",\n className\n )}\n >\n <SpinnerDecoratif />\n {libelle}\n </div>\n )\n}\n\n/** Les squelettes sont décoratifs : ce statut masqué dit qu'on charge. */\nfunction StatutChargement() {\n return (\n <span className=\"sr-only\" role=\"status\">\n Chargement…\n </span>\n )\n}\n\nconst LARGEURS = [\"w-[70%]\", \"w-[55%]\", \"w-[80%]\", \"w-[40%]\", \"w-[60%]\"]\n\nexport interface SkeletonTableProps {\n /** 5 par défaut. */\n lignes?: number\n /** 4 par défaut. */\n colonnes?: number\n className?: string\n}\n\n/** Lignes de barres, à la place d'un tableau qui charge. */\nexport function SkeletonTable({\n lignes = 5,\n colonnes = 4,\n className,\n}: SkeletonTableProps) {\n return (\n <div className={cn(\"flex flex-col gap-3 py-2\", className)}>\n <StatutChargement />\n {Array.from({ length: lignes }, (_, ligne) => (\n <div\n key={ligne}\n aria-hidden\n className=\"grid gap-4\"\n style={{ gridTemplateColumns: `repeat(${colonnes}, minmax(0, 1fr))` }}\n >\n {Array.from({ length: colonnes }, (_, colonne) => (\n <Skeleton\n key={colonne}\n className={cn(\n \"h-4\",\n LARGEURS[(ligne + colonne) % LARGEURS.length]\n )}\n />\n ))}\n </div>\n ))}\n </div>\n )\n}\n\nexport interface SkeletonCardProps {\n /** 3 par défaut. */\n lignes?: number\n /**\n * Porte le statut « Chargement… » ; vrai par défaut. Faux quand la carte\n * fait partie d'un squelette qui l'annonce déjà (une seule annonce par\n * zone qui charge).\n */\n annoncer?: boolean\n className?: string\n}\n\n/** Une carte de lignes de texte, pour une fiche ou un résumé. */\nexport function SkeletonCard({\n lignes = 3,\n annoncer = true,\n className,\n}: SkeletonCardProps) {\n return (\n <Card className={className}>\n <CardContent className=\"flex flex-col gap-3\">\n {annoncer ? <StatutChargement /> : null}\n {Array.from({ length: lignes }, (_, index) => (\n <Skeleton\n key={index}\n aria-hidden\n className={cn(\"h-4\", LARGEURS[(index + 3) % LARGEURS.length])}\n />\n ))}\n </CardContent>\n </Card>\n )\n}\n\nexport interface SkeletonPageProps {\n className?: string\n}\n\n/** Une fiche qui charge : la ligne du titre, puis deux cartes ; un seul\n * statut « Chargement… ». */\nexport function SkeletonPage({ className }: SkeletonPageProps) {\n return (\n <div className={cn(\"flex flex-col gap-6\", className)}>\n <StatutChargement />\n <div aria-hidden className=\"flex flex-col gap-2\">\n <Skeleton className=\"h-4 w-40\" />\n <Skeleton className=\"h-7 w-72 max-w-full\" />\n </div>\n <SkeletonCard lignes={4} annoncer={false} />\n <SkeletonCard lignes={3} annoncer={false} />\n </div>\n )\n}\n"],"mappings":";;;;;;AAeA,SAAgBA,EAAQ,EAAE,aAAU,eAAe,gBAA2B;CAC5E,OACE,kBAAC,OAAD;EACE,MAAK;EACL,WAAWC,EACT,6EACAC,CACF;EALF,UAAA,CAOE,kBAACC,GAAD,CAAmB,CAAA,GAClBC,CACE;;AAET;AAGA,SAASC,IAAmB;CAC1B,OACE,kBAAC,QAAD;EAAM,WAAU;EAAU,MAAK;EAAS,UAAA;CAElC,CAAA;AAEV;AAEA,IAAMC,IAAW;CAAC;CAAW;CAAW;CAAW;CAAW;AAAS;AAWvE,SAAgBC,EAAc,EAC5B,YAAS,GACT,cAAW,GACX,gBACqB;CACrB,OACE,kBAAC,OAAD;EAAK,WAAWN,EAAG,4BAA4BC,CAAS;EAAxD,UAAA,CACE,kBAACG,GAAD,CAAmB,CAAA,GAClB,MAAM,KAAK,EAAE,QAAQG,EAAO,IAAI,GAAG,MAClC,kBAAC,OAAD;GAEE,eAAA;GACA,WAAU;GACV,OAAO,EAAE,qBAAqB,UAAUC,EAAS,mBAAmB;GAEnE,UAAA,MAAM,KAAK,EAAE,QAAQA,EAAS,IAAI,GAAG,MACpC,kBAACC,GAAD,EAEE,WAAWT,EACT,OACAK,GAAUK,IAAQC,KAAWN,EAAS,OACxC,EACD,GALMM,CAKN,CACF;EACE,GAdED,CAcF,CACN,CACE;;AAET;AAeA,SAAgBE,EAAa,EAC3B,YAAS,GACT,cAAW,IACX,gBACoB;CACpB,OACE,kBAACC,GAAD;EAAiB;EACf,UAAA,kBAACC,GAAD;GAAa,WAAU;GAAvB,UAAA,CACGC,IAAW,kBAACX,GAAD,CAAmB,CAAA,IAAI,MAClC,MAAM,KAAK,EAAE,QAAQG,EAAO,IAAI,GAAG,MAClC,kBAACE,GAAD;IAEE,eAAA;IACA,WAAWT,EAAG,OAAOK,GAAUW,IAAQ,KAAKX,EAAS,OAAO;GAC7D,GAHMW,CAGN,CACF,CACU;;CACT,CAAA;AAEV;AAQA,SAAgBC,EAAa,EAAE,gBAAgC;CAC7D,OACE,kBAAC,OAAD;EAAK,WAAWjB,EAAG,uBAAuBC,CAAS;EAAnD,UAAA;GACE,kBAACG,GAAD,CAAmB,CAAA;GACnB,kBAAC,OAAD;IAAK,eAAA;IAAY,WAAU;IAA3B,UAAA,CACE,kBAACK,GAAD,EAAU,WAAU,WAAY,CAAA,GAChC,kBAACA,GAAD,EAAU,WAAU,sBAAuB,CAAA,CACxC;;GACL,kBAACG,GAAD;IAAc,QAAQ;IAAG,UAAU;GAAQ,CAAA;GAC3C,kBAACA,GAAD;IAAc,QAAQ;IAAG,UAAU;GAAQ,CAAA;EACxC;;AAET"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { ComponentProps } from 'react';
|
|
2
2
|
/** Largeur maximale du contenu ; « full » : toute la largeur disponible. */
|
|
3
3
|
export type PageContainerLargeur = "md" | "lg" | "xl" | "full";
|
|
4
|
+
/**
|
|
5
|
+
* Gouttières d'une page (16 px sur téléphone, 24 puis 32 px au-delà), seule
|
|
6
|
+
* source des marges du contenu : `PageContainer` et le `bandeau` d'`AppShell`
|
|
7
|
+
* s'en servent, pour rester alignés.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GOUTTIERES_PAGE: {
|
|
10
|
+
readonly laterales: "px-4 sm:px-6 min-[1025px]:px-8";
|
|
11
|
+
readonly haute: "pt-6 min-[1025px]:pt-8";
|
|
12
|
+
readonly basse: "pb-6 min-[1025px]:pb-8";
|
|
13
|
+
};
|
|
4
14
|
export interface PageContainerProps extends ComponentProps<"div"> {
|
|
5
15
|
/** « full » par défaut (listes, tableaux) ; « md » pour un formulaire ou
|
|
6
16
|
* une fiche à lire, « lg » ou « xl » entre les deux. Le contenu limité
|
|
@@ -6,15 +6,19 @@ var n = {
|
|
|
6
6
|
lg: "max-w-5xl",
|
|
7
7
|
xl: "max-w-7xl",
|
|
8
8
|
full: ""
|
|
9
|
+
}, r = {
|
|
10
|
+
laterales: "px-4 sm:px-6 min-[1025px]:px-8",
|
|
11
|
+
haute: "pt-6 min-[1025px]:pt-8",
|
|
12
|
+
basse: "pb-6 min-[1025px]:pb-8"
|
|
9
13
|
};
|
|
10
|
-
function
|
|
14
|
+
function i({ largeur: i = "full", className: a, ...o }) {
|
|
11
15
|
return /* @__PURE__ */ t("div", {
|
|
12
16
|
"data-slot": "page-container",
|
|
13
|
-
"data-largeur":
|
|
14
|
-
className: e("mx-auto flex w-full min-w-0 flex-1 flex-col gap-6
|
|
15
|
-
...
|
|
17
|
+
"data-largeur": i,
|
|
18
|
+
className: e("mx-auto flex w-full min-w-0 flex-1 flex-col gap-6", r.laterales, r.haute, r.basse, n[i], a),
|
|
19
|
+
...o
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
|
-
export { r as PageContainer };
|
|
22
|
+
export { r as GOUTTIERES_PAGE, i as PageContainer };
|
|
19
23
|
|
|
20
24
|
//# sourceMappingURL=page-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-container.js","names":["LARGEURS","PageContainer","props","largeur","cn","className"],"sources":["../../../src/components/etic/page-container.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { cn } from \"cn\"\n\n/** Largeur maximale du contenu ; « full » : toute la largeur disponible. */\nexport type PageContainerLargeur = \"md\" | \"lg\" | \"xl\" | \"full\"\n\nconst LARGEURS: Record<PageContainerLargeur, string> = {\n md: \"max-w-3xl\",\n lg: \"max-w-5xl\",\n xl: \"max-w-7xl\",\n full: \"\",\n}\n\nexport interface PageContainerProps extends ComponentProps<\"div\"> {\n /** « full » par défaut (listes, tableaux) ; « md » pour un formulaire ou\n * une fiche à lire, « lg » ou « xl » entre les deux. Le contenu limité\n * est centré. */\n largeur?: PageContainerLargeur\n}\n\n/**\n * Conteneur d'une page, dans le `<main>` d'`AppShell` : marges autour du\n * contenu (resserrées sur téléphone), largeur maximale, et espacement\n * vertical régulier entre les blocs (en-tête, cartes, tableau), sur le\n * modèle des blocs « dashboard » de shadcn. Chaque page enveloppe son\n * contenu dedans plutôt que de poser ses propres marges.\n */\nexport function PageContainer({\n largeur = \"full\",\n className,\n ...props\n}: PageContainerProps) {\n return (\n <div\n data-slot=\"page-container\"\n data-largeur={largeur}\n className={cn(\n \"mx-auto flex w-full min-w-0 flex-1 flex-col gap-6
|
|
1
|
+
{"version":3,"file":"page-container.js","names":["LARGEURS","GOUTTIERES_PAGE","PageContainer","props","largeur","cn","className"],"sources":["../../../src/components/etic/page-container.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { cn } from \"cn\"\n\n/** Largeur maximale du contenu ; « full » : toute la largeur disponible. */\nexport type PageContainerLargeur = \"md\" | \"lg\" | \"xl\" | \"full\"\n\nconst LARGEURS: Record<PageContainerLargeur, string> = {\n md: \"max-w-3xl\",\n lg: \"max-w-5xl\",\n xl: \"max-w-7xl\",\n full: \"\",\n}\n\n/**\n * Gouttières d'une page (16 px sur téléphone, 24 puis 32 px au-delà), seule\n * source des marges du contenu : `PageContainer` et le `bandeau` d'`AppShell`\n * s'en servent, pour rester alignés.\n */\nexport const GOUTTIERES_PAGE = {\n laterales: \"px-4 sm:px-6 min-[1025px]:px-8\",\n haute: \"pt-6 min-[1025px]:pt-8\",\n basse: \"pb-6 min-[1025px]:pb-8\",\n} as const\n\nexport interface PageContainerProps extends ComponentProps<\"div\"> {\n /** « full » par défaut (listes, tableaux) ; « md » pour un formulaire ou\n * une fiche à lire, « lg » ou « xl » entre les deux. Le contenu limité\n * est centré. */\n largeur?: PageContainerLargeur\n}\n\n/**\n * Conteneur d'une page, dans le `<main>` d'`AppShell` : marges autour du\n * contenu (resserrées sur téléphone), largeur maximale, et espacement\n * vertical régulier entre les blocs (en-tête, cartes, tableau), sur le\n * modèle des blocs « dashboard » de shadcn. Chaque page enveloppe son\n * contenu dedans plutôt que de poser ses propres marges.\n */\nexport function PageContainer({\n largeur = \"full\",\n className,\n ...props\n}: PageContainerProps) {\n return (\n <div\n data-slot=\"page-container\"\n data-largeur={largeur}\n className={cn(\n \"mx-auto flex w-full min-w-0 flex-1 flex-col gap-6\",\n GOUTTIERES_PAGE.laterales,\n GOUTTIERES_PAGE.haute,\n GOUTTIERES_PAGE.basse,\n LARGEURS[largeur],\n className\n )}\n {...props}\n />\n )\n}\n"],"mappings":";;;AAMA,IAAMA,IAAiD;CACrD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;AACR,GAOaC,IAAkB;CAC7B,WAAW;CACX,OAAO;CACP,OAAO;AACT;AAgBA,SAAgBC,EAAc,EAC5B,aAAU,QACV,cACA,GAAGC,KACkB;CACrB,OACE,kBAAC,OAAD;EACE,aAAU;EACV,gBAAcC;EACd,WAAWC,EACT,qDACAJ,EAAgB,WAChBA,EAAgB,OAChBA,EAAgB,OAChBD,EAASI,IACTE,CACF;EACA,GAAIH;CACL,CAAA;AAEL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { LucideIcon } from 'lucide-react';
|
|
3
|
-
import {
|
|
3
|
+
import { LienComposant } from './lien';
|
|
4
4
|
export interface PageHeaderProps {
|
|
5
5
|
titre: ReactNode;
|
|
6
6
|
/** Ligne discrète sous le titre. */
|
|
@@ -44,15 +44,21 @@ export interface DetailHeaderProps {
|
|
|
44
44
|
actions?: ReactNode;
|
|
45
45
|
/** Actions rares ou destructives, derrière « Plus d'actions ». */
|
|
46
46
|
actionsSecondaires?: DetailHeaderActionSecondaire[];
|
|
47
|
+
/**
|
|
48
|
+
* Taille des boutons de `actions` (leur `size`, à leur donner) : le bouton
|
|
49
|
+
* « Plus d'actions » la suit (`icon` ou `icon-lg`) pour rester aligné.
|
|
50
|
+
*/
|
|
51
|
+
tailleActions?: "default" | "lg";
|
|
47
52
|
/**
|
|
48
53
|
* Fiche dont la première carte répète déjà le nom : le fil d'Ariane porte
|
|
49
54
|
* seul le titre (le `<h1>`), actions sur la même ligne. Demande `chemin`.
|
|
50
55
|
*/
|
|
51
56
|
compact?: boolean;
|
|
52
|
-
/** Composant de lien du routeur,
|
|
53
|
-
|
|
57
|
+
/** Composant de lien du routeur ; par défaut, celui du `LienProvider`,
|
|
58
|
+
* sinon un `<a>`. */
|
|
59
|
+
lien?: LienComposant;
|
|
54
60
|
className?: string;
|
|
55
61
|
}
|
|
56
62
|
/** En-tête d'une fiche (un élément d'une liste) : fil d'Ariane, titre,
|
|
57
63
|
* badges, méta, actions courantes et menu des actions rares. */
|
|
58
|
-
export declare function DetailHeader({ chemin, titre, badges, meta, actions, actionsSecondaires, compact, lien
|
|
64
|
+
export declare function DetailHeader({ chemin, titre, badges, meta, actions, actionsSecondaires, tailleActions, compact, lien, className, }: DetailHeaderProps): import("react").JSX.Element;
|