@floegence/floe-webapp-core 0.101.9 → 0.101.10
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/ui/SegmentedControl.js +111 -73
- package/dist/styles.css +1 -1
- package/dist/surface.css +46 -7
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { use as
|
|
2
|
-
import { splitProps as
|
|
3
|
-
import { cn as
|
|
4
|
-
var
|
|
5
|
-
const
|
|
1
|
+
import { use as T, spread as X, mergeProps as Y, insert as p, createComponent as W, memo as V, effect as M, setAttribute as z, setStyleProperty as c, className as q, template as j, delegateEvents as Z } from "solid-js/web";
|
|
2
|
+
import { splitProps as ee, createSignal as B, createEffect as te, onMount as oe, onCleanup as G, For as I, untrack as re } from "solid-js";
|
|
3
|
+
import { cn as R } from "../../utils/cn.js";
|
|
4
|
+
var ne = /* @__PURE__ */ j("<div role=group data-floe-surface=inset data-floe-surface-part=rail><span aria-hidden=true><span class=floe-segmented-control__ink>"), ie = /* @__PURE__ */ j('<span class=floe-segmented-control__ink-label><span class="inline-flex items-center gap-1.5"><span>'), ae = /* @__PURE__ */ j('<button type=button role=radio data-floe-surface-part=segment data-floe-interactive=item><span class="inline-flex items-center gap-1.5"><span class=floe-segmented-control__label>');
|
|
5
|
+
const le = {
|
|
6
6
|
sm: {
|
|
7
7
|
container: "p-0.5 gap-0.5",
|
|
8
8
|
button: "h-[var(--floe-control-height-xs)] px-[var(--floe-control-padding-sm)] rounded-sm",
|
|
@@ -19,92 +19,129 @@ const ee = {
|
|
|
19
19
|
icon: "w-4 h-4"
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
function
|
|
23
|
-
const [
|
|
24
|
-
let
|
|
25
|
-
const
|
|
26
|
-
let
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
30
|
-
|
|
22
|
+
function fe(J) {
|
|
23
|
+
const [l, K] = ee(J, ["value", "onChange", "options", "size", "disabled", "class"]);
|
|
24
|
+
let u, m, g;
|
|
25
|
+
const [P, Q] = B({}), y = /* @__PURE__ */ new Map(), [d, A] = B();
|
|
26
|
+
let h, b, w, F;
|
|
27
|
+
const E = () => {
|
|
28
|
+
const a = y.get(l.value);
|
|
29
|
+
if (!u || !a) {
|
|
30
|
+
b?.cancel(), w?.cancel(), A(void 0), F = void 0;
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
if (!
|
|
34
|
-
const
|
|
35
|
-
x:
|
|
36
|
-
y:
|
|
37
|
-
width:
|
|
38
|
-
height:
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
width:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
if (!a.offsetWidth || !u.getClientRects().length) return;
|
|
34
|
+
const r = {
|
|
35
|
+
x: a.offsetLeft,
|
|
36
|
+
y: a.offsetTop,
|
|
37
|
+
width: a.offsetWidth,
|
|
38
|
+
height: a.offsetHeight
|
|
39
|
+
};
|
|
40
|
+
Q(Object.fromEntries([...y].map(([o, s]) => [o, {
|
|
41
|
+
x: s.offsetLeft,
|
|
42
|
+
y: s.offsetTop,
|
|
43
|
+
width: s.offsetWidth,
|
|
44
|
+
height: s.offsetHeight
|
|
45
|
+
}])));
|
|
46
|
+
const f = re(d);
|
|
47
|
+
if (f && Object.keys(r).every((o) => r[o] === f[o]) && F === l.value) return;
|
|
48
|
+
const $ = f && F !== l.value && m && !window.matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active)").matches, x = $ ? getComputedStyle(m) : void 0, C = x ? {
|
|
49
|
+
transform: x.transform,
|
|
50
|
+
width: x.width
|
|
51
|
+
} : void 0, e = $ && g ? getComputedStyle(g).transform : void 0;
|
|
52
|
+
if (b?.cancel(), w?.cancel(), A(r), F = l.value, C && m) {
|
|
53
|
+
const o = getComputedStyle(u), s = o.getPropertyValue("--floe-duration-slow").trim(), n = parseFloat(s) * (s.endsWith("ms") ? 1 : 1e3);
|
|
54
|
+
b = m.animate([C, {
|
|
55
|
+
transform: `translate(${r.x}px, ${r.y}px)`,
|
|
56
|
+
width: `${r.width}px`
|
|
50
57
|
}], {
|
|
51
58
|
// Position changes need visible travel: the fast entrance curve
|
|
52
59
|
// covers almost 90% of this short rail in its first 60ms.
|
|
53
|
-
duration: Number.isFinite(
|
|
54
|
-
easing:
|
|
55
|
-
}),
|
|
60
|
+
duration: Number.isFinite(n) ? n : 280,
|
|
61
|
+
easing: o.getPropertyValue("--floe-ease-in-out").trim() || "ease-in-out"
|
|
62
|
+
}), b.id = "floe-segmented-selection", g && e && (w = g.animate([{
|
|
63
|
+
transform: e
|
|
64
|
+
}, {
|
|
65
|
+
transform: `translate(${-r.x}px, ${-r.y}px)`
|
|
66
|
+
}], b.effect.getTiming()), w.id = "floe-segmented-ink");
|
|
56
67
|
}
|
|
57
68
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}),
|
|
69
|
+
te(() => {
|
|
70
|
+
l.value, l.options, l.size, E();
|
|
71
|
+
}), oe(() => {
|
|
61
72
|
if (typeof ResizeObserver < "u") {
|
|
62
|
-
|
|
63
|
-
for (const
|
|
73
|
+
h = new ResizeObserver(E), h.observe(u);
|
|
74
|
+
for (const a of y.values()) h.observe(a);
|
|
64
75
|
}
|
|
65
|
-
|
|
66
|
-
}),
|
|
67
|
-
|
|
76
|
+
E();
|
|
77
|
+
}), G(() => {
|
|
78
|
+
h?.disconnect(), b?.cancel(), w?.cancel();
|
|
68
79
|
});
|
|
69
|
-
const
|
|
70
|
-
|
|
80
|
+
const H = () => l.size ?? "md", O = () => le[H()], U = (a, r) => {
|
|
81
|
+
l.disabled || r || a !== l.value && l.onChange(a);
|
|
71
82
|
};
|
|
72
83
|
return (() => {
|
|
73
|
-
var
|
|
74
|
-
typeof
|
|
84
|
+
var a = ne(), r = a.firstChild, f = r.firstChild, $ = u;
|
|
85
|
+
typeof $ == "function" ? T($, a) : u = a, X(a, Y({
|
|
75
86
|
get "data-floe-segmented-pill"() {
|
|
76
|
-
return
|
|
87
|
+
return d() ? "true" : void 0;
|
|
77
88
|
},
|
|
78
89
|
get "data-floe-segmented-motion"() {
|
|
79
|
-
return
|
|
90
|
+
return d() ? "ready" : void 0;
|
|
80
91
|
},
|
|
81
92
|
get class() {
|
|
82
|
-
return
|
|
93
|
+
return R("floe-segmented-control relative inline-flex items-center border", "rounded-group", "text-[length:var(--floe-type-control)] leading-[var(--floe-line-control)]", O().container, l.disabled && "opacity-50 pointer-events-none", l.class);
|
|
83
94
|
}
|
|
84
|
-
},
|
|
85
|
-
var
|
|
86
|
-
|
|
95
|
+
}, K), !1, !0);
|
|
96
|
+
var x = m;
|
|
97
|
+
typeof x == "function" ? T(x, r) : m = r;
|
|
98
|
+
var C = g;
|
|
99
|
+
return typeof C == "function" ? T(C, f) : g = f, p(f, W(I, {
|
|
87
100
|
get each() {
|
|
88
|
-
return
|
|
101
|
+
return l.options;
|
|
102
|
+
},
|
|
103
|
+
children: (e) => (() => {
|
|
104
|
+
var o = ie(), s = o.firstChild, n = s.firstChild;
|
|
105
|
+
return p(s, (() => {
|
|
106
|
+
var i = V(() => !!e.icon);
|
|
107
|
+
return () => i() && W(e.icon, {
|
|
108
|
+
get class() {
|
|
109
|
+
return O().icon;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
})(), n), p(n, () => e.label), M((i) => {
|
|
113
|
+
var v = e.value, t = `${P()[e.value]?.x ?? 0}px`, k = `${P()[e.value]?.y ?? 0}px`, _ = `${P()[e.value]?.width ?? 0}px`, S = `${P()[e.value]?.height ?? 0}px`;
|
|
114
|
+
return v !== i.e && z(o, "data-segmented-label", i.e = v), t !== i.t && c(o, "left", i.t = t), k !== i.a && c(o, "top", i.a = k), _ !== i.o && c(o, "width", i.o = _), S !== i.i && c(o, "height", i.i = S), i;
|
|
115
|
+
}, {
|
|
116
|
+
e: void 0,
|
|
117
|
+
t: void 0,
|
|
118
|
+
a: void 0,
|
|
119
|
+
o: void 0,
|
|
120
|
+
i: void 0
|
|
121
|
+
}), o;
|
|
122
|
+
})()
|
|
123
|
+
})), p(a, W(I, {
|
|
124
|
+
get each() {
|
|
125
|
+
return l.options;
|
|
89
126
|
},
|
|
90
127
|
children: (e) => {
|
|
91
|
-
const
|
|
128
|
+
const o = () => l.value === e.value, s = () => l.disabled || e.disabled;
|
|
92
129
|
return (() => {
|
|
93
|
-
var
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
130
|
+
var n = ae(), i = n.firstChild, v = i.firstChild;
|
|
131
|
+
return n.$$click = () => U(e.value, e.disabled), T((t) => {
|
|
132
|
+
y.set(e.value, t), h?.observe(t), G(() => {
|
|
133
|
+
h?.unobserve(t), y.delete(e.value);
|
|
97
134
|
});
|
|
98
|
-
},
|
|
99
|
-
var t =
|
|
100
|
-
return () => t() &&
|
|
135
|
+
}, n), p(i, (() => {
|
|
136
|
+
var t = V(() => !!e.icon);
|
|
137
|
+
return () => t() && W(e.icon, {
|
|
101
138
|
get class() {
|
|
102
|
-
return
|
|
139
|
+
return O().icon;
|
|
103
140
|
}
|
|
104
141
|
});
|
|
105
|
-
})(),
|
|
106
|
-
var
|
|
107
|
-
return
|
|
142
|
+
})(), v), p(v, () => e.label), M((t) => {
|
|
143
|
+
var k = e.label, _ = e.label, S = o() ? "raised" : "flat", L = o(), N = s(), D = R("floe-segmented-control__item relative font-medium cursor-pointer border", "transition-[background-color,border-color,color,box-shadow] duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--floe-plane)]", O().button, o() ? "text-[var(--primary-foreground)]" : "text-[var(--floe-ink-soft)] hover:text-foreground", s() && "cursor-not-allowed opacity-50");
|
|
144
|
+
return k !== t.e && z(n, "aria-label", t.e = k), _ !== t.t && z(n, "title", t.t = _), S !== t.a && z(n, "data-floe-surface", t.a = S), L !== t.o && z(n, "aria-checked", t.o = L), N !== t.i && (n.disabled = t.i = N), D !== t.n && q(n, t.n = D), t;
|
|
108
145
|
}, {
|
|
109
146
|
e: void 0,
|
|
110
147
|
t: void 0,
|
|
@@ -112,22 +149,23 @@ function ne(D) {
|
|
|
112
149
|
o: void 0,
|
|
113
150
|
i: void 0,
|
|
114
151
|
n: void 0
|
|
115
|
-
}),
|
|
152
|
+
}), n;
|
|
116
153
|
})();
|
|
117
154
|
}
|
|
118
|
-
}), null),
|
|
119
|
-
var
|
|
120
|
-
return
|
|
155
|
+
}), null), M((e) => {
|
|
156
|
+
var o = R("floe-segmented-control__pill", H() === "lg" ? "rounded-md" : "rounded-sm"), s = d() ? "visible" : "hidden", n = `translate(${d()?.x ?? 0}px, ${d()?.y ?? 0}px)`, i = `${d()?.width ?? 0}px`, v = `${d()?.height ?? 0}px`, t = `translate(${-(d()?.x ?? 0)}px, ${-(d()?.y ?? 0)}px)`;
|
|
157
|
+
return o !== e.e && q(r, e.e = o), s !== e.t && c(r, "visibility", e.t = s), n !== e.a && c(r, "transform", e.a = n), i !== e.o && c(r, "width", e.o = i), v !== e.i && c(r, "height", e.i = v), t !== e.n && c(f, "transform", e.n = t), e;
|
|
121
158
|
}, {
|
|
122
159
|
e: void 0,
|
|
123
160
|
t: void 0,
|
|
124
161
|
a: void 0,
|
|
125
162
|
o: void 0,
|
|
126
|
-
i: void 0
|
|
127
|
-
|
|
163
|
+
i: void 0,
|
|
164
|
+
n: void 0
|
|
165
|
+
}), a;
|
|
128
166
|
})();
|
|
129
167
|
}
|
|
130
|
-
|
|
168
|
+
Z(["click"]);
|
|
131
169
|
export {
|
|
132
|
-
|
|
170
|
+
fe as SegmentedControl
|
|
133
171
|
};
|