@seanyeh77/ui 0.27.0 → 0.29.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";
@@ -491,7 +491,66 @@ function announce(text) {
491
491
  el.textContent = text;
492
492
  }, 60);
493
493
  }
494
+ // src/internal/dev.ts
495
+ const DEV = typeof __UI_DEV__ === "boolean" ? __UI_DEV__ : (() => {
496
+ try {
497
+ return process.env.NODE_ENV !== "production";
498
+ } catch {
499
+ return false;
500
+ }
501
+ })();
502
+ const seen = /* @__PURE__ */ new Set();
503
+ /** Logs once per message when cond is true. */
504
+ function devWarn(cond, component, message) {
505
+ if (!DEV || !cond) return;
506
+ const text = `[@seanyeh77/ui] ${component}: ${message}`;
507
+ if (seen.has(text)) return;
508
+ seen.add(text);
509
+ console.warn(text);
510
+ }
494
511
  // src/components/SideNav/SideNav.tsx
512
+ const isBrand = (b) => !!b && typeof b === "object" && !React.isValidElement(b) && !Array.isArray(b) && typeof b.name === "string";
513
+ function NavBrandRow({ brand, collapsed }) {
514
+ const spec = isBrand(brand) ? brand : typeof brand === "string" ? { name: brand } : null;
515
+ devWarn(!spec && collapsed, "SideNav", "brand 是一個元素,收合時讀不出哪部分是 logo,只能整塊藏起來。改傳 brand={{ mark, name, href }}:收合時顯示 mark,展開時加上名稱。");
516
+ if (!spec) return /* @__PURE__ */ jsx("div", {
517
+ className: "ui-nav-brand",
518
+ children: collapsed ? null : brand
519
+ });
520
+ const inner = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
521
+ className: "ui-nav-mark",
522
+ "aria-hidden": "true",
523
+ children: spec.mark ?? /* @__PURE__ */ jsx("span", {
524
+ className: "ui-nav-monogram",
525
+ children: Array.from(spec.name)[0]
526
+ })
527
+ }), /* @__PURE__ */ jsx("span", {
528
+ className: "ui-nav-brand-name",
529
+ children: spec.name
530
+ })] });
531
+ const label = collapsed ? spec.name : void 0;
532
+ return /* @__PURE__ */ jsx("div", {
533
+ className: "ui-nav-brand has-mark",
534
+ children: spec.href ? /* @__PURE__ */ jsx("a", {
535
+ className: "ui-nav-brand-link",
536
+ href: spec.href,
537
+ onClick: spec.onClick,
538
+ "aria-label": label,
539
+ children: inner
540
+ }) : spec.onClick ? /* @__PURE__ */ jsx("button", {
541
+ type: "button",
542
+ className: "ui-nav-brand-link",
543
+ onClick: spec.onClick,
544
+ "aria-label": label,
545
+ children: inner
546
+ }) : /* @__PURE__ */ jsx("span", {
547
+ className: "ui-nav-brand-link",
548
+ "aria-label": label,
549
+ role: label ? "img" : void 0,
550
+ children: inner
551
+ })
552
+ });
553
+ }
495
554
  /** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */
