Revue à deux axes du 27/10. Spec : les définitions de matrice, pyramide et rhizome ont été écrites par l'agent sans source relue ; elles passent en a_trier (non rendues, bandeau calculé « six concepts ») tant que Jules ne les a pas relues contre le deck ; le test le dit, et le lien architectures invisibles ↔ matrice attend avec elles. Standards : un nœud estompé revient à l'opacité pleine au focus (l'opacité éteignait l'anneau) ; boutons de pas et liens de relation à 44 px ; le résumé d'un texte ne porte plus de tiret long. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179wsewuntMrKBA2s9y7ZeX
610 lines
23 KiB
Vue
610 lines
23 KiB
Vue
<!--
|
|
GrapheConnaissances — B19-M2/M4. Un graphe biparti générique : des nœuds principaux
|
|
(par défaut les concepts) et des nœuds secondaires (les sources : textes, organisations,
|
|
outils), reliés par des liens typés. Écrit pour /connaissances, et pour être repris tel
|
|
quel par la bibliothèque du corpus (B9 réécrit) : il ne connaît ni la vue fiches, ni la
|
|
couche, seulement `noeuds`, `liens`, `selection`, `survol`.
|
|
|
|
La manière de GrapheMots (B6) : SVG rendu au serveur, taille mesurée, nœuds secondaires
|
|
hors tabulation avec <title>, estompage. Rien de sa couronne de sept mots.
|
|
Les gestes repris de l'explorateur Holosapiens (CONSTAT du 12/10, §4), en mieux :
|
|
- clic = recadrage en 600 ms au plus, puis immobile ; aucune dérive perpétuelle ;
|
|
- sœurs estompées, chemin allumé (liens de la sélection), un seul accent safran ;
|
|
- nœuds principaux = <button>, au clavier ; `prefers-reduced-motion` = état final, sans transition ;
|
|
- caméra bornée à la zone libre : le panneau de fiche est une colonne à part (VueFiches),
|
|
la barre de pas et la poignée ont leur marge ; aucun nœud dessous.
|
|
Graphe local (M4) : une sélection restreint le graphe à son voisinage à un ou deux pas
|
|
(bascule « 1 pas / 2 pas / tout »), comme le graphe local d'Obsidian ; sans sélection,
|
|
le graphe entier.
|
|
|
|
Layout : force simple à graine fixe, calculé depuis nœuds et liens (aucune position en
|
|
données), mis en cache par signature du graphe (une fois par processus serveur), puis
|
|
projeté sur la taille mesurée. Liens : trait plein = énoncé par la source, tirets = posé
|
|
par la curation.
|
|
-->
|
|
<template>
|
|
<div ref="racine" class="gc" :class="{ 'gc--fige': fige }">
|
|
<svg class="gc__svg" :viewBox="`0 0 ${taille.w} ${taille.h}`" aria-hidden="true" focusable="false">
|
|
<g class="gc__liens">
|
|
<line
|
|
v-for="l in liensVus"
|
|
:key="l.cle"
|
|
:x1="l.x1" :y1="l.y1" :x2="l.x2" :y2="l.y2"
|
|
class="gc__lien"
|
|
:class="[`gc__lien--${l.provenance}`, { 'gc__lien--vif': l.vif, 'gc__lien--eteint': l.eteint }]"
|
|
/>
|
|
</g>
|
|
<g
|
|
v-for="s in secondairesVus"
|
|
:key="s.id"
|
|
class="gc__source"
|
|
:class="{ 'gc__source--sel': s.sel, 'gc__source--survol': s.survol, 'gc__source--eteint': s.eteint === 'fort', 'gc__source--loin': s.eteint === 'leger' }"
|
|
:transform="`translate(${s.x} ${s.y})`"
|
|
@click="emit('select', s.id)"
|
|
@mouseenter="emit('survol', s.id)"
|
|
@mouseleave="emit('survol', null)"
|
|
>
|
|
<title>{{ s.libelle }}</title>
|
|
<rect x="-6" y="-6" width="12" height="12" rx="2" class="gc__carre" />
|
|
<text v-if="s.etiquette" x="10" y="4" class="gc__source-texte">{{ s.etiquette }}</text>
|
|
</g>
|
|
</svg>
|
|
|
|
<div class="gc__noeuds" role="group" :aria-label="titre">
|
|
<button
|
|
v-for="p in principauxVus"
|
|
:key="p.id"
|
|
type="button"
|
|
class="gc__noeud"
|
|
:class="{ 'gc__noeud--sel': p.sel, 'gc__noeud--survol': p.survol, 'gc__noeud--eteint': p.eteint === 'fort', 'gc__noeud--loin': p.eteint === 'leger' }"
|
|
:style="{ left: `${p.x}px`, top: `${p.y}px`, '--gc-r': `${p.r}px` }"
|
|
:data-id="p.id"
|
|
:aria-label="p.aria"
|
|
:aria-pressed="p.sel ? 'true' : 'false'"
|
|
@click="emit('select', p.id)"
|
|
@mouseenter="emit('survol', p.id)"
|
|
@mouseleave="emit('survol', null)"
|
|
@focus="emit('survol', p.id)"
|
|
@blur="emit('survol', null)"
|
|
>
|
|
<span class="gc__rond" aria-hidden="true" />
|
|
<span class="gc__libelle" aria-hidden="true">{{ p.libelle }}</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div v-if="selVue" class="gc__barre" role="group" aria-label="Voisinage affiché">
|
|
<button
|
|
v-for="o in OPTIONS_PAS"
|
|
:key="o.v"
|
|
type="button"
|
|
class="gc__pas"
|
|
:aria-pressed="pas === o.v ? 'true' : 'false'"
|
|
@click="pas = o.v"
|
|
>{{ o.libelle }}</button>
|
|
</div>
|
|
<p class="gc__legende" aria-hidden="true">
|
|
<span class="gc__legende-trait gc__legende-trait--source" />source
|
|
<span class="gc__legende-trait gc__legende-trait--curation" />curation
|
|
</p>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
/** Un nœud : `kind` dit sa forme (principal si dans `kindsPrincipaux`, sinon secondaire). */
|
|
export interface NoeudGraphe { id: string; libelle: string; kind: string; poids?: number }
|
|
export interface LienGraphe { de: string; vers: string; type: string; provenance: string }
|
|
export type Pas = 1 | 2 | 'tout'
|
|
|
|
type Pt = { x: number; y: number }
|
|
|
|
/** PRNG à graine fixe (mulberry32) : même graphe, même dessin, au serveur comme au navigateur. */
|
|
function alea(graine: number) {
|
|
let a = graine >>> 0
|
|
return () => {
|
|
a = (a + 0x6d2b79f5) >>> 0
|
|
let t = a
|
|
t = Math.imul(t ^ (t >>> 15), t | 1)
|
|
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
|
|
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Force simple (Fruchterman-Reingold), graine fixe, nombre de pas fixe : positions dans un
|
|
* repère sans unité, centré, d'étendue 1. Fonction pure de (nœuds, liens, principaux).
|
|
*/
|
|
export function disposer(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>): Map<string, Pt> {
|
|
const n = noeuds.length
|
|
const pos = new Map<string, Pt>()
|
|
if (!n) return pos
|
|
const rnd = alea(0x9e3779b9)
|
|
const index = new Map(noeuds.map((x, i) => [x.id, i]))
|
|
const aretes = liens
|
|
.map((l) => [index.get(l.de), index.get(l.vers)] as const)
|
|
.filter((a): a is readonly [number, number] => a[0] != null && a[1] != null && a[0] !== a[1])
|
|
const voisins: number[][] = noeuds.map(() => [])
|
|
for (const [a, b] of aretes) { voisins[a].push(b); voisins[b].push(a) }
|
|
|
|
// Départ : les principaux en cercle, chaque secondaire au barycentre de ses voisins principaux.
|
|
const prin = noeuds.map((x, i) => (principaux.has(x.kind) ? i : -1)).filter((i) => i >= 0)
|
|
const X = new Float64Array(n)
|
|
const Y = new Float64Array(n)
|
|
prin.forEach((i, k) => {
|
|
const t = (2 * Math.PI * k) / Math.max(prin.length, 1)
|
|
X[i] = 0.4 * Math.cos(t)
|
|
Y[i] = 0.4 * Math.sin(t)
|
|
})
|
|
noeuds.forEach((x, i) => {
|
|
if (principaux.has(x.kind)) return
|
|
const v = voisins[i].filter((j) => principaux.has(noeuds[j].kind))
|
|
if (v.length) {
|
|
X[i] = (v.reduce((s, j) => s + X[j], 0) / v.length) * 1.35 + (rnd() - 0.5) * 0.08
|
|
Y[i] = (v.reduce((s, j) => s + Y[j], 0) / v.length) * 1.35 + (rnd() - 0.5) * 0.08
|
|
} else {
|
|
X[i] = (rnd() - 0.5) * 0.9
|
|
Y[i] = (rnd() - 0.5) * 0.9
|
|
}
|
|
})
|
|
|
|
const k = 0.9 * Math.sqrt(1 / n)
|
|
const ITER = 350
|
|
const dx = new Float64Array(n)
|
|
const dy = new Float64Array(n)
|
|
for (let it = 0; it < ITER; it++) {
|
|
const temp = 0.08 * (1 - it / ITER) + 0.002
|
|
dx.fill(0)
|
|
dy.fill(0)
|
|
for (let i = 0; i < n; i++) {
|
|
for (let j = i + 1; j < n; j++) {
|
|
let ex = X[i] - X[j]
|
|
let ey = Y[i] - Y[j]
|
|
let d = Math.hypot(ex, ey)
|
|
if (d < 1e-4) { ex = (rnd() - 0.5) * 1e-3; ey = (rnd() - 0.5) * 1e-3; d = Math.hypot(ex, ey) }
|
|
const f = (k * k) / d
|
|
dx[i] += (ex / d) * f; dy[i] += (ey / d) * f
|
|
dx[j] -= (ex / d) * f; dy[j] -= (ey / d) * f
|
|
}
|
|
}
|
|
for (const [a, b] of aretes) {
|
|
const ex = X[a] - X[b]
|
|
const ey = Y[a] - Y[b]
|
|
const d = Math.max(Math.hypot(ex, ey), 1e-4)
|
|
const f = (d * d) / k
|
|
dx[a] -= (ex / d) * f; dy[a] -= (ey / d) * f
|
|
dx[b] += (ex / d) * f; dy[b] += (ey / d) * f
|
|
}
|
|
for (let i = 0; i < n; i++) {
|
|
dx[i] -= X[i] * 0.9 * k * 4
|
|
dy[i] -= Y[i] * 0.9 * k * 4
|
|
const d = Math.hypot(dx[i], dy[i])
|
|
if (d > 0) {
|
|
const m = Math.min(d, temp)
|
|
X[i] += (dx[i] / d) * m
|
|
Y[i] += (dy[i] / d) * m
|
|
}
|
|
}
|
|
}
|
|
|
|
// Centré, étendue 1 (le plus grand côté de la boîte englobante)
|
|
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity
|
|
for (let i = 0; i < n; i++) { x0 = Math.min(x0, X[i]); x1 = Math.max(x1, X[i]); y0 = Math.min(y0, Y[i]); y1 = Math.max(y1, Y[i]) }
|
|
const e = Math.max(x1 - x0, y1 - y0) || 1
|
|
noeuds.forEach((x, i) => pos.set(x.id, { x: (X[i] - (x0 + x1) / 2) / e, y: (Y[i] - (y0 + y1) / 2) / e }))
|
|
return pos
|
|
}
|
|
|
|
/** Cache par signature du graphe : au serveur, une fois par processus, pas une fois par requête. */
|
|
const CACHE = new Map<string, Map<string, Pt>>()
|
|
export function disposerEnCache(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>): Map<string, Pt> {
|
|
const sig = JSON.stringify([noeuds.map((x) => [x.id, x.kind]), liens.map((l) => [l.de, l.vers]), [...principaux]])
|
|
let p = CACHE.get(sig)
|
|
if (!p) {
|
|
p = disposer(noeuds, liens, principaux)
|
|
if (CACHE.size > 24) CACHE.delete(CACHE.keys().next().value as string)
|
|
CACHE.set(sig, p)
|
|
}
|
|
return p
|
|
}
|
|
|
|
/** Identifiants à `pas` liens au plus de `id` (le nœud compris) ; `tout` = tous. */
|
|
export function voisinage(liens: LienGraphe[], id: string, pas: Pas): Set<string> | null {
|
|
if (pas === 'tout') return null
|
|
const adj = new Map<string, string[]>()
|
|
for (const l of liens) {
|
|
if (!adj.has(l.de)) adj.set(l.de, [])
|
|
if (!adj.has(l.vers)) adj.set(l.vers, [])
|
|
adj.get(l.de)!.push(l.vers)
|
|
adj.get(l.vers)!.push(l.de)
|
|
}
|
|
const vus = new Set([id])
|
|
let front = [id]
|
|
for (let p = 0; p < pas; p++) {
|
|
const suite: string[] = []
|
|
for (const x of front) for (const y of adj.get(x) ?? []) if (!vus.has(y)) { vus.add(y); suite.push(y) }
|
|
front = suite
|
|
}
|
|
return vus
|
|
}
|
|
</script>
|
|
|
|
<script setup lang="ts">
|
|
const props = withDefaults(defineProps<{
|
|
noeuds: NoeudGraphe[]
|
|
liens: LienGraphe[]
|
|
selection: string | null
|
|
survol: string | null
|
|
/** Kinds rendus en nœuds principaux (ronds, boutons) ; les autres sont secondaires (carrés). */
|
|
kindsPrincipaux?: string[]
|
|
/** Pas du graphe local à l'ouverture d'une sélection. */
|
|
pasDefaut?: Pas
|
|
/** Nom accessible du groupe de nœuds. */
|
|
titre?: string
|
|
/** Libellé de kind pour les noms accessibles (« concept », « texte »…). */
|
|
libelleKind?: (kind: string) => string
|
|
/** Nœuds du résultat courant (filtres de la page) ; les autres s'estompent sans disparaître. null = tous. */
|
|
retenus?: Set<string> | null
|
|
}>(), {
|
|
kindsPrincipaux: () => ['concept'],
|
|
pasDefaut: 1,
|
|
titre: 'Graphe',
|
|
libelleKind: (k: string) => k,
|
|
retenus: null,
|
|
})
|
|
|
|
const emit = defineEmits<{
|
|
select: [id: string]
|
|
survol: [id: string | null]
|
|
}>()
|
|
|
|
const OPTIONS_PAS: { v: Pas; libelle: string }[] = [
|
|
{ v: 1, libelle: '1 pas' },
|
|
{ v: 2, libelle: '2 pas' },
|
|
{ v: 'tout', libelle: 'tout' },
|
|
]
|
|
const DUREE = 600 // recadrage : ≤ 700 ms, puis immobile
|
|
const MARGE = { haut: 52, bas: 44, gauche: 96, droite: 96 }
|
|
const MARGE_TEL = { haut: 52, bas: 84, gauche: 64, droite: 64 } // < 768 : le pied de la vue fiches couvre le bas ; les libellés sont tenus dans le cadre par la borne de `ecran`
|
|
|
|
// ── Taille mesurée (le rendu serveur part d'une taille plausible, comme GrapheMots) ──
|
|
const racine = ref<HTMLElement | null>(null)
|
|
const taille = reactive({ w: 720, h: 560 })
|
|
const fige = ref(false) // prefers-reduced-motion : état final, sans transition
|
|
let redim = false
|
|
onMounted(() => {
|
|
const mq = window.matchMedia('(prefers-reduced-motion: reduce)')
|
|
fige.value = mq.matches
|
|
const majMq = () => { fige.value = mq.matches }
|
|
mq.addEventListener('change', majMq)
|
|
const el = racine.value
|
|
if (el && typeof ResizeObserver !== 'undefined') {
|
|
const maj = (w: number, h: number, initiale = false) => {
|
|
if (w > 40 && h > 40 && (Math.round(w) !== taille.w || Math.round(h) !== taille.h)) {
|
|
redim = initiale // la première mesure saute ; un redimensionnement (fiche ouverte, fenêtre) se recadre en douceur
|
|
taille.w = Math.round(w)
|
|
taille.h = Math.round(h)
|
|
}
|
|
}
|
|
maj(el.clientWidth, el.clientHeight, true)
|
|
const ro = new ResizeObserver((e) => { const r = e[0]?.contentRect; if (r) maj(r.width, r.height) })
|
|
ro.observe(el)
|
|
onBeforeUnmount(() => ro.disconnect())
|
|
}
|
|
onBeforeUnmount(() => { mq.removeEventListener('change', majMq); if (raf) cancelAnimationFrame(raf) })
|
|
})
|
|
|
|
// ── Layout (repère abstrait, en cache) ──
|
|
const principaux = computed(() => new Set(props.kindsPrincipaux))
|
|
const monde = computed(() => disposerEnCache(props.noeuds, props.liens, principaux.value))
|
|
const ids = computed(() => new Set(props.noeuds.map((x) => x.id)))
|
|
|
|
// ── Sélection et voisinage ──
|
|
const selVue = computed(() => (props.selection && ids.value.has(props.selection) ? props.selection : null))
|
|
const pas = ref<Pas>(props.pasDefaut)
|
|
watch(selVue, (s, avant) => { if (s && !avant) pas.value = props.pasDefaut })
|
|
const visibles = computed<Set<string> | null>(() => (selVue.value ? voisinage(props.liens, selVue.value, pas.value) : null))
|
|
const voisinsSel = computed(() => (selVue.value ? voisinage(props.liens, selVue.value, 1)! : null))
|
|
const voisinsSurvol = computed(() => (props.survol && ids.value.has(props.survol) ? voisinage(props.liens, props.survol, 1)! : null))
|
|
|
|
// ── Caméra : boîte des nœuds visibles → zone libre ──
|
|
interface Camera { cx: number; cy: number; s: number }
|
|
const zone = computed(() => {
|
|
const m = taille.w < 768 ? MARGE_TEL : MARGE
|
|
return { x: m.gauche, y: m.haut, w: Math.max(40, taille.w - m.gauche - m.droite), h: Math.max(40, taille.h - m.haut - m.bas) }
|
|
})
|
|
/** Portrait d'écran et dessin paysage (ou l'inverse) : on tourne le dessin d'un quart. Projection, rien en base. */
|
|
const tourne = computed(() => {
|
|
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity
|
|
for (const p of monde.value.values()) { x0 = Math.min(x0, p.x); x1 = Math.max(x1, p.x); y0 = Math.min(y0, p.y); y1 = Math.max(y1, p.y) }
|
|
const paysage = x1 - x0 >= y1 - y0
|
|
return paysage !== zone.value.w >= zone.value.h
|
|
})
|
|
const pt = (id: string): Pt | null => {
|
|
const p = monde.value.get(id)
|
|
if (!p) return null
|
|
return tourne.value ? { x: p.y, y: -p.x } : p
|
|
}
|
|
|
|
const cible = computed<Camera>(() => {
|
|
const vis = visibles.value
|
|
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity
|
|
for (const x of props.noeuds) {
|
|
if (vis && !vis.has(x.id)) continue
|
|
const p = pt(x.id)
|
|
if (!p) continue
|
|
x0 = Math.min(x0, p.x); x1 = Math.max(x1, p.x); y0 = Math.min(y0, p.y); y1 = Math.max(y1, p.y)
|
|
}
|
|
if (!Number.isFinite(x0)) return { cx: 0, cy: 0, s: 1 }
|
|
const z = zone.value
|
|
const plein = Math.min(z.w, z.h) // échelle du graphe entier (étendue 1)
|
|
const s = Math.min(z.w / Math.max(x1 - x0, 1e-3), z.h / Math.max(y1 - y0, 1e-3), plein * 2.4)
|
|
return { cx: (x0 + x1) / 2, cy: (y0 + y1) / 2, s }
|
|
})
|
|
|
|
const camera = reactive<Camera>({ ...cible.value })
|
|
let raf = 0
|
|
watch(cible, (c) => {
|
|
if (raf) { cancelAnimationFrame(raf); raf = 0 }
|
|
if (!import.meta.client || fige.value || redim) {
|
|
redim = false
|
|
Object.assign(camera, c)
|
|
return
|
|
}
|
|
const de = { ...camera }
|
|
const t0 = performance.now()
|
|
const pasAnim = (t: number) => {
|
|
const u = Math.min(1, (t - t0) / DUREE)
|
|
const e = 1 - Math.pow(1 - u, 3)
|
|
camera.cx = de.cx + (c.cx - de.cx) * e
|
|
camera.cy = de.cy + (c.cy - de.cy) * e
|
|
camera.s = de.s + (c.s - de.s) * e
|
|
raf = u < 1 ? requestAnimationFrame(pasAnim) : 0
|
|
}
|
|
raf = requestAnimationFrame(pasAnim)
|
|
})
|
|
|
|
/** Bord à garder libre autour du centre d'un nœud : la demi-largeur maximale d'un libellé (9,5 rem) pour un principal. */
|
|
const BORD_PRINCIPAL = 80 // 64 sous 768 px, où le libellé passe à 8 rem
|
|
const BORD_SECONDAIRE = 12
|
|
const kindDe = computed(() => new Map(props.noeuds.map((x) => [x.id, x.kind])))
|
|
const ecran = (id: string): Pt | null => {
|
|
const p = pt(id)
|
|
if (!p) return null
|
|
const z = zone.value
|
|
const x = (p.x - camera.cx) * camera.s + z.x + z.w / 2
|
|
// Garde-fou : aucun libellé ne sort du cadre, même en pleine animation ou sur une colonne étroite.
|
|
const b = principaux.value.has(kindDe.value.get(id) ?? '') ? (taille.w < 768 ? 64 : BORD_PRINCIPAL) : BORD_SECONDAIRE
|
|
const xBorne = taille.w > 2 * b ? Math.min(taille.w - b, Math.max(b, x)) : x
|
|
return {
|
|
x: Math.round(xBorne * 10) / 10,
|
|
y: Math.round(((p.y - camera.cy) * camera.s + z.y + z.h / 2) * 10) / 10,
|
|
}
|
|
}
|
|
|
|
// ── Ce qui se dessine ──
|
|
const estPrincipal = (kind: string) => principaux.value.has(kind)
|
|
const vu = (id: string) => !visibles.value || visibles.value.has(id)
|
|
/**
|
|
* Estompé : hors du voisinage immédiat de la sélection. En « tout », les sœurs s'éteignent
|
|
* franchement ; en graphe local à deux pas, le second cercle reste lisible, un ton en dessous.
|
|
*/
|
|
const eteint = (id: string): 'fort' | 'leger' | null => {
|
|
if (!voisinsSel.value) return props.retenus && !props.retenus.has(id) ? 'fort' : null
|
|
if (voisinsSel.value.has(id) || voisinsSurvol.value?.has(id)) return null
|
|
return pas.value === 'tout' ? 'fort' : 'leger'
|
|
}
|
|
const degre = computed(() => {
|
|
const d = new Map<string, number>()
|
|
for (const l of props.liens) for (const id of [l.de, l.vers]) d.set(id, (d.get(id) ?? 0) + 1)
|
|
return d
|
|
})
|
|
const tronquer = (t: string, max = 30) => (t.length > max ? `${t.slice(0, max - 1).trimEnd()}…` : t)
|
|
|
|
const principauxVus = computed(() => props.noeuds
|
|
.filter((x) => estPrincipal(x.kind) && vu(x.id))
|
|
.map((x) => {
|
|
const p = ecran(x.id)!
|
|
const n = degre.value.get(x.id) ?? 0
|
|
return {
|
|
id: x.id,
|
|
libelle: x.libelle,
|
|
x: p.x,
|
|
y: p.y,
|
|
r: 7 + Math.min(x.poids ?? n, 6),
|
|
sel: x.id === selVue.value,
|
|
survol: x.id === props.survol,
|
|
eteint: eteint(x.id),
|
|
aria: `${x.libelle}, ${props.libelleKind(x.kind)}, ${n} ${n > 1 ? 'liens' : 'lien'}`,
|
|
}
|
|
}))
|
|
|
|
const secondairesVus = computed(() => props.noeuds
|
|
.filter((x) => !estPrincipal(x.kind) && vu(x.id))
|
|
.map((x) => {
|
|
const p = ecran(x.id)!
|
|
const enVue = !!visibles.value || !!voisinsSel.value?.has(x.id) || !!voisinsSurvol.value?.has(x.id) || x.id === props.survol
|
|
return {
|
|
id: x.id,
|
|
libelle: x.libelle,
|
|
etiquette: enVue ? tronquer(x.libelle) : '',
|
|
x: p.x,
|
|
y: p.y,
|
|
sel: x.id === selVue.value,
|
|
survol: x.id === props.survol,
|
|
eteint: eteint(x.id),
|
|
}
|
|
}))
|
|
|
|
const liensVus = computed(() => props.liens
|
|
.filter((l) => vu(l.de) && vu(l.vers))
|
|
.map((l, i) => {
|
|
const a = ecran(l.de)
|
|
const b = ecran(l.vers)
|
|
if (!a || !b) return null
|
|
const sel = selVue.value
|
|
const sv = props.survol
|
|
const vif = (!!sel && (l.de === sel || l.vers === sel)) || (!!sv && (l.de === sv || l.vers === sv))
|
|
return {
|
|
cle: `${l.de}>${l.vers}>${l.type}>${i}`,
|
|
x1: a.x, y1: a.y, x2: b.x, y2: b.y,
|
|
provenance: l.provenance === 'curation' ? 'curation' : 'source',
|
|
vif,
|
|
eteint: !!sel && !vif && pas.value === 'tout',
|
|
}
|
|
})
|
|
.filter((l): l is NonNullable<typeof l> => !!l))
|
|
</script>
|
|
|
|
<style scoped>
|
|
.gc {
|
|
position: relative;
|
|
flex: 1;
|
|
min-height: 0;
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
background: var(--bg-alt);
|
|
color: var(--text);
|
|
}
|
|
.gc__svg {
|
|
position: absolute;
|
|
inset: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
display: block;
|
|
font-family: inherit;
|
|
}
|
|
|
|
/* Liens : encre fine ; tirets = posé par la curation */
|
|
.gc__lien {
|
|
stroke: color-mix(in srgb, var(--text) 38%, transparent);
|
|
stroke-width: 1.1;
|
|
transition: stroke 160ms ease-out, stroke-width 160ms ease-out, opacity 160ms ease-out;
|
|
}
|
|
.gc__lien--curation { stroke-dasharray: 4 3; }
|
|
.gc__lien--vif { stroke: var(--text); stroke-width: 1.8; }
|
|
.gc__lien--eteint { opacity: 0.25; }
|
|
|
|
/* Sources : carrés gris, hors tabulation (au clavier, on y va par la liste des fiches) */
|
|
.gc__source { cursor: pointer; transition: opacity 160ms ease-out; }
|
|
.gc__carre {
|
|
fill: color-mix(in srgb, var(--text) 52%, var(--bg-alt));
|
|
stroke: var(--bg-alt);
|
|
stroke-width: 1.5;
|
|
}
|
|
.gc__source--survol .gc__carre { fill: var(--text); }
|
|
.gc__source--sel .gc__carre { fill: var(--accent); stroke: var(--text); }
|
|
.gc__source--eteint { opacity: 0.28; }
|
|
.gc__source--loin { opacity: 0.6; }
|
|
.gc__source-texte {
|
|
fill: color-mix(in srgb, var(--text) 80%, transparent);
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
paint-order: stroke;
|
|
stroke: var(--bg-alt);
|
|
stroke-width: 3px;
|
|
stroke-linejoin: round;
|
|
pointer-events: none;
|
|
}
|
|
|
|
/* Concepts : boutons HTML posés sur le dessin */
|
|
.gc__noeuds { position: absolute; inset: 0; pointer-events: none; }
|
|
.gc__noeud {
|
|
position: absolute;
|
|
transform: translate(-50%, calc(-1 * var(--gc-r)));
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 3px;
|
|
max-width: 9.5rem;
|
|
padding: 0 2px 2px;
|
|
border: none;
|
|
border-radius: var(--radius-sm);
|
|
background: none;
|
|
color: var(--text);
|
|
font: inherit;
|
|
cursor: pointer;
|
|
pointer-events: auto;
|
|
transition: opacity 160ms ease-out;
|
|
}
|
|
.gc__rond {
|
|
width: calc(2 * var(--gc-r));
|
|
height: calc(2 * var(--gc-r));
|
|
border-radius: 50%;
|
|
background: var(--surface);
|
|
border: 2px solid var(--text);
|
|
transition: background 160ms ease-out, border-color 160ms ease-out;
|
|
}
|
|
.gc__libelle {
|
|
font-size: 12.5px;
|
|
font-weight: 600;
|
|
line-height: 1.2;
|
|
text-align: center;
|
|
overflow-wrap: anywhere;
|
|
padding: 0 3px;
|
|
border-radius: 4px;
|
|
background: color-mix(in srgb, var(--bg-alt) 82%, transparent);
|
|
}
|
|
.gc__noeud--survol .gc__rond { border-width: 3px; }
|
|
.gc__noeud--sel .gc__rond { background: var(--accent); border-color: var(--text); }
|
|
.gc__noeud--sel .gc__libelle { background: var(--accent); color: var(--on-accent); }
|
|
.gc__noeud--eteint { opacity: 0.32; }
|
|
.gc__noeud--loin { opacity: 0.62; }
|
|
/* L'opacité éteindrait l'anneau de focus (DESIGN-SYSTEM §Texte atténué) : un nœud focalisé revient à l'opacité pleine. */
|
|
.gc__noeud--eteint:focus-visible, .gc__noeud--loin:focus-visible { opacity: 1; }
|
|
.gc__noeud:focus { outline: none; }
|
|
.gc__noeud:focus-visible .gc__rond { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
|
|
.gc__noeud:focus-visible .gc__libelle { outline: 2px solid var(--focus-ring); }
|
|
|
|
/* Barre du graphe local (en haut à gauche, hors de la poignée de la vue fiches) */
|
|
.gc__barre {
|
|
position: absolute;
|
|
top: var(--space-xs);
|
|
left: 32px;
|
|
display: inline-flex;
|
|
padding: 2px;
|
|
border-radius: var(--radius-md);
|
|
background: var(--surface);
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
.gc__pas {
|
|
min-height: 44px;
|
|
min-width: 44px;
|
|
padding: 0 var(--space-sm);
|
|
border: none;
|
|
border-radius: calc(var(--radius-md) - 2px);
|
|
background: none;
|
|
color: var(--text);
|
|
font: inherit;
|
|
font-size: var(--fs-sm);
|
|
font-weight: var(--fw-medium);
|
|
cursor: pointer;
|
|
}
|
|
.gc__pas[aria-pressed='true'] { background: var(--text); color: var(--surface); }
|
|
.gc__pas:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
|
|
|
|
.gc__legende {
|
|
position: absolute;
|
|
top: var(--space-xs);
|
|
right: var(--space-sm);
|
|
margin: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 11px;
|
|
color: color-mix(in srgb, var(--text) 78%, transparent);
|
|
pointer-events: none;
|
|
}
|
|
.gc__legende-trait { display: inline-block; width: 18px; border-top: 1.5px solid currentColor; margin-left: 6px; }
|
|
.gc__legende-trait--curation { border-top-style: dashed; }
|
|
@media (max-width: 639.98px) { .gc__legende { display: none; } }
|
|
@media (max-width: 767.98px) {
|
|
.gc__noeud { max-width: 8rem; }
|
|
.gc__libelle { font-size: 12px; }
|
|
}
|
|
|
|
/* Mouvement réduit : état final, sans transition (la caméra saute aussi, côté script) */
|
|
.gc--fige .gc__lien, .gc--fige .gc__source, .gc--fige .gc__noeud, .gc--fige .gc__rond { transition: none; }
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.gc__lien, .gc__source, .gc__noeud, .gc__rond { transition: none; }
|
|
}
|
|
</style>
|