import { useMemo } from 'react' import type { AnatomicalSheetDocument, SheetView, } from '@faunosteo/core-wasm/types' import Input from '@/components/ui/Input' import { groupAnnotations, 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' import AnnotationList, { annotationName } from './AnnotationList' 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 /** Put before every id (the read-only twin beside the kept edit panel). */ idPrefix?: string /** The « Filtrer par nom » term, held by the parent so a selection does not lose it. */ filter: string onFilter: (term: string) => void onSelectView: (viewId: string) => void /** The selection, marked in the list (A3). */ selectedId: string | null onSelectAnnotation: (annotationId: string) => void /** Enter on the selected row: its properties dialog (A1). */ onOpenAnnotation: (annotationId: string) => void onOpenSection: (section: AnnotationSection, opener: HTMLElement) => void } function SectionEntry({ section, label, onOpen, }: { section: AnnotationSection label: string onOpen: OverviewPanelProps['onOpenSection'] }) { return ( ) } 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 (
  • ) } function ViewsCard(props: OverviewPanelProps) { const t = useT() const { doc, viewId, readOnly, onSelectView, onOpenSection } = props const id = `${props.idPrefix ?? ''}overview-views` const counts = useOverviewCounts(doc) return (

    {t('editor.overview.views')}

    ) } function CategoriesCard(props: OverviewPanelProps) { const t = useT() const plural = usePlural() const locale = useLocaleStore((s) => s.locale) const { doc, readOnly, onOpenSection } = props const id = `${props.idPrefix ?? ''}overview-categories` const counts = useOverviewCounts(doc) return (

    {t('editor.overview.categories')} {doc.categories.length}

    {doc.categories.length === 0 && (

    {t('editor.overview.categories_empty')}

    )}
    {/* T17 / BDR-102: no vertebra role exists before U6, so this entry is always shown. */}
    ) } function AnnotationsCard(props: OverviewPanelProps) { const t = useT() const locale = useLocaleStore((s) => s.locale) const { doc, viewId, filter: term, onFilter } = props const prefix = props.idPrefix ?? '' const total = useOverviewCounts(doc).annotationsByView.get(viewId) ?? 0 const groups = useMemo( () => groupAnnotations(doc, viewId, term, (a) => annotationName(a, doc.views, locale), ), [doc, viewId, term, locale], ) return (

    {t('editor.annotations.list')} {total}

    onFilter(event.target.value)} /> {groups.length > 0 ? ( ) : (

    {t( total === 0 ? 'editor.annotations.list_empty' : 'editor.overview.no_match', )}

    )}
    ) } /** Board 01's overview: the views, the categories, then the annotations of the shown view. */ export default function OverviewPanel(props: OverviewPanelProps) { const t = useT() return (
    ) }