feat(editor): four tabs, Annotations sections, references from the header

U1 Lot B1. Four tabs (Général, Annotations, Constats, Vérification); views,
categories and regions become full-width Annotations sections opened from the
overview panel; references move to a header-toggled panel (minimal, Lot D
completes it); « Aller à » goes through EditorTarget and the navigation hook.
EditorWorkspace owns the navigation; DraftHeader split in HeaderActions and
SaveLine; EditorTabs split in TabList and MoreTabs.

R-24, assertions removed or rewritten (file: old -> new):
unit
- editor-route.test: seven tab names -> four; « Plus » at 800 px with
  Références clicked -> no « Plus »; below 640 px five others -> Général,
  Constats, and Constats opens the findings tab; + references panel cases
- editor-route-recovery.test: tab Références + editor-tab-references label ->
  header button + editor-references-panel labelled by its heading
- editor-mode.test: small tier `more` of five -> [general, findings]
- editor-focus-request.test: {key,serial} -> {target,serial}; ReferencesTab and
  VertebraeTab -> ReferencesPanel and RegionsSection; issueTarget tab/key ->
  target place/section/key (vertebrae tab -> annotations/regions); consumed
  context (serial) -> (serial, outcome); annotation case adds heading focus
- editor-verification.test: onGoTo('annotations', key) -> navigate(targetOfKey
  (key), opener); props onSelectTab/onGoTo -> navigate
- editor-annotations-tab.test: props onSelectTab -> navigate + section props;
  no_category text « (onglet Général) » -> « (Annotations, section
  Catégories) »
- editor-tabs-general.test: categories cases render GeneralTab ->
  CategoriesSection(doc); + Général holds no categories editor
- editor-tabs-lists.test: tab imports -> panel and section; read-only
  references « no button » -> only « Fermer les références »
- editor-tabs-views, editor-drawing-upload, editor-repair.test: ViewsTab ->
  ViewsSection import, assertions kept; editor-findings.test: navigate prop
e2e
- support/editor selectTab: exact name -> pattern (error badge in the name);
  + place, openSection, showDrawing, backToDrawing, openReferences, TABS
- support/warm-up: seven tabs -> four + sections + references panel
- editor-access: seven-tab axe loops -> four tabs + three sections + panel
  (edit and read-only); narrow widths add panel overflow and axe
- editor-drawings: tab Vues -> openSection views; tab Annotations ->
  showDrawing
- editor-structures: tab Général (categories) -> openSection categories, axe
  label « general tab » -> « categories section »; tab Références ->
  openReferences/closeReferences; tab Vertèbres -> openSection regions; tab
  Annotations -> showDrawing
- editor-geometry: three tab Vues -> openSection views
- editor-equine: tab Général (categories add) -> openSection categories; five
  tabs loop -> two tabs + sections + panel; tab Annotations -> showDrawing
- editor-journey: tab Vues, tab Général (category), tab Annotations ->
  openSection views/categories, showDrawing; frozen axe scrolls to the header
- lan/trial-lan (not run): tab Vues -> Annotations tab + views entry

Verified: typecheck, lint, vitest 107 files / 1125 tests, whole shell suite on
the sandbox 151 passed, 49 skipped, 0 failed.
This commit is contained in:
bchanot committed 2026-11-06 20:25:35 +01:00
1 parent 95b1b7e461
commit bc2dba7c14
56 files changed
+2419 -699

No files matched your search

