@seanyeh77/ui 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { a as parseDate, c as addMessages, d as unitFor, 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-BXwnh9f-.js";
2
+ import { a as parseDate, c as addMessages, d as unitFor, 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-ePskyytj.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";
@@ -793,12 +793,12 @@ function Tooltip({ label, side = "top", describe = true, wrap = false, disabled
793
793
  }
794
794
  // src/components/IconButton/IconButton.tsx
795
795
  /** A square icon-only button with a tooltip. */
796
- function IconButton({ label, icon, className, tooltip = true, filled, hint, ...native }) {
796
+ function IconButton({ label, icon, className, tooltip = true, filled, hint, variant, ...native }) {
797
797
  const id = React.useId();
798
798
  const btn = /* @__PURE__ */ jsxs("button", {
799
799
  type: "button",
800
800
  ...native,
801
- className: cx("ui-iconbtn", hint && "has-hint", className),
801
+ className: cx("ui-iconbtn", variant === "quiet" && "is-quiet", hint && "has-hint", className),
802
802
  "aria-label": label,
803
803
  "aria-describedby": hint ? id : native["aria-describedby"],
804
804
  children: [/* @__PURE__ */ jsx(IconOf, {
@@ -5164,7 +5164,7 @@ const HANDLE = 16;
5164
5164
  /** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */
5165
5165
  const STACK = 960;
5166
5166
  /** One arrow key press, in px. */
5167
- const STEP = 16;
5167
+ const STEP$1 = 16;
5168
5168
  const read = (key) => {
5169
5169
  if (!key) return null;
5170
5170
  try {
@@ -5213,7 +5213,7 @@ function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, l
5213
5213
  };
5214
5214
  const onKey = (e) => {
5215
5215
  if (browserKey(e)) return;
5216
- const to = e.key === "ArrowLeft" ? shown + STEP : e.key === "ArrowRight" ? shown - STEP : e.key === "Home" ? maxB : e.key === "End" ? minB : e.key === "Enter" ? defaultB : null;
5216
+ const to = e.key === "ArrowLeft" ? shown + STEP$1 : e.key === "ArrowRight" ? shown - STEP$1 : e.key === "Home" ? maxB : e.key === "End" ? minB : e.key === "Enter" ? defaultB : null;
5217
5217
  if (to == null) return;
5218
5218
  e.preventDefault();
5219
5219
  set(to);
@@ -9881,6 +9881,8 @@ function TreeList(p) {
9881
9881
  const { items } = p;
9882
9882
  const single = p.expand === "single";
9883
9883
  const plain = p.kind === "plain";
9884
+ const compact = plain && p.density === "compact";
9885
+ devWarn(p.density === "compact" && !plain, "TreeList", "density=\"compact\" works with kind=\"plain\" only: the files kind needs room for date and size.");
9884
9886
  const sort = p.sort === void 0 ? plain ? false : "newest" : p.sort;
9885
9887
  const selectable = !!p.selectable && !plain;
9886
9888
  devWarn(plain && p.selectable, "TreeList", "selectable works with kind=\"files\" only; for plain trees use selectedId and onSelect.");
@@ -10104,7 +10106,8 @@ function TreeList(p) {
10104
10106
  n.name,
10105
10107
  ...(n.tags ?? []).map(nodeText),
10106
10108
  n.meta,
10107
- n.path
10109
+ n.path,
10110
+ n.mark?.label
10108
10111
  ].filter(Boolean).join(tr(",")),
10109
10112
  "aria-selected": p.onSelect ? on : void 0,
10110
10113
  className: cx("ui-tree-row", "is-plain", on && "is-current", n.muted && "is-muted", r.fresh && "ui-tree-in"),
@@ -10126,7 +10129,7 @@ function TreeList(p) {
10126
10129
  },
10127
10130
  children: /* @__PURE__ */ jsx(Icon, {
10128
10131
  name: "caret-right",
10129
- size: 16
10132
+ size: compact ? 14 : 16
10130
10133
  })
10131
10134
  }),
10132
10135
  n.icon ? /* @__PURE__ */ jsx("span", {
@@ -10134,7 +10137,7 @@ function TreeList(p) {
10134
10137
  "aria-hidden": "true",
10135
10138
  children: /* @__PURE__ */ jsx(IconOf, {
10136
10139
  icon: n.icon,
10137
- size: 20
10140
+ size: compact ? 16 : 20
10138
10141
  })
10139
10142
  }) : null,
10140
10143
  /* @__PURE__ */ jsxs("div", {
@@ -10159,6 +10162,11 @@ function TreeList(p) {
10159
10162
  children: n.meta != null ? digits(meta, /(\d[\d,.]*)/) : meta
10160
10163
  }) : null]
10161
10164
  }),
10165
+ n.mark ? /* @__PURE__ */ jsx("span", {
10166
+ className: cx("ui-tree-mark", "is-" + (n.mark.tone ?? "warning")),
10167
+ "aria-hidden": "true",
10168
+ title: n.mark.label
10169
+ }) : null,
10162
10170
  p.rowActions ? /* @__PURE__ */ jsx("span", {
10163
10171
  className: "ui-tree-act",
10164
10172
  onClick: (e) => e.stopPropagation(),
@@ -10411,7 +10419,7 @@ function TreeList(p) {
10411
10419
  return [out, i];
10412
10420
  };
10413
10421
  return /* @__PURE__ */ jsxs("section", {
10414
- className: cx("ui-tree", plain && "is-plain", selectable && "is-selectable", selFiles.length && "has-sel", p.bare && "is-bare", p.height != null && "has-height", p.className),
10422
+ className: cx("ui-tree", plain && "is-plain", compact && "is-compact", selectable && "is-selectable", selFiles.length && "has-sel", p.bare && "is-bare", p.height != null && "has-height", p.className),
10415
10423
  "aria-label": p.title ? void 0 : p.label,
10416
10424
  style: p.height != null ? { height: typeof p.height === "number" ? p.height + "px" : p.height } : void 0,
10417
10425
  children: [head, rows.length ? /* @__PURE__ */ jsx("div", {
@@ -10428,6 +10436,1102 @@ function TreeList(p) {
10428
10436
  })]
10429
10437
  });
10430
10438
  }
10431
- export { AccentPicker, ActionBar, AiMark, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Markdown, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Section, SectionGroup, SectionGroupToggle, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour };
10439
+ // src/components/Workbench/Workbench.tsx
10440
+ const Ctx = React.createContext(null);
10441
+ /** For anything rendered inside a Workbench (actions, explorer, views). */
10442
+ function useWorkbench() {
10443
+ const api = React.useContext(Ctx);
10444
+ if (!api) throw new Error("useWorkbench() works inside <Workbench>.");
10445
+ return api;
10446
+ }
10447
+ const TOP = 48;
10448
+ const LIM = {
10449
+ explorer: [180, 480],
10450
+ side: [240, 560],
10451
+ panel: [120, Infinity]
10452
+ };
10453
+ const DEF_SIZE = {
10454
+ explorer: 260,
10455
+ side: 320,
10456
+ panel: 220
10457
+ };
10458
+ const STEP = 16;
10459
+ const FRAME = "<rect x=\"24\" y=\"40\" width=\"208\" height=\"176\" rx=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"16\"/>";
10460
+ const TOGGLE = {
10461
+ explorer: ["<rect x=\"40\" y=\"56\" width=\"64\" height=\"144\" rx=\"6\"/>", "<path d=\"M100 44v168\" stroke=\"currentColor\" stroke-width=\"16\"/>"],
10462
+ side: ["<rect x=\"152\" y=\"56\" width=\"64\" height=\"144\" rx=\"6\"/>", "<path d=\"M156 44v168\" stroke=\"currentColor\" stroke-width=\"16\"/>"],
10463
+ panel: ["<rect x=\"40\" y=\"136\" width=\"176\" height=\"64\" rx=\"6\"/>", "<path d=\"M28 140h200\" stroke=\"currentColor\" stroke-width=\"16\"/>"]
10464
+ };
10465
+ const toggleIcon = (r, open) => FRAME + TOGGLE[r][open ? 0 : 1];
10466
+ const MOVE_ICON = "M4 8h15m0 0-3.5-3.5M19 8l-3.5 3.5M20 16H5m0 0 3.5-3.5M5 16l3.5 3.5";
10467
+ function defaults(views, d) {
10468
+ const ids = views.map((v) => v.id);
10469
+ const side = (d?.side ?? []).filter((x) => ids.includes(x));
10470
+ const panel = (d?.panel ?? []).filter((x) => ids.includes(x) && !side.includes(x));
10471
+ for (const x of ids) if (!side.includes(x) && !panel.includes(x)) panel.push(x);
10472
+ return {
10473
+ side,
10474
+ panel,
10475
+ active: {
10476
+ side: side[0],
10477
+ panel: panel[0]
10478
+ },
10479
+ open: {
10480
+ explorer: true,
10481
+ side: true,
10482
+ panel: true,
10483
+ ...d?.open
10484
+ },
10485
+ size: {
10486
+ ...DEF_SIZE,
10487
+ ...d?.size
10488
+ }
10489
+ };
10490
+ }
10491
+ function restore(key, def) {
10492
+ try {
10493
+ const raw = store(key);
10494
+ if (!raw) return def;
10495
+ const s = JSON.parse(raw);
10496
+ const all = [...def.side, ...def.panel];
10497
+ const side = (s.side ?? []).filter((x) => all.includes(x));
10498
+ const panel = (s.panel ?? []).filter((x) => all.includes(x) && !side.includes(x));
10499
+ for (const x of def.side) if (!side.includes(x) && !panel.includes(x)) side.push(x);
10500
+ for (const x of def.panel) if (!side.includes(x) && !panel.includes(x)) panel.push(x);
10501
+ return {
10502
+ side,
10503
+ panel,
10504
+ active: {
10505
+ ...def.active,
10506
+ ...s.active
10507
+ },
10508
+ open: {
10509
+ ...def.open,
10510
+ ...s.open
10511
+ },
10512
+ size: {
10513
+ ...def.size,
10514
+ ...s.size
10515
+ }
10516
+ };
10517
+ } catch {
10518
+ return def;
10519
+ }
10520
+ }
10521
+ const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, Math.round(v)));
10522
+ const inField = (t) => t instanceof HTMLElement && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName));
10523
+ /** A draggable border between two regions: role="separator", arrows 16 px, Shift 64 px, Home/End, double-click resets. */
10524
+ function Splitter(p) {
10525
+ const start = React.useRef(null);
10526
+ const [on, setOn] = React.useState(false);
10527
+ const pos = (e) => p.vertical ? e.clientX : e.clientY;
10528
+ return /* @__PURE__ */ jsx("div", {
10529
+ className: cx("ui-wb-split", p.vertical ? "is-v" : "is-h", on && "is-on"),
10530
+ role: "separator",
10531
+ "aria-orientation": p.vertical ? "vertical" : "horizontal",
10532
+ "aria-label": p.label,
10533
+ "aria-valuenow": p.value,
10534
+ "aria-valuemin": p.min,
10535
+ "aria-valuemax": p.max,
10536
+ tabIndex: 0,
10537
+ style: p.style,
10538
+ onPointerDown: (e) => {
10539
+ e.currentTarget.setPointerCapture?.(e.pointerId);
10540
+ start.current = {
10541
+ at: pos(e),
10542
+ v: p.value
10543
+ };
10544
+ setOn(true);
10545
+ p.onDrag(true);
10546
+ },
10547
+ onPointerMove: (e) => {
10548
+ const s = start.current;
10549
+ if (s) p.onChange(clamp(s.v + (pos(e) - s.at) * p.grow, p.min, p.max));
10550
+ },
10551
+ onPointerUp: () => {
10552
+ start.current = null;
10553
+ setOn(false);
10554
+ p.onDrag(false);
10555
+ },
10556
+ onPointerCancel: () => {
10557
+ start.current = null;
10558
+ setOn(false);
10559
+ p.onDrag(false);
10560
+ },
10561
+ onDoubleClick: p.onReset,
10562
+ onKeyDown: (e) => {
10563
+ const step = e.shiftKey ? 64 : STEP;
10564
+ const grow = p.vertical ? p.grow > 0 ? "ArrowRight" : "ArrowLeft" : p.grow > 0 ? "ArrowDown" : "ArrowUp";
10565
+ const shrink = p.vertical ? p.grow > 0 ? "ArrowLeft" : "ArrowRight" : p.grow > 0 ? "ArrowUp" : "ArrowDown";
10566
+ let v = null;
10567
+ if (e.key === grow) v = p.value + step;
10568
+ else if (e.key === shrink) v = p.value - step;
10569
+ else if (e.key === "Home") v = p.min;
10570
+ else if (e.key === "End") v = p.max;
10571
+ if (v == null) return;
10572
+ e.preventDefault();
10573
+ p.onChange(clamp(v, p.min, p.max));
10574
+ },
10575
+ children: /* @__PURE__ */ jsx("span", {
10576
+ className: "ui-wb-split-line",
10577
+ "aria-hidden": "true"
10578
+ })
10579
+ });
10580
+ }
10581
+ /** A region's tab row: droplet underline, overflow (更多 menu with a mouse, scrolling on phones), drag and drop. */
10582
+ function TabRow(p) {
10583
+ const track = React.useRef(null);
10584
+ const tabs = React.useRef({});
10585
+ const widths = React.useRef({});
10586
+ const [fit, setFit] = React.useState(p.ids.length);
10587
+ const [box, setBox] = React.useState(null);
10588
+ const [forward, setForward] = React.useState(true);
10589
+ const [edges, setEdges] = React.useState({
10590
+ left: false,
10591
+ right: false
10592
+ });
10593
+ const [hold, setHold] = React.useState(null);
10594
+ const press = React.useRef(null);
10595
+ const prevActive = React.useRef(p.active);
10596
+ const menu = p.overflow === "menu";
10597
+ const order = hold ? (() => {
10598
+ const a = p.ids.filter((x) => x !== hold.id);
10599
+ a.splice(hold.at, 0, hold.id);
10600
+ return a;
10601
+ })() : p.ids;
10602
+ let shown = order;
10603
+ let hidden = [];
10604
+ if (menu && fit < order.length) {
10605
+ shown = order.slice(0, Math.max(1, fit));
10606
+ if (p.active && order.includes(p.active) && !shown.includes(p.active)) shown = [...shown.slice(0, -1), p.active];
10607
+ hidden = order.filter((x) => !shown.includes(x));
10608
+ }
10609
+ const measure = React.useCallback(() => {
10610
+ const tr2 = track.current;
10611
+ if (!tr2) return;
10612
+ const el = p.active ? tabs.current[p.active] : null;
10613
+ setBox(el ? {
10614
+ left: el.offsetLeft + 10,
10615
+ right: tr2.clientWidth - el.offsetLeft - el.offsetWidth + 10
10616
+ } : null);
10617
+ const left = tr2.scrollLeft > 1;
10618
+ const right = tr2.scrollLeft + tr2.clientWidth < tr2.scrollWidth - 1;
10619
+ setEdges((m) => m.left === left && m.right === right ? m : {
10620
+ left,
10621
+ right
10622
+ });
10623
+ if (menu) {
10624
+ for (const [id, t] of Object.entries(tabs.current)) if (t) widths.current[id] = t.offsetWidth;
10625
+ let used = 0;
10626
+ let n = 0;
10627
+ const total = p.ids.reduce((a, id) => a + (widths.current[id] ?? 80), 0);
10628
+ const room = tr2.clientWidth - (total > tr2.clientWidth ? 72 : 0);
10629
+ for (const id of p.ids) {
10630
+ used += widths.current[id] ?? 80;
10631
+ if (used > room) break;
10632
+ n++;
10633
+ }
10634
+ setFit((f) => f === n ? f : n);
10635
+ }
10636
+ }, [
10637
+ p.active,
10638
+ p.ids,
10639
+ menu
10640
+ ]);
10641
+ React.useLayoutEffect(() => {
10642
+ if (prevActive.current !== p.active) {
10643
+ setForward(p.ids.indexOf(p.active ?? "") > p.ids.indexOf(prevActive.current ?? ""));
10644
+ prevActive.current = p.active;
10645
+ }
10646
+ measure();
10647
+ const tr2 = track.current;
10648
+ if (!tr2) return;
10649
+ const el = p.active ? tabs.current[p.active] : null;
10650
+ if (el && !menu) {
10651
+ if (el.offsetLeft < tr2.scrollLeft) tr2.scrollLeft = el.offsetLeft - 4;
10652
+ else if (el.offsetLeft + el.offsetWidth > tr2.scrollLeft + tr2.clientWidth) tr2.scrollLeft = el.offsetLeft + el.offsetWidth - tr2.clientWidth + 4;
10653
+ }
10654
+ const ro = new ResizeObserver(measure);
10655
+ ro.observe(tr2);
10656
+ return () => ro.disconnect();
10657
+ }, [
10658
+ p.active,
10659
+ p.ids,
10660
+ measure,
10661
+ menu,
10662
+ hold
10663
+ ]);
10664
+ const drag = p.drag;
10665
+ const over = drag?.over?.region === p.region ? drag.over : void 0;
10666
+ const di = drag ? p.ids.indexOf(drag.id) : -1;
10667
+ const noop = (before) => di >= 0 && (before === drag?.id || before === (p.ids[di + 1] ?? null));
10668
+ const tabEl = (id, i, list) => {
10669
+ const v = p.views[id];
10670
+ const on = id === p.active;
10671
+ const next = list[i + 1] ?? null;
10672
+ const lineBefore = !!over && !over.noop && over.before === id;
10673
+ const lineAfter = !!over && !over.noop && over.before === null && i === list.length - 1 && list.length === p.ids.length;
10674
+ return /* @__PURE__ */ jsxs("button", {
10675
+ ref: (n) => {
10676
+ tabs.current[id] = n;
10677
+ },
10678
+ type: "button",
10679
+ role: "tab",
10680
+ "data-id": id,
10681
+ "aria-selected": on,
10682
+ tabIndex: on ? 0 : -1,
10683
+ className: cx("ui-wb-tab", on && "is-on", drag?.id === id && "is-ghost", hold?.id === id && "is-held", lineBefore && "has-line", lineAfter && "has-line-after"),
10684
+ draggable: !!p.setDrag,
10685
+ onClick: () => p.onPick(id),
10686
+ onKeyDown: (e) => {
10687
+ const k = e.key;
10688
+ const j = k === "ArrowRight" ? i + 1 : k === "ArrowLeft" ? i - 1 : k === "Home" ? 0 : k === "End" ? list.length - 1 : -1;
10689
+ if (j < 0 || j >= list.length) return;
10690
+ e.preventDefault();
10691
+ p.onPick(list[j]);
10692
+ tabs.current[list[j]]?.focus();
10693
+ },
10694
+ onDragStart: (e) => {
10695
+ e.dataTransfer.setData("text/plain", id);
10696
+ e.dataTransfer.effectAllowed = "move";
10697
+ p.setDrag?.({ id });
10698
+ },
10699
+ onDragEnd: () => p.setDrag?.(null),
10700
+ onDragOver: (e) => {
10701
+ if (!drag || !p.setDrag) return;
10702
+ e.preventDefault();
10703
+ e.stopPropagation();
10704
+ const r = e.currentTarget.getBoundingClientRect();
10705
+ const before = e.clientX > r.left + r.width / 2 ? next : id;
10706
+ const nn = noop(before);
10707
+ if (!over || over.before !== before || over.noop !== nn) p.setDrag({
10708
+ id: drag.id,
10709
+ over: {
10710
+ region: p.region,
10711
+ before,
10712
+ noop: nn
10713
+ }
10714
+ });
10715
+ },
10716
+ onDrop: (e) => {
10717
+ e.preventDefault();
10718
+ e.stopPropagation();
10719
+ if (drag && over && !over.noop) p.onDrop?.(drag.id, over.before);
10720
+ p.setDrag?.(null);
10721
+ },
10722
+ children: [v.title, v.attention ? /* @__PURE__ */ jsx("span", {
10723
+ className: "ui-wb-dot",
10724
+ "aria-label": tr("有新內容"),
10725
+ role: "img"
10726
+ }) : null]
10727
+ }, id);
10728
+ };
10729
+ const pressHandlers = p.onReorder ? {
10730
+ onPointerDown: (e) => {
10731
+ const t = e.target.closest?.("[data-id]");
10732
+ const c = e.currentTarget;
10733
+ const pr = {
10734
+ id: t ? t.getAttribute("data-id") : null,
10735
+ x: e.clientX,
10736
+ y: e.clientY,
10737
+ scroll: c.scrollLeft,
10738
+ mode: null,
10739
+ timer: void 0
10740
+ };
10741
+ pr.timer = setTimeout(() => {
10742
+ if (press.current === pr && !pr.mode && pr.id) {
10743
+ pr.mode = "drag";
10744
+ c.setPointerCapture?.(e.pointerId);
10745
+ navigator.vibrate?.(10);
10746
+ setHold({
10747
+ id: pr.id,
10748
+ at: p.ids.indexOf(pr.id)
10749
+ });
10750
+ }
10751
+ }, 300);
10752
+ press.current = pr;
10753
+ },
10754
+ onPointerMove: (e) => {
10755
+ const pr = press.current;
10756
+ if (!pr) return;
10757
+ const dx = e.clientX - pr.x;
10758
+ if (!pr.mode && (Math.abs(dx) > 8 || Math.abs(e.clientY - pr.y) > 8)) {
10759
+ clearTimeout(pr.timer);
10760
+ pr.mode = "scroll";
10761
+ }
10762
+ const c = e.currentTarget;
10763
+ if (pr.mode === "scroll") c.scrollLeft = pr.scroll - dx;
10764
+ else if (pr.mode === "drag" && pr.id) {
10765
+ let at = 0;
10766
+ c.querySelectorAll("[data-id]").forEach((el) => {
10767
+ if (el.getAttribute("data-id") === pr.id) return;
10768
+ const r = el.getBoundingClientRect();
10769
+ if (e.clientX > r.left + r.width / 2) at++;
10770
+ });
10771
+ setHold((h) => h && h.at === at ? h : {
10772
+ id: pr.id,
10773
+ at
10774
+ });
10775
+ const r = c.getBoundingClientRect();
10776
+ if (e.clientX < r.left + 28) c.scrollLeft -= 6;
10777
+ else if (e.clientX > r.right - 28) c.scrollLeft += 6;
10778
+ }
10779
+ },
10780
+ onPointerUp: () => {
10781
+ const pr = press.current;
10782
+ press.current = null;
10783
+ if (!pr) return;
10784
+ clearTimeout(pr.timer);
10785
+ if (pr.mode === "drag" && hold) {
10786
+ const next = order;
10787
+ setHold(null);
10788
+ if (next.join("\n") !== p.ids.join("\n")) p.onReorder?.(next);
10789
+ }
10790
+ },
10791
+ onPointerCancel: () => {
10792
+ const pr = press.current;
10793
+ if (pr) clearTimeout(pr.timer);
10794
+ press.current = null;
10795
+ setHold(null);
10796
+ },
10797
+ onContextMenu: (e) => e.preventDefault()
10798
+ } : {};
10799
+ return /* @__PURE__ */ jsxs("div", {
10800
+ className: "ui-wb-tabbar",
10801
+ children: [
10802
+ /* @__PURE__ */ jsxs("div", {
10803
+ ref: track,
10804
+ className: cx("ui-wb-tabs", !menu && "is-scroll", edges.left && "has-more-left", edges.right && "has-more-right", p.onReorder && "is-touch"),
10805
+ role: "tablist",
10806
+ "aria-label": p.name,
10807
+ onScroll: measure,
10808
+ onWheel: (e) => {
10809
+ const c = e.currentTarget;
10810
+ if (!menu && c.scrollWidth > c.clientWidth && Math.abs(e.deltaY) > Math.abs(e.deltaX)) c.scrollLeft += e.deltaY;
10811
+ },
10812
+ ...pressHandlers,
10813
+ children: [box ? /* @__PURE__ */ jsx("span", {
10814
+ className: "ui-wb-ind",
10815
+ "aria-hidden": "true",
10816
+ style: {
10817
+ left: box.left,
10818
+ right: box.right,
10819
+ transition: dropTransition("left", "right", forward)
10820
+ }
10821
+ }) : null, shown.map((id, i) => tabEl(id, i, shown))]
10822
+ }),
10823
+ hidden.length ? /* @__PURE__ */ jsxs(Menu$1.Root, { children: [/* @__PURE__ */ jsxs(Menu$1.Trigger, {
10824
+ className: "ui-wb-more",
10825
+ "aria-label": tr("更多分頁({n} 個)", { n: hidden.length }),
10826
+ children: [tr("更多 {n}", { n: hidden.length }), /* @__PURE__ */ jsx(Icon, {
10827
+ name: "caret-down",
10828
+ size: 14
10829
+ })]
10830
+ }), /* @__PURE__ */ jsx(Menu$1.Portal, { children: /* @__PURE__ */ jsx(Menu$1.Positioner, {
10831
+ className: "ui-menu-pos",
10832
+ align: "end",
10833
+ sideOffset: 4,
10834
+ children: /* @__PURE__ */ jsx(Menu$1.Popup, {
10835
+ className: "ui-menu",
10836
+ children: hidden.map((id) => /* @__PURE__ */ jsxs(Menu$1.Item, {
10837
+ className: "ui-menu-item",
10838
+ onClick: () => p.onPick(id),
10839
+ children: [/* @__PURE__ */ jsx("span", { className: "ui-menu-noicon" }), /* @__PURE__ */ jsx("span", {
10840
+ className: "ui-menu-label",
10841
+ children: p.views[id].title
10842
+ })]
10843
+ }, id))
10844
+ })
10845
+ }) })] }) : null,
10846
+ /* @__PURE__ */ jsx("div", {
10847
+ className: "ui-wb-tabbtns",
10848
+ children: p.buttons
10849
+ })
10850
+ ]
10851
+ });
10852
+ }
10853
+ /** The view's content; on a change its children rise one after another, 40 ms apart. */
10854
+ function Pane({ view, onSwipe }) {
10855
+ const start = React.useRef(null);
10856
+ return /* @__PURE__ */ jsx("div", {
10857
+ className: "ui-wb-panebox",
10858
+ role: "tabpanel",
10859
+ onPointerDown: onSwipe ? (e) => start.current = {
10860
+ x: e.clientX,
10861
+ y: e.clientY
10862
+ } : void 0,
10863
+ onPointerUp: onSwipe ? (e) => {
10864
+ const s = start.current;
10865
+ start.current = null;
10866
+ if (!s) return;
10867
+ const dx = e.clientX - s.x;
10868
+ const dy = e.clientY - s.y;
10869
+ if (Math.abs(dx) >= 48 && Math.abs(dx) > Math.abs(dy) * 1.5) onSwipe(dx < 0 ? 1 : -1);
10870
+ } : void 0,
10871
+ children: view ? /* @__PURE__ */ jsx("div", {
10872
+ className: "ui-wb-pane",
10873
+ children: view.render()
10874
+ }, view.id) : null
10875
+ });
10876
+ }
10877
+ /** An editor layout like VS Code: top bar, file explorer, main view, side bar and bottom panel, with resizable borders,
10878
+ * views that move between the side bar and the panel, Ctrl B / Ctrl J / Ctrl Alt B, and a remembered layout. */
10879
+ function Workbench({ ref, ...p }) {
10880
+ const views = React.useMemo(() => p.views ?? [], [p.views]);
10881
+ const byId = React.useMemo(() => Object.fromEntries(views.map((v) => [v.id, v])), [views]);
10882
+ const key = "ui-workbench:" + p.id;
10883
+ const def = React.useMemo(() => defaults(views, p.defaultLayout), [views, p.defaultLayout]);
10884
+ const [lay, setLay] = React.useState(() => restore(key, def));
10885
+ devWarn(new Set(views.map((v) => v.id)).size !== views.length, "Workbench", "two views share an id. Give each view its own id: the layout stores views by id.");
10886
+ const root = React.useRef(null);
10887
+ const [dim, setDim] = React.useState({
10888
+ w: 1280,
10889
+ h: 800
10890
+ });
10891
+ React.useLayoutEffect(() => {
10892
+ const el = root.current;
10893
+ if (!el) return;
10894
+ const read = () => setDim((d) => d.w === el.clientWidth && d.h === el.clientHeight ? d : {
10895
+ w: el.clientWidth,
10896
+ h: el.clientHeight
10897
+ });
10898
+ read();
10899
+ const ro = new ResizeObserver(read);
10900
+ ro.observe(el);
10901
+ return () => ro.disconnect();
10902
+ }, []);
10903
+ React.useEffect(() => {
10904
+ store(key, JSON.stringify(lay));
10905
+ }, [key, lay]);
10906
+ const onLayoutChange = p.onLayoutChange;
10907
+ React.useEffect(() => {
10908
+ onLayoutChange?.(lay);
10909
+ }, [lay]);
10910
+ const [ov, setOv] = React.useState({
10911
+ explorer: false,
10912
+ side: false
10913
+ });
10914
+ const [sheet, setSheet] = React.useState({ open: false });
10915
+ const [sheetH, setSheetH] = React.useState(null);
10916
+ const [drag, setDrag] = React.useState(null);
10917
+ const [sizing, setSizing] = React.useState(false);
10918
+ const { w, h } = dim;
10919
+ const phone = w < 600;
10920
+ const exOverlay = w < 960;
10921
+ const sideOverlay = w < 1280;
10922
+ const bodyH = Math.max(0, h - TOP);
10923
+ const [lastBand, setLastBand] = React.useState(0);
10924
+ const band = phone ? 3 : exOverlay ? 2 : sideOverlay ? 1 : 0;
10925
+ if (band !== lastBand) {
10926
+ setLastBand(band);
10927
+ setOv({
10928
+ explorer: false,
10929
+ side: false
10930
+ });
10931
+ setSheet((s) => ({
10932
+ ...s,
10933
+ open: false
10934
+ }));
10935
+ }
10936
+ const panelMax = Math.max(LIM.panel[0], Math.round(bodyH * .6));
10937
+ const exW = phone ? Math.round(w * .85) : clamp(lay.size.explorer, LIM.explorer[0], LIM.explorer[1]);
10938
+ const sideW = phone ? w : Math.min(clamp(lay.size.side, LIM.side[0], LIM.side[1]), w - 48);
10939
+ const panelH = clamp(lay.size.panel, LIM.panel[0], panelMax);
10940
+ const sheetMax = Math.round(bodyH * .75);
10941
+ const sheetSize = clamp(sheetH ?? bodyH * .45, 120, Math.max(120, sheetMax));
10942
+ const exOpen = exOverlay ? ov.explorer : lay.open.explorer;
10943
+ const sideHas = lay.side.length > 0;
10944
+ const panelHas = lay.panel.length > 0;
10945
+ const sideOpen = !phone && sideHas && (sideOverlay ? ov.side : lay.open.side);
10946
+ const panelOpen = !phone && panelHas && lay.open.panel;
10947
+ const exDocked = !exOverlay && exOpen;
10948
+ const sideDocked = !sideOverlay && sideOpen;
10949
+ const merged = [...lay.side, ...lay.panel];
10950
+ const sheetOpen = phone && sheet.open && merged.length > 0;
10951
+ const mainL = exDocked ? exW : 0;
10952
+ const mainR = sideDocked ? sideW : 0;
10953
+ const mainB = phone ? sheetOpen ? sheetSize : 0 : panelOpen ? panelH : 0;
10954
+ const activeOf = (r) => {
10955
+ const a = lay.active[r];
10956
+ return a && lay[r].includes(a) ? a : lay[r][0];
10957
+ };
10958
+ const update = React.useCallback((fn) => setLay((l) => fn(l)), []);
10959
+ const openSheet = (from) => setSheet((s) => {
10960
+ const act = lay.active[from] && lay[from].includes(lay.active[from]) ? lay.active[from] : lay[from][0];
10961
+ return s.open && s.act === act ? {
10962
+ open: false,
10963
+ act
10964
+ } : {
10965
+ open: true,
10966
+ act: act ?? merged[0]
10967
+ };
10968
+ });
10969
+ const toggle = (r) => {
10970
+ if (r === "explorer") {
10971
+ if (exOverlay) setOv((o) => ({
10972
+ ...o,
10973
+ explorer: !o.explorer
10974
+ }));
10975
+ else update((l) => ({
10976
+ ...l,
10977
+ open: {
10978
+ ...l.open,
10979
+ explorer: !l.open.explorer
10980
+ }
10981
+ }));
10982
+ } else if (phone) openSheet(r);
10983
+ else if (r === "side" && sideOverlay) setOv((o) => ({
10984
+ ...o,
10985
+ side: !o.side
10986
+ }));
10987
+ else update((l) => ({
10988
+ ...l,
10989
+ open: {
10990
+ ...l.open,
10991
+ [r]: !l.open[r]
10992
+ }
10993
+ }));
10994
+ };
10995
+ const toggleRef = React.useRef(toggle);
10996
+ React.useLayoutEffect(() => {
10997
+ toggleRef.current = toggle;
10998
+ });
10999
+ React.useEffect(() => {
11000
+ const onKey = (e) => {
11001
+ if (e.key === "Escape") {
11002
+ setOv((o) => o.explorer || o.side ? {
11003
+ explorer: false,
11004
+ side: false
11005
+ } : o);
11006
+ return;
11007
+ }
11008
+ if (!(IS_MAC ? e.metaKey : e.ctrlKey) || e.shiftKey) return;
11009
+ const k = e.key.toLowerCase();
11010
+ const code = e.code;
11011
+ if ((k === "b" || code === "KeyB") && e.altKey) toggleRef.current("side");
11012
+ else if (k === "b" || code === "KeyB") {
11013
+ if (inField(e.target)) return;
11014
+ toggleRef.current("explorer");
11015
+ } else if (k === "j" || code === "KeyJ") toggleRef.current("panel");
11016
+ else return;
11017
+ e.preventDefault();
11018
+ };
11019
+ document.addEventListener("keydown", onKey);
11020
+ return () => document.removeEventListener("keydown", onKey);
11021
+ }, []);
11022
+ const move = (id, to, before) => update((l) => {
11023
+ const from = l.side.includes(id) ? "side" : "panel";
11024
+ const n = {
11025
+ ...l,
11026
+ side: l.side.filter((x) => x !== id),
11027
+ panel: l.panel.filter((x) => x !== id),
11028
+ active: { ...l.active },
11029
+ open: { ...l.open }
11030
+ };
11031
+ const arr = n[to];
11032
+ const i = before ? arr.indexOf(before) : -1;
11033
+ if (i >= 0) arr.splice(i, 0, id);
11034
+ else arr.push(id);
11035
+ n.active[to] = id;
11036
+ if (from !== to && l.active[from] === id) n.active[from] = n[from][0];
11037
+ n.open[to] = true;
11038
+ return n;
11039
+ });
11040
+ const moveOver = (r) => {
11041
+ const act = activeOf(r);
11042
+ if (!act) return;
11043
+ move(act, r === "side" ? "panel" : "side", null);
11044
+ if (r === "side" && sideOverlay) setOv((o) => ({
11045
+ ...o,
11046
+ side: false
11047
+ }));
11048
+ if (r === "panel" && sideOverlay) setOv((o) => ({
11049
+ ...o,
11050
+ side: true
11051
+ }));
11052
+ };
11053
+ const resetLayout = () => {
11054
+ setLay(defaults(views, p.defaultLayout));
11055
+ setOv({
11056
+ explorer: false,
11057
+ side: false
11058
+ });
11059
+ setSheet({ open: false });
11060
+ setSheetH(null);
11061
+ };
11062
+ const show = (viewId) => {
11063
+ const r = lay.side.includes(viewId) ? "side" : lay.panel.includes(viewId) ? "panel" : null;
11064
+ devWarn(!r, "Workbench", `show('${viewId}'): no view has this id. Pass the id of one of the views.`);
11065
+ if (!r) return;
11066
+ const remember = !phone && !(r === "side" && sideOverlay);
11067
+ update((l) => ({
11068
+ ...l,
11069
+ active: {
11070
+ ...l.active,
11071
+ [r]: viewId
11072
+ },
11073
+ open: remember ? {
11074
+ ...l.open,
11075
+ [r]: true
11076
+ } : l.open
11077
+ }));
11078
+ if (phone) setSheet({
11079
+ open: true,
11080
+ act: viewId
11081
+ });
11082
+ else if (r === "side" && sideOverlay) setOv((o) => ({
11083
+ ...o,
11084
+ side: true
11085
+ }));
11086
+ };
11087
+ const api = {
11088
+ resetLayout,
11089
+ toggle,
11090
+ explorerPicked: () => {
11091
+ if (exOverlay) setOv((o) => ({
11092
+ ...o,
11093
+ explorer: false
11094
+ }));
11095
+ },
11096
+ phone,
11097
+ show,
11098
+ layout: lay
11099
+ };
11100
+ const latest = React.useRef(api);
11101
+ React.useLayoutEffect(() => {
11102
+ latest.current = api;
11103
+ });
11104
+ React.useImperativeHandle(ref, () => ({
11105
+ show: (id) => latest.current.show(id),
11106
+ toggle: (r) => latest.current.toggle(r),
11107
+ resetLayout: () => latest.current.resetLayout(),
11108
+ explorerPicked: () => latest.current.explorerPicked(),
11109
+ get phone() {
11110
+ return latest.current.phone;
11111
+ },
11112
+ getLayout: () => latest.current.layout
11113
+ }), []);
11114
+ const regionName = {
11115
+ explorer: tr("檔案總管"),
11116
+ side: tr("右側欄"),
11117
+ panel: tr("下方面板")
11118
+ };
11119
+ const keys = {
11120
+ explorer: (IS_MAC ? "⌘" : "Ctrl ") + "B",
11121
+ side: (IS_MAC ? "⌘⌥" : "Ctrl Alt ") + "B",
11122
+ panel: (IS_MAC ? "⌘" : "Ctrl ") + "J"
11123
+ };
11124
+ const attention = (r) => lay[r].some((id) => byId[id]?.attention);
11125
+ const toggleBtn = (r, open, dot) => /* @__PURE__ */ jsxs("span", {
11126
+ className: "ui-wb-toggle",
11127
+ children: [/* @__PURE__ */ jsx(IconButton, {
11128
+ variant: "quiet",
11129
+ icon: toggleIcon(r, open),
11130
+ label: regionName[r] + "(" + keys[r] + ")",
11131
+ "aria-pressed": open,
11132
+ onClick: () => toggle(r)
11133
+ }), dot ? /* @__PURE__ */ jsx("span", {
11134
+ className: "ui-wb-dot is-on-button",
11135
+ "aria-hidden": "true"
11136
+ }) : null]
11137
+ });
11138
+ const dropFrame = (r) => {
11139
+ const o = drag?.over;
11140
+ if (!o || o.region !== r) return null;
11141
+ const same = lay[r].includes(drag.id);
11142
+ const text = o.noop ? tr("位置不變") : same ? tr("放開以排在這裡") : tr("放開以移到{region}", { region: regionName[r] });
11143
+ return /* @__PURE__ */ jsx("div", {
11144
+ className: "ui-wb-dropframe",
11145
+ "aria-hidden": "true",
11146
+ children: /* @__PURE__ */ jsx("span", { children: text })
11147
+ });
11148
+ };
11149
+ const regionDrop = (r) => ({
11150
+ onDragOver: (e) => {
11151
+ if (!drag) return;
11152
+ e.preventDefault();
11153
+ const noop = lay[r][lay[r].length - 1] === drag.id;
11154
+ const o = drag.over;
11155
+ if (!o || o.region !== r || o.before !== null || o.noop !== noop) setDrag({
11156
+ id: drag.id,
11157
+ over: {
11158
+ region: r,
11159
+ before: null,
11160
+ noop
11161
+ }
11162
+ });
11163
+ },
11164
+ onDrop: (e) => {
11165
+ e.preventDefault();
11166
+ if (drag && !drag.over?.noop) move(drag.id, r, drag.over?.region === r ? drag.over.before : null);
11167
+ setDrag(null);
11168
+ }
11169
+ });
11170
+ const regionBox = (r) => {
11171
+ const act = activeOf(r);
11172
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
11173
+ /* @__PURE__ */ jsx(TabRow, {
11174
+ name: regionName[r],
11175
+ region: r,
11176
+ ids: lay[r],
11177
+ active: act,
11178
+ views: byId,
11179
+ onPick: (id) => update((l) => ({
11180
+ ...l,
11181
+ active: {
11182
+ ...l.active,
11183
+ [r]: id
11184
+ }
11185
+ })),
11186
+ overflow: "menu",
11187
+ drag,
11188
+ setDrag,
11189
+ onDrop: (id, before) => move(id, r, before),
11190
+ buttons: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconButton, {
11191
+ variant: "quiet",
11192
+ icon: MOVE_ICON,
11193
+ label: tr("把目前分頁移到{region}", { region: regionName[r === "side" ? "panel" : "side"] }),
11194
+ onClick: () => moveOver(r),
11195
+ disabled: !act
11196
+ }), /* @__PURE__ */ jsx(IconButton, {
11197
+ variant: "quiet",
11198
+ icon: r === "side" ? "caret-right" : "caret-down",
11199
+ label: tr("收合{region}", { region: regionName[r] }) + "(" + keys[r] + ")",
11200
+ onClick: () => toggle(r)
11201
+ })] })
11202
+ }),
11203
+ /* @__PURE__ */ jsx(Pane, { view: act ? byId[act] : void 0 }),
11204
+ dropFrame(r)
11205
+ ] });
11206
+ };
11207
+ const brand = p.brand;
11208
+ const brandInner = brand ? /* @__PURE__ */ jsxs(Fragment, { children: [brand.mark ? /* @__PURE__ */ jsx("span", {
11209
+ className: "ui-wb-mark",
11210
+ "aria-hidden": "true",
11211
+ children: brand.mark
11212
+ }) : null, /* @__PURE__ */ jsx("span", {
11213
+ className: "ui-wb-name",
11214
+ children: brand.name
11215
+ })] }) : null;
11216
+ const sheetAct = sheet.act && merged.includes(sheet.act) ? sheet.act : merged[0];
11217
+ const sheetIdx = merged.indexOf(sheetAct ?? "");
11218
+ const pickSheet = (id) => {
11219
+ setSheet((s) => ({
11220
+ ...s,
11221
+ act: id
11222
+ }));
11223
+ const r = lay.side.includes(id) ? "side" : "panel";
11224
+ update((l) => ({
11225
+ ...l,
11226
+ active: {
11227
+ ...l.active,
11228
+ [r]: id
11229
+ }
11230
+ }));
11231
+ };
11232
+ const reorderMerged = (next) => {
11233
+ const nSide = lay.side.length;
11234
+ update((l) => ({
11235
+ ...l,
11236
+ side: next.slice(0, nSide),
11237
+ panel: next.slice(nSide)
11238
+ }));
11239
+ };
11240
+ const shiftSheet = (dir) => {
11241
+ const j = sheetIdx + dir;
11242
+ if (sheetIdx < 0 || j < 0 || j >= merged.length) return;
11243
+ const next = merged.slice();
11244
+ next[sheetIdx] = next[j];
11245
+ next[j] = sheetAct;
11246
+ reorderMerged(next);
11247
+ };
11248
+ const showDropSide = !!drag && !phone && !sideDocked;
11249
+ const showDropPanel = !!drag && !phone && !panelOpen;
11250
+ return /* @__PURE__ */ jsx(Ctx.Provider, {
11251
+ value: api,
11252
+ children: /* @__PURE__ */ jsxs("div", {
11253
+ ref: root,
11254
+ className: cx("ui-wb", phone && "is-phone", sizing && "is-sizing", p.className),
11255
+ role: "group",
11256
+ "aria-label": p.label ?? tr("編輯器"),
11257
+ children: [/* @__PURE__ */ jsxs("header", {
11258
+ className: "ui-wb-top",
11259
+ children: [/* @__PURE__ */ jsxs("div", {
11260
+ className: "ui-wb-top-l",
11261
+ children: [
11262
+ toggleBtn("explorer", exOpen, false),
11263
+ brand ? brand.href ? /* @__PURE__ */ jsx("a", {
11264
+ className: "ui-wb-brand",
11265
+ href: brand.href,
11266
+ "aria-label": phone ? brand.name : void 0,
11267
+ children: brandInner
11268
+ }) : /* @__PURE__ */ jsx("span", {
11269
+ className: "ui-wb-brand",
11270
+ children: brandInner
11271
+ }) : null,
11272
+ p.crumbs?.length ? /* @__PURE__ */ jsx(Breadcrumb, {
11273
+ className: "ui-wb-crumbs",
11274
+ items: phone ? p.crumbs.slice(-1) : p.crumbs
11275
+ }) : null
11276
+ ]
11277
+ }), /* @__PURE__ */ jsxs("div", {
11278
+ className: "ui-wb-top-r",
11279
+ children: [
11280
+ p.actions,
11281
+ views.length ? /* @__PURE__ */ jsx("span", {
11282
+ className: "ui-wb-sep",
11283
+ "aria-hidden": "true"
11284
+ }) : null,
11285
+ views.length ? toggleBtn("panel", phone ? sheetOpen && lay.panel.includes(sheetAct ?? "") : panelOpen, (phone ? !sheetOpen : !panelOpen) && attention("panel")) : null,
11286
+ views.length ? toggleBtn("side", phone ? sheetOpen && lay.side.includes(sheetAct ?? "") : sideOpen, (phone ? !sheetOpen : !sideOpen) && attention("side")) : null
11287
+ ]
11288
+ })]
11289
+ }), /* @__PURE__ */ jsxs("div", {
11290
+ className: "ui-wb-body",
11291
+ children: [
11292
+ /* @__PURE__ */ jsx("main", {
11293
+ className: "ui-wb-main",
11294
+ style: {
11295
+ left: mainL,
11296
+ right: mainR,
11297
+ bottom: mainB
11298
+ },
11299
+ children: p.children
11300
+ }),
11301
+ p.explorer || p.explorerHead || p.explorerFoot ? /* @__PURE__ */ jsxs(Fragment, { children: [
11302
+ exOverlay ? /* @__PURE__ */ jsx("button", {
11303
+ type: "button",
11304
+ tabIndex: -1,
11305
+ className: cx("ui-wb-scrim", exOpen && "is-open"),
11306
+ "aria-label": tr("關閉{region}", { region: regionName.explorer }),
11307
+ onClick: () => setOv((o) => ({
11308
+ ...o,
11309
+ explorer: false
11310
+ }))
11311
+ }) : null,
11312
+ /* @__PURE__ */ jsxs("aside", {
11313
+ className: cx("ui-wb-ex", exOverlay ? "is-drawer" : "is-docked", exOpen ? "is-open" : "is-shut"),
11314
+ style: { width: exW },
11315
+ "aria-label": regionName.explorer,
11316
+ inert: !exOpen,
11317
+ children: [
11318
+ p.explorerHead ? /* @__PURE__ */ jsx("div", {
11319
+ className: "ui-wb-exhead",
11320
+ children: p.explorerHead
11321
+ }) : null,
11322
+ /* @__PURE__ */ jsx("div", {
11323
+ className: "ui-wb-exbody",
11324
+ children: p.explorer
11325
+ }),
11326
+ p.explorerFoot ? /* @__PURE__ */ jsx("div", {
11327
+ className: "ui-wb-exfoot",
11328
+ children: p.explorerFoot
11329
+ }) : null
11330
+ ]
11331
+ }),
11332
+ exDocked ? /* @__PURE__ */ jsx(Splitter, {
11333
+ label: tr("{region}寬度", { region: regionName.explorer }),
11334
+ vertical: true,
11335
+ grow: 1,
11336
+ value: exW,
11337
+ min: LIM.explorer[0],
11338
+ max: LIM.explorer[1],
11339
+ onChange: (v) => update((l) => ({
11340
+ ...l,
11341
+ size: {
11342
+ ...l.size,
11343
+ explorer: v
11344
+ }
11345
+ })),
11346
+ onReset: () => update((l) => ({
11347
+ ...l,
11348
+ size: {
11349
+ ...l.size,
11350
+ explorer: def.size.explorer
11351
+ }
11352
+ })),
11353
+ onDrag: setSizing,
11354
+ style: { left: exW }
11355
+ }) : null
11356
+ ] }) : null,
11357
+ !phone && panelHas ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("section", {
11358
+ className: cx("ui-wb-panel", panelOpen ? "is-open" : "is-shut", drag?.over?.region === "panel" && "is-dropping"),
11359
+ style: {
11360
+ left: mainL,
11361
+ right: mainR,
11362
+ height: panelH
11363
+ },
11364
+ "aria-label": regionName.panel,
11365
+ inert: !panelOpen,
11366
+ ...regionDrop("panel"),
11367
+ children: regionBox("panel")
11368
+ }), panelOpen ? /* @__PURE__ */ jsx(Splitter, {
11369
+ label: tr("{region}高度", { region: regionName.panel }),
11370
+ vertical: false,
11371
+ grow: -1,
11372
+ value: panelH,
11373
+ min: LIM.panel[0],
11374
+ max: panelMax,
11375
+ onChange: (v) => update((l) => ({
11376
+ ...l,
11377
+ size: {
11378
+ ...l.size,
11379
+ panel: v
11380
+ }
11381
+ })),
11382
+ onReset: () => update((l) => ({
11383
+ ...l,
11384
+ size: {
11385
+ ...l.size,
11386
+ panel: def.size.panel
11387
+ }
11388
+ })),
11389
+ onDrag: setSizing,
11390
+ style: {
11391
+ left: mainL,
11392
+ right: mainR,
11393
+ bottom: panelH
11394
+ }
11395
+ }) : null] }) : null,
11396
+ !phone && sideHas ? /* @__PURE__ */ jsxs(Fragment, { children: [
11397
+ sideOverlay ? /* @__PURE__ */ jsx("button", {
11398
+ type: "button",
11399
+ tabIndex: -1,
11400
+ className: cx("ui-wb-scrim", sideOpen && "is-open"),
11401
+ "aria-label": tr("關閉{region}", { region: regionName.side }),
11402
+ onClick: () => setOv((o) => ({
11403
+ ...o,
11404
+ side: false
11405
+ }))
11406
+ }) : null,
11407
+ /* @__PURE__ */ jsx("aside", {
11408
+ className: cx("ui-wb-side", sideOverlay ? "is-drawer" : "is-docked", sideOpen ? "is-open" : "is-shut", drag?.over?.region === "side" && "is-dropping"),
11409
+ style: { width: sideW },
11410
+ "aria-label": regionName.side,
11411
+ inert: !sideOpen,
11412
+ ...regionDrop("side"),
11413
+ children: regionBox("side")
11414
+ }),
11415
+ sideDocked ? /* @__PURE__ */ jsx(Splitter, {
11416
+ label: tr("{region}寬度", { region: regionName.side }),
11417
+ vertical: true,
11418
+ grow: -1,
11419
+ value: sideW,
11420
+ min: LIM.side[0],
11421
+ max: LIM.side[1],
11422
+ onChange: (v) => update((l) => ({
11423
+ ...l,
11424
+ size: {
11425
+ ...l.size,
11426
+ side: v
11427
+ }
11428
+ })),
11429
+ onReset: () => update((l) => ({
11430
+ ...l,
11431
+ size: {
11432
+ ...l.size,
11433
+ side: def.size.side
11434
+ }
11435
+ })),
11436
+ onDrag: setSizing,
11437
+ style: { right: sideW }
11438
+ }) : null
11439
+ ] }) : null,
11440
+ showDropSide ? /* @__PURE__ */ jsx("div", {
11441
+ className: cx("ui-wb-dropzone is-side", drag?.over?.region === "side" && "is-over"),
11442
+ style: { bottom: (panelOpen ? panelH : 0) + 8 },
11443
+ ...regionDrop("side"),
11444
+ children: tr("放開以移到{region}", { region: regionName.side })
11445
+ }) : null,
11446
+ showDropPanel ? /* @__PURE__ */ jsx("div", {
11447
+ className: cx("ui-wb-dropzone is-panel", drag?.over?.region === "panel" && "is-over"),
11448
+ style: {
11449
+ left: mainL + 8,
11450
+ right: mainR + (showDropSide ? 120 : 8)
11451
+ },
11452
+ ...regionDrop("panel"),
11453
+ children: tr("放開以移到{region}", { region: regionName.panel })
11454
+ }) : null,
11455
+ phone && merged.length ? /* @__PURE__ */ jsxs("section", {
11456
+ className: cx("ui-wb-sheet", sheetOpen ? "is-open" : "is-shut"),
11457
+ style: { height: sheetSize },
11458
+ "aria-label": tr("面板分頁"),
11459
+ inert: !sheetOpen,
11460
+ children: [
11461
+ /* @__PURE__ */ jsx(Splitter, {
11462
+ label: tr("面板高度"),
11463
+ vertical: false,
11464
+ grow: -1,
11465
+ value: sheetSize,
11466
+ min: 120,
11467
+ max: Math.max(120, sheetMax),
11468
+ onChange: setSheetH,
11469
+ onReset: () => setSheetH(null),
11470
+ onDrag: setSizing,
11471
+ style: {
11472
+ top: 0,
11473
+ left: 0,
11474
+ right: 0
11475
+ }
11476
+ }),
11477
+ /* @__PURE__ */ jsx("span", {
11478
+ className: "ui-wb-grab",
11479
+ "aria-hidden": "true"
11480
+ }),
11481
+ /* @__PURE__ */ jsx(TabRow, {
11482
+ name: tr("面板分頁"),
11483
+ region: "sheet",
11484
+ ids: merged,
11485
+ active: sheetAct,
11486
+ views: byId,
11487
+ onPick: pickSheet,
11488
+ overflow: "scroll",
11489
+ onReorder: reorderMerged,
11490
+ buttons: /* @__PURE__ */ jsxs(Fragment, { children: [
11491
+ /* @__PURE__ */ jsx(IconButton, {
11492
+ variant: "quiet",
11493
+ icon: "caret-left",
11494
+ label: tr("目前分頁往左移"),
11495
+ disabled: sheetIdx <= 0,
11496
+ onClick: () => shiftSheet(-1)
11497
+ }),
11498
+ /* @__PURE__ */ jsx(IconButton, {
11499
+ variant: "quiet",
11500
+ icon: "caret-right",
11501
+ label: tr("目前分頁往右移"),
11502
+ disabled: sheetIdx < 0 || sheetIdx >= merged.length - 1,
11503
+ onClick: () => shiftSheet(1)
11504
+ }),
11505
+ /* @__PURE__ */ jsx(IconButton, {
11506
+ variant: "quiet",
11507
+ icon: "caret-down",
11508
+ label: tr("收起面板"),
11509
+ onClick: () => setSheet((s) => ({
11510
+ ...s,
11511
+ open: false
11512
+ }))
11513
+ })
11514
+ ] })
11515
+ }),
11516
+ /* @__PURE__ */ jsx(Pane, {
11517
+ view: sheetAct ? byId[sheetAct] : void 0,
11518
+ onSwipe: (dir) => {
11519
+ const j = sheetIdx + dir;
11520
+ if (j >= 0 && j < merged.length) pickSheet(merged[j]);
11521
+ }
11522
+ }),
11523
+ /* @__PURE__ */ jsx("div", {
11524
+ className: "ui-wb-dots",
11525
+ "aria-hidden": "true",
11526
+ children: merged.map((id) => /* @__PURE__ */ jsx("span", { className: cx("ui-wb-pagedot", id === sheetAct && "is-on") }, id))
11527
+ })
11528
+ ]
11529
+ }) : null
11530
+ ]
11531
+ })]
11532
+ })
11533
+ });
11534
+ }
11535
+ export { AccentPicker, ActionBar, AiMark, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Markdown, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Section, SectionGroup, SectionGroupToggle, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, Workbench, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour, useWorkbench };
10432
11536
 
10433
11537
  //# sourceMappingURL=index.js.map