@seanyeh77/ui 0.43.0 → 0.43.1

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.
Files changed (31) hide show
  1. package/dist/bundle.js +19 -19
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/components/DataTable/DataTable.js +5 -3
  4. package/dist/components/DataTable/DataTable.js.map +1 -1
  5. package/dist/components/DataTable/parts.js +4 -4
  6. package/dist/components/DataTable/parts.js.map +1 -1
  7. package/dist/components/LayerGraph/LayerGraph.js +12 -8
  8. package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
  9. package/dist/components/LineChart/LineChart.js +1 -1
  10. package/dist/components/LineChart/LineChart.js.map +1 -1
  11. package/dist/components/Markdown/Markdown.js +4 -4
  12. package/dist/components/Markdown/Markdown.js.map +1 -1
  13. package/dist/components/Section/Section.js +1 -1
  14. package/dist/components/Section/Section.js.map +1 -1
  15. package/dist/components/SegmentedControl/SegmentedControl.js +4 -4
  16. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  17. package/dist/components/SplitPane/SplitPane.js +6 -6
  18. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  19. package/dist/components/Tabs/Tabs.js +5 -5
  20. package/dist/components/Tabs/Tabs.js.map +1 -1
  21. package/dist/components/Tour/Tour.js +3 -3
  22. package/dist/components/Tour/Tour.js.map +1 -1
  23. package/dist/components/Workbench/Workbench.js +7 -7
  24. package/dist/components/Workbench/Workbench.js.map +1 -1
  25. package/dist/internal/scrollHint.js +5 -5
  26. package/dist/internal/scrollHint.js.map +1 -1
  27. package/dist/internal/tableTools.js +1 -1
  28. package/dist/internal/tableTools.js.map +1 -1
  29. package/dist/internal/util.js +5 -1
  30. package/dist/internal/util.js.map +1 -1
  31. package/package.json +4 -2
