@floegence/floe-webapp-core 0.101.29 → 0.101.30

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.
@@ -8,6 +8,8 @@ export interface ActivityBarItem {
8
8
  active?: boolean;
9
9
  }>;
10
10
  label: string;
11
+ /** Fixed disclosures may opt out of user ordering. */
12
+ reorderable?: boolean;
11
13
  badge?: number | string | (() => number | string | undefined);
12
14
  onClick?: () => void;
13
15
  /** Requests a product-owned context menu for this concrete Activity Bar button. */
@@ -31,6 +33,8 @@ export interface ActivityBarItem {
31
33
  export interface ActivityBarProps {
32
34
  items: ActivityBarItem[];
33
35
  bottomItems?: ActivityBarItem[];
36
+ /** Commits the visible reorderable IDs; persistence belongs to the host. */
37
+ onReorder?: (ids: string[]) => void;
34
38
  activeId: string;
35
39
  onActiveChange: (id: string, opts?: {
36
40
  openSidebar?: boolean;
@@ -1,116 +1,168 @@
1
- import { insert as v, createComponent as l, effect as y, className as h, setAttribute as d, template as x, use as E, Dynamic as R, memo as S, delegateEvents as j } from "solid-js/web";
2
- import { createMemo as b, For as $, Show as D, onMount as q, onCleanup as P } from "solid-js";
3
- import { cn as f } from "../../utils/cn.js";
4
- import { deferNonBlocking as T } from "../../utils/defer.js";
5
- import { Tooltip as _ } from "../ui/Tooltip.js";
6
- import { resolveActivityBarClick as K } from "./activityBarBehavior.js";
7
- import { isBarItemContextMenuKey as N, keyboardBarItemContextMenuRequest as X } from "./barItemContextMenu.js";
8
- var Y = /* @__PURE__ */ x('<div class="flex flex-col">'), F = /* @__PURE__ */ x('<nav data-floe-shell-slot=activity-bar style=border-right-color:var(--activity-bar-border)><div class="flex flex-col">'), H = /* @__PURE__ */ x("<span>"), L = /* @__PURE__ */ x("<button type=button data-floe-interactive=press><span aria-hidden=true>");
9
- function W(t) {
10
- const o = b(() => t.activeId), c = b(() => t.collapsed ?? !1), s = b(() => t.onActiveChange), u = b(() => t.onCollapsedChange), m = (a) => {
11
- if (a.onClick) {
12
- T(() => a.onClick());
1
+ import { insert as s, createComponent as c, memo as I, effect as k, className as A, setAttribute as v, template as y, use as L, Dynamic as T, setStyleProperty as w, delegateEvents as N } from "solid-js/web";
2
+ import { createMemo as b, For as j, Show as M, onMount as X, onCleanup as Y } from "solid-js";
3
+ import { cn as h } from "../../utils/cn.js";
4
+ import { deferNonBlocking as F } from "../../utils/defer.js";
5
+ import { Tooltip as H } from "../ui/Tooltip.js";
6
+ import { createBarReorder as U, createBarLayoutMotion as V } from "./barReorder.js";
7
+ import { resolveActivityBarClick as z } from "./activityBarBehavior.js";
8
+ import { isBarItemContextMenuKey as G, keyboardBarItemContextMenuRequest as J } from "./barItemContextMenu.js";
9
+ var O = /* @__PURE__ */ y('<div class="flex flex-col">'), Q = /* @__PURE__ */ y('<nav data-floe-shell-slot=activity-bar style=border-right-color:var(--activity-bar-border)><div class="flex flex-col min-h-0 overflow-y-auto overflow-x-hidden">'), W = /* @__PURE__ */ y("<span aria-hidden=true style=position:absolute;left:6px;right:6px;height:2px;background:var(--ring);border-radius:2px>"), Z = /* @__PURE__ */ y("<span>"), _ = /* @__PURE__ */ y("<button type=button data-floe-interactive=press><span aria-hidden=true>");
10
+ function le(t) {
11
+ let u;
12
+ const d = /* @__PURE__ */ new Map(), g = b(() => new Map(t.items.map((i) => [i.id, i]))), l = U({
13
+ keys: () => t.items.filter((i) => i.reorderable !== !1).map((i) => i.id),
14
+ elements: d,
15
+ container: () => u,
16
+ onReorder: () => t.onReorder
17
+ });
18
+ V({
19
+ keys: () => t.items.map((i) => i.id),
20
+ elements: d,
21
+ preview: () => l.position()?.order,
22
+ axis: "y"
23
+ });
24
+ const f = b(() => t.activeId), B = b(() => t.collapsed ?? !1), x = b(() => t.onActiveChange), r = b(() => t.onCollapsedChange), C = (i) => {
25
+ if (i.onClick) {
26
+ F(() => i.onClick());
13
27
  return;
14
28
  }
15
- const e = K({
16
- clickedId: a.id,
17
- activeId: o(),
18
- collapsed: c(),
19
- behavior: a.collapseBehavior
29
+ const e = z({
30
+ clickedId: i.id,
31
+ activeId: f(),
32
+ collapsed: B(),
33
+ behavior: i.collapseBehavior
20
34
  });
21
- e.nextActiveId !== o() && (typeof e.openSidebar == "boolean" ? s()(e.nextActiveId, {
35
+ e.nextActiveId !== f() && (typeof e.openSidebar == "boolean" ? x()(e.nextActiveId, {
22
36
  openSidebar: e.openSidebar
23
- }) : s()(e.nextActiveId)), typeof e.nextCollapsed == "boolean" && u()?.(e.nextCollapsed);
37
+ }) : x()(e.nextActiveId)), typeof e.nextCollapsed == "boolean" && r()?.(e.nextCollapsed);
24
38
  };
25
39
  return (() => {
26
- var a = F(), e = a.firstChild;
27
- return v(e, l($, {
40
+ var i = Q(), e = i.firstChild, a = u;
41
+ return typeof a == "function" ? L(a, e) : u = e, s(e, c(j, {
28
42
  get each() {
29
- return t.items;
43
+ return t.items.map((n) => n.id);
30
44
  },
31
- children: (n) => l(B, {
32
- item: n,
45
+ children: (n) => c(q, {
46
+ get item() {
47
+ return g().get(n);
48
+ },
33
49
  get isActive() {
34
- return o() === n.id;
50
+ return f() === n;
51
+ },
52
+ onClick: () => {
53
+ l.consumeClick() || C(g().get(n));
54
+ },
55
+ elementRef: (o) => {
56
+ o ? d.set(n, o) : d.delete(n);
57
+ },
58
+ onPointerDown: (o) => l.begin(n, o),
59
+ onReorderKey: (o) => l.keyDown(n, o),
60
+ get reorderable() {
61
+ return I(() => !!t.onReorder)() && g().get(n)?.reorderable !== !1;
35
62
  },
36
- onClick: () => m(n)
63
+ get dragging() {
64
+ return l.dragging() === n;
65
+ },
66
+ get dropEdge() {
67
+ return I(() => l.position()?.key === n)() ? l.position()?.edge : void 0;
68
+ }
37
69
  })
38
- })), v(a, l(D, {
70
+ })), s(i, c(M, {
39
71
  get when() {
40
72
  return t.bottomItems?.length;
41
73
  },
42
74
  get children() {
43
- var n = Y();
44
- return v(n, l($, {
75
+ var n = O();
76
+ return s(n, c(j, {
45
77
  get each() {
46
78
  return t.bottomItems;
47
79
  },
48
- children: (r) => l(B, {
49
- item: r,
80
+ children: (o) => c(q, {
81
+ item: o,
50
82
  get isActive() {
51
- return o() === r.id;
83
+ return f() === o.id;
52
84
  },
53
- onClick: () => m(r)
85
+ onClick: () => C(o)
54
86
  })
55
87
  })), n;
56
88
  }
57
- }), null), y((n) => {
58
- var r = f("w-10 md:w-12 flex flex-col justify-between shrink-0 min-h-0", "bg-activity-bar border-r border-[var(--floe-line-quiet)]", t.class), i = t.ariaLabel;
59
- return r !== n.e && h(a, n.e = r), i !== n.t && d(a, "aria-label", n.t = i), n;
89
+ }), null), k((n) => {
90
+ var o = h("w-10 md:w-12 flex flex-col justify-between shrink-0 min-h-0", "bg-activity-bar border-r border-[var(--floe-line-quiet)]", t.class), m = t.ariaLabel;
91
+ return o !== n.e && A(i, n.e = o), m !== n.t && v(i, "aria-label", n.t = m), n;
60
92
  }, {
61
93
  e: void 0,
62
94
  t: void 0
63
- }), a;
95
+ }), i;
64
96
  })();
65
97
  }
66
- function B(t) {
67
- let o;
68
- const c = () => typeof t.item.badge == "function" ? t.item.badge() : t.item.badge, s = () => typeof t.item.ariaExpanded == "function" ? t.item.ariaExpanded() : t.item.ariaExpanded, u = () => t.isActive || s() === !0;
69
- q(() => t.item.buttonRef?.(o ?? null)), P(() => t.item.buttonRef?.(null));
70
- const m = (e) => {
71
- t.item.onContextMenu && (e.preventDefault(), e.stopPropagation(), t.item.onContextMenu({
72
- trigger: e.currentTarget,
73
- clientX: e.clientX,
74
- clientY: e.clientY,
98
+ function q(t) {
99
+ let u;
100
+ const d = () => typeof t.item.badge == "function" ? t.item.badge() : t.item.badge, g = () => typeof t.item.ariaExpanded == "function" ? t.item.ariaExpanded() : t.item.ariaExpanded, l = () => t.isActive || g() === !0;
101
+ let f;
102
+ X(() => {
103
+ const r = t.item.buttonRef;
104
+ r?.(u ?? null), t.elementRef?.(u ?? null), f = () => {
105
+ r?.(null), t.elementRef?.(null);
106
+ };
107
+ }), Y(() => f?.());
108
+ const B = (r) => {
109
+ t.item.onContextMenu && (r.preventDefault(), r.stopPropagation(), t.item.onContextMenu({
110
+ trigger: r.currentTarget,
111
+ clientX: r.clientX,
112
+ clientY: r.clientY,
75
113
  source: "pointer"
76
114
  }));
77
- }, a = (e) => {
78
- !t.item.onContextMenu || !N(e) || (e.preventDefault(), e.stopPropagation(), t.item.onContextMenu(X(e.currentTarget)));
115
+ }, x = (r) => {
116
+ t.onReorderKey?.(r), !(r.defaultPrevented || !t.item.onContextMenu || !G(r)) && (r.preventDefault(), r.stopPropagation(), t.item.onContextMenu(J(r.currentTarget)));
79
117
  };
80
- return l(_, {
118
+ return c(H, {
81
119
  get content() {
82
120
  return t.item.label;
83
121
  },
84
122
  placement: "right",
85
123
  delay: 0,
86
124
  get children() {
87
- var e = L(), n = e.firstChild;
88
- e.$$keydown = a, e.$$contextmenu = m, e.$$click = () => t.onClick();
89
- var r = o;
90
- return typeof r == "function" ? E(r, e) : o = e, v(e, l(R, {
125
+ var r = _(), C = r.firstChild;
126
+ r.$$keydown = x, r.$$contextmenu = B, r.$$click = () => t.onClick(), r.addEventListener("dragstart", (e) => e.preventDefault()), r.$$pointerdown = (e) => t.onPointerDown?.(e);
127
+ var i = u;
128
+ return typeof i == "function" ? L(i, r) : u = r, s(r, c(T, {
91
129
  get component() {
92
130
  return t.item.icon;
93
131
  },
94
132
  get active() {
95
- return u();
133
+ return l();
96
134
  },
97
135
  get class() {
98
- return f("relative w-5 h-5 transition-colors duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", u() ? "text-activity-bar-foreground-active" : "group-hover/activity-item:text-activity-bar-foreground-active");
136
+ return h("relative w-5 h-5 transition-colors duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", l() ? "text-activity-bar-foreground-active" : "group-hover/activity-item:text-activity-bar-foreground-active");
137
+ }
138
+ }), null), s(r, c(M, {
139
+ get when() {
140
+ return t.dropEdge;
141
+ },
142
+ get children() {
143
+ var e = W();
144
+ return k((a) => {
145
+ var n = t.dropEdge === "before" ? "0" : void 0, o = t.dropEdge === "after" ? "0" : void 0;
146
+ return n !== a.e && w(e, "top", a.e = n), o !== a.t && w(e, "bottom", a.t = o), a;
147
+ }, {
148
+ e: void 0,
149
+ t: void 0
150
+ }), e;
99
151
  }
100
- }), null), v(e, l(D, {
152
+ }), null), s(r, c(M, {
101
153
  get when() {
102
- return c();
154
+ return d();
103
155
  },
104
156
  get children() {
105
- var i = H();
106
- return v(i, (() => {
107
- var g = S(() => typeof c() == "number" && c() > 99);
108
- return () => g() ? "99+" : c();
109
- })()), y(() => h(i, f("absolute top-0.5 right-0.5 min-w-3.5 h-3.5 px-1", "flex items-center justify-center", "text-[length:var(--floe-type-caption)] font-medium rounded-full", "bg-activity-bar-badge text-activity-bar-badge-foreground"))), i;
157
+ var e = Z();
158
+ return s(e, (() => {
159
+ var a = I(() => typeof d() == "number" && d() > 99);
160
+ return () => a() ? "99+" : d();
161
+ })()), k(() => A(e, h("absolute top-0.5 right-0.5 min-w-3.5 h-3.5 px-1", "flex items-center justify-center", "text-[length:var(--floe-type-caption)] font-medium rounded-full", "bg-activity-bar-badge text-activity-bar-badge-foreground"))), e;
110
162
  }
111
- }), null), y((i) => {
112
- var g = f("group/activity-item relative w-full aspect-square flex items-center justify-center cursor-pointer", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset", "text-activity-bar-foreground", u() && "text-activity-bar-foreground-active"), C = t.item.label, k = t.isActive, A = s(), w = t.item.ariaControls, I = t.item.ariaHasPopup ?? (t.item.onContextMenu ? "menu" : void 0), M = f("absolute inset-1 rounded-md", "transition-colors duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", u() ? "bg-[var(--floe-state-selected)]" : "bg-transparent group-hover/activity-item:bg-[var(--floe-state-hover)]");
113
- return g !== i.e && h(e, i.e = g), C !== i.t && d(e, "aria-label", i.t = C), k !== i.a && d(e, "aria-pressed", i.a = k), A !== i.o && d(e, "aria-expanded", i.o = A), w !== i.i && d(e, "aria-controls", i.i = w), I !== i.n && d(e, "aria-haspopup", i.n = I), M !== i.s && h(n, i.s = M), i;
163
+ }), null), k((e) => {
164
+ var a = t.item.id, n = t.reorderable ? "Alt+Shift+ArrowUp Alt+Shift+ArrowDown" : void 0, o = t.reorderable ? "none" : void 0, m = t.dragging ? 0.5 : void 0, R = h("group/activity-item relative w-full shrink-0 aspect-square flex items-center justify-center cursor-pointer", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset", "text-activity-bar-foreground", l() && "text-activity-bar-foreground-active"), D = t.item.label, E = t.isActive, $ = g(), P = t.item.ariaControls, S = t.item.ariaHasPopup ?? (t.item.onContextMenu ? "menu" : void 0), K = h("absolute inset-1 rounded-md", "transition-colors duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", l() ? "bg-[var(--floe-state-selected)]" : "bg-transparent group-hover/activity-item:bg-[var(--floe-state-hover)]");
165
+ return a !== e.e && v(r, "data-floe-bar-key", e.e = a), n !== e.t && v(r, "aria-keyshortcuts", e.t = n), o !== e.a && w(r, "touch-action", e.a = o), m !== e.o && w(r, "opacity", e.o = m), R !== e.i && A(r, e.i = R), D !== e.n && v(r, "aria-label", e.n = D), E !== e.s && v(r, "aria-pressed", e.s = E), $ !== e.h && v(r, "aria-expanded", e.h = $), P !== e.r && v(r, "aria-controls", e.r = P), S !== e.d && v(r, "aria-haspopup", e.d = S), K !== e.l && A(C, e.l = K), e;
114
166
  }, {
115
167
  e: void 0,
116
168
  t: void 0,
@@ -118,12 +170,16 @@ function B(t) {
118
170
  o: void 0,
119
171
  i: void 0,
120
172
  n: void 0,
121
- s: void 0
122
- }), e;
173
+ s: void 0,
174
+ h: void 0,
175
+ r: void 0,
176
+ d: void 0,
177
+ l: void 0
178
+ }), r;
123
179
  }
124
180
  });
125
181
  }
126
- j(["click", "contextmenu", "keydown"]);
182
+ N(["pointerdown", "click", "contextmenu", "keydown"]);
127
183
  export {
128
- W as ActivityBar
184
+ le as ActivityBar
129
185
  };
@@ -37,6 +37,7 @@ export interface ShellProps {
37
37
  fillParent?: boolean;
38
38
  logo?: JSX.Element;
39
39
  activityItems?: ActivityBarItem[];
40
+ onActivityReorder?: (ids: string[]) => void;
40
41
  activityBottomItems?: ActivityBarItem[];
41
42
  /**
42
43
  * Where to render `activityBottomItems` on mobile.
@@ -1,4 +1,4 @@
1
- import { createComponent as n, Dynamic as oe, insert as d, use as U, effect as I, setStyleProperty as j, memo as P, className as k, setAttribute as C, mergeProps as pe, template as M, delegateEvents as Le } from "solid-js/web";
1
+ import { createComponent as n, Dynamic as oe, insert as d, use as U, effect as I, setStyleProperty as j, memo as P, className as k, setAttribute as C, mergeProps as Le, template as M, delegateEvents as pe } from "solid-js/web";
2
2
  import { createSignal as w, onMount as ze, onCleanup as $e, createEffect as A, createMemo as T, For as Fe, Show as m, batch as Ee } from "solid-js";
3
3
  import { observeViewport as He } from "../../viewport.js";
4
4
  import { useLayout as Ve } from "../../context/LayoutContext.js";
@@ -29,15 +29,15 @@ function Dt(i) {
29
29
  ze(() => {
30
30
  $e(He(window, (e) => de(e.keyboardOpen)));
31
31
  });
32
- const r = Ve(), ce = De(), l = r.isMobile, [be, ue] = w(), [fe, ve] = w(), me = Ke(fe), W = /* @__PURE__ */ new Map(), [V, p] = w(!1), [ge, he] = w(!1), Se = qe({
32
+ const r = Ve(), ce = De(), l = r.isMobile, [be, ue] = w(), [fe, ve] = w(), me = Ke(fe), W = /* @__PURE__ */ new Map(), [V, L] = w(!1), [ge, he] = w(!1), Se = qe({
33
33
  container: be,
34
34
  sidebarWidth: () => (D() ?? r.sidebarWidth()) + (me()?.width ?? 0),
35
35
  minContentWidth: () => i.sidebarMinContentWidth ?? 0
36
36
  }), h = () => !l() && !!i.sidebarMinContentWidth && !c() && Se() === "overlay";
37
37
  A(() => {
38
- (!h() || N()) && p(!1);
38
+ (!h() || N()) && L(!1);
39
39
  });
40
- const [L, S] = w(!1), [z, ye] = w(!1);
40
+ const [p, S] = w(!1), [z, ye] = w(!1);
41
41
  let G;
42
42
  const Ce = () => l() && !!i.mobileNavigationPanel?.open;
43
43
  A(() => {
@@ -69,7 +69,7 @@ function Dt(i) {
69
69
  }), r.setSidebarActiveTab(e, {
70
70
  openSidebar: !1,
71
71
  visibilityMotion: g
72
- }), p(!s)) : r.setSidebarActiveTab(e, {
72
+ }), L(!s)) : r.setSidebarActiveTab(e, {
73
73
  openSidebar: o,
74
74
  visibilityMotion: g
75
75
  });
@@ -117,7 +117,7 @@ function Dt(i) {
117
117
  }))), ke = (e) => {
118
118
  h() ? (e || W.get(r.sidebarActiveTab())?.focus({
119
119
  preventScroll: !0
120
- }), p(!e)) : r.setSidebarCollapsed(e);
120
+ }), L(!e)) : r.setSidebarCollapsed(e);
121
121
  }, Ae = T(() => c() ? [] : i.sidebarContent ? [] : b ? b.sidebarItems().filter((e) => !(l() && e.sidebar?.hiddenOnMobile)).filter((e) => e.sidebar?.fullScreen !== !0 && e.sidebar?.renderIn !== "main").map((e) => ({
122
122
  id: e.id,
123
123
  render: () => n(oe, {
@@ -160,7 +160,7 @@ function Dt(i) {
160
160
  } = at({
161
161
  clickedId: e,
162
162
  activeId: r.sidebarActiveTab(),
163
- mobileSidebarOpen: L(),
163
+ mobileSidebarOpen: p(),
164
164
  clickedIsFullScreen: a
165
165
  });
166
166
  if (r.sidebarActiveTab() !== s) {
@@ -210,7 +210,7 @@ function Dt(i) {
210
210
  e !== null && (r.setSidebarWidth(e), _(null));
211
211
  };
212
212
  Ge({
213
- open: () => l() && L() && !c(),
213
+ open: () => l() && p() && !c(),
214
214
  root: () => q,
215
215
  onClose: () => S(!1),
216
216
  lockBodyScroll: !0,
@@ -271,6 +271,9 @@ function Dt(i) {
271
271
  get items() {
272
272
  return Me();
273
273
  },
274
+ get onReorder() {
275
+ return i.onActivityReorder;
276
+ },
274
277
  get bottomItems() {
275
278
  return i.activityBottomItems;
276
279
  },
@@ -339,7 +342,7 @@ function Dt(i) {
339
342
  get open() {
340
343
  return P(() => !!(h() && V()))() && !N();
341
344
  },
342
- onOpenChange: p,
345
+ onOpenChange: L,
343
346
  onPresenceChange: he,
344
347
  presentation: "side-drawer",
345
348
  drawerSide: "left",
@@ -362,7 +365,7 @@ function Dt(i) {
362
365
  }
363
366
  }), g), d(o, n(m, {
364
367
  get when() {
365
- return P(() => !!(l() && L()))() && !c();
368
+ return P(() => !!(l() && p()))() && !c();
366
369
  },
367
370
  get children() {
368
371
  return [(() => {
@@ -409,7 +412,7 @@ function Dt(i) {
409
412
  return P(() => !!l())() && i.mobileNavigationPanel;
410
413
  },
411
414
  get children() {
412
- return n(it, pe(() => i.mobileNavigationPanel, {
415
+ return n(it, Le(() => i.mobileNavigationPanel, {
413
416
  navigation: () => G,
414
417
  onPresenceChange: (t) => {
415
418
  ye(t), i.mobileNavigationPanel?.onPresenceChange?.(t);
@@ -437,7 +440,7 @@ function Dt(i) {
437
440
  get activeId() {
438
441
  return nt({
439
442
  activeId: E(),
440
- mobileSidebarOpen: F.pending() ? !0 : L(),
443
+ mobileSidebarOpen: F.pending() ? !0 : p(),
441
444
  activeIsFullScreen: b?.getComponent(E())?.sidebar?.fullScreen ?? N(),
442
445
  activeIsPage: (() => {
443
446
  const t = b?.getComponent(E())?.sidebar;
@@ -484,7 +487,7 @@ function Dt(i) {
484
487
  }), e;
485
488
  })();
486
489
  }
487
- Le(["click"]);
490
+ pe(["click"]);
488
491
  export {
489
492
  Dt as Shell
490
493
  };
@@ -0,0 +1,32 @@
1
+ export type BarDropPosition = Readonly<{
2
+ key: string;
3
+ edge: 'before' | 'after';
4
+ order: string[];
5
+ }>;
6
+ /** A placement proposal only; owners commit order after a completed gesture. */
7
+ export declare function barDropPosition(keys: readonly string[], source: string, elements: ReadonlyMap<string, HTMLElement>, axis: 'x' | 'y', coordinate: number): BarDropPosition | undefined;
8
+ export declare function keyboardBarOrder(keys: readonly string[], source: string, event: KeyboardEvent, axis: 'x' | 'y'): string[] | undefined;
9
+ /** Activity rails own their pointer session; Dock shares the proposal with its canvas gesture. */
10
+ export declare function createBarReorder(options: {
11
+ keys: () => readonly string[];
12
+ elements: Map<string, HTMLElement>;
13
+ onReorder: () => ((keys: string[]) => void) | undefined;
14
+ container: () => HTMLElement | undefined;
15
+ }): {
16
+ dragging: import("solid-js").Accessor<string | undefined>;
17
+ position: import("solid-js").Accessor<Readonly<{
18
+ key: string;
19
+ edge: "before" | "after";
20
+ order: string[];
21
+ }> | undefined>;
22
+ keyDown(key: string, event: KeyboardEvent): void;
23
+ consumeClick(): boolean;
24
+ begin(key: string, event: PointerEvent): void;
25
+ };
26
+ /** Keyed layout motion survives pin/unpin, reorder and interrupted previews. */
27
+ export declare function createBarLayoutMotion(options: {
28
+ keys: () => readonly string[];
29
+ elements: Map<string, HTMLElement>;
30
+ preview: () => readonly string[] | undefined;
31
+ axis: 'x' | 'y';
32
+ }): void;
@@ -0,0 +1,114 @@
1
+ import { createSignal as w, createEffect as b, onCleanup as D } from "solid-js";
2
+ import { startPointerSession as k } from "../ui/pointerSession.js";
3
+ function C(n, d, o, p, l) {
4
+ const r = n.filter((e) => e !== d && o.has(e));
5
+ if (!n.includes(d) || !r.length) return;
6
+ let s = r.findIndex((e) => {
7
+ const f = o.get(e), t = f.getBoundingClientRect(), i = getComputedStyle(f).transform, c = typeof DOMMatrix == "function" ? new DOMMatrix(i === "none" ? void 0 : i) : void 0;
8
+ return l < (p === "x" ? t.left - (c?.m41 ?? 0) + t.width / 2 : t.top - (c?.m42 ?? 0) + t.height / 2);
9
+ });
10
+ s < 0 && (s = r.length);
11
+ const a = [...r];
12
+ return a.splice(s, 0, d), { key: r[Math.min(s, r.length - 1)], edge: s === r.length ? "after" : "before", order: a };
13
+ }
14
+ function R(n, d, o, p) {
15
+ if (!o.altKey || !o.shiftKey || o.ctrlKey || o.metaKey || o.isComposing) return;
16
+ const l = o.key === (p === "x" ? "ArrowLeft" : "ArrowUp") ? -1 : o.key === (p === "x" ? "ArrowRight" : "ArrowDown") ? 1 : 0, r = n.indexOf(d);
17
+ if (!l || r < 0) return;
18
+ o.preventDefault(), o.stopPropagation();
19
+ const s = Math.max(0, Math.min(n.length - 1, r + l));
20
+ if (r === s) return;
21
+ const a = [...n];
22
+ return a.splice(r, 1), a.splice(s, 0, d), a;
23
+ }
24
+ function O(n) {
25
+ const [d, o] = w(), [p, l] = w();
26
+ let r, s = !1, a;
27
+ const e = (t) => {
28
+ t.key !== "Escape" || !r || (t.preventDefault(), t.stopPropagation(), r.stop({ commit: !1 }));
29
+ };
30
+ b(() => {
31
+ n.keys(), n.onReorder(), r?.stop({ commit: !1 });
32
+ }), D(() => {
33
+ r?.stop({ commit: !1 }), a && clearTimeout(a);
34
+ });
35
+ const f = (t, i) => {
36
+ n.onReorder()?.(i), n.elements.get(t)?.focus({ preventScroll: !0 });
37
+ };
38
+ return {
39
+ dragging: d,
40
+ position: p,
41
+ keyDown(t, i) {
42
+ if (!n.onReorder()) return;
43
+ const c = R(n.keys(), t, i, "y");
44
+ c && f(t, c);
45
+ },
46
+ consumeClick() {
47
+ return s ? (s = !1, !0) : !1;
48
+ },
49
+ begin(t, i) {
50
+ if (i.button !== 0 || !n.onReorder() || !n.keys().includes(t)) return;
51
+ r?.stop({ commit: !1 });
52
+ const c = i.currentTarget, M = i.clientY, x = i.clientX;
53
+ let g = !1;
54
+ const h = (m, u) => {
55
+ if (g ||= Math.hypot(m - x, u - M) >= 5, !g) return;
56
+ o(t);
57
+ const y = n.container()?.getBoundingClientRect();
58
+ l(y && m >= y.left - 24 && m <= y.right + 24 && u >= y.top && u <= y.bottom ? C(n.keys(), t, n.elements, "y", u) : void 0);
59
+ };
60
+ c.ownerDocument.addEventListener("keydown", e, !0), r = k({
61
+ pointerEvent: i,
62
+ captureEl: c,
63
+ onMove: (m) => h(m.clientX, m.clientY),
64
+ onEnd: ({ commit: m, snapshot: u }) => {
65
+ h(u.latestClientX, u.latestClientY);
66
+ const y = p();
67
+ r = void 0, c.ownerDocument.removeEventListener("keydown", e, !0), o(void 0), l(void 0), g && (s = !0, a && clearTimeout(a), a = setTimeout(() => {
68
+ s = !1;
69
+ }, 0)), m && g && y && f(t, y.order);
70
+ }
71
+ });
72
+ }
73
+ };
74
+ }
75
+ function B(n) {
76
+ const d = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
77
+ let p = !1;
78
+ b(() => {
79
+ const l = [...n.keys()], r = n.preview(), s = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, a = new Map(l.flatMap((e) => {
80
+ const f = n.elements.get(e);
81
+ if (!f) return [];
82
+ const t = f.getBoundingClientRect(), i = getComputedStyle(f).transform, c = typeof DOMMatrix == "function" ? new DOMMatrix(i === "none" ? void 0 : i) : void 0;
83
+ return [[e, { left: t.left - (c?.m41 ?? 0), top: t.top - (c?.m42 ?? 0), dx: c?.m41 ?? 0, dy: c?.m42 ?? 0 }]];
84
+ }));
85
+ for (const e of l) {
86
+ const f = n.elements.get(e), t = a.get(e);
87
+ if (!f || !t) continue;
88
+ const i = d.get(e), c = r ? l[r.indexOf(e)] : e, M = a.get(c) ?? t, x = n.axis === "x" ? M.left - t.left : 0, g = n.axis === "y" ? M.top - t.top : 0;
89
+ if (o.get(e)?.cancel(), o.delete(e), f.style.transform = x || g ? `translate3d(${x}px, ${g}px, 0)` : "", !s && p && typeof f.animate == "function") {
90
+ const h = i ? i.left - t.left + t.dx : x, m = i ? i.top - t.top + t.dy : g;
91
+ if (!i || Math.abs(h - x) + Math.abs(m - g) > 0.5) {
92
+ const u = f.animate([
93
+ { transform: `translate3d(${h}px, ${m}px, 0)`, opacity: i ? 1 : 0 },
94
+ { transform: `translate3d(${x}px, ${g}px, 0)`, opacity: 1 }
95
+ ], { duration: 180, easing: "cubic-bezier(0.33, 1, 0.68, 1)" });
96
+ o.set(e, u), u.onfinish = () => {
97
+ o.get(e) === u && o.delete(e);
98
+ };
99
+ }
100
+ }
101
+ d.set(e, { left: t.left, top: t.top });
102
+ }
103
+ for (const e of d.keys()) l.includes(e) || (d.delete(e), o.get(e)?.cancel(), o.delete(e));
104
+ p = !0;
105
+ }), D(() => {
106
+ for (const l of o.values()) l.cancel();
107
+ });
108
+ }
109
+ export {
110
+ C as barDropPosition,
111
+ B as createBarLayoutMotion,
112
+ O as createBarReorder,
113
+ R as keyboardBarOrder
114
+ };
@@ -1,5 +1,5 @@
1
1
  import { type Component, type JSX } from 'solid-js';
2
- import { type BarItemContextMenuHandler } from '../layout/barItemContextMenu';
2
+ import { type BarItemContextMenuHandler, type BarItemContextMenuRequest } from '../layout/barItemContextMenu';
3
3
  import { type WorkbenchWidgetFrame } from './workbenchHelpers';
4
4
  import { type WorkbenchEdgeAutoPanFrame } from './workbenchEdgeAutoPan';
5
5
  import type { WorkbenchDockToolId, WorkbenchInteractionMode, WorkbenchViewport, WorkbenchWidgetDefinition, WorkbenchWidgetItem, WorkbenchWidgetType } from './types';
@@ -14,6 +14,7 @@ export interface WorkbenchFilterBarProps {
14
14
  activationMode?: WorkbenchDockItemActivationMode;
15
15
  /** Orders work-mode widgets and tools by id; unlisted entries retain their relative order at the end. */
16
16
  componentOrder?: readonly (WorkbenchWidgetType | WorkbenchDockToolId)[];
17
+ customization?: WorkbenchDockCustomization;
17
18
  /** Solo a single dock component in the supplied mode scope; soloing it again shows the full scope. */
18
19
  onSoloFilter: (id: string, scope: readonly string[]) => void;
19
20
  onSelectMode?: (mode: WorkbenchInteractionMode) => void;
@@ -42,6 +43,29 @@ export interface WorkbenchFilterBarProps {
42
43
  onViewportCommit?: (viewport: WorkbenchViewport) => void;
43
44
  onViewportInteractionStart?: (kind: 'pan') => void;
44
45
  }
46
+ /** Keys distinguish built-in components, host actions and host instances. */
47
+ export type WorkbenchDockEntry = Readonly<{
48
+ key: string;
49
+ kind: 'widget' | 'tool' | 'action' | 'host';
50
+ id: string;
51
+ label: string;
52
+ icon: Component<{
53
+ class?: string;
54
+ }>;
55
+ activate: (trigger: HTMLButtonElement) => void;
56
+ /** Focuses this entry after the host restores its visibility. */
57
+ focus: () => void;
58
+ }>;
59
+ export type WorkbenchDockCustomization = Readonly<{
60
+ order?: readonly string[];
61
+ hidden?: readonly string[];
62
+ onOrderChange?: (keys: string[]) => void;
63
+ onContextMenu?: (entry: WorkbenchDockEntry, request: BarItemContextMenuRequest) => void;
64
+ /** Host renders its localized overflow trigger/panel; hidden entries remain activatable. */
65
+ overflow?: Component<{
66
+ entries: readonly WorkbenchDockEntry[];
67
+ }>;
68
+ }>;
45
69
  export type WorkbenchDockItemActivationMode = 'solo-filter' | 'focus-cycle';
46
70
  export type WorkbenchDockItemPresentation = Readonly<{
47
71
  count: number;
@@ -63,6 +87,7 @@ export type WorkbenchDockAction = Readonly<{
63
87
  onActivate: (trigger: HTMLButtonElement) => void;
64
88
  /** Receives the concrete action button on mount and null on disposal. */
65
89
  buttonRef?: (button: HTMLButtonElement | null) => void;
90
+ onContextMenu?: BarItemContextMenuHandler;
66
91
  }>;
67
92
  export type WorkbenchHostDockItem = Readonly<{
68
93
  id: string;