@floegence/floe-webapp-core 0.26.2 → 0.26.5
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.
- package/dist/components/chat/input/ChatInput.js +59 -46
- package/dist/components/deck/WidgetResizeHandle.js +49 -49
- package/dist/components/file-browser/FileBrowser.js +41 -40
- package/dist/components/file-browser/FileBrowserToolbar.js +27 -26
- package/dist/components/file-browser/FileGridView.js +158 -142
- package/dist/components/launchpad/LaunchpadModal.js +53 -85
- package/dist/components/ui/CommandPalette.js +108 -94
- package/dist/components/ui/Dialog.js +53 -76
- package/dist/components/ui/Tabs.js +156 -116
- package/dist/hooks/useDeckDrag.js +36 -36
- package/dist/hooks/useFileBrowserDrag.js +50 -50
- package/dist/hooks/useOverlayMask.d.ts +26 -0
- package/dist/hooks/useOverlayMask.js +85 -0
- package/dist/styles.css +1 -1
- package/dist/utils/focus.d.ts +2 -0
- package/dist/utils/focus.js +25 -0
- package/package.json +1 -1
|
@@ -1,219 +1,259 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
import { splitProps as
|
|
1
|
+
import { createComponent as u, spread as Z, mergeProps as ee, insert as c, effect as g, className as p, setStyleProperty as G, memo as J, use as K, setAttribute as C, template as h, delegateEvents as we } from "solid-js/web";
|
|
2
|
+
import { splitProps as te, Show as m, createSignal as b, untrack as Q, createEffect as z, For as xe, onCleanup as Y } from "solid-js";
|
|
3
3
|
import { cn as v } from "../../utils/cn.js";
|
|
4
|
-
import { deferAfterPaint as
|
|
5
|
-
import { useViewActivation as
|
|
6
|
-
import { X as
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
var t =
|
|
10
|
-
return
|
|
4
|
+
import { deferAfterPaint as $ } from "../../utils/defer.js";
|
|
5
|
+
import { useViewActivation as ye } from "../../context/ViewActivationContext.js";
|
|
6
|
+
import { X as ke, Plus as $e, ChevronRight as Ce } from "../icons/index.js";
|
|
7
|
+
var Se = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="m15 18-6-6 6-6">'), Ae = /* @__PURE__ */ h('<button type=button aria-label="Scroll left">'), Ie = /* @__PURE__ */ h('<div class="pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 bg-primary transition-[transform,width] duration-200 ease-out will-change-transform motion-reduce:transition-none">'), ze = /* @__PURE__ */ h('<button type=button aria-label="Add new tab">'), Re = /* @__PURE__ */ h('<button type=button aria-label="Scroll right">'), Le = /* @__PURE__ */ h("<div><div>"), _e = /* @__PURE__ */ h("<span class=flex-shrink-0>"), Ue = /* @__PURE__ */ h("<button type=button>"), Ee = /* @__PURE__ */ h('<div role=tab><span class="truncate max-w-32">'), Pe = /* @__PURE__ */ h("<div role=tabpanel>");
|
|
8
|
+
const Oe = (w) => (() => {
|
|
9
|
+
var t = Se();
|
|
10
|
+
return g(() => C(t, "class", w.class)), t;
|
|
11
11
|
})();
|
|
12
|
-
function
|
|
13
|
-
const [t,
|
|
14
|
-
let
|
|
15
|
-
const
|
|
12
|
+
function Xe(w) {
|
|
13
|
+
const [t, R] = te(w, ["items", "activeId", "defaultActiveId", "onChange", "onActiveIdChange", "onClose", "onAdd", "showAdd", "closable", "size", "variant", "class"]);
|
|
14
|
+
let d;
|
|
15
|
+
const j = (() => {
|
|
16
16
|
try {
|
|
17
|
-
return
|
|
17
|
+
return ye();
|
|
18
18
|
} catch {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
})(),
|
|
22
|
-
let
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
})(), x = () => j ? j.active() : !0;
|
|
22
|
+
let L = !1;
|
|
23
|
+
const [re, ne] = b(0), [oe, le] = b(0), [B, _] = b(!1), U = /* @__PURE__ */ new Map();
|
|
24
|
+
let E = !1;
|
|
25
|
+
const S = () => (t.variant ?? "default") === "underline", M = (r) => {
|
|
26
|
+
if (!d || !S()) return !1;
|
|
27
|
+
const o = U.get(r);
|
|
28
|
+
if (!o) return !1;
|
|
29
|
+
const s = d.getBoundingClientRect(), e = o.getBoundingClientRect(), n = e.left - s.left + d.scrollLeft, a = e.width;
|
|
30
|
+
return ne(n), le(a), _(a > 0), a > 0;
|
|
31
|
+
}, se = () => {
|
|
32
|
+
if (!S()) {
|
|
33
|
+
_(!1);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
M(P()) || _(!1);
|
|
37
|
+
}, A = () => {
|
|
38
|
+
E || (E = !0, $(() => {
|
|
39
|
+
E = !1, Q(() => {
|
|
40
|
+
x() && se();
|
|
41
|
+
});
|
|
42
|
+
}));
|
|
43
|
+
}, T = () => t.activeId !== void 0, ie = () => t.onChange ?? t.onActiveIdChange, [de, ae] = b(Q(() => t.defaultActiveId ?? t.items[0]?.id ?? "")), V = () => T() ? t.activeId : de(), [P, W] = b(V());
|
|
44
|
+
z(() => {
|
|
45
|
+
W(V());
|
|
46
|
+
}), z(() => {
|
|
47
|
+
x() && (t.variant, P(), A());
|
|
26
48
|
});
|
|
27
|
-
const [
|
|
28
|
-
if (!
|
|
49
|
+
const [X, ce] = b(!1), [F, ue] = b(!1), [H, fe] = b(!1), ve = () => {
|
|
50
|
+
if (!d) return;
|
|
29
51
|
const {
|
|
30
52
|
scrollLeft: r,
|
|
31
|
-
scrollWidth:
|
|
32
|
-
clientWidth:
|
|
33
|
-
} =
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
scrollWidth: o,
|
|
54
|
+
clientWidth: s
|
|
55
|
+
} = d, e = o > s;
|
|
56
|
+
fe(e), ce(r > 0), ue(r + s < o - 1);
|
|
57
|
+
}, I = () => {
|
|
58
|
+
L || (L = !0, $(() => {
|
|
59
|
+
L = !1, x() && ve();
|
|
38
60
|
}));
|
|
39
|
-
},
|
|
40
|
-
|
|
61
|
+
}, he = () => {
|
|
62
|
+
d && d.scrollBy({
|
|
41
63
|
left: -150,
|
|
42
64
|
behavior: "smooth"
|
|
43
65
|
});
|
|
44
|
-
},
|
|
45
|
-
|
|
66
|
+
}, be = () => {
|
|
67
|
+
d && d.scrollBy({
|
|
46
68
|
left: 150,
|
|
47
69
|
behavior: "smooth"
|
|
48
70
|
});
|
|
49
71
|
};
|
|
50
|
-
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
const r = () =>
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
z(() => {
|
|
73
|
+
if (!d || !x()) return;
|
|
74
|
+
I(), A();
|
|
75
|
+
const r = () => I();
|
|
76
|
+
d.addEventListener("scroll", r);
|
|
77
|
+
const o = () => {
|
|
78
|
+
I(), A();
|
|
79
|
+
};
|
|
80
|
+
let s;
|
|
81
|
+
typeof ResizeObserver < "u" ? (s = new ResizeObserver(o), s.observe(d)) : typeof window < "u" && window.addEventListener("resize", o), Y(() => {
|
|
82
|
+
d?.removeEventListener("scroll", r), s?.disconnect(), typeof window < "u" && window.removeEventListener("resize", o);
|
|
59
83
|
});
|
|
60
|
-
}),
|
|
61
|
-
|
|
84
|
+
}), z(() => {
|
|
85
|
+
x() && (t.items.length, I(), A());
|
|
62
86
|
});
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
87
|
+
const D = (r, o) => {
|
|
88
|
+
if (o) return;
|
|
89
|
+
const s = ie();
|
|
90
|
+
if (W(r), S() && M(r), T() || ae(r), s) {
|
|
67
91
|
const e = r;
|
|
68
|
-
|
|
92
|
+
$(() => s(e));
|
|
69
93
|
}
|
|
70
|
-
},
|
|
94
|
+
}, ge = (r, o) => {
|
|
71
95
|
r.stopPropagation();
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
const e =
|
|
75
|
-
|
|
76
|
-
},
|
|
96
|
+
const s = t.onClose;
|
|
97
|
+
if (!s) return;
|
|
98
|
+
const e = o;
|
|
99
|
+
$(() => s(e));
|
|
100
|
+
}, O = {
|
|
77
101
|
sm: "h-7 px-2 text-[11px]",
|
|
78
102
|
md: "h-8 px-3 text-xs"
|
|
79
|
-
},
|
|
80
|
-
const
|
|
103
|
+
}, me = (r, o) => {
|
|
104
|
+
const s = "inline-flex items-center gap-1.5 font-medium transition-colors duration-150 whitespace-nowrap", e = o ? "cursor-not-allowed opacity-50" : "cursor-pointer";
|
|
81
105
|
return {
|
|
82
|
-
default: v(
|
|
83
|
-
card: v(
|
|
84
|
-
underline: v(
|
|
106
|
+
default: v(s, e, O[t.size ?? "md"], "rounded-t border-b-2", r ? "border-primary text-foreground bg-background" : "border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/50", o && "hover:bg-transparent hover:text-muted-foreground"),
|
|
107
|
+
card: v(s, e, O[t.size ?? "md"], "rounded-t border border-b-0", r ? "border-border bg-background text-foreground -mb-px z-10" : "border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/50", o && "hover:bg-transparent hover:text-muted-foreground"),
|
|
108
|
+
underline: v(s, e, O[t.size ?? "md"], "border-b-2 -mb-px", r ? B() ? "border-transparent text-foreground" : "border-primary text-foreground" : "border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/50", o && "hover:border-transparent hover:text-muted-foreground")
|
|
85
109
|
}[t.variant ?? "default"];
|
|
86
|
-
},
|
|
110
|
+
}, pe = {
|
|
87
111
|
default: "border-b border-border",
|
|
88
112
|
card: "border-b border-border",
|
|
89
113
|
underline: "border-b border-border"
|
|
90
114
|
};
|
|
91
115
|
return (() => {
|
|
92
|
-
var r =
|
|
93
|
-
|
|
116
|
+
var r = Le(), o = r.firstChild;
|
|
117
|
+
Z(r, ee({
|
|
94
118
|
get class() {
|
|
95
|
-
return v("relative flex items-center gap-0.5",
|
|
119
|
+
return v("relative flex items-center gap-0.5", pe[t.variant ?? "default"], t.class);
|
|
96
120
|
}
|
|
97
|
-
},
|
|
121
|
+
}, R), !1, !0), c(r, u(m, {
|
|
98
122
|
get when() {
|
|
99
|
-
return
|
|
123
|
+
return H();
|
|
100
124
|
},
|
|
101
125
|
get children() {
|
|
102
|
-
var e =
|
|
103
|
-
return e.$$click =
|
|
126
|
+
var e = Ae();
|
|
127
|
+
return e.$$click = he, c(e, u(Oe, {
|
|
104
128
|
class: "w-4 h-4"
|
|
105
|
-
})),
|
|
106
|
-
var
|
|
107
|
-
return
|
|
129
|
+
})), g((n) => {
|
|
130
|
+
var a = !X(), i = v("flex-shrink-0 flex items-center justify-center", "w-6 h-6 rounded cursor-pointer", "transition-all duration-150", X() ? "text-muted-foreground hover:text-foreground hover:bg-muted/80 opacity-100" : "opacity-0 pointer-events-none");
|
|
131
|
+
return a !== n.e && (e.disabled = n.e = a), i !== n.t && p(e, n.t = i), n;
|
|
132
|
+
}, {
|
|
133
|
+
e: void 0,
|
|
134
|
+
t: void 0
|
|
135
|
+
}), e;
|
|
136
|
+
}
|
|
137
|
+
}), o);
|
|
138
|
+
var s = d;
|
|
139
|
+
return typeof s == "function" ? K(s, o) : d = o, c(o, u(m, {
|
|
140
|
+
get when() {
|
|
141
|
+
return J(() => !!S())() && B();
|
|
142
|
+
},
|
|
143
|
+
get children() {
|
|
144
|
+
var e = Ie();
|
|
145
|
+
return g((n) => {
|
|
146
|
+
var a = `translate3d(${re()}px, 0, 0)`, i = `${oe()}px`;
|
|
147
|
+
return a !== n.e && G(e, "transform", n.e = a), i !== n.t && G(e, "width", n.t = i), n;
|
|
108
148
|
}, {
|
|
109
149
|
e: void 0,
|
|
110
150
|
t: void 0
|
|
111
151
|
}), e;
|
|
112
152
|
}
|
|
113
|
-
}),
|
|
114
|
-
var l = i;
|
|
115
|
-
return typeof l == "function" ? oe(l, n) : i = n, a(n, c(se, {
|
|
153
|
+
}), null), c(o, u(xe, {
|
|
116
154
|
get each() {
|
|
117
155
|
return t.items;
|
|
118
156
|
},
|
|
119
157
|
children: (e) => {
|
|
120
|
-
const
|
|
158
|
+
const n = () => e.id === P(), a = () => e.closable ?? t.closable ?? !1;
|
|
121
159
|
return (() => {
|
|
122
|
-
var
|
|
123
|
-
return
|
|
124
|
-
(
|
|
125
|
-
},
|
|
160
|
+
var i = Ee(), N = i.firstChild;
|
|
161
|
+
return i.$$keydown = (l) => {
|
|
162
|
+
(l.key === "Enter" || l.key === " ") && (l.preventDefault(), D(e.id, e.disabled));
|
|
163
|
+
}, i.$$click = () => D(e.id, e.disabled), K((l) => {
|
|
164
|
+
U.set(e.id, l), Y(() => U.delete(e.id));
|
|
165
|
+
}, i), c(i, u(m, {
|
|
126
166
|
get when() {
|
|
127
167
|
return e.icon;
|
|
128
168
|
},
|
|
129
169
|
get children() {
|
|
130
|
-
var
|
|
131
|
-
return
|
|
170
|
+
var l = _e();
|
|
171
|
+
return c(l, () => e.icon), l;
|
|
132
172
|
}
|
|
133
|
-
}),
|
|
173
|
+
}), N), c(N, () => e.label), c(i, u(m, {
|
|
134
174
|
get when() {
|
|
135
|
-
return
|
|
175
|
+
return J(() => !!a())() && !e.disabled;
|
|
136
176
|
},
|
|
137
177
|
get children() {
|
|
138
|
-
var
|
|
139
|
-
return
|
|
178
|
+
var l = Ue();
|
|
179
|
+
return l.$$click = (f) => ge(f, e.id), c(l, u(ke, {
|
|
140
180
|
class: "w-3 h-3"
|
|
141
|
-
})),
|
|
142
|
-
var
|
|
143
|
-
return
|
|
181
|
+
})), g((f) => {
|
|
182
|
+
var y = v("flex-shrink-0 flex items-center justify-center", "w-5 h-5 rounded cursor-pointer", "bg-transparent text-muted-foreground", "hover:bg-red-500 hover:text-white", "transition-colors duration-150", "ml-1.5"), k = `Close ${e.label}`;
|
|
183
|
+
return y !== f.e && p(l, f.e = y), k !== f.t && C(l, "aria-label", f.t = k), f;
|
|
144
184
|
}, {
|
|
145
185
|
e: void 0,
|
|
146
186
|
t: void 0
|
|
147
|
-
}),
|
|
187
|
+
}), l;
|
|
148
188
|
}
|
|
149
|
-
}), null),
|
|
150
|
-
var
|
|
151
|
-
return
|
|
189
|
+
}), null), g((l) => {
|
|
190
|
+
var f = me(n(), e.disabled), y = n(), k = e.disabled, q = e.disabled ? -1 : 0;
|
|
191
|
+
return f !== l.e && p(i, l.e = f), y !== l.t && C(i, "aria-selected", l.t = y), k !== l.a && C(i, "aria-disabled", l.a = k), q !== l.o && C(i, "tabindex", l.o = q), l;
|
|
152
192
|
}, {
|
|
153
193
|
e: void 0,
|
|
154
194
|
t: void 0,
|
|
155
195
|
a: void 0,
|
|
156
196
|
o: void 0
|
|
157
|
-
}),
|
|
197
|
+
}), i;
|
|
158
198
|
})();
|
|
159
199
|
}
|
|
160
|
-
})),
|
|
200
|
+
}), null), c(r, u(m, {
|
|
161
201
|
get when() {
|
|
162
202
|
return t.showAdd;
|
|
163
203
|
},
|
|
164
204
|
get children() {
|
|
165
|
-
var e =
|
|
205
|
+
var e = ze();
|
|
166
206
|
return e.$$click = () => {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
},
|
|
207
|
+
const n = t.onAdd;
|
|
208
|
+
n && $(() => n());
|
|
209
|
+
}, c(e, u($e, {
|
|
170
210
|
get class() {
|
|
171
211
|
return t.size === "sm" ? "w-3.5 h-3.5" : "w-4 h-4";
|
|
172
212
|
}
|
|
173
|
-
})),
|
|
213
|
+
})), g(() => p(e, v("flex-shrink-0 flex items-center justify-center", "rounded hover:bg-muted/80 cursor-pointer", "text-muted-foreground hover:text-foreground", "transition-colors duration-150", t.size === "sm" ? "w-6 h-6" : "w-7 h-7"))), e;
|
|
174
214
|
}
|
|
175
|
-
}), null),
|
|
215
|
+
}), null), c(r, u(m, {
|
|
176
216
|
get when() {
|
|
177
|
-
return
|
|
217
|
+
return H();
|
|
178
218
|
},
|
|
179
219
|
get children() {
|
|
180
|
-
var e =
|
|
181
|
-
return e.$$click =
|
|
220
|
+
var e = Re();
|
|
221
|
+
return e.$$click = be, c(e, u(Ce, {
|
|
182
222
|
class: "w-4 h-4"
|
|
183
|
-
})),
|
|
184
|
-
var
|
|
185
|
-
return
|
|
223
|
+
})), g((n) => {
|
|
224
|
+
var a = !F(), i = v("flex-shrink-0 flex items-center justify-center", "w-6 h-6 rounded cursor-pointer", "transition-all duration-150", F() ? "text-muted-foreground hover:text-foreground hover:bg-muted/80 opacity-100" : "opacity-0 pointer-events-none");
|
|
225
|
+
return a !== n.e && (e.disabled = n.e = a), i !== n.t && p(e, n.t = i), n;
|
|
186
226
|
}, {
|
|
187
227
|
e: void 0,
|
|
188
228
|
t: void 0
|
|
189
229
|
}), e;
|
|
190
230
|
}
|
|
191
|
-
}), null),
|
|
192
|
-
"flex-1 flex items-end gap-0.5 overflow-x-auto",
|
|
231
|
+
}), null), g(() => p(o, v(
|
|
232
|
+
"relative flex-1 flex items-end gap-0.5 overflow-x-auto",
|
|
193
233
|
"scrollbar-none",
|
|
194
234
|
// Hide scrollbar for all browsers
|
|
195
235
|
"[&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]"
|
|
196
236
|
))), r;
|
|
197
237
|
})();
|
|
198
238
|
}
|
|
199
|
-
function
|
|
200
|
-
const [t,
|
|
201
|
-
return
|
|
239
|
+
function Fe(w) {
|
|
240
|
+
const [t, R] = te(w, ["active", "keepMounted", "class", "children"]);
|
|
241
|
+
return u(m, {
|
|
202
242
|
get when() {
|
|
203
243
|
return t.keepMounted || t.active;
|
|
204
244
|
},
|
|
205
245
|
get children() {
|
|
206
|
-
var
|
|
207
|
-
return
|
|
246
|
+
var d = Pe();
|
|
247
|
+
return Z(d, ee({
|
|
208
248
|
get class() {
|
|
209
249
|
return v(!t.active && t.keepMounted && "hidden", t.class);
|
|
210
250
|
}
|
|
211
|
-
},
|
|
251
|
+
}, R), !1, !0), c(d, () => t.children), d;
|
|
212
252
|
}
|
|
213
253
|
});
|
|
214
254
|
}
|
|
215
|
-
|
|
255
|
+
we(["click", "keydown"]);
|
|
216
256
|
export {
|
|
217
|
-
|
|
218
|
-
|
|
257
|
+
Fe as TabPanel,
|
|
258
|
+
Xe as Tabs
|
|
219
259
|
};
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { createEffect as
|
|
1
|
+
import { createEffect as q, onCleanup as G } from "solid-js";
|
|
2
2
|
import { useDeck as z } from "../context/DeckContext.js";
|
|
3
|
-
import { applyDragDelta as
|
|
4
|
-
import { getGridConfigFromElement as
|
|
5
|
-
import { lockBodyStyle as
|
|
6
|
-
function
|
|
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";
|
|
6
|
+
function Z() {
|
|
7
7
|
const p = z();
|
|
8
|
-
let c = null, m = 0, f = 0, L = 0, g = 0,
|
|
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
9
|
const M = (t) => {
|
|
10
10
|
if (!t) {
|
|
11
11
|
y?.(), y = null;
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
y?.(), y =
|
|
15
|
-
},
|
|
16
|
-
c !== null && (a !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(a), a = null), c = null, v = null, T = null, n = null, w = null, M(!1), p.endDrag(!0));
|
|
17
|
-
},
|
|
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));
|
|
17
|
+
}, Y = () => {
|
|
18
18
|
if (!n) return;
|
|
19
|
-
const t = n.getBoundingClientRect(), e = 48, d = 24, s =
|
|
19
|
+
const t = b ?? n.getBoundingClientRect(), e = 48, d = 24, s = i - t.top, o = t.bottom - i;
|
|
20
20
|
let r = 0;
|
|
21
21
|
if (s < e ? r = -Math.ceil((e - s) / e * d) : o < e && (r = Math.ceil((e - o) / e * d)), r === 0) return;
|
|
22
|
-
const
|
|
23
|
-
h !==
|
|
24
|
-
},
|
|
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 = () => {
|
|
25
25
|
if (a !== null || typeof requestAnimationFrame > "u") return;
|
|
26
26
|
const t = () => {
|
|
27
27
|
if (c === null) {
|
|
28
28
|
a = null;
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
X(), a = requestAnimationFrame(t);
|
|
32
32
|
};
|
|
33
33
|
a = requestAnimationFrame(t);
|
|
34
|
-
},
|
|
34
|
+
}, S = (t) => {
|
|
35
35
|
const e = t.target;
|
|
36
36
|
if (e.closest('button, input, select, textarea, [role="button"], a') || e.closest("[data-widget-resize-handle]")) return;
|
|
37
37
|
const o = e.closest("[data-widget-drag-handle]");
|
|
38
38
|
if (!o || t.pointerType === "mouse" && t.button !== 0) return;
|
|
39
39
|
const r = o.dataset.widgetDragHandle;
|
|
40
40
|
if (!r) return;
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
43
|
-
t.preventDefault(), t.stopPropagation(), c = t.pointerId, m = t.clientX, f = t.clientY, g = m,
|
|
44
|
-
const u = p.activeLayout()?.widgets.find((
|
|
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
45
|
w = u ? { ...u.position } : null;
|
|
46
|
-
const E = window.getComputedStyle(
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
c !== t.pointerId || !v || (g = t.clientX,
|
|
50
|
-
},
|
|
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();
|
|
48
|
+
}, x = (t) => {
|
|
49
|
+
c !== t.pointerId || !v || (g = t.clientX, i = t.clientY, typeof requestAnimationFrame > "u" && X());
|
|
50
|
+
}, X = () => {
|
|
51
51
|
if (!v || !n || !w) return;
|
|
52
|
-
|
|
52
|
+
Y();
|
|
53
53
|
const t = n.scrollTop;
|
|
54
|
-
if (g === P &&
|
|
55
|
-
P = g, A =
|
|
56
|
-
const e = g - m, d =
|
|
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;
|
|
57
57
|
if (!Number.isFinite(u) || u <= 0) return;
|
|
58
|
-
const E = o + r,
|
|
59
|
-
p.updateDrag(
|
|
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 });
|
|
60
60
|
}, D = (t) => {
|
|
61
61
|
if (c === t.pointerId) {
|
|
62
62
|
try {
|
|
63
63
|
T?.releasePointerCapture(t.pointerId);
|
|
64
64
|
} catch {
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
H();
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
p.editMode() && (typeof document > "u" || (document.addEventListener("pointerdown",
|
|
71
|
-
|
|
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);
|
|
72
72
|
})));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
export {
|
|
76
|
-
|
|
76
|
+
Z as useDeckDrag
|
|
77
77
|
};
|