@floegence/floe-webapp-core 0.86.55 → 0.86.58

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.
@@ -30,6 +30,7 @@ interface ResolveFloatingWindowRectOptions {
30
30
  pointer: PointerPosition;
31
31
  dragStartPos: PointerPosition;
32
32
  dragStartRect: FloatingWindowRect;
33
+ dragTitlebarHeight?: number;
33
34
  resizeStartPos: PointerPosition;
34
35
  resizeStartRect: FloatingWindowRect;
35
36
  resizeHandle: FloatingWindowResizeHandle;
@@ -1,97 +1,113 @@
1
- function x(n, i, m) {
2
- return Math.max(i, Math.min(m, n));
1
+ function r(t, n, s) {
2
+ return Math.max(n, Math.min(s, t));
3
3
  }
4
- function l(n, i, m) {
5
- const s = Math.max(0, m), o = Math.min(n, s), c = Math.max(o, Math.min(i, s));
6
- return { min: o, max: c };
4
+ function Y(t, n, s, m, e) {
5
+ const x = r(t, n, s), i = t - x, c = Math.max(0, i < 0 ? m : e);
6
+ return x + (c === 0 ? 0 : i * c / (c + Math.abs(i)));
7
7
  }
8
- function v(n) {
9
- const i = Number(n);
10
- return Number.isFinite(i) && i > 0 ? i : 0;
8
+ function f(t, n, s) {
9
+ const m = Math.max(0, s), e = Math.min(t, m), x = Math.max(e, Math.min(n, m));
10
+ return { min: e, max: x };
11
11
  }
12
- function X(n, i = {}) {
13
- const m = Math.max(0, n.width), s = Math.max(0, n.height), o = Math.min(v(i.left), m), c = Math.min(v(i.top), s), e = Math.min(v(i.right), Math.max(0, m - o)), d = Math.min(v(i.bottom), Math.max(0, s - c));
12
+ function R(t) {
13
+ const n = Number(t);
14
+ return Number.isFinite(n) && n > 0 ? n : 0;
15
+ }
16
+ function I(t, n = {}) {
17
+ const s = Math.max(0, t.width), m = Math.max(0, t.height), e = Math.min(R(n.left), s), x = Math.min(R(n.top), m), i = Math.min(R(n.right), Math.max(0, s - e)), c = Math.min(R(n.bottom), Math.max(0, m - x));
14
18
  return {
15
- x: (n.x ?? 0) + o,
16
- y: (n.y ?? 0) + c,
17
- width: Math.max(0, m - o - e),
18
- height: Math.max(0, s - c - d)
19
+ x: (t.x ?? 0) + e,
20
+ y: (t.y ?? 0) + x,
21
+ width: Math.max(0, s - e - i),
22
+ height: Math.max(0, m - x - c)
19
23
  };
20
24
  }
21
- function Y(n) {
22
- return n.x + n.width;
25
+ function V(t) {
26
+ return t.x + t.width;
23
27
  }
24
- function H(n) {
25
- return n.y + n.height;
28
+ function N(t) {
29
+ return t.y + t.height;
26
30
  }
27
- function I(n) {
31
+ function T(t) {
28
32
  const {
29
- mode: i,
30
- pointer: m,
31
- dragStartPos: s,
32
- dragStartRect: o,
33
- resizeStartPos: c,
34
- resizeStartRect: e,
35
- resizeHandle: d,
36
- minSize: r,
37
- maxSize: t,
38
- viewport: R,
39
- viewportInsets: S,
40
- mobile: y,
41
- mobilePadding: f
42
- } = n, a = X(R, S), g = Y(a), M = H(a), u = m.x - (i === "drag" ? s.x : c.x), p = m.y - (i === "drag" ? s.y : c.y);
43
- if (i === "drag") {
44
- const h = Math.max(a.x, g - o.width), w = Math.max(a.y, M - o.height);
33
+ mode: n,
34
+ pointer: s,
35
+ dragStartPos: m,
36
+ dragStartRect: e,
37
+ resizeStartPos: x,
38
+ resizeStartRect: i,
39
+ resizeHandle: c,
40
+ minSize: w,
41
+ maxSize: h,
42
+ viewport: S,
43
+ viewportInsets: W,
44
+ mobile: b,
45
+ mobilePadding: p
46
+ } = t, a = I(S, W), d = V(a), g = N(a), u = s.x - (n === "drag" ? m.x : x.x), B = s.y - (n === "drag" ? m.y : x.y);
47
+ if (n === "drag") {
48
+ const o = Math.max(a.x, d - e.width), M = Math.max(a.y, g - e.height), l = Math.min(160, e.width, a.width), y = Math.min(t.dragTitlebarHeight ?? 32, e.height), P = Math.min(24, y, a.height), X = Math.min(160, e.width - l);
45
49
  return {
46
- ...o,
47
- x: x(y ? a.x + f : o.x + u, a.x, h),
48
- y: x(o.y + p, a.y, w)
50
+ ...e,
51
+ x: b ? r(a.x + p, a.x, o) : Y(
52
+ e.x + u,
53
+ a.x,
54
+ o,
55
+ X,
56
+ Math.min(X, d - l - o)
57
+ ),
58
+ y: Y(
59
+ e.y + B,
60
+ a.y,
61
+ M,
62
+ y - P,
63
+ Math.min(160, g - P - M)
64
+ )
49
65
  };
50
66
  }
51
- let b = e.width, z = e.height, W = e.x, F = e.y;
52
- if (!y && d.includes("e")) {
53
- const h = l(r.width, t.width, g - e.x);
54
- b = x(e.width + u, h.min, h.max);
67
+ let v = i.width, z = i.height, H = i.x, F = i.y;
68
+ if (!b && c.includes("e")) {
69
+ const o = f(w.width, h.width, d - i.x);
70
+ v = r(i.width + u, o.min, o.max);
55
71
  }
56
- if (!y && d.includes("w")) {
57
- const h = e.x + e.width, w = l(r.width, t.width, h - a.x), B = h - w.max, P = Math.max(B, h - w.min);
58
- W = x(e.x + u, B, P), b = Math.max(0, h - W);
72
+ if (!b && c.includes("w")) {
73
+ const o = i.x + i.width, M = f(w.width, h.width, o - a.x), l = o - M.max, y = Math.max(l, o - M.min);
74
+ H = r(i.x + u, l, y), v = Math.max(0, o - H);
59
75
  }
60
- if (d.includes("s")) {
61
- const h = l(r.height, t.height, M - e.y);
62
- z = x(e.height + p, h.min, h.max);
76
+ if (c.includes("s")) {
77
+ const o = f(w.height, h.height, g - i.y);
78
+ z = r(i.height + B, o.min, o.max);
63
79
  }
64
- if (d.includes("n")) {
65
- const h = e.y + e.height, w = l(r.height, t.height, h - a.y), B = h - w.max, P = Math.max(B, h - w.min);
66
- F = x(e.y + p, B, P), z = Math.max(0, h - F);
80
+ if (c.includes("n")) {
81
+ const o = i.y + i.height, M = f(w.height, h.height, o - a.y), l = o - M.max, y = Math.max(l, o - M.min);
82
+ F = r(i.y + B, l, y), z = Math.max(0, o - F);
67
83
  }
68
84
  return {
69
- x: x(W, a.x, Math.max(a.x, g - b)),
70
- y: x(F, a.y, Math.max(a.y, M - z)),
71
- width: b,
85
+ x: r(H, a.x, Math.max(a.x, d - v)),
86
+ y: r(F, a.y, Math.max(a.y, g - z)),
87
+ width: v,
72
88
  height: z
73
89
  };
74
90
  }
75
- function V(n) {
91
+ function A(t) {
76
92
  const {
77
- rect: i,
78
- minSize: m,
79
- maxSize: s,
80
- viewport: o,
81
- viewportInsets: c,
82
- mobile: e,
83
- mobilePadding: d,
84
- center: r = !1
85
- } = n, t = X(o, c), R = Y(t), S = H(t), y = e ? Math.max(0, t.width - d * 2) : t.width, f = l(m.width, s.width, y), a = l(m.height, s.height, t.height), g = e ? f.max : x(i.width, f.min, f.max), M = x(i.height, a.min, a.max), u = Math.max(t.x, R - g), p = Math.max(t.y, S - M);
93
+ rect: n,
94
+ minSize: s,
95
+ maxSize: m,
96
+ viewport: e,
97
+ viewportInsets: x,
98
+ mobile: i,
99
+ mobilePadding: c,
100
+ center: w = !1
101
+ } = t, h = I(e, x), S = V(h), W = N(h), b = i ? Math.max(0, h.width - c * 2) : h.width, p = f(s.width, m.width, b), a = f(s.height, m.height, h.height), d = i ? p.max : r(n.width, p.min, p.max), g = r(n.height, a.min, a.max), u = Math.max(h.x, S - d), B = Math.max(h.y, W - g);
86
102
  return {
87
- x: e ? x(t.x + d, t.x, u) : r ? Math.max(t.x, Math.round(t.x + (t.width - g) / 2)) : x(i.x, t.x, u),
88
- y: r ? Math.max(t.y, Math.round(t.y + (t.height - M) / 2)) : x(i.y, t.y, p),
89
- width: g,
90
- height: M
103
+ x: i ? r(h.x + c, h.x, u) : w ? Math.max(h.x, Math.round(h.x + (h.width - d) / 2)) : r(n.x, h.x, u),
104
+ y: w ? Math.max(h.y, Math.round(h.y + (h.height - g) / 2)) : r(n.y, h.y, B),
105
+ width: d,
106
+ height: g
91
107
  };
92
108
  }
93
109
  export {
94
- V as normalizeFloatingWindowRect,
95
- I as resolveFloatingWindowRect,
96
- X as resolveFloatingWindowViewport
110
+ A as normalizeFloatingWindowRect,
111
+ T as resolveFloatingWindowRect,
112
+ I as resolveFloatingWindowViewport
97
113
  };