@seanyeh77/ui 0.5.0 → 0.6.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.
@@ -44,6 +44,7 @@ const I18N = {
44
44
  更多操作: "More actions",
45
45
  更多: "More",
46
46
  左右滑動: "Scroll sideways",
47
+ 向右捲動: "Scroll right",
47
48
  筆: "rows",
48
49
  "C 語言": "C",
49
50
  程式語言: "Language",
@@ -401,4 +402,4 @@ const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a
401
402
  const dayAdd = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
402
403
  export { parseDate as a, addMessages as c, format as i, setLocale as l, fileSize as n, sameDay as o, fmtDate as r, I18N as s, dayAdd as t, tr as u };
403
404
 
404
- //# sourceMappingURL=format-entry-BWjH_kB_.js.map
405
+ //# sourceMappingURL=format-entry-CDWxD999.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-entry-CDWxD999.js","names":[],"sources":["../src/i18n.ts","../src/format.ts"],"sourcesContent":["/* ---------- i18n and formats ----------\n Every built-in string is the zh-TW text passed through tr(); other languages come from UI.addMessages().\n Dates and numbers go through UI.format, which uses Intl for the current locale. The zh-TW rules are the\n ones the design system chose; other locales use their own conventions from Intl. */\ninterface I18nState {\n locale: string;\n currency: string;\n messages: Record<string, Record<string, string>>;\n}\n\nexport const I18N: I18nState = {\n locale: 'zh-TW',\n currency: 'TWD',\n messages: {\n en: {\n 'Email 或帳號': 'Email or username',\n '{label}:{a} 到 {b}': '{label}: {a} to {b}',\n '{n} 個百分點': '{n} pts',\n 上一頁: 'Previous page',\n 上個月: 'Previous month',\n '上傳失敗,請再試一次。': 'Upload failed. Try again.',\n 下一頁: 'Next page',\n 下個月: 'Next month',\n 主要導覽: 'Main navigation',\n 主題: 'Theme',\n 今天: 'Today',\n 全選: 'Select all',\n 全部: 'All',\n 全部標為已讀: 'Mark all as read',\n '共 {n} 筆': '{n} items',\n 分頁: 'Pagination',\n 刪除: 'Delete',\n 危險操作: 'Danger zone',\n 取消選取: 'Clear selection',\n '可以直接輸入,例如 2026/11/14': 'Type a date, e.g. 2026/11/14',\n 回上一頁: 'Go back',\n 回首頁: 'Go home',\n '完成 ✓': 'Done ✓',\n 密碼: 'Password',\n 展開側邊欄: 'Expand sidebar',\n '已選 {n} 筆': '{n} selected',\n 帳號: 'Username',\n 強調色: 'Accent color',\n '忘記密碼?': 'Forgot password?',\n 找不到符合的選項: 'No matching options',\n '拖放檔案,或 ': 'Drop files here, or ',\n 搜尋: 'Search',\n 操作: 'Actions',\n 收合側邊欄: 'Collapse sidebar',\n 放棄: 'Discard',\n '放棄未儲存的變更?': 'Discard unsaved changes?',\n '新增「{q}」': 'Add “{q}”',\n '日期格式不正確,請寫成 2026/11/14': 'Invalid date. Use 2026/11/14.',\n 更多操作: 'More actions',\n 更多: 'More',\n 左右滑動: 'Scroll sideways',\n 向右捲動: 'Scroll right',\n 筆: 'rows',\n 'C 語言': 'C',\n 程式語言: 'Language',\n 全部頁面: 'All pages',\n '最近 30 天': 'Last 30 days',\n '最近 7 天': 'Last 7 days',\n 期間: 'Period',\n 未讀: 'Unread',\n 本月: 'This month',\n 沒有符合的資料: 'No matching data',\n 沒有通知: 'No notifications',\n 清除: 'Clear',\n 清除搜尋: 'Clear search',\n 登入: 'Sign in',\n 發生錯誤: 'Something went wrong',\n '移除 {name}': 'Remove {name}',\n '第 {a}–{b} 筆,共 {n} 筆': '{a}–{b} of {n}',\n 繼續編輯: 'Keep editing',\n '自訂強調色(色碼)': 'Custom accent color (hex)',\n '色碼格式不正確,例如 #2457d6': 'Invalid hex, e.g. #2457d6',\n 設定分類: 'Settings sections',\n 請輸入密碼: 'Enter your password',\n 請輸入帳號: 'Enter your username',\n 請選擇: 'Select',\n 路徑: 'Breadcrumb',\n 較上週: 'vs last week',\n 載入中: 'Loading',\n '輸入 # 加 6 碼': 'Enter # and 6 digits',\n 通知: 'Notifications',\n '通知,{n} 則未讀': 'Notifications, {n} unread',\n '選取第 {n} 筆': 'Select row {n}',\n 選擇日期: 'Choose date',\n 選擇期間: 'Choose period',\n 選擇檔案: 'choose files',\n 重試: 'Retry',\n 開啟日曆: 'Open calendar',\n 關閉: 'Close',\n '關閉後,剛才的修改不會保留。': 'If you close now, your changes will be lost.',\n 關閉提示: 'Dismiss',\n 隱藏密碼: 'Hide password',\n 顯示密碼: 'Show password',\n '(今天)': ' (today)',\n 伺服器暫時無法回應: 'The server is not responding',\n 找不到這個頁面: 'Page not found',\n 沒有權限查看這個頁面: 'You do not have access to this page',\n '網址可能打錯了,或這個頁面已經移除。': 'The address may be wrong, or the page has been removed.',\n '這個問題已經記錄下來,請稍後重新整理再試。': 'The problem has been logged. Refresh the page later.',\n '請向管理員申請權限,或切換成有權限的帳號。': 'Ask an admin for access, or switch to an account that has it.',\n 自動: 'Auto',\n 淺色: 'Light',\n 深色: 'Dark',\n 藍: 'Blue',\n 靛: 'Indigo',\n 紫: 'Purple',\n 桃紅: 'Pink',\n 紅: 'Red',\n 橘: 'Orange',\n 綠: 'Green',\n 青: 'Teal',\n 草稿: 'Draft',\n 進行中: 'In progress',\n 審核中: 'In review',\n 完成: 'Done',\n 失敗: 'Failed',\n 檢視: 'Views',\n '{n} / {total} 筆': '{n} / {total}',\n 欄位: 'Columns',\n 顯示的欄位: 'Visible columns',\n 清除篩選: 'Clear filters',\n 清除全部: 'Clear all',\n 篩選: 'Filter',\n 最低: 'Min',\n 最高: 'Max',\n '合計 {n} 筆': 'Total: {n}',\n 平均: 'Avg',\n '選取 {name}': 'Select {name}',\n '{n} 個新': '{n} new',\n '{n} 個檔案': '{n} files',\n '下載 {name}': 'Download {name}',\n '已選 {n} 個檔案': '{n} files selected',\n '共 {size}': '{size} total',\n 清除選取: 'Clear selection',\n 下載: 'Download',\n 全部展開: 'Expand all',\n 全部收合: 'Collapse all',\n 這裡還沒有檔案: 'No files here yet',\n 顯示全部: 'Show all',\n 收合: 'Show less',\n 依狀態篩選: 'Filter by status',\n 展開: 'Expand',\n 沒有項目: 'Nothing here',\n 即時: 'Live',\n 已過期: 'Stale',\n 離線: 'Offline',\n 切換專案: 'Switch project',\n '切換專案,目前是 {name}': 'Switch project, now {name}',\n 推測: 'Inferred',\n '{n} 個項目': '{n} items',\n '{a} 個項目使用,共 {b} 次': 'Used {b} times by {a} items',\n 共用項目: 'Shared',\n 次數越多線越粗: 'Thicker lines mean more often',\n 架構圖: 'Architecture',\n '{n} 次': '{n} calls',\n 原始碼: 'Source',\n '顯示全部 {n} 行': 'Show all {n} lines',\n '只顯示第 {n} 行前後': 'Show only around line {n}',\n '無法載入 {name} 的子項目': 'Could not load the children of {name}',\n '找不到符合「{q}」的結果': 'No results for “{q}”',\n 輸入名稱開始搜尋: 'Type a name to search',\n 搜尋中: 'Searching',\n 搜尋結果: 'Search results',\n 最近開啟: 'Recently opened',\n 選擇: 'Select',\n 打開: 'Open',\n 取消: 'Cancel',\n 略過: 'Skip',\n 上一步: 'Back',\n 下一步: 'Next',\n 建議修正: 'Suggested fix',\n 複製修正: 'Copy fix',\n 已複製: 'Copied',\n '原本:': 'Before: ',\n '改成:': 'After: ',\n 關閉說明: 'Close explanation',\n '(說明)': ' (explain)',\n '搜尋({k})': 'Search ({k})',\n 確定的關係: 'Confirmed',\n 推測的關係: 'Inferred',\n 外部項目: 'External',\n },\n },\n};\n\nfunction msgsFor(loc: string): Record<string, string> | null {\n return I18N.messages[loc] || I18N.messages[loc.split('-')[0]] || null;\n}\n\n/** Translates a built-in zh-TW string into the current locale; {name} placeholders take vars. */\nexport function tr(key: string, vars?: Record<string, string | number>): string {\n const m = I18N.locale.startsWith('zh') ? null : msgsFor(I18N.locale);\n const out = m?.[key] ?? key;\n return vars ? out.replace(/\\{(\\w+)\\}/g, (a, k: string) => (vars[k] !== undefined ? String(vars[k]) : a)) : out;\n}\n\n/** Switches the interface language and, optionally, the currency used by format.money. */\nexport function setLocale(locale: string, opts?: { currency?: string }): void {\n I18N.locale = locale || 'zh-TW';\n if (opts?.currency) I18N.currency = opts.currency;\n if (typeof document !== 'undefined') document.documentElement.setAttribute('lang', I18N.locale);\n}\n\n/** Adds or overrides translations for a locale. Keys are the zh-TW strings. */\nexport function addMessages(locale: string, dict: Record<string, string>): void {\n I18N.messages[locale] = { ...I18N.messages[locale], ...dict };\n}\n\nexport const isZhTW = (): boolean => /^zh-(TW|Hant)/i.test(I18N.locale);\n","import { I18N, isZhTW } from './i18n';\n\n/* Dates and numbers for the current locale (setLocale). zh-TW follows the design system's rules\n (2026/11/04(三), 24-hour clock, NT$ 1,280, 萬 and 億 in KPI cards); other locales use Intl's conventions. */\n\nexport type Decimals = number | 'money' | 'percent' | 'size' | 'count';\n\nconst DECIMALS = { money: 0, percent: 1, size: 1, count: 0 } as const;\n\nconst pad2 = (n: number): string => String(n).padStart(2, '0');\n\nfunction locale(): string {\n return I18N.locale;\n}\n\n/** zh-TW: 2026/11/04(三). Other locales: their short date with weekday. */\nfunction date(d: Date | null | undefined, o: { weekday?: boolean; long?: boolean } = {}): string {\n if (!d) return '';\n const wd = o.weekday !== false;\n if (o.long) return new Intl.DateTimeFormat(I18N.locale, { year: 'numeric', month: 'long', day: 'numeric', weekday: wd ? 'long' : undefined }).format(d);\n if (isZhTW()) return fmtDate(d) + (wd ? `(${new Intl.DateTimeFormat('zh-TW', { weekday: 'narrow' }).format(d)})` : '');\n return new Intl.DateTimeFormat(I18N.locale, { year: 'numeric', month: '2-digit', day: '2-digit', weekday: wd ? 'short' : undefined }).format(d);\n}\n\n/** zh-TW: 24-hour 15:57. Other locales: their own clock. */\nfunction time(d: Date | null | undefined): string {\n if (!d) return '';\n return new Intl.DateTimeFormat(\n I18N.locale,\n isZhTW() ? { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' } : { hour: 'numeric', minute: '2-digit' },\n ).format(d);\n}\n\nfunction dateTime(d: Date | null | undefined, o?: { weekday?: boolean }): string {\n return d ? `${date(d, o)} ${time(d)}` : '';\n}\n\n/** Within 7 days: 「2 小時前」、「昨天」. Older: full date and time. Pass now to test. */\nfunction relative(d: Date | null | undefined, now: Date = new Date()): string {\n if (!d) return '';\n const s = (now.getTime() - d.getTime()) / 1000;\n if (s < 0 || s >= 604800) return dateTime(d);\n const rt = new Intl.RelativeTimeFormat(I18N.locale, { numeric: 'auto' });\n if (s < 60) return rt.format(0, 'second');\n if (s < 3600) return rt.format(-Math.floor(s / 60), 'minute');\n if (s < 86400) return rt.format(-Math.floor(s / 3600), 'hour');\n return rt.format(-Math.floor(s / 86400), 'day');\n}\n\nfunction month(d: Date): string {\n return new Intl.DateTimeFormat(I18N.locale, { year: 'numeric', month: 'long' }).format(d);\n}\n\n/** Week starts on Sunday for zh-TW; other locales use Intl's week info when the browser has it. */\nfunction firstDay(): number {\n if (isZhTW()) return 0;\n try {\n const l = new Intl.Locale(I18N.locale) as Intl.Locale & { getWeekInfo?: () => { firstDay: number }; weekInfo?: { firstDay: number } };\n const w = l.getWeekInfo ? l.getWeekInfo() : l.weekInfo;\n if (w?.firstDay) return w.firstDay % 7;\n } catch {\n /* older browsers have no week info */\n }\n return 0;\n}\n\n/** Narrow weekday names, starting from firstDay(). */\nfunction weekdays(): string[] {\n const fd = firstDay();\n const f = new Intl.DateTimeFormat(I18N.locale, { weekday: 'narrow' });\n // 2026/11/01 is a Sunday.\n return Array.from({ length: 7 }, (_, i) => f.format(new Date(2026, 10, 1 + ((fd + i) % 7))));\n}\n\n/** Decimals by unit: money 0, percent 1, size 1, count 0; pass a number to force it. */\nfunction number(v: number, dec?: Decimals): string {\n const dd = typeof dec === 'number' ? dec : dec ? DECIMALS[dec] : 0;\n return new Intl.NumberFormat(I18N.locale, { minimumFractionDigits: dd, maximumFractionDigits: dd }).format(v);\n}\n\nfunction percent(v: number, dec = 1): string {\n return new Intl.NumberFormat(I18N.locale, { style: 'percent', minimumFractionDigits: dec, maximumFractionDigits: dec }).format(v / 100);\n}\n\n/** Only KPI cards abbreviate: 1,284 萬 in zh-TW (萬、億), 12.8M in English.\n * like: format v with the unit and decimals that `like` gets, so a counting KPI keeps its width. */\nfunction compact(v: number, like?: number): string {\n const ref = like ?? v;\n if (Math.abs(ref) < 1e4) return number(v);\n if (/^zh/i.test(I18N.locale)) {\n const a = Math.abs(ref);\n const [unit, div, maxDec] = a >= 1e8 ? (['億', 1e8, 2] as const) : (['萬', 1e4, 1] as const);\n const finalStr = new Intl.NumberFormat(I18N.locale, { maximumFractionDigits: maxDec }).format(a / div);\n const sign = v < 0 ? '-' : '';\n if (like === undefined) return `${sign}${finalStr} ${unit}`;\n const digits = (finalStr.split('.')[1] || '').length;\n return `${sign}${new Intl.NumberFormat(I18N.locale, { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(Math.abs(v) / div)} ${unit}`;\n }\n const nf = new Intl.NumberFormat(I18N.locale, { notation: 'compact', maximumFractionDigits: 1 });\n if (like === undefined) return nf.format(v);\n const parts = nf.formatToParts(ref);\n let num = '';\n let dec = '';\n for (const pt of parts) {\n if (pt.type === 'integer') num += pt.value;\n if (pt.type === 'fraction') {\n num += '.' + pt.value;\n dec = pt.value;\n }\n }\n const mant = parseFloat(num) || 1;\n const scale = 10 ** Math.round(Math.log10(Math.abs(ref) / mant));\n const inner = new Intl.NumberFormat(I18N.locale, { minimumFractionDigits: dec.length, maximumFractionDigits: dec.length }).format(Math.abs(v) / scale);\n let done = false;\n const body = parts\n .map((pt) => {\n if (pt.type === 'integer' || pt.type === 'group' || pt.type === 'decimal' || pt.type === 'fraction') {\n if (done) return '';\n done = true;\n return inner;\n }\n return pt.value;\n })\n .join('');\n return (v < 0 && ref >= 0 ? '-' : '') + body;\n}\n\n/** zh-TW with TWD: NT$ 1,280, negatives -NT$ 1,280. Other locales and currencies: Intl's own symbol and order. */\nfunction money(v: number, o: { currency?: string; compact?: boolean; like?: number } = {}): string {\n const cur = o.currency || I18N.currency;\n const body = o.compact ? compact(Math.abs(v), o.like !== undefined ? Math.abs(o.like) : undefined) : number(Math.abs(v), 'money');\n if (isZhTW() && cur === 'TWD') return `${v < 0 ? '-' : ''}NT$ ${body}`;\n if (o.compact) return `${v < 0 ? '-' : ''}${body} ${cur}`;\n return new Intl.NumberFormat(I18N.locale, {\n style: 'currency',\n currency: cur,\n currencyDisplay: 'narrowSymbol',\n minimumFractionDigits: 0,\n maximumFractionDigits: cur === 'TWD' || cur === 'JPY' ? 0 : 2,\n }).format(v);\n}\n\n/** Bytes to 「186 KB」「54.9 MB」「1.2 GB」. */\nexport function fileSize(b: number | null | undefined): string {\n if (b == null || Number.isNaN(b)) return '';\n if (b < 1048576) return number(Math.max(1, Math.round(b / 1024))) + ' KB';\n if (b < 1073741824) return number(b / 1048576, 1) + ' MB';\n return number(b / 1073741824, 1) + ' GB';\n}\n\n/** Shortens a path: keeps the first segment and the last two, 「src/…/hooks/ops.c:58」. */\nfunction path(p: string | null | undefined, o: { head?: number; tail?: number } = {}): string {\n const head = o.head ?? 1;\n const tail = o.tail ?? 2;\n const parts = String(p ?? '').split('/');\n return parts.length > head + tail ? `${parts.slice(0, head).join('/')}/…/${parts.slice(-tail).join('/')}` : String(p ?? '');\n}\n\n/** Every date, number, amount, size and path shown in the UI goes through these. */\nexport const format = { locale, date, time, dateTime, relative, month, weekdays, firstDay, number, percent, compact, money, fileSize, path };\n\n/* Calendar helpers (local dates, no time). */\nexport const fmtDate = (d: Date | null | undefined): string => (d ? `${d.getFullYear()}/${pad2(d.getMonth() + 1)}/${pad2(d.getDate())}` : '');\n\nexport function parseDate(s: string | null | undefined): Date | null {\n const m = /^(\\d{4})\\/(\\d{1,2})\\/(\\d{1,2})$/.exec(s || '');\n if (!m) return null;\n const d = new Date(+m[1], +m[2] - 1, +m[3]);\n return d.getMonth() === +m[2] - 1 ? d : null;\n}\n\nexport const sameDay = (a: Date | null | undefined, b: Date | null | undefined): boolean =>\n !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();\n\nexport const dayAdd = (d: Date, n: number): Date => new Date(d.getFullYear(),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A2C;CACnE,MAAM,IAAI,kCAAkC,KAAK,KAAK,EAAE;CACxD,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,IAAI,IAAI,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE;CAC1C,OAAO,EAAE,SAAS,MAAM,CAAC,EAAE,KAAK,IAAI,IAAI;AAC1C;AAEA,MAAa,WAAW,GAA4B,MAClD,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,MAAM,EAAE,YAAY,KAAK,EAAE,SAAS,MAAM,EAAE,SAAS,KAAK,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAElH,MAAa,UAAU,GAAS,MAAoB,IAAI,KAAK,EAAE,YAAY,GAAG,EAAE,SAAS,GAAG,EAAE,QAAQ,IAAI,CAAC"}
package/dist/format.js CHANGED
@@ -1 +1 @@
1
- export { c as addMessages, i as format, l as setLocale, u as t } from "./format-entry-BWjH_kB_.js";
1
+ export { c as addMessages, i as format, l as setLocale, u as t } from "./format-entry-CDWxD999.js";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { a as parseDate, c as addMessages, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-BWjH_kB_.js";
2
+ import { a as parseDate, c as addMessages, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-CDWxD999.js";
3
3
  import * as React from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
@@ -575,16 +575,31 @@ function Breadcrumb({ items, className }) {
575
575
  });
576
576
  }
577
577
  // src/components/Tooltip/Tooltip.tsx
578
+ const openNow = /* @__PURE__ */ new Set();
578
579
  /** Dark label above the element (below when there is no room), with an arrow. Appears at once on hover and focus. */
579
580
  function Tooltip({ label, side = "top", describe = true, wrap = false, disabled = false, children }) {
580
581
  const id = React.useId();
582
+ const [open, setOpen] = React.useState(false);
583
+ const close = React.useCallback(() => setOpen(false), []);
584
+ const shown = open && !disabled;
585
+ React.useEffect(() => {
586
+ if (!shown) return;
587
+ for (const other of openNow) if (other !== close) other();
588
+ openNow.add(close);
589
+ return () => {
590
+ openNow.delete(close);
591
+ };
592
+ }, [shown, close]);
581
593
  return /* @__PURE__ */ jsxs(Tooltip$1.Root, {
582
594
  disabled,
595
+ open: shown,
596
+ onOpenChange: setOpen,
583
597
  children: [
584
598
  /* @__PURE__ */ jsx(Tooltip$1.Trigger, {
585
599
  delay: 0,
586
600
  render: children,
587
- "aria-describedby": describe && !disabled ? id : void 0
601
+ "aria-describedby": describe && !disabled ? id : void 0,
602
+ onBlur: close
588
603
  }),
589
604
  describe && !disabled ? /* @__PURE__ */ jsx("span", {
590
605
  id,
@@ -1699,14 +1714,21 @@ function Checkbox({ checked, onChange, label, disabled, className, ...aria }) {
1699
1714
  // src/components/InlineCode/InlineCode.tsx
1700
1715
  /** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link. */
1701
1716
  function InlineCode({ children, href, onClick, className }) {
1702
- const cls = cx("ui-code", (href || onClick) && "is-link", typeof children === "string" && children.length <= 24 && "is-short", className);
1717
+ const [inline, setInline] = React.useState(false);
1718
+ const link = React.useCallback((el) => {
1719
+ const par = el?.parentNode;
1720
+ setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));
1721
+ }, []);
1722
+ const cls = cx("ui-code", (href || onClick) && "is-link", (href || onClick) && inline && "is-inline", typeof children === "string" && children.length <= 24 && "is-short", className);
1703
1723
  if (href) return /* @__PURE__ */ jsx("a", {
1724
+ ref: link,
1704
1725
  className: cls,
1705
1726
  href,
1706
1727
  onClick,
1707
1728
  children
1708
1729
  });
1709
1730
  if (onClick) return /* @__PURE__ */ jsx("button", {
1731
+ ref: link,
1710
1732
  type: "button",
1711
1733
  className: cls,
1712
1734
  onClick,
@@ -1810,6 +1832,29 @@ const tokenize = (lines, lang) => {
1810
1832
  });
1811
1833
  };
1812
1834
  // src/components/CodeView/CodeView.tsx
1835
+ const OPS = /(->|::|==|!=|<=|>=|&&|\|\||\+\+|--|<<|>>|=>|\+=|-=|\*=|\/=)/;
1836
+ const AFTER = /([,.([{;])/;
1837
+ /** A piece of code with soft break points after commas, dots and opening brackets, and operators kept together. */
1838
+ function breakable(text) {
1839
+ if (!OPS.test(text) && !AFTER.test(text)) return text;
1840
+ const out = [];
1841
+ text.split(OPS).forEach((part, i) => {
1842
+ if (!part) return;
1843
+ if (i % 2) {
1844
+ out.push(/* @__PURE__ */ jsx("span", {
1845
+ className: "ui-cv-op",
1846
+ children: part
1847
+ }, i), /* @__PURE__ */ jsx("wbr", {}, i + "w"));
1848
+ return;
1849
+ }
1850
+ part.split(AFTER).forEach((bit, k) => {
1851
+ if (!bit) return;
1852
+ out.push(bit);
1853
+ if (k % 2) out.push(/* @__PURE__ */ jsx("wbr", {}, i + "." + k));
1854
+ });
1855
+ });
1856
+ return out;
1857
+ }
1813
1858
  /** Source with line numbers and an optional target line: soft accent background, long lines wrap, light syntax colors. */
1814
1859
  function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile, title, language, languageLabel, highlight = true, tokenizer = tokenize, maxHeight, className }) {
1815
1860
  const lines = React.useMemo(() => String(code || "").replace(/\n$/, "").split("\n"), [code]);
@@ -1862,8 +1907,8 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
1862
1907
  className: "ui-cv-text",
1863
1908
  children: toks[i].map(([cls, text], j) => cls ? /* @__PURE__ */ jsx("span", {
1864
1909
  className: cls,
1865
- children: text
1866
- }, j) : text)
1910
+ children: breakable(text)
1911
+ }, j) : /* @__PURE__ */ jsx(React.Fragment, { children: breakable(text) }, j))
1867
1912
  })]
1868
1913
  }, i));
