@floegence/floe-webapp-core 0.35.13 → 0.35.15

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.
@@ -1,149 +1,142 @@
1
- import { createSignal as x, createEffect as q, onCleanup as Y } from "solid-js";
2
- import { lockBodyStyle as V } from "../utils/bodyStyleLock.js";
3
- import { useFileBrowserDrag as X } from "../context/FileBrowserDragContext.js";
4
- const W = 5, j = 500, z = 10, i = 48, b = 24;
5
- function $(n) {
6
- const e = X(), [f, T] = x(!1);
7
- let c = null, D = 0, P = 0, u = 0, g = 0, d = null, l = null, s = null, m = null, h = !1, p = "mouse", I = null;
8
- const L = () => (n.enabled?.() ?? !0) && !!e, _ = () => {
9
- m !== null && (clearTimeout(m), m = null);
10
- }, R = (t) => {
11
- if (!t) {
12
- l?.(), l = null;
13
- return;
14
- }
15
- l?.(), l = V({ cursor: "grabbing", "user-select": "none" });
16
- }, v = () => {
17
- s !== null && (cancelAnimationFrame(s), s = null), _(), c = null, d = null, h = !1, I = null, R(!1), T(!1);
18
- }, w = () => {
1
+ import { createSignal as x, createEffect as q, onCleanup as G } from "solid-js";
2
+ import { useFileBrowserDrag as y } from "../context/FileBrowserDragContext.js";
3
+ const Y = 5, k = 500, V = 10, i = 48, C = 24;
4
+ function J(n) {
5
+ const e = y(), [m, T] = x(!1);
6
+ let l = null, h = 0, P = 0, g = 0, u = 0, d = null, s = null, c = null, p = !1, f = "mouse", D = null;
7
+ const _ = () => (n.enabled?.() ?? !0) && !!e, I = () => {
8
+ c !== null && (clearTimeout(c), c = null);
9
+ }, L = () => {
10
+ s !== null && (cancelAnimationFrame(s), s = null), I(), l = null, d = null, p = !1, D = null, T(!1);
11
+ }, X = () => {
19
12
  if (!e) return;
20
13
  const t = e.getInstances();
21
14
  for (const [, a] of t) {
22
15
  const o = a.getScrollContainer();
23
- o && M(o, u, g);
16
+ o && R(o, g, u);
24
17
  const r = a.getSidebarScrollContainer();
25
- r && M(r, u, g);
18
+ r && R(r, g, u);
26
19
  }
27
- }, M = (t, a, o) => {
28
- const r = I?.get(t) ?? t.getBoundingClientRect();
29
- if (I?.set(t, r), a < r.left || a > r.right || o < r.top || o > r.bottom)
20
+ }, R = (t, a, o) => {
21
+ const r = D?.get(t) ?? t.getBoundingClientRect();
22
+ if (D?.set(t, r), a < r.left || a > r.right || o < r.top || o > r.bottom)
30
23
  return;
31
- const O = o - r.top, y = r.bottom - o, A = a - r.left, B = r.right - a;
32
- let E = 0, C = 0;
33
- if (O < i ? E = -Math.ceil((i - O) / i * b) : y < i && (E = Math.ceil((i - y) / i * b)), A < i ? C = -Math.ceil((i - A) / i * b) : B < i && (C = Math.ceil((i - B) / i * b)), E !== 0) {
34
- const S = Math.max(0, Math.min(t.scrollTop + E, t.scrollHeight - t.clientHeight));
24
+ const M = o - r.top, H = r.bottom - o, O = a - r.left, A = r.right - a;
25
+ let v = 0, E = 0;
26
+ if (M < i ? v = -Math.ceil((i - M) / i * C) : H < i && (v = Math.ceil((i - H) / i * C)), O < i ? E = -Math.ceil((i - O) / i * C) : A < i && (E = Math.ceil((i - A) / i * C)), v !== 0) {
27
+ const S = Math.max(0, Math.min(t.scrollTop + v, t.scrollHeight - t.clientHeight));
35
28
  S !== t.scrollTop && (t.scrollTop = S);
36
29
  }
37
- if (C !== 0) {
38
- const S = Math.max(0, Math.min(t.scrollLeft + C, t.scrollWidth - t.clientWidth));
30
+ if (E !== 0) {
31
+ const S = Math.max(0, Math.min(t.scrollLeft + E, t.scrollWidth - t.clientWidth));
39
32
  S !== t.scrollLeft && (t.scrollLeft = S);
40
33
  }
41
- }, F = () => {
34
+ }, w = () => {
42
35
  if (s !== null) return;
43
36
  const t = () => {
44
- if (c === null || !f()) {
37
+ if (l === null || !m()) {
45
38
  s = null;
46
39
  return;
47
40
  }
48
- w(), s = requestAnimationFrame(t);
41
+ X(), s = requestAnimationFrame(t);
49
42
  };
50
43
  s = requestAnimationFrame(t);
51
- }, H = () => {
44
+ }, b = () => {
52
45
  if (!e || !d) return;
53
- I = /* @__PURE__ */ new Map(), n.isSelected(d.id) || n.selectItem(d.id, !1);
46
+ D = /* @__PURE__ */ new Map(), n.isSelected(d.id) || n.selectItem(d.id, !1);
54
47
  const t = n.getSelectedItems(), o = (t.length > 0 && n.isSelected(d.id) ? t : [d]).map((r) => ({
55
48
  item: r,
56
49
  sourceInstanceId: n.instanceId,
57
50
  sourcePath: n.currentPath()
58
51
  }));
59
- R(!0), T(!0), e.startDrag(o, u, g), n.onDragStart?.(), F();
60
- }, U = (t, a) => {
61
- L() && c === null && (t.pointerType === "mouse" && t.button !== 0 || (c = t.pointerId, p = t.pointerType, D = t.clientX, P = t.clientY, u = D, g = P, d = a, h = !1, t.currentTarget.setPointerCapture(t.pointerId), (p === "touch" || p === "pen") && (_(), m = setTimeout(() => {
62
- if (c !== null && d) {
63
- if (h = !0, "vibrate" in navigator)
52
+ T(!0), e.startDrag(o, g, u), n.onDragStart?.(), w();
53
+ }, B = (t, a) => {
54
+ _() && l === null && (t.pointerType === "mouse" && t.button !== 0 || (l = t.pointerId, f = t.pointerType, h = t.clientX, P = t.clientY, g = h, u = P, d = a, p = !1, t.currentTarget.setPointerCapture(t.pointerId), (f === "touch" || f === "pen") && (I(), c = setTimeout(() => {
55
+ if (l !== null && d) {
56
+ if (p = !0, "vibrate" in navigator)
64
57
  try {
65
58
  navigator.vibrate(50);
66
59
  } catch {
67
60
  }
68
- H();
61
+ b();
69
62
  }
70
- }, j))));
71
- }, k = (t) => {
72
- if (c !== t.pointerId) return;
73
- u = t.clientX, g = t.clientY;
74
- const a = u - D, o = g - P, r = Math.sqrt(a * a + o * o);
75
- if ((p === "touch" || p === "pen") && !h && r > z) {
76
- _(), v();
63
+ }, k))));
64
+ }, F = (t) => {
65
+ if (l !== t.pointerId) return;
66
+ g = t.clientX, u = t.clientY;
67
+ const a = g - h, o = u - P, r = Math.sqrt(a * a + o * o);
68
+ if ((f === "touch" || f === "pen") && !p && r > V) {
69
+ I(), L();
77
70
  return;
78
71
  }
79
- p === "mouse" && !f() && r > W && H(), f() && e && e.updateDrag(u, g);
80
- }, G = (t) => {
81
- if (c === t.pointerId) {
72
+ f === "mouse" && !m() && r > Y && b(), m() && e && e.updateDrag(g, u);
73
+ }, U = (t) => {
74
+ if (l === t.pointerId) {
82
75
  try {
83
76
  t.currentTarget?.releasePointerCapture(t.pointerId);
84
77
  } catch {
85
78
  }
86
- f() && e && e.endDrag(!0), v();
79
+ m() && e && e.endDrag(!0), L();
87
80
  }
88
81
  }, N = (t) => {
89
- c === t.pointerId && (f() && e && e.endDrag(!1), v());
82
+ l === t.pointerId && (m() && e && e.endDrag(!1), L());
90
83
  };
91
84
  return q(() => {
92
- if (!L() || typeof document > "u") return;
93
- const t = (r) => k(r), a = (r) => G(r), o = (r) => N(r);
94
- document.addEventListener("pointermove", t, !0), document.addEventListener("pointerup", a, !0), document.addEventListener("pointercancel", o, !0), Y(() => {
95
- v(), document.removeEventListener("pointermove", t, !0), document.removeEventListener("pointerup", a, !0), document.removeEventListener("pointercancel", o, !0);
85
+ if (!_() || typeof document > "u") return;
86
+ const t = (r) => F(r), a = (r) => U(r), o = (r) => N(r);
87
+ document.addEventListener("pointermove", t, !0), document.addEventListener("pointerup", a, !0), document.addEventListener("pointercancel", o, !0), G(() => {
88
+ L(), document.removeEventListener("pointermove", t, !0), document.removeEventListener("pointerup", a, !0), document.removeEventListener("pointercancel", o, !0);
96
89
  });
97
90
  }), {
98
- isDragging: f,
91
+ isDragging: m,
99
92
  getDragHandlers: (t) => ({
100
- onPointerDown: (a) => U(a, t),
93
+ onPointerDown: (a) => B(a, t),
101
94
  "data-draggable": "true"
102
95
  })
103
96
  };
104
97
  }
105
- function tt(n) {
106
- const e = X(), [f, T] = x(!1), c = () => (n.enabled?.() ?? !0) && !!e, D = () => f() ? e?.dragState()?.isDragging ?? !1 : !1, P = () => {
107
- if (!D() || !e) return !1;
108
- const l = e.dragState();
109
- return l.isDragging ? e.canDropOn(
110
- l.draggedItems,
98
+ function K(n) {
99
+ const e = y(), [m, T] = x(!1), l = () => (n.enabled?.() ?? !0) && !!e, h = () => m() ? e?.dragState()?.isDragging ?? !1 : !1, P = () => {
100
+ if (!h() || !e) return !1;
101
+ const s = e.dragState();
102
+ return s.isDragging ? e.canDropOn(
103
+ s.draggedItems,
111
104
  n.targetPath(),
112
105
  n.targetItem(),
113
106
  n.instanceId
114
107
  ) : !1;
115
- }, u = (l) => {
116
- if (!c() || !e) return;
117
- const s = e.dragState();
118
- if (!s.isDragging) return;
108
+ }, g = (s) => {
109
+ if (!l() || !e) return;
110
+ const c = e.dragState();
111
+ if (!c.isDragging) return;
119
112
  T(!0);
120
- const m = n.targetPath(), h = n.targetItem(), p = e.canDropOn(s.draggedItems, m, h, n.instanceId), L = l.currentTarget?.getBoundingClientRect() ?? null;
113
+ const p = n.targetPath(), f = n.targetItem(), D = e.canDropOn(c.draggedItems, p, f, n.instanceId), I = s.currentTarget?.getBoundingClientRect() ?? null;
121
114
  e.setDropTarget(
122
115
  {
123
116
  instanceId: n.instanceId,
124
- targetPath: m,
125
- targetItem: h
117
+ targetPath: p,
118
+ targetItem: f
126
119
  },
127
- p,
128
- L
120
+ D,
121
+ I
129
122
  );
130
- }, g = (l) => {
123
+ }, u = (s) => {
131
124
  if (!e) return;
132
125
  T(!1);
133
- const s = e.dragState();
134
- s.isDragging && s.dropTarget?.instanceId === n.instanceId && s.dropTarget.targetPath === n.targetPath() && e.setDropTarget(null, !1);
126
+ const c = e.dragState();
127
+ c.isDragging && c.dropTarget?.instanceId === n.instanceId && c.dropTarget.targetPath === n.targetPath() && e.setDropTarget(null, !1);
135
128
  };
136
129
  return {
137
- isDropTarget: D,
130
+ isDropTarget: h,
138
131
  isValidDrop: P,
139
132
  getDropTargetProps: () => ({
140
- onPointerEnter: u,
141
- onPointerLeave: g,
133
+ onPointerEnter: g,
134
+ onPointerLeave: u,
142
135
  "data-drop-target": "true"
143
136
  })
144
137
  };
145
138
  }
146
139
  export {
147
- tt as useFileBrowserDropTarget,
148
- $ as useFileBrowserItemDrag
140
+ K as useFileBrowserDropTarget,
141
+ J as useFileBrowserItemDrag
149
142
  };