@floegence/floe-webapp-core 0.77.1 → 0.77.2
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,5 +1,6 @@
|
|
|
1
1
|
import { type Component } from 'solid-js';
|
|
2
|
-
|
|
2
|
+
import type { ActivityBarItem } from './ActivityBar';
|
|
3
|
+
export interface MobileTabBarItem extends Pick<ActivityBarItem, 'buttonRef' | 'ariaExpanded' | 'ariaControls' | 'ariaHasPopup'> {
|
|
3
4
|
id: string;
|
|
4
5
|
icon: Component<{
|
|
5
6
|
class?: string;
|
|
@@ -1,160 +1,168 @@
|
|
|
1
|
-
import { insert as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { deferNonBlocking as
|
|
5
|
-
var q = /* @__PURE__ */
|
|
6
|
-
function
|
|
7
|
-
let
|
|
8
|
-
const [
|
|
9
|
-
let
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
if (
|
|
1
|
+
import { insert as m, createComponent as v, effect as L, className as w, setAttribute as f, template as x, use as E, Dynamic as _, memo as z, delegateEvents as D } from "solid-js/web";
|
|
2
|
+
import { createSignal as $, onMount as F, onCleanup as W, Show as S, For as j } from "solid-js";
|
|
3
|
+
import { cn as y } from "../../utils/cn.js";
|
|
4
|
+
import { deferNonBlocking as R } from "../../utils/defer.js";
|
|
5
|
+
var q = /* @__PURE__ */ x('<div class="absolute left-0 top-0 bottom-0 w-8 bg-gradient-to-r from-background to-transparent z-10 pointer-events-none">'), B = /* @__PURE__ */ x('<div class="absolute right-0 top-0 bottom-0 w-8 bg-gradient-to-l from-background to-transparent z-10 pointer-events-none">'), H = /* @__PURE__ */ x('<nav data-floe-shell-slot=mobile-tab-bar style=border-top-color:var(--bottom-bar-border)><div class="relative h-14"><div class="h-full flex items-center overflow-x-auto scrollbar-hide snap-x snap-mandatory"role=tablist aria-orientation=horizontal style=-webkit-overflow-scrolling:touch>'), K = /* @__PURE__ */ x("<span>"), N = /* @__PURE__ */ x('<div class="absolute bottom-0 left-1/2 -translate-x-1/2 w-8 h-0.5 bg-primary rounded-t">'), T = /* @__PURE__ */ x("<button type=button role=tab><div></div><span>");
|
|
6
|
+
function O(e) {
|
|
7
|
+
let l;
|
|
8
|
+
const [I, b] = $(!1), [n, h] = $(!1);
|
|
9
|
+
let c = null;
|
|
10
|
+
const g = () => {
|
|
11
|
+
l && (b(l.scrollLeft > 0), h(l.scrollLeft < l.scrollWidth - l.clientWidth - 1));
|
|
12
|
+
}, t = () => {
|
|
13
|
+
if (c === null) {
|
|
14
14
|
if (typeof requestAnimationFrame > "u") {
|
|
15
|
-
|
|
15
|
+
g();
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
c = requestAnimationFrame(() => {
|
|
19
|
+
c = null, g();
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
},
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
if (
|
|
26
|
-
|
|
22
|
+
}, o = () => e.items, C = (a) => {
|
|
23
|
+
const i = o()[a];
|
|
24
|
+
if (i) {
|
|
25
|
+
if (i.onClick) {
|
|
26
|
+
R(() => i.onClick());
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
e.onSelect(
|
|
29
|
+
e.onSelect(i.id);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
|
|
32
|
+
return F(() => {
|
|
33
|
+
g();
|
|
34
|
+
const a = e.items.findIndex((i) => i.id === e.activeId);
|
|
35
|
+
if (a > 0 && l) {
|
|
36
|
+
const i = l.scrollWidth / e.items.length;
|
|
37
|
+
l.scrollLeft = Math.max(0, i * a - l.clientWidth / 2 + i / 2);
|
|
38
38
|
}
|
|
39
|
-
}),
|
|
40
|
-
|
|
39
|
+
}), W(() => {
|
|
40
|
+
c !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(c), c = null);
|
|
41
41
|
}), (() => {
|
|
42
|
-
var
|
|
43
|
-
|
|
42
|
+
var a = H(), i = a.firstChild, d = i.firstChild;
|
|
43
|
+
m(i, v(S, {
|
|
44
44
|
get when() {
|
|
45
|
-
return
|
|
45
|
+
return I();
|
|
46
46
|
},
|
|
47
47
|
get children() {
|
|
48
48
|
return q();
|
|
49
49
|
}
|
|
50
|
-
}),
|
|
50
|
+
}), d), m(i, v(S, {
|
|
51
51
|
get when() {
|
|
52
|
-
return
|
|
52
|
+
return n();
|
|
53
53
|
},
|
|
54
54
|
get children() {
|
|
55
55
|
return B();
|
|
56
56
|
}
|
|
57
|
-
}),
|
|
58
|
-
var
|
|
59
|
-
return typeof
|
|
57
|
+
}), d), d.addEventListener("scroll", t);
|
|
58
|
+
var k = l;
|
|
59
|
+
return typeof k == "function" ? E(k, d) : l = d, m(d, v(j, {
|
|
60
60
|
get each() {
|
|
61
61
|
return e.items;
|
|
62
62
|
},
|
|
63
|
-
children: (
|
|
64
|
-
item:
|
|
63
|
+
children: (r, s) => v(P, {
|
|
64
|
+
item: r,
|
|
65
65
|
get isActive() {
|
|
66
|
-
return e.activeId ===
|
|
66
|
+
return e.activeId === r.id;
|
|
67
67
|
},
|
|
68
68
|
get index() {
|
|
69
|
-
return
|
|
69
|
+
return s();
|
|
70
70
|
},
|
|
71
71
|
get itemCount() {
|
|
72
72
|
return e.items.length;
|
|
73
73
|
},
|
|
74
74
|
onClick: () => {
|
|
75
75
|
"vibrate" in navigator && navigator.vibrate(10);
|
|
76
|
-
const
|
|
77
|
-
|
|
76
|
+
const u = r.onClick, A = e.onSelect, M = r.id;
|
|
77
|
+
r.onClick ? R(() => u()) : A(M);
|
|
78
78
|
},
|
|
79
|
-
onKeyboardSelect: (
|
|
79
|
+
onKeyboardSelect: (u) => C(u)
|
|
80
80
|
})
|
|
81
|
-
})),
|
|
82
|
-
var
|
|
81
|
+
})), L((r) => {
|
|
82
|
+
var s = e.hidden, u = y(
|
|
83
83
|
// Same safe-area rule as TopBar: keep the visual bar height stable, and
|
|
84
84
|
// add safe-area padding on an outer wrapper (avoid squeezing content).
|
|
85
85
|
"relative shrink-0 bg-background border-t border-border safe-bottom safe-left safe-right",
|
|
86
86
|
e.class
|
|
87
|
-
),
|
|
88
|
-
return
|
|
87
|
+
), A = e.ariaLabel;
|
|
88
|
+
return s !== r.e && (a.hidden = r.e = s), u !== r.t && w(a, r.t = u), A !== r.a && f(a, "aria-label", r.a = A), r;
|
|
89
89
|
}, {
|
|
90
90
|
e: void 0,
|
|
91
91
|
t: void 0,
|
|
92
92
|
a: void 0
|
|
93
|
-
}),
|
|
93
|
+
}), a;
|
|
94
94
|
})();
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
96
|
+
function P(e) {
|
|
97
|
+
let l;
|
|
98
|
+
const I = () => typeof e.item.ariaExpanded == "function" ? e.item.ariaExpanded() : e.item.ariaExpanded;
|
|
99
|
+
F(() => e.item.buttonRef?.(l ?? null)), W(() => e.item.buttonRef?.(null));
|
|
100
|
+
const b = () => typeof e.item.badge == "function" ? e.item.badge() : e.item.badge;
|
|
98
101
|
return (() => {
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
let
|
|
102
|
+
var n = T(), h = n.firstChild, c = h.nextSibling;
|
|
103
|
+
n.$$keydown = (t) => {
|
|
104
|
+
let o = null;
|
|
102
105
|
switch (t.key) {
|
|
103
106
|
case "ArrowRight":
|
|
104
107
|
case "ArrowDown":
|
|
105
|
-
|
|
108
|
+
o = (e.index + 1) % e.itemCount;
|
|
106
109
|
break;
|
|
107
110
|
case "ArrowLeft":
|
|
108
111
|
case "ArrowUp":
|
|
109
|
-
|
|
112
|
+
o = (e.index - 1 + e.itemCount) % e.itemCount;
|
|
110
113
|
break;
|
|
111
114
|
case "Home":
|
|
112
|
-
|
|
115
|
+
o = 0;
|
|
113
116
|
break;
|
|
114
117
|
case "End":
|
|
115
|
-
|
|
118
|
+
o = e.itemCount - 1;
|
|
116
119
|
break;
|
|
117
120
|
default:
|
|
118
121
|
return;
|
|
119
122
|
}
|
|
120
|
-
t.preventDefault(), e.onKeyboardSelect(
|
|
121
|
-
},
|
|
123
|
+
t.preventDefault(), e.onKeyboardSelect(o);
|
|
124
|
+
}, n.$$click = () => e.onClick();
|
|
125
|
+
var g = l;
|
|
126
|
+
return typeof g == "function" ? E(g, n) : l = n, m(h, v(_, {
|
|
122
127
|
get component() {
|
|
123
128
|
return e.item.icon;
|
|
124
129
|
},
|
|
125
130
|
class: "w-6 h-6"
|
|
126
|
-
}), null),
|
|
131
|
+
}), null), m(h, v(S, {
|
|
127
132
|
get when() {
|
|
128
|
-
return
|
|
133
|
+
return b();
|
|
129
134
|
},
|
|
130
135
|
get children() {
|
|
131
|
-
var t =
|
|
132
|
-
return
|
|
133
|
-
var
|
|
134
|
-
return () =>
|
|
135
|
-
})()),
|
|
136
|
+
var t = K();
|
|
137
|
+
return m(t, (() => {
|
|
138
|
+
var o = z(() => typeof b() == "number" && b() > 99);
|
|
139
|
+
return () => o() ? "99+" : b();
|
|
140
|
+
})()), L(() => w(t, y("absolute -top-1 -right-2 min-w-4 h-4 px-1", "flex items-center justify-center", "text-[10px] font-medium rounded-full", "bg-primary text-primary-foreground"))), t;
|
|
136
141
|
}
|
|
137
|
-
}), null), c
|
|
142
|
+
}), null), m(c, () => e.item.label), m(n, v(S, {
|
|
138
143
|
get when() {
|
|
139
144
|
return e.isActive;
|
|
140
145
|
},
|
|
141
146
|
get children() {
|
|
142
|
-
return
|
|
147
|
+
return N();
|
|
143
148
|
}
|
|
144
|
-
}), null),
|
|
145
|
-
var
|
|
146
|
-
return
|
|
149
|
+
}), null), L((t) => {
|
|
150
|
+
var o = y("relative flex-shrink-0 flex flex-col items-center justify-center", "min-w-16 h-full px-4 snap-center", "transition-[color] duration-150", "focus:outline-none focus-visible:bg-muted", e.isActive ? "text-primary" : "text-muted-foreground active:text-foreground"), C = e.item.label, a = e.isActive, i = I(), d = e.item.ariaControls, k = e.item.ariaHasPopup, r = e.isActive ? 0 : -1, s = y("relative transition-transform duration-150", e.isActive && "scale-110"), u = y("mt-1 text-[10px] font-medium truncate max-w-full", e.isActive && "font-semibold");
|
|
151
|
+
return o !== t.e && w(n, t.e = o), C !== t.t && f(n, "aria-label", t.t = C), a !== t.a && f(n, "aria-selected", t.a = a), i !== t.o && f(n, "aria-expanded", t.o = i), d !== t.i && f(n, "aria-controls", t.i = d), k !== t.n && f(n, "aria-haspopup", t.n = k), r !== t.s && f(n, "tabindex", t.s = r), s !== t.h && w(h, t.h = s), u !== t.r && w(c, t.r = u), t;
|
|
147
152
|
}, {
|
|
148
153
|
e: void 0,
|
|
149
154
|
t: void 0,
|
|
150
155
|
a: void 0,
|
|
151
156
|
o: void 0,
|
|
152
157
|
i: void 0,
|
|
153
|
-
n: void 0
|
|
154
|
-
|
|
158
|
+
n: void 0,
|
|
159
|
+
s: void 0,
|
|
160
|
+
h: void 0,
|
|
161
|
+
r: void 0
|
|
162
|
+
}), n;
|
|
155
163
|
})();
|
|
156
164
|
}
|
|
157
|
-
|
|
165
|
+
D(["click", "keydown"]);
|
|
158
166
|
export {
|
|
159
|
-
|
|
167
|
+
O as MobileTabBar
|
|
160
168
|
};
|