@seanyeh77/ui 0.48.2 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +20 -20
- package/dist/components/FloorPlan/FloorPlan.d.ts +65 -0
- package/dist/components/FloorPlan/FloorPlan.js +822 -0
- package/dist/components/FloorPlan/FloorPlan.js.map +1 -0
- package/dist/components/InlineCode/InlineCode.js +41 -9
- package/dist/components/InlineCode/InlineCode.js.map +1 -1
- package/dist/components/LayerGraph/LayerGraph.js +19 -6
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
- package/dist/components/ZoneMap/ZoneMap.d.ts +3 -0
- package/dist/components/ZoneMap/ZoneMap.js +6 -20
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
- package/dist/css/DataTable.css +1 -1
- package/dist/css/FloorPlan.css +270 -0
- package/dist/css/InlineCode.css +23 -0
- package/dist/css/ZoneMap.css +0 -97
- package/dist/css/base.css +99 -0
- package/dist/i18n.js +6 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/util.js +19 -1
- package/dist/internal/util.js.map +1 -1
- package/dist/internal/zone.js +48 -0
- package/dist/internal/zone.js.map +1 -0
- package/dist/styles.css +440 -151
- package/docs/DataColors.md +1 -1
- package/docs/FloorPlan.md +43 -0
- package/docs/InlineCode.md +1 -1
- package/docs/ZoneMap.md +2 -2
- package/docs/agents.md +5 -5
- package/docs/components.json +4 -0
- package/docs/data.md +2 -1
- package/docs/monitoring.md +7 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloorPlan.js","names":["phPlus","phMinus","phCornersOut"],"sources":["../../../src/components/FloorPlan/FloorPlan.tsx"],"sourcesContent":["import * as React from 'react';\nimport { devWarn } from '../../internal/dev';\nimport { cx, reduced, resizeObserver, useMedia, useNarrow } from '../../internal/util';\nimport { heatRange, noData, zoneText } from '../../internal/zone';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\nimport phCornersOut from '../../icons/ph/corners-out';\nimport phMinus from '../../icons/ph/minus';\nimport phPlus from '../../icons/ph/plus';\nimport { includeIcons } from '../../icons/store';\nimport { IconButton } from '../IconButton/IconButton';\nimport type { Zone } from '../ZoneMap/ZoneMap';\n\nincludeIcons(phPlus, phMinus, phCornersOut);\n\n/** A MultiPolygon in metres: [polygon][ring][point][x, y]. The first ring of a polygon is its outline, the others are\n * holes (even-odd). y points north (up). */\nexport type MultiPolygon = number[][][][];\n\nexport interface FloorPlanZone extends Omit<Zone, 'area'> {\n /** The zone's outline, a MultiPolygon in metres (y up): several polygons for a zone in pieces, inner rings for holes. */\n outline: MultiPolygon;\n /** Where its label sits, [x, y] in metres, worked out by the caller (e.g. the pole of inaccessibility). */\n label: [number, number];\n /** 'muted': a secondary zone, drawn fainter with a smaller label; still selectable, and 「⚠」 still shows. Default\n * 'primary'. */\n emphasis?: 'primary' | 'muted';\n /** The id of the group it belongs to (`groups`). */\n group?: string;\n}\n\nexport interface FloorPlanGroup {\n /** Unique id, named by the zones' `group`. */\n id: string;\n /** Shown on its outline, e.g. 「北側機櫃列」. */\n name: string;\n}\n\nexport interface FloorPlanEdge {\n /** The id of the zone on one side. */\n a: string;\n /** The id of the zone on the other side. */\n b: string;\n /** The boundary as polylines in metres: [line][point][x, y]. */\n segs: [number, number][][];\n}\n\nexport interface FloorPlanProps {\n /** The zones. Tab moves through primary zones before muted ones, each from the smallest area up. */\n zones: FloorPlanZone[];\n /** What the plan shows, for screen readers, e.g. 「機房平面圖」. */\n label: string;\n /** Groups of zones: each gets a thin outline around its zones and its name. No group figures are worked out. */\n groups?: FloorPlanGroup[];\n /** The building's outline, drawn under the zones (a MultiPolygon in metres, y up). */\n shell?: MultiPolygon;\n /** Boundaries between zones, drawn as dashed lines. */\n edges?: FloorPlanEdge[];\n /** Bottom of the heat scale for zones without a fill. Default: the smallest value among the zones. */\n min?: number;\n /** Top of the heat scale for zones without a fill. Default: the largest value among the zones. */\n max?: number;\n /** The watch line on the legend's scale, in the zones' unit (from the caller; nothing is assumed). */\n warn?: number;\n /** The limit mark on the legend's scale, in the zones' unit. */\n limit?: number;\n /** false: no legend under the plan. Default true. */\n legend?: boolean;\n /** The selected zone's id (controlled); null for none. */\n value?: string | null;\n /** A zone was picked (click, tap, Enter or Space): its id, and the zone. */\n onChange?: (id: string, zone: FloorPlanZone) => void;\n /** The plan grows to fill the height it is given (in ConsoleLayout's main view, or any flex column), never below\n * 240 px. Without it the plan keeps the outline's proportions, 240 to 640 px high. */\n fill?: boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/* ---------- Geometry (exported for tests) ---------- */\n\n/** One ring as SVG path data, y flipped (north up on screen). */\nexport function ringPath(ring: number[][]): string {\n return ring.length ? 'M' + ring.map(([x, y]) => fmt(x) + ' ' + fmt(-y)).join('L') + 'Z' : '';\n}\nconst fmt = (n: number) => String(Math.round(n * 1000) / 1000);\n\n/** A MultiPolygon as one SVG path; drawn with fill-rule evenodd, inner rings are holes. */\nexport function polygonPath(mp: MultiPolygon): string {\n return mp.map((poly) => poly.map(ringPath).join('')).join('');\n}\n\nexport interface Box {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/** The viewBox (in flipped coordinates: y down) holding every zone and the shell, with a margin of 4 % of the longer\n * side on each edge. */\nexport function planBox(shapes: MultiPolygon[]): Box {\n let [x0, y0, x1, y1] = [Infinity, Infinity, -Infinity, -Infinity];\n for (const mp of shapes)\n for (const poly of mp)\n for (const ring of poly)\n for (const [x, y] of ring) {\n x0 = Math.min(x0, x);\n x1 = Math.max(x1, x);\n y0 = Math.min(y0, -y);\n y1 = Math.max(y1, -y);\n }\n if (!Number.isFinite(x0)) return { x: 0, y: 0, w: 1, h: 1 };\n const w = Math.max(x1 - x0, 1e-6);\n const h = Math.max(y1 - y0, 1e-6);\n const m = Math.max(w, h) * 0.04;\n return { x: x0 - m, y: y0 - m, w: w + 2 * m, h: h + 2 * m };\n}\n\n/** The area in m²: outlines minus holes. */\nexport function polygonArea(mp: MultiPolygon): number {\n let total = 0;\n for (const poly of mp)\n poly.forEach((ring, i) => {\n let a = 0;\n for (let k = 0; k < ring.length; k++) {\n const [xa, ya] = ring[k];\n const [xb, yb] = ring[(k + 1) % ring.length];\n a += xa * yb - xb * ya;\n }\n total += (i === 0 ? 1 : -1) * Math.abs(a / 2);\n });\n return total;\n}\n\n/** Whether [x, y] (metres, y up) is inside, by the even-odd rule over every ring. */\nexport function insidePolygon(x: number, y: number, mp: MultiPolygon): boolean {\n let inside = false;\n for (const poly of mp)\n for (const ring of poly)\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const [xi, yi] = ring[i];\n const [xj, yj] = ring[j];\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;\n }\n return inside;\n}\n\nfunction bounds(mp: MultiPolygon) {\n return planBox([mp]);\n}\n\n/** Primary zones first, then muted ones; each from the smallest area up. The Tab order, and the order labels are\n * given room in. */\nexport function zoneOrder<T extends Pick<FloorPlanZone, 'outline' | 'emphasis'>>(zones: readonly T[]): T[] {\n const area = new Map(zones.map((z) => [z, polygonArea(z.outline)]));\n return [...zones].sort((a, b) => Number(a.emphasis === 'muted') - Number(b.emphasis === 'muted') || (area.get(a) ?? 0) - (area.get(b) ?? 0));\n}\n\n/** The screen transform for a viewBox shown in W × H px (preserveAspectRatio xMidYMid meet): px per metre, and the\n * screen point of a point in metres (y up). */\nexport function screenOf(view: Box, W: number, H: number) {\n const s = Math.min(W / view.w, H / view.h);\n const ox = (W - view.w * s) / 2 - view.x * s;\n const oy = (H - view.h * s) / 2 - view.y * s;\n return {\n s,\n at: (x: number, y: number): [number, number] => [x * s + ox, -y * s + oy],\n back: (px: number, py: number): [number, number] => [(px - ox) / s, -(py - oy) / s],\n };\n}\n\n/** Width in px of text at a font size: a fixed estimate (CJK 1 em, Geist Mono 0.6 em, other Latin 0.58 em), so\n * labels are laid out the same before and after web fonts load, on the server and in tests. */\nexport function textWidth(text: string, size: number, mono = false): number {\n let w = 0;\n for (const ch of text) {\n const c = ch.codePointAt(0) ?? 0;\n w += c >= 0x2e80 ? 1 : ch === ' ' || ch === ' ' ? 0.3 : mono ? 0.6 : /[A-Z0-9]/.test(ch) ? 0.64 : 0.54;\n }\n return Math.ceil(w * size);\n}\n\nexport type LabelKind = 'full' | 'pill' | null;\nexport interface LabelSpot {\n kind: LabelKind;\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\ninterface LabelInput {\n id: string;\n outline: MultiPolygon;\n label: [number, number];\n muted: boolean;\n slender: boolean;\n full: [number, number];\n pill: [number, number];\n}\n\n/** Places labels in the given order (zoneOrder): the full label where it fits inside the zone's outline and clear of\n * labels already placed, else the one-line pill where it is clear, else none (the zone still shows its tooltip).\n * Slender zones (bounding box over 4 : 1) get the pill only. `taken` holds boxes already in use (group names). */\nexport function placeLabels(items: readonly LabelInput[], view: Box, W: number, H: number, taken: Box[] = []): Map<string, LabelSpot> {\n const { at, back } = screenOf(view, W, H);\n const out = new Map<string, LabelSpot>();\n const used = [...taken];\n const clear = (b: Box) =>\n b.x >= 0 &&\n b.y >= 0 &&\n b.x + b.w <= W &&\n b.y + b.h <= H &&\n used.every((u) => b.x + b.w + 2 <= u.x || u.x + u.w + 2 <= b.x || b.y + b.h + 2 <= u.y || u.y + u.h + 2 <= b.y);\n for (const it of items) {\n const [cx, cy] = at(it.label[0], it.label[1]);\n const box = ([w, h]: [number, number]): Box => ({ x: cx - w / 2, y: cy - h / 2, w, h });\n let spot: LabelSpot = { kind: null, x: cx, y: cy, w: 0, h: 0 };\n if (!it.slender) {\n const b = box(it.full);\n const probes: [number, number][] = [\n [b.x, b.y],\n [b.x + b.w, b.y],\n [b.x, b.y + b.h],\n [b.x + b.w, b.y + b.h],\n [cx, b.y],\n [cx, b.y + b.h],\n [b.x, cy],\n [b.x + b.w, cy],\n ];\n if (probes.every(([px, py]) => insidePolygon(...back(px, py), it.outline)) && clear(b)) spot = { kind: 'full', ...b };\n }\n if (!spot.kind) {\n const b = box(it.pill);\n if (clear(b)) spot = { kind: 'pill', ...b };\n }\n if (spot.kind) used.push(spot);\n out.set(it.id, spot);\n }\n return out;\n}\n\n/* ---------- Component ---------- */\n\nconst MIN_H = 240;\nconst MAX_H = 640;\nconst MAX_ZOOM = 8;\n\n/** A floor plan of zones with any outline (L shapes, pieces, holes), each filled by its value on the heat scale with\n * its name, figure and state. Zones are buttons in Tab order (primary first, smaller first); Enter or Space selects.\n * Wheel, pinch, drag, + − and the arrow keys zoom and pan; 「重設視角」 shows the whole plan again. */\nexport function FloorPlan({ zones, label, groups = [], shell, edges = [], legend = true, fill = false, className, ...p }: FloorPlanProps) {\n const id = 'fp' + React.useId().replace(/[^a-zA-Z0-9]/g, '');\n const ids = React.useMemo(() => new Map(zones.map((z) => [z.id, z])), [zones]);\n devWarn(ids.size !== zones.length, 'FloorPlan', 'two zones share an id: give each zone its own id, value and onChange use it.');\n devWarn(\n () => edges.some((e) => !ids.has(e.a) || !ids.has(e.b)),\n 'FloorPlan',\n () =>\n `an edge names a zone that is not in zones (${edges\n .filter((e) => !ids.has(e.a) || !ids.has(e.b))\n .map((e) => e.a + '–' + e.b)\n .join(', ')}).`,\n );\n devWarn(\n () => zones.some((z) => !insidePolygon(z.label[0], z.label[1], z.outline)),\n 'FloorPlan',\n () =>\n `the label point of ${zones\n .filter((z) => !insidePolygon(z.label[0], z.label[1], z.outline))\n .map((z) => z.id)\n .join(', ')} is outside its outline: pass a point inside (e.g. the pole of inaccessibility).`,\n );\n\n const [min, max] = heatRange(zones, p.min, p.max);\n const base = React.useMemo(() => planBox([...zones.map((z) => z.outline), ...(shell ? [shell] : [])]), [zones, shell]);\n const order = React.useMemo(() => zoneOrder(zones), [zones]);\n const paths = React.useMemo(() => new Map(zones.map((z) => [z.id, polygonPath(z.outline)])), [zones]);\n\n // Size of the drawing in px, measured; a first guess for the server and the first render.\n const box = React.useRef<HTMLDivElement>(null);\n const [size, setSize] = React.useState<[number, number]>(() => [800, Math.max(MIN_H, Math.min(MAX_H, (800 * base.h) / base.w))]);\n React.useLayoutEffect(() => {\n const el = box.current;\n if (!el) return;\n const measure = () => {\n const r = el.getBoundingClientRect();\n if (r.width > 0 && r.height > 0) setSize((s) => (Math.abs(s[0] - r.width) < 0.5 && Math.abs(s[1] - r.height) < 0.5 ? s : [r.width, r.height]));\n };\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const [W, H] = size;\n\n // The view: a viewBox inside (or around) the whole plan. Zoom is base.w / view.w, from 1 to MAX_ZOOM.\n // Kept with the plan it was made for: a new outline shows the whole plan again.\n const baseKey = `${base.x},${base.y},${base.w},${base.h}`;\n const [viewState, setViewState] = React.useState<{ key: string; view: Box }>({ key: baseKey, view: base });\n const view = viewState.key === baseKey ? viewState.view : base;\n const setView = React.useCallback((v: Box) => setViewState({ key: baseKey, view: v }), [baseKey]);\n const clampView = React.useCallback(\n (v: Box): Box => {\n // The whole plan: nothing to pan.\n if (v.w >= base.w * 0.999) return base;\n const w = Math.max(base.w / MAX_ZOOM, v.w);\n const h = (w * base.h) / base.w;\n const cx = Math.min(base.x + base.w, Math.max(base.x, v.x + v.w / 2));\n const cy = Math.min(base.y + base.h, Math.max(base.y, v.y + v.h / 2));\n return { x: cx - w / 2, y: cy - h / 2, w, h };\n },\n [base],\n );\n const viewRef = React.useRef(view);\n React.useLayoutEffect(() => {\n viewRef.current = view;\n });\n const anim = React.useRef(0);\n const goTo = React.useCallback(\n (to: Box, animate: boolean) => {\n cancelAnimationFrame(anim.current);\n const target = clampView(to);\n if (!animate || reduced() || typeof requestAnimationFrame !== 'function') return setView(target);\n const from = viewRef.current;\n const t0 = performance.now();\n const step = (now: number) => {\n const t = Math.min(1, (now - t0) / 200);\n const e = 1 - (1 - t) ** 3;\n if (t >= 1) return setView(target);\n setView({\n x: from.x + (target.x - from.x) * e,\n y: from.y + (target.y - from.y) * e,\n w: from.w + (target.w - from.w) * e,\n h: from.h + (target.h - from.h) * e,\n });\n anim.current = requestAnimationFrame(step);\n };\n anim.current = requestAnimationFrame(step);\n },\n [clampView, setView],\n );\n React.useEffect(() => () => cancelAnimationFrame(anim.current), []);\n /** Zoom by factor around a screen point (px in the drawing); default its middle. */\n const zoomAt = React.useCallback(\n (factor: number, px = W / 2, py = H / 2, animate = false) => {\n const v = viewRef.current;\n const { back } = screenOf(v, W, H);\n const [mx, my] = back(px, py);\n const fy = -my;\n const w = v.w / factor;\n const h = v.h / factor;\n goTo({ x: mx - ((mx - v.x) / v.w) * w, y: fy - ((fy - v.y) / v.h) * h, w, h }, animate);\n },\n [W, H, goTo],\n );\n const zoomed = Math.abs(view.w - base.w) > base.w * 1e-3 || Math.abs(view.x - base.x) > base.w * 1e-3 || Math.abs(view.y - base.y) > base.h * 1e-3;\n\n const svg = React.useRef<SVGSVGElement>(null);\n // The wheel zooms (a non-passive listener, so the page does not scroll under the plan).\n React.useEffect(() => {\n const el = svg.current;\n if (!el) return;\n const onWheel = (e: WheelEvent) => {\n e.preventDefault();\n const r = el.getBoundingClientRect();\n zoomAt(Math.exp(-e.deltaY * (e.deltaMode === 1 ? 0.05 : 0.0015)), e.clientX - r.left, e.clientY - r.top);\n };\n el.addEventListener('wheel', onWheel, { passive: false });\n return () => el.removeEventListener('wheel', onWheel);\n }, [zoomAt]);\n\n // Drag pans, two fingers pinch. A press that moved more than 4 px is not a click.\n const pointers = React.useRef(new Map<number, [number, number]>());\n const gesture = React.useRef<{ moved: boolean; start: [number, number]; dist?: number }>({ moved: false, start: [0, 0] });\n const local = (e: React.PointerEvent): [number, number] => {\n const r = svg.current?.getBoundingClientRect();\n return r ? [e.clientX - r.left, e.clientY - r.top] : [0, 0];\n };\n const onPointerDown = (e: React.PointerEvent) => {\n if (e.button !== 0) return;\n pointers.current.set(e.pointerId, local(e));\n if (pointers.current.size === 1) gesture.current = { moved: false, start: local(e) };\n else gesture.current.dist = undefined;\n };\n const onPointerMove = (e: React.PointerEvent) => {\n const prev = pointers.current.get(e.pointerId);\n if (!prev) return;\n const now = local(e);\n const g = gesture.current;\n if (!g.moved && Math.hypot(now[0] - g.start[0], now[1] - g.start[1]) > 4) {\n g.moved = true;\n if (typeof svg.current?.setPointerCapture === 'function') for (const pid of pointers.current.keys()) svg.current.setPointerCapture(pid);\n }\n if (!g.moved) {\n pointers.current.set(e.pointerId, now);\n return;\n }\n const v = viewRef.current;\n const s = Math.min(W / v.w, H / v.h);\n if (pointers.current.size === 1) goTo({ ...v, x: v.x - (now[0] - prev[0]) / s, y: v.y - (now[1] - prev[1]) / s }, false);\n pointers.current.set(e.pointerId, now);\n if (pointers.current.size === 2) {\n const [a, b] = [...pointers.current.values()];\n const d = Math.hypot(a[0] - b[0], a[1] - b[1]);\n if (g.dist) zoomAt(d / g.dist, (a[0] + b[0]) / 2, (a[1] + b[1]) / 2);\n g.dist = d;\n }\n };\n const onPointerUp = (e: React.PointerEvent) => {\n pointers.current.delete(e.pointerId);\n if (pointers.current.size < 2) gesture.current.dist = undefined;\n };\n const pick = (z: FloorPlanZone) => {\n if (gesture.current.moved) return;\n p.onChange?.(z.id, z);\n };\n\n // Keyboard: + − zoom, arrows pan (anywhere in the plan, including on a zone).\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n const v = viewRef.current;\n const pan: Record<string, [number, number]> = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] };\n if (e.key === '+' || e.key === '=') zoomAt(1.5, undefined, undefined, true);\n else if (e.key === '-' || e.key === '_') zoomAt(1 / 1.5, undefined, undefined, true);\n else if (pan[e.key]) goTo({ ...v, x: v.x + pan[e.key][0] * v.w * 0.15, y: v.y + pan[e.key][1] * v.h * 0.15 }, true);\n else return;\n e.preventDefault();\n };\n\n // Hover and focus show a tooltip at the pointer, or at the label point for focus.\n const [tip, setTip] = React.useState<{ id: string; x: number; y: number } | null>(null);\n const [focused, setFocused] = React.useState<string | null>(null);\n const [focusRing, setFocusRing] = React.useState<string | null>(null);\n\n const narrow = useNarrow();\n const coarse = useMedia('(pointer: coarse)');\n const scr = screenOf(view, W, H);\n const s = scr.s;\n\n // Labels: sizes in px, then placed for the current view.\n const texts = new Map(zones.map((z) => [z.id, zoneText(z, min, max, z.emphasis === 'muted' ? [tr('次要')] : [])]));\n const textOf = (z: FloorPlanZone) => texts.get(z.id) ?? zoneText(z, min, max);\n const groupBoxes: { g: FloorPlanGroup; members: FloorPlanZone[]; b: Box }[] = [];\n for (const g of groups) {\n const members = zones.filter((z) => z.group === g.id);\n if (members.length) groupBoxes.push({ g, members, b: planBox(members.map((m) => m.outline)) });\n }\n const groupLabels = groupBoxes.map(({ g, b }) => {\n // Top left of the group, just above its outline (b holds the 4 % margin of planBox; undo it).\n const m = (Math.max(b.w, b.h) / 1.08) * 0.04;\n const [x, y] = scr.at(b.x + m, -(b.y + m));\n const w = textWidth(g.name, 13) + 12;\n return { g, box: { x: Math.max(0, Math.min(W - w, x)), y: Math.max(0, y - 26), w, h: 22 } };\n });\n const spots = placeLabels(\n order.map((z) => {\n const t = textOf(z);\n const muted = z.emphasis === 'muted' || noData(z);\n const warn = !!z.tone && z.tone !== 'normal';\n const bb = bounds(z.outline);\n const ratio = Math.max(bb.w, bb.h) / Math.max(1e-9, Math.min(bb.w, bb.h));\n const unitW = z.unit ? textWidth(' ' + z.unit, muted ? 13 : 16) : 0;\n const head = noData(z) ? tr('沒有資料') : t.state;\n const full: [number, number] = muted\n ? [Math.max(textWidth((warn ? '⚠ ' : '') + z.name, 13), textWidth(noData(z) ? head : t.figure, 16, !noData(z)) + unitW) + 12, 46]\n : [Math.max(textWidth(z.name, 16), textWidth(t.figure, 25, true) + unitW, textWidth(head, 13)) + 16, 80];\n const pillText = (warn ? '⚠ ' : '') + z.name + ' ';\n const pill: [number, number] = [\n textWidth(pillText, 13) + (noData(z) ? textWidth(tr('沒有資料'), 13) : textWidth(t.figure, 13, true) + (z.unit ? textWidth(' ' + z.unit, 13) : 0)) + 18,\n 24,\n ];\n return { id: z.id, outline: z.outline, label: z.label, muted, slender: ratio > 4, full, pill };\n }),\n view,\n W,\n H,\n groupLabels.map((l) => l.box),\n );\n\n const u = (px: number) => px / s; // px in user units (metres) at the current zoom\n const all = { x: view.x - view.w, y: view.y - view.h, w: view.w * 3, h: view.h * 3 };\n const selected = p.value != null ? ids.get(p.value) : undefined;\n const ring = (zid: string, inner: number, width: number, color: string, key: string) => (\n <React.Fragment key={key}>\n <mask id={`${id}-${key}`} maskUnits=\"userSpaceOnUse\" x={all.x} y={all.y} width={all.w} height={all.h}>\n <path d={paths.get(zid)} fill=\"#fff\" stroke=\"#fff\" strokeWidth={u(2 * (inner + width))} strokeLinejoin=\"round\" fillRule=\"evenodd\" />\n <path d={paths.get(zid)} fill=\"#000\" stroke=\"#000\" strokeWidth={u(2 * inner)} strokeLinejoin=\"round\" fillRule=\"evenodd\" />\n </mask>\n <rect x={all.x} y={all.y} width={all.w} height={all.h} style={{ fill: color }} mask={`url(#${id}-${key})`} pointerEvents=\"none\" />\n </React.Fragment>\n );\n const hasMuted = zones.some((z) => z.emphasis === 'muted');\n const unit = zones.find((z) => z.unit)?.unit;\n const tipZone = tip ? ids.get(tip.id) : undefined;\n const tipAt = tip ?? { x: 0, y: 0 };\n const tipText = tipZone ? texts.get(tipZone.id) : undefined;\n const hint = `${id}-hint`;\n\n return (\n <div className={cx('ui-floorplan', fill && 'is-fill', className)} role=\"group\" aria-label={label} aria-describedby={hint} onKeyDown={onKeyDown}>\n <span id={hint} className=\"ui-visually-hidden\">\n {tr('+ − 縮放,方向鍵平移')}\n </span>\n <div\n ref={box}\n className=\"ui-fp-box\"\n style={fill ? undefined : ({ aspectRatio: `${base.w} / ${base.h}` } as React.CSSProperties)}\n onPointerLeave={() => setTip((t) => (t && focused === t.id ? t : null))}\n >\n <svg\n ref={svg}\n className=\"ui-fp-svg\"\n viewBox={`${view.x} ${view.y} ${view.w} ${view.h}`}\n preserveAspectRatio=\"xMidYMid meet\"\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n >\n <defs>\n <pattern id={`${id}-stripes`} patternUnits=\"userSpaceOnUse\" width={u(9)} height={u(9)} patternTransform=\"rotate(45)\">\n <rect width={u(4)} height={u(9)} className=\"ui-fp-stripe\" />\n </pattern>\n {zones.map((z) =>\n z.tone && z.tone !== 'normal' && !noData(z) ? (\n <clipPath key={z.id} id={`${id}-clip-${z.id}`}>\n <path d={paths.get(z.id)} clipRule=\"evenodd\" />\n </clipPath>\n ) : null,\n )}\n </defs>\n {shell ? <path className=\"ui-fp-shell\" d={polygonPath(shell)} fillRule=\"evenodd\" /> : null}\n {order.map((z) => {\n const d = paths.get(z.id) ?? '';\n if (noData(z)) return <path key={z.id} className=\"ui-fp-empty\" d={d} fillRule=\"evenodd\" />;\n const t = textOf(z);\n const muted = z.emphasis === 'muted';\n const on = p.value === z.id;\n return (\n <g\n key={z.id}\n role=\"button\"\n tabIndex={0}\n aria-pressed={on}\n aria-label={t.label}\n className={cx('ui-fp-zone', 'is-' + t.tone, muted && 'is-muted', on && 'is-selected')}\n data-id={z.id}\n onClick={() => pick(z)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n p.onChange?.(z.id, z);\n }\n }}\n onPointerEnter={(e) => {\n const r = box.current?.getBoundingClientRect();\n if (r && e.pointerType === 'mouse') setTip({ id: z.id, x: e.clientX - r.left, y: e.clientY - r.top });\n }}\n onPointerMove={(e) => {\n const r = box.current?.getBoundingClientRect();\n if (r && e.pointerType === 'mouse' && pointers.current.size === 0) setTip({ id: z.id, x: e.clientX - r.left, y: e.clientY - r.top });\n }}\n onPointerLeave={() => setTip((v) => (v?.id === z.id && focused !== z.id ? null : v))}\n onFocus={(e) => {\n setFocused(z.id);\n if ((e.target as Element).matches?.(':focus-visible')) {\n setFocusRing(z.id);\n const [x, y] = scr.at(z.label[0], z.label[1]);\n setTip({ id: z.id, x, y });\n }\n }}\n onBlur={() => {\n setFocused(null);\n setFocusRing(null);\n setTip((v) => (v?.id === z.id ? null : v));\n }}\n >\n <path className=\"ui-fp-fill\" d={d} fillRule=\"evenodd\" style={{ fill: muted ? `color-mix(in srgb, ${t.bg} 40%, var(--surface))` : t.bg }} />\n {z.forecast ? <path d={d} fillRule=\"evenodd\" fill={`url(#${id}-stripes)`} pointerEvents=\"none\" /> : null}\n {t.tone !== 'normal' ? (\n <path className=\"ui-fp-tone\" d={d} fill=\"none\" strokeWidth={u(8)} clipPath={`url(#${id}-clip-${z.id})`} pointerEvents=\"none\" />\n ) : null}\n {/* Small zones on touch screens get a 48 px round target at their label point. */}\n {(narrow || coarse) && (Math.min(bounds(z.outline).w, bounds(z.outline).h) / 1.08) * s < 48 ? (\n <circle cx={z.label[0]} cy={-z.label[1]} r={u(24)} fill=\"transparent\" />\n ) : null}\n </g>\n );\n })}\n {edges.map((e, i) =>\n e.segs.map((seg, k) => (\n <polyline\n key={i + '-' + k}\n className=\"ui-fp-edge\"\n points={seg.map(([x, y]) => `${fmt(x)},${fmt(-y)}`).join(' ')}\n vectorEffect=\"non-scaling-stroke\"\n />\n )),\n )}\n {groupBoxes.map(({ g, members }) => (\n <React.Fragment key={g.id}>\n <mask id={`${id}-g-${g.id}`} maskUnits=\"userSpaceOnUse\" x={all.x} y={all.y} width={all.w} height={all.h}>\n {members.map((m) => (\n <path key={m.id} d={paths.get(m.id)} fill=\"#fff\" stroke=\"#fff\" strokeWidth={u(2 * 3.5)} strokeLinejoin=\"round\" fillRule=\"evenodd\" />\n ))}\n {members.map((m) => (\n <path key={m.id} d={paths.get(m.id)} fill=\"#000\" stroke=\"#000\" strokeWidth={u(2 * 2)} strokeLinejoin=\"round\" fillRule=\"evenodd\" />\n ))}\n </mask>\n <rect x={all.x} y={all.y} width={all.w} height={all.h} className=\"ui-fp-group\" mask={`url(#${id}-g-${g.id})`} />\n </React.Fragment>\n ))}\n {selected && !noData(selected) ? ring(selected.id, 4, 2, 'var(--ink)', 'sel') : null}\n {focusRing ? ring(focusRing, 1, 2, 'var(--focus)', 'focus') : null}\n </svg>\n <div className=\"ui-fp-labels\" aria-hidden=\"true\">\n {groupLabels.map(({ g, box: b }) => (\n <span key={g.id} className=\"ui-fp-group-name\" style={{ left: b.x, top: b.y, width: b.w }}>\n {g.name}\n </span>\n ))}\n {order.map((z) => {\n const spot = spots.get(z.id);\n if (!spot?.kind) return null;\n const t = textOf(z);\n const empty = noData(z);\n const muted = z.emphasis === 'muted' || empty;\n const warn = t.tone !== 'normal' && !empty;\n const pos = { left: spot.x, top: spot.y, width: spot.w, height: spot.h };\n const unitEl = z.unit && !empty ? <span className=\"ui-fp-unit\">{' ' + z.unit}</span> : null;\n if (spot.kind === 'pill')\n return (\n <span key={z.id} className={cx('ui-fp-pill', empty && 'is-empty')} style={pos}>\n {(warn ? '⚠ ' : '') + z.name + ' '}\n <span className={empty ? undefined : 'ui-fp-num'}>{empty ? tr('沒有資料') : t.figure}</span>\n {unitEl}\n </span>\n );\n return (\n <span\n key={z.id}\n className={cx('ui-fp-label', muted && 'is-muted', empty && 'is-empty')}\n data-fill={muted ? undefined : t.fill}\n style={{ ...pos, color: muted ? undefined : t.color }}\n >\n <span className=\"ui-fp-name\">{(muted && warn ? '⚠ ' : '') + z.name}</span>\n {empty ? (\n <span className=\"ui-fp-state\">{tr('沒有資料')}</span>\n ) : (\n <span className=\"ui-fp-value\">\n {t.figure}\n {unitEl}\n </span>\n )}\n {muted ? null : <span className=\"ui-fp-state\">{t.state}</span>}\n </span>\n );\n })}\n </div>\n {tipZone && tipText ? (\n <div className=\"ui-fp-tip\" aria-hidden=\"true\" style={tipStyle(tipAt.x, tipAt.y, W, H)}>\n <span className=\"ui-fp-tip-name\">{tipZone.name}</span>\n <span>\n <span className=\"ui-fp-num\">{tipText.figure}</span>\n {tipZone.unit ? ' ' + tipZone.unit : ''}\n {tr(',') + tipText.state}\n {tipZone.emphasis === 'muted' ? tr(',') + tr('次要') : ''}\n </span>\n {tipZone.detail ? <span>{tipZone.detail}</span> : null}\n </div>\n ) : null}\n <div className=\"ui-fp-controls\">\n <IconButton\n icon=\"plus\"\n label={tr('放大')}\n tooltip={false}\n onClick={() => zoomAt(1.5, undefined, undefined, true)}\n disabled={view.w <= base.w / MAX_ZOOM + 1e-9}\n />\n <IconButton icon=\"minus\" label={tr('縮小')} tooltip={false} onClick={() => zoomAt(1 / 1.5, undefined, undefined, true)} disabled={!zoomed} />\n <IconButton icon=\"corners-out\" label={tr('重設視角')} tooltip={false} onClick={() => goTo(base, true)} disabled={!zoomed} />\n </div>\n </div>\n {legend ? (\n <Legend\n min={min}\n max={max}\n unit={unit}\n warn={p.warn}\n limit={p.limit}\n decimals={zones.find((z) => z.decimals != null)?.decimals ?? 1}\n muted={hasMuted}\n />\n ) : null}\n </div>\n );\n}\n\n/** The tooltip beside the point, kept inside the drawing. */\nfunction tipStyle(x: number, y: number, W: number, H: number): React.CSSProperties {\n const right = x > W - 240;\n const below = y < 90;\n return {\n left: right ? undefined : Math.max(4, x + 14),\n right: right ? Math.max(4, W - x + 14) : undefined,\n top: below ? Math.min(H - 4, y + 18) : undefined,\n bottom: below ? undefined : Math.max(4, H - y + 10),\n };\n}\n\nfunction Legend({\n min,\n max,\n unit,\n warn,\n limit,\n decimals,\n muted,\n}: {\n min: number;\n max: number;\n unit?: string;\n warn?: number;\n limit?: number;\n decimals: number;\n muted: boolean;\n}) {\n const pct = (v: number) => `${Math.min(100, Math.max(0, ((v - min) / (max - min)) * 100))}%`;\n const num = (v: number) => format.number(v, decimals) + (unit ? ' ' + unit : '');\n return (\n <div className=\"ui-fp-legend\">\n <span className=\"ui-fp-scale\">\n <span className=\"ui-fp-num\">{format.number(min, decimals)}</span>\n <span className=\"ui-fp-bar\">\n {[1, 2, 3, 4, 5, 6, 7].map((n) => (\n <span key={n} style={{ background: `var(--heat-${n})` }} />\n ))}\n {warn != null ? <span className=\"ui-fp-tick is-warning\" style={{ left: pct(warn) }} /> : null}\n {limit != null ? <span className=\"ui-fp-tick is-danger\" style={{ left: pct(limit) }} /> : null}\n </span>\n <span>\n <span className=\"ui-fp-num\">{format.number(max, decimals)}</span>\n {unit ? ' ' + unit : ''}\n </span>\n </span>\n {warn != null ? <span className=\"ui-fp-key is-warning\">{tr('注意 {v}', { v: num(warn) })}</span> : null}\n {limit != null ? <span className=\"ui-fp-key is-danger\">{tr('上限 {v}', { v: num(limit) })}</span> : null}\n {muted ? <span className=\"ui-fp-key is-muted\">{tr('淡色=次要區域')}</span> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,aAAaA,cAAQC,eAASC,mBAAY;;AAqE1C,SAAgB,SAAS,MAA0B;CACjD,OAAO,KAAK,SAAS,MAAM,KAAK,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,MAAM;AAC5F;AACA,MAAM,OAAO,MAAc,OAAO,KAAK,MAAM,IAAI,GAAI,IAAI,GAAI;;AAG7D,SAAgB,YAAY,IAA0B;CACpD,OAAO,GAAG,KAAK,SAAS,KAAK,IAAI,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;AAC9D;;;AAWA,SAAgB,QAAQ,QAA6B;CACnD,IAAI,CAAC,IAAI,IAAI,IAAI,MAAM;EAAC;EAAU;EAAU;EAAW;CAAS;CAChE,KAAK,MAAM,MAAM,QACf,KAAK,MAAM,QAAQ,IACjB,KAAK,MAAM,QAAQ,MACjB,KAAK,MAAM,CAAC,GAAG,MAAM,MAAM;EACzB,KAAK,KAAK,IAAI,IAAI,CAAC;EACnB,KAAK,KAAK,IAAI,IAAI,CAAC;EACnB,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC;EACpB,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC;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D;QAAM,WAAU;QAAwB,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE;OAAI,CAAA,IAAI;OACxF,SAAS,OAAO,oBAAC,QAAD;QAAM,WAAU;QAAuB,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE;OAAI,CAAA,IAAI;MACtF;;KACN,qBAAC,QAAD,EAAA,UAAA,CACE,oBAAC,QAAD;MAAM,WAAU;MAAa,UAAA,OAAO,OAAO,KAAK,QAAQ;KAAQ,CAAA,GAC/D,OAAO,SAAM,OAAO,EACjB,EAAA,CAAA;IACF;;GACL,QAAQ,OAAO,oBAAC,QAAD;IAAM,WAAU;IAAwB,UAAA,GAAG,UAAU,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;GAAQ,CAAA,IAAI;GAChG,SAAS,OAAO,oBAAC,QAAD;IAAM,WAAU;IAAuB,UAAA,GAAG,UAAU,EAAE,GAAG,IAAI,KAAK,EAAE,CAAC;GAAQ,CAAA,IAAI;GACjG,QAAQ,oBAAC,QAAD;IAAM,WAAU;IAAsB,UAAA,GAAG,SAAS;GAAQ,CAAA,IAAI;EACpE;;AAET"}
|
|
@@ -1,37 +1,69 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cx, keepUnits } from "../../internal/util.js";
|
|
2
|
+
import { cx, keepUnits, resizeObserver } from "../../internal/util.js";
|
|
3
|
+
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
3
4
|
import { codeSpans, hasCodeSpan } from "../../internal/codeSpans.js";
|
|
4
5
|
import * as React from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
// src/components/InlineCode/InlineCode.tsx
|
|
7
8
|
/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link; `look` turns a
|
|
8
9
|
* link into a name or a location. */
|
|
9
10
|
function InlineCode({ children, href, onClick, className, look = "chip" }) {
|
|
10
11
|
const [inline, setInline] = React.useState(false);
|
|
12
|
+
const self = React.useRef(null);
|
|
11
13
|
const link = React.useCallback((el) => {
|
|
14
|
+
self.current = el;
|
|
12
15
|
const par = el?.parentNode;
|
|
13
16
|
setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));
|
|
14
17
|
}, []);
|
|
15
18
|
const isLink = !!(href || onClick);
|
|
19
|
+
const location = isLink && look === "location" && typeof children === "string";
|
|
20
|
+
const slash = location ? children.lastIndexOf("/") + 1 : 0;
|
|
21
|
+
const [cut, setCut] = React.useState(false);
|
|
22
|
+
React.useLayoutEffect(() => {
|
|
23
|
+
const el = self.current;
|
|
24
|
+
if (!location || !el) return;
|
|
25
|
+
const check = () => {
|
|
26
|
+
setCut([...el.children].some((c) => c.scrollWidth > c.clientWidth + 1));
|
|
27
|
+
};
|
|
28
|
+
check();
|
|
29
|
+
const ro = resizeObserver(check);
|
|
30
|
+
ro?.observe(el);
|
|
31
|
+
return () => ro?.disconnect();
|
|
32
|
+
}, [location, children]);
|
|
16
33
|
const cls = cx("ui-code", isLink && "is-link", isLink && inline && "is-inline", isLink && look !== "chip" && `is-${look}`, typeof children === "string" && children.length <= 24 && "is-short", className);
|
|
17
|
-
|
|
34
|
+
const body = location ? /* @__PURE__ */ jsxs(Fragment, { children: [slash ? /* @__PURE__ */ jsx("span", {
|
|
35
|
+
className: "ui-code-dir",
|
|
36
|
+
children: children.slice(0, slash)
|
|
37
|
+
}) : null, /* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: "ui-code-file",
|
|
39
|
+
children: children.slice(slash)
|
|
40
|
+
})] }) : children;
|
|
41
|
+
const name = location ? children : void 0;
|
|
42
|
+
const el = href ? /* @__PURE__ */ jsx("a", {
|
|
18
43
|
ref: link,
|
|
19
44
|
className: cls,
|
|
20
45
|
href,
|
|
21
46
|
onClick,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
"aria-label": name,
|
|
48
|
+
children: body
|
|
49
|
+
}) : onClick ? /* @__PURE__ */ jsx("button", {
|
|
25
50
|
ref: link,
|
|
26
51
|
type: "button",
|
|
27
52
|
className: cls,
|
|
28
53
|
onClick,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
"aria-label": name,
|
|
55
|
+
children: body
|
|
56
|
+
}) : /* @__PURE__ */ jsx("code", {
|
|
32
57
|
className: cls,
|
|
33
58
|
children
|
|
34
59
|
});
|
|
60
|
+
return location ? /* @__PURE__ */ jsx(Tooltip, {
|
|
61
|
+
label: children,
|
|
62
|
+
wrap: true,
|
|
63
|
+
describe: false,
|
|
64
|
+
disabled: !cut,
|
|
65
|
+
children: el
|
|
66
|
+
}) : el;
|
|
35
67
|
}
|
|
36
68
|
/** A file and line, such as src/app.c:86 or main.py:12-20. */
|
|
37
69
|
const CODE_REF = /^[\w./-]+\.[A-Za-z0-9]+:\d+(-\d+)?$/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineCode.js","names":[],"sources":["../../../src/components/InlineCode/InlineCode.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx, keepUnits } from '../../internal/util';\nimport { codeSpans, hasCodeSpan } from '../../internal/codeSpans';\n\ninterface InlineCodeBase {\n /** The code, path or ID. */\n children?: React.ReactNode;\n /** Extra class on the root element. */\n className?: string;\n}\ntype Target =\n | { /** Makes it a link. */ href: string; onClick?: (e: React.MouseEvent<HTMLElement>) => void }\n | { href?: undefined; onClick: (e: React.MouseEvent<HTMLElement>) => void };\n\nexport type InlineCodeProps = InlineCodeBase &\n (\n | {\n /** 'chip' (default): monospace on a light gray chip; with href or onClick an underlined accent link. */\n look?: 'chip';\n /** Makes it a link. */\n href?: string;\n /** Makes it a button-like link that runs this. */\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n }\n | ({\n /** 'name': a function, class or variable that opens its definition. Accent monospace without a chip, underlined\n * on hover and keyboard focus. 'location': a file and line (src/app.c:86), gray and one step smaller, accent\n * and underlined on hover and focus. Both need href or onClick: text that points nowhere keeps the chip. */\n look: 'name' | 'location';\n } & Target)\n );\n\n/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link; `look` turns a\n * link into a name or a location. */\nexport function InlineCode({ children, href, onClick, className, look = 'chip' }: InlineCodeProps) {\n // Like Term: a link inside a sentence (text beside it) keeps its line height; on its own it gets the 48 px touch area.\n const [inline, setInline] = React.useState(false);\n const link = React.useCallback((el: HTMLElement | null) => {\n const par = el?.parentNode;\n setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));\n }, []);\n const isLink = !!(href || onClick);\n const cls = cx(\n 'ui-code',\n isLink && 'is-link',\n isLink && inline && 'is-inline',\n isLink && look !== 'chip' && `is-${look}`,\n typeof children === 'string' && children.length <= 24 && 'is-short',\n className,\n );\n if (href)\n return (\n <a ref={link} className={cls} href={href} onClick={onClick}>\n {children}\n </a>\n );\n if (onClick)\n return (\n <button ref={link} type=\"button\" className={cls} onClick={onClick}>\n {children}\n </button>\n );\n return <code className={cls}>{children}</code>;\n}\n\n/** Returns the link of a reference such as src/app.c:86, or undefined when it has no target. */\nexport type RefHref = (ref: string) => string | undefined | null;\n/** Called on a plain click on a reference; the default navigation is prevented. */\nexport type OnRef = (ref: string, e: React.MouseEvent<HTMLElement>) => void;\n\n/** A file and line, such as src/app.c:86 or main.py:12-20. */\nconst CODE_REF = /^[\\w./-]+\\.[A-Za-z0-9]+:\\d+(-\\d+)?$/;\nexport const isCodeRef = (span: string): boolean => CODE_REF.test(span);\n\nexport interface CodeTextProps {\n /** Text with `backtick` spans, as written in Markdown. */\n text: string;\n /** Spans that look like file.c:86 become links; return undefined when the reference has no target. */\n refHref?: RefHref;\n /** Called when a reference is pressed, for apps that open it themselves. */\n onRef?: OnRef;\n /** Which spans are references. Default: a file name with a line number. */\n isRef?: (span: string) => boolean;\n /** The element to render. Default span. */\n as?: 'span' | 'p' | 'div' | 'li';\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Text with `backtick` spans: renders them as InlineCode, never as raw backticks. */\nexport function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = 'span', className }: CodeTextProps) {\n return (\n <Tag className={className}>\n {codeSpans(text).map(({ code, text: v }, i) => {\n if (!code) return keepUnits(v);\n const href = refHref && isRef(v) ? refHref(v) || undefined : undefined;\n const link = isRef(v) && (refHref ? !!href : !!onRef);\n if (!link) return <InlineCode key={i}>{v}</InlineCode>;\n // A reference that points somewhere is a location: gray, one step smaller.\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n // A plain click goes to onRef; Ctrl, ⌘, Shift or the middle button still opens href in a new tab.\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n if (href)\n return (\n <InlineCode key={i} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={i} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n return <InlineCode key={i}>{v}</InlineCode>;\n })}\n </Tag>\n );\n}\n\n/** A sentence prop that takes a string: `backtick` spans become InlineCode, the backticks are not shown; a number and its\n * unit outside them never break apart (「100 MB」). Anything that is not a string (an element) is left alone. */\nexport function codeText(text: React.ReactNode): React.ReactNode {\n if (typeof text !== 'string') return text;\n if (!hasCodeSpan(text)) return keepUnits(text);\n return codeSpans(text).map((s, i) => (s.code ? <InlineCode key={i}>{s.text}</InlineCode> : keepUnits(s.text)));\n}\n"],"mappings":";;;;;;;;AAkCA,SAAgB,WAAW,EAAE,UAAU,MAAM,SAAS,WAAW,OAAO,UAA2B;CAEjG,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,MAAM,OAAO,MAAM,aAAa,OAA2B;EACzD,MAAM,MAAM,IAAI;EAChB,UAAU,CAAC,CAAC,OAAO,MAAM,KAAK,IAAI,UAAU,CAAC,CAAC,MAAM,MAAM,EAAE,aAAa,KAAK,CAAC,CAAC,EAAE,aAAa,KA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AI,OACF,OACE,oBAAC,YAAD;IAAoB,MAAK;IAAW,SAAS;IAC1C,UAAA;GACS,GAFK,CAEL;GAEhB,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAc,GAAlB,CAAkB;EAC5C,CAAC;CACE,CAAA;AAET;;;AAIA,SAAgB,SAAS,MAAwC;CAC/D,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI,CAAC,YAAY,IAAI,GAAG,OAAO,UAAU,IAAI;CAC7C,OAAO,UAAU,IAAI,CAAC,CAAC,KAAK,GAAG,MAAO,EAAE,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAE,KAAiB,GAAvB,CAAuB,IAAI,UAAU,EAAE,IAAI,CAAE;AAC/G"}
|
|
1
|
+
{"version":3,"file":"InlineCode.js","names":[],"sources":["../../../src/components/InlineCode/InlineCode.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx, keepUnits, resizeObserver } from '../../internal/util';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { codeSpans, hasCodeSpan } from '../../internal/codeSpans';\n\ninterface InlineCodeBase {\n /** The code, path or ID. */\n children?: React.ReactNode;\n /** Extra class on the root element. */\n className?: string;\n}\ntype Target =\n | { /** Makes it a link. */ href: string; onClick?: (e: React.MouseEvent<HTMLElement>) => void }\n | { href?: undefined; onClick: (e: React.MouseEvent<HTMLElement>) => void };\n\nexport type InlineCodeProps = InlineCodeBase &\n (\n | {\n /** 'chip' (default): monospace on a light gray chip; with href or onClick an underlined accent link. */\n look?: 'chip';\n /** Makes it a link. */\n href?: string;\n /** Makes it a button-like link that runs this. */\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n }\n | ({\n /** 'name': a function, class or variable that opens its definition. Accent monospace without a chip, underlined\n * on hover and keyboard focus. 'location': a file and line (src/app.c:86), gray and one step smaller, accent\n * and underlined on hover and focus. Both need href or onClick: text that points nowhere keeps the chip. */\n look: 'name' | 'location';\n } & Target)\n );\n\n/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link; `look` turns a\n * link into a name or a location. */\nexport function InlineCode({ children, href, onClick, className, look = 'chip' }: InlineCodeProps) {\n // Like Term: a link inside a sentence (text beside it) keeps its line height; on its own it gets the 48 px touch area.\n const [inline, setInline] = React.useState(false);\n const self = React.useRef<HTMLElement | null>(null);\n const link = React.useCallback((el: HTMLElement | null) => {\n self.current = el;\n const par = el?.parentNode;\n setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));\n }, []);\n const isLink = !!(href || onClick);\n // A location never breaks inside. Where its box is narrower (a phone card's value column), the folders are cut with\n // 「…」 and the file name and line stay (codemap/…/tshelper.ts:42): two spans of the same text, so the accessible\n // name is still the whole path. The whole path shows in a Tooltip while it is cut.\n const location = isLink && look === 'location' && typeof children === 'string';\n const slash = location ? (children as string).lastIndexOf('/') + 1 : 0;\n const [cut, setCut] = React.useState(false);\n React.useLayoutEffect(() => {\n const el = self.current;\n if (!location || !el) return;\n const check = () => {\n setCut([...el.children].some((c) => c.scrollWidth > c.clientWidth + 1));\n };\n check();\n const ro = resizeObserver(check);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, [location, children]);\n const cls = cx(\n 'ui-code',\n isLink && 'is-link',\n isLink && inline && 'is-inline',\n isLink && look !== 'chip' && `is-${look}`,\n typeof children === 'string' && children.length <= 24 && 'is-short',\n className,\n );\n const body = location ? (\n <>\n {slash ? <span className=\"ui-code-dir\">{(children as string).slice(0, slash)}</span> : null}\n <span className=\"ui-code-file\">{(children as string).slice(slash)}</span>\n </>\n ) : (\n children\n );\n // The two spans become flex items where the path is cut, and a screen reader would read a space between them: the\n // name is set to the whole path.\n const name = location ? (children as string) : undefined;\n const el = href ? (\n <a ref={link} className={cls} href={href} onClick={onClick} aria-label={name}>\n {body}\n </a>\n ) : onClick ? (\n <button ref={link} type=\"button\" className={cls} onClick={onClick} aria-label={name}>\n {body}\n </button>\n ) : (\n <code className={cls}>{children}</code>\n );\n // Always mounted for a location, turned on only while cut: swapping the wrapper would remount the link.\n return location ? (\n <Tooltip label={children as string} wrap describe={false} disabled={!cut}>\n {el}\n </Tooltip>\n ) : (\n el\n );\n}\n\n/** Returns the link of a reference such as src/app.c:86, or undefined when it has no target. */\nexport type RefHref = (ref: string) => string | undefined | null;\n/** Called on a plain click on a reference; the default navigation is prevented. */\nexport type OnRef = (ref: string, e: React.MouseEvent<HTMLElement>) => void;\n\n/** A file and line, such as src/app.c:86 or main.py:12-20. */\nconst CODE_REF = /^[\\w./-]+\\.[A-Za-z0-9]+:\\d+(-\\d+)?$/;\nexport const isCodeRef = (span: string): boolean => CODE_REF.test(span);\n\nexport interface CodeTextProps {\n /** Text with `backtick` spans, as written in Markdown. */\n text: string;\n /** Spans that look like file.c:86 become links; return undefined when the reference has no target. */\n refHref?: RefHref;\n /** Called when a reference is pressed, for apps that open it themselves. */\n onRef?: OnRef;\n /** Which spans are references. Default: a file name with a line number. */\n isRef?: (span: string) => boolean;\n /** The element to render. Default span. */\n as?: 'span' | 'p' | 'div' | 'li';\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Text with `backtick` spans: renders them as InlineCode, never as raw backticks. */\nexport function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = 'span', className }: CodeTextProps) {\n return (\n <Tag className={className}>\n {codeSpans(text).map(({ code, text: v }, i) => {\n if (!code) return keepUnits(v);\n const href = refHref && isRef(v) ? refHref(v) || undefined : undefined;\n const link = isRef(v) && (refHref ? !!href : !!onRef);\n if (!link) return <InlineCode key={i}>{v}</InlineCode>;\n // A reference that points somewhere is a location: gray, one step smaller.\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n // A plain click goes to onRef; Ctrl, ⌘, Shift or the middle button still opens href in a new tab.\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n if (href)\n return (\n <InlineCode key={i} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={i} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n return <InlineCode key={i}>{v}</InlineCode>;\n })}\n </Tag>\n );\n}\n\n/** A sentence prop that takes a string: `backtick` spans become InlineCode, the backticks are not shown; a number and its\n * unit outside them never break apart (「100 MB」). Anything that is not a string (an element) is left alone. */\nexport function codeText(text: React.ReactNode): React.ReactNode {\n if (typeof text !== 'string') return text;\n if (!hasCodeSpan(text)) return keepUnits(text);\n return codeSpans(text).map((s, i) => (s.code ? <InlineCode key={i}>{s.text}</InlineCode> : keepUnits(s.text)));\n}\n"],"mappings":";;;;;;;;;AAmCA,SAAgB,WAAW,EAAE,UAAU,MAAM,SAAS,WAAW,OAAO,UAA2B;CAEjG,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,MAAM,OAAO,MAAM,OAA2B,IAAI;CAClD,MAAM,OAAO,MAAM,aAAa,OAA2B;EACzD,KAAK,UAAU;EACf,MAAM,MAAM,IAAI;EAChB,UAAU,CAAC,CAAC,OAAO,MAAM,KAAK,IAAI,UAAU,CAAC,CAAC,MAAM,MAAM,EAAE,aAAa,KAAK,CAAC,CAAC,EAAE,aAAa,KAAK,CAAC,CAAC;CACxG,GAAG,CAAC,CAAC;CACL,MAAM,SAAS,CAAC,EAAE,QAAQ;CAI1B,MAAM,WAAW,UAAU,SAAS,cAAc,OAAO,aAAa;CACtE,MAAM,QAAQ,WAAY,SAAoB,YAAY,GAAG,IAAI,IAAI;CACrE,MAAM,CAAC,KAAK,UAAU,MAAM,SAAS,KAAK;CAC1C,MAAM,sBAAsB;EAC1B,MAAM,KAAK,KAAK;EAChB,IAAI,CAAC,YAAY,CAAC,IAAI;EACtB,MAAM,cAAc;GAClB,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,MAAM,MAAM,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;EACxE;EACA,MAAM;EACN,MAAM,KAAK,eAAe,KAAK;EAC/B,IAAI,Q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AAY,KAAA;GAE7D,IAAI,EADS,MAAM,CAAC,MAAM,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,SACpC,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAc,GAAlB,CAAkB;GAErD,MAAM,QAAQ,SACT,MAAqC;IAEpC,IAAI,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,IAAI;IACtE,EAAE,eAAe;IACjB,MAAM,GAAG,CAAC;GACZ,IACA,KAAA;GACJ,IAAI,MACF,OACE,oBAAC,YAAD;IAAoB,MAAK;IAAiB;IAAM,SAAS;IACtD,UAAA;GACS,GAFK,CAEL;GAEhB,IAAI,OACF,OACE,oBAAC,YAAD;IAAoB,MAAK;IAAW,SAAS;IAC1C,UAAA;GACS,GAFK,CAEL;GAEhB,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAc,GAAlB,CAAkB;EAC5C,CAAC;CACE,CAAA;AAET;;;AAIA,SAAgB,SAAS,MAAwC;CAC/D,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI,CAAC,YAAY,IAAI,GAAG,OAAO,UAAU,IAAI;CAC7C,OAAO,UAAU,IAAI,CAAC,CAAC,KAAK,GAAG,MAAO,EAAE,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAE,KAAiB,GAAvB,CAAuB,IAAI,UAAU,EAAE,IAAI,CAAE;AAC/G"}
|
|
@@ -5,7 +5,7 @@ import { IconButton } from "../IconButton/IconButton.js";
|
|
|
5
5
|
import { Switch } from "../Switch/Switch.js";
|
|
6
6
|
import { tr } from "../../i18n.js";
|
|
7
7
|
import { format } from "../../format.js";
|
|
8
|
-
import { cx, monoNums, resizeObserver } from "../../internal/util.js";
|
|
8
|
+
import { cx, monoNums, resizeObserver, useFontLoads } from "../../internal/util.js";
|
|
9
9
|
import { ScrollHint, useScrollHint } from "../../internal/scrollHint.js";
|
|
10
10
|
import { codeSpans } from "../../internal/codeSpans.js";
|
|
11
11
|
import { devWarn } from "../../internal/dev.js";
|
|
@@ -303,12 +303,14 @@ const clean = (pts) => pts.filter((q, i) => {
|
|
|
303
303
|
function LayerGraph(props) {
|
|
304
304
|
const p = resolveProps(props);
|
|
305
305
|
const [avail, setAvail] = React.useState(0);
|
|
306
|
+
const fontLoads = useFontLoads();
|
|
306
307
|
const [fit, setFit] = React.useState(null);
|
|
307
|
-
const
|
|
308
|
+
const fitAt = avail + "@" + fontLoads;
|
|
309
|
+
const fitted = fit && fit.at === fitAt ? fit : null;
|
|
308
310
|
const NW = fitted?.nw ?? (p.nodeWidth || 200);
|
|
309
311
|
const GAP = 56;
|
|
310
312
|
const [dh, setDh] = useStored(p.resizable && p.heightKey ? "ui-lg-height:" + p.heightKey : void 0, parseHeight, 0, (v) => String(Math.round(v)));
|
|
311
|
-
const spreadKey =
|
|
313
|
+
const spreadKey = fitAt + "#" + p.nodes.map((n) => n.id).join("|") + "#" + p.edges.map((e) => e.from + ">" + e.to + ":" + (e.label ?? "")).join("|");
|
|
312
314
|
const [spreadAt, setSpread] = React.useState({
|
|
313
315
|
key: "",
|
|
314
316
|
n: 0
|
|
@@ -428,7 +430,7 @@ function LayerGraph(props) {
|
|
|
428
430
|
paintHover();
|
|
429
431
|
}, [paintHover]);
|
|
430
432
|
React.useLayoutEffect(paintHover);
|
|
431
|
-
const { ref: scrollRef, more: scrollMore, overflows, scrolled, onScroll } = useScrollHint();
|
|
433
|
+
const { ref: scrollRef, more: scrollMore, overflows, scrolled, onScroll, measure: measureHint } = useScrollHint();
|
|
432
434
|
const uid = React.useId().replace(/:/g, "");
|
|
433
435
|
const [view, setView] = React.useState("graph");
|
|
434
436
|
const memKey = p.scrollKey ?? idsKey(all.map((n) => n.id));
|
|
@@ -1338,7 +1340,8 @@ function LayerGraph(props) {
|
|
|
1338
1340
|
p.countLabel,
|
|
1339
1341
|
p.inferredLabel,
|
|
1340
1342
|
p.declaredLabel,
|
|
1341
|
-
p.nodeWidth
|
|
1343
|
+
p.nodeWidth,
|
|
1344
|
+
fontLoads
|
|
1342
1345
|
]);
|
|
1343
1346
|
const drawn = routed.drawn;
|
|
1344
1347
|
W = routed.W;
|
|
@@ -1549,7 +1552,7 @@ function LayerGraph(props) {
|
|
|
1549
1552
|
const lose = W - avail - (cols - 1) * 16;
|
|
1550
1553
|
const nw = Math.max(Math.min(base, 120), Math.floor(base - Math.max(0, lose) / cols));
|
|
1551
1554
|
setFit({
|
|
1552
|
-
at:
|
|
1555
|
+
at: fitAt,
|
|
1553
1556
|
nw,
|
|
1554
1557
|
col: 24,
|
|
1555
1558
|
scale: 1
|
|
@@ -1575,12 +1578,22 @@ function LayerGraph(props) {
|
|
|
1575
1578
|
});
|
|
1576
1579
|
}, [
|
|
1577
1580
|
avail,
|
|
1581
|
+
fitAt,
|
|
1578
1582
|
showList,
|
|
1579
1583
|
fitted,
|
|
1580
1584
|
W,
|
|
1581
1585
|
p.nodeWidth,
|
|
1582
1586
|
cols
|
|
1583
1587
|
]);
|
|
1588
|
+
React.useLayoutEffect(() => {
|
|
1589
|
+
if (!showList) measureHint();
|
|
1590
|
+
}, [
|
|
1591
|
+
measureHint,
|
|
1592
|
+
showList,
|
|
1593
|
+
W,
|
|
1594
|
+
H,
|
|
1595
|
+
scale
|
|
1596
|
+
]);
|
|
1584
1597
|
const coveredNow = drawn.covered;
|
|
1585
1598
|
React.useLayoutEffect(() => {
|
|
1586
1599
|
if (coveredNow && spread < 5) setSpread({
|