@floegence/floe-webapp-core 0.101.29 → 0.101.33

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,173 @@
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 g, createComponent as u, memo as I, effect as k, className as A, setAttribute as s, template as y, use as L, Dynamic as T, setStyleProperty as w, delegateEvents as N } from "solid-js/web";
2
+ import { createMemo as m, For as j, untrack as X, Show as M, onMount as Y, onCleanup as F } from "solid-js";
3
+ import { cn as h } from "../../utils/cn.js";
4
+ import { deferNonBlocking as H } from "../../utils/defer.js";
5
+ import { Tooltip as U } from "../ui/Tooltip.js";
6
+ import { createBarReorder as V, createBarLayoutMotion as z } from "./barReorder.js";
7
+ import { resolveActivityBarClick as G } from "./activityBarBehavior.js";
8
+ import { isBarItemContextMenuKey as J, keyboardBarItemContextMenuRequest as O } from "./barItemContextMenu.js";
9
+ var Q = /* @__PURE__ */ y('<div class="flex flex-col">'), W = /* @__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">'), Z = /* @__PURE__ */ y("<span aria-hidden=true style=position:absolute;left:6px;right:6px;height:2px;background:var(--ring);border-radius:2px>"), _ = /* @__PURE__ */ y("<span>"), p = /* @__PURE__ */ y("<button type=button data-floe-interactive=press><span aria-hidden=true>");
10
+ function de(t) {
11
+ let v;
12
+ const c = /* @__PURE__ */ new Map(), b = m(() => new Map(t.items.map((i) => [i.id, i]))), d = V({
13
+ keys: () => t.items.filter((i) => i.reorderable !== !1).map((i) => i.id),
14
+ elements: c,
15
+ container: () => v,
16
+ onReorder: () => t.onReorder
17
+ });
18
+ z({
19
+ keys: () => t.items.map((i) => i.id),
20
+ elements: c,
21
+ preview: () => d.position()?.order,
22
+ axis: "y"
23
+ });
24
+ const f = m(() => t.activeId), B = m(() => t.collapsed ?? !1), x = m(() => t.onActiveChange), r = m(() => t.onCollapsedChange), C = (i) => {
25
+ if (i.onClick) {
26
+ H(() => 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 = G({
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 = W(), e = i.firstChild, l = v;
41
+ return typeof l == "function" ? L(l, e) : v = e, g(e, u(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,
33
- get isActive() {
34
- return o() === n.id;
35
- },
36
- onClick: () => m(n)
37
- })
38
- })), v(a, l(D, {
45
+ children: (n) => {
46
+ const o = m((a) => b().get(n) ?? a, X(() => b().get(n)));
47
+ return u(q, {
48
+ get item() {
49
+ return o();
50
+ },
51
+ get isActive() {
52
+ return f() === n;
53
+ },
54
+ onClick: () => {
55
+ d.consumeClick() || C(o());
56
+ },
57
+ elementRef: (a) => {
58
+ a ? c.set(n, a) : c.delete(n);
59
+ },
60
+ onPointerDown: (a) => d.begin(n, a),
61
+ onReorderKey: (a) => d.keyDown(n, a),
62
+ get reorderable() {
63
+ return I(() => !!t.onReorder)() && o().reorderable !== !1;
64
+ },
65
+ get dragging() {
66
+ return d.dragging() === n;
67
+ },
68
+ get dropEdge() {
69
+ return I(() => d.position()?.key === n)() ? d.position()?.edge : void 0;
70
+ }
71
+ });
72
+ }
73
+ })), g(i, u(M, {
39
74
  get when() {
40
75
  return t.bottomItems?.length;
41
76
  },
42
77
  get children() {
43
- var n = Y();
44
- return v(n, l($, {
78
+ var n = Q();
79
+ return g(n, u(j, {
45
80
  get each() {
46
81
  return t.bottomItems;
47
82
  },
48
- children: (r) => l(B, {
49
- item: r,
83
+ children: (o) => u(q, {
84
+ item: o,
50
85
  get isActive() {
51
- return o() === r.id;
86
+ return f() === o.id;
52
87
  },
53
- onClick: () => m(r)
88
+ onClick: () => C(o)
54
89
  })
55
90
  })), n;
56
91
  }
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;
92
+ }), null), k((n) => {
93
+ 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), a = t.ariaLabel;
94
+ return o !== n.e && A(i, n.e = o), a !== n.t && s(i, "aria-label", n.t = a), n;
60
95
  }, {
61
96
  e: void 0,
62
97
  t: void 0
63
- }), a;
98
+ }), i;
64
99
  })();
65
100
  }
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,
101
+ function q(t) {
102
+ let v;
103
+ const c = () => typeof t.item.badge == "function" ? t.item.badge() : t.item.badge, b = () => typeof t.item.ariaExpanded == "function" ? t.item.ariaExpanded() : t.item.ariaExpanded, d = () => t.isActive || b() === !0;
104
+ let f;
105
+ Y(() => {
106
+ const r = t.item.buttonRef;
107
+ r?.(v ?? null), t.elementRef?.(v ?? null), f = () => {
108
+ r?.(null), t.elementRef?.(null);
109
+ };
110
+ }), F(() => f?.());
111
+ const B = (r) => {
112
+ t.item.onContextMenu && (r.preventDefault(), r.stopPropagation(), t.item.onContextMenu({
113
+ trigger: r.currentTarget,
114
+ clientX: r.clientX,
115
+ clientY: r.clientY,
75
116
  source: "pointer"
76
117
  }));
77
- }, a = (e) => {
78
- !t.item.onContextMenu || !N(e) || (e.preventDefault(), e.stopPropagation(), t.item.onContextMenu(X(e.currentTarget)));
118
+ }, x = (r) => {
119
+ t.onReorderKey?.(r), !(r.defaultPrevented || !t.item.onContextMenu || !J(r)) && (r.preventDefault(), r.stopPropagation(), t.item.onContextMenu(O(r.currentTarget)));
79
120
  };
80
- return l(_, {
121
+ return u(U, {
81
122
  get content() {
82
123
  return t.item.label;
83
124
  },
84
125
  placement: "right",
85
126
  delay: 0,
127
+ triggerClass: "shrink-0",
128
+ portalScope: "viewport",
86
129
  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, {
130
+ var r = p(), C = r.firstChild;
131
+ r.$$keydown = x, r.$$contextmenu = B, r.$$click = () => t.onClick(), r.addEventListener("dragstart", (e) => e.preventDefault()), r.$$pointerdown = (e) => t.onPointerDown?.(e);
132
+ var i = v;
133
+ return typeof i == "function" ? L(i, r) : v = r, g(r, u(T, {
91
134
  get component() {
92
135
  return t.item.icon;
93
136
  },
94
137
  get active() {
95
- return u();
138
+ return d();
96
139
  },
97
140
  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");
141
+ return h("relative w-5 h-5 transition-colors duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", d() ? "text-activity-bar-foreground-active" : "group-hover/activity-item:text-activity-bar-foreground-active");
142
+ }
143
+ }), null), g(r, u(M, {
144
+ get when() {
145
+ return t.dropEdge;
146
+ },
147
+ get children() {
148
+ var e = Z();
149
+ return k((l) => {
150
+ var n = t.dropEdge === "before" ? "0" : void 0, o = t.dropEdge === "after" ? "0" : void 0;
151
+ return n !== l.e && w(e, "top", l.e = n), o !== l.t && w(e, "bottom", l.t = o), l;
152
+ }, {
153
+ e: void 0,
154
+ t: void 0
155
+ }), e;
99
156
  }
100
- }), null), v(e, l(D, {
157
+ }), null), g(r, u(M, {
101
158
  get when() {
102
159
  return c();
103
160
  },
104
161
  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;
162
+ var e = _();
163
+ return g(e, (() => {
164
+ var l = I(() => typeof c() == "number" && c() > 99);
165
+ return () => l() ? "99+" : c();
166
+ })()), 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
167
  }
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;
168
+ }), null), k((e) => {
169
+ var l = t.item.id, n = t.reorderable ? "Alt+Shift+ArrowUp Alt+Shift+ArrowDown" : void 0, o = t.reorderable ? "none" : void 0, a = 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", d() && "text-activity-bar-foreground-active"), D = t.item.label, E = t.isActive, S = b(), $ = t.item.ariaControls, P = 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)]", d() ? "bg-[var(--floe-state-selected)]" : "bg-transparent group-hover/activity-item:bg-[var(--floe-state-hover)]");
170
+ return l !== e.e && s(r, "data-floe-bar-key", e.e = l), n !== e.t && s(r, "aria-keyshortcuts", e.t = n), o !== e.a && w(r, "touch-action", e.a = o), a !== e.o && w(r, "opacity", e.o = a), R !== e.i && A(r, e.i = R), D !== e.n && s(r, "aria-label", e.n = D), E !== e.s && s(r, "aria-pressed", e.s = E), S !== e.h && s(r, "aria-expanded", e.h = S), $ !== e.r && s(r, "aria-controls", e.r = $), P !== e.d && s(r, "aria-haspopup", e.d = P), K !== e.l && A(C, e.l = K), e;
114
171
  }, {
115
172
  e: void 0,
116
173
  t: void 0,
@@ -118,12 +175,16 @@ function B(t) {
118
175
  o: void 0,
119
176
  i: void 0,
120
177
  n: void 0,
121
- s: void 0
122
- }), e;
178
+ s: void 0,
179
+ h: void 0,
180
+ r: void 0,
181
+ d: void 0,
182
+ l: void 0
183
+ }), r;
123
184
  }
124
185
  });
125
186
  }