@@ -0,0 +1,190 @@
import type {
AnatomicalSheetDocument,
SheetView,
} from '@faunosteo/core-wasm/types'
import { useOverviewCounts } from '@/editor/annotations/overview'
import type { AnnotationSection } from '@/editor/navigation'
import { usePlural } from '@/editor/plural'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
const CARD = 'space-y-2 rounded-xl border border-[var(--color-border)] p-4'
const TITLE = 'text-sm font-semibold'
const ROW =
'flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]'
const ENTRY =
'inline-flex min-h-11 items-center rounded-lg border border-[var(--color-border)] px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]'
export interface OverviewPanelProps {
doc: AnatomicalSheetDocument
/** The view the canvas shows. */
viewId: string
/** Read-only modes only consult: the entries read « Voir … ». */
readOnly: boolean
onSelectView: (viewId: string) => void
onOpenSection: (section: AnnotationSection, opener: HTMLElement) => void
}
function SectionEntry({
section,
label,
onOpen,
}: {
section: AnnotationSection
label: string
onOpen: OverviewPanelProps['onOpenSection']
}) {
return (
<button
type="button"
data-section-entry={section}
onClick={(event) => onOpen(section, event.currentTarget)}
className={ENTRY}
>
{label}
</button>
)
}
function ViewRow({
view,
current,
count,
onSelect,
}: {
view: SheetView
current: boolean
count: number
onSelect: () => void
}) {
const t = useT()
const plural = usePlural()
const locale = useLocaleStore((s) => s.locale)
return (
<li>
<button
type="button"
aria-current={current}
onClick={onSelect}
className={`${ROW} ${current ? 'bg-[var(--color-surface-strong)]' : ''}`}
>
<span className="min-w-0">
<span className="block truncate font-medium">
{view.name[locale]}
</span>
<span className="text-[var(--color-ink-muted)]">
{t(
view.kind === 'main'
? 'editor.overview.view_main'
: 'editor.overview.view_detail',
)}
</span>
</span>
<span className="shrink-0 text-[var(--color-ink-muted)]">
{plural('editor.overview.annotations', count)}
</span>
</button>
</li>
)
}
function ViewsCard(props: OverviewPanelProps) {
const t = useT()
const { doc, viewId, readOnly, onSelectView, onOpenSection } = props
const counts = useOverviewCounts(doc)
return (
<section aria-labelledby="overview-views" className={CARD}>
<h3 id="overview-views" className={TITLE}>
{t('editor.overview.views')}
</h3>
<ul>
{doc.views.map((view) => (
<ViewRow
key={view.id}
view={view}
current={view.id === viewId}
count={counts.annotationsByView.get(view.id) ?? 0}
onSelect={() => onSelectView(view.id)}
/>
))}
</ul>
<SectionEntry
section="views"
label={t(
readOnly
? 'editor.overview.see_views'
: 'editor.overview.manage_views',
)}
onOpen={onOpenSection}
/>
</section>
)
}
function CategoriesCard(props: OverviewPanelProps) {
const t = useT()
const plural = usePlural()
const locale = useLocaleStore((s) => s.locale)
const { doc, readOnly, onOpenSection } = props
const counts = useOverviewCounts(doc)
return (
<section aria-labelledby="overview-categories" className={CARD}>
<h3 id="overview-categories" className={TITLE}>
{t('editor.overview.categories')}
</h3>
{doc.categories.length === 0 && (
<p className="text-sm text-[var(--color-ink-muted)]">
{t('editor.overview.categories_empty')}
</p>
)}
<ul className="flex flex-wrap gap-2">
{doc.categories.map((category) => (
<li
key={category.id}
className="inline-flex items-center gap-2 rounded-full border border-[var(--color-border)] px-3 py-1 text-sm"
>
<span
aria-hidden="true"
className="size-3 rounded-full border border-[var(--color-border)]"
style={{ backgroundColor: category.color ?? undefined }}
/>
{category.name[locale]}
</li>
))}
</ul>
<div className="flex flex-wrap gap-2">
<SectionEntry
section="categories"
label={t(
readOnly
? 'editor.overview.see_categories'
: 'editor.overview.edit_categories',
)}
onOpen={onOpenSection}
/>
{/* T17 / BDR-102: no vertebra role exists before U6, so this entry is always shown. */}
<SectionEntry
section="regions"
label={plural('editor.overview.regions', counts.regions)}
onOpen={onOpenSection}
/>
</div>
</section>
)
}
/** Board 01's overview: the views and the categories, with the entries to their sections. */
export default function OverviewPanel(props: OverviewPanelProps) {
const t = useT()
return (
<div
role="region"
aria-label={t('editor.overview.label')}
data-testid="annotation-overview"
className="space-y-3"
>
<ViewsCard {...props} />
<CategoriesCard {...props} />
</div>
)
}