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.
58 lines
2.3 KiB
TypeScript
58 lines
2.3 KiB
TypeScript
import type { PreviewState } from '@faunosteo/core-wasm/types'
|
|
import type { EditorTarget, FocusRequest } from './navigation'
|
|
import { unmeasuredViews } from './issues'
|
|
import type { TabTier } from './useViewport'
|
|
|
|
export const EDITOR_TABS = [
|
|
'general',
|
|
'annotations',
|
|
'findings',
|
|
'verification',
|
|
] as const
|
|
export type EditorTabId = (typeof EDITOR_TABS)[number]
|
|
|
|
/** Board 05: the tabs shown beside « Plus » at each width; the rest sit under « Plus ». */
|
|
const SHOWN: Record<TabTier, readonly EditorTabId[]> = {
|
|
wide: EDITOR_TABS,
|
|
medium: EDITOR_TABS,
|
|
small: ['annotations', 'verification'],
|
|
}
|
|
|
|
export function tabsFor(tier: TabTier): {
|
|
shown: readonly EditorTabId[]
|
|
more: readonly EditorTabId[]
|
|
} {
|
|
const shown = SHOWN[tier]
|
|
return { shown, more: EDITOR_TABS.filter((tab) => !shown.includes(tab)) }
|
|
}
|
|
|
|
/**
|
|
* The tab a version opens on: Annotations once a view can be annotated, Général while
|
|
* there is nothing to annotate yet. A tier that does not list Général keeps Annotations.
|
|
*/
|
|
export function initialTab(state: PreviewState, tier: TabTier): EditorTabId {
|
|
const unmeasured = unmeasuredViews(state)
|
|
const measurable = state.document.views.some((v) => !unmeasured.has(v.id))
|
|
const wanted = measurable ? 'annotations' : 'general'
|
|
return SHOWN[tier].includes(wanted) ? wanted : 'annotations'
|
|
}
|
|
|
|
/** Props of every place (tab body, Annotations section, references panel). */
|
|
export interface EditorPlaceProps {
|
|
/** Not editable now: a mode that cannot save, or a recovery offer not answered yet. */
|
|
readOnly: boolean
|
|
/** « Aller à … » and any link between places; `opener` takes the focus back on return. */
|
|
navigate: (target: EditorTarget, opener?: HTMLElement | null) => void
|
|
/** « Aller à … » with an element: the place seeds its own selection from it once. */
|
|
focus?: FocusRequest
|
|
/** Reads the sheet's overview again (after a submission: the round freezes the draft). */
|
|
reloadSheet: () => void
|
|
}
|
|
|
|
export const tabDomId = (tab: EditorTabId) => `editor-tab-${tab}`
|
|
export const panelDomId = (tab: EditorTabId) => `editor-panel-${tab}`
|
|
/** The « Plus » disclosure button, focused when the active tab sits under it. */
|
|
export const MORE_BUTTON_ID = 'editor-tabs-more-button'
|
|
/** The header button that toggles the references panel. */
|
|
export const REFERENCES_BUTTON_ID = 'editor-references-button'
|