126
- j(["click", "contextmenu", "keydown"]);
187
+ N(["pointerdown", "click", "contextmenu", "keydown"]);
127
188
  export {
128
- W as ActivityBar
189
+ de as ActivityBar
129
190
  };
@@ -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,132 @@
1
+ import { createSignal as D, createEffect as R, onCleanup as v } from "solid-js";
2
+ import { startPointerSession as T } from "../ui/pointerSession.js";
3
+ function A(n, m, i, y, h) {
4
+ const t = n.filter((p) => p !== m && i.has(p));
5
+ if (!n.includes(m) || !t.length) return;
6
+ let a = t.findIndex((p) => {
7
+ const x = i.get(p), e = x.getBoundingClientRect(), o = getComputedStyle(x).transform, r = typeof DOMMatrix == "function" ? new DOMMatrix(o === "none" ? void 0 : o) : void 0;
8
+ return h < (y === "x" ? e.left - (r?.m41 ?? 0) + e.width / 2 : e.top - (r?.m42 ?? 0) + e.height / 2);
9
+ });
10
+ a < 0 && (a = t.length);
11
+ const u = [...t];
12
+ return u.splice(a, 0, m), { key: t[Math.min(a, t.length - 1)], edge: a === t.length ? "after" : "before", order: u };
13
+ }
14
+ function B(n, m, i, y) {
15
+ if (!i.altKey || !i.shiftKey || i.ctrlKey || i.metaKey || i.isComposing) return;
16
+ const h = i.key === (y === "x" ? "ArrowLeft" : "ArrowUp") ? -1 : i.key === (y === "x" ? "ArrowRight" : "ArrowDown") ? 1 : 0, t = n.indexOf(m);
17
+ if (!h || t < 0) return;
18
+ i.preventDefault(), i.stopPropagation();
19
+ const a = Math.max(0, Math.min(n.length - 1, t + h));
20
+ if (t === a) return;
21
+ const u = [...n];
22
+ return u.splice(t, 1), u.splice(a, 0, m), u;
23
+ }
24
+ function Y(n) {
25
+ const [m, i] = D(), [y, h] = D();
26
+ let t, a = !1, u = 0, p;
27
+ const x = (o) => {
28
+ o.key !== "Escape" || !t || (o.preventDefault(), o.stopPropagation(), t.stop({ commit: !1 }));
29
+ };
30
+ R(() => {
31
+ n.keys(), n.onReorder(), t?.stop({ commit: !1 });
32
+ }), v(() => {
33
+ t?.stop({ commit: !1 }), p && clearTimeout(p);
34
+ });
35
+ const e = (o, r) => {
36
+ n.onReorder()?.(r), n.elements.get(o)?.focus({ preventScroll: !0 });
37
+ };
38
+ return {
39
+ dragging: m,
40
+ position: y,
41
+ keyDown(o, r) {
42
+ if (!n.onReorder()) return;
43
+ const l = B(n.keys(), o, r, "y");
44
+ l && e(o, l);
45
+ },
46
+ consumeClick() {
47
+ return a ? (a = !1, !0) : !1;
48
+ },
49
+ begin(o, r) {
50
+ if (r.button !== 0 || !n.onReorder() || !n.keys().includes(o)) return;
51
+ t?.stop({ commit: !1 });
52
+ const l = r.currentTarget, M = r.clientY, w = r.clientX;
53
+ let d = w, c = M, b = !1;
54
+ const k = (f, s) => {
55
+ if (d = f, c = s, b ||= Math.hypot(f - w, s - M) >= 5, !b) return;
56
+ i(o);
57
+ const g = n.container()?.getBoundingClientRect();
58
+ h(g && f >= g.left - 24 && f <= g.right + 24 && s >= g.top && s <= g.bottom ? A(n.keys(), o, n.elements, "y", s) : void 0);
59
+ }, C = () => {
60
+ const f = n.container();
61
+ if (b && f) {
62
+ const s = f.getBoundingClientRect(), g = c < s.top + 28 ? c - s.top - 28 : c > s.bottom - 28 ? c - s.bottom + 28 : 0;
63
+ if (d >= s.left - 24 && d <= s.right + 24 && c >= s.top - 24 && c <= s.bottom + 24 && g) {
64
+ const E = f.scrollTop;
65
+ f.scrollTop += Math.sign(g) * Math.min(10, Math.abs(g) / 3), f.scrollTop !== E && k(d, c);
66
+ }
67
+ }
68
+ u = requestAnimationFrame(C);
69
+ };
70
+ u = requestAnimationFrame(C), l.ownerDocument.addEventListener("keydown", x, !0), t = T({
71
+ pointerEvent: r,
72
+ captureEl: l,
73
+ onMove: (f) => k(f.clientX, f.clientY),
74
+ onEnd: ({ commit: f, snapshot: s }) => {
75
+ k(s.latestClientX, s.latestClientY);
76
+ const g = y();
77
+ cancelAnimationFrame(u), t = void 0, l.ownerDocument.removeEventListener("keydown", x, !0), i(void 0), h(void 0), b && (a = !0, p && clearTimeout(p), p = setTimeout(() => {
78
+ a = !1;
79
+ }, 0)), f && b && g && e(o, g.order);
80
+ }
81
+ });
82
+ }
83
+ };
84
+ }
85
+ function $(n) {
86
+ const m = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
87
+ let y = !1, h = 0;
88
+ R(() => {
89
+ const t = [...n.keys()], a = n.preview(), u = ++h;
90
+ queueMicrotask(() => {
91
+ if (h !== u) return;
92
+ const p = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, x = new Map(t.flatMap((e) => {
93
+ const o = n.elements.get(e);
94
+ if (!o) return [];
95
+ const r = o.getBoundingClientRect(), l = getComputedStyle(o).transform, M = typeof DOMMatrix == "function" ? new DOMMatrix(l === "none" ? void 0 : l) : void 0;
96
+ let w = 0, d = 0;
97
+ for (let c = o.parentElement; c; c = c.parentElement)
98
+ w += c.scrollLeft, d += c.scrollTop;
99
+ return [[e, { left: r.left + w - (M?.m41 ?? 0), top: r.top + d - (M?.m42 ?? 0), dx: M?.m41 ?? 0, dy: M?.m42 ?? 0 }]];
100
+ }));
101
+ for (const e of t) {
102
+ const o = n.elements.get(e), r = x.get(e);
103
+ if (!o || !r) continue;
104
+ const l = m.get(e), M = a ? t[a.indexOf(e)] : e, w = x.get(M) ?? r, d = n.axis === "x" ? w.left - r.left : 0, c = n.axis === "y" ? w.top - r.top : 0;
105
+ if (i.get(e)?.cancel(), i.delete(e), o.style.transform = d || c ? `translate3d(${d}px, ${c}px, 0)` : "", !p && y && typeof o.animate == "function") {
106
+ const b = l ? l.left - r.left + r.dx : d, k = l ? l.top - r.top + r.dy : c;
107
+ if (!l || Math.abs(b - d) + Math.abs(k - c) > 0.5) {
108
+ const C = o.animate([
109
+ { transform: `translate3d(${b}px, ${k}px, 0)`, opacity: l ? 1 : 0 },
110
+ { transform: `translate3d(${d}px, ${c}px, 0)`, opacity: 1 }
111
+ ], { duration: 180, easing: "cubic-bezier(0.33, 1, 0.68, 1)" });
112
+ i.set(e, C), C.onfinish = () => {
113
+ i.get(e) === C && i.delete(e);
114
+ };
115
+ }
116
+ }
117
+ m.set(e, { left: r.left, top: r.top });
118
+ }
119
+ for (const e of m.keys()) t.includes(e) || (m.delete(e), i.get(e)?.cancel(), i.delete(e));
120
+ y = !0;
121
+ });
122
+ }), v(() => {
123
+ h += 1;
124
+ for (const t of i.values()) t.cancel();
125
+ });
126
+ }
127
+ export {
128
+ A as barDropPosition,
129
+ $ as createBarLayoutMotion,
130
+ Y as createBarReorder,
131
+ B as keyboardBarOrder
132
+ };