diff --git a/eslint.config.js b/eslint.config.js
index 75b4d61e..400197f8 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -47,8 +47,26 @@ export default tseslint.config(
alphabetize: { order: 'asc' },
},
],
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
+ '@typescript-eslint/no-unused-vars': [
+ 'error',
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
+ ],
'@typescript-eslint/consistent-type-imports': 'error',
+ // React-idiomatic relaxations (strict-type-checked is too aggressive
+ // against common JSX patterns):
+ '@typescript-eslint/no-confusing-void-expression': 'off',
+ '@typescript-eslint/no-misused-promises': [
+ 'error',
+ { checksVoidReturn: { attributes: false } },
+ ],
+ '@typescript-eslint/no-floating-promises': 'warn',
+ '@typescript-eslint/no-unnecessary-condition': 'off',
+ '@typescript-eslint/restrict-template-expressions': [
+ 'error',
+ { allowNumber: true, allowBoolean: true },
+ ],
+ '@typescript-eslint/dot-notation': 'off',
+ '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
},
},
prettierConfig,
diff --git a/src/components/Brand.tsx b/src/components/Brand.tsx
index 6db2172b..b9607675 100644
--- a/src/components/Brand.tsx
+++ b/src/components/Brand.tsx
@@ -1,3 +1,26 @@
-export function Brand() {
- return null;
+import { FR } from '@/i18n/fr';
+
+export function Brand({ compact = false }: { compact?: boolean }) {
+ return (
+
+
+
+ {FR.app.name}
+
+
+ );
}
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx
index 86272469..c881ba22 100644
--- a/src/components/Footer.tsx
+++ b/src/components/Footer.tsx
@@ -1,3 +1,23 @@
+import { FR } from '@/i18n/fr';
+
export function Footer() {
- return null;
+ const year = new Date().getFullYear();
+ return (
+
+ );
}
diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index c6bb6a91..01c86c0b 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -1,3 +1,11 @@
+import { Brand } from './Brand';
+
export function Header() {
- return null;
+ return (
+
+ );
}
diff --git a/src/components/Shell.tsx b/src/components/Shell.tsx
new file mode 100644
index 00000000..21dbfd7c
--- /dev/null
+++ b/src/components/Shell.tsx
@@ -0,0 +1,14 @@
+import type { ReactNode } from 'react';
+
+import { Footer } from './Footer';
+import { Header } from './Header';
+
+export function Shell({ children }: { children: ReactNode }) {
+ return (
+
+
+ {children}
+
+
+ );
+}
diff --git a/src/components/ui/Badge.tsx b/src/components/ui/Badge.tsx
new file mode 100644
index 00000000..73c0bf9e
--- /dev/null
+++ b/src/components/ui/Badge.tsx
@@ -0,0 +1,33 @@
+import type { HTMLAttributes, ReactNode } from 'react';
+
+import { cn } from '@/lib/cn';
+
+type Variant = 'neutral' | 'mild' | 'moderate' | 'severe' | 'soft';
+
+const variants: Record = {
+ neutral: 'bg-clinic-100 text-clinic-800',
+ mild: 'bg-clinic-200 text-clinic-800',
+ moderate: 'bg-warm-300 text-clinic-900',
+ severe: 'bg-warm-500 text-white',
+ soft: 'bg-clinic-50 text-clinic-700 border border-clinic-100',
+};
+
+export function Badge({
+ variant = 'neutral',
+ className,
+ children,
+ ...rest
+}: HTMLAttributes & { variant?: Variant; children?: ReactNode }) {
+ return (
+
+ {children}
+
+ );
+}
diff --git a/src/components/ui/Button.tsx b/src/components/ui/Button.tsx
new file mode 100644
index 00000000..f97a6d07
--- /dev/null
+++ b/src/components/ui/Button.tsx
@@ -0,0 +1,45 @@
+import type { ButtonHTMLAttributes, ReactNode } from 'react';
+
+import { cn } from '@/lib/cn';
+
+type Variant = 'primary' | 'secondary' | 'ghost' | 'danger';
+type Size = 'sm' | 'md' | 'lg';
+
+interface ButtonProps extends ButtonHTMLAttributes {
+ variant?: Variant;
+ size?: Size;
+ children?: ReactNode;
+}
+
+const base =
+ 'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors ' +
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-clinic-500 focus-visible:ring-offset-2 ' +
+ 'disabled:pointer-events-none disabled:opacity-50';
+
+const variants: Record = {
+ primary: 'bg-clinic-600 text-white hover:bg-clinic-700',
+ secondary: 'bg-clinic-100 text-clinic-800 hover:bg-clinic-200',
+ ghost: 'text-clinic-700 hover:bg-clinic-100',
+ danger: 'bg-warm-500 text-white hover:bg-warm-400',
+};
+
+const sizes: Record = {
+ sm: 'h-8 px-3 text-sm',
+ md: 'h-10 px-4 text-sm',
+ lg: 'h-12 px-6 text-base',
+};
+
+export function Button({
+ variant = 'primary',
+ size = 'md',
+ className,
+ children,
+ type = 'button',
+ ...rest
+}: ButtonProps) {
+ return (
+
+ );
+}
diff --git a/src/components/ui/Card.tsx b/src/components/ui/Card.tsx
new file mode 100644
index 00000000..36558051
--- /dev/null
+++ b/src/components/ui/Card.tsx
@@ -0,0 +1,37 @@
+import type { HTMLAttributes, ReactNode } from 'react';
+
+import { cn } from '@/lib/cn';
+
+export function Card({
+ className,
+ children,
+ ...rest
+}: HTMLAttributes & { children?: ReactNode }) {
+ return (
+
+ {children}
+
+ );
+}
+
+export function CardHeader({
+ className,
+ children,
+}: HTMLAttributes & { children?: ReactNode }) {
+ return (
+ {children}
+ );
+}
+
+export function CardBody({
+ className,
+ children,
+}: HTMLAttributes & { children?: ReactNode }) {
+ return {children}
;
+}
diff --git a/src/components/ui/Dialog.tsx b/src/components/ui/Dialog.tsx
new file mode 100644
index 00000000..a371b635
--- /dev/null
+++ b/src/components/ui/Dialog.tsx
@@ -0,0 +1,58 @@
+import { AnimatePresence, motion } from 'motion/react';
+import type { ReactNode } from 'react';
+import { useEffect } from 'react';
+
+import { SPRING } from '@/lib/motion';
+import { cn } from '@/lib/cn';
+
+interface DialogProps {
+ open: boolean;
+ onClose: () => void;
+ title?: string;
+ children?: ReactNode;
+ className?: string;
+}
+
+export function Dialog({ open, onClose, title, children, className }: DialogProps) {
+ useEffect(() => {
+ if (!open) return undefined;
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') onClose();
+ };
+ document.addEventListener('keydown', onKey);
+ return () => document.removeEventListener('keydown', onKey);
+ }, [open, onClose]);
+
+ return (
+
+ {open && (
+
+
+
+ {title && {title}
}
+ {children}
+
+
+ )}
+
+ );
+}
diff --git a/src/components/ui/Input.tsx b/src/components/ui/Input.tsx
new file mode 100644
index 00000000..ca23f079
--- /dev/null
+++ b/src/components/ui/Input.tsx
@@ -0,0 +1,21 @@
+import type { InputHTMLAttributes } from 'react';
+import { forwardRef } from 'react';
+
+import { cn } from '@/lib/cn';
+
+export const Input = forwardRef>(
+ function Input({ className, ...rest }, ref) {
+ return (
+
+ );
+ },
+);
diff --git a/src/components/ui/Label.tsx b/src/components/ui/Label.tsx
new file mode 100644
index 00000000..01367793
--- /dev/null
+++ b/src/components/ui/Label.tsx
@@ -0,0 +1,15 @@
+import type { LabelHTMLAttributes, ReactNode } from 'react';
+
+import { cn } from '@/lib/cn';
+
+export function Label({
+ className,
+ children,
+ ...rest
+}: LabelHTMLAttributes & { children?: ReactNode }) {
+ return (
+
+ );
+}
diff --git a/src/components/ui/Select.tsx b/src/components/ui/Select.tsx
new file mode 100644
index 00000000..efdaa5e7
--- /dev/null
+++ b/src/components/ui/Select.tsx
@@ -0,0 +1,23 @@
+import type { SelectHTMLAttributes } from 'react';
+import { forwardRef } from 'react';
+
+import { cn } from '@/lib/cn';
+
+export const Select = forwardRef>(
+ function Select({ className, children, ...rest }, ref) {
+ return (
+
+ );
+ },
+);
diff --git a/src/components/ui/Textarea.tsx b/src/components/ui/Textarea.tsx
new file mode 100644
index 00000000..d7c071ae
--- /dev/null
+++ b/src/components/ui/Textarea.tsx
@@ -0,0 +1,21 @@
+import type { TextareaHTMLAttributes } from 'react';
+import { forwardRef } from 'react';
+
+import { cn } from '@/lib/cn';
+
+export const Textarea = forwardRef<
+ HTMLTextAreaElement,
+ TextareaHTMLAttributes
+>(function Textarea({ className, ...rest }, ref) {
+ return (
+
+ );
+});
diff --git a/src/editor/AnatomyCanvas.tsx b/src/editor/AnatomyCanvas.tsx
index f1976674..6cd09bd7 100644
--- a/src/editor/AnatomyCanvas.tsx
+++ b/src/editor/AnatomyCanvas.tsx
@@ -1,3 +1,61 @@
-export function AnatomyCanvas() {
- return null;
+import { motion } from 'motion/react';
+import { useState } from 'react';
+
+import { cn } from '@/lib/cn';
+import { FADE_IN_UP } from '@/lib/motion';
+import type { SpeciesAnatomy, View } from '@/species/types';
+
+import { AnatomyView } from './AnatomyView';
+
+const TABS: { id: View; label: string }[] = [
+ { id: 'lateral_left', label: 'Latéral gauche' },
+ { id: 'lateral_right', label: 'Latéral droit' },
+ { id: 'dorsal', label: 'Vue dorsale' },
+];
+
+interface Props {
+ anatomy: SpeciesAnatomy;
+ highlightFinding?: string[];
+}
+
+export function AnatomyCanvas({ anatomy, highlightFinding }: Props) {
+ const [view, setView] = useState('lateral_left');
+ return (
+
+
+ {TABS.map((t) => (
+
+ ))}
+
+
+
+
+
+
+ );
}
diff --git a/src/editor/AnatomyView.tsx b/src/editor/AnatomyView.tsx
index 6b99be2b..984f1e5d 100644
--- a/src/editor/AnatomyView.tsx
+++ b/src/editor/AnatomyView.tsx
@@ -1,3 +1,89 @@
-export function AnatomyView() {
- return null;
+import { useEffect, useRef } from 'react';
+
+import { cn } from '@/lib/cn';
+import { useReportStore } from '@/state/reportStore';
+
+interface Props {
+ src: string;
+ className?: string;
+ highlightFinding?: string[];
+}
+
+// SVG sources come from our own /public/species/ directory — fully static,
+// same-origin, controlled assets. We parse them with DOMParser (not innerHTML)
+// then adopt the root SVG node into the live DOM so we can wire click handlers
+// and style zones via CSS variables.
+export function AnatomyView({ src, className, highlightFinding = [] }: Props) {
+ const containerRef = useRef(null);
+ const selection = useReportStore((s) => s.selection);
+ const toggleZone = useReportStore((s) => s.toggleZone);
+
+ useEffect(() => {
+ const el = containerRef.current;
+ if (!el) return undefined;
+ let cancelled = false;
+ (async () => {
+ try {
+ const res = await fetch(src);
+ const text = await res.text();
+ if (cancelled || !el) return;
+ const doc = new DOMParser().parseFromString(text, 'image/svg+xml');
+ const svg = doc.documentElement;
+ // Clear and adopt
+ while (el.firstChild) el.removeChild(el.firstChild);
+ const imported = document.importNode(svg, true);
+ el.appendChild(imported);
+ } catch {
+ if (el) {
+ while (el.firstChild) el.removeChild(el.firstChild);
+ const err = document.createElement('div');
+ err.className = 'p-4 text-warm-500';
+ err.textContent = 'Erreur de chargement du schéma.';
+ el.appendChild(err);
+ }
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ }, [src]);
+
+ useEffect(() => {
+ const el = containerRef.current;
+ if (!el) return undefined;
+ const onClick = (e: Event) => {
+ const target = (e.target as Element).closest('[data-zone]') as HTMLElement | null;
+ if (!target) return;
+ const zoneId = target.dataset['zone'];
+ if (zoneId) toggleZone(zoneId);
+ };
+ el.addEventListener('click', onClick);
+ return () => el.removeEventListener('click', onClick);
+ }, [toggleZone]);
+
+ useEffect(() => {
+ const el = containerRef.current;
+ if (!el) return;
+ const zones = el.querySelectorAll('[data-zone]');
+ zones.forEach((z) => {
+ const id = z.dataset['zone'] ?? '';
+ const sel = selection.includes(id);
+ const linked = highlightFinding.includes(id);
+ z.style.cursor = 'pointer';
+ z.style.transition = 'fill 0.15s ease';
+ if (sel) z.style.fill = 'var(--zone-selected)';
+ else if (linked) z.style.fill = 'var(--zone-linked)';
+ else z.style.fill = 'transparent';
+ z.setAttribute('data-selected', sel ? 'true' : 'false');
+ z.setAttribute('data-linked', linked ? 'true' : 'false');
+ });
+ }, [selection, highlightFinding]);
+
+ return (
+
+ );
}
diff --git a/src/editor/ConclusionPanel.tsx b/src/editor/ConclusionPanel.tsx
index e950d553..25823ace 100644
--- a/src/editor/ConclusionPanel.tsx
+++ b/src/editor/ConclusionPanel.tsx
@@ -1,3 +1,47 @@
+import { Card, CardBody } from '@/components/ui/Card';
+import { Input } from '@/components/ui/Input';
+import { Label } from '@/components/ui/Label';
+import { Textarea } from '@/components/ui/Textarea';
+import { useReportStore } from '@/state/reportStore';
+
export function ConclusionPanel() {
- return null;
+ const report = useReportStore((s) => s.report);
+ const setConclusion = useReportStore((s) => s.setConclusion);
+ const setRecommendations = useReportStore((s) => s.setRecommendations);
+ const setNextAppointment = useReportStore((s) => s.setNextAppointment);
+
+ return (
+
+
+ Conclusion
+
+
+
+
+
+
+
+
+ setNextAppointment(e.target.value || undefined)}
+ />
+
+
+
+ );
}
diff --git a/src/editor/ExportButton.tsx b/src/editor/ExportButton.tsx
index 2d3934a6..d7508431 100644
--- a/src/editor/ExportButton.tsx
+++ b/src/editor/ExportButton.tsx
@@ -1,3 +1,36 @@
-export function ExportButton() {
- return null;
+import { useState } from 'react';
+
+import { Button } from '@/components/ui/Button';
+import { exportReport, type AnatomyAssets } from '@/pdf/export';
+import type { Report } from '@/schema/report';
+
+interface Props {
+ report: Report;
+ assets: AnatomyAssets;
+}
+
+export function ExportButton({ report, assets }: Props) {
+ const [loading, setLoading] = useState(false);
+
+ const handleClick = async () => {
+ setLoading(true);
+ try {
+ const blob = await exportReport(report, assets);
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ const safe = report.animal.name.replace(/[^\p{L}\p{N}_-]+/gu, '_');
+ a.download = `bilan-${safe}-${report.sessionDate}.pdf`;
+ a.click();
+ URL.revokeObjectURL(url);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+
+ );
}
diff --git a/src/editor/FindingEditor.tsx b/src/editor/FindingEditor.tsx
index 441f75ff..7054fd37 100644
--- a/src/editor/FindingEditor.tsx
+++ b/src/editor/FindingEditor.tsx
@@ -1,3 +1,229 @@
-export function FindingEditor() {
- return null;
+import { useMemo, useState } from 'react';
+
+import { Badge } from '@/components/ui/Badge';
+import { Button } from '@/components/ui/Button';
+import { Dialog } from '@/components/ui/Dialog';
+import { Input } from '@/components/ui/Input';
+import { Label } from '@/components/ui/Label';
+import { Textarea } from '@/components/ui/Textarea';
+import { FR } from '@/i18n/fr';
+import { newId } from '@/lib/id';
+import { cn } from '@/lib/cn';
+import type { Finding, PathologyRef, Severity } from '@/schema/finding';
+import type { PathologyEntry } from '@/species/types';
+
+interface Props {
+ open: boolean;
+ onClose: () => void;
+ zones: string[];
+ zoneLabel: (id: string) => string;
+ allZones: { id: string; label: string }[];
+ catalog: PathologyEntry[];
+ initial?: Finding | null;
+ onSubmit: (input: Omit & { id?: string }) => void;
+}
+
+export function FindingEditor({
+ open,
+ onClose,
+ zones,
+ zoneLabel,
+ allZones,
+ catalog,
+ initial,
+ onSubmit,
+}: Props) {
+ const [severity, setSeverity] = useState(initial?.severity ?? 'mild');
+ const [pathologies, setPathologies] = useState(initial?.pathologies ?? []);
+ const [comment, setComment] = useState(initial?.comment ?? '');
+ const [linkedZones, setLinkedZones] = useState(initial?.linkedZones ?? []);
+ const [freeText, setFreeText] = useState('');
+
+ const filtered = useMemo(() => {
+ const zoneSet = new Set([...zones, ...linkedZones]);
+ return catalog.filter((p) => {
+ if (p.applicableZones.length === 0) return true;
+ return p.applicableZones.some((z) => zoneSet.has(z));
+ });
+ }, [catalog, zones, linkedZones]);
+
+ const togglePathology = (entry: PathologyEntry) => {
+ setPathologies((prev) => {
+ const exists = prev.find((p) => p.id === entry.id);
+ if (exists) return prev.filter((p) => p.id !== entry.id);
+ return [...prev, { id: entry.id, label: entry.label, free: false }];
+ });
+ };
+
+ const addFreeText = () => {
+ const label = freeText.trim();
+ if (!label) return;
+ setPathologies((prev) => [...prev, { id: newId('free'), label, free: true }]);
+ setFreeText('');
+ };
+
+ const toggleLinkedZone = (id: string) => {
+ setLinkedZones((prev) => (prev.includes(id) ? prev.filter((z) => z !== id) : [...prev, id]));
+ };
+
+ const handleSubmit = () => {
+ const payload = {
+ ...(initial?.id ? { id: initial.id } : {}),
+ zones,
+ linkedZones,
+ pathologies,
+ severity,
+ comment,
+ };
+ onSubmit(payload);
+ };
+
+ return (
+
+ );
}
diff --git a/src/editor/FindingPanel.tsx b/src/editor/FindingPanel.tsx
index b8065d06..79f42a7b 100644
--- a/src/editor/FindingPanel.tsx
+++ b/src/editor/FindingPanel.tsx
@@ -1,3 +1,145 @@
-export function FindingPanel() {
- return null;
+import { AnimatePresence, motion } from 'motion/react';
+import { useState } from 'react';
+
+import { Badge } from '@/components/ui/Badge';
+import { Button } from '@/components/ui/Button';
+import { Card, CardBody } from '@/components/ui/Card';
+import { FR } from '@/i18n/fr';
+import type { Finding, Severity } from '@/schema/finding';
+import type { PathologyEntry, SpeciesAnatomy } from '@/species/types';
+import { useReportStore } from '@/state/reportStore';
+
+import { FindingEditor } from './FindingEditor';
+
+interface Props {
+ anatomy: SpeciesAnatomy;
+ catalog: PathologyEntry[];
+ onPreviewFinding: (id: string | null) => void;
+}
+
+const severityVariant: Record = {
+ mild: 'mild',
+ moderate: 'moderate',
+ severe: 'severe',
+};
+
+export function FindingPanel({ anatomy, catalog, onPreviewFinding }: Props) {
+ const report = useReportStore((s) => s.report);
+ const selection = useReportStore((s) => s.selection);
+ const addFinding = useReportStore((s) => s.addFinding);
+ const updateFinding = useReportStore((s) => s.updateFinding);
+ const removeFinding = useReportStore((s) => s.removeFinding);
+
+ const [editorOpen, setEditorOpen] = useState(false);
+ const [editing, setEditing] = useState(null);
+
+ const zoneLabel = (id: string) => anatomy.zones.find((z) => z.id === id)?.label ?? id;
+ const allZones = anatomy.zones.map((z) => ({ id: z.id, label: z.label }));
+
+ const openNew = () => {
+ if (selection.length === 0) return;
+ setEditing(null);
+ setEditorOpen(true);
+ };
+ const openEdit = (f: Finding) => {
+ setEditing(f);
+ setEditorOpen(true);
+ };
+ const handleSubmit = (payload: Omit & { id?: string }) => {
+ if (payload.id) {
+ const { id, ...rest } = payload;
+ updateFinding(id, rest);
+ } else {
+ addFinding(payload);
+ }
+ setEditorOpen(false);
+ onPreviewFinding(null);
+ };
+
+ const editorZones = editing ? editing.zones : selection;
+
+ return (
+
+
+
Observations
+
+
+
+
+ {(report?.findings ?? []).map((f) => (
+ onPreviewFinding(f.id)}
+ onMouseLeave={() => onPreviewFinding(null)}
+ >
+
+
+
+
+ {f.zones.map((z) => (
+
+ {zoneLabel(z)}
+
+ ))}
+ {f.linkedZones.map((z) => (
+
+ ↳ {zoneLabel(z)}
+
+ ))}
+
+
{FR.severity[f.severity]}
+
+ {f.pathologies.length > 0 && (
+
+ {f.pathologies.map((p) => (
+
+ • {p.label}
+
+ ))}
+
+ )}
+ {f.comment && {f.comment}
}
+
+
+
+
+
+
+
+ ))}
+
+
+ {(report?.findings ?? []).length === 0 && (
+
+ Aucune observation. Cliquez sur des zones puis validez pour en créer.
+
+ )}
+
+
setEditorOpen(false)}
+ zones={editorZones}
+ zoneLabel={zoneLabel}
+ allZones={allZones}
+ catalog={catalog}
+ initial={editing}
+ onSubmit={handleSubmit}
+ />
+
+ );
}
diff --git a/src/editor/ZoneSelection.tsx b/src/editor/ZoneSelection.tsx
index d11d11f8..4294d3cb 100644
--- a/src/editor/ZoneSelection.tsx
+++ b/src/editor/ZoneSelection.tsx
@@ -1,3 +1,55 @@
-export function ZoneSelection() {
- return null;
+import { AnimatePresence, motion } from 'motion/react';
+
+import { Badge } from '@/components/ui/Badge';
+import { Button } from '@/components/ui/Button';
+import { useReportStore } from '@/state/reportStore';
+
+interface Props {
+ zoneLabel: (id: string) => string;
+ onValidate: () => void;
+}
+
+export function ZoneSelection({ zoneLabel, onValidate }: Props) {
+ const selection = useReportStore((s) => s.selection);
+ const toggleZone = useReportStore((s) => s.toggleZone);
+ const clearSelection = useReportStore((s) => s.clearSelection);
+
+ if (selection.length === 0) {
+ return (
+
+ Cliquez sur les zones du schéma pour créer une observation.
+
+ );
+ }
+
+ return (
+
+
+
+ {selection.map((id) => (
+
+ toggleZone(id)}>
+ {zoneLabel(id)} ×
+
+
+ ))}
+
+
+
+
+
+
+
+ );
}
diff --git a/src/editor/rasterize.ts b/src/editor/rasterize.ts
new file mode 100644
index 00000000..9c75d8dc
--- /dev/null
+++ b/src/editor/rasterize.ts
@@ -0,0 +1,59 @@
+// Rasterizes an SVG URL into a PNG Uint8Array using