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

+67 -6
View File
@@ -1,20 +1,81 @@
import { useContext, useEffect, useRef } from 'react'
import type {
AnatomicalSheetDocument,
ElementKey,
} from '@faunosteo/core-wasm/types'
import {
AnnounceContext,
useFocusRequest,
visibleElement,
type FocusRequest,
} from '../focusRequest'
import { useT } from '@/i18n/useT'
/** What « Aller à … » seeds in the Annotations tab: a view, and maybe an annotation. */
/** What « Aller à … » seeds on the drawing: the view and the annotation a key names. */
export function annotationFocus(
doc: AnatomicalSheetDocument,
key: ElementKey,
): { viewId: string; annotationId: string | null } | null {
if (key.kind === 'view') {
const view = doc.views.find((v) => v.id === key.id)
return view ? { viewId: view.id, annotationId: null } : null
}
): { viewId: string; annotationId: string } | null {
if (key.kind !== 'annotation') return null
const annotation = doc.annotations.find((a) => a.id === key.id)
return annotation
? { viewId: annotation.view_id, annotationId: annotation.id }
: null
}
/** What the request needs to know of the drawing, and the one thing it may do to it. */
export interface DrawingState {
viewId: string
selectedId: string | null
/** A creation or a tracing in progress: the request is kept, not served. */
busy: 'creation' | 'tracing' | null
show: (viewId: string, annotationId: string) => void
}
const BUSY_TARGET = {
creation: '[data-creation-heading]',
tracing: '[data-testid="tracing-bar"]',
} as const
const focusFirst = (selector: string) => visibleElement(selector)?.focus()
/**
* « Aller à » an annotation on the drawing: shows its view, selects it, then focuses the
* properties heading once it has rendered. While a creation or a tracing is in progress
* the request is kept: nothing is dispatched (it would drop the work), the panel or bar
* takes the focus and the live region says why.
*/
export function useAnnotationRequest(
focus: FocusRequest | undefined,
doc: AnatomicalSheetDocument,
drawing: DrawingState,
): void {
const t = useT()
const announce = useContext(AnnounceContext)
const awaiting = useRef<string | null>(null)
useFocusRequest(focus, (target) => {
const found = target.key ? annotationFocus(doc, target.key) : null
if (!found) return 'none'
if (drawing.busy) {
announce(t(`editor.live.${drawing.busy}_kept`))
focusFirst(BUSY_TARGET[drawing.busy])
return 'kept'
}
const same =
drawing.selectedId === found.annotationId &&
drawing.viewId === found.viewId
if (same) focusFirst('[data-properties-heading]')
else {
awaiting.current = found.annotationId
drawing.show(found.viewId, found.annotationId)
}
return 'found'
})
useEffect(() => {
if (awaiting.current === null || drawing.selectedId !== awaiting.current) {
return
}
awaiting.current = null
focusFirst('[data-properties-heading]')
})
}
@@ -0,0 +1,26 @@
import { useMemo } from 'react'
import type { AnatomicalSheetDocument } from '@faunosteo/core-wasm/types'
/**
* What the overview panel counts, read once per parsed document: the annotations of each
* view and the vertebral regions. A display count, no rule: no core call, no network.
*/
export interface OverviewCounts {
annotationsByView: ReadonlyMap<string, number>
regions: number
}
export function overviewCounts(doc: AnatomicalSheetDocument): OverviewCounts {
const annotationsByView = new Map<string, number>()
for (const annotation of doc.annotations) {
const count = annotationsByView.get(annotation.view_id) ?? 0
annotationsByView.set(annotation.view_id, count + 1)
}
return { annotationsByView, regions: doc.vertebral_config.regions.length }
}
export function useOverviewCounts(
doc: AnatomicalSheetDocument,
): OverviewCounts {
return useMemo(() => overviewCounts(doc), [doc])
}