1869
1914
  }
@@ -2082,10 +2127,10 @@ function CommandPalette(props) {
2082
2127
  className: "ui-pal-text",
2083
2128
  children: [/* @__PURE__ */ jsxs("span", {
2084
2129
  className: "ui-pal-line",
2085
- children: [labelOf(it, at), it.kind ? /* @__PURE__ */ jsx("span", {
2130
+ children: [it.kind ? /* @__PURE__ */ jsx("span", {
2086
2131
  className: "ui-visually-hidden",
2087
- children: "," + it.kind
2088
- }) : null]
2132
+ children: it.kind + " "
2133
+ }) : null, labelOf(it, at)]
2089
2134
  }), it.detail ? /* @__PURE__ */ jsx(CodeText, {
2090
2135
  className: "ui-pal-detail",
2091
2136
  text: it.detail
@@ -2274,15 +2319,17 @@ function useScrollHint() {
2274
2319
  measure
2275
2320
  };
2276
2321
  }
2277
- /** 「→ 左右滑動」 under the box, right-aligned. Hidden after the first sideways scroll but keeps its line, so nothing below jumps. */
2322
+ /** 「→ 左右滑動」 (touch) or 「→ 向右捲動」 (mouse, trackpad) under the box, right-aligned. Hidden after the first sideways
2323
+ * scroll but keeps its line, so nothing below jumps. */
2278
2324
  function ScrollHint({ show, done }) {
2325
+ const touch = useMedia("(pointer: coarse)");
2279
2326
  return show ? /* @__PURE__ */ jsxs("span", {
2280
2327
  className: cx("ui-scroll-hint", done && "is-done"),
2281
2328
  "aria-hidden": "true",
2282
2329
  children: [/* @__PURE__ */ jsx(Icon, {
2283
2330
  name: "arrow-right",
2284
2331
  size: 14
2285
- }), tr("左右滑動")]
2332
+ }), touch ? tr("左右滑動") : tr("向右捲動")]
2286
2333
  }) : null;
2287
2334
  }