@@ -1 +1 @@
1
- {"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys and reset\n * with a double-click. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press.\n const dragging = React.useRef(false);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = true;\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current || !root.current) return;\n const r = root.current.getBoundingClientRect();\n set(r.right - e.clientX - HANDLE / 2, false);\n };\n const onUp = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current) return;\n dragging.current = false;\n setDrag(false);\n try {\n if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={onUp}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA0BA,MAAM,SAAS;;AAEf,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAEb,MAAM,QAAQ,QAA2C;CACvD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,IAAI,OAAO,OAAO,aAAa,QAAQ,cAAc,GAAG,CAAC;EAC/D,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;CAC3C,QAAQ;EACN,OAAO;CACT;AACF;AACA,MAAM,SAAS,KAAyB,MAAc;CACpD,IAAI,CAAC,KAAK;CACV,IAAI;EACF,OAAO,aAAa,QAAQ,cAAc,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,C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AiB;IACjB,cAAY,SAAS,GAAG,QAAQ;IAChC,iBAAe;IACf,iBAAe;IACf,iBAAe;IACf,iBAAe,KAAK,IAAI,MAAM,QAAQ,SAAS,IAAI;IACnD,kBAAgB,GAAG,yBAAyB;KAAE,GAAG;KAAQ,GAAG;IAAM,CAAC;IACnE,WAAU;IACV,WAAW;IACX,eAAe;IACf,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,qBAAqB,IAAI,QAAQ;IAGjC,UAAA,qBAAC,QAAD;KAAM,WAAU;KAAgB,eAAY;KAA5C,UAAA;MACE,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;KACA;;GACH,CAAA;GAEP,oBAAC,OAAD;IAAS;IAAI,WAAU;IACpB,UAAA;GACE,CAAA;EACF;;AAET"}
1
+ {"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys and reset\n * with a double-click. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press.\n const dragging = React.useRef(false);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = true;\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current || !root.current) return;\n const r = root.current.getBoundingClientRect();\n set(r.right - e.clientX - HANDLE / 2, false);\n };\n const onUp = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current) return;\n dragging.current = false;\n setDrag(false);\n try {\n if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={onUp}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA0BA,MAAM,SAAS;;AAEf,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAEb,MAAM,QAAQ,QAA2C;CACvD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,IAAI,OAAO,OAAO,aAAa,QAAQ,cAAc,GAAG,CAAC;EAC/D,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;CAC3C,QAAQ;EACN,OAAO;CACT;AACF;AACA,MAAM,SAAS,KAAyB,MAAc;CACpD,IAAI,CAAC,KAAK;CACV,IAAI;EACF,OAAO,aAAa,QAAQ,cAAc,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC;CACtE,QAAQ,CAER;AACF;;;AAIA,SAAgB,UAAU,EAAE,GAAG,GAAG,WAAW,KAAK,OAAO,KAAK,OAAO,KAAK,YAAY,OAAO,UAAU,aAA6B;CAClI,QAAQ,WAAW,MAAM,aAAa,aAAa,SAAS,sBAAsB,KAAK,4BAA4B,KAAK,mCAAmC;CAC3J,MAAM,OAAO,MAAM,OAAuB,IAAI;CAC9C,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,CAAC;CAG1C,MAAM,CAAC,MAAM,WAAW,MAAM,gBAAgB,OAAO,WAAW,cAAc,OAAO,KAAK,UAAU,MAAM,QAAQ;CAClH,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAE5C,MAAM,WAAW,MAAM,OAAO,KAAK;CACnC,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,sBAAsB;EAC1B,MAAM,KAAK,KAAK;EAChB,IAAI,CAAC,IAAI;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
3
3
  import { dropTransition, useMoving } from "../../motion.js";
4
- import { browserKey, cx } from "../../internal/util.js";
4
+ import { browserKey, cx, resizeObserver } from "../../internal/util.js";
5
5
  import { devWarn } from "../../internal/dev.js";
6
6
  import { useFocusRescue } from "../../internal/focus.js";
7
7
  import { announce } from "../../announce.js";
@@ -49,10 +49,10 @@ function Tabs({ items, value, onChange, label, unit, className }) {
49
49
  measure();
50
50
  if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;
51
51
  else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;
52
- const ro = new ResizeObserver(measure);
53
- ro.observe(tr);
54
- for (const t of refs.current) if (t) ro.observe(t);
55
- return () => ro.disconnect();
52
+ const ro = resizeObserver(measure);
53
+ ro?.observe(tr);
54
+ for (const t of refs.current) if (t) ro?.observe(t);
55
+ return () => ro?.disconnect();
56
56
  }, [
57
57
  idx,
58
58
  items.length,
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { dropTransition, useMoving } from '../../motion';\nimport { cx, browserKey } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { useFocusRescue } from '../../internal/focus';\nimport { announce } from '../../announce';\nimport { unitFor, type CountUnit } from '../../i18n';\n\nexport interface TabItem<V extends string = string> {\n id: V;\n label: string;\n /** A count after the label, e.g. how many rows a view has. */\n count?: number;\n /** Unit after this tab's count, e.g. 「筆」, or a function of the count for plurals. Default: the list's unit. */\n unit?: CountUnit;\n}\n\nexport interface TabsProps<V extends string = string> {\n items: TabItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** aria-label of the tab list. */\n label?: string;\n /** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit. A function gets the count, for plurals:\n * `(n) => (n === 1 ? 'item' : 'items')`. */\n unit?: CountUnit;\n className?: string;\n}\n\n/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */\nexport function Tabs<V extends string = string>({ items, value, onChange, label, unit, className }: TabsProps<V>) {\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const track = React.useRef<HTMLDivElement>(null);\n const [box, setBox] = React.useState<{ left: number; right: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n const [moving, bump] = useMoving();\n // Wider than its box (G0): a fade on the side that has more tabs, and the selected tab kept in view.\n const [more, setMore] = React.useState({ left: false, right: false });\n const edges = React.useCallback(() => {\n const el = track.current;\n if (!el) return;\n const left = el.scrollLeft > 1;\n // The end of the last tab, not scrollWidth: the moving indicator can stick out for a moment and leave a fade on a\n // row that fits.\n const last = refs.current.filter(Boolean).pop();\n const end = last ? last.offsetLeft + last.offsetWidth : el.scrollWidth;\n const right = el.scrollLeft + el.clientWidth < end - 1;\n setMore((m) => (m.left === left && m.right === right ? m : { left, right }));\n }, []);\n // The focused tab re-rendered away (new items, the app swapped the list): focus goes to the selected tab.\n useFocusRescue(\n track,\n () =>\n refs.current[\n Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n )\n ],\n );\n devWarn(\n items.some((t) => t.count != null && !(t.unit || unit)),\n 'Tabs',\n \"a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.\",\n );\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n const tr = track.current;\n if (!el || !tr) return;\n // Counts, fonts and the container change tab widths without changing the selection.\n const measure = () => {\n // Both sides from the row's own box: a tab past the visible part gets a negative right, and scrolls with the row.\n setBox({ left: el.offsetLeft, right: tr.clientWidth - el.offsetLeft - el.offsetWidth });\n edges();\n };\n measure();\n // The selected tab in view, without scrolling the page.\n if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;\n else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;\n const ro = new ResizeObserver(measure);\n ro.observe(tr);\n for (const t of refs.current) if (t) ro.observe(t);\n return () => ro.disconnect();\n }, [idx, items.length, edges]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n bump();\n onChange?.(items[i].id);\n announce(\n items[i].label +\n (items[i].count != null\n ? ' ' + format.number(items[i].count ?? 0) + (items[i].unit || unit ? ' ' + unitFor(items[i].unit || unit, items[i].count ?? 0) : '')\n : ''),\n );\n };\n return (\n <div\n ref={track}\n className={cx('ui-tabs', more.left && 'has-more-left', more.right && 'has-more-right', className)}\n role=\"tablist\"\n aria-label={label}\n onScroll={edges}\n >\n {box ? (\n <span\n className=\"ui-tabs-ind\"\n aria-hidden=\"true\"\n style={{ left: box.left, right: box.right, transform: moving ? 'scaleY(.82)' : 'none', transition: dropTransition('left', 'right', forward) }}\n />\n ) : null}\n {items.map((t, i) => (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"tab\"\n aria-selected={i === idx}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-tab', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const to = e.key === 'ArrowRight' ? (i + 1) % items.length : e.key === 'ArrowLeft' ? (i - 1 + items.length) % items.length : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.label}\n {/* A space between the name and its count, also for screen readers: 「全部 26 個」. */}\n {t.count != null ? ' ' : null}\n {t.count != null ? (\n <span className=\"ui-tab-count\">\n {format.number(t.count)}\n {t.unit || unit ? (\n <>\n {' '}\n <span className=\"ui-unit\">{unitFor(t.unit || unit, t.count)}</span>\n </>\n ) : null}\n </span>\n ) : null}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,KAAgC,EAA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MAAM,MAAM,IAAI;GAC1B,WAAW,GAAG,UAAU,MAAM,OAAO,aAAa;GAClD,eAAe,GAAG,CAAC;GACnB,YAAY,MAAM;IAChB,IAAI,WAAW,CAAC,GAAG;IACnB,MAAM,KAAK,EAAE,QAAQ,gBAAgB,IAAI,KAAK,MAAM,SAAS,EAAE,QAAQ,eAAe,IAAI,IAAI,MAAM,UAAU,MAAM,SAAS;IAC7H,IAAI,KAAK,GAAG;IACZ,EAAE,eAAe;IACjB,KAAK,QAAQ,GAAG,EAAE,MAAM;IACxB,GAAG,EAAE;GACP;GAlBF,UAAA;IAoBG,EAAE;IAEF,EAAE,SAAS,OAAO,MAAM;IACxB,EAAE,SAAS,OACV,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACG,OAAO,OAAO,EAAE,KAAK,GACrB,EAAE,QAAQ,OACT,qBAAA,UAAA,EAAA,UAAA,CACG,KACD,oBAAC,QAAD;MAAM,WAAU;MAAW,UAAA,QAAQ,EAAE,QAAQ,MAAM,EAAE,KAAK;KAAQ,CAAA,CAClE,EAAA,CAAA,IACA,IACA;IACJ,CAAA,IAAA;GACE;EAjCD,GAAA,EAAE,EAiCD,CACT,CACE;;AAET"}
1
+ {"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { dropTransition, useMoving } from '../../motion';\nimport { cx, browserKey, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { useFocusRescue } from '../../internal/focus';\nimport { announce } from '../../announce';\nimport { unitFor, type CountUnit } from '../../i18n';\n\nexport interface TabItem<V extends string = string> {\n id: V;\n label: string;\n /** A count after the label, e.g. how many rows a view has. */\n count?: number;\n /** Unit after this tab's count, e.g. 「筆」, or a function of the count for plurals. Default: the list's unit. */\n unit?: CountUnit;\n}\n\nexport interface TabsProps<V extends string = string> {\n items: TabItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** aria-label of the tab list. */\n label?: string;\n /** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit. A function gets the count, for plurals:\n * `(n) => (n === 1 ? 'item' : 'items')`. */\n unit?: CountUnit;\n className?: string;\n}\n\n/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */\nexport function Tabs<V extends string = string>({ items, value, onChange, label, unit, className }: TabsProps<V>) {\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const track = React.useRef<HTMLDivElement>(null);\n const [box, setBox] = React.useState<{ left: number; right: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n const [moving, bump] = useMoving();\n // Wider than its box (G0): a fade on the side that has more tabs, and the selected tab kept in view.\n const [more, setMore] = React.useState({ left: false, right: false });\n const edges = React.useCallback(() => {\n const el = track.current;\n if (!el) return;\n const left = el.scrollLeft > 1;\n // The end of the last tab, not scrollWidth: the moving indicator can stick out for a moment and leave a fade on a\n // row that fits.\n const last = refs.current.filter(Boolean).pop();\n const end = last ? last.offsetLeft + last.offsetWidth : el.scrollWidth;\n const right = el.scrollLeft + el.clientWidth < end - 1;\n setMore((m) => (m.left === left && m.right === right ? m : { left, right }));\n }, []);\n // The focused tab re-rendered away (new items, the app swapped the list): focus goes to the selected tab.\n useFocusRescue(\n track,\n () =>\n refs.current[\n Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n )\n ],\n );\n devWarn(\n items.some((t) => t.count != null && !(t.unit || unit)),\n 'Tabs',\n \"a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.\",\n );\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n const tr = track.current;\n if (!el || !tr) return;\n // Counts, fonts and the container change tab widths without changing the selection.\n const measure = () => {\n // Both sides from the row's own box: a tab past the visible part gets a negative right, and scrolls with the row.\n setBox({ left: el.offsetLeft, right: tr.clientWidth - el.offsetLeft - el.offsetWidth });\n edges();\n };\n measure();\n // The selected tab in view, without scrolling the page.\n if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;\n else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;\n const ro = resizeObserver(measure);\n ro?.observe(tr);\n for (const t of refs.current) if (t) ro?.observe(t);\n return () => ro?.disconnect();\n }, [idx, items.length, edges]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n bump();\n onChange?.(items[i].id);\n announce(\n items[i].label +\n (items[i].count != null\n ? ' ' + format.number(items[i].count ?? 0) + (items[i].unit || unit ? ' ' + unitFor(items[i].unit || unit, items[i].count ?? 0) : '')\n : ''),\n );\n };\n return (\n <div\n ref={track}\n className={cx('ui-tabs', more.left && 'has-more-left', more.right && 'has-more-right', className)}\n role=\"tablist\"\n aria-label={label}\n onScroll={edges}\n >\n {box ? (\n <span\n className=\"ui-tabs-ind\"\n aria-hidden=\"true\"\n style={{ left: box.left, right: box.right, transform: moving ? 'scaleY(.82)' : 'none', transition: dropTransition('left', 'right', forward) }}\n />\n ) : null}\n {items.map((t, i) => (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"tab\"\n aria-selected={i === idx}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-tab', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const to = e.key === 'ArrowRight' ? (i + 1) % items.length : e.key === 'ArrowLeft' ? (i - 1 + items.length) % items.length : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.label}\n {/* A space between the name and its count, also for screen readers: 「全部 26 個」. */}\n {t.count != null ? ' ' : null}\n {t.count != null ? (\n <span className=\"ui-tab-count\">\n {format.number(t.count)}\n {t.unit || unit ? (\n <>\n {' '}\n <span className=\"ui-unit\">{unitFor(t.unit || unit, t.count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AD;GAEE,MAAM,MAAM;IACV,KAAK,QAAQ,KAAK;GACpB;GACA,MAAK;GACL,MAAK;GACL,iBAAe,MAAM;GACrB,UAAU,MAAM,MAAM,IAAI;GAC1B,WAAW,GAAG,UAAU,MAAM,OAAO,aAAa;GAClD,eAAe,GAAG,CAAC;GACnB,YAAY,MAAM;IAChB,IAAI,WAAW,CAAC,GAAG;IACnB,MAAM,KAAK,EAAE,QAAQ,gBAAgB,IAAI,KAAK,MAAM,SAAS,EAAE,QAAQ,eAAe,IAAI,IAAI,MAAM,UAAU,MAAM,SAAS;IAC7H,IAAI,KAAK,GAAG;IACZ,EAAE,eAAe;IACjB,KAAK,QAAQ,GAAG,EAAE,MAAM;IACxB,GAAG,EAAE;GACP;GAlBF,UAAA;IAoBG,EAAE;IAEF,EAAE,SAAS,OAAO,MAAM;IACxB,EAAE,SAAS,OACV,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACG,OAAO,OAAO,EAAE,KAAK,GACrB,EAAE,QAAQ,OACT,qBAAA,UAAA,EAAA,UAAA,CACG,KACD,oBAAC,QAAD;MAAM,WAAU;MAAW,UAAA,QAAQ,EAAE,QAAQ,MAAM,EAAE,KAAK;KAAQ,CAAA,CAClE,EAAA,CAAA,IACA,IACA;IACJ,CAAA,IAAA;GACE;EAjCD,GAAA,EAAE,EAiCD,CACT,CACE;;AAET"}
@@ -4,7 +4,7 @@ import { CodeText } from "../InlineCode/InlineCode.js";
4
4
  import { Button } from "../Button/Button.js";
5
5
  import { tr } from "../../i18n.js";
6
6
  import { announce } from "../../announce.js";
7
- import { cx, seenOnly, store } from "../../internal/util.js";
7
+ import { cx, resizeObserver, seenOnly, store } from "../../internal/util.js";
8
8
  import { devWarn } from "../../internal/dev.js";
9
9
  import * as React from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -303,8 +303,8 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
303
303
  setCardW(el.offsetWidth);
304
304
  };
305
305
  measure();
306
- observer.current = new ResizeObserver(measure);
307
- observer.current.observe(el);
306
+ observer.current = resizeObserver(measure);
307
+ observer.current?.observe(el);
308
308
  }, []);
309
309
  const measured = cardH > 0;
310
310
  React.useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Tour.js","names":[],"sources":["../../../src/components/Tour/Tour.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useReturnFocus } from '../../internal/focus';\nimport { Popover } from '@base-ui/react/popover';\nimport { CodeText } from '../InlineCode/InlineCode';\nimport { Button } from '../Button/Button';\nimport { tr } from '../../i18n';\nimport { announce } from '../../announce';\nimport { cx, seenOnly, store } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport type { IconButtonHint } from '../IconButton/IconButton';\n\nexport interface TourStep {\n /** A data-tour name ('search' matches [data-tour=\"search\"]), a CSS selector (first visible match), a ref or an element.\n * Leave it out for a step in the middle of the screen. */\n target?: string | React.RefObject<Element | null> | Element;\n /** Names the part: 「搜尋」. */\n title: string;\n /** What it does, 1 short sentence; `backticks` are code. */\n text: string;\n /** Default 'bottom'. The card goes below, above, right or left of the target, the first side where it fits in the\n * window and covers neither the target nor `keepVisible` ('top' tries above first). With no such side the page\n * scrolls to make room; failing that, the side that covers the least of the target. */\n side?: 'bottom' | 'top';\n /** Space around the highlighted part in px. Default 6. */\n padding?: number;\n /** Parts the card must not cover either, e.g. the table the step talks about under a highlighted summary: same forms\n * as target. The card then goes to the next side that leaves them visible. */\n keepVisible?: TourStep['target'] | TourStep['target'][];\n}\n\nexport interface TourProps {\n open: boolean;\n steps: TourStep[];\n onClose?: (reason: 'done' | 'skip') => void;\n /** 「略過」 and Esc end the tour early. Default true. */\n skippable?: boolean;\n /** Controlled step index. */\n step?: number;\n onStepChange?: (index: number) => void;\n}\n\nconst TOUR_KEY = 'ui-tour:';\n\n/** Opens the tour once per browser: { open, start, close, seen, hint }. Pass close to Tour's onClose; start() shows\n * it again. hint(text) gives IconButton's `hint` for the button that starts the tour: a page that uses it shows the dot\n * and the bubble instead of opening the tour by itself. 「開始」 starts the tour; × and finishing it hide the hint for\n * good (the same record as seen). */\nexport function useTour(key: string) {\n const [seen, setSeen] = React.useState(() => !!store(TOUR_KEY + key));\n const [open, setOpen] = React.useState(false);\n // hint() is called while the page renders; the tour opens by itself after that render only when it was not.\n const hinted = React.useRef(false);\n React.useLayoutEffect(() => {\n // Known only after the page rendered: whether it uses hint().\n if (!store(TOUR_KEY + key) && !hinted.current) setOpen(true);\n }, [key]);\n const remember = () => {\n store(TOUR_KEY + key, '1');\n setSeen(true);\n };\n return {\n open,\n start: () => setOpen(true),\n close: () => {\n remember();\n setOpen(false);\n },\n seen,\n /** IconButton's `hint` for the button that starts this tour, or undefined once seen or while the tour is open. */\n hint: (text: string, action?: string): IconButtonHint | undefined => {\n hinted.current = true;\n if (seen || open) return undefined;\n return { text, action, onAction: () => setOpen(true), onDismiss: remember };\n },\n };\n}\n\nfunction findTarget(t: TourStep['target']): Element | null {\n if (!t) return null;\n if (typeof t === 'string') {\n const sel = /^[\\w-]+$/.test(t) && !/^(html|body|main|nav|header|footer|section|aside)$/.test(t) ? `[data-tour=\"${t}\"]` : t;\n return Array.from(document.querySelectorAll(sel)).find((e) => e.getClientRects().length > 0) ?? null;\n }\n return t instanceof Element ? t : t.current;\n}\n\ninterface Box {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nconst GAP = 12;\n\n/** The space kept between the card and the window edges: the --space-3 token. */\nfunction edge() {\n return parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--space-3')) || 12;\n}\n\nconst narrowNow = () => typeof window !== 'undefined' && window.innerWidth < 600;\n\n/** The part of the window between a phone's fixed top bar and bottom tab bar (when the target is not one of them):\n * the card stays inside it and never covers either bar. The whole window elsewhere. */\nfunction bounds(target: Element | null): { top: number; bottom: number } {\n const vh = typeof window === 'undefined' ? 0 : window.innerHeight;\n if (!narrowNow()) return { top: 0, bottom: vh };\n let top = 0;\n let bottom = vh;\n const head = document.querySelector('.ui-shell-top');\n const bar = document.querySelector('.ui-tabbar');\n if (head && !(target && head.contains(target))) {\n const r = head.getBoundingClientRect();\n if (r.height && r.bottom > 0 && r.bottom < vh / 2) top = r.bottom;\n }\n if (bar && !(target && bar.contains(target))) {\n const r = bar.getBoundingClientRect();\n if (r.height && r.top > vh / 2 && r.top < vh) bottom = r.top;\n }\n return { top, bottom };\n}\n\ntype Side = 'bottom' | 'top' | 'right' | 'left';\nconst area = (a: Box, b: Box) =>\n Math.max(0, Math.min(a.left + a.width, b.left + b.width) - Math.max(a.left, b.left)) *\n Math.max(0, Math.min(a.top + a.height, b.top + b.height) - Math.max(a.top, b.top));\n\n/** Where the card goes for a highlighted box. Below, above, right, left (above first with side 'top'): the first\n * where the card fits inside the window and covers neither the target nor the parts the step keeps visible. When\n * none does (after the tour scrolled to make room, see makeRoom), the one that covers the least of the target, then\n * of those parts. Returns the card's box: it is placed at that box's top-left corner. */\nfunction placeCard(rect: Box | null, cardH: number, prefer: 'bottom' | 'top', area_?: { top: number; bottom: number }, cardW = 320, keep: Box[] = []) {\n const margin = typeof document === 'undefined' ? 12 : edge();\n const vw = typeof window === 'undefined' ? 0 : window.innerWidth;\n const vh = area_?.bottom ?? (typeof window === 'undefined' ? 0 : window.innerHeight);\n const vt = area_?.top ?? 0;\n if (!rect) {\n // No target: centered in the window.\n const box = { left: (vw - cardW) / 2, top: Math.max(vt + margin, (vt + vh) / 2 - cardH / 2), width: cardW, height: cardH };\n return { mode: 'center', box, fits: true };\n }\n const clampX = (x: number) => Math.max(margin, Math.min(vw - margin - cardW, x));\n const clampY = (y: number) => Math.max(vt + margin, Math.min(vh - margin - cardH, y));\n const midX = rect.left + rect.width / 2 - cardW / 2;\n const midY = rect.top + rect.height / 2 - cardH / 2;\n const at: Record<Side, { left: number; top: number }> = {\n bottom: { left: midX, top: rect.top + rect.height + GAP },\n top: { left: midX, top: rect.top - GAP - cardH },\n right: { left: rect.left + rect.width + GAP, top: midY },\n left: { left: rect.left - GAP - cardW, top: midY },\n };\n const order: Side[] = prefer === 'top' ? ['top', 'bottom', 'right', 'left'] : ['bottom', 'top', 'right', 'left'];\n const options = order.map((side) => {\n const want = at[side];\n // Along the target's edge the card may shift to stay inside the window; away from it, it must not.\n const box = { left: clampX(want.left), top: clampY(want.top), width: cardW, height: cardH };\n const inside = side === 'bottom' || side === 'top' ? box.top === want.top : box.left === want.left;\n const onTarget = area(box, rect);\n const onKept = keep.reduce((n, k) => n + area(box, k), 0);\n return { mode: side, box, fits: inside && !onTarget && !onKept, onTarget, onKept };\n });\n const best = options.find((o) => o.fits) ?? [...options].sort((x, y) => x.onTarget - y.onTarget || x.onKept - y.onKept)[0];\n return { mode: best.mode, box: best.box, fits: best.fits };\n}\n\n/** The first-use walkthrough: the page goes dark except the part being introduced, with a card beside it. */\nexport function Tour({ open, steps, onClose, skippable = true, step: controlled, onStepChange }: TourProps) {\n const [inner, setInner] = React.useState(0);\n const i = Math.max(0, Math.min(steps.length - 1, controlled ?? inner));\n const step = steps[i];\n const [rect, setRect] = React.useState<Box | null>(null);\n const [kept, setKept] = React.useState<Box[]>([]);\n const next = React.useRef<HTMLButtonElement>(null);\n const [cardH, setCardH] = React.useState(0);\n const [cardW, setCardW] = React.useState(320);\n const [wasOpen, setWasOpen] = React.useState(open);\n if (open !== wasOpen) {\n setWasOpen(open);\n if (open && controlled == null) setInner(0);\n }\n const go = (n: number) => {\n onStepChange?.(n);\n if (controlled == null) setInner(n);\n };\n const end = (why: 'done' | 'skip') => onClose?.(why);\n useReturnFocus(open);\n // A new step after 下一步 or 上一步: its count, title and text are read (focus stays on the button, which does not read\n // them). The first step is read as the dialog opens.\n const shownStep = React.useRef(-1);\n React.useEffect(() => {\n if (!open || !step) {\n shownStep.current = -1;\n return;\n }\n if (shownStep.current !== -1 && shownStep.current !== i)\n announce(tr('第 {a} 步,共 {b} 步', { a: i + 1, b: steps.length }) + tr('。') + step.title + tr('。') + step.text.replace(/`/g, ''));\n shownStep.current = i;\n }, [open, i, step, steps.length]);\n const cardEl = React.useRef<HTMLDivElement | null>(null);\n // Tab and Shift+Tab go round the card's buttons only. Base UI's popover leaves focus guards around the card (no\n // name) that let Tab reach the page; focus that gets out anyway (a click on the dimmed page) comes back to 下一步.\n const tabbables = () =>\n Array.from(\n cardEl.current?.querySelectorAll<HTMLElement>('button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])') ?? [],\n ).filter((e) => e.getClientRects().length > 0);\n const onTab = (e: React.KeyboardEvent) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey) return;\n const list = tabbables();\n if (!list.length) return;\n e.preventDefault();\n const at = list.indexOf(document.activeElement as HTMLElement);\n const to = at < 0 ? 0 : (at + (e.shiftKey ? -1 : 1) + list.length) % list.length;\n list[to].focus();\n };\n React.useEffect(() => {\n if (!open) return;\n const back = (e: FocusEvent) => {\n const box = cardEl.current;\n if (!box || !(e.target instanceof Node) || box.contains(e.target)) return;\n (next.current ?? tabbables()[0])?.focus();\n };\n document.addEventListener('focusin', back);\n return () => document.removeEventListener('focusin', back);\n }, [open]);\n\n // Follow the target while it moves (scrolling, layout changes).\n // Depends on the step's fields, not the object: inline steps arrays are new on every render.\n const target = step?.target;\n const pad = step?.padding ?? 6;\n // keepVisible as one stable value for the effect below (an inline array is new on every render).\n const keepList = step?.keepVisible == null ? [] : Array.isArray(step.keepVisible) ? step.keepVisible : [step.keepVisible];\n const keepKey = keepList.map((k) => (typeof k === 'string' ? k : '#')).join('|');\n const keepRef = React.useRef(keepList);\n React.useLayoutEffect(() => {\n keepRef.current = keepList;\n });\n const hasStep = !!step;\n React.useEffect(() => {\n if (!open || !hasStep) return;\n // A selector is looked up again until it appears (the target may render later), then kept.\n let el = findTarget(target);\n // Bring the target into view first; one taller than the window shows from its top. On a phone the target goes\n // to the top, just under the top bar, so the card fits below it instead of covering it. The jump is instant: the\n // modal's scroll lock stops a smooth scroll halfway; the spotlight's own transition shows the move.\n const tall = (el?.getBoundingClientRect().height ?? 0) > window.innerHeight;\n // A target as tall as the window leaves no room beside it: the card has to cover part of it.\n devWarn(\n el && el.getBoundingClientRect().height > window.innerHeight * 0.7,\n 'Tour',\n `第 ${i + 1} 步的目標「${target}」比視窗的 70% 高,說明卡只能蓋住它的一部分。請把 data-tour 放在較小的元素上,例如要說明的那張卡片或那一列,而不是整頁。`,\n );\n if (el instanceof HTMLElement && narrowNow()) {\n const keep = el.style.scrollMarginTop;\n el.style.scrollMarginTop = bounds(el).top + edge() + pad + 'px';\n el.scrollIntoView?.({ block: 'start', behavior: 'auto' });\n el.style.scrollMarginTop = keep;\n } else el?.scrollIntoView?.({ block: tall ? 'start' : 'center', behavior: 'auto' });\n let raf = 0;\n let last = '';\n const tick = () => {\n if (!el?.isConnected) el = findTarget(target);\n const r = el?.getBoundingClientRect();\n let v: Box | null = null;\n if (r && r.width) {\n const l = Math.max(3, r.left - pad);\n const t = Math.max(3, r.top - pad);\n v = {\n left: l,\n top: t,\n width: Math.max(0, Math.min(window.innerWidth - 3, r.right + pad) - l),\n height: Math.max(0, Math.min(window.innerHeight - 3, r.bottom + pad) - t),\n };\n }\n const ks: Box[] = [];\n for (const kt of keepRef.current) {\n const kr = findTarget(kt)?.getBoundingClientRect();\n if (kr && kr.width) ks.push({ left: kr.left, top: kr.top, width: kr.width, height: kr.height });\n }\n const k = JSON.stringify([v, ks]);\n if (k !== last) {\n last = k;\n setRect(v);\n setKept(ks);\n }\n raf = requestAnimationFrame(tick);\n };\n tick();\n return () => cancelAnimationFrame(raf);\n }, [open, hasStep, i, target, pad, keepKey]);\n\n // The card's height decides where it fits. The popup mounts after the first render (in a portal), so it is measured\n // through a callback ref when it appears, and again on every resize.\n const observer = React.useRef<ResizeObserver | null>(null);\n const card = React.useCallback((el: HTMLDivElement | null) => {\n cardEl.current = el;\n observer.current?.disconnect();\n observer.current = null;\n if (!el) return;\n const measure = () => {\n setCardH(el.offsetHeight);\n setCardW(el.offsetWidth);\n };\n measure();\n observer.current = new ResizeObserver(measure);\n observer.current.observe(el);\n }, []);\n\n // Make room for the card (per step, again when its height changes: its width, and so its height, depends on where it\n // goes): with no room above or below the target, the page\n // scrolls so the target's top sits just under the window's top when the target and the card fit together, card\n // below; when they do not (a target taller than the window), so the card fits above the target. The card then\n // covers no part of the target.\n const measured = cardH > 0;\n React.useEffect(() => {\n if (!open || !hasStep || !measured) return;\n const el = findTarget(target);\n if (!(el instanceof HTMLElement)) return;\n const ar = bounds(el);\n const m = edge();\n const r = el.getBoundingClientRect();\n const top = r.top - pad;\n const bottom = r.bottom + pad;\n // A side already fits: nothing to do.\n const spot = { left: r.left - pad, top, width: r.width + 2 * pad, height: bottom - top };\n if (placeCard(spot, cardH, step?.side ?? 'bottom', ar, cardW, kept).fits) return;\n const together = bottom - top + GAP + cardH + 2 * m <= ar.bottom - ar.top;\n const want = together ? ar.top + m + pad : ar.top + m + cardH + GAP + pad;\n // The nearest box that scrolls (AppShell's main), else the window, moves by exactly the difference.\n let box: HTMLElement | null = el.parentElement;\n while (box && !(/(auto|scroll)/.test(getComputedStyle(box).overflowY) && box.scrollHeight > box.clientHeight)) box = box.parentElement;\n const dy = r.top - want;\n if (box) box.scrollBy({ top: dy, behavior: 'auto' });\n else window.scrollBy({ top: dy, behavior: 'auto' });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- kept moves with every scroll; the room is made once per step\n }, [open, hasStep, i, target, pad, measured, cardH]);\n\n const room = open && step ? bounds(findTarget(step.target)) : undefined;\n const place = placeCard(rect, cardH, step?.side ?? 'bottom', room, cardW, kept);\n // The card's top-left corner: a point the popup hangs from (side bottom, aligned at its start).\n const ax = place.box.left;\n const ay = place.box.top;\n const anchor = React.useMemo(() => ({ getBoundingClientRect: () => new DOMRect(ax, ay, 0, 0) }), [ax, ay]);\n if (!open || !step) return null;\n const lastStep = i === steps.length - 1;\n return (\n <Popover.Root\n open\n modal\n onOpenChange={(_, details) => {\n if (details.reason === 'escape-key' && skippable) end('skip');\n }}\n >\n <Popover.Portal>\n <div className=\"ui-tour-layer\">\n <div className={cx('ui-tour-block', !rect && 'is-dim')} />\n {rect ? <div className=\"ui-tour-spot\" aria-hidden=\"true\" style={rect} /> : null}\n </div>\n <Popover.Positioner\n className=\"ui-float ui-tour-float\"\n anchor={anchor}\n side=\"bottom\"\n align=\"start\"\n sideOffset={0}\n // Where the card goes is worked out above (placeCard), already inside the window.\n collisionAvoidance={{ side: 'none', align: 'none', fallbackAxisSide: 'none' }}\n >\n <Popover.Popup ref={card} key={i} className=\"ui-tour-card\" data-placement={place.mode} initialFocus={next} onKeyDown={onTab}>\n {/* Taller than the window (phones): this part scrolls, the buttons stay at the bottom. */}\n <div className=\"ui-tour-body\">\n <div className=\"ui-tour-count\">\n {/* Shown 「1 / 5」, drawn by CSS; read and copied as 「第 1 步,共 5 步」, not 「1 斜線 5」. */}\n <span aria-hidden=\"true\">{seenOnly(tr('{n} / {total}', { n: '\\u0001', total: '\\u0002' }), [String(i + 1), String(steps.length)])}</span>\n <span className=\"ui-visually-hidden\">{tr('第 {a} 步,共 {b} 步', { a: i + 1, b: steps.length })}</span>\n </div>\n <Popover.Title className=\"ui-tour-title\">{step.title}</Popover.Title>\n <CodeText as=\"div\" className=\"ui-tour-text\" text={step.text} />\n </div>\n <div className=\"ui-tour-actions\">\n {skippable && !lastStep ? (\n <button type=\"button\" className=\"ui-link-btn is-muted\" onClick={() => end('skip')}>\n {tr('略過')}\n </button>\n ) : null}\n <span className=\"ui-tour-gap\" />\n {i > 0 ? <Button onClick={() => go(i - 1)}>{tr('上一步')}</Button> : null}\n <Button ref={next} variant=\"primary\" onClick={() => (lastStep ? end('done') : go(i + 1))}>\n {lastStep ? tr('完成') : tr('下一步')}\n </Button>\n </div>\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAyCA,MAAM,WAAW;;;;;AAMjB,SAAgB,QAAQ,KAAa;CACnC,MAAM,CAAC,MAAM,WAAW,MAAM,eAAe,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,KAAK;OAAM,SAAQ;OAAU,eAAgB,WAAW,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC;OACnF,UAAA,WAAW,GAAG,IAAI,IAAI,GAAG,KAAK;MACzB,CAAA;KACL;IACQ,CAAA,CAAA;GAvBgB,GAAA,CAuBhB;EACG,CAAA,CACN,EAAA,CAAA;CACJ,CAAA;AAElB"}
1
+ {"version":3,"file":"Tour.js","names":[],"sources":["../../../src/components/Tour/Tour.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useReturnFocus } from '../../internal/focus';\nimport { Popover } from '@base-ui/react/popover';\nimport { CodeText } from '../InlineCode/InlineCode';\nimport { Button } from '../Button/Button';\nimport { tr } from '../../i18n';\nimport { announce } from '../../announce';\nimport { cx, seenOnly, store, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport type { IconButtonHint } from '../IconButton/IconButton';\n\nexport interface TourStep {\n /** A data-tour name ('search' matches [data-tour=\"search\"]), a CSS selector (first visible match), a ref or an element.\n * Leave it out for a step in the middle of the screen. */\n target?: string | React.RefObject<Element | null> | Element;\n /** Names the part: 「搜尋」. */\n title: string;\n /** What it does, 1 short sentence; `backticks` are code. */\n text: string;\n /** Default 'bottom'. The card goes below, above, right or left of the target, the first side where it fits in the\n * window and covers neither the target nor `keepVisible` ('top' tries above first). With no such side the page\n * scrolls to make room; failing that, the side that covers the least of the target. */\n side?: 'bottom' | 'top';\n /** Space around the highlighted part in px. Default 6. */\n padding?: number;\n /** Parts the card must not cover either, e.g. the table the step talks about under a highlighted summary: same forms\n * as target. The card then goes to the next side that leaves them visible. */\n keepVisible?: TourStep['target'] | TourStep['target'][];\n}\n\nexport interface TourProps {\n open: boolean;\n steps: TourStep[];\n onClose?: (reason: 'done' | 'skip') => void;\n /** 「略過」 and Esc end the tour early. Default true. */\n skippable?: boolean;\n /** Controlled step index. */\n step?: number;\n onStepChange?: (index: number) => void;\n}\n\nconst TOUR_KEY = 'ui-tour:';\n\n/** Opens the tour once per browser: { open, start, close, seen, hint }. Pass close to Tour's onClose; start() shows\n * it again. hint(text) gives IconButton's `hint` for the button that starts the tour: a page that uses it shows the dot\n * and the bubble instead of opening the tour by itself. 「開始」 starts the tour; × and finishing it hide the hint for\n * good (the same record as seen). */\nexport function useTour(key: string) {\n const [seen, setSeen] = React.useState(() => !!store(TOUR_KEY + key));\n const [open, setOpen] = React.useState(false);\n // hint() is called while the page renders; the tour opens by itself after that render only when it was not.\n const hinted = React.useRef(false);\n React.useLayoutEffect(() => {\n // Known only after the page rendered: whether it uses hint().\n if (!store(TOUR_KEY + key) && !hinted.current) setOpen(true);\n }, [key]);\n const remember = () => {\n store(TOUR_KEY + key, '1');\n setSeen(true);\n };\n return {\n open,\n start: () => setOpen(true),\n close: () => {\n remember();\n setOpen(false);\n },\n seen,\n /** IconButton's `hint` for the button that starts this tour, or undefined once seen or while the tour is open. */\n hint: (text: string, action?: string): IconButtonHint | undefined => {\n hinted.current = true;\n if (seen || open) return undefined;\n return { text, action, onAction: () => setOpen(true), onDismiss: remember };\n },\n };\n}\n\nfunction findTarget(t: TourStep['target']): Element | null {\n if (!t) return null;\n if (typeof t === 'string') {\n const sel = /^[\\w-]+$/.test(t) && !/^(html|body|main|nav|header|footer|section|aside)$/.test(t) ? `[data-tour=\"${t}\"]` : t;\n return Array.from(document.querySelectorAll(sel)).find((e) => e.getClientRects().length > 0) ?? null;\n }\n return t instanceof Element ? t : t.current;\n}\n\ninterface Box {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nconst GAP = 12;\n\n/** The space kept between the card and the window edges: the --space-3 token. */\nfunction edge() {\n return parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--space-3')) || 12;\n}\n\nconst narrowNow = () => typeof window !== 'undefined' && window.innerWidth < 600;\n\n/** The part of the window between a phone's fixed top bar and bottom tab bar (when the target is not one of them):\n * the card stays inside it and never covers either bar. The whole window elsewhere. */\nfunction bounds(target: Element | null): { top: number; bottom: number } {\n const vh = typeof window === 'undefined' ? 0 : window.innerHeight;\n if (!narrowNow()) return { top: 0, bottom: vh };\n let top = 0;\n let bottom = vh;\n const head = document.querySelector('.ui-shell-top');\n const bar = document.querySelector('.ui-tabbar');\n if (head && !(target && head.contains(target))) {\n const r = head.getBoundingClientRect();\n if (r.height && r.bottom > 0 && r.bottom < vh / 2) top = r.bottom;\n }\n if (bar && !(target && bar.contains(target))) {\n const r = bar.getBoundingClientRect();\n if (r.height && r.top > vh / 2 && r.top < vh) bottom = r.top;\n }\n return { top, bottom };\n}\n\ntype Side = 'bottom' | 'top' | 'right' | 'left';\nconst area = (a: Box, b: Box) =>\n Math.max(0, Math.min(a.left + a.width, b.left + b.width) - Math.max(a.left, b.left)) *\n Math.max(0, Math.min(a.top + a.height, b.top + b.height) - Math.max(a.top, b.top));\n\n/** Where the card goes for a highlighted box. Below, above, right, left (above first with side 'top'): the first\n * where the card fits inside the window and covers neither the target nor the parts the step keeps visible. When\n * none does (after the tour scrolled to make room, see makeRoom), the one that covers the least of the target, then\n * of those parts. Returns the card's box: it is placed at that box's top-left corner. */\nfunction placeCard(rect: Box | null, cardH: number, prefer: 'bottom' | 'top', area_?: { top: number; bottom: number }, cardW = 320, keep: Box[] = []) {\n const margin = typeof document === 'undefined' ? 12 : edge();\n const vw = typeof window === 'undefined' ? 0 : window.innerWidth;\n const vh = area_?.bottom ?? (typeof window === 'undefined' ? 0 : window.innerHeight);\n const vt = area_?.top ?? 0;\n if (!rect) {\n // No target: centered in the window.\n const box = { left: (vw - cardW) / 2, top: Math.max(vt + margin, (vt + vh) / 2 - cardH / 2), width: cardW, height: cardH };\n return { mode: 'center', box, fits: true };\n }\n const clampX = (x: number) => Math.max(margin, Math.min(vw - margin - cardW, x));\n const clampY = (y: number) => Math.max(vt + margin, Math.min(vh - margin - cardH, y));\n const midX = rect.left + rect.width / 2 - cardW / 2;\n const midY = rect.top + rect.height / 2 - cardH / 2;\n const at: Record<Side, { left: number; top: number }> = {\n bottom: { left: midX, top: rect.top + rect.height + GAP },\n top: { left: midX, top: rect.top - GAP - cardH },\n right: { left: rect.left + rect.width + GAP, top: midY },\n left: { left: rect.left - GAP - cardW, top: midY },\n };\n const order: Side[] = prefer === 'top' ? ['top', 'bottom', 'right', 'left'] : ['bottom', 'top', 'right', 'left'];\n const options = order.map((side) => {\n const want = at[side];\n // Along the target's edge the card may shift to stay inside the window; away from it, it must not.\n const box = { left: clampX(want.left), top: clampY(want.top), width: cardW, height: cardH };\n const inside = side === 'bottom' || side === 'top' ? box.top === want.top : box.left === want.left;\n const onTarget = area(box, rect);\n const onKept = keep.reduce((n, k) => n + area(box, k), 0);\n return { mode: side, box, fits: inside && !onTarget && !onKept, onTarget, onKept };\n });\n const best = options.find((o) => o.fits) ?? [...options].sort((x, y) => x.onTarget - y.onTarget || x.onKept - y.onKept)[0];\n return { mode: best.mode, box: best.box, fits: best.fits };\n}\n\n/** The first-use walkthrough: the page goes dark except the part being introduced, with a card beside it. */\nexport function Tour({ open, steps, onClose, skippable = true, step: controlled, onStepChange }: TourProps) {\n const [inner, setInner] = React.useState(0);\n const i = Math.max(0, Math.min(steps.length - 1, controlled ?? inner));\n const step = steps[i];\n const [rect, setRect] = React.useState<Box | null>(null);\n const [kept, setKept] = React.useState<Box[]>([]);\n const next = React.useRef<HTMLButtonElement>(null);\n const [cardH, setCardH] = React.useState(0);\n const [cardW, setCardW] = React.useState(320);\n const [wasOpen, setWasOpen] = React.useState(open);\n if (open !== wasOpen) {\n setWasOpen(open);\n if (open && controlled == null) setInner(0);\n }\n const go = (n: number) => {\n onStepChange?.(n);\n if (controlled == null) setInner(n);\n };\n const end = (why: 'done' | 'skip') => onClose?.(why);\n useReturnFocus(open);\n // A new step after 下一步 or 上一步: its count, title and text are read (focus stays on the button, which does not read\n // them). The first step is read as the dialog opens.\n const shownStep = React.useRef(-1);\n React.useEffect(() => {\n if (!open || !step) {\n shownStep.current = -1;\n return;\n }\n if (shownStep.current !== -1 && shownStep.current !== i)\n announce(tr('第 {a} 步,共 {b} 步', { a: i + 1, b: steps.length }) + tr('。') + step.title + tr('。') + step.text.replace(/`/g, ''));\n shownStep.current = i;\n }, [open, i, step, steps.length]);\n const cardEl = React.useRef<HTMLDivElement | null>(null);\n // Tab and Shift+Tab go round the card's buttons only. Base UI's popover leaves focus guards around the card (no\n // name) that let Tab reach the page; focus that gets out anyway (a click on the dimmed page) comes back to 下一步.\n const tabbables = () =>\n Array.from(\n cardEl.current?.querySelectorAll<HTMLElement>('button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])') ?? [],\n ).filter((e) => e.getClientRects().length > 0);\n const onTab = (e: React.KeyboardEvent) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey) return;\n const list = tabbables();\n if (!list.length) return;\n e.preventDefault();\n const at = list.indexOf(document.activeElement as HTMLElement);\n const to = at < 0 ? 0 : (at + (e.shiftKey ? -1 : 1) + list.length) % list.length;\n list[to].focus();\n };\n React.useEffect(() => {\n if (!open) return;\n const back = (e: FocusEvent) => {\n const box = cardEl.current;\n if (!box || !(e.target instanceof Node) || box.contains(e.target)) return;\n (next.current ?? tabbables()[0])?.focus();\n };\n document.addEventListener('focusin', back);\n return () => document.removeEventListener('focusin', back);\n }, [open]);\n\n // Follow the target while it moves (scrolling, layout changes).\n // Depends on the step's fields, not the object: inline steps arrays are new on every render.\n const target = step?.target;\n const pad = step?.padding ?? 6;\n // keepVisible as one stable value for the effect below (an inline array is new on every render).\n const keepList = step?.keepVisible == null ? [] : Array.isArray(step.keepVisible) ? step.keepVisible : [step.keepVisible];\n const keepKey = keepList.map((k) => (typeof k === 'string' ? k : '#')).join('|');\n const keepRef = React.useRef(keepList);\n React.useLayoutEffect(() => {\n keepRef.current = keepList;\n });\n const hasStep = !!step;\n React.useEffect(() => {\n if (!open || !hasStep) return;\n // A selector is looked up again until it appears (the target may render later), then kept.\n let el = findTarget(target);\n // Bring the target into view first; one taller than the window shows from its top. On a phone the target goes\n // to the top, just under the top bar, so the card fits below it instead of covering it. The jump is instant: the\n // modal's scroll lock stops a smooth scroll halfway; the spotlight's own transition shows the move.\n const tall = (el?.getBoundingClientRect().height ?? 0) > window.innerHeight;\n // A target as tall as the window leaves no room beside it: the card has to cover part of it.\n devWarn(\n el && el.getBoundingClientRect().height > window.innerHeight * 0.7,\n 'Tour',\n `第 ${i + 1} 步的目標「${target}」比視窗的 70% 高,說明卡只能蓋住它的一部分。請把 data-tour 放在較小的元素上,例如要說明的那張卡片或那一列,而不是整頁。`,\n );\n if (el instanceof HTMLElement && narrowNow()) {\n const keep = el.style.scrollMarginTop;\n el.style.scrollMarginTop = bounds(el).top + edge() + pad + 'px';\n el.scrollIntoView?.({ block: 'start', behavior: 'auto' });\n el.style.scrollMarginTop = keep;\n } else el?.scrollIntoView?.({ block: tall ? 'start' : 'center', behavior: 'auto' });\n let raf = 0;\n let last = '';\n const tick = () => {\n if (!el?.isConnected) el = findTarget(target);\n const r = el?.getBoundingClientRect();\n let v: Box | null = null;\n if (r && r.width) {\n const l = Math.max(3, r.left - pad);\n const t = Math.max(3, r.top - pad);\n v = {\n left: l,\n top: t,\n width: Math.max(0, Math.min(window.innerWidth - 3, r.right + pad) - l),\n height: Math.max(0, Math.min(window.innerHeight - 3, r.bottom + pad) - t),\n };\n }\n const ks: Box[] = [];\n for (const kt of keepRef.current) {\n const kr = findTarget(kt)?.getBoundingClientRect();\n if (kr && kr.width) ks.push({ left: kr.left, top: kr.top, width: kr.width, height: kr.height });\n }\n const k = JSON.stringify([v, ks]);\n if (k !== last) {\n last = k;\n setRect(v);\n setKept(ks);\n }\n raf = requestAnimationFrame(tick);\n };\n tick();\n return () => cancelAnimationFrame(raf);\n }, [open, hasStep, i, target, pad, keepKey]);\n\n // The card's height decides where it fits. The popup mounts after the first render (in a portal), so it is measured\n // through a callback ref when it appears, and again on every resize.\n const observer = React.useRef<ResizeObserver | null>(null);\n const card = React.useCallback((el: HTMLDivElement | null) => {\n cardEl.current = el;\n observer.current?.disconnect();\n observer.current = null;\n if (!el) return;\n const measure = () => {\n setCardH(el.offsetHeight);\n setCardW(el.offsetWidth);\n };\n measure();\n observer.current = resizeObserver(measure);\n observer.current?.observe(el);\n }, []);\n\n // Make room for the card (per step, again when its height changes: its width, and so its height, depends on where it\n // goes): with no room above or below the target, the page\n // scrolls so the target's top sits just under the window's top when the target and the card fit together, card\n // below; when they do not (a target taller than the window), so the card fits above the target. The card then\n // covers no part of the target.\n const measured = cardH > 0;\n React.useEffect(() => {\n if (!open || !hasStep || !measured) return;\n const el = findTarget(target);\n if (!(el instanceof HTMLElement)) return;\n const ar = bounds(el);\n const m = edge();\n const r = el.getBoundingClientRect();\n const top = r.top - pad;\n const bottom = r.bottom + pad;\n // A side already fits: nothing to do.\n const spot = { left: r.left - pad, top, width: r.width + 2 * pad, height: bottom - top };\n if (placeCard(spot, cardH, step?.side ?? 'bottom', ar, cardW, kept).fits) return;\n const together = bottom - top + GAP + cardH + 2 * m <= ar.bottom - ar.top;\n const want = together ? ar.top + m + pad : ar.top + m + cardH + GAP + pad;\n // The nearest box that scrolls (AppShell's main), else the window, moves by exactly the difference.\n let box: HTMLElement | null = el.parentElement;\n while (box && !(/(auto|scroll)/.test(getComputedStyle(box).overflowY) && box.scrollHeight > box.clientHeight)) box = box.parentElement;\n const dy = r.top - want;\n if (box) box.scrollBy({ top: dy, behavior: 'auto' });\n else window.scrollBy({ top: dy, behavior: 'auto' });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- kept moves with every scroll; the room is made once per step\n }, [open, hasStep, i, target, pad, measured, cardH]);\n\n const room = open && step ? bounds(findTarget(step.target)) : undefined;\n const place = placeCard(rect, cardH, step?.side ?? 'bottom', room, cardW, kept);\n // The card's top-left corner: a point the popup hangs from (side bottom, aligned at its start).\n const ax = place.box.left;\n const ay = place.box.top;\n const anchor = React.useMemo(() => ({ getBoundingClientRect: () => new DOMRect(ax, ay, 0, 0) }), [ax, ay]);\n if (!open || !step) return null;\n const lastStep = i === steps.length - 1;\n return (\n <Popover.Root\n open\n modal\n onOpenChange={(_, details) => {\n if (details.reason === 'escape-key' && skippable) end('skip');\n }}\n >\n <Popover.Portal>\n <div className=\"ui-tour-layer\">\n <div className={cx('ui-tour-block', !rect && 'is-dim')} />\n {rect ? <div className=\"ui-tour-spot\" aria-hidden=\"true\" style={rect} /> : null}\n </div>\n <Popover.Positioner\n className=\"ui-float ui-tour-float\"\n anchor={anchor}\n side=\"bottom\"\n align=\"start\"\n sideOffset={0}\n // Where the card goes is worked out above (placeCard), already inside the window.\n collisionAvoidance={{ side: 'none', align: 'none', fallbackAxisSide: 'none' }}\n >\n <Popover.Popup ref={card} key={i} className=\"ui-tour-card\" data-placement={place.mode} initialFocus={next} onKeyDown={onTab}>\n {/* Taller than the window (phones): this part scrolls, the buttons stay at the bottom. */}\n <div className=\"ui-tour-body\">\n <div className=\"ui-tour-count\">\n {/* Shown 「1 / 5」, drawn by CSS; read and copied as 「第 1 步,共 5 步」, not 「1 斜線 5」. */}\n <span aria-hidden=\"true\">{seenOnly(tr('{n} / {total}', { n: '\\u0001', total: '\\u0002' }), [String(i + 1), String(steps.length)])}</span>\n <span className=\"ui-visually-hidden\">{tr('第 {a} 步,共 {b} 步', { a: i + 1, b: steps.length })}</span>\n </div>\n <Popover.Title className=\"ui-tour-title\">{step.title}</Popover.Title>\n <CodeText as=\"div\" className=\"ui-tour-text\" text={step.text} />\n </div>\n <div className=\"ui-tour-actions\">\n {skippable && !lastStep ? (\n <button type=\"button\" className=\"ui-link-btn is-muted\" onClick={() => end('skip')}>\n {tr('略過')}\n </button>\n ) : null}\n <span className=\"ui-tour-gap\" />\n {i > 0 ? <Button onClick={() => go(i - 1)}>{tr('上一步')}</Button> : null}\n <Button ref={next} variant=\"primary\" onClick={() => (lastStep ? end('done') : go(i + 1))}>\n {lastStep ? tr('完成') : tr('下一步')}\n </Button>\n </div>\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAyCA,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IAAI,CAAC;OAAI,UAAA,GAAG,KAAK;MAAU,CAAA,IAAI;MAClE,oBAAC,QAAD;OAAQ,KAAK;OAAM,SAAQ;OAAU,eAAgB,WAAW,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC;OACnF,UAAA,WAAW,GAAG,IAAI,IAAI,GAAG,KAAK;MACzB,CAAA;KACL;IACQ,CAAA,CAAA;GAvBgB,GAAA,CAuBhB;EACG,CAAA,CACN,EAAA,CAAA;CACJ,CAAA;AAElB"}
@@ -3,7 +3,7 @@ import { IconButton } from "../IconButton/IconButton.js";
3
3
  import { SearchField } from "../SearchField/SearchField.js";
4
4
  import { Breadcrumb } from "../Breadcrumb/Breadcrumb.js";
5
5
  import { Icon } from "../../icons/Icon.js";
6
- import { IS_MAC, cx, store } from "../../internal/util.js";
6
+ import { IS_MAC, cx, resizeObserver, store } from "../../internal/util.js";
7
7
  import { devWarn } from "../../internal/dev.js";
8
8
  import { tr } from "../../i18n.js";
9
9
  import { dropTransition } from "../../motion.js";
@@ -231,9 +231,9 @@ function TabRow(p) {
231
231
  if (el.offsetLeft < tr2.scrollLeft) tr2.scrollLeft = el.offsetLeft - 4;
232
232
  else if (el.offsetLeft + el.offsetWidth > tr2.scrollLeft + tr2.clientWidth) tr2.scrollLeft = el.offsetLeft + el.offsetWidth - tr2.clientWidth + 4;
233
233
  }
234
- const ro = new ResizeObserver(measure);
235
- ro.observe(tr2);
236
- return () => ro.disconnect();
234
+ const ro = resizeObserver(measure);
235
+ ro?.observe(tr2);
236
+ return () => ro?.disconnect();
237
237
  }, [
238
238
  p.active,
239
239
  p.ids,
@@ -478,9 +478,9 @@ function Workbench({ ref, ...p }) {
478
478
  measured: true
479
479
  });
480
480
  read();
481
- const ro = new ResizeObserver(read);
482
- ro.observe(el);
483
- return () => ro.disconnect();
481
+ const ro = resizeObserver(read);
482
+ ro?.observe(el);
483
+ return () => ro?.disconnect();
484
484
  }, []);
485
485
  React.useEffect(() => {
486
486
  store(key, JSON.stringify(lay));