496
555
  function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin, pinned = false, brand, label, className }) {
497
556
  const refs = React.useRef({});
@@ -594,9 +653,9 @@ function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin
594
653
  return /* @__PURE__ */ jsxs("aside", {
595
654
  className: cx("ui-sidenav", collapsed && "is-collapsed", className),
596
655
  children: [
597
- brand ? /* @__PURE__ */ jsx("div", {
598
- className: "ui-nav-brand",
599
- children: brand
656
+ brand ? /* @__PURE__ */ jsx(NavBrandRow, {
657
+ brand,
658
+ collapsed
600
659
  }) : null,
601
660
  /* @__PURE__ */ jsx("nav", {
602
661
  className: "ui-nav-list",
@@ -734,12 +793,12 @@ function Tooltip({ label, side = "top", describe = true, wrap = false, disabled
734
793
  }
735
794
  // src/components/IconButton/IconButton.tsx
736
795
  /** A square icon-only button with a tooltip. */
737
- function IconButton({ label, icon, className, tooltip = true, filled, hint, ...native }) {
796
+ function IconButton({ label, icon, className, tooltip = true, filled, hint, variant, ...native }) {
738
797
  const id = React.useId();
739
798
  const btn = /* @__PURE__ */ jsxs("button", {
740
799
  type: "button",
741
800
  ...native,
742
- className: cx("ui-iconbtn", hint && "has-hint", className),
801
+ className: cx("ui-iconbtn", variant === "quiet" && "is-quiet", hint && "has-hint", className),
743
802
  "aria-label": label,
744
803
  "aria-describedby": hint ? id : native["aria-describedby"],
745
804
  children: [/* @__PURE__ */ jsx(IconOf, {
@@ -869,23 +928,6 @@ function MobileTabBar({ items, value, onChange, label, labels = true, className
869
928
  }, t.id))]
870
929
  });
871
930
  }
872
- // src/internal/dev.ts
873
- const DEV = typeof __UI_DEV__ === "boolean" ? __UI_DEV__ : (() => {
874
- try {
875
- return process.env.NODE_ENV !== "production";
876
- } catch {
877
- return false;
878
- }
879
- })();
880
- const seen = /* @__PURE__ */ new Set();
881
- /** Logs once per message when cond is true. */
882
- function devWarn(cond, component, message) {
883
- if (!DEV || !cond) return;
884
- const text = `[@seanyeh77/ui] ${component}: ${message}`;
885
- if (seen.has(text)) return;
886
- seen.add(text);
887
- console.warn(text);
888
- }
889
931
  // src/components/Button/Button.tsx
890
932
  /** Buttons. Labels are verbs; one primary per section; danger actions are always confirmed. */
891
933
  function Button(props) {
@@ -5122,7 +5164,7 @@ const HANDLE = 16;
5122
5164
  /** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */
5123
5165
  const STACK = 960;
5124
5166
  /** One arrow key press, in px. */
5125
- const STEP = 16;
5167
+ const STEP$1 = 16;
5126
5168
  const read = (key) => {
5127
5169
  if (!key) return null;
5128
5170
  try {
@@ -5171,7 +5213,7 @@ function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, l
5171
5213
  };
5172
5214
  const onKey = (e) => {
5173
5215
  if (browserKey(e)) return;
5174
- 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;
5175
5217
  if (to == null) return;
5176
5218
  e.preventDefault();
5177
5219
  set(to);
@@ -9839,6 +9881,8 @@ function TreeList(p) {
9839
9881
  const { items } = p;
9840
9882
  const single = p.expand === "single";
9841
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.");
9842
9886
  const sort = p.sort === void 0 ? plain ? false : "newest" : p.sort;
9843
9887
  const selectable = !!p.selectable && !plain;
9844
9888
  devWarn(plain && p.selectable, "TreeList", "selectable works with kind=\"files\" only; for plain trees use selectedId and onSelect.");
@@ -10062,7 +10106,8 @@ function TreeList(p) {
10062
10106
  n.name,
10063
10107
  ...(n.tags ?? []).map(nodeText),
10064
10108
  n.meta,
10065
- n.path
10109
+ n.path,
10110
+ n.mark?.label
10066
10111
  ].filter(Boolean).join(tr(",")),
10067
10112
  "aria-selected": p.onSelect ? on : void 0,
10068
10113
  className: cx("ui-tree-row", "is-plain", on && "is-current", n.muted && "is-muted", r.fresh && "ui-tree-in"),
@@ -10084,7 +10129,7 @@ function TreeList(p) {
10084
10129
  },
10085
10130
  children: /* @__PURE__ */ jsx(Icon, {
10086
10131
  name: "caret-right",
10087
- size: 16
10132
+ size: compact ? 14 : 16
10088
10133
  })
10089
10134
  }),
10090
10135
  n.icon ? /* @__PURE__ */ jsx("span", {
@@ -10092,7 +10137,7 @@ function TreeList(p) {
10092
10137
  "aria-hidden": "true",
10093
10138
  children: /* @__PURE__ */ jsx(IconOf, {
10094
10139
  icon: n.icon,
10095
- size: 20
10140
+ size: compact ? 16 : 20
10096
10141
  })
10097
10142
  }) : null,
10098
10143
  /* @__PURE__ */ jsxs("div", {
@@ -10117,6 +10162,11 @@ function TreeList(p) {
10117
10162
  children: n.meta != null ? digits(meta, /(\d[\d,.]*)/) : meta
10118
10163
  }) : null]
10119
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,
10120
10170
  p.rowActions ? /* @__PURE__ */ jsx("span", {
10121
10171
  className: "ui-tree-act",
10122
10172
  onClick: (e) => e.stopPropagation(),
@@ -10369,7 +10419,7 @@ function TreeList(p) {
10369
10419
  return [out, i];
10370
10420
  };
10371
10421
  return /* @__PURE__ */ jsxs("section", {
10372
- 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),
10373
10423
  "aria-label": p.title ? void 0 : p.label,
10374
10424
  style: p.height != null ? { height: typeof p.height === "number" ? p.height + "px" : p.height } : void 0,
10375
10425
  children: [head, rows.length ? /* @__PURE__ */ jsx("div", {
@@ -10386,6 +10436,1047 @@ function TreeList(p) {
10386
10436
  })]
10387
10437
  });
10388
10438
  }
10389
- 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(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 [ov, setOv] = React.useState({
10907
+ explorer: false,
10908
+ side: false
10909
+ });
10910
+ const [sheet, setSheet] = React.useState({ open: false });
10911
+ const [sheetH, setSheetH] = React.useState(null);
10912
+ const [drag, setDrag] = React.useState(null);
10913
+ const [sizing, setSizing] = React.useState(false);
10914
+ const { w, h } = dim;
10915
+ const phone = w < 600;
10916
+ const exOverlay = w < 960;
10917
+ const sideOverlay = w < 1280;
10918
+ const bodyH = Math.max(0, h - TOP);
10919
+ const [lastBand, setLastBand] = React.useState(0);
10920
+ const band = phone ? 3 : exOverlay ? 2 : sideOverlay ? 1 : 0;
10921
+ if (band !== lastBand) {
10922
+ setLastBand(band);
10923
+ setOv({
10924
+ explorer: false,
10925
+ side: false
10926
+ });
10927
+ setSheet((s) => ({
10928
+ ...s,
10929
+ open: false
10930
+ }));
10931
+ }
10932
+ const panelMax = Math.max(LIM.panel[0], Math.round(bodyH * .6));
10933
+ const exW = phone ? Math.round(w * .85) : clamp(lay.size.explorer, LIM.explorer[0], LIM.explorer[1]);
10934
+ const sideW = phone ? w : Math.min(clamp(lay.size.side, LIM.side[0], LIM.side[1]), w - 48);
10935
+ const panelH = clamp(lay.size.panel, LIM.panel[0], panelMax);
10936
+ const sheetMax = Math.round(bodyH * .75);
10937
+ const sheetSize = clamp(sheetH ?? bodyH * .45, 120, Math.max(120, sheetMax));
10938
+ const exOpen = exOverlay ? ov.explorer : lay.open.explorer;
10939
+ const sideHas = lay.side.length > 0;
10940
+ const panelHas = lay.panel.length > 0;
10941
+ const sideOpen = !phone && sideHas && (sideOverlay ? ov.side : lay.open.side);
10942
+ const panelOpen = !phone && panelHas && lay.open.panel;
10943
+ const exDocked = !exOverlay && exOpen;
10944
+ const sideDocked = !sideOverlay && sideOpen;
10945
+ const merged = [...lay.side, ...lay.panel];
10946
+ const sheetOpen = phone && sheet.open && merged.length > 0;
10947
+ const mainL = exDocked ? exW : 0;
10948
+ const mainR = sideDocked ? sideW : 0;
10949
+ const mainB = phone ? sheetOpen ? sheetSize : 0 : panelOpen ? panelH : 0;
10950
+ const activeOf = (r) => {
10951
+ const a = lay.active[r];
10952
+ return a && lay[r].includes(a) ? a : lay[r][0];
10953
+ };
10954
+ const update = React.useCallback((fn) => setLay((l) => fn(l)), []);
10955
+ const openSheet = (from) => setSheet((s) => {
10956
+ const act = lay.active[from] && lay[from].includes(lay.active[from]) ? lay.active[from] : lay[from][0];
10957
+ return s.open && s.act === act ? {
10958
+ open: false,
10959
+ act
10960
+ } : {
10961
+ open: true,
10962
+ act: act ?? merged[0]
10963
+ };
10964
+ });
10965
+ const toggle = (r) => {
10966
+ if (r === "explorer") {
10967
+ if (exOverlay) setOv((o) => ({
10968
+ ...o,
10969
+ explorer: !o.explorer
10970
+ }));
10971
+ else update((l) => ({
10972
+ ...l,
10973
+ open: {
10974
+ ...l.open,
10975
+ explorer: !l.open.explorer
10976
+ }
10977
+ }));
10978
+ } else if (phone) openSheet(r);
10979
+ else if (r === "side" && sideOverlay) setOv((o) => ({
10980
+ ...o,
10981
+ side: !o.side
10982
+ }));
10983
+ else update((l) => ({
10984
+ ...l,
10985
+ open: {
10986
+ ...l.open,
10987
+ [r]: !l.open[r]
10988
+ }
10989
+ }));
10990
+ };
10991
+ const toggleRef = React.useRef(toggle);
10992
+ React.useLayoutEffect(() => {
10993
+ toggleRef.current = toggle;
10994
+ });
10995
+ React.useEffect(() => {
10996
+ const onKey = (e) => {
10997
+ if (e.key === "Escape") {
10998
+ setOv((o) => o.explorer || o.side ? {
10999
+ explorer: false,
11000
+ side: false
11001
+ } : o);
11002
+ return;
11003
+ }
11004
+ if (!(IS_MAC ? e.metaKey : e.ctrlKey) || e.shiftKey) return;
11005
+ const k = e.key.toLowerCase();
11006
+ const code = e.code;
11007
+ if ((k === "b" || code === "KeyB") && e.altKey) toggleRef.current("side");
11008
+ else if (k === "b" || code === "KeyB") {
11009
+ if (inField(e.target)) return;
11010
+ toggleRef.current("explorer");
11011
+ } else if (k === "j" || code === "KeyJ") toggleRef.current("panel");
11012
+ else return;
11013
+ e.preventDefault();
11014
+ };
11015
+ document.addEventListener("keydown", onKey);
11016
+ return () => document.removeEventListener("keydown", onKey);
11017
+ }, []);
11018
+ const move = (id, to, before) => update((l) => {
11019
+ const from = l.side.includes(id) ? "side" : "panel";
11020
+ const n = {
11021
+ ...l,
11022
+ side: l.side.filter((x) => x !== id),
11023
+ panel: l.panel.filter((x) => x !== id),
11024
+ active: { ...l.active },
11025
+ open: { ...l.open }
11026
+ };
11027
+ const arr = n[to];
11028
+ const i = before ? arr.indexOf(before) : -1;
11029
+ if (i >= 0) arr.splice(i, 0, id);
11030
+ else arr.push(id);
11031
+ n.active[to] = id;
11032
+ if (from !== to && l.active[from] === id) n.active[from] = n[from][0];
11033
+ n.open[to] = true;
11034
+ return n;
11035
+ });
11036
+ const moveOver = (r) => {
11037
+ const act = activeOf(r);
11038
+ if (!act) return;
11039
+ move(act, r === "side" ? "panel" : "side", null);
11040
+ if (r === "side" && sideOverlay) setOv((o) => ({
11041
+ ...o,
11042
+ side: false
11043
+ }));
11044
+ if (r === "panel" && sideOverlay) setOv((o) => ({
11045
+ ...o,
11046
+ side: true
11047
+ }));
11048
+ };
11049
+ const resetLayout = () => {
11050
+ setLay(defaults(views, p.defaultLayout));
11051
+ setOv({
11052
+ explorer: false,
11053
+ side: false
11054
+ });
11055
+ setSheet({ open: false });
11056
+ setSheetH(null);
11057
+ };
11058
+ const api = {
11059
+ resetLayout,
11060
+ toggle,
11061
+ explorerPicked: () => {
11062
+ if (exOverlay) setOv((o) => ({
11063
+ ...o,
11064
+ explorer: false
11065
+ }));
11066
+ },
11067
+ phone
11068
+ };
11069
+ const regionName = {
11070
+ explorer: tr("檔案總管"),
11071
+ side: tr("右側欄"),
11072
+ panel: tr("下方面板")
11073
+ };
11074
+ const keys = {
11075
+ explorer: (IS_MAC ? "⌘" : "Ctrl ") + "B",
11076
+ side: (IS_MAC ? "⌘⌥" : "Ctrl Alt ") + "B",
11077
+ panel: (IS_MAC ? "⌘" : "Ctrl ") + "J"
11078
+ };
11079
+ const attention = (r) => lay[r].some((id) => byId[id]?.attention);
11080
+ const toggleBtn = (r, open, dot) => /* @__PURE__ */ jsxs("span", {
11081
+ className: "ui-wb-toggle",
11082
+ children: [/* @__PURE__ */ jsx(IconButton, {
11083
+ variant: "quiet",
11084
+ icon: toggleIcon(r, open),
11085
+ label: regionName[r] + "(" + keys[r] + ")",
11086
+ "aria-pressed": open,
11087
+ onClick: () => toggle(r)
11088
+ }), dot ? /* @__PURE__ */ jsx("span", {
11089
+ className: "ui-wb-dot is-on-button",
11090
+ "aria-hidden": "true"
11091
+ }) : null]
11092
+ });
11093
+ const dropFrame = (r) => {
11094
+ const o = drag?.over;
11095
+ if (!o || o.region !== r) return null;
11096
+ const same = lay[r].includes(drag.id);
11097
+ const text = o.noop ? tr("位置不變") : same ? tr("放開以排在這裡") : tr("放開以移到{region}", { region: regionName[r] });
11098
+ return /* @__PURE__ */ jsx("div", {
11099
+ className: "ui-wb-dropframe",
11100
+ "aria-hidden": "true",
11101
+ children: /* @__PURE__ */ jsx("span", { children: text })
11102
+ });
11103
+ };
11104
+ const regionDrop = (r) => ({
11105
+ onDragOver: (e) => {
11106
+ if (!drag) return;
11107
+ e.preventDefault();
11108
+ const noop = lay[r][lay[r].length - 1] === drag.id;
11109
+ const o = drag.over;
11110
+ if (!o || o.region !== r || o.before !== null || o.noop !== noop) setDrag({
11111
+ id: drag.id,
11112
+ over: {
11113
+ region: r,
11114
+ before: null,
11115
+ noop
11116
+ }
11117
+ });
11118
+ },
11119
+ onDrop: (e) => {
11120
+ e.preventDefault();
11121
+ if (drag && !drag.over?.noop) move(drag.id, r, drag.over?.region === r ? drag.over.before : null);
11122
+ setDrag(null);
11123
+ }
11124
+ });
11125
+ const regionBox = (r) => {
11126
+ const act = activeOf(r);
11127
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
11128
+ /* @__PURE__ */ jsx(TabRow, {
11129
+ name: regionName[r],
11130
+ region: r,
11131
+ ids: lay[r],
11132
+ active: act,
11133
+ views: byId,
11134
+ onPick: (id) => update((l) => ({
11135
+ ...l,
11136
+ active: {
11137
+ ...l.active,
11138
+ [r]: id
11139
+ }
11140
+ })),
11141
+ overflow: "menu",
11142
+ drag,
11143
+ setDrag,
11144
+ onDrop: (id, before) => move(id, r, before),
11145
+ buttons: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconButton, {
11146
+ variant: "quiet",
11147
+ icon: MOVE_ICON,
11148
+ label: tr("把目前分頁移到{region}", { region: regionName[r === "side" ? "panel" : "side"] }),
11149
+ onClick: () => moveOver(r),
11150
+ disabled: !act
11151
+ }), /* @__PURE__ */ jsx(IconButton, {
11152
+ variant: "quiet",
11153
+ icon: r === "side" ? "caret-right" : "caret-down",
11154
+ label: tr("收合{region}", { region: regionName[r] }) + "(" + keys[r] + ")",
11155
+ onClick: () => toggle(r)
11156
+ })] })
11157
+ }),
11158
+ /* @__PURE__ */ jsx(Pane, { view: act ? byId[act] : void 0 }),
11159
+ dropFrame(r)
11160
+ ] });
11161
+ };
11162
+ const brand = p.brand;
11163
+ const brandInner = brand ? /* @__PURE__ */ jsxs(Fragment, { children: [brand.mark ? /* @__PURE__ */ jsx("span", {
11164
+ className: "ui-wb-mark",
11165
+ "aria-hidden": "true",
11166
+ children: brand.mark
11167
+ }) : null, /* @__PURE__ */ jsx("span", {
11168
+ className: "ui-wb-name",
11169
+ children: brand.name
11170
+ })] }) : null;
11171
+ const sheetAct = sheet.act && merged.includes(sheet.act) ? sheet.act : merged[0];
11172
+ const sheetIdx = merged.indexOf(sheetAct ?? "");
11173
+ const pickSheet = (id) => setSheet((s) => ({
11174
+ ...s,
11175
+ act: id
11176
+ }));
11177
+ const reorderMerged = (next) => {
11178
+ const nSide = lay.side.length;
11179
+ update((l) => ({
11180
+ ...l,
11181
+ side: next.slice(0, nSide),
11182
+ panel: next.slice(nSide)
11183
+ }));
11184
+ };
11185
+ const shiftSheet = (dir) => {
11186
+ const j = sheetIdx + dir;
11187
+ if (sheetIdx < 0 || j < 0 || j >= merged.length) return;
11188
+ const next = merged.slice();
11189
+ next[sheetIdx] = next[j];
11190
+ next[j] = sheetAct;
11191
+ reorderMerged(next);
11192
+ };
11193
+ const showDropSide = !!drag && !phone && !sideDocked;
11194
+ const showDropPanel = !!drag && !phone && !panelOpen;
11195
+ return /* @__PURE__ */ jsx(Ctx.Provider, {
11196
+ value: api,
11197
+ children: /* @__PURE__ */ jsxs("div", {
11198
+ ref: root,
11199
+ className: cx("ui-wb", phone && "is-phone", sizing && "is-sizing", p.className),
11200
+ role: "group",
11201
+ "aria-label": p.label ?? tr("編輯器"),
11202
+ children: [/* @__PURE__ */ jsxs("header", {
11203
+ className: "ui-wb-top",
11204
+ children: [/* @__PURE__ */ jsxs("div", {
11205
+ className: "ui-wb-top-l",
11206
+ children: [
11207
+ toggleBtn("explorer", exOpen, false),
11208
+ brand ? brand.href ? /* @__PURE__ */ jsx("a", {
11209
+ className: "ui-wb-brand",
11210
+ href: brand.href,
11211
+ "aria-label": phone ? brand.name : void 0,
11212
+ children: brandInner
11213
+ }) : /* @__PURE__ */ jsx("span", {
11214
+ className: "ui-wb-brand",
11215
+ children: brandInner
11216
+ }) : null,
11217
+ p.crumbs?.length ? /* @__PURE__ */ jsx(Breadcrumb, {
11218
+ className: "ui-wb-crumbs",
11219
+ items: phone ? p.crumbs.slice(-1) : p.crumbs
11220
+ }) : null
11221
+ ]
11222
+ }), /* @__PURE__ */ jsxs("div", {
11223
+ className: "ui-wb-top-r",
11224
+ children: [
11225
+ p.actions,
11226
+ views.length ? /* @__PURE__ */ jsx("span", {
11227
+ className: "ui-wb-sep",
11228
+ "aria-hidden": "true"
11229
+ }) : null,
11230
+ views.length ? toggleBtn("panel", phone ? sheetOpen && lay.panel.includes(sheetAct ?? "") : panelOpen, (phone ? !sheetOpen : !panelOpen) && attention("panel")) : null,
11231
+ views.length ? toggleBtn("side", phone ? sheetOpen && lay.side.includes(sheetAct ?? "") : sideOpen, (phone ? !sheetOpen : !sideOpen) && attention("side")) : null
11232
+ ]
11233
+ })]
11234
+ }), /* @__PURE__ */ jsxs("div", {
11235
+ className: "ui-wb-body",
11236
+ children: [
11237
+ /* @__PURE__ */ jsx("main", {
11238
+ className: "ui-wb-main",
11239
+ style: {
11240
+ left: mainL,
11241
+ right: mainR,
11242
+ bottom: mainB
11243
+ },
11244
+ children: p.children
11245
+ }),
11246
+ p.explorer || p.explorerHead || p.explorerFoot ? /* @__PURE__ */ jsxs(Fragment, { children: [
11247
+ exOverlay ? /* @__PURE__ */ jsx("button", {
11248
+ type: "button",
11249
+ tabIndex: -1,
11250
+ className: cx("ui-wb-scrim", exOpen && "is-open"),
11251
+ "aria-label": tr("關閉{region}", { region: regionName.explorer }),
11252
+ onClick: () => setOv((o) => ({
11253
+ ...o,
11254
+ explorer: false
11255
+ }))
11256
+ }) : null,
11257
+ /* @__PURE__ */ jsxs("aside", {
11258
+ className: cx("ui-wb-ex", exOverlay ? "is-drawer" : "is-docked", exOpen ? "is-open" : "is-shut"),
11259
+ style: { width: exW },
11260
+ "aria-label": regionName.explorer,
11261
+ inert: !exOpen,
11262
+ children: [
11263
+ p.explorerHead ? /* @__PURE__ */ jsx("div", {
11264
+ className: "ui-wb-exhead",
11265
+ children: p.explorerHead
11266
+ }) : null,
11267
+ /* @__PURE__ */ jsx("div", {
11268
+ className: "ui-wb-exbody",
11269
+ children: p.explorer
11270
+ }),
11271
+ p.explorerFoot ? /* @__PURE__ */ jsx("div", {
11272
+ className: "ui-wb-exfoot",
11273
+ children: p.explorerFoot
11274
+ }) : null
11275
+ ]
11276
+ }),
11277
+ exDocked ? /* @__PURE__ */ jsx(Splitter, {
11278
+ label: tr("{region}寬度", { region: regionName.explorer }),
11279
+ vertical: true,
11280
+ grow: 1,
11281
+ value: exW,
11282
+ min: LIM.explorer[0],
11283
+ max: LIM.explorer[1],
11284
+ onChange: (v) => update((l) => ({
11285
+ ...l,
11286
+ size: {
11287
+ ...l.size,
11288
+ explorer: v
11289
+ }
11290
+ })),
11291
+ onReset: () => update((l) => ({
11292
+ ...l,
11293
+ size: {
11294
+ ...l.size,
11295
+ explorer: def.size.explorer
11296
+ }
11297
+ })),
11298
+ onDrag: setSizing,
11299
+ style: { left: exW }
11300
+ }) : null
11301
+ ] }) : null,
11302
+ !phone && panelHas ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("section", {
11303
+ className: cx("ui-wb-panel", panelOpen ? "is-open" : "is-shut", drag?.over?.region === "panel" && "is-dropping"),
11304
+ style: {
11305
+ left: mainL,
11306
+ right: mainR,
11307
+ height: panelH
11308
+ },
11309
+ "aria-label": regionName.panel,
11310
+ inert: !panelOpen,
11311
+ ...regionDrop("panel"),
11312
+ children: regionBox("panel")
11313
+ }), panelOpen ? /* @__PURE__ */ jsx(Splitter, {
11314
+ label: tr("{region}高度", { region: regionName.panel }),
11315
+ vertical: false,
11316
+ grow: -1,
11317
+ value: panelH,
11318
+ min: LIM.panel[0],
11319
+ max: panelMax,
11320
+ onChange: (v) => update((l) => ({
11321
+ ...l,
11322
+ size: {
11323
+ ...l.size,
11324
+ panel: v
11325
+ }
11326
+ })),
11327
+ onReset: () => update((l) => ({
11328
+ ...l,
11329
+ size: {
11330
+ ...l.size,
11331
+ panel: def.size.panel
11332
+ }
11333
+ })),
11334
+ onDrag: setSizing,
11335
+ style: {
11336
+ left: mainL,
11337
+ right: mainR,
11338
+ bottom: panelH
11339
+ }
11340
+ }) : null] }) : null,
11341
+ !phone && sideHas ? /* @__PURE__ */ jsxs(Fragment, { children: [
11342
+ sideOverlay ? /* @__PURE__ */ jsx("button", {
11343
+ type: "button",
11344
+ tabIndex: -1,
11345
+ className: cx("ui-wb-scrim", sideOpen && "is-open"),
11346
+ "aria-label": tr("關閉{region}", { region: regionName.side }),
11347
+ onClick: () => setOv((o) => ({
11348
+ ...o,
11349
+ side: false
11350
+ }))
11351
+ }) : null,
11352
+ /* @__PURE__ */ jsx("aside", {
11353
+ className: cx("ui-wb-side", sideOverlay ? "is-drawer" : "is-docked", sideOpen ? "is-open" : "is-shut", drag?.over?.region === "side" && "is-dropping"),
11354
+ style: { width: sideW },
11355
+ "aria-label": regionName.side,
11356
+ inert: !sideOpen,
11357
+ ...regionDrop("side"),
11358
+ children: regionBox("side")
11359
+ }),
11360
+ sideDocked ? /* @__PURE__ */ jsx(Splitter, {
11361
+ label: tr("{region}寬度", { region: regionName.side }),
11362
+ vertical: true,
11363
+ grow: -1,
11364
+ value: sideW,
11365
+ min: LIM.side[0],
11366
+ max: LIM.side[1],
11367
+ onChange: (v) => update((l) => ({
11368
+ ...l,
11369
+ size: {
11370
+ ...l.size,
11371
+ side: v
11372
+ }
11373
+ })),
11374
+ onReset: () => update((l) => ({
11375
+ ...l,
11376
+ size: {
11377
+ ...l.size,
11378
+ side: def.size.side
11379
+ }
11380
+ })),
11381
+ onDrag: setSizing,
11382
+ style: { right: sideW }
11383
+ }) : null
11384
+ ] }) : null,
11385
+ showDropSide ? /* @__PURE__ */ jsx("div", {
11386
+ className: cx("ui-wb-dropzone is-side", drag?.over?.region === "side" && "is-over"),
11387
+ style: { bottom: (panelOpen ? panelH : 0) + 8 },
11388
+ ...regionDrop("side"),
11389
+ children: tr("放開以移到{region}", { region: regionName.side })
11390
+ }) : null,
11391
+ showDropPanel ? /* @__PURE__ */ jsx("div", {
11392
+ className: cx("ui-wb-dropzone is-panel", drag?.over?.region === "panel" && "is-over"),
11393
+ style: {
11394
+ left: mainL + 8,
11395
+ right: mainR + (showDropSide ? 120 : 8)
11396
+ },
11397
+ ...regionDrop("panel"),
11398
+ children: tr("放開以移到{region}", { region: regionName.panel })
11399
+ }) : null,
11400
+ phone && merged.length ? /* @__PURE__ */ jsxs("section", {
11401
+ className: cx("ui-wb-sheet", sheetOpen ? "is-open" : "is-shut"),
11402
+ style: { height: sheetSize },
11403
+ "aria-label": tr("面板分頁"),
11404
+ inert: !sheetOpen,
11405
+ children: [
11406
+ /* @__PURE__ */ jsx(Splitter, {
11407
+ label: tr("面板高度"),
11408
+ vertical: false,
11409
+ grow: -1,
11410
+ value: sheetSize,
11411
+ min: 120,
11412
+ max: Math.max(120, sheetMax),
11413
+ onChange: setSheetH,
11414
+ onReset: () => setSheetH(null),
11415
+ onDrag: setSizing,
11416
+ style: {
11417
+ top: 0,
11418
+ left: 0,
11419
+ right: 0
11420
+ }
11421
+ }),
11422
+ /* @__PURE__ */ jsx("span", {
11423
+ className: "ui-wb-grab",
11424
+ "aria-hidden": "true"
11425
+ }),
11426
+ /* @__PURE__ */ jsx(TabRow, {
11427
+ name: tr("面板分頁"),
11428
+ region: "sheet",
11429
+ ids: merged,
11430
+ active: sheetAct,
11431
+ views: byId,
11432
+ onPick: pickSheet,
11433
+ overflow: "scroll",
11434
+ onReorder: reorderMerged,
11435
+ buttons: /* @__PURE__ */ jsxs(Fragment, { children: [
11436
+ /* @__PURE__ */ jsx(IconButton, {
11437
+ variant: "quiet",
11438
+ icon: "caret-left",
11439
+ label: tr("目前分頁往左移"),
11440
+ disabled: sheetIdx <= 0,
11441
+ onClick: () => shiftSheet(-1)
11442
+ }),
11443
+ /* @__PURE__ */ jsx(IconButton, {
11444
+ variant: "quiet",
11445
+ icon: "caret-right",
11446
+ label: tr("目前分頁往右移"),
11447
+ disabled: sheetIdx < 0 || sheetIdx >= merged.length - 1,
11448
+ onClick: () => shiftSheet(1)
11449
+ }),
11450
+ /* @__PURE__ */ jsx(IconButton, {
11451
+ variant: "quiet",
11452
+ icon: "caret-down",
11453
+ label: tr("收起面板"),
11454
+ onClick: () => setSheet((s) => ({
11455
+ ...s,
11456
+ open: false
11457
+ }))
11458
+ })
11459
+ ] })
11460
+ }),
11461
+ /* @__PURE__ */ jsx(Pane, {
11462
+ view: sheetAct ? byId[sheetAct] : void 0,
11463
+ onSwipe: (dir) => {
11464
+ const j = sheetIdx + dir;
11465
+ if (j >= 0 && j < merged.length) pickSheet(merged[j]);
11466
+ }
11467
+ }),
11468
+ /* @__PURE__ */ jsx("div", {
11469
+ className: "ui-wb-dots",
11470
+ "aria-hidden": "true",
11471
+ children: merged.map((id) => /* @__PURE__ */ jsx("span", { className: cx("ui-wb-pagedot", id === sheetAct && "is-on") }, id))
11472
+ })
11473
+ ]
11474
+ }) : null
11475
+ ]
11476
+ })]
11477
+ })
11478
+ });
11479
+ }
11480
+ 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 };
10390
11481
 
10391
11482
  //# sourceMappingURL=index.js.map