2288
2335
  // src/components/DataTable/filters.ts
@@ -3950,7 +3997,7 @@ function LayerGraph(p) {
3950
3997
  }
3951
3998
  const layers = [...byLayer.keys()].sort((a, b) => a - b);
3952
3999
  const cols = Math.max(1, ...layers.map((l) => byLayer.get(l)?.length ?? 0));
3953
- const W = 32 + cols * NW + (cols - 1) * COL;
4000
+ let W = 32 + cols * NW + (cols - 1) * COL;
3954
4001
  const H = 32 + layers.length * NH + Math.max(0, layers.length - 1) * GAP;
3955
4002
  const pos = {};
3956
4003
  const layerIndex = {};
@@ -3967,13 +4014,30 @@ function LayerGraph(p) {
3967
4014
  });
3968
4015
  const maxSize = Math.max(1, ...main.map((n) => sizeOf(n) || 0));
3969
4016
  const maxCount = Math.max(1, ...edges.map((e) => e.count || 0));
4017
+ const isUp = (e) => !!pos[e.from] && !!pos[e.to] && layerIndex[e.to] < layerIndex[e.from];
3970
4018
  const outs = {};
3971
4019
  const ins = {};
4020
+ const upOut = {};
4021
+ const upIn = {};
3972
4022
  for (const e of edges) {
3973
4023
  if (!pos[e.from] || !pos[e.to]) continue;
4024
+ if (isUp(e)) {
4025
+ (upOut[e.from] ??= []).push(e);
4026
+ (upIn[e.to] ??= []).push(e);
4027
+ continue;
4028
+ }
3974
4029
  (outs[e.from] ??= []).push(e);
3975
4030
  (ins[e.to] ??= []).push(e);
3976
4031
  }
