@seanyeh77/ui 0.48.2 → 0.48.3

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.
@@ -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
- if (href) return /* @__PURE__ */ jsx("a", {
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
- children
23
- });
24
- if (onClick) return /* @__PURE__ */ jsx("button", {
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
- children
30
- });
31
- return /* @__PURE__ */ jsx("code", {
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;C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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"}
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;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A,UAAU,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,MAAM,KAAK,MAAM;GAC7C,IAAI,CAAC,MAAM,OAAO,UAAU,CAAC;GAC7B,MAAM,OAAO,WAAW,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK,KAAA,IAAY,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 fitted = fit && fit.at === avail ? fit : null;
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 = avail + "#" + p.nodes.map((n) => n.id).join("|") + "#" + p.edges.map((e) => e.from + ">" + e.to + ":" + (e.label ?? "")).join("|");
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: avail,
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({