@floegence/floe-webapp-core 0.35.32 → 0.35.34
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/file-browser/DirectoryTree.js +84 -86
- package/dist/components/file-browser/FileContextMenu.d.ts +2 -2
- package/dist/components/file-browser/FileContextMenu.js +300 -142
- package/dist/components/file-browser/FileGridView.js +50 -45
- package/dist/components/file-browser/FileIcons.d.ts +10 -2
- package/dist/components/file-browser/FileIcons.js +289 -181
- package/dist/components/file-browser/FileListView.js +99 -94
- package/dist/components/file-browser/contextMenuEvent.d.ts +10 -0
- package/dist/components/file-browser/contextMenuEvent.js +19 -0
- package/dist/components/file-browser/index.d.ts +2 -2
- package/dist/components/file-browser/longPressContextMenu.d.ts +1 -0
- package/dist/components/file-browser/longPressContextMenu.js +45 -32
- package/dist/components/file-browser/types.d.ts +23 -1
- package/dist/components/layout/Shell.d.ts +8 -0
- package/dist/components/layout/Shell.js +157 -138
- package/dist/components/layout/Sidebar.d.ts +2 -0
- package/dist/components/layout/Sidebar.js +39 -38
- package/dist/components/layout/sidebarVisibilityMotion.d.ts +22 -0
- package/dist/components/layout/sidebarVisibilityMotion.js +16 -0
- package/dist/components/ui/Dropdown.d.ts +0 -1
- package/dist/components/ui/Dropdown.js +150 -204
- package/dist/components/ui/menuUtils.d.ts +15 -0
- package/dist/components/ui/menuUtils.js +60 -0
- package/dist/components/ui/picker/PickerBase.js +90 -96
- package/dist/context/LayoutContext.d.ts +5 -0
- package/dist/context/LayoutContext.js +58 -46
- package/dist/file-browser.js +35 -31
- package/dist/full.js +411 -407
- package/package.json +1 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { setAttribute as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { deferNonBlocking as
|
|
5
|
-
import { ChevronDown as
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { setAttribute as m, insert as f, createComponent as l, Portal as U, use as L, effect as D, className as M, setStyleProperty as q, template as E, memo as K, delegateEvents as J } from "solid-js/web";
|
|
2
|
+
import { createSignal as F, createEffect as Q, onCleanup as V, Show as $, Index as z } from "solid-js";
|
|
3
|
+
import { cn as C } from "../../utils/cn.js";
|
|
4
|
+
import { deferNonBlocking as X } from "../../utils/defer.js";
|
|
5
|
+
import { ChevronDown as Y, Check as Z, ChevronRight as ee } from "../icons/index.js";
|
|
6
|
+
import { focusMenuItem as O, MENU_ITEM_SELECTOR as te, moveMenuFocus as N, calculateMenuPosition as ne, calculateSubmenuPosition as re } from "./menuUtils.js";
|
|
7
|
+
var H = /* @__PURE__ */ E("<div role=menu>"), oe = /* @__PURE__ */ E("<div><div role=button aria-haspopup=menu data-floe-dropdown-trigger>"), W = /* @__PURE__ */ E('<div class="my-1 h-px bg-border"role=separator>'), ie = /* @__PURE__ */ E("<div>"), ae = /* @__PURE__ */ E('<button type=button role=menuitem><span class="w-3.5 h-3.5 flex items-center justify-center"></span><span class="flex-1 text-left">'), le = /* @__PURE__ */ E("<div class=relative>"), ue = /* @__PURE__ */ E('<span class="w-3.5 h-3.5 flex items-center justify-center">'), de = /* @__PURE__ */ E("<span>");
|
|
8
8
|
let se = 0, ce = 0;
|
|
9
|
-
function fe(e,
|
|
9
|
+
function fe(e, s) {
|
|
10
10
|
switch (e) {
|
|
11
11
|
case "Enter":
|
|
12
12
|
case " ":
|
|
13
|
-
return
|
|
13
|
+
return s.open ? {
|
|
14
14
|
nextOpen: !1
|
|
15
15
|
} : {
|
|
16
16
|
nextOpen: !0,
|
|
17
|
-
focusMode:
|
|
17
|
+
focusMode: s.hasSelection ? "selected" : "first"
|
|
18
18
|
};
|
|
19
19
|
case "ArrowDown":
|
|
20
20
|
return {
|
|
21
21
|
nextOpen: !0,
|
|
22
|
-
focusMode:
|
|
22
|
+
focusMode: s.hasSelection ? "selected" : "first"
|
|
23
23
|
};
|
|
24
24
|
case "ArrowUp":
|
|
25
25
|
return {
|
|
@@ -30,182 +30,129 @@ function fe(e, r) {
|
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function me(e
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
function ve(e, r, i) {
|
|
37
|
-
const o = window.innerWidth, f = window.innerHeight;
|
|
38
|
-
let a;
|
|
39
|
-
switch (i) {
|
|
40
|
-
case "center":
|
|
41
|
-
a = e.left + e.width / 2 - r.width / 2;
|
|
42
|
-
break;
|
|
43
|
-
case "end":
|
|
44
|
-
a = e.right - r.width;
|
|
45
|
-
break;
|
|
46
|
-
default:
|
|
47
|
-
a = e.left;
|
|
48
|
-
}
|
|
49
|
-
let c = e.bottom + 4;
|
|
50
|
-
if (a + r.width > o - h && (a = o - r.width - h), a = Math.max(h, a), c + r.height > f - h) {
|
|
51
|
-
const g = e.top - h, k = f - e.bottom - h;
|
|
52
|
-
g > k && g >= r.height ? c = e.top - r.height - 4 : c = f - r.height - h;
|
|
53
|
-
}
|
|
54
|
-
return c = Math.max(h, c), {
|
|
55
|
-
x: a,
|
|
56
|
-
y: c
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function he(e, r) {
|
|
60
|
-
const i = window.innerWidth, o = window.innerHeight;
|
|
61
|
-
let f = e.right, a = e.top;
|
|
62
|
-
if (f + r.width > i - h) {
|
|
63
|
-
const c = e.left - r.width;
|
|
64
|
-
c >= h ? f = c : f = i - r.width - h;
|
|
65
|
-
}
|
|
66
|
-
return a + r.height > o - h && (a = o - r.height - h), f = Math.max(h, f), a = Math.max(h, a), {
|
|
67
|
-
x: f,
|
|
68
|
-
y: a
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function Q(e) {
|
|
72
|
-
return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(J)).filter((r) => r instanceof HTMLElement);
|
|
73
|
-
}
|
|
74
|
-
function p(e, r = "first") {
|
|
75
|
-
const i = Q(e);
|
|
76
|
-
if (!i.length) return !1;
|
|
77
|
-
let o = i[0];
|
|
78
|
-
return r === "last" ? o = i[i.length - 1] : r === "selected" && (o = i.find((f) => f.getAttribute("data-floe-selected") === "true") ?? i[0]), o.focus(), !0;
|
|
79
|
-
}
|
|
80
|
-
function K(e, r, i) {
|
|
81
|
-
const o = Q(e);
|
|
82
|
-
if (!o.length) return !1;
|
|
83
|
-
const f = r ? o.indexOf(r) : -1, a = me(o.length, f, i);
|
|
84
|
-
return a === null ? !1 : (o[a]?.focus(), !0);
|
|
85
|
-
}
|
|
86
|
-
function ge(e) {
|
|
87
|
-
const [r, i] = _(!1), [o, f] = _({
|
|
33
|
+
function me(e) {
|
|
34
|
+
const [s, u] = F(!1), [c, P] = F({
|
|
88
35
|
x: -9999,
|
|
89
36
|
y: -9999
|
|
90
37
|
});
|
|
91
|
-
let
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
94
|
-
const
|
|
95
|
-
|
|
38
|
+
let y, x;
|
|
39
|
+
const h = `floe-dropdown-${se += 1}`, k = `${h}-menu`, R = () => {
|
|
40
|
+
if (!y || !x) return;
|
|
41
|
+
const o = y.getBoundingClientRect(), r = x.getBoundingClientRect(), d = ne(o, r, e.align ?? "start");
|
|
42
|
+
P(d);
|
|
96
43
|
};
|
|
97
|
-
|
|
98
|
-
if (!
|
|
99
|
-
|
|
44
|
+
Q(() => {
|
|
45
|
+
if (!s()) {
|
|
46
|
+
P({
|
|
100
47
|
x: -9999,
|
|
101
48
|
y: -9999
|
|
102
49
|
});
|
|
103
50
|
return;
|
|
104
51
|
}
|
|
105
|
-
const
|
|
106
|
-
const n =
|
|
107
|
-
n && typeof n.closest == "function" && n.closest(`[data-floe-dropdown="${
|
|
108
|
-
},
|
|
109
|
-
|
|
52
|
+
const o = (d) => {
|
|
53
|
+
const n = d.target;
|
|
54
|
+
n && typeof n.closest == "function" && n.closest(`[data-floe-dropdown="${h}"]`) || u(!1);
|
|
55
|
+
}, r = (d) => {
|
|
56
|
+
d.key === "Escape" && (u(!1), requestAnimationFrame(() => y?.focus()));
|
|
110
57
|
};
|
|
111
|
-
document.addEventListener("mousedown",
|
|
112
|
-
|
|
113
|
-
}),
|
|
114
|
-
document.removeEventListener("mousedown",
|
|
58
|
+
document.addEventListener("mousedown", o), document.addEventListener("keydown", r), requestAnimationFrame(() => {
|
|
59
|
+
R(), O(x, e.value ? "selected" : "first");
|
|
60
|
+
}), V(() => {
|
|
61
|
+
document.removeEventListener("mousedown", o), document.removeEventListener("keydown", r);
|
|
115
62
|
});
|
|
116
63
|
});
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
},
|
|
121
|
-
e.disabled || (
|
|
122
|
-
|
|
64
|
+
const v = (o) => {
|
|
65
|
+
const r = e.onSelect;
|
|
66
|
+
o.keepOpen || u(!1), X(() => r(o.id));
|
|
67
|
+
}, A = (o, r = "first") => {
|
|
68
|
+
e.disabled || (u(o), requestAnimationFrame(() => {
|
|
69
|
+
R(), O(x, r);
|
|
123
70
|
}));
|
|
124
|
-
},
|
|
71
|
+
}, _ = (o) => {
|
|
125
72
|
if (e.disabled) return;
|
|
126
|
-
const
|
|
127
|
-
open:
|
|
73
|
+
const r = fe(o.key, {
|
|
74
|
+
open: s(),
|
|
128
75
|
hasSelection: !!e.value
|
|
129
76
|
});
|
|
130
|
-
if (
|
|
131
|
-
if (
|
|
132
|
-
|
|
77
|
+
if (r) {
|
|
78
|
+
if (o.preventDefault(), !r.nextOpen) {
|
|
79
|
+
u(!1);
|
|
133
80
|
return;
|
|
134
81
|
}
|
|
135
|
-
|
|
82
|
+
A(!0, r.focusMode ?? "first");
|
|
136
83
|
}
|
|
137
|
-
},
|
|
138
|
-
const
|
|
139
|
-
switch (
|
|
84
|
+
}, T = (o) => {
|
|
85
|
+
const r = o.target, d = r?.closest('[role="menu"]'), n = r?.closest(te);
|
|
86
|
+
switch (o.key) {
|
|
140
87
|
case "ArrowDown":
|
|
141
|
-
|
|
88
|
+
o.preventDefault(), N(d, n, 1);
|
|
142
89
|
return;
|
|
143
90
|
case "ArrowUp":
|
|
144
|
-
|
|
91
|
+
o.preventDefault(), N(d, n, -1);
|
|
145
92
|
return;
|
|
146
93
|
case "Home":
|
|
147
|
-
|
|
94
|
+
o.preventDefault(), O(d, "first");
|
|
148
95
|
return;
|
|
149
96
|
case "End":
|
|
150
|
-
|
|
97
|
+
o.preventDefault(), O(d, "last");
|
|
151
98
|
return;
|
|
152
99
|
case "Tab":
|
|
153
|
-
|
|
100
|
+
u(!1);
|
|
154
101
|
return;
|
|
155
102
|
default:
|
|
156
103
|
return;
|
|
157
104
|
}
|
|
158
105
|
};
|
|
159
106
|
return (() => {
|
|
160
|
-
var
|
|
161
|
-
|
|
107
|
+
var o = oe(), r = o.firstChild;
|
|
108
|
+
m(o, "data-floe-dropdown", h), r.$$keydown = _, r.$$click = () => {
|
|
162
109
|
if (!e.disabled) {
|
|
163
|
-
if (
|
|
164
|
-
|
|
110
|
+
if (s()) {
|
|
111
|
+
u(!1);
|
|
165
112
|
return;
|
|
166
113
|
}
|
|
167
|
-
|
|
114
|
+
A(!0, e.value ? "selected" : "first");
|
|
168
115
|
}
|
|
169
116
|
};
|
|
170
|
-
var
|
|
171
|
-
return typeof
|
|
117
|
+
var d = y;
|
|
118
|
+
return typeof d == "function" ? L(d, r) : y = r, m(r, "aria-controls", k), f(r, () => e.trigger), f(o, l($, {
|
|
172
119
|
get when() {
|
|
173
|
-
return
|
|
120
|
+
return s();
|
|
174
121
|
},
|
|
175
122
|
get children() {
|
|
176
|
-
return
|
|
123
|
+
return l(U, {
|
|
177
124
|
get children() {
|
|
178
|
-
var n =
|
|
179
|
-
n.$$keydown =
|
|
180
|
-
var
|
|
181
|
-
return typeof
|
|
125
|
+
var n = H();
|
|
126
|
+
n.$$keydown = T;
|
|
127
|
+
var g = x;
|
|
128
|
+
return typeof g == "function" ? L(g, n) : x = n, m(n, "data-floe-dropdown", h), m(n, "id", k), f(n, l(z, {
|
|
182
129
|
get each() {
|
|
183
130
|
return e.items;
|
|
184
131
|
},
|
|
185
|
-
children: (t) =>
|
|
132
|
+
children: (t) => l($, {
|
|
186
133
|
get when() {
|
|
187
134
|
return !t().separator;
|
|
188
135
|
},
|
|
189
136
|
get fallback() {
|
|
190
|
-
return
|
|
137
|
+
return W();
|
|
191
138
|
},
|
|
192
139
|
get children() {
|
|
193
|
-
return
|
|
140
|
+
return l(G, {
|
|
194
141
|
get item() {
|
|
195
142
|
return t();
|
|
196
143
|
},
|
|
197
144
|
get selected() {
|
|
198
145
|
return e.value === t().id;
|
|
199
146
|
},
|
|
200
|
-
onSelect:
|
|
201
|
-
onCloseMenu: () =>
|
|
202
|
-
dropdownId:
|
|
147
|
+
onSelect: v,
|
|
148
|
+
onCloseMenu: () => u(!1),
|
|
149
|
+
dropdownId: h
|
|
203
150
|
});
|
|
204
151
|
}
|
|
205
152
|
})
|
|
206
153
|
})), D((t) => {
|
|
207
|
-
var
|
|
208
|
-
return
|
|
154
|
+
var w = C("fixed z-50 min-w-36 py-0.5", "bg-popover text-popover-foreground", "rounded border border-border shadow-md", "animate-in fade-in slide-in-from-top-2"), i = `${c().x}px`, b = `${c().y}px`;
|
|
155
|
+
return w !== t.e && M(n, t.e = w), i !== t.t && q(n, "left", t.t = i), b !== t.a && q(n, "top", t.a = b), t;
|
|
209
156
|
}, {
|
|
210
157
|
e: void 0,
|
|
211
158
|
t: void 0,
|
|
@@ -215,8 +162,8 @@ function ge(e) {
|
|
|
215
162
|
});
|
|
216
163
|
}
|
|
217
164
|
}), null), D((n) => {
|
|
218
|
-
var
|
|
219
|
-
return
|
|
165
|
+
var g = C("relative inline-block", e.class), t = C("cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-ring", e.triggerClass, e.disabled && "pointer-events-none opacity-50"), w = e.disabled ? -1 : 0, i = s(), b = e.triggerAriaLabel, a = e.disabled ? "true" : void 0;
|
|
166
|
+
return g !== n.e && M(o, n.e = g), t !== n.t && M(r, n.t = t), w !== n.a && m(r, "tabindex", n.a = w), i !== n.o && m(r, "aria-expanded", n.o = i), b !== n.i && m(r, "aria-label", n.i = b), a !== n.n && m(r, "aria-disabled", n.n = a), n;
|
|
220
167
|
}, {
|
|
221
168
|
e: void 0,
|
|
222
169
|
t: void 0,
|
|
@@ -224,94 +171,94 @@ function ge(e) {
|
|
|
224
171
|
o: void 0,
|
|
225
172
|
i: void 0,
|
|
226
173
|
n: void 0
|
|
227
|
-
}),
|
|
174
|
+
}), o;
|
|
228
175
|
})();
|
|
229
176
|
}
|
|
230
|
-
function
|
|
231
|
-
const [
|
|
177
|
+
function G(e) {
|
|
178
|
+
const [s, u] = F(!1), [c, P] = F({
|
|
232
179
|
x: -9999,
|
|
233
180
|
y: -9999
|
|
234
181
|
});
|
|
235
|
-
let
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
238
|
-
const n =
|
|
239
|
-
|
|
240
|
-
},
|
|
241
|
-
|
|
242
|
-
|
|
182
|
+
let y, x, h, k;
|
|
183
|
+
const R = `floe-dropdown-item-${ce += 1}`, v = () => e.item.children && e.item.children.length > 0, A = () => {
|
|
184
|
+
if (!y || !h) return;
|
|
185
|
+
const n = y.getBoundingClientRect(), g = h.getBoundingClientRect(), t = re(n, g);
|
|
186
|
+
P(t);
|
|
187
|
+
}, _ = () => {
|
|
188
|
+
v() && (clearTimeout(k), k = setTimeout(() => {
|
|
189
|
+
u(!0), requestAnimationFrame(A);
|
|
243
190
|
}, 100));
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
|
|
191
|
+
}, T = () => {
|
|
192
|
+
v() && (clearTimeout(k), k = void 0, !e.item.keepOpen && (k = setTimeout(() => {
|
|
193
|
+
u(!1);
|
|
247
194
|
}, 150)));
|
|
248
|
-
},
|
|
195
|
+
}, o = (n) => {
|
|
249
196
|
if (!e.item.disabled) {
|
|
250
197
|
if (e.item.content && e.item.keepOpen) {
|
|
251
198
|
n.stopPropagation();
|
|
252
199
|
return;
|
|
253
200
|
}
|
|
254
|
-
|
|
201
|
+
v() ? (u((g) => !g), requestAnimationFrame(A)) : e.item.content || e.onSelect(e.item);
|
|
255
202
|
}
|
|
256
|
-
},
|
|
257
|
-
|
|
258
|
-
|
|
203
|
+
}, r = (n = "first") => {
|
|
204
|
+
v() && (u(!0), requestAnimationFrame(() => {
|
|
205
|
+
A(), O(h, n);
|
|
259
206
|
}));
|
|
260
|
-
},
|
|
261
|
-
|
|
207
|
+
}, d = () => {
|
|
208
|
+
u(!1), requestAnimationFrame(() => x?.focus());
|
|
262
209
|
};
|
|
263
210
|
return (() => {
|
|
264
|
-
var n =
|
|
265
|
-
n.addEventListener("mouseleave",
|
|
266
|
-
var
|
|
267
|
-
return typeof
|
|
211
|
+
var n = le();
|
|
212
|
+
n.addEventListener("mouseleave", T), n.addEventListener("mouseenter", _);
|
|
213
|
+
var g = y;
|
|
214
|
+
return typeof g == "function" ? L(g, n) : y = n, f(n, l($, {
|
|
268
215
|
get when() {
|
|
269
216
|
return e.item.content;
|
|
270
217
|
},
|
|
271
218
|
get children() {
|
|
272
|
-
var t =
|
|
273
|
-
return t.$$click =
|
|
219
|
+
var t = ie();
|
|
220
|
+
return t.$$click = o, f(t, e.item.content), D(() => M(t, C("w-full px-2 py-1.5", e.item.disabled && "opacity-50 pointer-events-none"))), t;
|
|
274
221
|
}
|
|
275
|
-
}), null),
|
|
222
|
+
}), null), f(n, l($, {
|
|
276
223
|
get when() {
|
|
277
224
|
return !e.item.content;
|
|
278
225
|
},
|
|
279
226
|
get children() {
|
|
280
|
-
var t =
|
|
281
|
-
t.$$keydown = (
|
|
282
|
-
e.item.disabled ||
|
|
283
|
-
}, t.$$click =
|
|
284
|
-
var
|
|
285
|
-
return typeof
|
|
227
|
+
var t = ae(), w = t.firstChild, i = w.nextSibling;
|
|
228
|
+
t.$$keydown = (a) => {
|
|
229
|
+
e.item.disabled || v() && ((a.key === "ArrowRight" || a.key === "Enter" || a.key === " ") && (a.preventDefault(), r("first")), a.key === "ArrowLeft" && (a.preventDefault(), d()));
|
|
230
|
+
}, t.$$click = o;
|
|
231
|
+
var b = x;
|
|
232
|
+
return typeof b == "function" ? L(b, t) : x = t, m(t, "id", R), f(w, l($, {
|
|
286
233
|
get when() {
|
|
287
|
-
return
|
|
234
|
+
return K(() => !!e.selected)() && !v();
|
|
288
235
|
},
|
|
289
236
|
get children() {
|
|
290
|
-
return
|
|
237
|
+
return l(Z, {
|
|
291
238
|
class: "w-3 h-3"
|
|
292
239
|
});
|
|
293
240
|
}
|
|
294
|
-
})),
|
|
241
|
+
})), f(t, l($, {
|
|
295
242
|
get when() {
|
|
296
243
|
return e.item.icon;
|
|
297
244
|
},
|
|
298
245
|
keyed: !0,
|
|
299
|
-
children: (
|
|
300
|
-
var
|
|
301
|
-
return
|
|
246
|
+
children: (a) => (() => {
|
|
247
|
+
var S = ue();
|
|
248
|
+
return f(S, a), S;
|
|
302
249
|
})()
|
|
303
|
-
}),
|
|
250
|
+
}), i), f(i, () => e.item.label), f(t, l($, {
|
|
304
251
|
get when() {
|
|
305
|
-
return
|
|
252
|
+
return v();
|
|
306
253
|
},
|
|
307
254
|
get children() {
|
|
308
|
-
return
|
|
255
|
+
return l(ee, {
|
|
309
256
|
class: "w-3 h-3 text-muted-foreground"
|
|
310
257
|
});
|
|
311
258
|
}
|
|
312
|
-
}), null), D((
|
|
313
|
-
var
|
|
314
|
-
return
|
|
259
|
+
}), null), D((a) => {
|
|
260
|
+
var S = C("w-full flex items-center gap-1.5 px-2 py-1 text-xs", "transition-colors duration-75", "focus:outline-none focus:bg-accent", e.item.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-accent cursor-pointer"), I = e.item.disabled, B = v() ? "menu" : void 0, p = v() ? s() : void 0, j = e.selected && !v() ? "true" : void 0;
|
|
261
|
+
return S !== a.e && M(t, a.e = S), I !== a.t && (t.disabled = a.t = I), B !== a.a && m(t, "aria-haspopup", a.a = B), p !== a.o && m(t, "aria-expanded", a.o = p), j !== a.i && m(t, "data-floe-selected", a.i = j), a;
|
|
315
262
|
}, {
|
|
316
263
|
e: void 0,
|
|
317
264
|
t: void 0,
|
|
@@ -320,35 +267,35 @@ function X(e) {
|
|
|
320
267
|
i: void 0
|
|
321
268
|
}), t;
|
|
322
269
|
}
|
|
323
|
-
}), null),
|
|
270
|
+
}), null), f(n, l($, {
|
|
324
271
|
get when() {
|
|
325
|
-
return
|
|
272
|
+
return K(() => !!s())() && v();
|
|
326
273
|
},
|
|
327
274
|
get children() {
|
|
328
|
-
return
|
|
275
|
+
return l(U, {
|
|
329
276
|
get children() {
|
|
330
|
-
var t =
|
|
331
|
-
t.$$keydown = (
|
|
332
|
-
|
|
333
|
-
}, t.addEventListener("mouseleave",
|
|
277
|
+
var t = H();
|
|
278
|
+
t.$$keydown = (i) => {
|
|
279
|
+
i.key !== "ArrowLeft" && i.key !== "Escape" || (i.preventDefault(), i.stopPropagation(), d());
|
|
280
|
+
}, t.addEventListener("mouseleave", T), t.addEventListener("mouseenter", () => {
|
|
334
281
|
clearTimeout(k);
|
|
335
282
|
});
|
|
336
|
-
var
|
|
337
|
-
return typeof
|
|
283
|
+
var w = h;
|
|
284
|
+
return typeof w == "function" ? L(w, t) : h = t, m(t, "aria-labelledby", R), f(t, l(z, {
|
|
338
285
|
get each() {
|
|
339
286
|
return e.item.children;
|
|
340
287
|
},
|
|
341
|
-
children: (
|
|
288
|
+
children: (i) => l($, {
|
|
342
289
|
get when() {
|
|
343
|
-
return !
|
|
290
|
+
return !i().separator;
|
|
344
291
|
},
|
|
345
292
|
get fallback() {
|
|
346
|
-
return
|
|
293
|
+
return W();
|
|
347
294
|
},
|
|
348
295
|
get children() {
|
|
349
|
-
return
|
|
296
|
+
return l(G, {
|
|
350
297
|
get item() {
|
|
351
|
-
return
|
|
298
|
+
return i();
|
|
352
299
|
},
|
|
353
300
|
selected: !1,
|
|
354
301
|
get onSelect() {
|
|
@@ -363,9 +310,9 @@ function X(e) {
|
|
|
363
310
|
});
|
|
364
311
|
}
|
|
365
312
|
})
|
|
366
|
-
})), D((
|
|
367
|
-
var
|
|
368
|
-
return
|
|
313
|
+
})), D((i) => {
|
|
314
|
+
var b = C("fixed z-50 min-w-36 py-0.5", "bg-popover text-popover-foreground", "rounded border border-border shadow-md", "animate-in fade-in slide-in-from-left-1"), a = e.dropdownId, S = `${c().x}px`, I = `${c().y}px`;
|
|
315
|
+
return b !== i.e && M(t, i.e = b), a !== i.t && m(t, "data-floe-dropdown", i.t = a), S !== i.a && q(t, "left", i.a = S), I !== i.o && q(t, "top", i.o = I), i;
|
|
369
316
|
}, {
|
|
370
317
|
e: void 0,
|
|
371
318
|
t: void 0,
|
|
@@ -378,25 +325,25 @@ function X(e) {
|
|
|
378
325
|
}), null), n;
|
|
379
326
|
})();
|
|
380
327
|
}
|
|
381
|
-
function
|
|
382
|
-
const
|
|
383
|
-
id:
|
|
384
|
-
label:
|
|
328
|
+
function xe(e) {
|
|
329
|
+
const s = () => e.options.find((c) => c.value === e.value), u = () => e.options.map((c) => ({
|
|
330
|
+
id: c.value,
|
|
331
|
+
label: c.label
|
|
385
332
|
}));
|
|
386
|
-
return
|
|
333
|
+
return l(me, {
|
|
387
334
|
get triggerClass() {
|
|
388
|
-
return
|
|
335
|
+
return C("flex items-center justify-between gap-2 h-8 px-2.5 w-full", "rounded border border-input bg-background text-xs shadow-sm", "transition-colors duration-100", e.class);
|
|
389
336
|
},
|
|
390
337
|
get trigger() {
|
|
391
338
|
return [(() => {
|
|
392
|
-
var
|
|
393
|
-
return
|
|
394
|
-
})(),
|
|
339
|
+
var c = de();
|
|
340
|
+
return f(c, () => s()?.label ?? e.placeholder ?? "Select..."), D(() => M(c, C("truncate", !s() && "text-muted-foreground"))), c;
|
|
341
|
+
})(), l(Y, {
|
|
395
342
|
class: "w-3.5 h-3.5 text-muted-foreground"
|
|
396
343
|
})];
|
|
397
344
|
},
|
|
398
345
|
get items() {
|
|
399
|
-
return
|
|
346
|
+
return u();
|
|
400
347
|
},
|
|
401
348
|
get value() {
|
|
402
349
|
return e.value;
|
|
@@ -409,10 +356,9 @@ function Me(e) {
|
|
|
409
356
|
}
|
|
410
357
|
});
|
|
411
358
|
}
|
|
412
|
-
|
|
359
|
+
J(["click", "keydown"]);
|
|
413
360
|
export {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
me as getWrappedMenuItemIndex,
|
|
361
|
+
me as Dropdown,
|
|
362
|
+
xe as Select,
|
|
417
363
|
fe as resolveDropdownTriggerKeyAction
|
|
418
364
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const VIEWPORT_MARGIN = 8;
|
|
2
|
+
export declare const MENU_ITEM_SELECTOR = "[role=\"menuitem\"]:not([disabled]):not([aria-disabled=\"true\"])";
|
|
3
|
+
export type MenuFocusMode = 'first' | 'last' | 'selected';
|
|
4
|
+
export declare function calculateMenuPosition(triggerRect: DOMRect, menuRect: DOMRect, align: 'start' | 'center' | 'end'): {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function calculateSubmenuPosition(parentRect: DOMRect, submenuRect: DOMRect): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function getWrappedMenuItemIndex(length: number, currentIndex: number, delta: 1 | -1): number | null;
|
|
13
|
+
export declare function getMenuItems(root: ParentNode | null | undefined): HTMLElement[];
|
|
14
|
+
export declare function focusMenuItem(root: ParentNode | null | undefined, mode?: MenuFocusMode): boolean;
|
|
15
|
+
export declare function moveMenuFocus(root: ParentNode | null | undefined, current: HTMLElement | null, delta: 1 | -1): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const d = 8, r = '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])';
|
|
2
|
+
function M(e, t, n) {
|
|
3
|
+
const o = window.innerWidth, f = window.innerHeight;
|
|
4
|
+
let i;
|
|
5
|
+
switch (n) {
|
|
6
|
+
case "center":
|
|
7
|
+
i = e.left + e.width / 2 - t.width / 2;
|
|
8
|
+
break;
|
|
9
|
+
case "end":
|
|
10
|
+
i = e.right - t.width;
|
|
11
|
+
break;
|
|
12
|
+
default:
|
|
13
|
+
i = e.left;
|
|
14
|
+
}
|
|
15
|
+
let l = e.bottom + 4;
|
|
16
|
+
if (i + t.width > o - 8 && (i = o - t.width - 8), i = Math.max(8, i), l + t.height > f - 8) {
|
|
17
|
+
const I = e.top - 8, h = f - e.bottom - 8;
|
|
18
|
+
I > h && I >= t.height ? l = e.top - t.height - 4 : l = f - t.height - 8;
|
|
19
|
+
}
|
|
20
|
+
return l = Math.max(8, l), { x: i, y: l };
|
|
21
|
+
}
|
|
22
|
+
function u(e, t) {
|
|
23
|
+
const n = window.innerWidth, o = window.innerHeight;
|
|
24
|
+
let f = e.right, i = e.top;
|
|
25
|
+
if (f + t.width > n - 8) {
|
|
26
|
+
const l = e.left - t.width;
|
|
27
|
+
l >= 8 ? f = l : f = n - t.width - 8;
|
|
28
|
+
}
|
|
29
|
+
return i + t.height > o - 8 && (i = o - t.height - 8), f = Math.max(8, f), i = Math.max(8, i), { x: f, y: i };
|
|
30
|
+
}
|
|
31
|
+
function a(e, t, n) {
|
|
32
|
+
return e <= 0 ? null : t < 0 ? n > 0 ? 0 : e - 1 : (t + n + e) % e;
|
|
33
|
+
}
|
|
34
|
+
function s(e) {
|
|
35
|
+
return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(r)).filter(
|
|
36
|
+
(t) => t instanceof HTMLElement
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function w(e, t = "first") {
|
|
40
|
+
const n = s(e);
|
|
41
|
+
if (!n.length) return !1;
|
|
42
|
+
let o = n[0];
|
|
43
|
+
return t === "last" ? o = n[n.length - 1] : t === "selected" && (o = n.find((f) => f.getAttribute("data-floe-selected") === "true") ?? n[0]), o.focus(), !0;
|
|
44
|
+
}
|
|
45
|
+
function E(e, t, n) {
|
|
46
|
+
const o = s(e);
|
|
47
|
+
if (!o.length) return !1;
|
|
48
|
+
const f = t ? o.indexOf(t) : -1, i = a(o.length, f, n);
|
|
49
|
+
return i === null ? !1 : (o[i]?.focus(), !0);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
r as MENU_ITEM_SELECTOR,
|
|
53
|
+
d as VIEWPORT_MARGIN,
|
|
54
|
+
M as calculateMenuPosition,
|
|
55
|
+
u as calculateSubmenuPosition,
|
|
56
|
+
w as focusMenuItem,
|
|
57
|
+
s as getMenuItems,
|
|
58
|
+
a as getWrappedMenuItemIndex,
|
|
59
|
+
E as moveMenuFocus
|
|
60
|
+
};
|