4032
+ const ups = edges.filter(isUp);
4033
+ const rowOf = (id) => byLayer.get(layers[layerIndex[id]]) ?? [];
4034
+ const rightmost = (id) => rowOf(id)[rowOf(id).length - 1]?.id === id;
4035
+ const leftmost = (id) => rowOf(id)[0]?.id === id;
4036
+ const onLeft = (e) => !rightmost(e.to) && leftmost(e.to);
4037
+ const upsL = ups.filter(onLeft);
4038
+ const upsR = ups.filter((e) => !onLeft(e));
4039
+ const LANE = 20;
4040
+ const LANE_STEP = 12;
3977
4041
  for (const k in outs) outs[k].sort((a, b) => pos[a.to].x - pos[b.to].x);
3978
4042
  for (const k in ins) ins[k].sort((a, b) => pos[a.from].x - pos[b.from].x);
3979
4043
  const edgeId = (e) => e.id ?? `${e.from}->${e.to}`;
@@ -3993,6 +4057,22 @@ function LayerGraph(p) {
3993
4057
  };
3994
4058
  const nameOf = (id) => all.find((n) => n.id === id)?.name || id;
3995
4059
  const countText = (e) => (p.countLabel ?? tr("{n} 次")).replace("{n}", String(e.count ?? 0));
