@floegence/floe-webapp-core 0.35.13 → 0.35.14

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.
@@ -0,0 +1,65 @@
1
+ function l(o, h, e) {
2
+ return Math.max(h, Math.min(e, o));
3
+ }
4
+ function z(o, h, e) {
5
+ const a = Math.max(0, e), t = Math.min(o, a), n = Math.max(t, Math.min(h, a));
6
+ return { min: t, max: n };
7
+ }
8
+ function S(o) {
9
+ const {
10
+ mode: h,
11
+ pointer: e,
12
+ dragStartPos: a,
13
+ dragStartRect: t,
14
+ resizeStartPos: n,
15
+ resizeStartRect: i,
16
+ resizeHandle: m,
17
+ minSize: g,
18
+ maxSize: d,
19
+ viewport: s,
20
+ mobile: x,
21
+ mobilePadding: M
22
+ } = o, r = e.x - (h === "drag" ? a.x : n.x), w = e.y - (h === "drag" ? a.y : n.y);
23
+ if (h === "drag")
24
+ return {
25
+ ...t,
26
+ x: x ? M : Math.max(0, Math.min(s.width - t.width, t.x + r)),
27
+ y: Math.max(0, Math.min(s.height - t.height, t.y + w))
28
+ };
29
+ let u = i.width, f = i.height, y = i.x, b = i.y;
30
+ if (!x && m.includes("e") && (u = Math.max(g.width, Math.min(d.width, i.width + r))), !x && m.includes("w")) {
31
+ const c = i.width - r;
32
+ c >= g.width && c <= d.width && (u = c, y = i.x + r);
33
+ }
34
+ if (m.includes("s") && (f = Math.max(g.height, Math.min(d.height, i.height + w))), m.includes("n")) {
35
+ const c = i.height - w;
36
+ c >= g.height && c <= d.height && (f = c, b = i.y + w);
37
+ }
38
+ return {
39
+ x: Math.max(0, Math.min(s.width - u, y)),
40
+ y: Math.max(0, Math.min(s.height - f, b)),
41
+ width: u,
42
+ height: f
43
+ };
44
+ }
45
+ function p(o) {
46
+ const {
47
+ rect: h,
48
+ minSize: e,
49
+ maxSize: a,
50
+ viewport: t,
51
+ mobile: n,
52
+ mobilePadding: i,
53
+ center: m = !1
54
+ } = o, g = n ? Math.max(0, t.width - i * 2) : t.width, d = z(e.width, a.width, g), s = z(e.height, a.height, t.height), x = n ? d.max : l(h.width, d.min, d.max), M = l(h.height, s.min, s.max), r = Math.max(0, t.width - x), w = Math.max(0, t.height - M);
55
+ return {
56
+ x: n ? l(i, 0, r) : m ? Math.max(0, Math.round((t.width - x) / 2)) : l(h.x, 0, r),
57
+ y: m ? Math.max(0, Math.round((t.height - M) / 2)) : l(h.y, 0, w),
58
+ width: x,
59
+ height: M
60
+ };
61
+ }
62
+ export {
63
+ p as normalizeFloatingWindowRect,
64
+ S as resolveFloatingWindowRect
65
+ };
@@ -1,7 +1,8 @@
1
- import { createComponent as F } from "solid-js/web";
2
- import { createSignal as N, onCleanup as _, useContext as h, createContext as z } from "solid-js";
3
- import { lockBodyStyle as O } from "../utils/bodyStyleLock.js";
4
- const D = z(), T = {
1
+ import { createComponent as E } from "solid-js/web";
2
+ import { createSignal as F, onCleanup as _, useContext as h, createContext as k } from "solid-js";
3
+ import { deferNonBlocking as z } from "../utils/defer.js";
4
+ import { startHotInteraction as O } from "../utils/hotInteraction.js";
5
+ const D = k(), T = {
5
6
  isDragging: !1,
6
7
  draggedItems: [],
7
8
  sourceInstanceId: null,
@@ -16,23 +17,24 @@ const D = z(), T = {
16
17
  isDropCommitted: !1,
17
18
  dropTargetRect: null
18
19
  }, b = 200;
19
- function k(m) {
20
+ function H(m) {
20
21
  const d = m.trim() || "/";
21
22
  if (d === "/") return "/";
22
23
  const r = d.split("/").filter(Boolean);
23
24
  return r.pop(), r.length ? "/" + r.join("/") : "/";
24
25
  }
25
- function W(m) {
26
- const [d, r] = N(T), a = /* @__PURE__ */ new Map();
27
- let i = null;
26
+ function q(m) {
27
+ const [d, r] = F(T), a = /* @__PURE__ */ new Map();
28
+ let s = null;
28
29
  const P = (t) => {
29
30
  a.set(t.instanceId, t);
30
31
  }, R = (t) => {
31
32
  a.delete(t);
32
33
  }, C = (t) => a.get(t), v = () => a, x = (t, e, n) => {
33
- t.length !== 0 && (i?.(), i = O({
34
+ t.length !== 0 && (s?.(), s = O({
35
+ kind: "drag",
34
36
  cursor: "grabbing",
35
- "user-select": "none"
37
+ lockUserSelect: !0
36
38
  }), r({
37
39
  isDragging: !0,
38
40
  draggedItems: t,
@@ -56,29 +58,29 @@ function W(m) {
56
58
  y: e
57
59
  }
58
60
  }));
59
- }, y = (t, e, n) => {
61
+ }, A = (t, e, n) => {
60
62
  r((c) => ({
61
63
  ...c,
62
64
  dropTarget: t,
63
65
  isValidDrop: e,
64
66
  dropTargetRect: n ?? null
65
67
  }));
66
- }, A = (t, e, n, c) => {
68
+ }, B = (t, e, n, c) => {
67
69
  if (t.length === 0 || n && n.type === "file") return !1;
68
70
  for (const o of t) {
69
- const l = o.item.path, g = k(l);
71
+ const g = o.item.path, l = H(g);
70
72
  if (o.item.type === "folder") {
71
- const u = e.trim() || "/", p = l.trim() || "/";
72
- if (u === p || u.startsWith(p + "/")) return !1;
73
+ const p = e.trim() || "/", u = g.trim() || "/";
74
+ if (p === u || p.startsWith(u + "/")) return !1;
73
75
  }
74
- if (o.sourceInstanceId === c && g === e)
76
+ if (o.sourceInstanceId === c && l === e)
75
77
  return !1;
76
78
  }
77
79
  return !0;
78
- }, B = (t) => {
80
+ }, S = (t) => {
79
81
  const e = d();
80
82
  if (!e.isDragging) return;
81
- i?.(), i = null;
83
+ s?.(), s = null;
82
84
  const n = !!(t && e.dropTarget && e.isValidDrop);
83
85
  let c = null;
84
86
  if (n && e.dropTargetRect && (c = {
@@ -94,24 +96,24 @@ function W(m) {
94
96
  })), n) {
95
97
  const {
96
98
  draggedItems: o,
97
- sourceInstanceId: l
99
+ sourceInstanceId: g
98
100
  } = e, {
99
- targetPath: g,
100
- instanceId: u
101
- } = e.dropTarget, p = l ? a.get(l) : void 0, f = a.get(u);
101
+ targetPath: l,
102
+ instanceId: p
103
+ } = e.dropTarget, u = g ? a.get(g) : void 0, f = a.get(p);
102
104
  if (f?.onDragMove) {
103
- const I = o.map((s) => s.item), M = o.map((s) => s.item.path);
104
- p?.optimisticRemove(M);
105
- for (const s of I) {
106
- const V = g === "/" ? "/" + s.name : g + "/" + s.name, E = {
107
- ...s,
105
+ const I = o.map((i) => i.item), N = o.map((i) => i.item.path);
106
+ u?.optimisticRemove(N);
107
+ for (const i of I) {
108
+ const V = l === "/" ? "/" + i.name : l + "/" + i.name, y = {
109
+ ...i,
108
110
  path: V
109
111
  };
110
- f.optimisticInsert(g, E);
112
+ f.optimisticInsert(l, y);
111
113
  }
112
- setTimeout(() => {
113
- f.onDragMove(I, g, l || "");
114
- }, 0);
114
+ z(() => {
115
+ f.onDragMove(I, l, g || "");
116
+ });
115
117
  }
116
118
  }
117
119
  setTimeout(() => {
@@ -119,9 +121,9 @@ function W(m) {
119
121
  }, b);
120
122
  };
121
123
  _(() => {
122
- i?.(), i = null, a.clear();
124
+ s?.(), s = null, a.clear();
123
125
  });
124
- const S = {
126
+ const M = {
125
127
  dragState: d,
126
128
  registerInstance: P,
127
129
  unregisterInstance: R,
@@ -129,25 +131,25 @@ function W(m) {
129
131
  getInstances: v,
130
132
  startDrag: x,
131
133
  updateDrag: w,
132
- setDropTarget: y,
133
- endDrag: B,
134
- canDropOn: A
134
+ setDropTarget: A,
135
+ endDrag: S,
136
+ canDropOn: B
135
137
  };
136
- return F(D.Provider, {
137
- value: S,
138
+ return E(D.Provider, {
139
+ value: M,
138
140
  get children() {
139
141
  return m.children;
140
142
  }
141
143
  });
142
144
  }
143
- function q() {
145
+ function J() {
144
146
  return h(D);
145
147
  }
146
- function H() {
148
+ function K() {
147
149
  return h(D) !== void 0;
148
150
  }
149
151
  export {
150
- W as FileBrowserDragProvider,
151
- H as hasFileBrowserDragContext,
152
- q as useFileBrowserDrag
152
+ q as FileBrowserDragProvider,
153
+ K as hasFileBrowserDragContext,
154
+ J as useFileBrowserDrag
153
155
  };
@@ -3,6 +3,7 @@ export interface LayoutContextValue {
3
3
  sidebarWidth: Accessor<number>;
4
4
  sidebarActiveTab: Accessor<string>;
5
5
  sidebarCollapsed: Accessor<boolean>;
6
+ clampSidebarWidth: (width: number) => number;
6
7
  setSidebarWidth: (width: number) => void;
7
8
  setSidebarActiveTab: (tab: string, opts?: {
8
9
  openSidebar?: boolean;
@@ -1,16 +1,16 @@
1
- import { createEffect as c } from "solid-js";
2
- import { createStore as m, produce as d } from "solid-js/store";
3
- import { createSimpleContext as p } from "./createSimpleContext.js";
4
- import { useResolvedFloeConfig as h } from "./FloeConfigContext.js";
1
+ import { createEffect as m } from "solid-js";
2
+ import { createStore as p, produce as d } from "solid-js/store";
3
+ import { createSimpleContext as h } from "./createSimpleContext.js";
4
+ import { useResolvedFloeConfig as f } from "./FloeConfigContext.js";
5
5
  const {
6
- Provider: T,
7
- use: w
8
- } = p({
6
+ Provider: w,
7
+ use: y
8
+ } = h({
9
9
  name: "Layout",
10
- init: f
10
+ init: u
11
11
  });
12
- function f() {
13
- const l = h(), a = () => l.config.layout, n = () => typeof window > "u" ? !1 : window.matchMedia(a().mobileQuery).matches, o = l.persist.load(a().storageKey, {}), b = {
12
+ function u() {
13
+ const l = f(), a = () => l.config.layout, b = () => typeof window > "u" ? !1 : window.matchMedia(a().mobileQuery).matches, o = l.persist.load(a().storageKey, {}), c = {
14
14
  sidebar: {
15
15
  width: o.sidebar?.width ?? a().sidebar.defaultWidth,
16
16
  activeTab: o.sidebar?.activeTab ?? a().sidebar.defaultActiveTab,
@@ -20,9 +20,9 @@ function f() {
20
20
  opened: o.terminal?.opened ?? a().terminal.defaultOpened,
21
21
  height: o.terminal?.height ?? a().terminal.defaultHeight
22
22
  },
23
- isMobile: n()
24
- }, [i, t] = m(b);
25
- return c(() => {
23
+ isMobile: b()
24
+ }, [i, t] = p(c), s = (e) => Math.max(a().sidebar.clamp.min, Math.min(a().sidebar.clamp.max, e));
25
+ return m(() => {
26
26
  const e = {
27
27
  sidebar: {
28
28
  width: i.sidebar.width,
@@ -40,12 +40,13 @@ function f() {
40
40
  sidebarWidth: () => i.sidebar.width,
41
41
  sidebarActiveTab: () => i.sidebar.activeTab,
42
42
  sidebarCollapsed: () => i.sidebar.collapsed,
43
+ clampSidebarWidth: s,
43
44
  // Sidebar actions
44
45
  setSidebarWidth: (e) => t(d((r) => {
45
- r.sidebar.width = Math.max(a().sidebar.clamp.min, Math.min(a().sidebar.clamp.max, e));
46
+ r.sidebar.width = s(e);
46
47
  })),
47
- setSidebarActiveTab: (e, r) => t(d((s) => {
48
- s.sidebar.activeTab = e, r?.openSidebar !== !1 && (s.sidebar.collapsed = !1);
48
+ setSidebarActiveTab: (e, r) => t(d((n) => {
49
+ n.sidebar.activeTab = e, r?.openSidebar !== !1 && (n.sidebar.collapsed = !1);
49
50
  })),
50
51
  setSidebarCollapsed: (e) => t(d((r) => {
51
52
  r.sidebar.collapsed = e;
@@ -69,7 +70,7 @@ function f() {
69
70
  };
70
71
  }
71
72
  export {
72
- T as LayoutProvider,
73
- f as createLayoutService,
74
- w as useLayout
73
+ w as LayoutProvider,
74
+ u as createLayoutService,
75
+ y as useLayout
75
76
  };
package/dist/floe.css CHANGED
@@ -328,6 +328,18 @@
328
328
  -webkit-tap-highlight-color: transparent;
329
329
  touch-action: manipulation;
330
330
  }
331
+
332
+ [data-floe-geometry-surface='floating-window'] {
333
+ contain: layout paint style;
334
+ }
335
+
336
+ [data-floe-hot-interaction~='resize'] [data-floe-geometry-surface='shell-sidebar'],
337
+ [data-floe-hot-interaction~='resize'] [data-floe-geometry-surface='sidebar-pane'],
338
+ [data-floe-hot-interaction~='resize'] [data-floe-geometry-surface='floating-window'],
339
+ [data-floe-hot-interaction~='drag'] [data-floe-geometry-surface='floating-window'] {
340
+ animation: none !important;
341
+ transition: none !important;
342
+ }
331
343
  }
332
344
 
333
345
  /* Animation utilities */
@@ -1,27 +1,31 @@
1
- import { createEffect as q, onCleanup as G } from "solid-js";
2
- import { useDeck as z } from "../context/DeckContext.js";
3
- import { applyDragDelta as N } from "../utils/gridLayout.js";
4
- import { getGridConfigFromElement as O } from "../components/deck/DeckGrid.js";
5
- import { lockBodyStyle as U } from "../utils/bodyStyleLock.js";
1
+ import { createEffect as G, onCleanup as z } from "solid-js";
2
+ import { useDeck as B } from "../context/DeckContext.js";
3
+ import { applyDragDelta as U } from "../utils/gridLayout.js";
4
+ import { getGridConfigFromElement as N } from "../components/deck/DeckGrid.js";
5
+ import { startHotInteraction as O } from "../utils/hotInteraction.js";
6
6
  function Z() {
7
- const p = z();
8
- let c = null, m = 0, f = 0, L = 0, g = 0, i = 0, P = 0, A = 0, F = 0, a = null, v = null, T = null, y = null, n = null, b = null, k = 0, C = 0, w = null;
9
- const M = (t) => {
7
+ const p = B();
8
+ let c = null, m = 0, f = 0, L = 0, g = 0, l = 0, P = 0, I = 0, A = 0, a = null, v = null, F = null, w = null, n = null, T = null, H = 0, k = 0, y = null;
9
+ const C = (t) => {
10
10
  if (!t) {
11
- y?.(), y = null;
11
+ w?.(), w = null;
12
12
  return;
13
13
  }
14
- y?.(), y = U({ cursor: "grabbing", "user-select": "none" });
15
- }, H = () => {
16
- c !== null && (a !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(a), a = null), c = null, v = null, T = null, n = null, b = null, w = null, M(!1), p.endDrag(!0));
14
+ w?.(), w = O({
15
+ kind: "drag",
16
+ cursor: "grabbing",
17
+ lockUserSelect: !0
18
+ });
19
+ }, M = () => {
20
+ c !== null && (a !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(a), a = null), c = null, v = null, F = null, n = null, T = null, y = null, C(!1), p.endDrag(!0));
17
21
  }, Y = () => {
18
22
  if (!n) return;
19
- const t = b ?? n.getBoundingClientRect(), e = 48, d = 24, s = i - t.top, o = t.bottom - i;
23
+ const t = T ?? n.getBoundingClientRect(), e = 48, d = 24, s = l - t.top, o = t.bottom - l;
20
24
  let r = 0;
21
25
  if (s < e ? r = -Math.ceil((e - s) / e * d) : o < e && (r = Math.ceil((e - o) / e * d)), r === 0) return;
22
- const l = n.scrollTop, h = Math.max(0, Math.min(l + r, n.scrollHeight - n.clientHeight));
23
- h !== l && (n.scrollTop = h);
24
- }, B = () => {
26
+ const i = n.scrollTop, h = Math.max(0, Math.min(i + r, n.scrollHeight - n.clientHeight));
27
+ h !== i && (n.scrollTop = h);
28
+ }, R = () => {
25
29
  if (a !== null || typeof requestAnimationFrame > "u") return;
26
30
  const t = () => {
27
31
  if (c === null) {
@@ -38,37 +42,37 @@ function Z() {
38
42
  if (!o || t.pointerType === "mouse" && t.button !== 0) return;
39
43
  const r = o.dataset.widgetDragHandle;
40
44
  if (!r) return;
41
- const l = o.closest(".deck-grid");
42
- if (!l) return;
43
- t.preventDefault(), t.stopPropagation(), c = t.pointerId, m = t.clientX, f = t.clientY, g = m, i = f, P = m, A = f, v = r, T = o, n = l, b = l.getBoundingClientRect(), L = l.scrollTop, F = L, M(!0);
44
- const u = p.activeLayout()?.widgets.find((I) => I.id === r);
45
- w = u ? { ...u.position } : null;
46
- const E = window.getComputedStyle(l);
47
- k = parseFloat(E.paddingLeft) || 0, C = parseFloat(E.paddingRight) || 0, p.startDrag(r, m, f), o.setPointerCapture(t.pointerId), B();
45
+ const i = o.closest(".deck-grid");
46
+ if (!i) return;
47
+ t.preventDefault(), t.stopPropagation(), c = t.pointerId, m = t.clientX, f = t.clientY, g = m, l = f, P = m, I = f, v = r, F = o, n = i, T = i.getBoundingClientRect(), L = i.scrollTop, A = L, C(!0);
48
+ const u = p.activeLayout()?.widgets.find((b) => b.id === r);
49
+ y = u ? { ...u.position } : null;
50
+ const E = window.getComputedStyle(i);
51
+ H = parseFloat(E.paddingLeft) || 0, k = parseFloat(E.paddingRight) || 0, p.startDrag(r, m, f), o.setPointerCapture(t.pointerId), R();
48
52
  }, x = (t) => {
49
- c !== t.pointerId || !v || (g = t.clientX, i = t.clientY, typeof requestAnimationFrame > "u" && X());
53
+ c !== t.pointerId || !v || (g = t.clientX, l = t.clientY, typeof requestAnimationFrame > "u" && X());
50
54
  }, X = () => {
51
- if (!v || !n || !w) return;
55
+ if (!v || !n || !y) return;
52
56
  Y();
53
57
  const t = n.scrollTop;
54
- if (g === P && i === A && t === F) return;
55
- P = g, A = i, F = t;
56
- const e = g - m, d = i - f + (t - L), { cols: s, rowHeight: o, gap: r } = O(n), l = n.clientWidth - k - C, h = r * (s - 1), u = (l - h) / s;
58
+ if (g === P && l === I && t === A) return;
59
+ P = g, I = l, A = t;
60
+ const e = g - m, d = l - f + (t - L), { cols: s, rowHeight: o, gap: r } = N(n), i = n.clientWidth - H - k, h = r * (s - 1), u = (i - h) / s;
57
61
  if (!Number.isFinite(u) || u <= 0) return;
58
- const E = o + r, I = Math.round(e / u), R = Math.round(d / E), W = N(w, I, R, s);
59
- p.updateDrag(W, { x: e, y: d });
62
+ const E = o + r, b = Math.round(e / u), W = Math.round(d / E), q = U(y, b, W, s);
63
+ p.updateDrag(q, { x: e, y: d });
60
64
  }, D = (t) => {
61
65
  if (c === t.pointerId) {
62
66
  try {
63
- T?.releasePointerCapture(t.pointerId);
67
+ F?.releasePointerCapture(t.pointerId);
64
68
  } catch {
65
69
  }
66
- H();
70
+ M();
67
71
  }
68
72
  };
69
- q(() => {
70
- p.editMode() && (typeof document > "u" || (document.addEventListener("pointerdown", S, !0), document.addEventListener("pointermove", x, !0), document.addEventListener("pointerup", D, !0), document.addEventListener("pointercancel", D, !0), G(() => {
71
- H(), document.removeEventListener("pointerdown", S, !0), document.removeEventListener("pointermove", x, !0), document.removeEventListener("pointerup", D, !0), document.removeEventListener("pointercancel", D, !0);
73
+ G(() => {
74
+ p.editMode() && (typeof document > "u" || (document.addEventListener("pointerdown", S, !0), document.addEventListener("pointermove", x, !0), document.addEventListener("pointerup", D, !0), document.addEventListener("pointercancel", D, !0), z(() => {
75
+ M(), document.removeEventListener("pointerdown", S, !0), document.removeEventListener("pointermove", x, !0), document.removeEventListener("pointerup", D, !0), document.removeEventListener("pointercancel", D, !0);
72
76
  })));
73
77
  });
74
78
  }