@floegence/floe-webapp-core 0.36.40 → 0.36.42

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.
@@ -19,6 +19,8 @@ export interface OverlayHostGeometry {
19
19
  scrollTop: number;
20
20
  clientLeft: number;
21
21
  clientTop: number;
22
+ scaleX?: number;
23
+ scaleY?: number;
22
24
  }
23
25
  export interface FileBrowserMarqueeSelectionOptions {
24
26
  getContainer: () => HTMLElement | null;
@@ -1,93 +1,99 @@
1
- import { createSignal as S, createMemo as b, onCleanup as w } from "solid-js";
2
- import { isPrimaryModKeyPressed as M } from "../../utils/keybind.js";
3
- const y = 4, A = "pointer-events-none absolute z-40 rounded-md floe-file-browser-marquee-overlay";
4
- function T(e, n, c, o) {
5
- const l = Math.min(e, c), u = Math.min(n, o);
1
+ import { createSignal as v, createMemo as w, onCleanup as M } from "solid-js";
2
+ import { isPrimaryModKeyPressed as T } from "../../utils/keybind.js";
3
+ const x = 4, _ = "pointer-events-none absolute z-40 rounded-md floe-file-browser-marquee-overlay";
4
+ function y(e, t, l, r) {
5
+ const i = Math.min(e, l), s = Math.min(t, r);
6
6
  return {
7
- left: l,
8
- top: u,
9
- width: Math.abs(c - e),
10
- height: Math.abs(o - n)
7
+ left: i,
8
+ top: s,
9
+ width: Math.abs(l - e),
10
+ height: Math.abs(r - t)
11
11
  };
12
12
  }
13
- function O(e, n) {
14
- return !(e.left + e.width < n.left || n.right < e.left || e.top + e.height < n.top || n.bottom < e.top);
13
+ function H(e, t) {
14
+ return !(e.left + e.width < t.left || t.right < e.left || e.top + e.height < t.top || t.bottom < e.top);
15
15
  }
16
- function P(e) {
16
+ function O(e) {
17
17
  return !(!(e instanceof Element) || e.closest("[data-file-browser-item-id]") || e.closest('button, input, textarea, select, a, [role="button"], [role="menuitem"]'));
18
18
  }
19
- function x(e) {
20
- const n = e.getBoundingClientRect();
19
+ function P(e) {
20
+ const t = e.getBoundingClientRect(), l = e.offsetWidth, r = e.offsetHeight;
21
21
  return {
22
- left: n.left,
23
- top: n.top,
22
+ left: t.left,
23
+ top: t.top,
24
24
  scrollLeft: e.scrollLeft,
25
25
  scrollTop: e.scrollTop,
26
26
  clientLeft: e.clientLeft,
27
- clientTop: e.clientTop
27
+ clientTop: e.clientTop,
28
+ scaleX: l > 0 && t.width > 0 ? t.width / l : 1,
29
+ scaleY: r > 0 && t.height > 0 ? t.height / r : 1
28
30
  };
29
31
  }
30
- function C(e, n) {
32
+ function I(e) {
33
+ return Number.isFinite(e) && e !== void 0 && e > 0 ? e : 1;
34
+ }
35
+ function B(e, t) {
36
+ const l = I(t.scaleX), r = I(t.scaleY);
31
37
  return {
32
- left: e.left - n.left + n.scrollLeft - n.clientLeft,
33
- top: e.top - n.top + n.scrollTop - n.clientTop,
34
- width: e.width,
35
- height: e.height
38
+ left: (e.left - t.left) / l + t.scrollLeft - t.clientLeft,
39
+ top: (e.top - t.top) / r + t.scrollTop - t.clientTop,
40
+ width: e.width / l,
41
+ height: e.height / r
36
42
  };
37
43
  }
38
- function D(e) {
39
- const [n, c] = S(null);
40
- let o = null, l = !1, u = [], a = 0, f = 0, s = !1;
41
- const I = () => {
42
- typeof document > "u" || (document.removeEventListener("pointermove", p, !0), document.removeEventListener("pointerup", m, !0), document.removeEventListener("pointercancel", h, !0));
43
- }, d = () => {
44
- I(), o = null, l = !1, u = [], a = 0, f = 0, s = !1, c(null);
45
- }, L = (t) => {
46
- const i = e.getVisibleItemIdsInOrder().filter((R) => {
47
- const g = e.getElementForId(R);
48
- return g ? O(t, g.getBoundingClientRect()) : !1;
49
- }), r = l ? [...u, ...i] : i;
50
- e.replaceSelection(r, {
51
- anchorId: l ? void 0 : r[0] ?? null,
52
- lastInteractedId: r[r.length - 1] ?? null,
53
- preserveAnchor: l
44
+ function A(e) {
45
+ const [t, l] = v(null);
46
+ let r = null, i = !1, s = [], a = 0, d = 0, u = !1;
47
+ const L = () => {
48
+ typeof document > "u" || (document.removeEventListener("pointermove", p, !0), document.removeEventListener("pointerup", h, !0), document.removeEventListener("pointercancel", m, !0));
49
+ }, f = () => {
50
+ L(), r = null, i = !1, s = [], a = 0, d = 0, u = !1, l(null);
51
+ }, E = (n) => {
52
+ const c = e.getVisibleItemIdsInOrder().filter((S) => {
53
+ const g = e.getElementForId(S);
54
+ return g ? H(n, g.getBoundingClientRect()) : !1;
55
+ }), o = i ? [...s, ...c] : c;
56
+ e.replaceSelection(o, {
57
+ anchorId: i ? void 0 : o[0] ?? null,
58
+ lastInteractedId: o[o.length - 1] ?? null,
59
+ preserveAnchor: i
54
60
  });
55
- }, p = (t) => {
56
- if (o !== t.pointerId) return;
57
- const i = Math.hypot(t.clientX - a, t.clientY - f);
58
- if (!s && i < y)
61
+ }, p = (n) => {
62
+ if (r !== n.pointerId) return;
63
+ const c = Math.hypot(n.clientX - a, n.clientY - d);
64
+ if (!u && c < x)
59
65
  return;
60
- t.preventDefault(), s = !0;
61
- const r = T(a, f, t.clientX, t.clientY);
62
- c(r), L(r);
63
- }, m = (t) => {
64
- o === t.pointerId && (!s && !l && e.clearSelection(), d());
65
- }, h = (t) => {
66
- o === t.pointerId && d();
67
- }, v = (t) => {
68
- t.pointerType !== "mouse" || t.button !== 0 || P(t.target) && e.getContainer() && (o = t.pointerId, l = M(t), u = l ? e.getSelectedIds() : [], a = t.clientX, f = t.clientY, s = !1, typeof document < "u" && (document.addEventListener("pointermove", p, !0), document.addEventListener("pointerup", m, !0), document.addEventListener("pointercancel", h, !0)), t.preventDefault());
69
- }, E = b(() => {
70
- const t = n();
71
- if (!t) return null;
72
- const i = e.getOverlayHost?.() ?? e.getContainer();
73
- if (!i) return null;
74
- const r = C(t, x(i));
66
+ n.preventDefault(), u = !0;
67
+ const o = y(a, d, n.clientX, n.clientY);
68
+ l(o), E(o);
69
+ }, h = (n) => {
70
+ r === n.pointerId && (!u && !i && e.clearSelection(), f());
71
+ }, m = (n) => {
72
+ r === n.pointerId && f();
73
+ }, b = (n) => {
74
+ n.pointerType !== "mouse" || n.button !== 0 || O(n.target) && e.getContainer() && (r = n.pointerId, i = T(n), s = i ? e.getSelectedIds() : [], a = n.clientX, d = n.clientY, u = !1, typeof document < "u" && (document.addEventListener("pointermove", p, !0), document.addEventListener("pointerup", h, !0), document.addEventListener("pointercancel", m, !0)), n.preventDefault());
75
+ }, R = w(() => {
76
+ const n = t();
77
+ if (!n) return null;
78
+ const c = e.getOverlayHost?.() ?? e.getContainer();
79
+ if (!c) return null;
80
+ const o = B(n, P(c));
75
81
  return {
76
- left: `${r.left}px`,
77
- top: `${r.top}px`,
78
- width: `${r.width}px`,
79
- height: `${r.height}px`
82
+ left: `${o.left}px`,
83
+ top: `${o.top}px`,
84
+ width: `${o.width}px`,
85
+ height: `${o.height}px`
80
86
  };
81
87
  });
82
- return w(() => {
83
- d();
88
+ return M(() => {
89
+ f();
84
90
  }), {
85
- overlayStyle: E,
86
- onPointerDown: v
91
+ overlayStyle: R,
92
+ onPointerDown: b
87
93
  };
88
94
  }
89
95
  export {
90
- A as FILE_BROWSER_MARQUEE_OVERLAY_CLASS,
91
- D as createFileBrowserMarqueeSelection,
92
- C as projectViewportRectToOverlayHost
96
+ _ as FILE_BROWSER_MARQUEE_OVERLAY_CLASS,
97
+ A as createFileBrowserMarqueeSelection,
98
+ B as projectViewportRectToOverlayHost
93
99
  };
@@ -1,4 +1,5 @@
1
1
  import { type JSX } from 'solid-js';
2
+ import { type FloatingWindowViewportInsets } from './floatingWindowGeometry';
2
3
  export interface FloatingWindowProps {
3
4
  /** Whether the window is open */
4
5
  open: boolean;
@@ -30,6 +31,8 @@ export interface FloatingWindowProps {
30
31
  width: number;
31
32
  height: number;
32
33
  };
34
+ /** Safe area inside the browser viewport that the floating window should avoid */
35
+ viewportInsets?: FloatingWindowViewportInsets;
33
36
  /** Whether the window can be resized */
34
37
  resizable?: boolean;
35
38
  /** Whether the window can be dragged */