4060
+ const upW = (list) => Math.max(0, ...list.map((e) => Math.ceil(Math.max(labelWidth(e.inferred ? e.label || p.inferredLabel || tr("推測") : ""), labelWidth(countText(e))))));
4061
+ if (upsL.length) {
4062
+ const left0 = Math.min(...main.map((n) => pos[n.id].x));
4063
+ const shift = Math.max(0, PAD + upW(upsL) + 8 + (upsL.length - 1) * LANE_STEP + LANE - left0);
4064
+ for (const id in pos) pos[id] = {
4065
+ x: pos[id].x + shift,
4066
+ y: pos[id].y
4067
+ };
4068
+ W += shift;
4069
+ }
4070
+ const boxesLeft = Math.min(...main.map((n) => pos[n.id].x));
4071
+ const boxesRight = Math.max(0, ...main.map((n) => pos[n.id].x + NW));
4072
+ const laneX = (e) => onLeft(e) ? boxesLeft - LANE - upsL.indexOf(e) * LANE_STEP : boxesRight + LANE + upsR.indexOf(e) * LANE_STEP;
4073
+ const upLabelX = boxesRight + LANE + Math.max(0, upsR.length - 1) * LANE_STEP + 8;
4074
+ const upLabelEndL = boxesLeft - LANE - Math.max(0, upsL.length - 1) * LANE_STEP - 8;
4075
+ if (upsR.length) W = Math.max(W, upLabelX + upW(upsR) + PAD);
3996
4076
  const choose = (e) => {
3997
4077
  const id = edgeId(e);
3998
4078
  const next = p.selectedEdge === id ? null : id;
@@ -4002,47 +4082,148 @@ function LayerGraph(p) {
4002
4082
  const paths = [];
4003
4083
  const labels = [];
4004
4084
  const marks = [];
4085
+ const runs = [];
4005
4086
  const arrows = [];
4006
4087
  const hitPaths = [];
4007
4088
  edges.forEach((e, idx) => {
4008
4089
  const a = pos[e.from];
4009
4090
  const b = pos[e.to];
4010
4091
  if (!a || !b) return;
4011
- const oi = outs[e.from].indexOf(e);
4012
- const on = outs[e.from].length;
4013
- const ii = ins[e.to].indexOf(e);
4014
- const inn = ins[e.to].length;
4015
- const sx = Math.round(a.x + NW * (oi + 1) / (on + 1));
4016
- const sy = a.y + NH;
4017
- const tx = Math.round(b.x + NW * (ii + 1) / (inn + 1));
4018
- const ty = b.y;
4019
- const off = (oi - (on - 1) / 2) * 6;
4020
- const y1 = sy + GAP / 2 + off;
4092
+ const r = related(e);
4093
+ const dim = focus && !r;
4094
+ const picked = e === selEdge;
4095
+ const hovered = !!pickEdge && hover === edgeId(e) && !r;
4096
+ const up = isUp(e);
4021
4097
  let pts;
4022
- if (layerIndex[e.to] - layerIndex[e.from] > 1) {
4023
- const next = (byLayer.get(layers[layerIndex[e.from] + 1]) ?? []).map((n) => pos[n.id]);
4024
- const mid = (sx + tx) / 2;
4025
- const chans = [next[0].x - COL / 2, ...next.map((q) => q.x + NW + COL / 2)].map((c) => Math.max(PAD / 2, Math.min(W - PAD / 2, c)));
4026
- const chx = chans.reduce((best, c) => Math.abs(c - mid) < Math.abs(best - mid) ? c : best, chans[0]) + off;
4027
- const y2 = ty - GAP / 2 + off;
4028
- pts = [
4098
+ let tx;
4099
+ let ty;
4100
+ let arrow;
4101
+ let inn = 1;
4102
+ if (up) {
4103
+ const lx = laneX(e);
4104
+ const L = onLeft(e);
4105
+ const si = upOut[e.from].indexOf(e);
4106
+ const sn = upOut[e.from].length;
4107
+ const ti = upIn[e.to].indexOf(e);
4108
+ const tn = upIn[e.to].length;
4109
+ const start = [];
4110
+ let y0;
4111
+ if (L ? leftmost(e.from) : rightmost(e.from)) {
4112
+ y0 = Math.round(a.y + NH / 2 + (si - (sn - 1) / 2) * 10);
4113
+ start.push([L ? a.x : a.x + NW, y0], [lx, y0]);
4114
+ } else {
4115
+ const px = L ? a.x + 20 + si * 10 : a.x + NW - 20 - si * 10;
4116
+ y0 = a.y - 12 - si * 6;
4117
+ start.push([px, a.y], [px, y0], [lx, y0]);
4118
+ }
4119
+ let y1;
4120
+ if (L || rightmost(e.to)) {
4121
+ y1 = Math.round(b.y + NH / 2 + (ti - (tn - 1) / 2) * 10);
4122
+ tx = L ? b.x : b.x + NW;
4123
+ ty = y1;
4124
+ const back = L ? tx - 9 : tx + 9;
4125
+ pts = [
4126
+ ...start,
4127
+ [lx, y1],
4128
+ [back, y1]
4129
+ ];
4130
+ arrow = `M${back} ${ty - 5} L${back} ${ty + 5} L${tx} ${ty} Z`;
4131
+ arrows.push([
4132
+ Math.min(tx, back),
4133
+ Math.max(tx, back),
4134
+ ty - 5,
4135
+ ty + 5
4136
+ ]);
4137
+ runs.push([
4138
+ Math.min(tx, lx),
4139
+ Math.max(tx, lx),
4140
+ y1 - 3,
4141
+ y1 + 3
4142
+ ]);
4143
+ } else {
4144
+ tx = b.x + NW - 20 - ti * 10;
4145
+ y1 = b.y + NH + 12 + ti * 6;
4146
+ ty = b.y + NH;
4147
+ pts = [
4148
+ ...start,
4149
+ [lx, y1],
4150
+ [tx, y1],
4151
+ [tx, ty + 9]
4152
+ ];
4153
+ arrow = `M${tx - 5} ${ty + 9} L${tx + 5} ${ty + 9} L${tx} ${ty} Z`;
4154
+ arrows.push([
4155
+ tx - 5,
4156
+ tx + 5,
4157
+ ty,
4158
+ ty + 9
4159
+ ]);
4160
+ runs.push([
4161
+ tx,
4162
+ lx,
4163
+ y1 - 3,
4164
+ y1 + 3
4165
+ ]);
4166
+ }
4167
+ const sx0 = start[start.length - 2][0];
4168
+ runs.push([
4169
+ Math.min(sx0, lx),
4170
+ Math.max(sx0, lx),
4171
+ y0 - 3,
4172
+ y0 + 3
4173
+ ]);
4174
+ if (e.inferred || r) {
4175
+ const text = e.inferred ? e.label || p.inferredLabel || tr("推測") : countText(e);
4176
+ marks.push({
4177
+ idx,
4178
+ e,
4179
+ text,
4180
+ tx: L ? upLabelEndL : upLabelX,
4181
+ ty: Math.round((y0 + y1) / 2),
4182
+ left: L,
4183
+ r,
4184
+ dim,
4185
+ up: true
4186
+ });
4187
+ }
4188
+ } else {
4189
+ const oi = outs[e.from].indexOf(e);
4190
+ const on = outs[e.from].length;
4191
+ const ii = ins[e.to].indexOf(e);
4192
+ inn = ins[e.to].length;
4193
+ const sx = Math.round(a.x + NW * (oi + 1) / (on + 1));
4194
+ const sy = a.y + NH;
4195
+ tx = Math.round(b.x + NW * (ii + 1) / (inn + 1));
4196
+ ty = b.y;
4197
+ const off = (oi - (on - 1) / 2) * 6;
4198
+ const y1 = sy + GAP / 2 + off;
4199
+ if (layerIndex[e.to] - layerIndex[e.from] > 1) {
4200
+ const next = (byLayer.get(layers[layerIndex[e.from] + 1]) ?? []).map((n) => pos[n.id]);
4201
+ const mid = (sx + tx) / 2;
4202
+ const chans = [next[0].x - COL / 2, ...next.map((q) => q.x + NW + COL / 2)].map((c) => Math.max(PAD / 2, Math.min(W - PAD / 2, c)));
4203
+ const chx = chans.reduce((best, c) => Math.abs(c - mid) < Math.abs(best - mid) ? c : best, chans[0]) + off;
4204
+ const y2 = ty - GAP / 2 + off;
4205
+ pts = [
4206
+ [sx, sy],
4207
+ [sx, y1],
4208
+ [chx, y1],
4209
+ [chx, y2],
4210
+ [tx, y2],
4211
+ [tx, ty - 8]
4212
+ ];
4213
+ } else pts = [
4029
4214
  [sx, sy],
4030
4215
  [sx, y1],
4031
- [chx, y1],
4032
- [chx, y2],
4033
- [tx, y2],
4216
+ [tx, y1],
4034
4217
  [tx, ty - 8]
4035
4218
  ];
4036
- } else pts = [
4037
- [sx, sy],
4038
- [sx, y1],
4039
- [tx, y1],
4040
- [tx, ty - 8]
4041
- ];
4042
- const r = related(e);
4043
- const dim = focus && !r;
4044
- const picked = e === selEdge;
4045
- const hovered = !!pickEdge && hover === edgeId(e) && !r;
4219
+ arrow = `M${tx - 5} ${ty - 9} L${tx + 5} ${ty - 9} L${tx} ${ty} Z`;
4220
+ arrows.push([
4221
+ tx - 5,
4222
+ tx + 5,
4223
+ ty - 9,
4224
+ ty
4225
+ ]);
4226
+ }
4046
4227
  const w = (e.inferred ? 1.5 : 1.5 + 5.5 * ((e.count || 0) / maxCount)) + (picked ? 1.5 : 0) + (hovered ? 2 : 0);
4047
4228
  const d = route(clean(pts), 10);
4048
4229
  paths.push(/* @__PURE__ */ jsx("path", {
@@ -4071,17 +4252,11 @@ function LayerGraph(p) {
4071
4252
  } else if (ev.key === "Escape" && picked) pickEdge(null);
4072
4253
  }
4073
4254
  }, "h" + idx));
4074
- arrows.push([
4075
- tx - 5,
4076
- tx + 5,
4077
- ty - 9,
4078
- ty
4079
- ]);
4080
4255
  paths.push(/* @__PURE__ */ jsx("path", {
4081
4256
  className: cx("ui-lg-arrow", r && "is-related", dim && "is-dim"),
4082
- d: `M${tx - 5} ${ty - 9} L${tx + 5} ${ty - 9} L${tx} ${ty} Z`
4257
+ d: arrow
4083
4258
  }, "a" + idx));
4084
- if (e.inferred || r) {
4259
+ if (!up && (e.inferred || r)) {
4085
4260
  const text = e.inferred ? e.label || p.inferredLabel || tr("推測") : countText(e);
4086
4261
  marks.push({
4087
4262
  idx,
@@ -4095,10 +4270,39 @@ function LayerGraph(p) {
4095
4270
  });
4096
4271
  }
4097
4272
  });
4098
- const placed = [...arrows];
4273
+ const placed = [...arrows, ...runs];
4099
4274
  const hits = (x0, x1, y0, y1) => placed.some((q) => x0 < q[1] + (q[4] || 0) && q[0] < x1 + (q[4] || 0) && y0 < q[3] && q[2] < y1);
4275
+ const labelEl = (m, x0, top) => /* @__PURE__ */ jsx("span", {
4276
+ className: cx("ui-lg-label", pickEdge && "is-clickable", pickEdge && hover === edgeId(m.e) && "is-hover", m.r && "is-related", m.dim && "is-dim"),
4277
+ style: {
4278
+ left: x0,
4279
+ top
4280
+ },
4281
+ onClick: pickEdge ? (ev) => {
4282
+ ev.stopPropagation();
4283
+ choose(m.e);
4284
+ } : void 0,
4285
+ onPointerEnter: pickEdge ? () => setHover(edgeId(m.e)) : void 0,
4286
+ onPointerLeave: pickEdge ? () => setHover(null) : void 0,
4287
+ children: labelParts(m.text)
4288
+ }, "l" + m.idx);
4100
4289
  marks.sort((m, n) => m.ty - n.ty || m.tx - n.tx).forEach((m) => {
4101
4290
  const w = Math.ceil(labelWidth(m.text));
4291
+ if (m.up) {
4292
+ const x0 = m.left ? m.tx - w : m.tx;
4293
+ let top = Math.max(10, Math.min(H - 10, m.ty));
4294
+ for (let k = 0; k < 8 && hits(x0, x0 + w, top - 8, top + 8) && top - 18 >= 10; k++) top -= 18;
4295
+ for (let k = 0; k < 16 && hits(x0, x0 + w, top - 8, top + 8) && top + 18 <= H - 10; k++) top += 18;
4296
+ placed.push([
4297
+ x0,
4298
+ x0 + w,
4299
+ top - 8,
4300
+ top + 8,
4301
+ 6
4302
+ ]);
4303
+ labels.push(labelEl(m, x0, top));
4304
+ return;
4305
+ }
4102
4306
  let left = m.left;
4103
4307
  if (left && m.tx - 8 - w < 0) left = false;
4104
4308
  else if (!left && m.tx + 8 + w > W) left = m.tx - 8 - w >= 0;
@@ -4113,20 +4317,7 @@ function LayerGraph(p) {
4113
4317
  top + 8,
4114
4318
  6
4115
4319
  ]);
4116
- labels.push(/* @__PURE__ */ jsx("span", {
4117
- className: cx("ui-lg-label", pickEdge && "is-clickable", pickEdge && hover === edgeId(m.e) && "is-hover", m.r && "is-related", m.dim && "is-dim"),
4118
- style: {
4119
- left: x0,
4120
- top
4121
- },
4122
- onClick: pickEdge ? (ev) => {
4123
- ev.stopPropagation();
4124
- choose(m.e);
4125
- } : void 0,
4126
- onPointerEnter: pickEdge ? () => setHover(edgeId(m.e)) : void 0,
4127
- onPointerLeave: pickEdge ? () => setHover(null) : void 0,
4128
- children: labelParts(m.text)
4129
- }, "l" + m.idx));
4320
+ labels.push(labelEl(m, x0, top));
4130
4321
  });
4131
4322
  const sizeText = p.sizeLabel ?? tr("{n} 個項目");
4132
4323
  const useText = p.useLabel ?? tr("使用 {n} 次");
@@ -5320,12 +5511,39 @@ const GAP = 12;
5320
5511
  function edge() {
5321
5512
  return parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--space-3")) || 12;
5322
5513
  }
5514
+ const narrowNow = () => typeof window !== "undefined" && window.innerWidth < 600;
5515
+ /** The part of the window between a phone's fixed top bar and bottom tab bar (when the target is not one of them):
5516
+ * the card stays inside it and never covers either bar. The whole window elsewhere. */
5517
+ function bounds(target) {
5518
+ const vh = typeof window === "undefined" ? 0 : window.innerHeight;
5519
+ if (!narrowNow()) return {
5520
+ top: 0,
5521
+ bottom: vh
5522
+ };
5523
+ let top = 0;
5524
+ let bottom = vh;
5525
+ const head = document.querySelector(".ui-shell-top");
5526
+ const bar = document.querySelector(".ui-tabbar");
5527
+ if (head && !(target && head.contains(target))) {
5528
+ const r = head.getBoundingClientRect();
5529
+ if (r.height && r.bottom > 0 && r.bottom < vh / 2) top = r.bottom;
5530
+ }
5531
+ if (bar && !(target && bar.contains(target))) {
5532
+ const r = bar.getBoundingClientRect();
5533
+ if (r.height && r.top > vh / 2 && r.top < vh) bottom = r.top;
5534
+ }
5535
+ return {
5536
+ top,
5537
+ bottom
5538
+ };
5539
+ }
5323
5540
  /** Where the card goes for a highlighted box: the preferred side, the other side, or inside the box at the bottom
5324
5541
  * center of the window when neither side has room. Returns the anchor line the card is placed against. */
5325
- function placeCard(rect, cardH, prefer) {
5542
+ function placeCard(rect, cardH, prefer, area) {
5326
5543
  const margin = typeof document === "undefined" ? 12 : edge();
5327
- const vh = typeof window === "undefined" ? 0 : window.innerHeight;
5328
- const fits = (side) => rect ? side === "bottom" ? rect.top + rect.height + GAP + cardH + margin <= vh : rect.top - GAP - cardH - margin >= 0 : false;
5544
+ const vh = area?.bottom ?? (typeof window === "undefined" ? 0 : window.innerHeight);
5545
+ const vt = area?.top ?? 0;
5546
+ const fits = (side) => rect ? side === "bottom" ? rect.top + rect.height + GAP + cardH + margin <= vh : rect.top - GAP - cardH - margin >= vt : false;
5329
5547
  if (!rect) return {
5330
5548
  mode: "center",
5331
5549
  side: "top",
@@ -5333,7 +5551,7 @@ function placeCard(rect, cardH, prefer) {
5333
5551
  margin,
5334
5552
  line: {
5335
5553
  left: 0,
5336
- top: Math.max(margin + cardH, vh / 2 + cardH / 2),
5554
+ top: Math.max(vt + margin + cardH, (vt + vh) / 2 + cardH / 2),
5337
5555
  width: window.innerWidth,
5338
5556
  height: 0
5339
5557
  }
@@ -5348,7 +5566,7 @@ function placeCard(rect, cardH, prefer) {
5348
5566
  line: rect
5349
5567
  };
5350
5568
  const end = rect.top + rect.height;
5351
- const bottom = Math.max(margin + cardH, end >= vh - margin ? vh - margin : end - margin);
5569
+ const bottom = Math.max(vt + margin + cardH, end >= vh - margin ? vh - margin : end - margin);
5352
5570
  return {
5353
5571
  mode: "inside",
5354
5572
  side: "top",
@@ -5387,9 +5605,17 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
5387
5605
  if (!open || !hasStep) return;
5388
5606
  let el = findTarget(target);
5389
5607
  const tall = (el?.getBoundingClientRect().height ?? 0) > window.innerHeight;
5390
- el?.scrollIntoView?.({
5608
+ if (el instanceof HTMLElement && narrowNow()) {
5609
+ const keep = el.style.scrollMarginTop;
5610
+ el.style.scrollMarginTop = bounds(el).top + edge() + pad + "px";
5611
+ el.scrollIntoView?.({
5612
+ block: "start",
5613
+ behavior: "auto"
5614
+ });
5615
+ el.style.scrollMarginTop = keep;
5616
+ } else el?.scrollIntoView?.({
5391
5617
  block: tall ? "start" : "center",
5392
- behavior: reduced() ? "auto" : "smooth"
5618
+ behavior: "auto"
5393
5619
  });
5394
5620
  let raf = 0;
5395
5621
  let last = "";
@@ -5433,7 +5659,8 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
5433
5659
  observer.current = new ResizeObserver(measure);
5434
5660
  observer.current.observe(el);
5435
5661
  }, []);
5436
- const place = placeCard(rect, cardH, step?.side ?? "bottom");
5662
+ const area = open && step ? bounds(findTarget(step.target)) : void 0;
5663
+ const place = placeCard(rect, cardH, step?.side ?? "bottom", area);
5437
5664
  const line = place.line;
5438
5665
  const anchor = React.useMemo(() => ({ getBoundingClientRect: () => line ? new DOMRect(line.left, line.top, line.width, line.height) : new DOMRect(window.innerWidth / 2, window.innerHeight / 2, 0, 0) }), [
5439
5666
  line?.left,